NetworkManager r4218 - in trunk: . libnm-util src src/ppp-manager
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r4218 - in trunk: . libnm-util src src/ppp-manager
- Date: Sun, 26 Oct 2008 17:21:02 +0000 (UTC)
Author: dcbw
Date: Sun Oct 26 17:21:01 2008
New Revision: 4218
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=4218&view=rev
Log:
2008-10-26 Dan Williams <dcbw redhat com>
Patch from Tambet Ingo <tambet gmail com>
* libnm-util/libnm-util.ver
libnm-util/nm-setting-cdma.c
libnm-util/nm-setting-cdma.h
- Make properties private and add accessor functions
* src/nm-cdma-device.c
src/ppp-manager/nm-ppp-manager.c
- Use those accessors
Modified:
trunk/ChangeLog
trunk/libnm-util/libnm-util.ver
trunk/libnm-util/nm-setting-cdma.c
trunk/libnm-util/nm-setting-cdma.h
trunk/src/nm-cdma-device.c
trunk/src/ppp-manager/nm-ppp-manager.c
Modified: trunk/libnm-util/libnm-util.ver
==============================================================================
--- trunk/libnm-util/libnm-util.ver (original)
+++ trunk/libnm-util/libnm-util.ver Sun Oct 26 17:21:01 2008
@@ -40,6 +40,9 @@
nm_setting_cdma_error_quark;
nm_setting_cdma_get_type;
nm_setting_cdma_new;
+ nm_setting_cdma_get_number;
+ nm_setting_cdma_get_username;
+ nm_setting_cdma_get_password;
nm_setting_clear_secrets;
nm_setting_compare;
nm_setting_connection_error_get_type;
Modified: trunk/libnm-util/nm-setting-cdma.c
==============================================================================
--- trunk/libnm-util/nm-setting-cdma.c (original)
+++ trunk/libnm-util/nm-setting-cdma.c Sun Oct 26 17:21:01 2008
@@ -64,6 +64,14 @@
G_DEFINE_TYPE (NMSettingCdma, nm_setting_cdma, NM_TYPE_SETTING)
+#define NM_SETTING_CDMA_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_CDMA, NMSettingCdmaPrivate))
+
+typedef struct {
+ char *number; /* For dialing, duh */
+ char *username;
+ char *password;
+} NMSettingCdmaPrivate;
+
enum {
PROP_0,
PROP_NUMBER,
@@ -79,6 +87,30 @@
return (NMSetting *) g_object_new (NM_TYPE_SETTING_CDMA, NULL);
}
+const char *
+nm_setting_cdma_get_number (NMSettingCdma *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_CDMA (setting), NULL);
+
+ return NM_SETTING_CDMA_GET_PRIVATE (setting)->number;
+}
+
+const char *
+nm_setting_cdma_get_username (NMSettingCdma *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_CDMA (setting), NULL);
+
+ return NM_SETTING_CDMA_GET_PRIVATE (setting)->username;
+}
+
+const char *
+nm_setting_cdma_get_password (NMSettingCdma *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_CDMA (setting), NULL);
+
+ return NM_SETTING_CDMA_GET_PRIVATE (setting)->password;
+}
+
static gint
find_setting_by_name (gconstpointer a, gconstpointer b)
{
@@ -91,7 +123,7 @@
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
- NMSettingCdma *self = NM_SETTING_CDMA (setting);
+ NMSettingCdmaPrivate *priv = NM_SETTING_CDMA_GET_PRIVATE (setting);
/* Serial connections require a PPP setting */
if (all_settings &&
@@ -103,13 +135,13 @@
return FALSE;
}
- if (!self->number) {
+ if (!priv->number) {
g_set_error (error,
NM_SETTING_CDMA_ERROR,
NM_SETTING_CDMA_ERROR_MISSING_PROPERTY,
NM_SETTING_CDMA_NUMBER);
return FALSE;
- } else if (!strlen (self->number)) {
+ } else if (!strlen (priv->number)) {
g_set_error (error,
NM_SETTING_CDMA_ERROR,
NM_SETTING_CDMA_ERROR_INVALID_PROPERTY,
@@ -117,7 +149,7 @@
return FALSE;
}
- if (self->username && !strlen (self->username)) {
+ if (priv->username && !strlen (priv->username)) {
g_set_error (error,
NM_SETTING_CDMA_ERROR,
NM_SETTING_CDMA_ERROR_INVALID_PROPERTY,
@@ -125,7 +157,7 @@
return FALSE;
}
- if (self->password && !strlen (self->password)) {
+ if (priv->password && !strlen (priv->password)) {
g_set_error (error,
NM_SETTING_CDMA_ERROR,
NM_SETTING_CDMA_ERROR_INVALID_PROPERTY,
@@ -139,13 +171,13 @@
static GPtrArray *
need_secrets (NMSetting *setting)
{
- NMSettingCdma *self = NM_SETTING_CDMA (setting);
+ NMSettingCdmaPrivate *priv = NM_SETTING_CDMA_GET_PRIVATE (setting);
GPtrArray *secrets = NULL;
- if (self->password)
+ if (priv->password)
return NULL;
- if (self->username) {
+ if (priv->username) {
secrets = g_ptr_array_sized_new (1);
g_ptr_array_add (secrets, NM_SETTING_CDMA_PASSWORD);
}
@@ -162,11 +194,11 @@
static void
finalize (GObject *object)
{
- NMSettingCdma *self = NM_SETTING_CDMA (object);
+ NMSettingCdmaPrivate *priv = NM_SETTING_CDMA_GET_PRIVATE (object);
- g_free (self->number);
- g_free (self->username);
- g_free (self->password);
+ g_free (priv->number);
+ g_free (priv->username);
+ g_free (priv->password);
G_OBJECT_CLASS (nm_setting_cdma_parent_class)->finalize (object);
}
@@ -175,20 +207,20 @@
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
- NMSettingCdma *setting = NM_SETTING_CDMA (object);
+ NMSettingCdmaPrivate *priv = NM_SETTING_CDMA_GET_PRIVATE (object);
switch (prop_id) {
case PROP_NUMBER:
- g_free (setting->number);
- setting->number = g_value_dup_string (value);
+ g_free (priv->number);
+ priv->number = g_value_dup_string (value);
break;
case PROP_USERNAME:
- g_free (setting->username);
- setting->username = g_value_dup_string (value);
+ g_free (priv->username);
+ priv->username = g_value_dup_string (value);
break;
case PROP_PASSWORD:
- g_free (setting->password);
- setting->password = g_value_dup_string (value);
+ g_free (priv->password);
+ priv->password = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -204,13 +236,13 @@
switch (prop_id) {
case PROP_NUMBER:
- g_value_set_string (value, setting->number);
+ g_value_set_string (value, nm_setting_cdma_get_number (setting));
break;
case PROP_USERNAME:
- g_value_set_string (value, setting->username);
+ g_value_set_string (value, nm_setting_cdma_get_username (setting));
break;
case PROP_PASSWORD:
- g_value_set_string (value, setting->password);
+ g_value_set_string (value, nm_setting_cdma_get_password (setting));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -224,6 +256,8 @@
GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
+ g_type_class_add_private (setting_class, sizeof (NMSettingCdmaPrivate));
+
/* virtual methods */
object_class->set_property = set_property;
object_class->get_property = get_property;
Modified: trunk/libnm-util/nm-setting-cdma.h
==============================================================================
--- trunk/libnm-util/nm-setting-cdma.h (original)
+++ trunk/libnm-util/nm-setting-cdma.h Sun Oct 26 17:21:01 2008
@@ -59,10 +59,6 @@
typedef struct {
NMSetting parent;
-
- char *number; /* For dialing, duh */
- char *username;
- char *password;
} NMSettingCdma;
typedef struct {
@@ -71,7 +67,10 @@
GType nm_setting_cdma_get_type (void);
-NMSetting *nm_setting_cdma_new (void);
+NMSetting *nm_setting_cdma_new (void);
+const char *nm_setting_cdma_get_number (NMSettingCdma *setting);
+const char *nm_setting_cdma_get_username (NMSettingCdma *setting);
+const char *nm_setting_cdma_get_password (NMSettingCdma *setting);
G_END_DECLS
Modified: trunk/src/nm-cdma-device.c
==============================================================================
--- trunk/src/nm-cdma-device.c (original)
+++ trunk/src/nm-cdma-device.c Sun Oct 26 17:21:01 2008
@@ -127,7 +127,7 @@
setting = NM_SETTING_CDMA (cdma_device_get_setting (NM_CDMA_DEVICE (device), NM_TYPE_SETTING_CDMA));
- command = g_strconcat ("ATDT", setting->number, NULL);
+ command = g_strconcat ("ATDT", nm_setting_cdma_get_number (setting), NULL);
if (nm_serial_device_send_command_string (device, command))
id = nm_serial_device_wait_for_reply (device, 60, responses, responses, dial_done, NULL);
g_free (command);
@@ -280,10 +280,13 @@
NULL,
"missing CDMA setting; no secrets could be found.");
} else {
+ const char *cdma_username = nm_setting_cdma_get_username (s_cdma);
+ const char *cdma_password = nm_setting_cdma_get_password (s_cdma);
+
nm_ppp_manager_update_secrets (ppp_manager,
nm_device_get_iface (dev),
- s_cdma->username ? s_cdma->username : "",
- s_cdma->password ? s_cdma->password : "",
+ cdma_username ? cdma_username : "",
+ cdma_password ? cdma_password : "",
NULL);
}
return;
@@ -324,7 +327,7 @@
s_cdma = (NMSettingCdma *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA);
g_assert (s_cdma);
- return s_cdma->username;
+ return nm_setting_cdma_get_username (s_cdma);
}
/*****************************************************************************/
Modified: trunk/src/ppp-manager/nm-ppp-manager.c
==============================================================================
--- trunk/src/ppp-manager/nm-ppp-manager.c (original)
+++ trunk/src/ppp-manager/nm-ppp-manager.c Sun Oct 26 17:21:01 2008
@@ -376,8 +376,8 @@
username = NM_SETTING_GSM (setting)->username;
password = NM_SETTING_GSM (setting)->password;
} else if (NM_IS_SETTING_CDMA (setting)) {
- username = NM_SETTING_CDMA (setting)->username;
- password = NM_SETTING_CDMA (setting)->password;
+ username = nm_setting_cdma_get_username (NM_SETTING_CDMA (setting));
+ password = nm_setting_cdma_get_password (NM_SETTING_CDMA (setting));
}
/* If secrets are not required, send the existing username and password
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]