NetworkManager r3225 - in trunk: . libnm-util src



Author: dcbw
Date: Wed Jan  9 18:27:23 2008
New Revision: 3225
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3225&view=rev

Log:
2008-01-09  Dan Williams  <dcbw redhat com>

	* src/nm-device.c
	  src/nm-device.h
		- (device_activation_precheck, check_connection_complete): remove this
			virtual function; incomplete connections should be invalid by
			definition, complete-ness should be checked in the setting's
			verify function

	* src/nm-serial-device.c
	  src/nm-gsm-device.c
		- (real_check_connection_complete): remove

	* libnm-util/nm-setting-serial.c
		- (verify): new function; ensure there is a PPP setting too

	* libnm-util/nm-setting-gsm.c
		- (verify): ensure there is a serial setting too



Modified:
   trunk/ChangeLog
   trunk/libnm-util/nm-setting-gsm.c
   trunk/libnm-util/nm-setting-serial.c
   trunk/src/nm-device.c
   trunk/src/nm-device.h
   trunk/src/nm-gsm-device.c
   trunk/src/nm-serial-device.c

Modified: trunk/libnm-util/nm-setting-gsm.c
==============================================================================
--- trunk/libnm-util/nm-setting-gsm.c	(original)
+++ trunk/libnm-util/nm-setting-gsm.c	Wed Jan  9 18:27:23 2008
@@ -2,6 +2,7 @@
 
 #include <string.h>
 #include "nm-setting-gsm.h"
+#include "nm-setting-serial.h"
 #include "nm-utils.h"
 
 G_DEFINE_TYPE (NMSettingGsm, nm_setting_gsm, NM_TYPE_SETTING)
@@ -27,11 +28,27 @@
 	return (NMSetting *) g_object_new (NM_TYPE_SETTING_GSM, NULL);
 }
 
+static gint
+find_setting_by_name (gconstpointer a, gconstpointer b)
+{
+	NMSetting *setting = NM_SETTING (a);
+	const char *str = (const char *) b;
+
+	return strcmp (nm_setting_get_name (setting), str);
+}
+
 static gboolean
 verify (NMSetting *setting, GSList *all_settings)
 {
 	NMSettingGsm *self = NM_SETTING_GSM (setting);
 
+	/* Serial connections require a PPP setting */
+	if (all_settings && 
+	    !g_slist_find_custom (all_settings, NM_SETTING_SERIAL_SETTING_NAME, find_setting_by_name)) {
+		g_warning ("Missing serial setting");
+		return FALSE;
+	}
+
 	if (!self->number || strlen (self->number) < 1) {
 		nm_warning ("Missing phone number");
 		return FALSE;

Modified: trunk/libnm-util/nm-setting-serial.c
==============================================================================
--- trunk/libnm-util/nm-setting-serial.c	(original)
+++ trunk/libnm-util/nm-setting-serial.c	Wed Jan  9 18:27:23 2008
@@ -1,6 +1,9 @@
 /* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
 
+#include <string.h>
+
 #include "nm-setting-serial.h"
+#include "nm-setting-ppp.h"
 
 G_DEFINE_TYPE (NMSettingSerial, nm_setting_serial, NM_TYPE_SETTING)
 
@@ -21,6 +24,28 @@
 	return (NMSetting *) g_object_new (NM_TYPE_SETTING_SERIAL, NULL);
 }
 
+static gint
+find_setting_by_name (gconstpointer a, gconstpointer b)
+{
+	NMSetting *setting = NM_SETTING (a);
+	const char *str = (const char *) b;
+
+	return strcmp (nm_setting_get_name (setting), str);
+}
+
+static gboolean
+verify (NMSetting *setting, GSList *all_settings)
+{
+	/* Serial connections require a PPP setting */
+	if (all_settings && 
+	    !g_slist_find_custom (all_settings, NM_SETTING_PPP_SETTING_NAME, find_setting_by_name)) {
+		g_warning ("Missing PPP setting");
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
 static void
 nm_setting_serial_init (NMSettingSerial *setting)
 {
@@ -87,10 +112,12 @@
 nm_setting_serial_class_init (NMSettingSerialClass *setting_class)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
+	NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
 
 	/* virtual methods */
 	object_class->set_property = set_property;
 	object_class->get_property = get_property;
+	parent_class->verify       = verify;
 
 	/* Properties */
 

Modified: trunk/src/nm-device.c
==============================================================================
--- trunk/src/nm-device.c	(original)
+++ trunk/src/nm-device.c	Wed Jan  9 18:27:23 2008
@@ -1148,13 +1148,6 @@
 	g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
 	g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
 
-	if (   NM_DEVICE_GET_CLASS (self)->check_connection_complete
-	    && !NM_DEVICE_GET_CLASS (self)->check_connection_complete (self, connection, error)) {
-		/* connection is invalid */
-		g_assert (*error);
-		return FALSE;
-	}
-
 	if (nm_device_get_state (self) != NM_DEVICE_STATE_ACTIVATED)
 		return TRUE;
 

Modified: trunk/src/nm-device.h
==============================================================================
--- trunk/src/nm-device.h	(original)
+++ trunk/src/nm-device.h	Wed Jan  9 18:27:23 2008
@@ -102,10 +102,6 @@
 	                                            NMConnection *connection,
 	                                            NMConnection *system_connection);
 
-	gboolean    (* check_connection_complete) (NMDevice *self,
-	                                           NMConnection *connection,
-	                                           GError **error);
-
 	NMActStageReturn	(* act_stage1_prepare)	(NMDevice *self);
 	NMActStageReturn	(* act_stage2_config)	(NMDevice *self);
 	NMActStageReturn	(* act_stage3_ip_config_start) (NMDevice *self);

Modified: trunk/src/nm-gsm-device.c
==============================================================================
--- trunk/src/nm-gsm-device.c	(original)
+++ trunk/src/nm-gsm-device.c	Wed Jan  9 18:27:23 2008
@@ -474,31 +474,6 @@
 	return NM_DEVICE_CAP_NM_SUPPORTED;
 }
 
-static gboolean
-real_check_connection_complete (NMDevice *dev, NMConnection *connection, GError **error)
-{
-	NMSettingGsm *gsm;
-
-	gsm = (NMSettingGsm *) nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM);
-	if (!gsm) {
-		g_set_error (error,
-		             NM_DEVICE_INTERFACE_ERROR,
-		             NM_DEVICE_INTERFACE_ERROR_CONNECTION_INVALID,
-		             "%s", "Connection invalid: GSM setting not present");
-		return FALSE;
-	}
-
-	if (!gsm->number) {
-		g_set_error (error,
-		             NM_DEVICE_INTERFACE_ERROR,
-		             NM_DEVICE_INTERFACE_ERROR_CONNECTION_INVALID,
-		             "%s", "Connection invalid: Phone number not set");
-		return FALSE;
-	}
-
-	return NM_DEVICE_CLASS (nm_gsm_device_parent_class)->check_connection_complete (dev, connection, error);
-}
-
 static void
 real_connection_secrets_updated (NMDevice *dev,
                                  NMConnection *connection,
@@ -700,7 +675,6 @@
 	object_class->finalize = finalize;
 
 	device_class->get_generic_capabilities = real_get_generic_capabilities;
-	device_class->check_connection_complete = real_check_connection_complete;
 	device_class->act_stage1_prepare = real_act_stage1_prepare;
 	device_class->connection_secrets_updated = real_connection_secrets_updated;
 	device_class->deactivate_quickly = real_deactivate_quickly;

Modified: trunk/src/nm-serial-device.c
==============================================================================
--- trunk/src/nm-serial-device.c	(original)
+++ trunk/src/nm-serial-device.c	Wed Jan  9 18:27:23 2008
@@ -908,33 +908,6 @@
 }
 
 static gboolean
-real_check_connection_complete (NMDevice *dev, NMConnection *connection, GError **error)
-{
-	NMSettingSerial *serial;
-	NMSettingPPP *ppp;
-
-	serial = (NMSettingSerial *) nm_connection_get_setting (connection, NM_TYPE_SETTING_SERIAL);
-	if (!serial) {
-		g_set_error (error,
-		             NM_DEVICE_INTERFACE_ERROR,
-		             NM_DEVICE_INTERFACE_ERROR_CONNECTION_INVALID,
-		             "%s", "Connection invalid: serial setting not present");
-		return FALSE;
-	}
-
-	ppp = (NMSettingPPP *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPP);
-	if (!ppp) {
-		g_set_error (error,
-		             NM_DEVICE_INTERFACE_ERROR,
-		             NM_DEVICE_INTERFACE_ERROR_CONNECTION_INVALID,
-		             "%s", "Connection invalid: PPP setting not present");
-		return FALSE;
-	}
-
-	return NM_DEVICE_CLASS (nm_serial_device_parent_class)->check_connection_complete (dev, connection, error);
-}
-
-static gboolean
 real_is_up (NMDevice *device)
 {
 	/* Serial devices are always "up" */
@@ -977,7 +950,6 @@
 
 	parent_class->get_generic_capabilities = real_get_generic_capabilities;
 	parent_class->is_up = real_is_up;
-	parent_class->check_connection_complete = real_check_connection_complete;
 	parent_class->act_stage2_config = real_act_stage2_config;
 	parent_class->act_stage4_get_ip4_config = real_act_stage4_get_ip4_config;
 	parent_class->deactivate_quickly = real_deactivate_quickly;



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