mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-21 18:24:49 +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-gsm.c libnm-util/nm-setting-gsm.h - Make properties private and add accessor functions * src/nm-gsm-device.c src/nm-hso-gsm-device.c src/ppp-manager/nm-ppp-manager.c - Use those accessors git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4219 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
41b0e05573
commit
76c366b546
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
2008-10-26 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
|
Patch from Tambet Ingo <tambet@gmail.com>
|
||||||
|
|
||||||
|
* libnm-util/libnm-util.ver
|
||||||
|
libnm-util/nm-setting-gsm.c
|
||||||
|
libnm-util/nm-setting-gsm.h
|
||||||
|
- Make properties private and add accessor functions
|
||||||
|
|
||||||
|
* src/nm-gsm-device.c
|
||||||
|
src/nm-hso-gsm-device.c
|
||||||
|
src/ppp-manager/nm-ppp-manager.c
|
||||||
|
- Use those accessors
|
||||||
|
|
||||||
2008-10-26 Dan Williams <dcbw@redhat.com>
|
2008-10-26 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
Patch from Tambet Ingo <tambet@gmail.com>
|
Patch from Tambet Ingo <tambet@gmail.com>
|
||||||
|
|
|
@ -58,6 +58,15 @@ global:
|
||||||
nm_setting_gsm_error_quark;
|
nm_setting_gsm_error_quark;
|
||||||
nm_setting_gsm_get_type;
|
nm_setting_gsm_get_type;
|
||||||
nm_setting_gsm_new;
|
nm_setting_gsm_new;
|
||||||
|
nm_setting_gsm_get_number;
|
||||||
|
nm_setting_gsm_get_username;
|
||||||
|
nm_setting_gsm_get_password;
|
||||||
|
nm_setting_gsm_get_apn;
|
||||||
|
nm_setting_gsm_get_network_id;
|
||||||
|
nm_setting_gsm_get_network_type;
|
||||||
|
nm_setting_gsm_get_band;
|
||||||
|
nm_setting_gsm_get_pin;
|
||||||
|
nm_setting_gsm_get_puk;
|
||||||
nm_setting_ip4_config_error_get_type;
|
nm_setting_ip4_config_error_get_type;
|
||||||
nm_setting_ip4_config_error_quark;
|
nm_setting_ip4_config_error_quark;
|
||||||
nm_setting_ip4_config_get_type;
|
nm_setting_ip4_config_get_type;
|
||||||
|
|
|
@ -67,6 +67,22 @@ nm_setting_gsm_error_get_type (void)
|
||||||
|
|
||||||
G_DEFINE_TYPE (NMSettingGsm, nm_setting_gsm, NM_TYPE_SETTING)
|
G_DEFINE_TYPE (NMSettingGsm, nm_setting_gsm, NM_TYPE_SETTING)
|
||||||
|
|
||||||
|
#define NM_SETTING_GSM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_GSM, NMSettingGsmPrivate))
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *number; /* For dialing, duh */
|
||||||
|
char *username;
|
||||||
|
char *password;
|
||||||
|
|
||||||
|
char *apn; /* NULL for dynamic */
|
||||||
|
char *network_id; /* for manual registration or NULL for automatic */
|
||||||
|
int network_type; /* One of the NM_GSM_NETWORK_* */
|
||||||
|
int band;
|
||||||
|
|
||||||
|
char *pin;
|
||||||
|
char *puk;
|
||||||
|
} NMSettingGsmPrivate;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_NUMBER,
|
PROP_NUMBER,
|
||||||
|
@ -97,10 +113,82 @@ find_setting_by_name (gconstpointer a, gconstpointer b)
|
||||||
return strcmp (nm_setting_get_name (setting), str);
|
return strcmp (nm_setting_get_name (setting), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
nm_setting_gsm_get_number (NMSettingGsm *setting)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
|
||||||
|
|
||||||
|
return NM_SETTING_GSM_GET_PRIVATE (setting)->number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
nm_setting_gsm_get_username (NMSettingGsm *setting)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
|
||||||
|
|
||||||
|
return NM_SETTING_GSM_GET_PRIVATE (setting)->username;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
nm_setting_gsm_get_password (NMSettingGsm *setting)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
|
||||||
|
|
||||||
|
return NM_SETTING_GSM_GET_PRIVATE (setting)->password;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
nm_setting_gsm_get_apn (NMSettingGsm *setting)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
|
||||||
|
|
||||||
|
return NM_SETTING_GSM_GET_PRIVATE (setting)->apn;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
nm_setting_gsm_get_network_id (NMSettingGsm *setting)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
|
||||||
|
|
||||||
|
return NM_SETTING_GSM_GET_PRIVATE (setting)->network_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
nm_setting_gsm_get_network_type (NMSettingGsm *setting)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (NM_IS_SETTING_GSM (setting), -1);
|
||||||
|
|
||||||
|
return NM_SETTING_GSM_GET_PRIVATE (setting)->network_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
nm_setting_gsm_get_band (NMSettingGsm *setting)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (NM_IS_SETTING_GSM (setting), -1);
|
||||||
|
|
||||||
|
return NM_SETTING_GSM_GET_PRIVATE (setting)->band;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
nm_setting_gsm_get_pin (NMSettingGsm *setting)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
|
||||||
|
|
||||||
|
return NM_SETTING_GSM_GET_PRIVATE (setting)->pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
nm_setting_gsm_get_puk (NMSettingGsm *setting)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
|
||||||
|
|
||||||
|
return NM_SETTING_GSM_GET_PRIVATE (setting)->puk;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
verify (NMSetting *setting, GSList *all_settings, GError **error)
|
verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||||
{
|
{
|
||||||
NMSettingGsm *self = NM_SETTING_GSM (setting);
|
NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (setting);
|
||||||
|
|
||||||
/* Serial connections require a PPP setting */
|
/* Serial connections require a PPP setting */
|
||||||
if (all_settings &&
|
if (all_settings &&
|
||||||
|
@ -112,13 +200,13 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self->number) {
|
if (!priv->number) {
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
NM_SETTING_GSM_ERROR,
|
NM_SETTING_GSM_ERROR,
|
||||||
NM_SETTING_GSM_ERROR_MISSING_PROPERTY,
|
NM_SETTING_GSM_ERROR_MISSING_PROPERTY,
|
||||||
NM_SETTING_GSM_NUMBER);
|
NM_SETTING_GSM_NUMBER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (!strlen (self->number)) {
|
} else if (!strlen (priv->number)) {
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
NM_SETTING_GSM_ERROR,
|
NM_SETTING_GSM_ERROR,
|
||||||
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
|
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
|
||||||
|
@ -126,7 +214,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->apn && (strlen (self->apn) < 1 || strchr (self->apn, '"'))) {
|
if (priv->apn && (strlen (priv->apn) < 1 || strchr (priv->apn, '"'))) {
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
NM_SETTING_GSM_ERROR,
|
NM_SETTING_GSM_ERROR,
|
||||||
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
|
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
|
||||||
|
@ -134,7 +222,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->username && !strlen (self->username)) {
|
if (priv->username && !strlen (priv->username)) {
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
NM_SETTING_GSM_ERROR,
|
NM_SETTING_GSM_ERROR,
|
||||||
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
|
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
|
||||||
|
@ -142,7 +230,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->password && !strlen (self->password)) {
|
if (priv->password && !strlen (priv->password)) {
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
NM_SETTING_GSM_ERROR,
|
NM_SETTING_GSM_ERROR,
|
||||||
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
|
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
|
||||||
|
@ -150,8 +238,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->network_id) {
|
if (priv->network_id) {
|
||||||
guint32 nid_len = strlen (self->network_id);
|
guint32 nid_len = strlen (priv->network_id);
|
||||||
guint32 i;
|
guint32 i;
|
||||||
|
|
||||||
/* Accept both 5 and 6 digit MCC/MNC codes */
|
/* Accept both 5 and 6 digit MCC/MNC codes */
|
||||||
|
@ -164,7 +252,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nid_len; i++) {
|
for (i = 0; i < nid_len; i++) {
|
||||||
if (!isdigit (self->network_id[i])) {
|
if (!isdigit (priv->network_id[i])) {
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
NM_SETTING_GSM_ERROR,
|
NM_SETTING_GSM_ERROR,
|
||||||
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
|
NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
|
||||||
|
@ -180,13 +268,13 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||||
static GPtrArray *
|
static GPtrArray *
|
||||||
need_secrets (NMSetting *setting)
|
need_secrets (NMSetting *setting)
|
||||||
{
|
{
|
||||||
NMSettingGsm *self = NM_SETTING_GSM (setting);
|
NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (setting);
|
||||||
GPtrArray *secrets = NULL;
|
GPtrArray *secrets = NULL;
|
||||||
|
|
||||||
if (self->password)
|
if (priv->password)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (self->username) {
|
if (priv->username) {
|
||||||
secrets = g_ptr_array_sized_new (1);
|
secrets = g_ptr_array_sized_new (1);
|
||||||
g_ptr_array_add (secrets, NM_SETTING_GSM_PASSWORD);
|
g_ptr_array_add (secrets, NM_SETTING_GSM_PASSWORD);
|
||||||
}
|
}
|
||||||
|
@ -203,15 +291,15 @@ nm_setting_gsm_init (NMSettingGsm *setting)
|
||||||
static void
|
static void
|
||||||
finalize (GObject *object)
|
finalize (GObject *object)
|
||||||
{
|
{
|
||||||
NMSettingGsm *self = NM_SETTING_GSM (object);
|
NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (object);
|
||||||
|
|
||||||
g_free (self->number);
|
g_free (priv->number);
|
||||||
g_free (self->username);
|
g_free (priv->username);
|
||||||
g_free (self->password);
|
g_free (priv->password);
|
||||||
g_free (self->apn);
|
g_free (priv->apn);
|
||||||
g_free (self->network_id);
|
g_free (priv->network_id);
|
||||||
g_free (self->pin);
|
g_free (priv->pin);
|
||||||
g_free (self->puk);
|
g_free (priv->puk);
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_setting_gsm_parent_class)->finalize (object);
|
G_OBJECT_CLASS (nm_setting_gsm_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -220,42 +308,42 @@ static void
|
||||||
set_property (GObject *object, guint prop_id,
|
set_property (GObject *object, guint prop_id,
|
||||||
const GValue *value, GParamSpec *pspec)
|
const GValue *value, GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
NMSettingGsm *setting = NM_SETTING_GSM (object);
|
NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_NUMBER:
|
case PROP_NUMBER:
|
||||||
g_free (setting->number);
|
g_free (priv->number);
|
||||||
setting->number = g_value_dup_string (value);
|
priv->number = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
case PROP_USERNAME:
|
case PROP_USERNAME:
|
||||||
g_free (setting->username);
|
g_free (priv->username);
|
||||||
setting->username = g_value_dup_string (value);
|
priv->username = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
case PROP_PASSWORD:
|
case PROP_PASSWORD:
|
||||||
g_free (setting->password);
|
g_free (priv->password);
|
||||||
setting->password = g_value_dup_string (value);
|
priv->password = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
case PROP_APN:
|
case PROP_APN:
|
||||||
g_free (setting->apn);
|
g_free (priv->apn);
|
||||||
setting->apn = g_value_dup_string (value);
|
priv->apn = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
case PROP_NETWORK_ID:
|
case PROP_NETWORK_ID:
|
||||||
g_free (setting->network_id);
|
g_free (priv->network_id);
|
||||||
setting->network_id = g_value_dup_string (value);
|
priv->network_id = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
case PROP_NETWORK_TYPE:
|
case PROP_NETWORK_TYPE:
|
||||||
setting->network_type = g_value_get_int (value);
|
priv->network_type = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
case PROP_BAND:
|
case PROP_BAND:
|
||||||
setting->band = g_value_get_int (value);
|
priv->band = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
case PROP_PIN:
|
case PROP_PIN:
|
||||||
g_free (setting->pin);
|
g_free (priv->pin);
|
||||||
setting->pin = g_value_dup_string (value);
|
priv->pin = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
case PROP_PUK:
|
case PROP_PUK:
|
||||||
g_free (setting->puk);
|
g_free (priv->puk);
|
||||||
setting->puk = g_value_dup_string (value);
|
priv->puk = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -271,31 +359,31 @@ get_property (GObject *object, guint prop_id,
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_NUMBER:
|
case PROP_NUMBER:
|
||||||
g_value_set_string (value, setting->number);
|
g_value_set_string (value, nm_setting_gsm_get_number (setting));
|
||||||
break;
|
break;
|
||||||
case PROP_USERNAME:
|
case PROP_USERNAME:
|
||||||
g_value_set_string (value, setting->username);
|
g_value_set_string (value, nm_setting_gsm_get_username (setting));
|
||||||
break;
|
break;
|
||||||
case PROP_PASSWORD:
|
case PROP_PASSWORD:
|
||||||
g_value_set_string (value, setting->password);
|
g_value_set_string (value, nm_setting_gsm_get_password (setting));
|
||||||
break;
|
break;
|
||||||
case PROP_APN:
|
case PROP_APN:
|
||||||
g_value_set_string (value, setting->apn);
|
g_value_set_string (value, nm_setting_gsm_get_apn (setting));
|
||||||
break;
|
break;
|
||||||
case PROP_NETWORK_ID:
|
case PROP_NETWORK_ID:
|
||||||
g_value_set_string (value, setting->network_id);
|
g_value_set_string (value, nm_setting_gsm_get_network_id (setting));
|
||||||
break;
|
break;
|
||||||
case PROP_NETWORK_TYPE:
|
case PROP_NETWORK_TYPE:
|
||||||
g_value_set_int (value, setting->network_type);
|
g_value_set_int (value, nm_setting_gsm_get_network_type (setting));
|
||||||
break;
|
break;
|
||||||
case PROP_BAND:
|
case PROP_BAND:
|
||||||
g_value_set_int (value, setting->band);
|
g_value_set_int (value, nm_setting_gsm_get_band (setting));
|
||||||
break;
|
break;
|
||||||
case PROP_PIN:
|
case PROP_PIN:
|
||||||
g_value_set_string (value, setting->pin);
|
g_value_set_string (value, nm_setting_gsm_get_pin (setting));
|
||||||
break;
|
break;
|
||||||
case PROP_PUK:
|
case PROP_PUK:
|
||||||
g_value_set_string (value, setting->puk);
|
g_value_set_string (value, nm_setting_gsm_get_puk (setting));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -309,6 +397,8 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
|
GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
|
||||||
NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
|
NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
|
||||||
|
|
||||||
|
g_type_class_add_private (setting_class, sizeof (NMSettingGsmPrivate));
|
||||||
|
|
||||||
/* virtual methods */
|
/* virtual methods */
|
||||||
object_class->set_property = set_property;
|
object_class->set_property = set_property;
|
||||||
object_class->get_property = get_property;
|
object_class->get_property = get_property;
|
||||||
|
|
|
@ -73,18 +73,6 @@ enum {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NMSetting parent;
|
NMSetting parent;
|
||||||
|
|
||||||
char *number; /* For dialing, duh */
|
|
||||||
char *username;
|
|
||||||
char *password;
|
|
||||||
|
|
||||||
char *apn; /* NULL for dynamic */
|
|
||||||
char *network_id; /* for manual registration or NULL for automatic */
|
|
||||||
int network_type; /* One of the NM_GSM_NETWORK_* */
|
|
||||||
int band;
|
|
||||||
|
|
||||||
char *pin;
|
|
||||||
char *puk;
|
|
||||||
} NMSettingGsm;
|
} NMSettingGsm;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -93,7 +81,16 @@ typedef struct {
|
||||||
|
|
||||||
GType nm_setting_gsm_get_type (void);
|
GType nm_setting_gsm_get_type (void);
|
||||||
|
|
||||||
NMSetting *nm_setting_gsm_new (void);
|
NMSetting *nm_setting_gsm_new (void);
|
||||||
|
const char *nm_setting_gsm_get_number (NMSettingGsm *setting);
|
||||||
|
const char *nm_setting_gsm_get_username (NMSettingGsm *setting);
|
||||||
|
const char *nm_setting_gsm_get_password (NMSettingGsm *setting);
|
||||||
|
const char *nm_setting_gsm_get_apn (NMSettingGsm *setting);
|
||||||
|
const char *nm_setting_gsm_get_network_id (NMSettingGsm *setting);
|
||||||
|
int nm_setting_gsm_get_network_type (NMSettingGsm *setting);
|
||||||
|
int nm_setting_gsm_get_band (NMSettingGsm *setting);
|
||||||
|
const char *nm_setting_gsm_get_pin (NMSettingGsm *setting);
|
||||||
|
const char *nm_setting_gsm_get_puk (NMSettingGsm *setting);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -154,23 +154,25 @@ real_do_dial (NMGsmDevice *device, guint cid)
|
||||||
{
|
{
|
||||||
NMSettingGsm *setting;
|
NMSettingGsm *setting;
|
||||||
char *command;
|
char *command;
|
||||||
|
const char *number;
|
||||||
const char *responses[] = { "CONNECT", "BUSY", "NO DIAL TONE", "NO CARRIER", NULL };
|
const char *responses[] = { "CONNECT", "BUSY", "NO DIAL TONE", "NO CARRIER", NULL };
|
||||||
|
|
||||||
setting = NM_SETTING_GSM (gsm_device_get_setting (NM_GSM_DEVICE (device), NM_TYPE_SETTING_GSM));
|
setting = NM_SETTING_GSM (gsm_device_get_setting (NM_GSM_DEVICE (device), NM_TYPE_SETTING_GSM));
|
||||||
|
number = nm_setting_gsm_get_number (setting);
|
||||||
|
|
||||||
if (cid) {
|
if (cid) {
|
||||||
GString *str;
|
GString *str;
|
||||||
|
|
||||||
str = g_string_new ("ATD");
|
str = g_string_new ("ATD");
|
||||||
if (g_str_has_suffix (setting->number, "#"))
|
if (g_str_has_suffix (number, "#"))
|
||||||
str = g_string_append_len (str, setting->number, strlen (setting->number) - 1);
|
str = g_string_append_len (str, number, strlen (number) - 1);
|
||||||
else
|
else
|
||||||
str = g_string_append (str, setting->number);
|
str = g_string_append (str, number);
|
||||||
|
|
||||||
g_string_append_printf (str, "***%d#", cid);
|
g_string_append_printf (str, "***%d#", cid);
|
||||||
command = g_string_free (str, FALSE);
|
command = g_string_free (str, FALSE);
|
||||||
} else
|
} else
|
||||||
command = g_strconcat ("ATDT", setting->number, NULL);
|
command = g_strconcat ("ATDT", number, NULL);
|
||||||
|
|
||||||
modem_wait_for_reply (device, command, 60, responses, responses, dial_done, NULL);
|
modem_wait_for_reply (device, command, 60, responses, responses, dial_done, NULL);
|
||||||
g_free (command);
|
g_free (command);
|
||||||
|
@ -201,19 +203,22 @@ set_apn (NMGsmDevice *device)
|
||||||
NMGsmDevicePrivate *priv = NM_GSM_DEVICE_GET_PRIVATE (device);
|
NMGsmDevicePrivate *priv = NM_GSM_DEVICE_GET_PRIVATE (device);
|
||||||
NMSettingGsm *setting;
|
NMSettingGsm *setting;
|
||||||
char *command;
|
char *command;
|
||||||
|
const char *apn;
|
||||||
const char *responses[] = { "OK", "ERROR", NULL };
|
const char *responses[] = { "OK", "ERROR", NULL };
|
||||||
guint cid = 1;
|
guint cid = 1;
|
||||||
|
|
||||||
priv->reg_tries = 0;
|
priv->reg_tries = 0;
|
||||||
|
|
||||||
setting = NM_SETTING_GSM (gsm_device_get_setting (NM_GSM_DEVICE (device), NM_TYPE_SETTING_GSM));
|
setting = NM_SETTING_GSM (gsm_device_get_setting (NM_GSM_DEVICE (device), NM_TYPE_SETTING_GSM));
|
||||||
if (!setting->apn) {
|
|
||||||
|
apn = nm_setting_gsm_get_apn (setting);
|
||||||
|
if (!apn) {
|
||||||
/* APN not set, nothing to do */
|
/* APN not set, nothing to do */
|
||||||
NM_GSM_DEVICE_GET_CLASS (device)->do_dial (NM_GSM_DEVICE (device), 0);
|
NM_GSM_DEVICE_GET_CLASS (device)->do_dial (NM_GSM_DEVICE (device), 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
command = g_strdup_printf ("AT+CGDCONT=%d,\"IP\",\"%s\"", cid, setting->apn);
|
command = g_strdup_printf ("AT+CGDCONT=%d,\"IP\",\"%s\"", cid, apn);
|
||||||
modem_wait_for_reply (device, command, 7, responses, responses, set_apn_done, GUINT_TO_POINTER (cid));
|
modem_wait_for_reply (device, command, 7, responses, responses, set_apn_done, GUINT_TO_POINTER (cid));
|
||||||
g_free (command);
|
g_free (command);
|
||||||
}
|
}
|
||||||
|
@ -281,7 +286,7 @@ manual_registration (NMGsmDevice *device)
|
||||||
|
|
||||||
setting = NM_SETTING_GSM (gsm_device_get_setting (device, NM_TYPE_SETTING_GSM));
|
setting = NM_SETTING_GSM (gsm_device_get_setting (device, NM_TYPE_SETTING_GSM));
|
||||||
|
|
||||||
command = g_strdup_printf ("AT+COPS=1,2,\"%s\"", setting->network_id);
|
command = g_strdup_printf ("AT+COPS=1,2,\"%s\"", nm_setting_gsm_get_network_id (setting));
|
||||||
modem_wait_for_reply (device, command, 15, responses, responses, manual_registration_response, NULL);
|
modem_wait_for_reply (device, command, 15, responses, responses, manual_registration_response, NULL);
|
||||||
g_free (command);
|
g_free (command);
|
||||||
}
|
}
|
||||||
|
@ -417,7 +422,7 @@ do_register (NMGsmDevice *device)
|
||||||
setting = NM_SETTING_GSM (gsm_device_get_setting (device, NM_TYPE_SETTING_GSM));
|
setting = NM_SETTING_GSM (gsm_device_get_setting (device, NM_TYPE_SETTING_GSM));
|
||||||
|
|
||||||
priv->reg_tries = 0;
|
priv->reg_tries = 0;
|
||||||
if (setting->network_id)
|
if (nm_setting_gsm_get_network_id (setting))
|
||||||
manual_registration (device);
|
manual_registration (device);
|
||||||
else
|
else
|
||||||
automatic_registration (device);
|
automatic_registration (device);
|
||||||
|
@ -507,12 +512,10 @@ enter_pin_done (NMSerialDevice *device,
|
||||||
|
|
||||||
switch (secret) {
|
switch (secret) {
|
||||||
case NM_GSM_SECRET_PIN:
|
case NM_GSM_SECRET_PIN:
|
||||||
g_free (setting->pin);
|
g_object_set (setting, NM_SETTING_GSM_PIN, NULL, NULL);
|
||||||
setting->pin = NULL;
|
|
||||||
break;
|
break;
|
||||||
case NM_GSM_SECRET_PUK:
|
case NM_GSM_SECRET_PUK:
|
||||||
g_free (setting->puk);
|
g_object_set (setting, NM_SETTING_GSM_PUK, NULL, NULL);
|
||||||
setting->puk = NULL;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -529,7 +532,7 @@ enter_pin (NMGsmDevice *device, NMGsmSecret secret_type, gboolean retry)
|
||||||
NMSettingGsm *setting;
|
NMSettingGsm *setting;
|
||||||
NMActRequest *req;
|
NMActRequest *req;
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
char *secret;
|
const char *secret;
|
||||||
char *secret_name = NULL;
|
char *secret_name = NULL;
|
||||||
|
|
||||||
req = nm_device_get_act_request (NM_DEVICE (device));
|
req = nm_device_get_act_request (NM_DEVICE (device));
|
||||||
|
@ -541,11 +544,9 @@ enter_pin (NMGsmDevice *device, NMGsmSecret secret_type, gboolean retry)
|
||||||
|
|
||||||
switch (secret_type) {
|
switch (secret_type) {
|
||||||
case NM_GSM_SECRET_PIN:
|
case NM_GSM_SECRET_PIN:
|
||||||
secret = setting->pin;
|
|
||||||
secret_name = NM_SETTING_GSM_PIN;
|
secret_name = NM_SETTING_GSM_PIN;
|
||||||
break;
|
break;
|
||||||
case NM_GSM_SECRET_PUK:
|
case NM_GSM_SECRET_PUK:
|
||||||
secret = setting->puk;
|
|
||||||
secret_name = NM_SETTING_GSM_PUK;
|
secret_name = NM_SETTING_GSM_PUK;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -553,6 +554,7 @@ enter_pin (NMGsmDevice *device, NMGsmSecret secret_type, gboolean retry)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_object_get (setting, secret_name, &secret, NULL);
|
||||||
if (secret) {
|
if (secret) {
|
||||||
char *command;
|
char *command;
|
||||||
const char *responses[] = { "OK", "ERROR", "ERR", NULL };
|
const char *responses[] = { "OK", "ERROR", "ERR", NULL };
|
||||||
|
@ -725,10 +727,13 @@ real_connection_secrets_updated (NMDevice *dev,
|
||||||
NULL,
|
NULL,
|
||||||
"missing GSM setting; no secrets could be found.");
|
"missing GSM setting; no secrets could be found.");
|
||||||
} else {
|
} else {
|
||||||
|
const char *gsm_username = nm_setting_gsm_get_username (s_gsm);
|
||||||
|
const char *gsm_password = nm_setting_gsm_get_password (s_gsm);
|
||||||
|
|
||||||
nm_ppp_manager_update_secrets (ppp_manager,
|
nm_ppp_manager_update_secrets (ppp_manager,
|
||||||
nm_device_get_iface (dev),
|
nm_device_get_iface (dev),
|
||||||
s_gsm->username ? s_gsm->username : "",
|
gsm_username ? gsm_username : "",
|
||||||
s_gsm->password ? s_gsm->password : "",
|
gsm_password ? gsm_password : "",
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -785,7 +790,7 @@ real_get_ppp_name (NMSerialDevice *device, NMActRequest *req)
|
||||||
s_gsm = (NMSettingGsm *) nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM);
|
s_gsm = (NMSettingGsm *) nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM);
|
||||||
g_assert (s_gsm);
|
g_assert (s_gsm);
|
||||||
|
|
||||||
return s_gsm->username;
|
return nm_setting_gsm_get_username (s_gsm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -178,6 +178,8 @@ do_hso_auth (NMHsoGsmDevice *device)
|
||||||
NMActRequest *req;
|
NMActRequest *req;
|
||||||
const char *responses[] = { "OK", "ERROR", "ERR", NULL };
|
const char *responses[] = { "OK", "ERROR", "ERR", NULL };
|
||||||
char *command;
|
char *command;
|
||||||
|
const char *gsm_username;
|
||||||
|
const char *gsm_password;
|
||||||
guint cid;
|
guint cid;
|
||||||
|
|
||||||
req = nm_device_get_act_request (NM_DEVICE (device));
|
req = nm_device_get_act_request (NM_DEVICE (device));
|
||||||
|
@ -187,10 +189,13 @@ do_hso_auth (NMHsoGsmDevice *device)
|
||||||
|
|
||||||
s_gsm = NM_SETTING_GSM (gsm_device_get_setting (NM_GSM_DEVICE (device), NM_TYPE_SETTING_GSM));
|
s_gsm = NM_SETTING_GSM (gsm_device_get_setting (NM_GSM_DEVICE (device), NM_TYPE_SETTING_GSM));
|
||||||
|
|
||||||
|
gsm_username = nm_setting_gsm_get_username (s_gsm);
|
||||||
|
gsm_password = nm_setting_gsm_get_password (s_gsm);
|
||||||
|
|
||||||
command = g_strdup_printf ("AT$QCPDPP=%d,1,\"%s\",\"%s\"",
|
command = g_strdup_printf ("AT$QCPDPP=%d,1,\"%s\",\"%s\"",
|
||||||
cid,
|
cid,
|
||||||
s_gsm->password ? s_gsm->password : "",
|
gsm_password ? gsm_password : "",
|
||||||
s_gsm->username ? s_gsm->username : "");
|
gsm_username ? gsm_username : "");
|
||||||
modem_wait_for_reply (NM_GSM_DEVICE (device), command, 5, responses, responses, hso_auth_done, GUINT_TO_POINTER (cid));
|
modem_wait_for_reply (NM_GSM_DEVICE (device), command, 5, responses, responses, hso_auth_done, GUINT_TO_POINTER (cid));
|
||||||
g_free (command);
|
g_free (command);
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,8 +373,8 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager,
|
||||||
username = nm_setting_pppoe_get_username (NM_SETTING_PPPOE (setting));
|
username = nm_setting_pppoe_get_username (NM_SETTING_PPPOE (setting));
|
||||||
password = nm_setting_pppoe_get_password (NM_SETTING_PPPOE (setting));
|
password = nm_setting_pppoe_get_password (NM_SETTING_PPPOE (setting));
|
||||||
} else if (NM_IS_SETTING_GSM (setting)) {
|
} else if (NM_IS_SETTING_GSM (setting)) {
|
||||||
username = NM_SETTING_GSM (setting)->username;
|
username = nm_setting_gsm_get_username (NM_SETTING_GSM (setting));
|
||||||
password = NM_SETTING_GSM (setting)->password;
|
password = nm_setting_gsm_get_password (NM_SETTING_GSM (setting));
|
||||||
} else if (NM_IS_SETTING_CDMA (setting)) {
|
} else if (NM_IS_SETTING_CDMA (setting)) {
|
||||||
username = nm_setting_cdma_get_username (NM_SETTING_CDMA (setting));
|
username = nm_setting_cdma_get_username (NM_SETTING_CDMA (setting));
|
||||||
password = nm_setting_cdma_get_password (NM_SETTING_CDMA (setting));
|
password = nm_setting_cdma_get_password (NM_SETTING_CDMA (setting));
|
||||||
|
|
Loading…
Reference in a new issue