summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2015-02-16 15:49:06 -0600
committerDan Williams <dcbw@redhat.com>2015-02-16 16:02:53 -0600
commit6f75bfefbd6c0605666191d5153b8a83974a3f1c (patch)
tree138a791fc11b463f2a1ef79101b81a9c826b6f72
parent0c3600238bb2da31af48d7184df5cf3ddebec2b8 (diff)
downloadnetwork-manager-applet-6f75bfefbd6c0605666191d5153b8a83974a3f1c.tar.gz
applet: remove obsolete support for ModemManager <= 0.7
NetworkManager 1.0 and later don't support the old ModemManager, and the applet doesn't support old versions of NetworkManager, so remove the obsolete support and bump the version requirements to NM 1.0+.
-rw-r--r--configure.ac26
-rw-r--r--src/Makefile.am20
-rw-r--r--src/applet-device-cdma.c746
-rw-r--r--src/applet-device-cdma.h32
-rw-r--r--src/applet-device-gsm.c1221
-rw-r--r--src/applet-device-gsm.h33
-rw-r--r--src/applet.c88
-rw-r--r--src/applet.h8
-rw-r--r--src/gnome-bluetooth/Makefile.am13
-rw-r--r--src/gnome-bluetooth/nma-bt-device.c178
10 files changed, 60 insertions, 2305 deletions
diff --git a/configure.ac b/configure.ac
index f6ce1d53..5452784b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -74,10 +74,10 @@ PKG_CHECK_MODULES(GOBJECT, gobject-2.0)
PKG_CHECK_MODULES(NMA,
[dbus-glib-1 >= 0.74
gio-2.0 >= 2.32
- NetworkManager >= 0.9.10
- libnm-glib >= 0.9.10
- libnm-util >= 0.9.10
- libnm-glib-vpn >= 0.9.10
+ NetworkManager >= 1.0
+ libnm-glib >= 1.0
+ libnm-util >= 1.0
+ libnm-glib-vpn >= 1.0
gmodule-export-2.0])
NMA_CFLAGS="$NMA_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32"
@@ -147,9 +147,9 @@ esac
AM_CONDITIONAL(HAVE_GBT, test x"$have_gbt" = "xyes")
-dnl ModemManager1 with libmm-glib
-AC_ARG_WITH(modem-manager-1, AS_HELP_STRING([--with-modem-manager-1], [Enable new ModemManager1 interface support]),,[with_modem_manager_1=auto])
-if (test "${with_modem_manager_1}" != "no"); then
+dnl ModemManager1 with libmm-glib for WWAN support
+AC_ARG_WITH(wwan, AS_HELP_STRING([--with-wwan], [Enable WWAN support]),,[with_wwan=auto])
+if (test "${with_wwan}" != "no"); then
PKG_CHECK_MODULES(MM_GLIB,
[mm-glib],
[have_libmm_glib=yes],
@@ -158,20 +158,20 @@ if (test "${with_modem_manager_1}" != "no"); then
AC_SUBST(MM_GLIB_LIBS)
if (test "${have_libmm_glib}" = "no"); then
- if (test "${with_modem_manager_1}" = "yes"); then
+ if (test "${with_wwan}" = "yes"); then
AC_MSG_ERROR([Couldn't find libmm-glib])
fi
else
- with_modem_manager_1="yes"
+ with_wwan="yes"
fi
fi
-if (test "${with_modem_manager_1}" = "yes"); then
- AC_DEFINE(WITH_MODEM_MANAGER_1, 1, [Define if you have ModemManager1 support])
+if (test "${with_wwan}" = "yes"); then
+ AC_DEFINE(WITH_WWAN, 1, [Define if you have ModemManager/WWAN support])
else
- AC_DEFINE(WITH_MODEM_MANAGER_1, 0, [Define if you have ModemManager1 support])
+ AC_DEFINE(WITH_WWAN, 0, [Define if you have ModemManager/WWAN support])
fi
-AM_CONDITIONAL(WITH_MODEM_MANAGER_1, test "${with_modem_manager_1}" = "yes")
+AM_CONDITIONAL(WITH_WWAN, test "${with_wwan}" = "yes")
dnl Check for gudev
PKG_CHECK_MODULES(GUDEV, gudev-1.0 >= 147)
diff --git a/src/Makefile.am b/src/Makefile.am
index acf6c135..903102cf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,6 +7,7 @@ nm_applet_CPPFLAGS = \
$(NMA_CFLAGS) \
$(LIBSECRET_CFLAGS) \
$(NOTIFY_CFLAGS) \
+ $(MM_GLIB_CFLAGS) \
-DNM_VERSION_MIN_REQUIRED=NM_VERSION_0_9_10 \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_0_9_10 \
-DICONDIR=\""$(datadir)/icons"\" \
@@ -50,10 +51,6 @@ nm_applet_SOURCES = \
ap-menu-item.c \
mb-menu-item.h \
mb-menu-item.c \
- applet-device-gsm.h \
- applet-device-gsm.c \
- applet-device-cdma.h \
- applet-device-cdma.c \
mobile-helpers.c \
mobile-helpers.h \
applet-device-bt.h \
@@ -72,25 +69,24 @@ nm_applet_SOURCES = \
applet-device-infiniband.c \
fallback-icon.h
+if WITH_WWAN
+nm_applet_SOURCES += \
+ applet-device-broadband.h \
+ applet-device-broadband.c
+endif
+
nm_applet_LDADD = \
-lm \
$(GTK_LIBS) \
$(NMA_LIBS) \
$(LIBSECRET_LIBS) \
$(NOTIFY_LIBS) \
+ $(MM_GLIB_LIBS) \
${top_builddir}/src/marshallers/libmarshallers.la \
${top_builddir}/src/utils/libutils.la \
${top_builddir}/src/wireless-security/libwireless-security.la \
${top_builddir}/src/libnm-gtk/libnm-gtk.la
-if WITH_MODEM_MANAGER_1
-nm_applet_SOURCES += \
- applet-device-broadband.h \
- applet-device-broadband.c
-nm_applet_CPPFLAGS += $(MM_GLIB_CFLAGS)
-nm_applet_LDADD += $(MM_GLIB_LIBS)
-endif
-
if BUILD_MIGRATION_TOOL
SUBDIRS += gconf-helpers
diff --git a/src/applet-device-cdma.c b/src/applet-device-cdma.c
deleted file mode 100644
index 5abd75d7..00000000
--- a/src/applet-device-cdma.c
+++ /dev/null
@@ -1,746 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager Applet -- allow user control over networking
- *
- * Dan Williams <dcbw@redhat.com>
- *
- * 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.
- *
- * (C) Copyright 2008 - 2012 Red Hat, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
-
-#include <nm-device.h>
-#include <nm-setting-connection.h>
-#include <nm-setting-cdma.h>
-#include <nm-setting-serial.h>
-#include <nm-setting-ppp.h>
-#include <nm-device-modem.h>
-#include <nm-utils.h>
-#include <nm-secret-agent.h>
-
-#include "applet.h"
-#include "applet-device-cdma.h"
-#include "utils.h"
-#include "applet-dialogs.h"
-#include "nma-marshal.h"
-#include "nm-mobile-providers.h"
-#include "mb-menu-item.h"
-#include "nm-ui-utils.h"
-#include "nm-glib-compat.h"
-
-typedef struct {
- NMApplet *applet;
- NMDevice *device;
-
- DBusGConnection *bus;
- DBusGProxy *props_proxy;
- DBusGProxy *cdma_proxy;
- gboolean quality_valid;
- guint32 quality;
- guint32 cdma1x_state;
- guint32 evdo_state;
- gboolean evdo_capable;
- guint32 sid;
- gboolean modem_enabled;
-
- NMAMobileProvidersDatabase *mobile_providers_database;
- char *provider_name;
-
- guint32 poll_id;
- gboolean skip_reg_poll;
- gboolean skip_signal_poll;
-} CdmaDeviceInfo;
-
-static void check_start_polling (CdmaDeviceInfo *info);
-
-typedef struct {
- NMApplet *applet;
- NMDevice *device;
- NMConnection *connection;
-} CdmaMenuItemInfo;
-
-static void
-cdma_menu_item_info_destroy (gpointer data)
-{
- CdmaMenuItemInfo *info = data;
-
- g_object_unref (G_OBJECT (info->device));
- if (info->connection)
- g_object_unref (info->connection);
-
- g_slice_free (CdmaMenuItemInfo, data);
-}
-
-static gboolean
-cdma_new_auto_connection (NMDevice *device,
- gpointer dclass_data,
- AppletNewAutoConnectionCallback callback,
- gpointer callback_data)
-{
- return mobile_helper_wizard (NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO,
- callback,
- callback_data);
-}
-
-static void
-dbus_3g_add_and_activate_cb (NMClient *client,
- NMActiveConnection *active,
- const char *connection_path,
- GError *error,
- gpointer user_data)
-{
- if (error)
- g_warning ("Failed to add/activate connection: (%d) %s", error->code, error->message);
-}
-
-typedef struct {
- NMApplet *applet;
- NMDevice *device;
-} Dbus3gInfo;
-
-static void
-dbus_connect_3g_cb (NMConnection *connection,
- gboolean auto_created,
- gboolean canceled,
- gpointer user_data)
-{
- Dbus3gInfo *info = user_data;
-
- if (canceled == FALSE) {
- g_return_if_fail (connection != NULL);
-
- /* Ask NM to add the new connection and activate it; NM will fill in the
- * missing details based on the specific object and the device.
- */
- nm_client_add_and_activate_connection (info->applet->nm_client,
- connection,
- info->device,
- "/",
- dbus_3g_add_and_activate_cb,
- info->applet);
- }
-
- g_object_unref (info->device);
- memset (info, 0, sizeof (*info));
- g_free (info);
-}
-
-void
-applet_cdma_connect_network (NMApplet *applet, NMDevice *device)
-{
- Dbus3gInfo *info;
-
- info = g_malloc0 (sizeof (*info));
- info->applet = applet;
- info->device = g_object_ref (device);
-
- if (!mobile_helper_wizard (NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO,
- dbus_connect_3g_cb,
- info)) {
- g_warning ("Couldn't run mobile wizard for CDMA device");
- g_object_unref (info->device);
- g_free (info);
- }
-}
-
-static void
-cdma_menu_item_activate (GtkMenuItem *item, gpointer user_data)
-{
- CdmaMenuItemInfo *info = (CdmaMenuItemInfo *) user_data;
-
- applet_menu_item_activate_helper (info->device,
- info->connection,
- "/",
- info->applet,
- user_data);
-}
-
-static void
-add_connection_item (NMDevice *device,
- NMConnection *connection,
- GtkWidget *item,
- GtkWidget *menu,
- NMApplet *applet)
-{
- CdmaMenuItemInfo *info;
-
- info = g_slice_new0 (CdmaMenuItemInfo);
- info->applet = applet;
- info->device = g_object_ref (G_OBJECT (device));
- info->connection = connection ? g_object_ref (connection) : NULL;
-
- g_signal_connect_data (item, "activate",
- G_CALLBACK (cdma_menu_item_activate),
- info,
- (GClosureNotify) cdma_menu_item_info_destroy, 0);
-
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-}
-
-static guint32
-cdma_state_to_mb_state (CdmaDeviceInfo *info)
-{
- if (!info->modem_enabled)
- return MB_STATE_UNKNOWN;
-
- /* EVDO state overrides 1X state for now */
- if (info->evdo_state) {
- if (info->evdo_state == 3)
- return MB_STATE_ROAMING;
- return MB_STATE_HOME;
- } else if (info->cdma1x_state) {
- if (info->cdma1x_state == 3)
- return MB_STATE_ROAMING;
- return MB_STATE_HOME;
- }
-
- return MB_STATE_UNKNOWN;
-}
-
-static guint32
-cdma_act_to_mb_act (CdmaDeviceInfo *info)
-{
- if (info->evdo_state)
- return MB_TECH_EVDO;
- else if (info->cdma1x_state)
- return MB_TECH_1XRTT;
- return MB_TECH_UNKNOWN;
-}
-
-static void
-cdma_add_menu_item (NMDevice *device,
- gboolean multiple_devices,
- GSList *connections,
- NMConnection *active,
- GtkWidget *menu,
- NMApplet *applet)
-{
- CdmaDeviceInfo *info;
- char *text;
- GtkWidget *item;
- GSList *iter;
-
- info = g_object_get_data (G_OBJECT (device), "devinfo");
-
- if (multiple_devices) {
- const char *desc;
-
- desc = nma_utils_get_device_description (device);
- text = g_strdup_printf (_("Mobile Broadband (%s)"), desc);
- } else {
- text = g_strdup (_("Mobile Broadband"));
- }
-
- item = applet_menu_item_create_device_item_helper (device, applet, text);
- gtk_widget_set_sensitive (item, FALSE);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
- g_free (text);
-
- /* Add the active connection */
- if (active) {
- NMSettingConnection *s_con;
-
- s_con = nm_connection_get_setting_connection (active);
- g_assert (s_con);
-
- item = nm_mb_menu_item_new (nm_setting_connection_get_id (s_con),
- info->quality_valid ? info->quality : 0,
- info->provider_name,
- TRUE,
- cdma_act_to_mb_act (info),
- cdma_state_to_mb_state (info),
- info->modem_enabled,
- applet);
- gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
- add_connection_item (device, active, item, menu, applet);
- }
-
- /* Get the "disconnect" item if connected */
- if (nm_device_get_state (device) > NM_DEVICE_STATE_DISCONNECTED) {
- item = nma_menu_device_get_menu_item (device, applet, NULL);
- if (item) {
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
- }
- } else {
- /* Otherwise show idle registration state or disabled */
- item = nm_mb_menu_item_new (NULL,
- info->quality_valid ? info->quality : 0,
- info->provider_name,
- FALSE,
- cdma_act_to_mb_act (info),
- cdma_state_to_mb_state (info),
- info->modem_enabled,
- applet);
- gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- }
-
- /* Add the default / inactive connection items */
- if (!nma_menu_device_check_unusable (device)) {
- if ((!active && g_slist_length (connections)) || (active && g_slist_length (connections) > 1))
- applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"));
-
- if (g_slist_length (connections)) {
- for (iter = connections; iter; iter = g_slist_next (iter)) {
- NMConnection *connection = NM_CONNECTION (iter->data);
-
- if (connection != active) {
- item = applet_new_menu_item_helper (connection, NULL, FALSE);
- add_connection_item (device, connection, item, menu, applet);
- }
- }
- } else {
- /* Default connection item */
- item = gtk_check_menu_item_new_with_label (_("New Mobile Broadband (CDMA) connection..."));
- add_connection_item (device, NULL, item, menu, applet);
- }
- }
-}
-
-static void
-cdma_device_state_changed (NMDevice *device,
- NMDeviceState new_state,
- NMDeviceState old_state,
- NMDeviceStateReason reason,
- NMApplet *applet)
-{
- CdmaDeviceInfo *info;
-
- /* Start/stop polling of quality and registration when device state changes */
- info = g_object_get_data (G_OBJECT (device), "devinfo");
- check_start_polling (info);
-}
-
-static void
-cdma_notify_connected (NMDevice *device,
- const char *msg,
- NMApplet *applet)
-{
- applet_do_notify_with_pref (applet,
- _("Connection Established"),
- msg ? msg : _("You are now connected to the CDMA network."),
- "nm-device-wwan",
- PREF_DISABLE_CONNECTED_NOTIFICATIONS);
-}
-
-static void
-cdma_get_icon (NMDevice *device,
- NMDeviceState state,
- NMConnection *connection,
- GdkPixbuf **out_pixbuf,
- const char **out_icon_name,
- char **tip,
- NMApplet *applet)
-{
- CdmaDeviceInfo *info;
-
- info = g_object_get_data (G_OBJECT (device), "devinfo");
- g_assert (info);
-
- mobile_helper_get_icon (device,
- state,
- connection,
- out_pixbuf,
- out_icon_name,
- tip,
- applet,
- cdma_state_to_mb_state (info),
- cdma_act_to_mb_act (info),
- info->quality,
- info->quality_valid);
-}
-
-static gboolean
-cdma_get_secrets (SecretsRequest *req, GError **error)
-{
- return mobile_helper_get_secrets (NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO, req, error);
-}
-
-static void
-cdma_device_info_free (gpointer data)
-{
- CdmaDeviceInfo *info = data;
-
- if (info->props_proxy)
- g_object_unref (info->props_proxy);
- if (info->cdma_proxy)
- g_object_unref (info->cdma_proxy);
- if (info->bus)
- dbus_g_connection_unref (info->bus);
- if (info->poll_id)
- g_source_remove (info->poll_id);
- if (info->mobile_providers_database)
- g_object_unref (info->mobile_providers_database);
- g_free (info->provider_name);
- memset (info, 0, sizeof (CdmaDeviceInfo));
- g_free (info);
-}
-
-static void
-notify_user_of_cdma_reg_change (CdmaDeviceInfo *info)
-{
- guint32 mb_state = cdma_state_to_mb_state (info);
-
- if (mb_state == MB_STATE_HOME) {
- applet_do_notify_with_pref (info->applet,
- _("CDMA network."),
- _("You are now registered on the home network."),
- "nm-signal-100",
- PREF_DISABLE_CONNECTED_NOTIFICATIONS);
- } else if (mb_state == MB_STATE_ROAMING) {
- applet_do_notify_with_pref (info->applet,
- _("CDMA network."),
- _("You are now registered on a roaming network."),
- "nm-signal-100",
- PREF_DISABLE_CONNECTED_NOTIFICATIONS);
- }
-}
-
-static void
-update_registration_state (CdmaDeviceInfo *info,
- guint32 new_cdma1x_state,
- guint32 new_evdo_state)
-{
- guint32 old_mb_state = cdma_state_to_mb_state (info);
-
- if ( (info->cdma1x_state != new_cdma1x_state)
- || (info->evdo_state != new_evdo_state)) {
- info->cdma1x_state = new_cdma1x_state;
- info->evdo_state = new_evdo_state;
- }
-
- /* Use the composite state to notify of home/roaming changes */
- if (cdma_state_to_mb_state (info) != old_mb_state)
- notify_user_of_cdma_reg_change (info);
-}
-
-static void
-reg_state_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- CdmaDeviceInfo *info = user_data;
- GError *error = NULL;
- guint32 cdma1x_state = 0, evdo_state = 0;
-
- if (dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_UINT, &cdma1x_state,
- G_TYPE_UINT, &evdo_state,
- G_TYPE_INVALID)) {
- update_registration_state (info, cdma1x_state, evdo_state);
- applet_schedule_update_icon (info->applet);
- }
-
- g_clear_error (&error);
-}
-
-static void
-signal_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- CdmaDeviceInfo *info = user_data;
- GError *error = NULL;
- guint32 quality = 0;
-
- if (dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_UINT, &quality,
- G_TYPE_INVALID)) {
- info->quality = quality;
- info->quality_valid = TRUE;
- applet_schedule_update_icon (info->applet);
- }
-
- g_clear_error (&error);
-}
-
-#define SERVING_SYSTEM_TYPE (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID))
-
-static void
-serving_system_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- CdmaDeviceInfo *info = user_data;
- GError *error = NULL;
- GValueArray *array = NULL;
- guint32 new_sid = 0;
- GValue *value;
-
- if (dbus_g_proxy_end_call (proxy, call, &error,
- SERVING_SYSTEM_TYPE, &array,
- G_TYPE_INVALID)) {
- if (array->n_values == 3) {
- value = g_value_array_get_nth (array, 2);
- if (G_VALUE_HOLDS_UINT (value))
- new_sid = g_value_get_uint (value);
- }
-
- g_value_array_free (array);
- }
-
- if (new_sid != info->sid) {
- info->sid = new_sid;
- g_free (info->provider_name);
- info->provider_name = mobile_helper_parse_3gpp2_operator_name (&(info->mobile_providers_database), info->sid);
- }
-
- g_clear_error (&error);
-}
-
-static void
-enabled_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- CdmaDeviceInfo *info = user_data;
- GError *error = NULL;
- GValue value = { 0 };
-
- if (dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_VALUE, &value,
- G_TYPE_INVALID)) {
- if (G_VALUE_HOLDS_BOOLEAN (&value))
- info->modem_enabled = g_value_get_boolean (&value);
- g_value_unset (&value);
- }
-
- g_clear_error (&error);
- check_start_polling (info);
-}
-
-static gboolean
-cdma_poll_cb (gpointer user_data)
-{
- CdmaDeviceInfo *info = user_data;
-
- /* Kick off calls to get registration state and signal quality */
- if (!info->skip_reg_poll) {
- dbus_g_proxy_begin_call (info->cdma_proxy, "GetRegistrationState",
- reg_state_reply, info, NULL,
- G_TYPE_INVALID);
- info->skip_reg_poll = FALSE;
- }
-
- if (!info->skip_signal_poll) {
- dbus_g_proxy_begin_call (info->cdma_proxy, "GetSignalQuality",
- signal_reply, info, NULL,
- G_TYPE_INVALID);
- info->skip_signal_poll = FALSE;
- }
-
- dbus_g_proxy_begin_call (info->cdma_proxy, "GetServingSystem",
- serving_system_reply, info, NULL,
- G_TYPE_INVALID);
-
- return TRUE; /* keep running until we're told to stop */
-}
-
-static void
-check_start_polling (CdmaDeviceInfo *info)
-{
- NMDeviceState state;
- gboolean poll = TRUE;
-
- g_return_if_fail (info != NULL);
-
- /* Don't poll if any of the following are true:
- *
- * 1) NM says the device is not available
- * 3) the modem isn't enabled
- */
-
- state = nm_device_get_state (info->device);
- if ( (state <= NM_DEVICE_STATE_UNAVAILABLE)
- || (info->modem_enabled == FALSE))
- poll = FALSE;
-
- if (poll) {
- if (!info->poll_id) {
- /* 33 seconds to be just a bit more than MM's poll interval, so
- * that if we get an unsolicited update from MM between polls we'll
- * skip the next poll.
- */
- info->poll_id = g_timeout_add_seconds (33, cdma_poll_cb, info);
- }
- cdma_poll_cb (info);
- } else {
- if (info->poll_id)
- g_source_remove (info->poll_id);
- info->poll_id = 0;
- info->skip_reg_poll = FALSE;
- info->skip_signal_poll = FALSE;
- }
-}
-
-static void
-reg_state_changed_cb (DBusGProxy *proxy,
- guint32 cdma1x_state,
- guint32 evdo_state,
- gpointer user_data)
-{
- CdmaDeviceInfo *info = user_data;
-
- update_registration_state (info, cdma1x_state, evdo_state);
- info->skip_reg_poll = TRUE;
- applet_schedule_update_icon (info->applet);
-}
-
-static void
-signal_quality_changed_cb (DBusGProxy *proxy,
- guint32 quality,
- gpointer user_data)
-{
- CdmaDeviceInfo *info = user_data;
-
- info->quality = quality;
- info->quality_valid = TRUE;
- info->skip_signal_poll = TRUE;
-
- applet_schedule_update_icon (info->applet);
-}
-
-#define MM_OLD_DBUS_INTERFACE_MODEM "org.freedesktop.ModemManager.Modem"
-#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
-
-static void
-modem_properties_changed (DBusGProxy *proxy,
- const char *interface,
- GHashTable *props,
- gpointer user_data)
-{
- CdmaDeviceInfo *info = user_data;
- GValue *value;
-
- if (!strcmp (interface, MM_OLD_DBUS_INTERFACE_MODEM)) {
- value = g_hash_table_lookup (props, "Enabled");
- if (value && G_VALUE_HOLDS_BOOLEAN (value)) {
- info->modem_enabled = g_value_get_boolean (value);
- if (!info->modem_enabled) {
- info->quality = 0;
- info->quality_valid = 0;
- info->cdma1x_state = 0;
- info->evdo_state = 0;
- info->sid = 0;
- g_free (info->provider_name);
- info->provider_name = NULL;
- }
- check_start_polling (info);
- }
- }
-}
-
-static void
-cdma_device_added (NMDevice *device, NMApplet *applet)
-{
- NMDeviceModem *modem = NM_DEVICE_MODEM (device);
- CdmaDeviceInfo *info;
- DBusGConnection *bus;
- const char *udi;
- GError *error = NULL;
-
- udi = nm_device_get_udi (device);
- if (!udi)
- return;
-
- bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (!bus) {
- g_warning ("%s: failed to connect to D-Bus: (%d) %s", __func__, error->code, error->message);
- g_clear_error (&error);
- return;
- }
-
- info = g_malloc0 (sizeof (CdmaDeviceInfo));
- info->applet = applet;
- info->device = device;
- info->bus = bus;
- info->quality_valid = FALSE;
-
- info->props_proxy = dbus_g_proxy_new_for_name (bus,
- "org.freedesktop.ModemManager",
- udi,
- "org.freedesktop.DBus.Properties");
- if (!info->props_proxy) {
- g_message ("%s: failed to create D-Bus properties proxy.", __func__);
- cdma_device_info_free (info);
- return;
- }
-
- info->cdma_proxy = dbus_g_proxy_new_for_name (bus,
- "org.freedesktop.ModemManager",
- udi,
- "org.freedesktop.ModemManager.Modem.Cdma");
- if (!info->cdma_proxy) {
- g_message ("%s: failed to create CDMA proxy.", __func__);
- cdma_device_info_free (info);
- return;
- }
-
- g_object_set_data_full (G_OBJECT (modem), "devinfo", info, cdma_device_info_free);
-
- /* Registration state change signal */
- dbus_g_object_register_marshaller (_nma_marshal_VOID__UINT_UINT,
- G_TYPE_NONE,
- G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_add_signal (info->cdma_proxy, "RegistrationStateChanged",
- G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (info->cdma_proxy, "RegistrationStateChanged",
- G_CALLBACK (reg_state_changed_cb), info, NULL);
-
- /* Signal quality change signal */
- dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__UINT,
- G_TYPE_NONE, G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_add_signal (info->cdma_proxy, "SignalQuality", G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (info->cdma_proxy, "SignalQuality",
- G_CALLBACK (signal_quality_changed_cb), info, NULL);
-
- /* Modem property change signal */
- dbus_g_object_register_marshaller (_nma_marshal_VOID__STRING_BOXED,
- G_TYPE_NONE, G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT,
- G_TYPE_INVALID);
- dbus_g_proxy_add_signal (info->props_proxy, "MmPropertiesChanged",
- G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (info->props_proxy, "MmPropertiesChanged",
- G_CALLBACK (modem_properties_changed),
- info, NULL);
-
- /* Ask whether the device is enabled */
- dbus_g_proxy_begin_call (info->props_proxy, "Get",
- enabled_reply, info, NULL,
- G_TYPE_STRING, MM_OLD_DBUS_INTERFACE_MODEM,
- G_TYPE_STRING, "Enabled",
- G_TYPE_INVALID);
-}
-
-NMADeviceClass *
-applet_device_cdma_get_class (NMApplet *applet)
-{
- NMADeviceClass *dclass;
-
- dclass = g_slice_new0 (NMADeviceClass);
- if (!dclass)
- return NULL;
-
- dclass->new_auto_connection = cdma_new_auto_connection;
- dclass->add_menu_item = cdma_add_menu_item;
- dclass->device_state_changed = cdma_device_state_changed;
- dclass->notify_connected = cdma_notify_connected;
- dclass->get_icon = cdma_get_icon;
- dclass->get_secrets = cdma_get_secrets;
- dclass->secrets_request_size = sizeof (MobileHelperSecretsInfo);
- dclass->device_added = cdma_device_added;
-
- return dclass;
-}
diff --git a/src/applet-device-cdma.h b/src/applet-device-cdma.h
deleted file mode 100644
index 75e4f33a..00000000
--- a/src/applet-device-cdma.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager Applet -- allow user control over networking
- *
- * Dan Williams <dcbw@redhat.com>
- *
- * 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.
- *
- * (C) Copyright 2008 Red Hat, Inc.
- */
-
-#ifndef __APPLET_DEVICE_CDMA_H__
-#define __APPLET_DEVICE_CDMA_H__
-
-#include "applet.h"
-
-NMADeviceClass *applet_device_cdma_get_class (NMApplet *applet);
-
-void applet_cdma_connect_network (NMApplet *applet, NMDevice *device);
-
-#endif /* __APPLET_DEVICE_CDMA_H__ */
diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
deleted file mode 100644
index b3982240..00000000
--- a/src/applet-device-gsm.c
+++ /dev/null
@@ -1,1221 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager Applet -- allow user control over networking
- *
- * Dan Williams <dcbw@redhat.com>
- *
- * 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.
- *
- * (C) Copyright 2008 - 2012 Red Hat, Inc.
- * (C) Copyright 2008 Novell, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <ctype.h>
-
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
-
-#define SECRET_API_SUBJECT_TO_CHANGE
-#include <libsecret/secret.h>
-
-#include <nm-device.h>
-#include <nm-setting-connection.h>
-#include <nm-setting-gsm.h>
-#include <nm-setting-serial.h>
-#include <nm-setting-ppp.h>
-#include <nm-device-modem.h>
-#include <nm-utils.h>
-#include <nm-secret-agent.h>
-
-#include "applet.h"
-#include "applet-device-gsm.h"
-#include "utils.h"
-#include "applet-dialogs.h"
-#include "mb-menu-item.h"
-#include "nma-marshal.h"
-#include "nm-mobile-providers.h"
-#include "nm-ui-utils.h"
-#include "nm-glib-compat.h"
-
-typedef enum {
- MM_MODEM_GSM_ACCESS_TECH_UNKNOWN = 0,
- MM_MODEM_GSM_ACCESS_TECH_GSM = 1,
- MM_MODEM_GSM_ACCESS_TECH_GSM_COMPACT = 2,
- MM_MODEM_GSM_ACCESS_TECH_GPRS = 3,
- MM_MODEM_GSM_ACCESS_TECH_EDGE = 4, /* GSM w/EGPRS */
- MM_MODEM_GSM_ACCESS_TECH_UMTS = 5, /* UTRAN */
- MM_MODEM_GSM_ACCESS_TECH_HSDPA = 6, /* UTRAN w/HSDPA */
- MM_MODEM_GSM_ACCESS_TECH_HSUPA = 7, /* UTRAN w/HSUPA */
- MM_MODEM_GSM_ACCESS_TECH_HSPA = 8, /* UTRAN w/HSDPA and HSUPA */
- MM_MODEM_GSM_ACCESS_TECH_HSPA_PLUS = 9,
- MM_MODEM_GSM_ACCESS_TECH_LTE = 10,
-
- MM_MODEM_GSM_ACCESS_TECH_LAST = MM_MODEM_GSM_ACCESS_TECH_LTE
-} MMModemGsmAccessTech;
-
-typedef struct {
- NMApplet *applet;
- NMDevice *device;
-
- DBusGConnection *bus;
- DBusGProxy *props_proxy;
- DBusGProxy *card_proxy;
- DBusGProxy *net_proxy;
-
- gboolean quality_valid;
- guint32 quality;
- char *unlock_required;
- char *devid;
- char *simid;
- gboolean modem_enabled;
- MMModemGsmAccessTech act;
-
- /* reg_state is (1 + MM reg state) so that 0 means we haven't gotten a
- * value from MM yet. 0 is a valid MM GSM reg state.
- */
- guint reg_state;
- char *op_code;
- char *op_name;
- NMAMobileProvidersDatabase *mobile_providers_database;
-
- guint32 poll_id;
- gboolean skip_reg_poll;
- gboolean skip_signal_poll;
-
- /* Unlock dialog stuff */
- GtkWidget *dialog;
- GCancellable *cancellable;
-} GsmDeviceInfo;
-
-static void unlock_dialog_destroy (GsmDeviceInfo *info);
-static void check_start_polling (GsmDeviceInfo *info);
-
-typedef struct {
- NMApplet *applet;
- NMDevice *device;
- NMConnection *connection;
-} GSMMenuItemInfo;
-
-static void
-gsm_menu_item_info_destroy (gpointer data)
-{
- GSMMenuItemInfo *info = data;
-
- g_object_unref (G_OBJECT (info->device));
- if (info->connection)
- g_object_unref (info->connection);
-
- g_slice_free (GSMMenuItemInfo, data);
-}
-
-static gboolean
-gsm_new_auto_connection (NMDevice *device,
- gpointer dclass_data,
- AppletNewAutoConnectionCallback callback,
- gpointer callback_data)
-{
- return mobile_helper_wizard (NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS,
- callback,
- callback_data);
-}
-
-static void
-dbus_3g_add_and_activate_cb (NMClient *client,
- NMActiveConnection *active,
- const char *connection_path,
- GError *error,
- gpointer user_data)
-{
- if (error)
- g_warning ("Failed to add/activate connection: (%d) %s", error->code, error->message);
-}
-
-typedef struct {
- NMApplet *applet;
- NMDevice *device;
-} Dbus3gInfo;
-
-static void
-dbus_connect_3g_cb (NMConnection *connection,
- gboolean auto_created,
- gboolean canceled,
- gpointer user_data)
-{
- Dbus3gInfo *info = user_data;
-
- if (canceled == FALSE) {
- g_return_if_fail (connection != NULL);
-
- /* Ask NM to add the new connection and activate it; NM will fill in the
- * missing details based on the specific object and the device.
- */
- nm_client_add_and_activate_connection (info->applet->nm_client,
- connection,
- info->device,
- "/",
- dbus_3g_add_and_activate_cb,
- info->applet);
- }
-
- g_object_unref (info->device);
- memset (info, 0, sizeof (*info));
- g_free (info);
-}
-
-void
-applet_gsm_connect_network (NMApplet *applet, NMDevice *device)
-{
- Dbus3gInfo *info;
-
- info = g_malloc0 (sizeof (*info));
- info->applet = applet;
- info->device = g_object_ref (device);
-
-
- if (!mobile_helper_wizard (NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS,
- dbus_connect_3g_cb,
- info)) {
- g_warning ("Couldn't run mobile wizard for CDMA device");
- g_object_unref (info->device);
- g_free (info);
- }
-}
-
-static void
-gsm_menu_item_activate (GtkMenuItem *item, gpointer user_data)
-{
- GSMMenuItemInfo *info = (GSMMenuItemInfo *) user_data;
-
- applet_menu_item_activate_helper (info->device,
- info->connection,
- "/",
- info->applet,
- user_data);
-}
-
-static void
-add_connection_item (NMDevice *device,
- NMConnection *connection,
- GtkWidget *item,
- GtkWidget *menu,
- NMApplet *applet)
-{
- GSMMenuItemInfo *info;
-
- info = g_slice_new0 (GSMMenuItemInfo);
- info->applet = applet;
- info->device = g_object_ref (G_OBJECT (device));
- info->connection = connection ? g_object_ref (connection) : NULL;
-
- g_signal_connect_data (item, "activate",
- G_CALLBACK (gsm_menu_item_activate),
- info,
- (GClosureNotify) gsm_menu_item_info_destroy, 0);
-
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-}
-
-static guint32
-gsm_state_to_mb_state (GsmDeviceInfo *info)
-{
- if (!info->modem_enabled)
- return MB_STATE_UNKNOWN;
-
- switch (info->reg_state) {
- case 1: /* IDLE */
- return MB_STATE_IDLE;
- case 2: /* HOME */
- return MB_STATE_HOME;
- case 3: /* SEARCHING */
- return MB_STATE_SEARCHING;
- case 4: /* DENIED */
- return MB_STATE_DENIED;
- case 6: /* ROAMING */
- return MB_STATE_ROAMING;
- case 5: /* UNKNOWN */
- default:
- break;
- }
-
- return MB_STATE_UNKNOWN;
-}
-
-static guint32
-gsm_act_to_mb_act (GsmDeviceInfo *info)
-{
- switch (info->act) {
- case MM_MODEM_GSM_ACCESS_TECH_GPRS:
- return MB_TECH_GPRS;
- case MM_MODEM_GSM_ACCESS_TECH_EDGE:
- return MB_TECH_EDGE;
- case MM_MODEM_GSM_ACCESS_TECH_UMTS:
- return MB_TECH_UMTS;
- case MM_MODEM_GSM_ACCESS_TECH_HSDPA:
- return MB_TECH_HSDPA;
- case MM_MODEM_GSM_ACCESS_TECH_HSUPA:
- return MB_TECH_HSUPA;
- case MM_MODEM_GSM_ACCESS_TECH_HSPA:
- return MB_TECH_HSPA;
- case MM_MODEM_GSM_ACCESS_TECH_HSPA_PLUS:
- return MB_TECH_HSPA_PLUS;
- case MM_MODEM_GSM_ACCESS_TECH_LTE:
- return MB_TECH_LTE;
- default:
- break;
- }
-
- return MB_TECH_GSM;
-}
-
-static void
-gsm_add_menu_item (NMDevice *device,
- gboolean multiple_devices,
- GSList *connections,
- NMConnection *active,
- GtkWidget *menu,
- NMApplet *applet)
-{
- GsmDeviceInfo *info;
- char *text;
- GtkWidget *item;
- GSList *iter;
-
- info = g_object_get_data (G_OBJECT (device), "devinfo");
-
- if (multiple_devices) {
- const char *desc;
-
- desc = nma_utils_get_device_description (device);
- text = g_strdup_printf (_("Mobile Broadband (%s)"), desc);
- } else {
- text = g_strdup (_("Mobile Broadband"));
- }
-
- item = applet_menu_item_create_device_item_helper (device, applet, text);
- gtk_widget_set_sensitive (item, FALSE);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
- g_free (text);
-
- /* Add the active connection */
- if (active) {
- NMSettingConnection *s_con;
-
- s_con = nm_connection_get_setting_connection (active);
- g_assert (s_con);
-
- item = nm_mb_menu_item_new (nm_setting_connection_get_id (s_con),
- info->quality_valid ? info->quality : 0,
- info->op_name,
- TRUE,
- gsm_act_to_mb_act (info),
- gsm_state_to_mb_state (info),
- info->modem_enabled,
- applet);
- gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
- add_connection_item (device, active, item, menu, applet);
- }
-
- /* Notify user of unmanaged or unavailable device */
- if (nm_device_get_state (device) > NM_DEVICE_STATE_DISCONNECTED) {
- item = nma_menu_device_get_menu_item (device, applet, NULL);
- if (item) {
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
- }
- } else {
- /* Otherwise show idle registration state or disabled */
- item = nm_mb_menu_item_new (NULL,
- info->quality_valid ? info->quality : 0,
- info->op_name,
- FALSE,
- gsm_act_to_mb_act (info),
- gsm_state_to_mb_state (info),
- info->modem_enabled,
- applet);
- gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- }
-
- /* Add the default / inactive connection items */
- if (!nma_menu_device_check_unusable (device)) {
- if ((!active && g_slist_length (connections)) || (active && g_slist_length (connections) > 1))
- applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"));
-
- if (g_slist_length (connections)) {
- for (iter = connections; iter; iter = g_slist_next (iter)) {
- NMConnection *connection = NM_CONNECTION (iter->data);
-
- if (connection != active) {
- item = applet_new_menu_item_helper (connection, NULL, FALSE);
- add_connection_item (device, connection, item, menu, applet);
- }
- }
- } else {
- /* Default connection item */
- item = gtk_check_menu_item_new_with_label (_("New Mobile Broadband (GSM) connection..."));
- add_connection_item (device, NULL, item, menu, applet);
- }
- }
-}
-
-static void
-gsm_device_state_changed (NMDevice *device,
- NMDeviceState new_state,
- NMDeviceState old_state,
- NMDeviceStateReason reason,
- NMApplet *applet)
-{
- GsmDeviceInfo *info;
-
- /* Start/stop polling of quality and registration when device state changes */
- info = g_object_get_data (G_OBJECT (device), "devinfo");
- check_start_polling (info);
-}
-
-static void
-gsm_notify_connected (NMDevice *device,
- const char *msg,
- NMApplet *applet)
-{
- applet_do_notify_with_pref (applet,
- _("Connection Established"),
- msg ? msg : _("You are now connected to the GSM network."),
- "nm-device-wwan",
- PREF_DISABLE_CONNECTED_NOTIFICATIONS);
-}
-
-static void
-gsm_get_icon (NMDevice *device,
- NMDeviceState state,
- NMConnection *connection,
- GdkPixbuf **out_pixbuf,
- const char **out_icon_name,
- char **tip,
- NMApplet *applet)
-{
- GsmDeviceInfo *info;
-
- info = g_object_get_data (G_OBJECT (device), "devinfo");
- g_assert (info);
-
- mobile_helper_get_icon (device,
- state,
- connection,
- out_pixbuf,
- out_icon_name,
- tip,
- applet,
- gsm_state_to_mb_state (info),
- gsm_act_to_mb_act (info),
- info->quality,
- info->quality_valid);
-}
-
-static gboolean
-gsm_get_secrets (SecretsRequest *req, GError **error)
-{
- NMDevice *device;
- GsmDeviceInfo *devinfo;
-
- if (!mobile_helper_get_secrets (NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS, req, error))
- return FALSE;
-
- device = applet_get_device_for_connection (req->applet, req->connection);
- if (!device) {
- g_set_error (error,
- NM_SECRET_AGENT_ERROR,
- NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
- "%s.%d (%s): failed to find device for active connection.",
- __FILE__, __LINE__, __func__);
- return FALSE;
- }
-
- devinfo = g_object_get_data (G_OBJECT (device), "devinfo");
- g_assert (devinfo);
-
- /* A GetSecrets PIN dialog overrides the initial unlock dialog */
- if (devinfo->dialog)
- unlock_dialog_destroy (devinfo);
-
- return TRUE;
-}
-
-/********************************************************************/
-
-static void
-unlock_dialog_destroy (GsmDeviceInfo *info)
-{
- gtk_widget_destroy (info->dialog);
- info->dialog = NULL;
-}
-
-static void
-unlock_pin_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- GsmDeviceInfo *info = user_data;
- GError *error = NULL;
- const char *dbus_error, *msg = NULL, *code1;
-
- if (dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID)) {
- if (applet_mobile_pin_dialog_get_auto_unlock (info->dialog)) {
- code1 = applet_mobile_pin_dialog_get_entry1 (info->dialog);
- mobile_helper_save_pin_in_keyring (info->devid, info->simid, code1);
- } else
- mobile_helper_delete_pin_in_keyring (info->devid);
- unlock_dialog_destroy (info);
- return;
- }
-
- dbus_error = dbus_g_error_get_name (error);
- if (dbus_error && !strcmp (dbus_error, "org.freedesktop.ModemManager.Modem.Gsm.IncorrectPassword"))
- msg = _("Wrong PIN code; please contact your provider.");
- else
- msg = error ? error->message : NULL;
-
- applet_mobile_pin_dialog_stop_spinner (info->dialog, msg);
- g_warning ("%s: error unlocking with PIN: %s", __func__, error ? error->message : "unknown");
- g_clear_error (&error);
-}
-
-static void
-unlock_puk_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- GsmDeviceInfo *info = user_data;
- GError *error = NULL;
- const char *dbus_error, *msg = NULL;
-
- if (dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID)) {
- unlock_dialog_destroy (info);
- return;
- }
-
- dbus_error = dbus_g_error_get_name (error);
- if (dbus_error && !strcmp (dbus_error, "org.freedesktop.ModemManager.Modem.Gsm.IncorrectPassword"))
- msg = _("Wrong PUK code; please contact your provider.");
- else
- msg = error ? error->message : NULL;
-
- applet_mobile_pin_dialog_stop_spinner (info->dialog, msg);
- g_warning ("%s: error unlocking with PUK: %s", __func__, error ? error->message : "unknown");
- g_clear_error (&error);
-}
-
-#define UNLOCK_CODE_PIN 1
-#define UNLOCK_CODE_PUK 2
-
-static void
-unlock_dialog_response (GtkDialog *dialog,
- gint response,
- gpointer user_data)
-{
- GsmDeviceInfo *info = user_data;
- const char *code1, *code2;
- guint32 unlock_code;
-
- if (response == GTK_RESPONSE_CANCEL || response == GTK_RESPONSE_DELETE_EVENT) {
- unlock_dialog_destroy (info);
- return;
- }
-
- /* Start the spinner to show the progress of the unlock */
- applet_mobile_pin_dialog_start_spinner (info->dialog, _("Sending unlock code..."));
-
- unlock_code = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (info->dialog), "unlock-code"));
- if (!unlock_code) {
- g_warn_if_fail (unlock_code != 0);
- unlock_dialog_destroy (info);
- return;
- }
-
- code1 = applet_mobile_pin_dialog_get_entry1 (info->dialog);
- if (!code1 || !strlen (code1)) {
- g_warn_if_fail (code1 != NULL && strlen (code1));
- unlock_dialog_destroy (info);
- return;
- }
-
- /* Send the code to ModemManager */
- if (unlock_code == UNLOCK_CODE_PIN) {
- dbus_g_proxy_begin_call_with_timeout (info->card_proxy, "SendPin",
- unlock_pin_reply, info, NULL,
- 15000, /* 15 seconds */
- G_TYPE_STRING, code1,
- G_TYPE_INVALID);
- } else if (unlock_code == UNLOCK_CODE_PUK) {
- code2 = applet_mobile_pin_dialog_get_entry2 (info->dialog);
- if (!code2) {
- g_warn_if_fail (code2 != NULL);
- unlock_dialog_destroy (info);
- return;
- }
-
- dbus_g_proxy_begin_call_with_timeout (info->card_proxy, "SendPuk",
- unlock_puk_reply, info, NULL,
- 15000, /* 15 seconds */
- G_TYPE_STRING, code1,
- G_TYPE_STRING, code2,
- G_TYPE_INVALID);
- }
-}
-
-static void
-unlock_dialog_new (NMDevice *device, GsmDeviceInfo *info)
-{
- g_return_if_fail (info->unlock_required != NULL);
- g_return_if_fail (!strcmp (info->unlock_required, "sim-pin") || !strcmp (info->unlock_required, "sim-puk"));
-
- if (info->dialog)
- return;
-
- info->dialog = applet_mobile_pin_dialog_new (info->unlock_required,
- nma_utils_get_device_description (device));
-
- if (!strcmp (info->unlock_required, "sim-pin"))
- g_object_set_data (G_OBJECT (info->dialog), "unlock-code", GUINT_TO_POINTER (UNLOCK_CODE_PIN));
- else if (!strcmp (info->unlock_required, "sim-puk"))
- g_object_set_data (G_OBJECT (info->dialog), "unlock-code", GUINT_TO_POINTER (UNLOCK_CODE_PUK));
- else
- g_assert_not_reached ();
-
- g_signal_connect (info->dialog, "response", G_CALLBACK (unlock_dialog_response), info);
-
- /* Need to resize the dialog after hiding widgets */
- gtk_window_resize (GTK_WINDOW (info->dialog), 400, 100);
-
- /* Show the dialog */
- gtk_widget_realize (info->dialog);
- gtk_window_present (GTK_WINDOW (info->dialog));
-}
-
-/********************************************************************/
-
-static void
-gsm_device_info_free (gpointer data)
-{
- GsmDeviceInfo *info = data;
-
- if (info->props_proxy)
- g_object_unref (info->props_proxy);
- if (info->card_proxy)
- g_object_unref (info->card_proxy);
- if (info->net_proxy)
- g_object_unref (info->net_proxy);
- if (info->bus)
- dbus_g_connection_unref (info->bus);
-
- if (info->mobile_providers_database)
- g_object_unref (info->mobile_providers_database);
-
- if (info->poll_id)
- g_source_remove (info->poll_id);
-
- if (info->dialog)
- unlock_dialog_destroy (info);
-
- g_object_unref (info->cancellable);
-
- g_free (info->devid);
- g_free (info->simid);
- g_free (info->op_code);
- g_free (info->op_name);
- memset (info, 0, sizeof (GsmDeviceInfo));
- g_free (info);
-}
-
-static void
-signal_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- GsmDeviceInfo *info = user_data;
- GError *error = NULL;
- guint32 quality = 0;
-
- if (dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_UINT, &quality,
- G_TYPE_INVALID)) {
- info->quality = quality;
- info->quality_valid = TRUE;
- applet_schedule_update_icon (info->applet);
- }
-
- g_clear_error (&error);
-}
-
-static void
-notify_user_of_gsm_reg_change (GsmDeviceInfo *info)
-{
- guint32 mb_state = gsm_state_to_mb_state (info);
-
- if (mb_state == MB_STATE_HOME) {
- applet_do_notify_with_pref (info->applet,
- _("GSM network."),
- _("You are now registered on the home network."),
- "nm-signal-100",
- PREF_DISABLE_CONNECTED_NOTIFICATIONS);
- } else if (mb_state == MB_STATE_ROAMING) {
- applet_do_notify_with_pref (info->applet,
- _("GSM network."),
- _("You are now registered on a roaming network."),
- "nm-signal-100",
- PREF_DISABLE_CONNECTED_NOTIFICATIONS);
- }
-}
-
-#define REG_INFO_TYPE (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID))
-#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
-
-static void
-reg_info_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- GsmDeviceInfo *info = user_data;
- GError *error = NULL;
- GValueArray *array = NULL;
- guint32 new_state = 0;
- char *new_op_code = NULL;
- char *new_op_name = NULL;
- GValue *value;
-
- if (dbus_g_proxy_end_call (proxy, call, &error, REG_INFO_TYPE, &array, G_TYPE_INVALID)) {
- if (array->n_values == 3) {
- value = g_value_array_get_nth (array, 0);
- if (G_VALUE_HOLDS_UINT (value))
- new_state = g_value_get_uint (value) + 1;
-
- value = g_value_array_get_nth (array, 1);
- if (G_VALUE_HOLDS_STRING (value)) {
- new_op_code = g_value_dup_string (value);
- if (new_op_code && !strlen (new_op_code)) {
- g_free (new_op_code);
- new_op_code = NULL;
- }
- }
-
- value = g_value_array_get_nth (array, 2);
- if (G_VALUE_HOLDS_STRING (value))
- new_op_name = mobile_helper_parse_3gpp_operator_name (&(info->mobile_providers_database),
- g_value_get_string (value),
- new_op_code);
- }
-
- g_value_array_free (array);
- }
-
- if (info->reg_state != new_state) {
- info->reg_state = new_state;
- notify_user_of_gsm_reg_change (info);
- }
-
- g_free (info->op_code);
- info->op_code = new_op_code;
- g_free (info->op_name);
- info->op_name = new_op_name;
-
- g_clear_error (&error);
-}
-
-static void
-enabled_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- GsmDeviceInfo *info = user_data;
- GError *error = NULL;
- GValue value = { 0 };
-
- if (dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_VALUE, &value,
- G_TYPE_INVALID)) {
- if (G_VALUE_HOLDS_BOOLEAN (&value))
- info->modem_enabled = g_value_get_boolean (&value);
- g_value_unset (&value);
- }
-
- g_clear_error (&error);
- check_start_polling (info);
-}
-
-static char *
-parse_unlock_required (GValue *value)
-{
- const char *new_val;
-
- /* Empty string means NULL */
- new_val = g_value_get_string (value);
- if (new_val && strlen (new_val)) {
- /* PIN2/PUK2 only required for various dialing things that we don't care
- * about; it doesn't inhibit normal operation.
- */
- if (strcmp (new_val, "sim-puk2") && strcmp (new_val, "sim-pin2"))
- return g_strdup (new_val);
- }
-
- return NULL;
-}
-
-static void
-keyring_unlock_pin_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- GsmDeviceInfo *info = user_data;
- GError *error = NULL;
-
- if (!dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID)) {
- g_warning ("Failed to auto-unlock devid:%s simid:%s : (%s) %s",
- info->devid ? info->devid : "(unknown)",
- info->simid ? info->simid : "(unknown)",
- dbus_g_error_get_name (error),
- error->message);
- /* Ask the user */
- unlock_dialog_new (info->device, info);
- g_clear_error (&error);
- }
-}
-
-static void
-keyring_pin_check_cb (GObject *source,
- GAsyncResult *result,
- gpointer user_data)
-{
- GsmDeviceInfo *info = user_data;
- GList *iter;
- GList *list;
- SecretItem *item;
- GError *error = NULL;
- SecretValue *pin = NULL;
- GHashTable *attributes;
- const gchar *simid;
-
- list = secret_service_search_finish (NULL, result, &error);
-
- if (!list) {
- /* No saved PIN, just ask the user */
- unlock_dialog_new (info->device, info);
- g_clear_error (&error);
- return;
- }
-
- /* Look for a result with a matching "simid" attribute since that's
- * better than just using a matching "devid". The PIN is really tied
- * to the SIM, not the modem itself.
- */
- for (iter = list;
- info->simid && (pin == NULL) && iter;
- iter = g_list_next (iter)) {
- item = iter->data;
-
- /* Look for a matching "simid" attribute */
- attributes = secret_item_get_attributes (item);
- simid = g_hash_table_lookup (attributes, "simid");
- if (g_strcmp0 (simid, info->simid))
- pin = secret_item_get_secret (item);
- else
- pin = NULL;
- g_hash_table_unref (attributes);
-
- if (pin != NULL)
- break;
- }
-
- if (pin == NULL) {
- /* Fall back to the first result's PIN */
- pin = secret_item_get_secret (list->data);
- if (pin == NULL) {
- unlock_dialog_new (info->device, info);
- return;
- }
- }
-
- /* Send the PIN code to ModemManager */
- if (!dbus_g_proxy_begin_call_with_timeout (info->card_proxy, "SendPin",
- keyring_unlock_pin_reply, info, NULL,
- 15000, /* 15 seconds */
- G_TYPE_STRING, secret_value_get (pin, NULL),
- G_TYPE_INVALID)) {
- g_warning ("Failed to auto-unlock devid:%s simid:%s",
- info->devid ? info->devid : "(unknown)",
- info->simid ? info->simid : "(unknown)");
- }
-
- secret_value_unref (pin);
-}
-
-static void
-simid_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- GsmDeviceInfo *info = user_data;
- GError *error = NULL;
- GValue value = { 0 };
- GHashTable *attrs;
-
- if (dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_VALUE, &value,
- G_TYPE_INVALID)) {
- if (G_VALUE_HOLDS_STRING (&value)) {
- g_free (info->simid);
- info->simid = g_value_dup_string (&value);
- }
- g_value_unset (&value);
- }
- g_clear_error (&error);
-
- /* Procure unlock code and apply it if an unlock is now required. */
- if (info->unlock_required) {
- /* If we have a device ID ask the keyring for any saved SIM-PIN codes */
- if (info->devid && (g_strcmp0 (info->unlock_required, "sim-pin") == 0)) {
- attrs = secret_attributes_build (&mobile_secret_schema, "devid", info->devid, NULL);
- secret_service_search (NULL, &mobile_secret_schema, attrs,
- SECRET_SEARCH_UNLOCK | SECRET_SEARCH_LOAD_SECRETS,
- info->cancellable, keyring_pin_check_cb, info);
- g_hash_table_unref (attrs);
- } else {
- /* Couldn't get a device ID, but unlock required; present dialog */
- unlock_dialog_new (info->device, info);
- }
- }
-
- check_start_polling (info);
-}
-
-#define MM_OLD_DBUS_INTERFACE_MODEM_GSM_CARD "org.freedesktop.ModemManager.Modem.Gsm.Card"
-
-static void
-unlock_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- GsmDeviceInfo *info = user_data;
- GError *error = NULL;
- GHashTable *props = NULL;
-
- if (dbus_g_proxy_end_call (proxy, call, &error,
- DBUS_TYPE_G_MAP_OF_VARIANT, &props,
- G_TYPE_INVALID)) {
- GHashTableIter iter;
- const char *prop_name;
- GValue *value;
-
- g_hash_table_iter_init (&iter, props);
- while (g_hash_table_iter_next (&iter, (gpointer) &prop_name, (gpointer) &value)) {
- if ((strcmp (prop_name, "UnlockRequired") == 0) && G_VALUE_HOLDS_STRING (value)) {
- g_free (info->unlock_required);
- info->unlock_required = parse_unlock_required (value);
- }
-
- if ((strcmp (prop_name, "DeviceIdentifier") == 0) && G_VALUE_HOLDS_STRING (value)) {
- g_free (info->devid);
- info->devid = g_value_dup_string (value);
- }
- }
- g_hash_table_destroy (props);
-
- /* Get SIM card identifier */
- dbus_g_proxy_begin_call (info->props_proxy, "Get",
- simid_reply, info, NULL,
- G_TYPE_STRING, MM_OLD_DBUS_INTERFACE_MODEM_GSM_CARD,
- G_TYPE_STRING, "SimIdentifier",
- G_TYPE_INVALID);
- }
-
- g_clear_error (&error);
- check_start_polling (info);
-}
-
-static void
-access_tech_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- GsmDeviceInfo *info = user_data;
- GError *error = NULL;
- GValue value = { 0 };
-
- if (dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_VALUE, &value,
- G_TYPE_INVALID)) {
- if (G_VALUE_HOLDS_UINT (&value)) {
- info->act = g_value_get_uint (&value);
- applet_schedule_update_icon (info->applet);
- }
- g_value_unset (&value);
- }
- g_clear_error (&error);
-}
-
-static gboolean
-gsm_poll_cb (gpointer user_data)
-{
- GsmDeviceInfo *info = user_data;
-
- /* MM might have just sent an unsolicited update, in which case we just
- * skip this poll and wait till the next one.
- */
-
- if (!info->skip_reg_poll) {
- dbus_g_proxy_begin_call (info->net_proxy, "GetRegistrationInfo",
- reg_info_reply, info, NULL,
- G_TYPE_INVALID);
- info->skip_reg_poll = FALSE;
- }
-
- if (!info->skip_signal_poll) {
- dbus_g_proxy_begin_call (info->net_proxy, "GetSignalQuality",
- signal_reply, info, NULL,
- G_TYPE_INVALID);
- info->skip_signal_poll = FALSE;
- }
-
- return TRUE; /* keep running until we're told to stop */
-}
-
-static void
-check_start_polling (GsmDeviceInfo *info)
-{
- NMDeviceState state;
- gboolean poll = TRUE;
-
- g_return_if_fail (info != NULL);
-
- /* Don't poll if any of the following are true:
- *
- * 1) NM says the device is not available
- * 2) the modem requires an unlock code
- * 3) the modem isn't enabled
- */
-
- state = nm_device_get_state (info->device);
- if ( (state <= NM_DEVICE_STATE_UNAVAILABLE)
- || info->unlock_required
- || (info->modem_enabled == FALSE))
- poll = FALSE;
-
- if (poll) {
- if (!info->poll_id) {
- /* 33 seconds to be just a bit more than MM's poll interval, so
- * that if we get an unsolicited update from MM between polls we'll
- * skip the next poll.
- */
- info->poll_id = g_timeout_add_seconds (33, gsm_poll_cb, info);
- }
- gsm_poll_cb (info);
- } else {
- if (info->poll_id)
- g_source_remove (info->poll_id);
- info->poll_id = 0;
- info->skip_reg_poll = FALSE;
- info->skip_signal_poll = FALSE;
- }
-}
-
-static void
-reg_info_changed_cb (DBusGProxy *proxy,
- guint32 reg_state,
- const char *op_code,
- const char *op_name,
- gpointer user_data)
-{
- GsmDeviceInfo *info = user_data;
- guint32 new_state = reg_state + 1;
-
- if (info->reg_state != new_state) {
- info->reg_state = new_state;
- notify_user_of_gsm_reg_change (info);
- }
-
- g_free (info->op_code);
- info->op_code = strlen (op_code) ? g_strdup (op_code) : NULL;
- g_free (info->op_name);
- info->op_name = mobile_helper_parse_3gpp_operator_name (&(info->mobile_providers_database),
- op_name,
- info->op_code);
- info->skip_reg_poll = TRUE;
-}
-
-static void
-signal_quality_changed_cb (DBusGProxy *proxy,
- guint32 quality,
- gpointer user_data)
-{
- GsmDeviceInfo *info = user_data;
-
- info->quality = quality;
- info->quality_valid = TRUE;
- info->skip_signal_poll = TRUE;
-
- applet_schedule_update_icon (info->applet);
-}
-
-#define MM_OLD_DBUS_INTERFACE_MODEM "org.freedesktop.ModemManager.Modem"
-#define MM_OLD_DBUS_INTERFACE_MODEM_GSM_NETWORK "org.freedesktop.ModemManager.Modem.Gsm.Network"
-
-static void
-modem_properties_changed (DBusGProxy *proxy,
- const char *interface,
- GHashTable *props,
- gpointer user_data)
-{
- GsmDeviceInfo *info = user_data;
- GValue *value;
-
- if (!strcmp (interface, MM_OLD_DBUS_INTERFACE_MODEM)) {
- value = g_hash_table_lookup (props, "UnlockRequired");
- if (value && G_VALUE_HOLDS_STRING (value)) {
- g_free (info->unlock_required);
- info->unlock_required = parse_unlock_required (value);
- check_start_polling (info);
- }
-
- value = g_hash_table_lookup (props, "Enabled");
- if (value && G_VALUE_HOLDS_BOOLEAN (value)) {
- info->modem_enabled = g_value_get_boolean (value);
- if (!info->modem_enabled) {
- info->quality = 0;
- info->quality_valid = 0;
- info->reg_state = 0;
- info->act = 0;
- g_free (info->op_code);
- info->op_code = NULL;
- g_free (info->op_name);
- info->op_name = NULL;
- }
- check_start_polling (info);
- }
- } else if (!strcmp (interface, MM_OLD_DBUS_INTERFACE_MODEM_GSM_NETWORK)) {
- value = g_hash_table_lookup (props, "AccessTechnology");
- if (value && G_VALUE_HOLDS_UINT (value)) {
- info->act = g_value_get_uint (value);
- applet_schedule_update_icon (info->applet);
- }
- }
-}
-
-static void
-gsm_device_added (NMDevice *device, NMApplet *applet)
-{
- NMDeviceModem *modem = NM_DEVICE_MODEM (device);
- GsmDeviceInfo *info;
- const char *udi;
- DBusGConnection *bus;
- GError *error = NULL;
-
- udi = nm_device_get_udi (device);
- if (!udi)
- return;
-
- bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (!bus) {
- g_warning ("%s: failed to connect to D-Bus: (%d) %s", __func__, error->code, error->message);
- g_clear_error (&error);
- return;
- }
-
- info = g_malloc0 (sizeof (GsmDeviceInfo));
- info->applet = applet;
- info->device = device;
- info->bus = bus;
- info->cancellable = g_cancellable_new ();
-
- info->props_proxy = dbus_g_proxy_new_for_name (info->bus,
- "org.freedesktop.ModemManager",
- udi,
- "org.freedesktop.DBus.Properties");
- if (!info->props_proxy) {
- g_message ("%s: failed to create D-Bus properties proxy.", __func__);
- gsm_device_info_free (info);
- return;
- }
-
- info->card_proxy = dbus_g_proxy_new_for_name (info->bus,
- "org.freedesktop.ModemManager",
- udi,
- "org.freedesktop.ModemManager.Modem.Gsm.Card");
- if (!info->card_proxy) {
- g_message ("%s: failed to create GSM Card proxy.", __func__);
- gsm_device_info_free (info);
- return;
- }
-
- info->net_proxy = dbus_g_proxy_new_for_name (info->bus,
- "org.freedesktop.ModemManager",
- udi,
- MM_OLD_DBUS_INTERFACE_MODEM_GSM_NETWORK);
- if (!info->net_proxy) {
- g_message ("%s: failed to create GSM Network proxy.", __func__);
- gsm_device_info_free (info);
- return;
- }
-
- g_object_set_data_full (G_OBJECT (modem), "devinfo", info, gsm_device_info_free);
-
- /* Registration info signal */
- dbus_g_object_register_marshaller (_nma_marshal_VOID__UINT_STRING_STRING,
- G_TYPE_NONE,
- G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_add_signal (info->net_proxy, "RegistrationInfo",
- G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (info->net_proxy, "RegistrationInfo",
- G_CALLBACK (reg_info_changed_cb), info, NULL);
-
- /* Signal quality change signal */
- dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__UINT,
- G_TYPE_NONE, G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_add_signal (info->net_proxy, "SignalQuality", G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (info->net_proxy, "SignalQuality",
- G_CALLBACK (signal_quality_changed_cb), info, NULL);
-
- /* Modem property change signal */
- dbus_g_object_register_marshaller (_nma_marshal_VOID__STRING_BOXED,
- G_TYPE_NONE, G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT,
- G_TYPE_INVALID);
- dbus_g_proxy_add_signal (info->props_proxy, "MmPropertiesChanged",
- G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (info->props_proxy, "MmPropertiesChanged",
- G_CALLBACK (modem_properties_changed),
- info, NULL);
-
- /* Ask whether the device needs to be unlocked */
- dbus_g_proxy_begin_call (info->props_proxy, "GetAll",
- unlock_reply, info, NULL,
- G_TYPE_STRING, MM_OLD_DBUS_INTERFACE_MODEM,
- G_TYPE_INVALID);
-
- /* Ask whether the device is enabled */
- dbus_g_proxy_begin_call (info->props_proxy, "Get",
- enabled_reply, info, NULL,
- G_TYPE_STRING, MM_OLD_DBUS_INTERFACE_MODEM,
- G_TYPE_STRING, "Enabled",
- G_TYPE_INVALID);
-
- dbus_g_proxy_begin_call (info->props_proxy, "Get",
- access_tech_reply, info, NULL,
- G_TYPE_STRING, MM_OLD_DBUS_INTERFACE_MODEM_GSM_NETWORK,
- G_TYPE_STRING, "AccessTechnology",
- G_TYPE_INVALID);
-}
-
-NMADeviceClass *
-applet_device_gsm_get_class (NMApplet *applet)
-{
- NMADeviceClass *dclass;
-
- dclass = g_slice_new0 (NMADeviceClass);
- if (!dclass)
- return NULL;
-
- dclass->new_auto_connection = gsm_new_auto_connection;
- dclass->add_menu_item = gsm_add_menu_item;
- dclass->device_state_changed = gsm_device_state_changed;
- dclass->notify_connected = gsm_notify_connected;
- dclass->get_icon = gsm_get_icon;
- dclass->get_secrets = gsm_get_secrets;
- dclass->secrets_request_size = sizeof (MobileHelperSecretsInfo);
- dclass->device_added = gsm_device_added;
-
- return dclass;
-}
diff --git a/src/applet-device-gsm.h b/src/applet-device-gsm.h
deleted file mode 100644
index b40716b8..00000000
--- a/src/applet-device-gsm.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager Applet -- allow user control over networking
- *
- * Dan Williams <dcbw@redhat.com>
- *
- * 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.
- *
- * (C) Copyright 2008 Red Hat, Inc.
- * (C) Copyright 2008 Novell, Inc.
- */
-
-#ifndef __APPLET_DEVICE_GSM_H__
-#define __APPLET_DEVICE_GSM_H__
-
-#include "applet.h"
-
-NMADeviceClass *applet_device_gsm_get_class (NMApplet *applet);
-
-void applet_gsm_connect_network (NMApplet *applet, NMDevice *device);
-
-#endif /* __APPLET_DEVICE_GSM_H__ */
diff --git a/src/applet.c b/src/applet.c
index 2ecf591e..5989b620 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -76,10 +76,8 @@
#include "applet-device-team.h"
#include "applet-device-bridge.h"
#include "applet-device-bt.h"
-#include "applet-device-cdma.h"
#include "applet-device-ethernet.h"
#include "applet-device-infiniband.h"
-#include "applet-device-gsm.h"
#include "applet-device-vlan.h"
#include "applet-device-wifi.h"
#include "applet-device-wimax.h"
@@ -90,7 +88,7 @@
#include "nm-ui-utils.h"
#include "nm-glib-compat.h"
-#if WITH_MODEM_MANAGER_1
+#if WITH_WWAN
# include "applet-device-broadband.h"
#endif
@@ -198,7 +196,6 @@ impl_dbus_connect_to_3g_network (NMApplet *applet,
GError **error)
{
NMDevice *device;
- NMDeviceModemCapabilities caps;
device = nm_client_get_device_by_path (applet->nm_client, device_path);
if (!device || NM_IS_DEVICE_MODEM (device) == FALSE) {
@@ -209,35 +206,18 @@ impl_dbus_connect_to_3g_network (NMApplet *applet,
return FALSE;
}
-#if WITH_MODEM_MANAGER_1
- if (g_str_has_prefix (nm_device_get_udi (device), "/org/freedesktop/ModemManager1/Modem/")) {
- if (applet->mm1_running) {
- applet_broadband_connect_network (applet, device);
- return TRUE;
- }
-
- g_set_error_literal (error,
- NM_SECRET_AGENT_ERROR,
- NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
- "ModemManager was not found");
- return FALSE;
+#if WITH_WWAN
+ if (applet->mm1_running) {
+ applet_broadband_connect_network (applet, device);
+ return TRUE;
}
#endif
- caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
- if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) {
- applet_gsm_connect_network (applet, device);
- } else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) {
- applet_cdma_connect_network (applet, device);
- } else {
- g_set_error_literal (error,
- NM_SECRET_AGENT_ERROR,
- NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
- "The device had no GSM or CDMA capabilities.");
- return FALSE;
- }
-
- return TRUE;
+ g_set_error_literal (error,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
+ "ModemManager was not found");
+ return FALSE;
}
#include "applet-dbus-bindings.h"
@@ -255,20 +235,11 @@ get_device_class (NMDevice *device, NMApplet *applet)
else if (NM_IS_DEVICE_WIFI (device))
return applet->wifi_class;
else if (NM_IS_DEVICE_MODEM (device)) {
- NMDeviceModemCapabilities caps;
-
-#if WITH_MODEM_MANAGER_1
- if (g_str_has_prefix (nm_device_get_udi (device), "/org/freedesktop/ModemManager1/Modem/"))
- return applet->broadband_class;
+#if WITH_WWAN
+ return applet->broadband_class;
+#else
+ g_debug ("%s: modem found but WWAN support not enabled", __func__);
#endif
-
- caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
- if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)
- return applet->gsm_class;
- else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
- return applet->cdma_class;
- else
- g_debug ("%s: unhandled modem capabilities 0x%X", __func__, caps);
} else if (NM_IS_DEVICE_BT (device))
return applet->bt_class;
else if (NM_IS_DEVICE_WIMAX (device))
@@ -307,14 +278,10 @@ get_device_class_from_connection (NMConnection *connection, NMApplet *applet)
return applet->ethernet_class;
else if (!strcmp (ctype, NM_SETTING_WIRELESS_SETTING_NAME))
return applet->wifi_class;
-#if WITH_MODEM_MANAGER_1
- else if (applet->mm1_running && (!strcmp (ctype, NM_SETTING_GSM_SETTING_NAME) || !strcmp (ctype, NM_SETTING_CDMA_SETTING_NAME)))
+#if WITH_WWAN
+ else if (!strcmp (ctype, NM_SETTING_GSM_SETTING_NAME) || !strcmp (ctype, NM_SETTING_CDMA_SETTING_NAME))
return applet->broadband_class;
#endif
- else if (!strcmp (ctype, NM_SETTING_GSM_SETTING_NAME))
- return applet->gsm_class;
- else if (!strcmp (ctype, NM_SETTING_CDMA_SETTING_NAME))
- return applet->cdma_class;
else if (!strcmp (ctype, NM_SETTING_BLUETOOTH_SETTING_NAME))
return applet->bt_class;
else if (!strcmp (ctype, NM_SETTING_BOND_SETTING_NAME))
@@ -1603,7 +1570,8 @@ add_device_items (NMDeviceType type, const GPtrArray *all_devices, GSList *all_c
GSList *connections;
dclass = get_device_class (device, applet);
- g_assert (dclass != NULL);
+ if (!dclass)
+ continue;
connections = nm_device_filter_connections (device, all_connections);
active = applet_find_active_connection_for_device (device, applet, NULL);
@@ -2683,7 +2651,7 @@ foo_client_setup (NMApplet *applet)
applet_schedule_update_icon (applet);
}
-#if WITH_MODEM_MANAGER_1
+#if WITH_WWAN
static void
mm1_name_owner_changed_cb (GDBusObjectManagerClient *mm1,
@@ -2739,7 +2707,7 @@ mm1_client_setup (NMApplet *applet)
}
}
-#endif /* WITH_MODEM_MANAGER_1 */
+#endif /* WITH_WWAN */
static void
applet_common_get_device_icon (NMDeviceState state,
@@ -3617,13 +3585,7 @@ initable_init (GInitable *initable, GCancellable *cancellable, GError **error)
applet->wifi_class = applet_device_wifi_get_class (applet);
g_assert (applet->wifi_class);
- applet->gsm_class = applet_device_gsm_get_class (applet);
- g_assert (applet->gsm_class);
-
- applet->cdma_class = applet_device_cdma_get_class (applet);
- g_assert (applet->cdma_class);
-
-#if WITH_MODEM_MANAGER_1
+#if WITH_WWAN
applet->broadband_class = applet_device_broadband_get_class (applet);
g_assert (applet->broadband_class);
#endif
@@ -3649,7 +3611,7 @@ initable_init (GInitable *initable, GCancellable *cancellable, GError **error)
applet->infiniband_class = applet_device_infiniband_get_class (applet);
g_assert (applet->infiniband_class);
-#if WITH_MODEM_MANAGER_1
+#if WITH_WWAN
mm1_client_setup (applet);
#endif
@@ -3671,9 +3633,7 @@ static void finalize (GObject *object)
g_slice_free (NMADeviceClass, applet->ethernet_class);
g_slice_free (NMADeviceClass, applet->wifi_class);
- g_slice_free (NMADeviceClass, applet->gsm_class);
- g_slice_free (NMADeviceClass, applet->cdma_class);
-#if WITH_MODEM_MANAGER_1
+#if WITH_WWAN
g_slice_free (NMADeviceClass, applet->broadband_class);
#endif
g_slice_free (NMADeviceClass, applet->bt_class);
@@ -3707,7 +3667,7 @@ static void finalize (GObject *object)
g_clear_object (&applet->gsettings);
g_clear_object (&applet->nm_client);
-#if WITH_MODEM_MANAGER_1
+#if WITH_WWAN
g_clear_object (&applet->mm1);
#endif
diff --git a/src/applet.h b/src/applet.h
index 66ca9455..95bc2874 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -45,7 +45,7 @@
#include <nm-remote-settings.h>
#include "applet-agent.h"
-#if WITH_MODEM_MANAGER_1
+#if WITH_WWAN
#include <libmm-glib.h>
#endif
@@ -92,7 +92,7 @@ typedef struct
GSettings *gsettings;
-#if WITH_MODEM_MANAGER_1
+#if WITH_WWAN
MMManager *mm1;
gboolean mm1_running;
#endif
@@ -105,9 +105,7 @@ typedef struct
/* Device classes */
NMADeviceClass *ethernet_class;
NMADeviceClass *wifi_class;
- NMADeviceClass *gsm_class;
- NMADeviceClass *cdma_class;
-#if WITH_MODEM_MANAGER_1
+#if WITH_WWAN
NMADeviceClass *broadband_class;
#endif
NMADeviceClass *bt_class;
diff --git a/src/gnome-bluetooth/Makefile.am b/src/gnome-bluetooth/Makefile.am
index 940aebaa..1e3ec5e6 100644
--- a/src/gnome-bluetooth/Makefile.am
+++ b/src/gnome-bluetooth/Makefile.am
@@ -22,11 +22,7 @@ plugin_LTLIBRARIES = libnma.la
libnma_la_SOURCES = $(BT_WIDGET_SOURCES)
-libnma_la_CPPFLAGS = $(AM_CPPFLAGS)
-
-if WITH_MODEM_MANAGER_1
-libnma_la_CPPFLAGS += $(MM_GLIB_CFLAGS)
-endif
+libnma_la_CPPFLAGS = $(AM_CPPFLAGS) $(MM_GLIB_CFLAGS)
libnma_la_LDFLAGS = -module -avoid-version
@@ -34,11 +30,8 @@ libnma_la_LIBADD = \
$(top_builddir)/src/marshallers/libmarshallers.la \
$(top_builddir)/src/utils/libutils.la \
$(top_builddir)/src/libnm-gtk/libnm-gtk.la \
- $(GNOME_BLUETOOTH_LIBS)
-
-if WITH_MODEM_MANAGER_1
-libnma_la_LIBADD += $(MM_GLIB_LIBS)
-endif
+ $(GNOME_BLUETOOTH_LIBS) \
+ $(MM_GLIB_LIBS)
endif
diff --git a/src/gnome-bluetooth/nma-bt-device.c b/src/gnome-bluetooth/nma-bt-device.c
index 870d2be1..7af6c494 100644
--- a/src/gnome-bluetooth/nma-bt-device.c
+++ b/src/gnome-bluetooth/nma-bt-device.c
@@ -43,7 +43,7 @@
#include "nm-utils.h"
#include "utils.h"
-#if WITH_MODEM_MANAGER_1
+#if WITH_WWAN
#include <libmm-glib.h>
#endif
@@ -69,15 +69,12 @@ typedef struct {
gboolean dun_enabled;
/* DUN stuff */
+#if WITH_WWAN
+ GDBusConnection *dbus_connection;
+ MMManager *modem_manager_1;
DBusGProxy *dun_proxy;
- DBusGProxy *mm_proxy;
- GSList *modem_proxies;
char *rfcomm_iface;
guint dun_timeout_id;
-
-#if WITH_MODEM_MANAGER_1
- GDBusConnection *dbus_connection;
- MMManager *modem_manager_1;
#endif
GtkWindow *parent_window;
@@ -114,15 +111,6 @@ static void _set_dun_enabled (NmaBtDevice *device, gboolean enabled);
#define BLUEZ_SERIAL_INTERFACE "org.bluez.Serial"
#define BLUEZ_NETWORK_INTERFACE "org.bluez.Network"
-#define MM_SERVICE "org.freedesktop.ModemManager"
-#define MM_PATH "/org/freedesktop/ModemManager"
-#define MM_INTERFACE "org.freedesktop.ModemManager"
-#define MM_MODEM_INTERFACE "org.freedesktop.ModemManager.Modem"
-
-#if WITH_MODEM_MANAGER_1
-#include <libmm-glib.h>
-#endif
-
/*********************************************************************/
static gboolean
@@ -282,16 +270,8 @@ static void
dun_cleanup (NmaBtDevice *self)
{
NmaBtDevicePrivate *priv = NMA_BT_DEVICE_GET_PRIVATE (self);
- GSList *iter;
-
- /* ModemManager */
- for (iter = priv->modem_proxies; iter; iter = g_slist_next (iter))
- g_object_unref (DBUS_G_PROXY (iter->data));
- g_slist_free (priv->modem_proxies);
- priv->modem_proxies = NULL;
- g_clear_object (&priv->mm_proxy);
-#if WITH_MODEM_MANAGER_1
+#if WITH_WWAN
g_clear_object (&priv->dbus_connection);
g_clear_object (&priv->modem_manager_1);
#endif
@@ -517,124 +497,7 @@ start_wizard (NmaBtDevice *self,
nma_mobile_wizard_present (priv->wizard);
}
-static void
-modem_get_all_cb (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
-{
- NmaBtDevice *self = NMA_BT_DEVICE (user_data);
- NmaBtDevicePrivate *priv = NMA_BT_DEVICE_GET_PRIVATE (self);
- const char *path;
- GHashTable *properties = NULL;
- GError *error = NULL;
- GValue *value;
- NMDeviceModemCapabilities caps = NM_DEVICE_MODEM_CAPABILITY_NONE;
-
- path = dbus_g_proxy_get_path (proxy);
- g_message ("%s: (%s) processing GetAll reply", __func__, path);
-
- if (!dbus_g_proxy_end_call (proxy, call, &error,
- DBUS_TYPE_G_MAP_OF_VARIANT, &properties,
- G_TYPE_INVALID)) {
- g_warning ("%s: (%s) Error getting modem properties: (%d) %s",
- __func__,
- path,
- error ? error->code : -1,
- (error && error->message) ? error->message : "(unknown)");
- g_error_free (error);
- goto out;
- }
-
- /* check whether this is the device we care about */
- value = g_hash_table_lookup (properties, "Device");
- if (value && G_VALUE_HOLDS_STRING (value) && g_value_get_string (value)) {
- char *iface_basename = g_path_get_basename (priv->rfcomm_iface);
- const char *modem_iface = g_value_get_string (value);
-
- if (strcmp (iface_basename, modem_iface) == 0) {
- /* yay, found it! */
-
- value = g_hash_table_lookup (properties, "Type");
- if (value && G_VALUE_HOLDS_UINT (value)) {
- switch (g_value_get_uint (value)) {
- case 1:
- caps = NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS;
- break;
- case 2:
- caps = NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO;
- break;
- default:
- g_message ("%s: (%s) unknown modem type", __func__, path);
- break;
- }
- }
- } else {
- g_message ("%s: (%s) (%s) not the modem we're looking for (%s)",
- __func__, path, modem_iface, iface_basename);
- }
-
- g_free (iface_basename);
- } else
- g_message ("%s: (%s) modem had no 'Device' property", __func__, path);
-
- g_hash_table_unref (properties);
-
- /* Launch wizard! */
- start_wizard (self, path, caps);
-
-out:
- g_message ("%s: finished", __func__);
-}
-
-static void
-modem_added (DBusGProxy *proxy, const char *path, gpointer user_data)
-{
- NmaBtDevice *self = NMA_BT_DEVICE (user_data);
- NmaBtDevicePrivate *priv = NMA_BT_DEVICE_GET_PRIVATE (self);
- DBusGProxy *props_proxy;
-
- g_return_if_fail (path != NULL);
-
- g_message ("%s: (%s) modem found", __func__, path);
-
- /* Create a proxy for the modem and get its properties */
- props_proxy = dbus_g_proxy_new_for_name (priv->bus,
- MM_SERVICE,
- path,
- "org.freedesktop.DBus.Properties");
- g_assert (proxy);
- priv->modem_proxies = g_slist_append (priv->modem_proxies, props_proxy);
-
- g_message ("%s: (%s) calling GetAll...", __func__, path);
-
- dbus_g_proxy_begin_call (props_proxy, "GetAll",
- modem_get_all_cb,
- self,
- NULL,
- G_TYPE_STRING, MM_MODEM_INTERFACE,
- G_TYPE_INVALID);
-}
-
-static void
-modem_removed (DBusGProxy *proxy, const char *path, gpointer user_data)
-{
- NmaBtDevice *self = NMA_BT_DEVICE (user_data);
- NmaBtDevicePrivate *priv = NMA_BT_DEVICE_GET_PRIVATE (self);
- GSList *iter;
-
- g_return_if_fail (path != NULL);
-
- g_message ("%s: (%s) modem removed", __func__, path);
-
- /* Clean up if a modem gets removed */
- for (iter = priv->modem_proxies; iter; iter = g_slist_next (iter)) {
- if (!strcmp (path, dbus_g_proxy_get_path (DBUS_G_PROXY (iter->data)))) {
- priv->modem_proxies = g_slist_remove (priv->modem_proxies, iter->data);
- g_object_unref (iter->data);
- break;
- }
- }
-}
-
-#if WITH_MODEM_MANAGER_1
+#if WITH_WWAN
static gboolean
check_modem (NmaBtDevice *self,
@@ -697,7 +560,7 @@ modem_object_added (MMManager *modem_manager,
check_modem (self, modem_object);
}
-#endif /* WITH_MODEM_MANAGER_1 */
+#endif /* WITH_WWAN */
static void
dun_connect_cb (DBusGProxy *proxy,
@@ -708,7 +571,7 @@ dun_connect_cb (DBusGProxy *proxy,
NmaBtDevicePrivate *priv = NMA_BT_DEVICE_GET_PRIVATE (self);
GError *error = NULL;
char *device;
-#if WITH_MODEM_MANAGER_1
+#if WITH_WWAN
GList *modems, *iter;
gboolean matched = FALSE;
#endif
@@ -733,7 +596,7 @@ dun_connect_cb (DBusGProxy *proxy,
priv->rfcomm_iface = device;
g_message ("%s: new rfcomm interface '%s'", __func__, device);
-#if WITH_MODEM_MANAGER_1
+#if WITH_WWAN
/* ModemManager1 stuff */
priv->dbus_connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
if (!priv->dbus_connection) {
@@ -814,29 +677,6 @@ dun_start (NmaBtDevice *self)
_set_status (self, _("Detecting phone configuration..."));
- /* ModemManager stuff */
- priv->mm_proxy = dbus_g_proxy_new_for_name (priv->bus,
- MM_SERVICE,
- MM_PATH,
- MM_INTERFACE);
- g_assert (priv->mm_proxy);
-
- dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE,
- G_TYPE_BOXED,
- G_TYPE_INVALID);
- dbus_g_proxy_add_signal (priv->mm_proxy, "DeviceAdded",
- DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->mm_proxy, "DeviceAdded",
- G_CALLBACK (modem_added), self,
- NULL);
-
- dbus_g_proxy_add_signal (priv->mm_proxy, "DeviceRemoved",
- DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->mm_proxy, "DeviceRemoved",
- G_CALLBACK (modem_removed), self,
- NULL);
-
/* Bluez */
priv->dun_proxy = dbus_g_proxy_new_for_name (priv->bus,
BLUEZ_SERVICE,