2007-08-13 Rodrigo Moya <rodrigo@gnome-db.org>

* include/NetworkManager.h: added DBus path for connection settings.

	* libnm-glib/nm-settings.[ch] (nm_settings_signal_new_connection,
	nm_connection_settings_signal_updated,
	nm_connection_settings_signal_removed): new functions to wrap the
	objects' signals.
	(nm_connection_settings_init): register GObject with DBus.
	(nm_connection_settings_get_dbus_object_path): new function.

	* libnm-glib/Makefile.am: added libnmutil to link flags.

git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2672 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Rodrigo Moya 2007-08-13 13:07:33 +00:00
parent 8bc21a93d5
commit 3cd8398aee
5 changed files with 87 additions and 2 deletions

View file

@ -1,3 +1,16 @@
2007-08-13 Rodrigo Moya <rodrigo@gnome-db.org>
* include/NetworkManager.h: added DBus path for connection settings.
* libnm-glib/nm-settings.[ch] (nm_settings_signal_new_connection,
nm_connection_settings_signal_updated,
nm_connection_settings_signal_removed): new functions to wrap the
objects' signals.
(nm_connection_settings_init): register GObject with DBus.
(nm_connection_settings_get_dbus_object_path): new function.
* libnm-glib/Makefile.am: added libnmutil to link flags.
2007-08-13 Tambet Ingo <tambet@gmail.com>
* configure.in: Remove checks for dhcdbd as it's killed! killed! killed!

View file

@ -36,6 +36,8 @@
#define NM_DBUS_PATH_ACCESS_POINT "/org/freedesktop/NetworkManager/AccessPoint"
#define NM_DBUS_INTERFACE_ACCESS_POINT "org.freedesktop.NetworkManager.AccessPoint"
#define NM_DBUS_PATH_CONNECTION_SETTINGS "/org/freedesktop/NetworkManager/Settings/Connection"
#define NMI_DBUS_SERVICE "org.freedesktop.NetworkManagerInfo"
#define NMI_DBUS_PATH "/org/freedesktop/NetworkManagerInfo"
#define NMI_DBUS_INTERFACE "org.freedesktop.NetworkManagerInfo"

View file

@ -1,4 +1,4 @@
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/libnm-util
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/utils -I$(top_srcdir)/libnm-util
BUILT_SOURCES = \
nm-access-point-bindings.h \
@ -49,6 +49,7 @@ libnm_glib_la_SOURCES = \
nm-marshal-main.c
libnm_glib_la_LIBADD = \
$(top_builddir)/utils/libnmutils.la \
$(top_builddir)/libnm-util/libnm-util.la \
$(GLIB_LIBS) \
$(GTHREAD_LIBS) \

View file

@ -1,3 +1,5 @@
#include <NetworkManager.h>
#include <nm-utils.h>
#include "nm-settings.h"
static GError *
@ -94,6 +96,15 @@ nm_settings_class_init (NMSettingsClass *settings_class)
&dbus_glib_nm_settings_object_info);
}
void
nm_settings_signal_new_connection (NMSettings *settings, NMConnectionSettings *connection)
{
g_return_if_fail (NM_IS_SETTINGS (settings));
g_return_if_fail (NM_IS_CONNECTION_SETTINGS (connection));
g_signal_emit (settings, settings_signals[S_NEW_CONNECTION], 0, connection);
}
/*
* NMConnectionSettings implementation
*/
@ -179,6 +190,22 @@ impl_connection_settings_get_secrets (NMConnectionSettings *connection,
static void
nm_connection_settings_init (NMConnectionSettings *connection)
{
DBusGConnection *bus_connection;
GError *error = NULL;
/* register object with DBus */
bus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (!bus_connection) {
g_warning ("Couldn't connect to session bus: %s", error->message);
g_error_free (error);
} else {
gchar *path;
path = nm_connection_settings_get_dbus_object_path (connection);
dbus_g_connection_register_g_object (bus_connection, path, G_OBJECT (connection));
g_free (path);
}
}
static void
@ -221,3 +248,39 @@ nm_connection_settings_class_init (NMConnectionSettingsClass *connection_setting
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (connection_settings_class),
&dbus_glib_nm_connection_settings_object_info);
}
gchar *
nm_connection_settings_get_dbus_object_path (NMConnectionSettings *connection)
{
gchar *object_path, *escaped_object_path, *id;
g_return_val_if_fail (NM_IS_CONNECTION_SETTINGS (connection), NULL);
if (!CONNECTION_SETTINGS_CLASS (connection)->get_id)
return NULL;
id = CONNECTION_SETTINGS_CLASS (connection)->get_id (connection);
object_path = g_strdup_printf ("%s/%s", NM_DBUS_PATH_CONNECTION_SETTINGS, id);
escaped_object_path = nm_dbus_escape_object_path ((const gchar *) object_path);
g_free (object_path);
g_free (id);
return escaped_object_path;
}
void
nm_connection_settings_signal_updated (NMConnectionSettings *connection, GHashTable *settings)
{
g_return_if_fail (NM_IS_CONNECTION_SETTINGS (connection));
g_signal_emit (connection, connection_signals[CS_UPDATED], 0, settings);
}
void
nm_connection_settings_signal_removed (NMConnectionSettings *connection)
{
g_return_if_fail (NM_IS_CONNECTION_SETTINGS (connection));
g_signal_emit (connection, connection_signals[CS_REMOVED], 0);
}

View file

@ -30,7 +30,11 @@ typedef struct {
void (* removed) (NMConnectionSettings *connection);
} NMConnectionSettingsClass;
GType nm_connection_settings_get_type (void);
GType nm_connection_settings_get_type (void);
gchar *nm_connection_settings_get_dbus_object_path (NMConnectionSettings *connection);
void nm_connection_settings_signal_updated (NMConnectionSettings *connection, GHashTable *settings);
void nm_connection_settings_signal_removed (NMConnectionSettings *connection);
#define NM_TYPE_SETTINGS (nm_settings_get_type ())
#define NM_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS, NMSettings))
@ -55,6 +59,8 @@ typedef struct {
GType nm_settings_get_type (void);
void nm_settings_signal_new_connection (NMSettings *settings, NMConnectionSettings *connection);
G_END_DECLS
#endif