mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-08 19:55:47 +00:00
2008-10-26 Dan Williams <dcbw@redhat.com>
Patch from Tambet Ingo <tambet@gmail.com> * libnm-util/libnm-util.ver libnm-util/nm-setting-pppoe.c libnm-util/nm-setting-pppoe.h - Make properties private and add accessor functions * src/nm-device-ethernet.c src/ppp-manager/nm-ppp-manager.c - Use those accesors git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4217 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
6a5b10b12e
commit
55fd788e5a
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2008-10-26 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
Patch from Tambet Ingo <tambet@gmail.com>
|
||||
|
||||
* libnm-util/libnm-util.ver
|
||||
libnm-util/nm-setting-pppoe.c
|
||||
libnm-util/nm-setting-pppoe.h
|
||||
- Make properties private and add accessor functions
|
||||
|
||||
* src/nm-device-ethernet.c
|
||||
src/ppp-manager/nm-ppp-manager.c
|
||||
- Use those accesors
|
||||
|
||||
2008-10-26 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
Patch from Tambet Ingo <tambet@gmail.com>
|
||||
|
|
|
@ -72,6 +72,9 @@ global:
|
|||
nm_setting_pppoe_error_quark;
|
||||
nm_setting_pppoe_get_type;
|
||||
nm_setting_pppoe_new;
|
||||
nm_setting_pppoe_get_service;
|
||||
nm_setting_pppoe_get_username;
|
||||
nm_setting_pppoe_get_password;
|
||||
nm_setting_register;
|
||||
nm_setting_serial_error_get_type;
|
||||
nm_setting_serial_error_quark;
|
||||
|
|
|
@ -65,6 +65,14 @@ nm_setting_pppoe_error_get_type (void)
|
|||
|
||||
G_DEFINE_TYPE (NMSettingPPPOE, nm_setting_pppoe, NM_TYPE_SETTING)
|
||||
|
||||
#define NM_SETTING_PPPOE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_PPPOE, NMSettingPPPOEPrivate))
|
||||
|
||||
typedef struct {
|
||||
char *service;
|
||||
char *username;
|
||||
char *password;
|
||||
} NMSettingPPPOEPrivate;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_SERVICE,
|
||||
|
@ -80,6 +88,30 @@ nm_setting_pppoe_new (void)
|
|||
return (NMSetting *) g_object_new (NM_TYPE_SETTING_PPPOE, NULL);
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_setting_pppoe_get_service (NMSettingPPPOE *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_PPPOE (setting), NULL);
|
||||
|
||||
return NM_SETTING_PPPOE_GET_PRIVATE (setting)->service;
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_setting_pppoe_get_username (NMSettingPPPOE *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_PPPOE (setting), NULL);
|
||||
|
||||
return NM_SETTING_PPPOE_GET_PRIVATE (setting)->username;
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_setting_pppoe_get_password (NMSettingPPPOE *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_PPPOE (setting), NULL);
|
||||
|
||||
return NM_SETTING_PPPOE_GET_PRIVATE (setting)->password;
|
||||
}
|
||||
|
||||
static gint
|
||||
find_setting_by_name (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
|
@ -92,15 +124,15 @@ find_setting_by_name (gconstpointer a, gconstpointer b)
|
|||
static gboolean
|
||||
verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||
{
|
||||
NMSettingPPPOE *self = NM_SETTING_PPPOE (setting);
|
||||
NMSettingPPPOEPrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE (setting);
|
||||
|
||||
if (!self->username) {
|
||||
if (!priv->username) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_PPPOE_ERROR,
|
||||
NM_SETTING_PPPOE_ERROR_MISSING_PROPERTY,
|
||||
NM_SETTING_PPPOE_USERNAME);
|
||||
return FALSE;
|
||||
} else if (!strlen (self->username)) {
|
||||
} else if (!strlen (priv->username)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_PPPOE_ERROR,
|
||||
NM_SETTING_PPPOE_ERROR_INVALID_PROPERTY,
|
||||
|
@ -108,7 +140,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (self->service && !strlen (self->service)) {
|
||||
if (priv->service && !strlen (priv->service)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_PPPOE_ERROR,
|
||||
NM_SETTING_PPPOE_ERROR_INVALID_PROPERTY,
|
||||
|
@ -130,10 +162,10 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
static GPtrArray *
|
||||
need_secrets (NMSetting *setting)
|
||||
{
|
||||
NMSettingPPPOE *self = NM_SETTING_PPPOE (setting);
|
||||
NMSettingPPPOEPrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE (setting);
|
||||
GPtrArray *secrets;
|
||||
|
||||
if (self->password)
|
||||
if (priv->password)
|
||||
return NULL;
|
||||
|
||||
secrets = g_ptr_array_sized_new (1);
|
||||
|
@ -152,20 +184,20 @@ static void
|
|||
set_property (GObject *object, guint prop_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingPPPOE *setting = NM_SETTING_PPPOE (object);
|
||||
NMSettingPPPOEPrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_SERVICE:
|
||||
g_free (setting->service);
|
||||
setting->service = g_value_dup_string (value);
|
||||
g_free (priv->service);
|
||||
priv->service = 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);
|
||||
|
@ -181,13 +213,13 @@ get_property (GObject *object, guint prop_id,
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_SERVICE:
|
||||
g_value_set_string (value, setting->service);
|
||||
g_value_set_string (value, nm_setting_pppoe_get_service (setting));
|
||||
break;
|
||||
case PROP_USERNAME:
|
||||
g_value_set_string (value, setting->username);
|
||||
g_value_set_string (value, nm_setting_pppoe_get_username (setting));
|
||||
break;
|
||||
case PROP_PASSWORD:
|
||||
g_value_set_string (value, setting->password);
|
||||
g_value_set_string (value, nm_setting_pppoe_get_password (setting));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
@ -201,6 +233,8 @@ nm_setting_pppoe_class_init (NMSettingPPPOEClass *setting_class)
|
|||
GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
|
||||
NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
|
||||
|
||||
g_type_class_add_private (setting_class, sizeof (NMSettingPPPOEPrivate));
|
||||
|
||||
/* virtual methods */
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = get_property;
|
||||
|
|
|
@ -59,10 +59,6 @@ GQuark nm_setting_pppoe_error_quark (void);
|
|||
|
||||
typedef struct {
|
||||
NMSetting parent;
|
||||
|
||||
char *service;
|
||||
char *username;
|
||||
char *password;
|
||||
} NMSettingPPPOE;
|
||||
|
||||
typedef struct {
|
||||
|
@ -71,7 +67,10 @@ typedef struct {
|
|||
|
||||
GType nm_setting_pppoe_get_type (void);
|
||||
|
||||
NMSetting *nm_setting_pppoe_new (void);
|
||||
NMSetting *nm_setting_pppoe_new (void);
|
||||
const char *nm_setting_pppoe_get_service (NMSettingPPPOE *setting);
|
||||
const char *nm_setting_pppoe_get_username (NMSettingPPPOE *setting);
|
||||
const char *nm_setting_pppoe_get_password (NMSettingPPPOE *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -610,10 +610,13 @@ real_connection_secrets_updated (NMDevice *dev,
|
|||
NULL,
|
||||
"missing PPPoE setting; no secrets could be found.");
|
||||
} else {
|
||||
const char *pppoe_username = nm_setting_pppoe_get_username (s_pppoe);
|
||||
const char *pppoe_password = nm_setting_pppoe_get_password (s_pppoe);
|
||||
|
||||
nm_ppp_manager_update_secrets (priv->ppp_manager,
|
||||
nm_device_get_iface (dev),
|
||||
s_pppoe->username ? s_pppoe->username : "",
|
||||
s_pppoe->password ? s_pppoe->password : "",
|
||||
pppoe_username ? pppoe_username : "",
|
||||
pppoe_password ? pppoe_password : "",
|
||||
NULL);
|
||||
}
|
||||
return;
|
||||
|
@ -1255,7 +1258,7 @@ pppoe_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason)
|
|||
g_assert (s_pppoe);
|
||||
|
||||
priv->ppp_manager = nm_ppp_manager_new (nm_device_get_iface (NM_DEVICE (self)));
|
||||
if (nm_ppp_manager_start (priv->ppp_manager, req, s_pppoe->username, &err)) {
|
||||
if (nm_ppp_manager_start (priv->ppp_manager, req, nm_setting_pppoe_get_username (s_pppoe), &err)) {
|
||||
g_signal_connect (priv->ppp_manager, "state-changed",
|
||||
G_CALLBACK (ppp_state_changed),
|
||||
self);
|
||||
|
|
|
@ -370,8 +370,8 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager,
|
|||
|
||||
/* FIXME: push this down to the settings and keep PPP manager generic */
|
||||
if (NM_IS_SETTING_PPPOE (setting)) {
|
||||
username = NM_SETTING_PPPOE (setting)->username;
|
||||
password = NM_SETTING_PPPOE (setting)->password;
|
||||
username = nm_setting_pppoe_get_username (NM_SETTING_PPPOE (setting));
|
||||
password = nm_setting_pppoe_get_password (NM_SETTING_PPPOE (setting));
|
||||
} else if (NM_IS_SETTING_GSM (setting)) {
|
||||
username = NM_SETTING_GSM (setting)->username;
|
||||
password = NM_SETTING_GSM (setting)->password;
|
||||
|
@ -739,6 +739,7 @@ create_pppd_cmd_line (NMPPPManager *self,
|
|||
|
||||
if (pppoe) {
|
||||
char *dev_str;
|
||||
const char *pppoe_service;
|
||||
|
||||
nm_cmd_line_add_string (cmd, "plugin");
|
||||
nm_cmd_line_add_string (cmd, "rp-pppoe.so");
|
||||
|
@ -747,9 +748,10 @@ create_pppd_cmd_line (NMPPPManager *self,
|
|||
nm_cmd_line_add_string (cmd, dev_str);
|
||||
g_free (dev_str);
|
||||
|
||||
if (pppoe->service) {
|
||||
pppoe_service = nm_setting_pppoe_get_service (pppoe);
|
||||
if (pppoe_service) {
|
||||
nm_cmd_line_add_string (cmd, "rp_pppoe_service");
|
||||
nm_cmd_line_add_string (cmd, pppoe->service);
|
||||
nm_cmd_line_add_string (cmd, pppoe_service);
|
||||
}
|
||||
} else {
|
||||
nm_cmd_line_add_string (cmd, priv->parent_iface);
|
||||
|
|
Loading…
Reference in New Issue
Block a user