NetworkManager r3528 - in trunk: . libnm-glib



Author: dcbw
Date: Thu Apr  3 19:19:19 2008
New Revision: 3528
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3528&view=rev

Log:
2008-04-03  Dan Williams  <dcbw redhat com>

	* 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()



Modified:
   trunk/ChangeLog
   trunk/libnm-glib/nm-settings.c
   trunk/libnm-glib/nm-settings.h

Modified: trunk/libnm-glib/nm-settings.c
==============================================================================
--- trunk/libnm-glib/nm-settings.c	(original)
+++ trunk/libnm-glib/nm-settings.c	Thu Apr  3 19:19:19 2008
@@ -143,31 +143,38 @@
                                                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;

Modified: trunk/libnm-glib/nm-settings.h
==============================================================================
--- trunk/libnm-glib/nm-settings.h	(original)
+++ trunk/libnm-glib/nm-settings.h	Thu Apr  3 19:19:19 2008
@@ -27,7 +27,7 @@
 	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 @@
 
 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);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]