| author | Dan Williams <dcbw@redhat.com> | 2009-10-05 06:35:20 (GMT) |
|---|---|---|
| committer | Dan Williams <dcbw@redhat.com> | 2009-10-05 06:35:20 (GMT) |
| commit | e4e9d4099819b108738a2d4ab0c46713c946f6b8 (patch) | |
| tree | 0c80d0f1a9529ed11dd418cdc716b7da5799a5ac | |
| parent | c5cf3b1d9bfca3475d85afab5c5fa0916a31e643 (diff) | |
| download | NetworkManager-e4e9d4099819b108738a2d4ab0c46713c946f6b8.zip NetworkManager-e4e9d4099819b108738a2d4ab0c46713c946f6b8.tar.gz NetworkManager-e4e9d4099819b108738a2d4ab0c46713c946f6b8.tar.bz2 | |
modem: re-implement CDMA device on top of generic modem code
| -rw-r--r-- | src/Makefile.am | 2 | ||||
| -rw-r--r-- | src/modem-manager/nm-modem-cdma.c | 2 | ||||
| -rw-r--r-- | src/modem-manager/nm-modem-gsm.c | 2 | ||||
| -rw-r--r-- | src/modem-manager/nm-modem.c | 44 | ||||
| -rw-r--r-- | src/modem-manager/nm-modem.h | 11 | ||||
| -rw-r--r-- | src/nm-device-cdma.c | 378 | ||||
| -rw-r--r-- | src/nm-device-cdma.h | 56 | ||||
| -rw-r--r-- | src/nm-manager.c | 52 |
8 files changed, 511 insertions, 36 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index fb337a6..4fb955d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -74,6 +74,8 @@ NetworkManager_SOURCES = \ nm-device-olpc-mesh.h \ nm-device-bt.c \ nm-device-bt.h \ + nm-device-cdma.c \ + nm-device-cdma.h \ NetworkManagerAP.c \ NetworkManagerAP.h \ nm-dbus-manager.h \ diff --git a/src/modem-manager/nm-modem-cdma.c b/src/modem-manager/nm-modem-cdma.c index c695597..f5964d4 100644 --- a/src/modem-manager/nm-modem-cdma.c +++ b/src/modem-manager/nm-modem-cdma.c @@ -13,8 +13,6 @@ #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)) diff --git a/src/modem-manager/nm-modem-gsm.c b/src/modem-manager/nm-modem-gsm.c index b178590..0a631d3 100644 --- a/src/modem-manager/nm-modem-gsm.c +++ b/src/modem-manager/nm-modem-gsm.c @@ -11,8 +11,6 @@ #include "nm-utils.h" #include "NetworkManagerUtils.h" -#include "nm-device-gsm-glue.h" - typedef enum { MM_MODEM_GSM_MODE_UNKNOWN = 0x00000000, MM_MODEM_GSM_MODE_ANY = 0x00000001, diff --git a/src/modem-manager/nm-modem.c b/src/modem-manager/nm-modem.c index fa39bc8..0b91efd 100644 --- a/src/modem-manager/nm-modem.c +++ b/src/modem-manager/nm-modem.c @@ -268,13 +268,13 @@ static_stage3_done (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data) NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (self); GValueArray *ret_array = NULL; GError *error = NULL; + NMIP4Config *config = NULL; priv->call = NULL; if (dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_VALUE_ARRAY, &ret_array, G_TYPE_INVALID)) { - NMIP4Config *config; NMIP4Address *addr; int i; @@ -285,7 +285,7 @@ static_stage3_done (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data) nm_ip4_address_set_prefix (addr, 32); nm_ip4_config_take_address (config, addr); - for (i = 1; i < ret_array->n_values; i++) { + for (i = 0; i < ret_array->n_values; i++) { GValue *value = g_value_array_get_nth (ret_array, i); nm_ip4_config_add_nameserver (config, g_value_get_uint (value)); @@ -294,15 +294,10 @@ static_stage3_done (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data) priv->pending_ip4_config = g_object_ref (config); g_signal_emit (self, signals[IP4_CONFIG_RESULT], 0, NULL, config, NULL); - } else { - nm_warning ("%s: retrieving IP4 configuration failed: (%d) %s", - __func__, - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); - - g_signal_emit (self, signals[IP4_CONFIG_RESULT], 0, NULL, NULL, error); - g_error_free (error); } + + g_signal_emit (self, signals[IP4_CONFIG_RESULT], 0, NULL, config, error); + g_clear_error (&error); } static NMActStageReturn @@ -564,6 +559,26 @@ nm_modem_act_stage2_config (NMModem *self, return NM_ACT_STAGE_RETURN_SUCCESS; } +NMConnection * +nm_modem_get_best_auto_connection (NMModem *self, + GSList *connections, + char **specific_object) +{ + if (NM_MODEM_GET_CLASS (self)->get_best_auto_connection) + return NM_MODEM_GET_CLASS (self)->get_best_auto_connection (self, connections, specific_object); + return NULL; +} + +gboolean +nm_modem_check_connection_compatible (NMModem *self, + NMConnection *connection, + GError **error) +{ + if (NM_MODEM_GET_CLASS (self)->check_connection_compatible) + return NM_MODEM_GET_CLASS (self)->check_connection_compatible (self, connection, error); + return FALSE; +} + static void real_deactivate_quickly (NMModem *self, NMDevice *device) { @@ -689,6 +704,15 @@ nm_modem_get_iface (NMModem *self) return NM_MODEM_GET_PRIVATE (self)->iface; } +const char * +nm_modem_get_path (NMModem *self) +{ + g_return_val_if_fail (self != NULL, NULL); + g_return_val_if_fail (NM_IS_MODEM (self), NULL); + + return NM_MODEM_GET_PRIVATE (self)->path; +} + /*****************************************************************************/ static void diff --git a/src/modem-manager/nm-modem.h b/src/modem-manager/nm-modem.h index ec4f91f..b8af89f 100644 --- a/src/modem-manager/nm-modem.h +++ b/src/modem-manager/nm-modem.h @@ -22,6 +22,8 @@ G_BEGIN_DECLS #define NM_MODEM_IFACE "iface" #define NM_MODEM_IP_METHOD "ip-method" +#define NM_MODEM_PPP_STATS "ppp-stats" +#define NM_MODEM_PPP_FAILED "ppp-failed" #define NM_MODEM_PREPARE_RESULT "prepare-result" #define NM_MODEM_IP4_CONFIG_RESULT "ip4-config-result" #define NM_MODEM_NEED_AUTH "need-auth" @@ -78,6 +80,15 @@ GType nm_modem_get_type (void); NMPPPManager *nm_modem_get_ppp_manager (NMModem *modem); DBusGProxy * nm_modem_get_proxy (NMModem *modem, const char *interface); const char * nm_modem_get_iface (NMModem *modem); +const char * nm_modem_get_path (NMModem *modem); + +NMConnection *nm_modem_get_best_auto_connection (NMModem *self, + GSList *connections, + char **specific_object); + +gboolean nm_modem_check_connection_compatible (NMModem *self, + NMConnection *connection, + GError **error); NMActStageReturn nm_modem_act_stage1_prepare (NMModem *modem, NMActRequest *req, diff --git a/src/nm-device-cdma.c b/src/nm-device-cdma.c new file mode 100644 index 0000000..0fc721b --- a/dev/null +++ b/src/nm-device-cdma.c @@ -0,0 +1,378 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2009 Red Hat, Inc. + */ + +#include <string.h> + +#include "nm-dbus-glib-types.h" +#include "nm-modem.h" +#include "nm-modem-cdma.h" +#include "nm-device-interface.h" +#include "nm-device-private.h" +#include "nm-device-cdma.h" +#include "nm-utils.h" +#include "NetworkManagerUtils.h" +#include "nm-marshal.h" +#include "nm-properties-changed-signal.h" + +#include "nm-device-cdma-glue.h" +#include "nm-serial-device-glue.h" + +G_DEFINE_TYPE (NMDeviceCdma, nm_device_cdma, NM_TYPE_DEVICE) + +#define NM_DEVICE_CDMA_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_CDMA, NMDeviceCdmaPrivate)) + +typedef struct { + gboolean disposed; + + NMModem *modem; +} NMDeviceCdmaPrivate; + +enum { + PPP_STATS, + PROPERTIES_CHANGED, + + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +static void +ppp_stats (NMModem *modem, + guint32 in_bytes, + guint32 out_bytes, + gpointer user_data) +{ + g_signal_emit (NM_DEVICE_CDMA (user_data), signals[PPP_STATS], 0, in_bytes, out_bytes); +} + +static void +ppp_failed (NMModem *modem, NMDeviceStateReason reason, gpointer user_data) +{ + NMDevice *device = NM_DEVICE (user_data); + + switch (nm_device_interface_get_state (NM_DEVICE_INTERFACE (device))) { + case NM_DEVICE_STATE_PREPARE: + case NM_DEVICE_STATE_CONFIG: + case NM_DEVICE_STATE_NEED_AUTH: + case NM_DEVICE_STATE_IP_CONFIG: + case NM_DEVICE_STATE_ACTIVATED: + nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason); + break; + default: + break; + } +} + +static void +device_state_changed (NMDevice *device, + NMDeviceState new_state, + NMDeviceState old_state, + NMDeviceStateReason reason, + gpointer user_data) +{ + NMDeviceCdmaPrivate *priv = NM_DEVICE_CDMA_GET_PRIVATE (device); + + nm_modem_device_state_changed (priv->modem, new_state, old_state, reason); +} + +static gboolean +real_hw_is_up (NMDevice *device) +{ + return nm_modem_hw_is_up (NM_DEVICE_CDMA_GET_PRIVATE (device)->modem, device); +} + +static gboolean +real_hw_bring_up (NMDevice *device, gboolean *no_firmware) +{ + return nm_modem_hw_bring_up (NM_DEVICE_CDMA_GET_PRIVATE (device)->modem, device, no_firmware); +} + +static NMConnection * +real_get_best_auto_connection (NMDevice *device, + GSList *connections, + char **specific_object) +{ + NMDeviceCdmaPrivate *priv = NM_DEVICE_CDMA_GET_PRIVATE (device); + + return nm_modem_get_best_auto_connection (priv->modem, connections, specific_object); +} + +static void +real_connection_secrets_updated (NMDevice *device, + NMConnection *connection, + GSList *updated_settings, + RequestSecretsCaller caller) +{ + NMDeviceCdmaPrivate *priv = NM_DEVICE_CDMA_GET_PRIVATE (device); + NMActRequest *req; + + req = nm_device_get_act_request (device); + g_assert (req); + + if (!nm_modem_connection_secrets_updated (priv->modem, + req, + connection, + updated_settings, + caller)) { + nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_NO_SECRETS); + return; + } + + /* PPP handles stuff itself... */ + if (caller == SECRETS_CALLER_PPP) + return; + + /* Otherwise, on success for CDMA secrets we need to schedule stage1 again */ + g_return_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_NEED_AUTH); + nm_device_activate_schedule_stage1_device_prepare (device); +} + +static gboolean +real_check_connection_compatible (NMDevice *device, + NMConnection *connection, + GError **error) +{ + NMDeviceCdmaPrivate *priv = NM_DEVICE_CDMA_GET_PRIVATE (device); + + return nm_modem_check_connection_compatible (priv->modem, connection, error); +} + + +static void +modem_need_auth (NMModem *modem, + const char *setting_name, + gboolean retry, + RequestSecretsCaller caller, + const char *hint1, + const char *hint2, + gpointer user_data) +{ + NMDeviceCdma *self = NM_DEVICE_CDMA (self); + NMActRequest *req; + + req = nm_device_get_act_request (NM_DEVICE (self)); + g_assert (req); + + nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE); + nm_act_request_get_secrets (req, setting_name, retry, caller, hint1, hint2); +} + +static void +modem_prepare_result (NMModem *modem, + gboolean success, + NMDeviceStateReason reason, + gpointer user_data) +{ + NMDevice *device = NM_DEVICE (user_data); + NMDeviceState state; + + state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (device)); + g_return_if_fail (state == NM_DEVICE_STATE_PREPARE); + + if (success) + nm_device_activate_schedule_stage2_device_config (device); + else + nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason); +} + +static NMActStageReturn +real_act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) +{ + NMActRequest *req; + + req = nm_device_get_act_request (device); + g_assert (req); + + return nm_modem_act_stage1_prepare (NM_DEVICE_CDMA_GET_PRIVATE (device)->modem, req, reason); +} + +static NMActStageReturn +real_act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) +{ + NMActRequest *req; + + req = nm_device_get_act_request (device); + g_assert (req); + + return nm_modem_act_stage2_config (NM_DEVICE_CDMA_GET_PRIVATE (device)->modem, req, reason); +} + +static void +modem_ip4_config_result (NMModem *self, + const char *iface, + NMIP4Config *config, + GError *error, + gpointer user_data) +{ + NMDevice *device = NM_DEVICE (user_data); + NMDeviceState state; + + state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (device)); + g_return_if_fail (state == NM_DEVICE_STATE_IP_CONFIG); + + if (error) { + nm_warning ("%s: retrieving IP4 configuration failed: (%d) %s", + __func__, + error ? error->code : -1, + error && error->message ? error->message : "(unknown)"); + + nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); + } else { + if (iface) + nm_device_set_ip_iface (device, iface); + + nm_device_activate_schedule_stage4_ip4_config_get (device); + } +} + +static NMActStageReturn +real_act_stage3_ip4_config_start (NMDevice *device, NMDeviceStateReason *reason) +{ + return nm_modem_stage3_ip4_config_start (NM_DEVICE_CDMA_GET_PRIVATE (device)->modem, + device, + NM_DEVICE_CLASS (nm_device_cdma_parent_class), + reason); +} + +static NMActStageReturn +real_act_stage4_get_ip4_config (NMDevice *device, + NMIP4Config **config, + NMDeviceStateReason *reason) +{ + return nm_modem_stage4_get_ip4_config (NM_DEVICE_CDMA_GET_PRIVATE (device)->modem, + device, + NM_DEVICE_CLASS (nm_device_cdma_parent_class), + config, + reason); +} + +static void +real_deactivate_quickly (NMDevice *device) +{ + NMDeviceCdmaPrivate *priv = NM_DEVICE_CDMA_GET_PRIVATE (device); + + nm_modem_deactivate_quickly (priv->modem, device); +} + +static guint32 +real_get_generic_capabilities (NMDevice *device) +{ + return NM_DEVICE_CAP_NM_SUPPORTED; +} + +/*****************************************************************************/ + +NMDevice * +nm_device_cdma_new (NMModemCdma *modem, const char *driver) +{ + NMDevice *device; + + g_return_val_if_fail (modem != NULL, NULL); + g_return_val_if_fail (NM_IS_MODEM_CDMA (modem), NULL); + g_return_val_if_fail (driver != NULL, NULL); + + device = (NMDevice *) g_object_new (NM_TYPE_DEVICE_CDMA, + NM_DEVICE_INTERFACE_UDI, nm_modem_get_path (NM_MODEM (modem)), + NM_DEVICE_INTERFACE_IFACE, nm_modem_get_iface (NM_MODEM (modem)), + NM_DEVICE_INTERFACE_DRIVER, driver, + NM_DEVICE_INTERFACE_TYPE_DESC, "CDMA", + NM_DEVICE_INTERFACE_DEVICE_TYPE, NM_DEVICE_TYPE_CDMA, + NULL); + if (device) { + NM_DEVICE_CDMA_GET_PRIVATE (device)->modem = g_object_ref (modem); + g_signal_connect (device, "state-changed", G_CALLBACK (device_state_changed), device); + + g_signal_connect (modem, NM_MODEM_PPP_STATS, G_CALLBACK (ppp_stats), device); + g_signal_connect (modem, NM_MODEM_PPP_FAILED, G_CALLBACK (ppp_failed), device); + g_signal_connect (modem, NM_MODEM_PREPARE_RESULT, G_CALLBACK (modem_prepare_result), device); + g_signal_connect (modem, NM_MODEM_IP4_CONFIG_RESULT, G_CALLBACK (modem_ip4_config_result), device); + g_signal_connect (modem, NM_MODEM_NEED_AUTH, G_CALLBACK (modem_need_auth), device); + } + + return device; +} + +static void +nm_device_cdma_init (NMDeviceCdma *self) +{ +} + +static void +dispose (GObject *object) +{ + NMDeviceCdmaPrivate *priv = NM_DEVICE_CDMA_GET_PRIVATE (object); + + if (priv->disposed) { + G_OBJECT_CLASS (nm_device_cdma_parent_class)->dispose (object); + return; + } + priv->disposed = TRUE; + + g_object_unref (priv->modem); + priv->modem = NULL; + + G_OBJECT_CLASS (nm_device_cdma_parent_class)->dispose (object); +} + +static void +nm_device_cdma_class_init (NMDeviceCdmaClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (NMDeviceCdmaPrivate)); + + /* Virtual methods */ + object_class->dispose = dispose; + + device_class->get_best_auto_connection = real_get_best_auto_connection; + device_class->connection_secrets_updated = real_connection_secrets_updated; + device_class->check_connection_compatible = real_check_connection_compatible; + device_class->hw_is_up = real_hw_is_up; + device_class->hw_bring_up = real_hw_bring_up; + device_class->get_generic_capabilities = real_get_generic_capabilities; + device_class->act_stage1_prepare = real_act_stage1_prepare; + device_class->act_stage2_config = real_act_stage2_config; + device_class->act_stage3_ip4_config_start = real_act_stage3_ip4_config_start; + device_class->act_stage4_get_ip4_config = real_act_stage4_get_ip4_config; + device_class->deactivate_quickly = real_deactivate_quickly; + + /* Signals */ + signals[PPP_STATS] = + g_signal_new ("ppp-stats", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMDeviceCdmaClass, ppp_stats), + NULL, NULL, + _nm_marshal_VOID__UINT_UINT, + G_TYPE_NONE, 2, + G_TYPE_UINT, G_TYPE_UINT); + + signals[PROPERTIES_CHANGED] = + nm_properties_changed_signal_new (object_class, + G_STRUCT_OFFSET (NMDeviceCdmaClass, properties_changed)); + + dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), + &dbus_glib_nm_serial_device_object_info); + + dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), + &dbus_glib_nm_device_cdma_object_info); +} + diff --git a/src/nm-device-cdma.h b/src/nm-device-cdma.h new file mode 100644 index 0000000..ec4496d --- a/dev/null +++ b/src/nm-device-cdma.h @@ -0,0 +1,56 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2009 Red Hat, Inc. + */ + +#ifndef NM_DEVICE_CDMA_H +#define NM_DEVICE_CDMA_H + +#include "nm-device.h" +#include "nm-modem-cdma.h" + +G_BEGIN_DECLS + +#define NM_TYPE_DEVICE_CDMA (nm_device_cdma_get_type ()) +#define NM_DEVICE_CDMA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_CDMA, NMDeviceCdma)) +#define NM_DEVICE_CDMA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_CDMA, NMDeviceCdmaClass)) +#define NM_IS_DEVICE_CDMA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_CDMA)) +#define NM_IS_DEVICE_CDMA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_CDMA)) +#define NM_DEVICE_CDMA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_CDMA, NMDeviceCdmaClass)) + +typedef struct { + NMDevice parent; +} NMDeviceCdma; + +typedef struct { + NMDeviceClass parent; + + /* Signals */ + void (*signal_quality) (NMDeviceCdma *self, guint32 quality); + + void (*ppp_stats) (NMDeviceCdma *self, guint32 in_bytes, guint32 out_bytes); + void (*properties_changed) (NMDeviceCdma *self, GHashTable *properties); +} NMDeviceCdmaClass; + +GType nm_device_cdma_get_type (void); + +NMDevice *nm_device_cdma_new (NMModemCdma *modem, const char *driver); + +G_END_DECLS + +#endif /* NM_DEVICE_CDMA_H */ diff --git a/src/nm-manager.c b/src/nm-manager.c index 416df1a..18c5df4 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -37,6 +37,8 @@ #include "nm-device-ethernet.h" #include "nm-device-wifi.h" #include "nm-device-olpc-mesh.h" +#include "nm-device-cdma.h" +//#include "nm-device-gsm.h" #include "NetworkManagerSystem.h" #include "nm-properties-changed-signal.h" #include "nm-setting-bluetooth.h" @@ -135,6 +137,8 @@ remove_one_device (NMManager *manager, gboolean quitting, gboolean force_unmanage); +static NMDevice *nm_manager_get_device_by_udi (NMManager *manager, const char *udi); + #define SSD_POKE_INTERVAL 120 #define ORIGDEV_TAG "originating-device" @@ -289,26 +293,16 @@ vpn_manager_connection_deactivated_cb (NMVPNManager *manager, static void modem_added (NMModemManager *modem_manager, - NMDevice *modem, + NMModem *modem, + const char *driver, gpointer user_data) { - NMManagerPrivate *priv; - NMDeviceType type; - NMDevice *replace_device; - const char *type_name; + NMManager *self = NM_MANAGER (user_data); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); + NMDevice *replace_device, *device = NULL; const char *ip_iface; - priv = NM_MANAGER_GET_PRIVATE (user_data); - - type = nm_device_get_device_type (NM_DEVICE (modem)); - if (type == NM_DEVICE_TYPE_GSM) - type_name = "GSM modem"; - else if (type == NM_DEVICE_TYPE_CDMA) - type_name = "CDMA modem"; - else - type_name = "Unknown modem"; - - ip_iface = nm_device_get_ip_iface (modem); + ip_iface = nm_modem_get_iface (modem); replace_device = find_device_by_iface (NM_MANAGER (user_data), ip_iface); if (replace_device) { @@ -319,7 +313,18 @@ modem_added (NMModemManager *modem_manager, TRUE); } - add_device (NM_MANAGER (user_data), NM_DEVICE (g_object_ref (modem))); +#if 0 + if (NM_IS_MODEM_GSM (modem)) + device = nm_device_gsm_new (NM_MODEM_GSM (modem), driver); + else +#endif + if (NM_IS_MODEM_CDMA (modem)) + device = nm_device_cdma_new (NM_MODEM_CDMA (modem), driver); + else + g_message ("%s: unhandled modem '%s'", __func__, ip_iface); + + if (device) + add_device (self, device); } static void @@ -417,13 +422,16 @@ remove_one_device (NMManager *manager, static void modem_removed (NMModemManager *modem_manager, - NMDevice *modem, + NMModem *modem, gpointer user_data) { NMManager *self = NM_MANAGER (user_data); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); + NMDevice *found; - priv->devices = remove_one_device (self, priv->devices, modem, FALSE, TRUE); + found = nm_manager_get_device_by_udi (self, nm_modem_get_path (modem)); + if (found) + priv->devices = remove_one_device (self, priv->devices, found, FALSE, TRUE); } static void @@ -1208,7 +1216,7 @@ add_device (NMManager *self, NMDevice *device) iface = nm_device_get_ip_iface (device); g_assert (iface); - if (!NM_IS_MODEM(device) && nm_modem_manager_has_modem_for_iface (priv->modem_manager, iface)) { + if (!NM_IS_MODEM (device) && nm_modem_manager_has_modem_for_iface (priv->modem_manager, iface)) { g_object_unref (device); return; } @@ -2770,9 +2778,9 @@ nm_manager_init (NMManager *manager) g_object_unref); priv->modem_manager = nm_modem_manager_get (); - priv->modem_added_id = g_signal_connect (priv->modem_manager, "device-added", + priv->modem_added_id = g_signal_connect (priv->modem_manager, "modem-added", G_CALLBACK (modem_added), manager); - priv->modem_removed_id = g_signal_connect (priv->modem_manager, "device-removed", + priv->modem_removed_id = g_signal_connect (priv->modem_manager, "modem-removed", G_CALLBACK (modem_removed), manager); priv->vpn_manager = nm_vpn_manager_get (); |
