mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-09 22:50:21 +01:00
Use the 'Simple' modem interface.
This commit is contained in:
parent
9c0d6b468d
commit
10784dd1b6
8 changed files with 123 additions and 396 deletions
|
|
@ -157,12 +157,12 @@ NetworkManager_LDADD = \
|
|||
./named-manager/libnamed-manager.la \
|
||||
./vpn-manager/libvpn-manager.la \
|
||||
./dhcp-manager/libdhcp-manager.la \
|
||||
./supplicant-manager/libsupplicant-manager.la \
|
||||
./dnsmasq-manager/libdnsmasq-manager.la \
|
||||
./ppp-manager/libppp-manager.la \
|
||||
./modem-manager/libmodem-manager.la \
|
||||
./backends/libnmbackend.la \
|
||||
$(top_builddir)/libnm-util/libnm-util.la
|
||||
./supplicant-manager/libsupplicant-manager.la \
|
||||
./dnsmasq-manager/libdnsmasq-manager.la \
|
||||
./ppp-manager/libppp-manager.la \
|
||||
./modem-manager/libmodem-manager.la \
|
||||
./backends/libnmbackend.la \
|
||||
$(top_builddir)/libnm-util/libnm-util.la
|
||||
|
||||
NetworkManager_LDFLAGS = -rdynamic
|
||||
|
||||
|
|
|
|||
|
|
@ -10,31 +10,12 @@
|
|||
#include "nm-setting-connection.h"
|
||||
#include "nm-setting-cdma.h"
|
||||
#include "nm-utils.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
#include "nm-device-cdma-glue.h"
|
||||
|
||||
G_DEFINE_TYPE (NMModemCdma, nm_modem_cdma, NM_TYPE_MODEM)
|
||||
|
||||
#define NM_MODEM_CDMA_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_MODEM_CDMA, NMModemCdmaPrivate))
|
||||
|
||||
enum {
|
||||
MODEM_STATE_BEGIN,
|
||||
MODEM_STATE_ENABLE,
|
||||
MODEM_STATE_CONNECT
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int modem_state;
|
||||
} NMModemCdmaPrivate;
|
||||
|
||||
enum {
|
||||
SIGNAL_QUALITY,
|
||||
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
NMDevice *
|
||||
nm_modem_cdma_new (const char *path,
|
||||
const char *data_device,
|
||||
|
|
@ -53,77 +34,55 @@ nm_modem_cdma_new (const char *path,
|
|||
NULL);
|
||||
}
|
||||
|
||||
static NMSetting *
|
||||
get_setting (NMModemCdma *self, GType setting_type)
|
||||
{
|
||||
NMActRequest *req;
|
||||
NMSetting *setting = NULL;
|
||||
|
||||
req = nm_device_get_act_request (NM_DEVICE (self));
|
||||
if (req) {
|
||||
NMConnection *connection;
|
||||
|
||||
connection = nm_act_request_get_connection (req);
|
||||
if (connection)
|
||||
setting = nm_connection_get_setting (connection, setting_type);
|
||||
}
|
||||
|
||||
return setting;
|
||||
}
|
||||
|
||||
static void
|
||||
state_machine (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
stage1_prepare_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
{
|
||||
NMModemCdma *modem = NM_MODEM_CDMA (user_data);
|
||||
NMModemCdmaPrivate *priv = NM_MODEM_CDMA_GET_PRIVATE (modem);
|
||||
NMSettingCdma *setting;
|
||||
NMDevice *device = NM_DEVICE (user_data);
|
||||
GError *error = NULL;
|
||||
|
||||
setting = NM_SETTING_CDMA (get_setting (modem, NM_TYPE_SETTING_CDMA));
|
||||
|
||||
if (call_id)
|
||||
dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID);
|
||||
|
||||
if (error) {
|
||||
dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID);
|
||||
if (!error)
|
||||
nm_device_activate_schedule_stage2_device_config (device);
|
||||
else {
|
||||
nm_warning ("CDMA modem connection failed: %s", error->message);
|
||||
nm_device_state_changed (NM_DEVICE (modem), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_NONE);
|
||||
return;
|
||||
g_error_free (error);
|
||||
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
switch (priv->modem_state) {
|
||||
case MODEM_STATE_BEGIN:
|
||||
priv->modem_state = MODEM_STATE_ENABLE;
|
||||
dbus_g_proxy_begin_call (nm_modem_get_proxy (NM_MODEM (modem), NULL),
|
||||
"Enable", state_machine,
|
||||
modem, NULL,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_INVALID);
|
||||
break;
|
||||
case MODEM_STATE_ENABLE:
|
||||
priv->modem_state = MODEM_STATE_CONNECT;
|
||||
dbus_g_proxy_begin_call (nm_modem_get_proxy (NM_MODEM (modem), NULL),
|
||||
"Connect", state_machine,
|
||||
modem, NULL,
|
||||
G_TYPE_STRING, nm_setting_cdma_get_number (setting),
|
||||
G_TYPE_INVALID);
|
||||
break;
|
||||
case MODEM_STATE_CONNECT:
|
||||
nm_device_activate_schedule_stage2_device_config (NM_DEVICE (modem));
|
||||
break;
|
||||
default:
|
||||
nm_warning ("Invalid modem state %d", priv->modem_state);
|
||||
nm_device_state_changed (NM_DEVICE (modem), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_NONE);
|
||||
break;
|
||||
}
|
||||
static GHashTable *
|
||||
create_connect_properties (NMConnection *connection)
|
||||
{
|
||||
NMSettingCdma *setting;
|
||||
GHashTable *properties;
|
||||
const char *str;
|
||||
|
||||
setting = NM_SETTING_CDMA (nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA));
|
||||
properties = value_hash_create ();
|
||||
|
||||
str = nm_setting_cdma_get_number (setting);
|
||||
if (str)
|
||||
value_hash_add_str (properties, "number", str);
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
static NMActStageReturn
|
||||
real_act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
|
||||
{
|
||||
NMModemCdmaPrivate *priv = NM_MODEM_CDMA_GET_PRIVATE (device);
|
||||
NMConnection *connection;
|
||||
GHashTable *properties;
|
||||
|
||||
priv->modem_state = MODEM_STATE_BEGIN;
|
||||
state_machine (NULL, NULL, device);
|
||||
connection = nm_act_request_get_connection (nm_device_get_act_request (device));
|
||||
g_assert (connection);
|
||||
|
||||
properties = create_connect_properties (connection);
|
||||
dbus_g_proxy_begin_call_with_timeout (nm_modem_get_proxy (NM_MODEM (device), MM_DBUS_INTERFACE_MODEM_SIMPLE),
|
||||
"Connect", stage1_prepare_done,
|
||||
device, NULL, 120000,
|
||||
dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
|
||||
properties,
|
||||
G_TYPE_INVALID);
|
||||
|
||||
return NM_ACT_STAGE_RETURN_POSTPONE;
|
||||
}
|
||||
|
|
@ -236,29 +195,15 @@ nm_modem_cdma_init (NMModemCdma *self)
|
|||
static void
|
||||
nm_modem_cdma_class_init (NMModemCdmaClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
|
||||
NMModemClass *modem_class = NM_MODEM_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (NMModemCdmaPrivate));
|
||||
|
||||
/* Virtual methods */
|
||||
device_class->get_best_auto_connection = real_get_best_auto_connection;
|
||||
device_class->connection_secrets_updated = real_connection_secrets_updated;
|
||||
device_class->act_stage1_prepare = real_act_stage1_prepare;
|
||||
modem_class->get_ppp_name = real_get_ppp_name;
|
||||
|
||||
/* Signals */
|
||||
signals[SIGNAL_QUALITY] =
|
||||
g_signal_new ("signal-quality",
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (NMModemCdmaClass, signal_quality),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__UINT,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_UINT);
|
||||
|
||||
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
|
||||
&dbus_glib_nm_device_cdma_object_info);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,62 +84,8 @@ nm_modem_gsm_hso_new (const char *path,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static NMSetting *
|
||||
get_setting (NMModemGsmHso *modem, GType setting_type)
|
||||
{
|
||||
NMActRequest *req;
|
||||
NMSetting *setting = NULL;
|
||||
|
||||
req = nm_device_get_act_request (NM_DEVICE (modem));
|
||||
if (req) {
|
||||
NMConnection *connection;
|
||||
|
||||
connection = nm_act_request_get_connection (req);
|
||||
if (connection)
|
||||
setting = nm_connection_get_setting (connection, setting_type);
|
||||
}
|
||||
|
||||
return setting;
|
||||
}
|
||||
|
||||
static void
|
||||
hso_auth_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
{
|
||||
NMDevice *device = NM_DEVICE (user_data);
|
||||
GError *error = NULL;
|
||||
|
||||
if (dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID))
|
||||
nm_device_activate_schedule_stage3_ip_config_start (device);
|
||||
else {
|
||||
nm_warning ("Authentication failed: %s", error->message);
|
||||
g_error_free (error);
|
||||
nm_device_state_changed (device,
|
||||
NM_DEVICE_STATE_FAILED,
|
||||
NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
do_hso_auth (NMModemGsmHso *device)
|
||||
{
|
||||
NMSettingGsm *s_gsm;
|
||||
const char *username;
|
||||
const char *password;
|
||||
|
||||
s_gsm = NM_SETTING_GSM (get_setting (device, NM_TYPE_SETTING_GSM));
|
||||
username = nm_setting_gsm_get_username (s_gsm);
|
||||
password = nm_setting_gsm_get_password (s_gsm);
|
||||
|
||||
dbus_g_proxy_begin_call (nm_modem_get_proxy (NM_MODEM (device), MM_DBUS_INTERFACE_MODEM_GSM_HSO),
|
||||
"Authenticate", hso_auth_done,
|
||||
device, NULL,
|
||||
G_TYPE_STRING, username ? username : "",
|
||||
G_TYPE_STRING, password ? password : "",
|
||||
G_TYPE_INVALID);
|
||||
}
|
||||
|
||||
static NMActStageReturn
|
||||
real_act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
|
||||
real_act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
|
||||
{
|
||||
NMActRequest *req;
|
||||
NMConnection *connection;
|
||||
|
|
@ -154,10 +100,8 @@ real_act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
|
|||
g_assert (connection);
|
||||
|
||||
setting_name = nm_connection_need_secrets (connection, &hints);
|
||||
if (!setting_name) {
|
||||
do_hso_auth (NM_MODEM_GSM_HSO (device));
|
||||
return NM_ACT_STAGE_RETURN_POSTPONE;
|
||||
}
|
||||
if (!setting_name)
|
||||
return NM_DEVICE_CLASS (nm_modem_gsm_hso_parent_class)->act_stage1_prepare (device, reason);
|
||||
|
||||
if (hints) {
|
||||
if (hints->len > 0)
|
||||
|
|
@ -303,12 +247,6 @@ real_hw_bring_up (NMDevice *device, gboolean *no_firmware)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
real_connect (NMModem *modem, const char *number)
|
||||
{
|
||||
nm_device_activate_schedule_stage2_device_config (NM_DEVICE (modem));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -331,18 +269,15 @@ nm_modem_gsm_hso_class_init (NMModemGsmHsoClass *klass)
|
|||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
|
||||
NMModemClass *modem_class = NM_MODEM_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (NMModemGsmHsoPrivate));
|
||||
|
||||
object_class->finalize = finalize;
|
||||
|
||||
device_class->act_stage2_config = real_act_stage2_config;
|
||||
device_class->act_stage1_prepare = real_act_stage1_prepare;
|
||||
device_class->act_stage3_ip_config_start = real_act_stage3_ip_config_start;
|
||||
device_class->act_stage4_get_ip4_config = real_act_stage4_get_ip4_config;
|
||||
device_class->deactivate = real_deactivate;
|
||||
device_class->hw_is_up = real_hw_is_up;
|
||||
device_class->hw_bring_up = real_hw_bring_up;
|
||||
|
||||
modem_class->connect = real_connect;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,12 +216,6 @@ real_hw_bring_up (NMDevice *device, gboolean *no_firmware)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
real_connect (NMModem *modem, const char *number)
|
||||
{
|
||||
nm_device_activate_schedule_stage2_device_config (NM_DEVICE (modem));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -244,7 +238,6 @@ nm_modem_gsm_mbm_class_init (NMModemGsmMbmClass *klass)
|
|||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
|
||||
NMModemClass *modem_class = NM_MODEM_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (NMModemGsmMbmPrivate));
|
||||
|
||||
|
|
@ -256,6 +249,4 @@ nm_modem_gsm_mbm_class_init (NMModemGsmMbmClass *klass)
|
|||
device_class->deactivate = real_deactivate;
|
||||
device_class->hw_is_up = real_hw_is_up;
|
||||
device_class->hw_bring_up = real_hw_bring_up;
|
||||
|
||||
modem_class->connect = real_connect;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,28 +8,12 @@
|
|||
#include "nm-setting-gsm.h"
|
||||
#include "nm-modem-types.h"
|
||||
#include "nm-utils.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
#include "nm-device-gsm-glue.h"
|
||||
|
||||
G_DEFINE_TYPE (NMModemGsm, nm_modem_gsm, NM_TYPE_MODEM)
|
||||
|
||||
#define NM_MODEM_GSM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_MODEM_GSM, NMModemGsmPrivate))
|
||||
|
||||
enum {
|
||||
MODEM_STATE_BEGIN,
|
||||
MODEM_STATE_ENABLE,
|
||||
MODEM_STATE_SET_PIN,
|
||||
MODEM_STATE_SET_APN,
|
||||
MODEM_STATE_SET_BAND,
|
||||
MODEM_STATE_SET_NETWORK_MODE,
|
||||
MODEM_STATE_REGISTER,
|
||||
MODEM_STATE_FAILED,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int modem_state;
|
||||
} NMModemGsmPrivate;
|
||||
|
||||
NMDevice *
|
||||
nm_modem_gsm_new (const char *path,
|
||||
const char *data_device,
|
||||
|
|
@ -48,183 +32,100 @@ nm_modem_gsm_new (const char *path,
|
|||
NULL);
|
||||
}
|
||||
|
||||
static NMSetting *
|
||||
get_setting (NMModemGsm *modem, GType setting_type)
|
||||
{
|
||||
NMActRequest *req;
|
||||
NMSetting *setting = NULL;
|
||||
|
||||
req = nm_device_get_act_request (NM_DEVICE (modem));
|
||||
if (req) {
|
||||
NMConnection *connection;
|
||||
|
||||
connection = nm_act_request_get_connection (req);
|
||||
if (connection)
|
||||
setting = nm_connection_get_setting (connection, setting_type);
|
||||
}
|
||||
|
||||
return setting;
|
||||
}
|
||||
|
||||
#define get_proxy(dev,iface) (nm_modem_get_proxy(NM_MODEM (dev), iface))
|
||||
|
||||
static void
|
||||
state_machine (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
stage1_prepare_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
{
|
||||
NMModemGsm *modem = NM_MODEM_GSM (user_data);
|
||||
NMModemGsmPrivate *priv = NM_MODEM_GSM_GET_PRIVATE (modem);
|
||||
NMSettingGsm *setting;
|
||||
const char *secret = NULL;
|
||||
const char *secret_name = NULL;
|
||||
const char *str;
|
||||
NMDevice *device = NM_DEVICE (user_data);
|
||||
GError *error = NULL;
|
||||
int i;
|
||||
gboolean retry_secret = FALSE;
|
||||
|
||||
setting = NM_SETTING_GSM (get_setting (modem, NM_TYPE_SETTING_GSM));
|
||||
dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID);
|
||||
if (!error)
|
||||
nm_device_activate_schedule_stage2_device_config (device);
|
||||
else {
|
||||
const char *required_secret = NULL;
|
||||
gboolean retry_secret = FALSE;
|
||||
|
||||
if (call_id)
|
||||
dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID);
|
||||
|
||||
if (error) {
|
||||
g_debug ("%s", dbus_g_error_get_name (error));
|
||||
|
||||
if (dbus_g_error_has_name (error, MM_MODEM_ERROR_SIM_PIN)) {
|
||||
secret = nm_setting_gsm_get_pin (setting);
|
||||
secret_name = NM_SETTING_GSM_PIN;
|
||||
priv->modem_state = MODEM_STATE_SET_PIN;
|
||||
} else if (dbus_g_error_has_name (error, MM_MODEM_ERROR_SIM_PUK)) {
|
||||
secret = nm_setting_gsm_get_puk (setting);
|
||||
secret_name = NM_SETTING_GSM_PUK;
|
||||
priv->modem_state = MODEM_STATE_SET_PIN;
|
||||
} else if (dbus_g_error_has_name (error, MM_MODEM_ERROR_SIM_WRONG)) {
|
||||
g_object_set (setting, NM_SETTING_GSM_PIN, NULL, NULL);
|
||||
secret_name = NM_SETTING_GSM_PIN;
|
||||
if (dbus_g_error_has_name (error, MM_MODEM_ERROR_SIM_PIN))
|
||||
required_secret = NM_SETTING_GSM_PIN;
|
||||
else if (dbus_g_error_has_name (error, MM_MODEM_ERROR_SIM_PUK))
|
||||
required_secret = NM_SETTING_GSM_PUK;
|
||||
else if (dbus_g_error_has_name (error, MM_MODEM_ERROR_SIM_WRONG)) {
|
||||
/* FIXME: Unset the wrong PIN: g_object_set (setting, NM_SETTING_GSM_PIN, NULL, NULL); */
|
||||
required_secret = NM_SETTING_GSM_PIN;
|
||||
retry_secret = TRUE;
|
||||
priv->modem_state = MODEM_STATE_SET_PIN;
|
||||
}
|
||||
|
||||
/* FIXME: Hacks to ignore failures of setting band and network mode for now
|
||||
since only Huawei module supports it. Remove when ModemManager rules.
|
||||
*/
|
||||
else if (dbus_g_error_has_name (error, MM_MODEM_ERROR_OPERATION_NOT_SUPPORTED) &&
|
||||
(priv->modem_state == MODEM_STATE_SET_BAND ||
|
||||
priv->modem_state == MODEM_STATE_SET_NETWORK_MODE)) {
|
||||
|
||||
nm_warning ("Modem does not support setting %s, ignoring",
|
||||
priv->modem_state == MODEM_STATE_SET_BAND ? "band" : "network mode");
|
||||
} else {
|
||||
priv->modem_state = MODEM_STATE_FAILED;
|
||||
} else
|
||||
nm_warning ("GSM modem connection failed: %s", error->message);
|
||||
}
|
||||
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
again:
|
||||
|
||||
switch (priv->modem_state) {
|
||||
case MODEM_STATE_BEGIN:
|
||||
priv->modem_state = MODEM_STATE_ENABLE;
|
||||
dbus_g_proxy_begin_call (get_proxy (modem, MM_DBUS_INTERFACE_MODEM),
|
||||
"Enable", state_machine,
|
||||
modem, NULL,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_INVALID);
|
||||
break;
|
||||
|
||||
case MODEM_STATE_SET_PIN:
|
||||
if (secret) {
|
||||
priv->modem_state = MODEM_STATE_ENABLE;
|
||||
dbus_g_proxy_begin_call (get_proxy (modem, MM_DBUS_INTERFACE_MODEM_GSM_CARD),
|
||||
"SendPin", state_machine,
|
||||
modem, NULL,
|
||||
G_TYPE_STRING, secret,
|
||||
G_TYPE_INVALID);
|
||||
} else {
|
||||
nm_device_state_changed (NM_DEVICE (modem), NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE);
|
||||
nm_act_request_request_connection_secrets (nm_device_get_act_request (NM_DEVICE (modem)),
|
||||
if (required_secret) {
|
||||
nm_device_state_changed (device, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE);
|
||||
nm_act_request_request_connection_secrets (nm_device_get_act_request (device),
|
||||
NM_SETTING_GSM_SETTING_NAME,
|
||||
retry_secret,
|
||||
SECRETS_CALLER_GSM,
|
||||
secret_name,
|
||||
required_secret,
|
||||
NULL);
|
||||
} else
|
||||
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_NONE);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case MODEM_STATE_ENABLE:
|
||||
priv->modem_state = MODEM_STATE_SET_APN;
|
||||
str = nm_setting_gsm_get_apn (setting);
|
||||
|
||||
if (str)
|
||||
dbus_g_proxy_begin_call (get_proxy (modem, MM_DBUS_INTERFACE_MODEM_GSM_NETWORK),
|
||||
"SetApn", state_machine,
|
||||
modem, NULL,
|
||||
G_TYPE_STRING, str,
|
||||
G_TYPE_INVALID);
|
||||
else
|
||||
goto again;
|
||||
|
||||
break;
|
||||
case MODEM_STATE_SET_APN:
|
||||
priv->modem_state = MODEM_STATE_SET_BAND;
|
||||
i = nm_setting_gsm_get_band (setting);
|
||||
|
||||
if (i)
|
||||
dbus_g_proxy_begin_call (get_proxy (modem, MM_DBUS_INTERFACE_MODEM_GSM_NETWORK),
|
||||
"SetBand", state_machine,
|
||||
modem, NULL,
|
||||
G_TYPE_UINT, (guint32) i,
|
||||
G_TYPE_INVALID);
|
||||
else
|
||||
goto again;
|
||||
|
||||
break;
|
||||
|
||||
case MODEM_STATE_SET_BAND:
|
||||
priv->modem_state = MODEM_STATE_SET_NETWORK_MODE;
|
||||
i = nm_setting_gsm_get_network_type (setting);
|
||||
|
||||
if (i)
|
||||
dbus_g_proxy_begin_call (get_proxy (modem, MM_DBUS_INTERFACE_MODEM_GSM_NETWORK),
|
||||
"SetNetworkMode", state_machine,
|
||||
modem, NULL,
|
||||
G_TYPE_UINT, (guint32) i,
|
||||
G_TYPE_INVALID);
|
||||
else
|
||||
goto again;
|
||||
|
||||
break;
|
||||
|
||||
case MODEM_STATE_SET_NETWORK_MODE:
|
||||
priv->modem_state = MODEM_STATE_REGISTER;
|
||||
|
||||
str = nm_setting_gsm_get_network_id (setting);
|
||||
dbus_g_proxy_begin_call_with_timeout (get_proxy (modem, MM_DBUS_INTERFACE_MODEM_GSM_NETWORK),
|
||||
"Register", state_machine,
|
||||
modem, NULL, 120000,
|
||||
G_TYPE_STRING, str ? str : "",
|
||||
G_TYPE_INVALID);
|
||||
break;
|
||||
|
||||
case MODEM_STATE_REGISTER:
|
||||
nm_modem_connect (NM_MODEM (modem), nm_setting_gsm_get_number (setting));
|
||||
break;
|
||||
case MODEM_STATE_FAILED:
|
||||
default:
|
||||
nm_device_state_changed (NM_DEVICE (modem), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_NONE);
|
||||
break;
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
static GHashTable *
|
||||
create_connect_properties (NMConnection *connection)
|
||||
{
|
||||
NMSettingGsm *setting;
|
||||
GHashTable *properties;
|
||||
const char *str;
|
||||
|
||||
setting = NM_SETTING_GSM (nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM));
|
||||
properties = value_hash_create ();
|
||||
|
||||
str = nm_setting_gsm_get_number (setting);
|
||||
if (str)
|
||||
value_hash_add_str (properties, "number", str);
|
||||
|
||||
str = nm_setting_gsm_get_apn (setting);
|
||||
if (str)
|
||||
value_hash_add_str (properties, "apn", str);
|
||||
|
||||
str = nm_setting_gsm_get_network_id (setting);
|
||||
if (str)
|
||||
value_hash_add_str (properties, "network_id", str);
|
||||
|
||||
str = nm_setting_gsm_get_pin (setting);
|
||||
if (str)
|
||||
value_hash_add_str (properties, "pin", str);
|
||||
|
||||
str = nm_setting_gsm_get_username (setting);
|
||||
if (str)
|
||||
value_hash_add_str (properties, "username", str);
|
||||
|
||||
str = nm_setting_gsm_get_password (setting);
|
||||
if (str)
|
||||
value_hash_add_str (properties, "password", str);
|
||||
|
||||
/* FIXME: network_type, band */
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
static NMActStageReturn
|
||||
real_act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
|
||||
{
|
||||
NMModemGsmPrivate *priv = NM_MODEM_GSM_GET_PRIVATE (device);
|
||||
NMConnection *connection;
|
||||
GHashTable *properties;
|
||||
|
||||
priv->modem_state = MODEM_STATE_BEGIN;
|
||||
state_machine (NULL, NULL, device);
|
||||
connection = nm_act_request_get_connection (nm_device_get_act_request (device));
|
||||
g_assert (connection);
|
||||
|
||||
properties = create_connect_properties (connection);
|
||||
dbus_g_proxy_begin_call_with_timeout (nm_modem_get_proxy (NM_MODEM (device), MM_DBUS_INTERFACE_MODEM_SIMPLE),
|
||||
"Connect", stage1_prepare_done,
|
||||
device, NULL, 120000,
|
||||
dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
|
||||
properties,
|
||||
G_TYPE_INVALID);
|
||||
|
||||
return NM_ACT_STAGE_RETURN_POSTPONE;
|
||||
}
|
||||
|
|
@ -337,12 +238,9 @@ nm_modem_gsm_init (NMModemGsm *self)
|
|||
static void
|
||||
nm_modem_gsm_class_init (NMModemGsmClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
|
||||
NMModemClass *modem_class = NM_MODEM_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (NMModemGsmPrivate));
|
||||
|
||||
/* Virtual methods */
|
||||
device_class->get_best_auto_connection = real_get_best_auto_connection;
|
||||
device_class->connection_secrets_updated = real_connection_secrets_updated;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#define MM_DBUS_PATH "/org/freedesktop/ModemManager"
|
||||
#define MM_DBUS_INTERFACE "org.freedesktop.ModemManager"
|
||||
#define MM_DBUS_INTERFACE_MODEM "org.freedesktop.ModemManager.Modem"
|
||||
#define MM_DBUS_INTERFACE_MODEM_SIMPLE "org.freedesktop.ModemManager.Modem.Simple"
|
||||
#define MM_DBUS_INTERFACE_MODEM_CDMA "org.freedesktop.ModemManager.Modem.Cdma"
|
||||
|
||||
#define MM_DBUS_INTERFACE_MODEM_GSM_CARD "org.freedesktop.ModemManager.Modem.Gsm.Card"
|
||||
|
|
|
|||
|
|
@ -77,15 +77,6 @@ nm_modem_get_proxy (NMModem *self,
|
|||
return priv->proxy;
|
||||
}
|
||||
|
||||
void
|
||||
nm_modem_connect (NMModem *self,
|
||||
const char *number)
|
||||
{
|
||||
g_return_if_fail (NM_IS_MODEM (self));
|
||||
|
||||
NM_MODEM_GET_CLASS (self)->connect (self, number);
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_modem_get_ppp_name (NMModem *self,
|
||||
NMConnection *connection)
|
||||
|
|
@ -236,32 +227,6 @@ real_get_generic_capabilities (NMDevice *dev)
|
|||
return NM_DEVICE_CAP_NM_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
connect_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
||||
{
|
||||
NMDevice *device = NM_DEVICE (user_data);
|
||||
GError *error = NULL;
|
||||
|
||||
if (dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID))
|
||||
nm_device_activate_schedule_stage2_device_config (device);
|
||||
else {
|
||||
nm_warning ("Connect failed: %s", error->message);
|
||||
g_error_free (error);
|
||||
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
real_connect (NMModem *modem, const char *number)
|
||||
{
|
||||
dbus_g_proxy_begin_call_with_timeout (nm_modem_get_proxy (modem, MM_DBUS_INTERFACE_MODEM),
|
||||
"Connect", connect_done,
|
||||
modem, NULL, 60000,
|
||||
G_TYPE_STRING, number ? number : "",
|
||||
G_TYPE_INVALID);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
unavailable_to_disconnected (gpointer user_data)
|
||||
{
|
||||
|
|
@ -426,8 +391,6 @@ nm_modem_class_init (NMModemClass *klass)
|
|||
device_class->act_stage4_get_ip4_config = real_act_stage4_get_ip4_config;
|
||||
device_class->deactivate_quickly = real_deactivate_quickly;
|
||||
|
||||
klass->connect = real_connect;
|
||||
|
||||
/* Properties */
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PATH,
|
||||
|
|
|
|||
|
|
@ -25,9 +25,6 @@ typedef struct {
|
|||
typedef struct {
|
||||
NMDeviceClass parent;
|
||||
|
||||
void (*connect) (NMModem *self,
|
||||
const char *number);
|
||||
|
||||
const char *(*get_ppp_name) (NMModem *self,
|
||||
NMConnection *connection);
|
||||
|
||||
|
|
@ -44,9 +41,6 @@ NMPPPManager *nm_modem_get_ppp_manager (NMModem *self);
|
|||
DBusGProxy *nm_modem_get_proxy (NMModem *self,
|
||||
const char *interface);
|
||||
|
||||
void nm_modem_connect (NMModem *self,
|
||||
const char *number);
|
||||
|
||||
const char *nm_modem_get_ppp_name (NMModem *self,
|
||||
NMConnection *connection);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue