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



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3225 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams
2008-01-09 18:27:23 +00:00
parent 925aa2ff3d
commit 2497bea1d2
7 changed files with 63 additions and 65 deletions

View File

@@ -1,3 +1,22 @@
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
2008-01-06 Dan Williams <dcbw@redhat.com>
* src/dhcp-manager/nm-dhcp-manager.c

View File

@@ -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 @@ nm_setting_gsm_new (void)
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;

View File

@@ -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 @@ nm_setting_serial_new (void)
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 @@ static void
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 */

View File

@@ -1148,13 +1148,6 @@ device_activation_precheck (NMDevice *self, NMConnection *connection, GError **e
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;

View File

@@ -102,10 +102,6 @@ struct _NMDeviceClass
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);

View File

@@ -474,31 +474,6 @@ real_get_generic_capabilities (NMDevice *dev)
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 @@ nm_gsm_device_class_init (NMGsmDeviceClass *klass)
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;

View File

@@ -907,33 +907,6 @@ real_deactivate_quickly (NMDevice *device)
nm_serial_device_close (self);
}
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)
{
@@ -977,7 +950,6 @@ nm_serial_device_class_init (NMSerialDeviceClass *klass)
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;