From f934f0b1f71c832ebacb8255f8635175d160a95c Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 3 Apr 2008 18:19:19 +0000 Subject: [PATCH] 2008-04-03 Dan Williams * libnm-glib/nm-settings.c libnm-glib/nm-settings.h - (nm_exported_connection_get_id): new function - (impl_exported_connection_get_id): use nm_exported_connection_get_id() git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3528 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 7 +++++++ libnm-glib/nm-settings.c | 41 +++++++++++++++++++++++----------------- libnm-glib/nm-settings.h | 4 +++- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 609532d40b..3c3b481efa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-04-03 Dan Williams + + * libnm-glib/nm-settings.c + libnm-glib/nm-settings.h + - (nm_exported_connection_get_id): new function + - (impl_exported_connection_get_id): use nm_exported_connection_get_id() + 2008-04-02 Dan Williams * src/nm-device-interface.c diff --git a/libnm-glib/nm-settings.c b/libnm-glib/nm-settings.c index 8381c94d87..867b0deb27 100644 --- a/libnm-glib/nm-settings.c +++ b/libnm-glib/nm-settings.c @@ -143,31 +143,38 @@ typedef struct { NM_TYPE_EXPORTED_CONNECTION, \ NMExportedConnectionPrivate)) +const char * +nm_exported_connection_get_id (NMExportedConnection *connection) +{ + NMExportedConnectionPrivate *priv; + NMSettingConnection *s_con; + + g_return_val_if_fail (NM_IS_EXPORTED_CONNECTION (connection), NULL); + + priv = NM_EXPORTED_CONNECTION_GET_PRIVATE (connection); + if (EXPORTED_CONNECTION_CLASS (connection)->get_id) + return EXPORTED_CONNECTION_CLASS (connection)->get_id (connection); + + s_con = (NMSettingConnection *) nm_connection_get_setting (priv->wrapped, NM_TYPE_SETTING_CONNECTION); + if (NM_IS_SETTING_CONNECTION (s_con)) + return s_con->id; + + return NULL; +} static gboolean impl_exported_connection_get_id (NMExportedConnection *connection, gchar **id, GError **error) { - NMExportedConnectionPrivate *priv; - g_return_val_if_fail (NM_IS_EXPORTED_CONNECTION (connection), FALSE); - priv = NM_EXPORTED_CONNECTION_GET_PRIVATE (connection); - if (!EXPORTED_CONNECTION_CLASS (connection)->get_id) { - NMSettingConnection *s_con; - - s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (priv->wrapped, NM_TYPE_SETTING_CONNECTION)); - if (!s_con || !s_con->id) { - g_set_error (error, NM_SETTINGS_ERROR, 1, - "%s.%d - Invalid connection.", - __FILE__, __LINE__); - return FALSE; - } - - *id = g_strdup (s_con->id); - } else { - *id = EXPORTED_CONNECTION_CLASS (connection)->get_id (connection); + *id = (gchar *) nm_exported_connection_get_id (connection); + if (!*id) { + g_set_error (error, NM_SETTINGS_ERROR, 1, + "%s.%d - Could not get connection ID.", + __FILE__, __LINE__); + return FALSE; } return TRUE; diff --git a/libnm-glib/nm-settings.h b/libnm-glib/nm-settings.h index 232a21a276..49bd123a59 100644 --- a/libnm-glib/nm-settings.h +++ b/libnm-glib/nm-settings.h @@ -27,7 +27,7 @@ typedef struct { GObjectClass parent_class; /* virtual methods */ - gchar * (* get_id) (NMExportedConnection *connection); + const gchar *(* get_id) (NMExportedConnection *connection); GHashTable * (* get_settings) (NMExportedConnection *connection); void (* get_secrets) (NMExportedConnection *connection, const gchar *setting_name, @@ -48,6 +48,8 @@ void nm_exported_connection_register_object (NMExportedConnection *connection, NMConnection *nm_exported_connection_get_connection (NMExportedConnection *connection); +const char *nm_exported_connection_get_id (NMExportedConnection *connection); + void nm_exported_connection_signal_updated (NMExportedConnection *connection, GHashTable *settings); void nm_exported_connection_signal_removed (NMExportedConnection *connection);