Commit 0d69dfe3 authored by Dan Williams's avatar Dan Williams

libnm-glib: implement new settings interfaces

The old NMExportedConnection was used for both client and server-side classes,
which was a mistake and made the code very complicated to follow.  Additionally,
all PolicyKit operations were synchronous, and PK operations can block for a
long time (ie for user input) before returning, so they need to be async.  But
NMExportedConnection and NMSysconfigConnection didn't allow for async PK ops
at all.

Use this opportunity to clean up the mess and create GInterfaces that both
server and client objects implement, so that the connection editor and applet
can operate on generic objects like they did before (using the interfaces) but
can perform specific operations (like async PK verification of callers) depending
on whether they are local or remote or whatever.
parent 8f0652a9
......@@ -212,42 +212,10 @@ PKG_CHECK_MODULES(UUID, uuid)
AC_SUBST(UUID_CFLAGS)
AC_SUBST(UUID_LIBS)
PKG_CHECK_MODULES(POLKIT, polkit-dbus)
##### Find out the version of PolicyKit we're using
polkit_version=`pkg-config --modversion polkit`
POLKIT_VERSION_MAJOR=`echo $polkit_version | awk -F. '{print $1}'`
POLKIT_VERSION_MINOR=`echo $polkit_version | awk -F. '{print $2}'`
POLKIT_VERSION_MICRO=`echo $polkit_version | awk -F. '{print $3}'`
if test "z$POLKIT_VERSION_MAJOR" = "z"; then
POLKIT_VERSION_MAJOR="0"
fi
if test "z$POLKIT_VERSION_MINOR" = "z"; then
POLKIT_VERSION_MINOR="0"
fi
if test "z$POLKIT_VERSION_MICRO" = "z"; then
POLKIT_VERSION_MICRO="0"
fi
PKG_CHECK_MODULES(POLKIT, polkit-gobject-1)
if test "z$POLKIT_VERSION_MAJOR" = "z0" -a "z$POLKIT_VERSION_MINOR" = "z0" -a "z$POLKIT_VERSION_MICRO" = "z0"; then
echo "Error: Couldn't determine the version of your PolicyKit package."
echo " This is probably an error in this script, please report it"
echo " along with the following information:"
echo " Base PolicyKit version ='$polkit_version'"
echo " POLKIT_VERSION_MAJOR='$POLKIT_VERSION_MAJOR'"
echo " POLKIT_VERSION_MINOR='$POLKIT_VERSION_MINOR'"
echo " POLKIT_VERSION_MICRO='$POLKIT_VERSION_MICRO'"
exit 1
else
echo "Your PolicyKit version is $POLKIT_VERSION_MAJOR,$POLKIT_VERSION_MINOR,$POLKIT_VERSION_MICRO."
POLKIT_CFLAGS="$POLKIT_CFLAGS -DPOLKIT_VERSION_MAJOR=$POLKIT_VERSION_MAJOR"
POLKIT_CFLAGS="$POLKIT_CFLAGS -DPOLKIT_VERSION_MINOR=$POLKIT_VERSION_MINOR"
POLKIT_CFLAGS="$POLKIT_CFLAGS -DPOLKIT_VERSION_MICRO=$POLKIT_VERSION_MICRO"
fi
AC_SUBST(POLKIT_CFLAGS)
AC_PATH_PROG([POLKIT_POLICY_FILE_VALIDATE], [polkit-policy-file-validate], [false])
AC_ARG_WITH(crypto, AS_HELP_STRING([--with-crypto=nss | gnutls], [Cryptography library to use for certificate and key operations]),ac_crypto=$withval, ac_crypto=nss)
with_nss=no
......
......@@ -8,7 +8,7 @@
<method name="AddConnection">
<tp:docstring>
Add new connection.
DEPRECATED. Adds new connection.
</tp:docstring>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_add_connection"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
......
......@@ -18,9 +18,22 @@
</arg>
</method>
<method name="AddConnection">
<tp:docstring>
Add new connection.
</tp:docstring>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_add_connection"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg name="connection" type="a{sa{sv}}" direction="in">
<tp:docstring>
Connection settings and properties.
</tp:docstring>
</arg>
</method>
<signal name="NewConnection">
<tp:docstring>
Emitted when a new connection has been configured.
Emitted when a new connection has been added.
</tp:docstring>
<arg name="connection" type="o">
<tp:docstring>
......
......@@ -41,7 +41,6 @@ libnminclude_HEADERS = \
nm-device-bt.h \
nm-access-point.h \
nm-ip4-config.h \
nm-settings.h \
nm-gsm-device.h \
nm-cdma-device.h \
nm-serial-device.h \
......@@ -50,10 +49,15 @@ libnminclude_HEADERS = \
nm-vpn-plugin-ui-interface.h \
nm-types.h \
nm-active-connection.h \
nm-dbus-connection.h \
nm-dbus-settings.h \
nm-dbus-settings-system.h \
nm-dhcp4-config.h
nm-dhcp4-config.h \
nm-remote-connection.h \
nm-settings-interface.h \
nm-settings-system-interface.h \
nm-remote-settings.h \
nm-remote-settings-system.h \
nm-settings-connection-interface.h \
nm-exported-connection.h \
nm-settings-service.h
libnm_glib_la_SOURCES = \
libnm_glib.c \
......@@ -69,7 +73,6 @@ libnm_glib_la_SOURCES = \
nm-device-bt.c \
nm-access-point.c \
nm-ip4-config.c \
nm-settings.c \
nm-gsm-device.c \
nm-cdma-device.c \
nm-serial-device.c \
......@@ -79,10 +82,15 @@ libnm_glib_la_SOURCES = \
nm-object-cache.c \
nm-object-cache.h \
nm-active-connection.c \
nm-dbus-connection.c \
nm-dbus-settings.c \
nm-dbus-settings-system.c \
nm-dhcp4-config.c
nm-dhcp4-config.c \
nm-remote-connection.c \
nm-settings-interface.c \
nm-settings-system-interface.c \
nm-remote-settings.c \
nm-remote-settings-system.c \
nm-settings-connection-interface.c \
nm-exported-connection.c \
nm-settings-service.c
libnm_glib_la_LIBADD = \
$(top_builddir)/libnm-util/libnm-util.la \
......
......@@ -40,8 +40,6 @@ global:
nm_client_wireless_get_enabled;
nm_client_wireless_hardware_get_enabled;
nm_client_wireless_set_enabled;
nm_dbus_connection_get_type;
nm_dbus_connection_new;
nm_dbus_settings_get_connection_by_path;
nm_dbus_settings_get_type;
nm_dbus_settings_new;
......@@ -85,14 +83,9 @@ global:
nm_dhcp4_config_get_options;
nm_dhcp4_config_get_type;
nm_dhcp4_config_new;
nm_exported_connection_delete;
nm_exported_connection_get_connection;
nm_exported_connection_export;
nm_exported_connection_get_type;
nm_exported_connection_new;
nm_exported_connection_register_object;
nm_exported_connection_signal_removed;
nm_exported_connection_signal_updated;
nm_exported_connection_update;
nm_gsm_device_get_type;
nm_gsm_device_new;
nm_ip4_config_get_addresses;
......@@ -107,9 +100,31 @@ global:
nm_object_get_connection;
nm_object_get_path;
nm_object_get_type;
nm_remote_connection_get_type;
nm_remote_connection_new;
nm_remote_settings_get_type;
nm_remote_settings_new;
nm_remote_settings_system_get_type;
nm_remote_settings_system_new;
nm_serial_device_get_bytes_received;
nm_serial_device_get_bytes_sent;
nm_serial_device_get_type;
nm_settings_connection_interface_delete;
nm_settings_connection_interface_emit_updated;
nm_settings_connection_interface_get_secrets;
nm_settings_connection_interface_get_type;
nm_settings_connection_interface_update;
nm_settings_interface_add_connection;
nm_settings_interface_error_quark;
nm_settings_interface_get_connection_by_path;
nm_settings_interface_get_type;
nm_settings_interface_list_connections;
nm_settings_service_export;
nm_settings_service_get_connection_by_path;
nm_settings_service_get_type;
nm_settings_system_interface_get_type;
nm_settings_system_interface_add_connection;
nm_settings_system_interface_save_hostname;
nm_settings_error_quark;
nm_settings_get_type;
nm_settings_list_connections;
......
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* libnm_glib -- Access network status & information from glib applications
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2008 Novell, Inc.
* Copyright (C) 2008 Red Hat, Inc.
*/
#include <string.h>
#include <NetworkManager.h>
#include <nm-dbus-glib-types.h>
#include "nm-dbus-connection.h"
#include "nm-exported-connection-bindings.h"
#include "nm-utils.h"
G_DEFINE_TYPE (NMDBusConnection, nm_dbus_connection, NM_TYPE_EXPORTED_CONNECTION)
#define NM_DBUS_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DBUS_CONNECTION, NMDBusConnectionPrivate))
typedef struct {
DBusGConnection *dbus_connection;
NMConnectionScope scope;
char *path;
DBusGProxy *proxy;
gboolean disposed;
} NMDBusConnectionPrivate;
enum {
PROP_0,
PROP_BUS,
PROP_SCOPE,
PROP_PATH,
LAST_PROP
};
NMDBusConnection *
nm_dbus_connection_new (DBusGConnection *dbus_connection,
NMConnectionScope scope,
const char *path)
{
g_return_val_if_fail (dbus_connection != NULL, NULL);
g_return_val_if_fail (scope != NM_CONNECTION_SCOPE_UNKNOWN, NULL);
g_return_val_if_fail (path != NULL, NULL);
return (NMDBusConnection *) g_object_new (NM_TYPE_DBUS_CONNECTION,
NM_DBUS_CONNECTION_BUS, dbus_connection,
NM_DBUS_CONNECTION_SCOPE, scope,
NM_DBUS_CONNECTION_PATH, path,
NULL);
}
static GHashTable *
get_settings (NMExportedConnection *exported)
{
return nm_connection_to_hash (nm_exported_connection_get_connection (exported));
}
static gboolean
update (NMExportedConnection *exported, GHashTable *new_settings, GError **err)
{
NMDBusConnectionPrivate *priv = NM_DBUS_CONNECTION_GET_PRIVATE (exported);
return org_freedesktop_NetworkManagerSettings_Connection_update (priv->proxy, new_settings, err);
}
static gboolean
do_delete (NMExportedConnection *exported, GError **err)
{
NMDBusConnectionPrivate *priv = NM_DBUS_CONNECTION_GET_PRIVATE (exported);
return org_freedesktop_NetworkManagerSettings_Connection_delete (priv->proxy, err);
}
static void
connection_updated_cb (DBusGProxy *proxy, GHashTable *settings, gpointer user_data)
{
NMExportedConnection *exported = NM_EXPORTED_CONNECTION (user_data);
NMConnection *wrapped;
GError *error = NULL;
wrapped = nm_exported_connection_get_connection (exported);
if (nm_connection_replace_settings (wrapped, settings, &error))
nm_exported_connection_signal_updated (exported, settings);
else {
g_warning ("%s: '%s' / '%s' invalid: %d",
__func__,
error ? g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)) : "(none)",
(error && error->message) ? error->message : "(none)",
error ? error->code : -1);
g_clear_error (&error);
nm_exported_connection_signal_removed (exported);
}
}
static void
connection_removed_cb (DBusGProxy *proxy, gpointer user_data)
{
nm_exported_connection_signal_removed (NM_EXPORTED_CONNECTION (user_data));
}
/* GObject */
static void
nm_dbus_connection_init (NMDBusConnection *connection)
{
}
static GObject *
constructor (GType type,
guint n_construct_params,
GObjectConstructParam *construct_params)
{
GObject *object;
NMDBusConnectionPrivate *priv;
NMConnection *wrapped;
const char *service;
GHashTable *settings = NULL;
GError *error = NULL;
object = G_OBJECT_CLASS (nm_dbus_connection_parent_class)->constructor (type, n_construct_params, construct_params);
if (!object)
return NULL;
priv = NM_DBUS_CONNECTION_GET_PRIVATE (object);
if (!priv->dbus_connection) {
nm_warning ("DBusGConnection not provided.");
goto err;
}
if (!priv->path)
nm_warning ("DBus path not provided.");
service = (priv->scope == NM_CONNECTION_SCOPE_SYSTEM) ?
NM_DBUS_SERVICE_SYSTEM_SETTINGS : NM_DBUS_SERVICE_USER_SETTINGS;
priv->proxy = dbus_g_proxy_new_for_name (priv->dbus_connection,
service,
priv->path,
NM_DBUS_IFACE_SETTINGS_CONNECTION);
if (!org_freedesktop_NetworkManagerSettings_Connection_get_settings (priv->proxy, &settings, &error)) {
nm_warning ("Can not retrieve settings: %s", error->message);
g_error_free (error);
goto err;
}
wrapped = nm_connection_new_from_hash (settings, &error);
g_hash_table_destroy (settings);
if (!wrapped) {
nm_warning ("Invalid connection: '%s' / '%s' invalid: %d",
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
error->message,
error->code);
g_error_free (error);
goto err;
}
nm_connection_set_scope (wrapped, priv->scope);
nm_connection_set_path (wrapped, priv->path);
g_object_set (object, NM_EXPORTED_CONNECTION_CONNECTION, wrapped, NULL);
g_object_unref (wrapped);
dbus_g_proxy_add_signal (priv->proxy, "Updated",
DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT,
G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->proxy, "Updated",
G_CALLBACK (connection_updated_cb),
object, NULL);
dbus_g_proxy_add_signal (priv->proxy, "Removed", G_TYPE_INVALID, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->proxy, "Removed",
G_CALLBACK (connection_removed_cb),
object, NULL);
return object;
err:
g_object_unref (object);
return NULL;
}
static void
dispose (GObject *object)
{
NMDBusConnectionPrivate *priv = NM_DBUS_CONNECTION_GET_PRIVATE (object);
if (priv->disposed)
return;
priv->disposed = TRUE;
g_object_unref (priv->proxy);
dbus_g_connection_unref (priv->dbus_connection);
G_OBJECT_CLASS (nm_dbus_connection_parent_class)->dispose (object);
}
static void
finalize (GObject *object)
{
NMDBusConnectionPrivate *priv = NM_DBUS_CONNECTION_GET_PRIVATE (object);
g_free (priv->path);
G_OBJECT_CLASS (nm_dbus_connection_parent_class)->finalize (object);
}
static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
NMDBusConnectionPrivate *priv = NM_DBUS_CONNECTION_GET_PRIVATE (object);
switch (prop_id) {
case PROP_BUS:
/* Construct only */
priv->dbus_connection = dbus_g_connection_ref ((DBusGConnection *) g_value_get_boxed (value));
break;
case PROP_SCOPE:
/* Construct only */
priv->scope = (NMConnectionScope) g_value_get_uint (value);
break;
case PROP_PATH:
/* Construct only */
priv->path = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMDBusConnectionPrivate *priv = NM_DBUS_CONNECTION_GET_PRIVATE (object);
switch (prop_id) {
case PROP_BUS:
g_value_set_boxed (value, priv->dbus_connection);
break;
case PROP_SCOPE:
g_value_set_uint (value, priv->scope);
break;
case PROP_PATH:
g_value_set_string (value, priv->path);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
nm_dbus_connection_class_init (NMDBusConnectionClass *dbus_connection_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (dbus_connection_class);
NMExportedConnectionClass *connection_class = NM_EXPORTED_CONNECTION_CLASS (dbus_connection_class);
g_type_class_add_private (dbus_connection_class, sizeof (NMDBusConnectionPrivate));
/* Virtual methods */
object_class->constructor = constructor;
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->dispose = dispose;
object_class->finalize = finalize;
connection_class->get_settings = get_settings;
connection_class->update = update;
connection_class->do_delete = do_delete;
/* Properties */
g_object_class_install_property
(object_class, PROP_BUS,
g_param_spec_boxed (NM_DBUS_CONNECTION_BUS,
"DBusGConnection",
"DBusGConnection",
DBUS_TYPE_G_CONNECTION,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property
(object_class, PROP_SCOPE,
g_param_spec_uint (NM_DBUS_CONNECTION_SCOPE,
"Scope",
"NMConnection scope",
NM_CONNECTION_SCOPE_UNKNOWN,
NM_CONNECTION_SCOPE_USER,
NM_CONNECTION_SCOPE_UNKNOWN,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property
(object_class, PROP_PATH,
g_param_spec_string (NM_DBUS_CONNECTION_PATH,
"DBus path",
"DBus path",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager system settings service
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2009 Red Hat, Inc.
*/
#ifndef NM_EXPORTED_CONNECTION_H
#define NM_EXPORTED_CONNECTION_H
#include <nm-connection.h>
#include <dbus/dbus-glib.h>
G_BEGIN_DECLS
#define NM_TYPE_EXPORTED_CONNECTION (nm_exported_connection_get_type ())
#define NM_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_EXPORTED_CONNECTION, NMExportedConnection))
#define NM_EXPORTED_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_EXPORTED_CONNECTION, NMExportedConnectionClass))
#define NM_IS_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_EXPORTED_CONNECTION))
#define NM_IS_EXPORTED_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_EXPORTED_CONNECTION))
#define NM_EXPORTED_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_EXPORTED_CONNECTION, NMExportedConnectionClass))
#define NM_EXPORTED_CONNECTION_BUS "bus"
typedef struct {
NMConnection parent;
} NMExportedConnection;
typedef struct {
NMConnectionClass parent;
GHashTable * (*get_settings) (NMExportedConnection *self,
GError **error);
void (*update) (NMExportedConnection *self,
GHashTable *new_settings,
DBusGMethodInvocation *context);
void (*delete) (NMExportedConnection *self,
DBusGMethodInvocation *context);
void (*get_secrets) (NMExportedConnection *self,
const gchar *setting_name,
const gchar **hints,
gboolean request_new,
DBusGMethodInvocation *context);
} NMExportedConnectionClass;
GType nm_exported_connection_get_type (void);
NMExportedConnection *nm_exported_connection_new (DBusGConnection *bus,
NMConnectionScope scope);
void nm_exported_connection_export (NMExportedConnection *self);
G_END_DECLS
#endif /* NM_EXPORTED_CONNECTION_H */
This diff is collapsed.
......@@ -17,54 +17,41 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2008 Novell, Inc.
* Copyright (C) 2008 Red Hat, Inc.
* Copyright (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2007 - 2009 Red Hat, Inc.
*/
#ifndef NM_DBUS_SETTINGS_SYSTEM_H
#define NM_DBUS_SETTINGS_SYSTEM_H
#ifndef __NM_REMOTE_CONNECTION_H__
#define __NM_REMOTE_CONNECTION_H__
#include <nm-dbus-settings.h>
#include <glib-object.h>
#include <dbus/dbus-glib.h>
G_BEGIN_DECLS
#include <nm-connection.h>
#define NM_TYPE_DBUS_SETTINGS_SYSTEM (nm_dbus_settings_system_get_type ())
#define NM_DBUS_SETTINGS_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DBUS_SETTINGS_SYSTEM, NMDBusSettingsSystem))
#define NM_DBUS_SETTINGS_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DBUS_SETTINGS_SYSTEM, NMDBusSettingsSystemClass))
#define NM_IS_DBUS_SETTINGS_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DBUS_SETTINGS_SYSTEM))
#define NM_IS_DBUS_SETTINGS_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_DBUS_SETTINGS_SYSTEM))
#define NM_DBUS_SETTINGS_SYSTEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DBUS_SETTINGS_SYSTEM, NMDBusSettingsSystemClass))
G_BEGIN_DECLS
#define NM_DBUS_SETTINGS_SYSTEM_UNMANAGED_DEVICES "unmanaged-devices"
#define NM_DBUS_SETTINGS_SYSTEM_HOSTNAME "hostname"
#define NM_DBUS_SETTINGS_SYSTEM_CAN_MODIFY "can-modify"
#define NM_TYPE_REMOTE_CONNECTION (nm_remote_connection_get_type ())
#define NM_REMOTE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_REMOTE_CONNECTION, NMRemoteConnection))
#define NM_REMOTE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_REMOTE_CONNECTION, NMRemoteConnectionClass))
#define NM_IS_REMOTE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_REMOTE_CONNECTION))
#define NM_IS_REMOTE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_REMOTE_CONNECTION))
#define NM_REMOTE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_REMOTE_CONNECTION, NMRemoteConnectionClass))
typedef struct {
NMDBusSettings parent;
} NMDBusSettingsSystem;
NMConnection parent;
} NMRemoteConnection;
typedef struct {
NMDBusSettingsClass parent;
} NMDBusSettingsSystemClass;
GType nm_dbus_settings_system_get_type (void);
NMDBusSettingsSystem *nm_dbus_settings_system_new (DBusGConnection *dbus_connection);
gboolean nm_dbus_settings_system_add_connection (NMDBusSettingsSystem *self,
NMConnection *connection,
GError **err);
NMConnectionClass parent_class;
} NMRemoteConnectionClass;
GSList *nm_dbus_settings_system_get_unmanaged_devices (NMDBusSettingsSystem *self);
const char *nm_dbus_settings_system_get_hostname (NMDBusSettingsSystem *self);
gboolean nm_dbus_settings_system_save_hostname (NMDBusSettingsSystem *self,
const char *hostname,
GError **err);
gboolean nm_dbus_settings_system_get_can_modify (NMDBusSettingsSystem *self);
GType nm_remote_connection_get_type (void);
NMRemoteConnection *nm_remote_connection_new (DBusGConnection *dbus_connection,
NMConnectionScope scope,
const char *path);
G_END_DECLS
#endif /* NM_DBUS_SETTINGS_SYSTEM_H */
#endif /* __NM_REMOTE_CONNECTION__ */
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* libnm_glib -- Access network status & information from glib applications
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2008 Novell, Inc.
* Copyright (C) 2009 Red Hat, Inc.
*/
#include <string.h>
#include <NetworkManager.h>
#include <nm-connection.h>
#include "nm-marshal.h"
#include "nm-dbus-glib-types.h"
#include "nm-remote-settings-system.h"
#include "nm-settings-system-bindings.h"
#include "nm-settings-system-interface.h"
static void settings_system_interface_init (NMSettingsSystemInterface *klass);
G_DEFINE_TYPE_EXTENDED (NMRemoteSettingsSystem, nm_remote_settings_system, NM_TYPE_REMOTE_SETTINGS, 0,
G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_SYSTEM_INTERFACE, settings_system_interface_init))
#define NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_REMOTE_SETTINGS_SYSTEM, NMRemoteSettingsSystemPrivate))
typedef struct {
DBusGProxy *proxy;
DBusGProxy *props_proxy;
char *hostname;
gboolean can_modify;
gboolean disposed;
} NMRemoteSettingsSystemPrivate;
static void
properties_changed_cb (DBusGProxy *proxy,
GHashTable *properties,
gpointer user_data)
{
NMRemoteSettingsSystem *self = NM_REMOTE_SETTINGS_SYSTEM (user_data);
NMRemoteSettingsSystemPrivate *priv = NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE (self);
GHashTableIter iter;
gpointer key, tmp;