summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac1
-rw-r--r--po/POTFILES.in4
-rw-r--r--src/Makefile.am20
-rw-r--r--src/devices/bluetooth/Makefile.am7
-rw-r--r--src/devices/wwan/Makefile.am75
-rw-r--r--src/devices/wwan/README (renamed from src/modem-manager/README)0
-rw-r--r--src/devices/wwan/nm-device-modem.c (renamed from src/devices/nm-device-modem.c)14
-rw-r--r--src/devices/wwan/nm-device-modem.h (renamed from src/devices/nm-device-modem.h)2
-rw-r--r--src/devices/wwan/nm-modem-broadband.c (renamed from src/modem-manager/nm-modem-broadband.c)29
-rw-r--r--src/devices/wwan/nm-modem-broadband.h (renamed from src/modem-manager/nm-modem-broadband.h)2
-rw-r--r--src/devices/wwan/nm-modem-manager.c (renamed from src/modem-manager/nm-modem-manager.c)67
-rw-r--r--src/devices/wwan/nm-modem-manager.h (renamed from src/modem-manager/nm-modem-manager.h)29
-rw-r--r--src/devices/wwan/nm-modem-old-types.h (renamed from src/modem-manager/nm-modem-old-types.h)0
-rw-r--r--src/devices/wwan/nm-modem-old.c (renamed from src/modem-manager/nm-modem-old.c)0
-rw-r--r--src/devices/wwan/nm-modem-old.h (renamed from src/modem-manager/nm-modem-old.h)0
-rw-r--r--src/devices/wwan/nm-modem.c (renamed from src/modem-manager/nm-modem.c)2
-rw-r--r--src/devices/wwan/nm-modem.h (renamed from src/modem-manager/nm-modem.h)0
-rw-r--r--src/devices/wwan/nm-wwan-factory.c160
-rw-r--r--src/devices/wwan/nm-wwan-factory.h37
-rw-r--r--src/nm-manager.c56
20 files changed, 353 insertions, 152 deletions
diff --git a/configure.ac b/configure.ac
index 79aa225fd5..a7f60ff616 100644
--- a/configure.ac
+++ b/configure.ac
@@ -765,6 +765,7 @@ src/rdisc/tests/Makefile
src/devices/atm/Makefile
src/devices/wimax/Makefile
src/devices/bluetooth/Makefile
+src/devices/wwan/Makefile
libnm-util/libnm-util.pc
libnm-util/Makefile
libnm-util/tests/Makefile
diff --git a/po/POTFILES.in b/po/POTFILES.in
index fa7806f3f4..d03f5aa8fa 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -47,8 +47,6 @@ src/dns-manager/nm-dns-manager.c
src/logging/nm-logging.c
src/config/nm-config.c
src/devices/atm/nm-device-adsl.c
-src/modem-manager/nm-modem-broadband.c
-src/modem-manager/nm-modem-old.c
src/devices/bluetooth/nm-bluez-device.c
src/devices/bluetooth/nm-device-bt.c
src/devices/nm-device-bond.c
@@ -58,6 +56,8 @@ src/devices/nm-device-infiniband.c
src/devices/nm-device-olpc-mesh.c
src/devices/nm-device-team.c
src/devices/nm-device-vlan.c
+src/devices/wwan/nm-modem-broadband.c
+src/devices/wwan/nm-modem-old.c
src/nm-manager.c
src/nm-sleep-monitor-systemd.c
src/settings/plugins/ifcfg-rh/reader.c
diff --git a/src/Makefile.am b/src/Makefile.am
index a50932ed20..fd0bb6964c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,6 +5,7 @@ include $(GLIB_MAKEFILE)
SUBDIRS = \
. \
devices/atm \
+ devices/wwan \
devices/bluetooth \
dhcp-manager \
ppp-manager \
@@ -76,8 +77,6 @@ nm_sources = \
devices/nm-device-infiniband.h \
devices/nm-device-macvlan.c \
devices/nm-device-macvlan.h \
- devices/nm-device-modem.c \
- devices/nm-device-modem.h \
devices/nm-device-olpc-mesh.c \
devices/nm-device-olpc-mesh.h \
devices/nm-device-private.h \
@@ -123,14 +122,6 @@ nm_sources = \
logging/nm-logging.c \
logging/nm-logging.h \
\
- modem-manager/nm-modem-old.c \
- modem-manager/nm-modem-old.h \
- modem-manager/nm-modem-old-types.h \
- modem-manager/nm-modem-manager.c \
- modem-manager/nm-modem-manager.h \
- modem-manager/nm-modem.c \
- modem-manager/nm-modem.h \
- \
platform/nm-fake-platform.c \
platform/nm-fake-platform.h \
platform/nm-linux-platform.c \
@@ -259,12 +250,6 @@ nm_sources = \
NetworkManagerUtils.c \
NetworkManagerUtils.h
-if WITH_MODEM_MANAGER_1
-nm_sources += \
- modem-manager/nm-modem-broadband.c \
- modem-manager/nm-modem-broadband.h
-endif
-
if SESSION_TRACKING_SYSTEMD
nm_sources += nm-session-monitor-systemd.c
else
@@ -312,7 +297,6 @@ glue_sources = \
nm-device-gre-glue.h \
nm-device-infiniband-glue.h \
nm-device-macvlan-glue.h \
- nm-device-modem-glue.h \
nm-device-olpc-mesh-glue.h \
nm-device-team-glue.h \
nm-device-tun-glue.h \
@@ -342,7 +326,6 @@ AM_CPPFLAGS += \
$(LIBNL_CFLAGS) \
$(LIBNDP_CFLAGS) \
$(LIBSOUP_CFLAGS) \
- $(MM_GLIB_CFLAGS) \
$(POLKIT_CFLAGS) \
$(SYSTEMD_LOGIN_CFLAGS) \
\
@@ -385,7 +368,6 @@ libNetworkManager_la_LIBADD = \
$(GLIB_LIBS) \
$(GUDEV_LIBS) \
$(LIBNL_LIBS) \
- $(MM_GLIB_LIBS) \
$(POLKIT_LIBS) \
$(SYSTEMD_LOGIN_LIBS) \
$(LIBDL) \
diff --git a/src/devices/bluetooth/Makefile.am b/src/devices/bluetooth/Makefile.am
index 7713fc9124..5e716af25f 100644
--- a/src/devices/bluetooth/Makefile.am
+++ b/src/devices/bluetooth/Makefile.am
@@ -9,7 +9,7 @@ AM_CPPFLAGS = \
-I${top_srcdir}/src/devices \
-I${top_srcdir}/src/settings \
-I${top_srcdir}/src/platform \
- -I${top_srcdir}/src/modem-manager \
+ -I${top_srcdir}/src/devices/wwan \
-I${top_builddir}/include \
-I${top_srcdir}/include \
-I${top_builddir}/libnm-util \
@@ -50,7 +50,10 @@ libnm_device_plugin_bt_la_SOURCES = \
$(BUILT_SOURCES)
libnm_device_plugin_bt_la_LDFLAGS = -module -avoid-version
-libnm_device_plugin_bt_la_LIBADD = $(DBUS_LIBS) $(GUDEV_LIBS)
+libnm_device_plugin_bt_la_LIBADD = \
+ $(top_builddir)/src/devices/wwan/libnm-wwan.la \
+ $(DBUS_LIBS) \
+ $(GUDEV_LIBS)
CLEANFILES = $(BUILT_SOURCES)
diff --git a/src/devices/wwan/Makefile.am b/src/devices/wwan/Makefile.am
new file mode 100644
index 0000000000..46ae255ea0
--- /dev/null
+++ b/src/devices/wwan/Makefile.am
@@ -0,0 +1,75 @@
+include $(GLIB_MAKEFILE)
+
+@GNOME_CODE_COVERAGE_RULES@
+
+AM_CPPFLAGS = \
+ -I${top_srcdir}/src \
+ -I${top_builddir}/src \
+ -I${top_srcdir}/src/logging \
+ -I${top_srcdir}/src/devices \
+ -I${top_srcdir}/src/settings \
+ -I${top_srcdir}/src/platform \
+ -I${top_builddir}/include \
+ -I${top_srcdir}/include \
+ -I${top_builddir}/libnm-util \
+ -I${top_srcdir}/libnm-util \
+ $(DBUS_CFLAGS) \
+ $(POLKIT_CFLAGS) \
+ $(MM_GLIB_CFLAGS)
+
+BUILT_SOURCES = $(null)
+
+pkglib_LTLIBRARIES = libnm-wwan.la libnm-device-plugin-wwan.la
+
+###########################################################
+
+GLIB_GENERATED = nm-modem-enum-types.h nm-modem-enum-types.c
+GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM
+GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM
+nm_modem_enum_types_sources = $(srcdir)/nm-modem.h
+
+BUILT_SOURCES += $(GLIB_GENERATED)
+
+libnm_wwan_la_SOURCES = \
+ nm-modem-old.c \
+ nm-modem-old.h \
+ nm-modem-old-types.h \
+ nm-modem-manager.c \
+ nm-modem-manager.h \
+ nm-modem.c \
+ nm-modem.h \
+ \
+ $(GLIB_GENERATED)
+
+if WITH_MODEM_MANAGER_1
+libnm_wwan_la_SOURCES += \
+ nm-modem-broadband.c \
+ nm-modem-broadband.h
+endif
+
+libnm_wwan_la_LDFLAGS = -avoid-version
+libnm_wwan_la_LIBADD = $(DBUS_LIBS) $(MM_GLIB_LIBS)
+
+###########################################################
+
+nm-device-modem-glue.h: $(top_srcdir)/introspection/nm-device-modem.xml
+ dbus-binding-tool --prefix=nm_device_modem --mode=glib-server --output=$@ $<
+
+BUILT_SOURCES += nm-device-modem-glue.h
+
+libnm_device_plugin_wwan_la_SOURCES = \
+ nm-wwan-factory.c \
+ nm-wwan-factory.h \
+ nm-device-modem.c \
+ nm-device-modem.h \
+ nm-device-modem-glue.h
+
+libnm_device_plugin_wwan_la_LDFLAGS = -module -avoid-version
+libnm_device_plugin_wwan_la_LIBADD = \
+ libnm-wwan.la \
+ $(DBUS_LIBS)
+
+###########################################################
+
+CLEANFILES = $(BUILT_SOURCES)
+
diff --git a/src/modem-manager/README b/src/devices/wwan/README
index 4661c04287..4661c04287 100644
--- a/src/modem-manager/README
+++ b/src/devices/wwan/README
diff --git a/src/devices/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c
index 6a3656c4e9..723f86e4dd 100644
--- a/src/devices/nm-device-modem.c
+++ b/src/devices/wwan/nm-device-modem.c
@@ -360,14 +360,14 @@ set_enabled (NMDevice *device, gboolean enabled)
/*****************************************************************************/
NMDevice *
-nm_device_modem_new (NMModem *modem, const char *driver)
+nm_device_modem_new (NMModem *modem)
{
NMDeviceModemCapabilities caps = NM_DEVICE_MODEM_CAPABILITY_NONE;
NMDeviceModemCapabilities current_caps = NM_DEVICE_MODEM_CAPABILITY_NONE;
NMDevice *device;
+ const char *data_port;
g_return_val_if_fail (NM_IS_MODEM (modem), NULL);
- g_return_val_if_fail (driver != NULL, NULL);
/* Load capabilities */
nm_modem_get_capabilities (modem, &caps, &current_caps);
@@ -375,7 +375,7 @@ nm_device_modem_new (NMModem *modem, const char *driver)
device = (NMDevice *) g_object_new (NM_TYPE_DEVICE_MODEM,
NM_DEVICE_UDI, nm_modem_get_path (modem),
NM_DEVICE_IFACE, nm_modem_get_uid (modem),
- NM_DEVICE_DRIVER, driver,
+ NM_DEVICE_DRIVER, nm_modem_get_driver (modem),
NM_DEVICE_TYPE_DESC, "Broadband",
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_MODEM,
NM_DEVICE_RFKILL_TYPE, RFKILL_TYPE_WWAN,
@@ -384,10 +384,10 @@ nm_device_modem_new (NMModem *modem, const char *driver)
NM_DEVICE_MODEM_CURRENT_CAPABILITIES, current_caps,
NULL);
- /* In old MM modems, data port is known right away (may be changed
- * afterwards during a PPP session setup) */
- if (NM_IS_MODEM_OLD (modem))
- nm_device_set_ip_iface (device, nm_modem_get_data_port (modem));
+ /* If the data port is known, set it as the IP interface immediately */
+ data_port = nm_modem_get_data_port (modem);
+ if (data_port)
+ nm_device_set_ip_iface (device, data_port);
return device;
}
diff --git a/src/devices/nm-device-modem.h b/src/devices/wwan/nm-device-modem.h
index aa0c7c351b..1147b57be3 100644
--- a/src/devices/nm-device-modem.h
+++ b/src/devices/wwan/nm-device-modem.h
@@ -51,7 +51,7 @@ typedef struct {
GType nm_device_modem_get_type (void);
-NMDevice *nm_device_modem_new (NMModem *modem, const char *driver);
+NMDevice *nm_device_modem_new (NMModem *modem);
/* Private for subclases */
NMModem *nm_device_modem_get_modem (NMDeviceModem *self);
diff --git a/src/modem-manager/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c
index f368c2e0ac..3fd94586a9 100644
--- a/src/modem-manager/nm-modem-broadband.c
+++ b/src/devices/wwan/nm-modem-broadband.c
@@ -814,10 +814,12 @@ modem_state_changed (MMModem *modem,
/*****************************************************************************/
NMModem *
-nm_modem_broadband_new (GObject *object)
+nm_modem_broadband_new (GObject *object, GError **error)
{
+ NMModem *modem;
MMObject *modem_object;
MMModem *modem_iface;
+ gchar *drivers;
g_return_val_if_fail (MM_IS_OBJECT (object), NULL);
modem_object = MM_OBJECT (object);
@@ -831,18 +833,25 @@ nm_modem_broadband_new (GObject *object)
* This happens when a severe error happened when trying to initialize it,
* like missing SIM. */
if (mm_modem_get_state (modem_iface) == MM_MODEM_STATE_FAILED) {
- nm_log_warn (LOGD_MB, "(%s): unusable modem detected",
- mm_modem_get_primary_port (modem_iface));
+ g_set_error (error, NM_MODEM_ERROR, NM_MODEM_ERROR_INITIALIZATION_FAILED,
+ "(%s): unusable modem detected",
+ mm_modem_get_primary_port (modem_iface));
return NULL;
}
- return (NMModem *) g_object_new (NM_TYPE_MODEM_BROADBAND,
- NM_MODEM_PATH, mm_object_get_path (modem_object),
- NM_MODEM_UID, mm_modem_get_primary_port (modem_iface),
- NM_MODEM_CONTROL_PORT, mm_modem_get_primary_port (modem_iface),
- NM_MODEM_DATA_PORT, NULL, /* We don't know it until bearer created */
- NM_MODEM_BROADBAND_MODEM, modem_object,
- NULL);
+ /* Build a single string with all drivers listed */
+ drivers = g_strjoinv (", ", (gchar **)mm_modem_get_drivers (modem_iface));
+
+ modem = g_object_new (NM_TYPE_MODEM_BROADBAND,
+ NM_MODEM_PATH, mm_object_get_path (modem_object),
+ NM_MODEM_UID, mm_modem_get_primary_port (modem_iface),
+ NM_MODEM_CONTROL_PORT, mm_modem_get_primary_port (modem_iface),
+ NM_MODEM_DATA_PORT, NULL, /* We don't know it until bearer created */
+ NM_MODEM_BROADBAND_MODEM, modem_object,
+ NM_MODEM_DRIVER, drivers,
+ NULL);
+ g_free (drivers);
+ return modem;
}
static void
diff --git a/src/modem-manager/nm-modem-broadband.h b/src/devices/wwan/nm-modem-broadband.h
index 635c619a4f..e12ca68caf 100644
--- a/src/modem-manager/nm-modem-broadband.h
+++ b/src/devices/wwan/nm-modem-broadband.h
@@ -51,7 +51,7 @@ struct _NMModemBroadbandClass {
GType nm_modem_broadband_get_type (void);
-NMModem *nm_modem_broadband_new (GObject *object);
+NMModem *nm_modem_broadband_new (GObject *object, GError **error);
G_END_DECLS
diff --git a/src/modem-manager/nm-modem-manager.c b/src/devices/wwan/nm-modem-manager.c
index f68a569666..c48117004e 100644
--- a/src/modem-manager/nm-modem-manager.c
+++ b/src/devices/wwan/nm-modem-manager.c
@@ -15,7 +15,7 @@
* 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 - 2010 Red Hat, Inc.
+ * Copyright (C) 2009 - 2014 Red Hat, Inc.
* Copyright (C) 2009 Novell, Inc.
* Copyright (C) 2009 Canonical Ltd.
*/
@@ -63,24 +63,26 @@ struct _NMModemManagerPrivate {
enum {
MODEM_ADDED,
- LAST_SIGNAL
+ LAST_SIGNAL,
};
-
static guint signals[LAST_SIGNAL] = { 0 };
+/************************************************************************/
-NMModemManager *
-nm_modem_manager_get (void)
+static void
+handle_new_modem (NMModemManager *self, NMModem *modem)
{
- static NMModemManager *singleton = NULL;
+ const char *path;
- if (!singleton)
- singleton = NM_MODEM_MANAGER (g_object_new (NM_TYPE_MODEM_MANAGER, NULL));
- else
- g_object_ref (singleton);
+ path = nm_modem_get_path (modem);
+ if (g_hash_table_lookup (self->priv->modems, path)) {
+ g_warn_if_reached ();
+ return;
+ }
- g_assert (singleton);
- return singleton;
+ /* Track the new modem */
+ g_hash_table_insert (self->priv->modems, g_strdup (path), modem);
+ g_signal_emit (self, signals[MODEM_ADDED], 0, modem);
}
/************************************************************************/
@@ -125,10 +127,9 @@ create_modem (NMModemManager *self, const char *path)
G_TYPE_INVALID)) {
/* Success, create the modem */
modem = nm_modem_old_new (path, properties, &error);
- if (modem) {
- g_hash_table_insert (self->priv->modems, g_strdup (path), modem);
- g_signal_emit (self, signals[MODEM_ADDED], 0, modem, nm_modem_get_driver (modem));
- } else {
+ if (modem)
+ handle_new_modem (self, modem);
+ else {
nm_log_warn (LOGD_MB, "failed to create modem: %s",
error ? error->message : "(unknown)");
}
@@ -372,9 +373,9 @@ modem_object_added (MMManager *modem_manager,
NMModemManager *self)
{
const gchar *path;
- gchar *drivers;
MMModem *modem_iface;
NMModem *modem;
+ GError *error = NULL;
/* Ensure we don't have the same modem already */
path = mm_object_get_path (modem_object);
@@ -397,17 +398,14 @@ modem_object_added (MMManager *modem_manager,
}
/* Create a new modem object */
- modem = nm_modem_broadband_new (G_OBJECT (modem_object));
- if (!modem)
- return;
-
- /* Build a single string with all drivers listed */
- drivers = g_strjoinv (", ", (gchar **)mm_modem_get_drivers (modem_iface));
-
- /* Keep track of the new modem and notify about it */
- g_hash_table_insert (self->priv->modems, g_strdup (path), modem);
- g_signal_emit (self, signals[MODEM_ADDED], 0, modem, drivers);
- g_free (drivers);
+ modem = nm_modem_broadband_new (G_OBJECT (modem_object), &error);
+ if (modem)
+ handle_new_modem (self, modem);
+ else {
+ nm_log_warn (LOGD_MB, "failed to create modem: %s",
+ error ? error->message : "(unknown)");
+ }
+ g_clear_error (&error);
}
static void
@@ -749,12 +747,11 @@ nm_modem_manager_class_init (NMModemManagerClass *klass)
object_class->dispose = dispose;
- /* signals */
signals[MODEM_ADDED] =
- g_signal_new ("modem-added",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMModemManagerClass, modem_added),
- NULL, NULL, NULL,
- G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_STRING);
+ g_signal_new (NM_MODEM_MANAGER_MODEM_ADDED,
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (NMModemManagerClass, modem_added),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1, NM_TYPE_MODEM);
}
diff --git a/src/modem-manager/nm-modem-manager.h b/src/devices/wwan/nm-modem-manager.h
index 0c2b243b91..3082bdb39f 100644
--- a/src/modem-manager/nm-modem-manager.h
+++ b/src/devices/wwan/nm-modem-manager.h
@@ -15,7 +15,7 @@
* 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.
+ * Copyright (C) 2009 - 2014 Red Hat, Inc.
* Copyright (C) 2009 Novell, Inc.
* Copyright (C) 2009 Canonical Ltd.
*/
@@ -26,33 +26,24 @@
#include <glib-object.h>
#include "nm-modem.h"
-#define NM_TYPE_MODEM_MANAGER (nm_modem_manager_get_type ())
-#define NM_MODEM_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MODEM_MANAGER, NMModemManager))
-#define NM_MODEM_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_MODEM_MANAGER, NMModemManagerClass))
-#define NM_IS_MODEM_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_MODEM_MANAGER))
-#define NM_IS_MODEM_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_MODEM_MANAGER))
-#define NM_MODEM_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_MODEM_MANAGER, NMModemManagerClass))
+#define NM_TYPE_MODEM_MANAGER (nm_modem_manager_get_type ())
+#define NM_MODEM_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MODEM_MANAGER, NMModemManager))
+
+#define NM_MODEM_MANAGER_MODEM_ADDED "modem-added"
-typedef struct _NMModemManager NMModemManager;
-typedef struct _NMModemManagerClass NMModemManagerClass;
typedef struct _NMModemManagerPrivate NMModemManagerPrivate;
-struct _NMModemManager {
+typedef struct {
GObject parent;
NMModemManagerPrivate *priv;
-};
+} NMModemManager;
-struct _NMModemManagerClass {
+typedef struct {
GObjectClass parent;
- /* Signals */
- void (*modem_added) (NMModemManager *manager, NMModem *modem, const char *driver);
-
- void (*modem_removed) (NMModemManager *manager, NMModem *modem);
-};
+ void (*modem_added) (NMModemManager *self, NMModem *modem);
+} NMModemManagerClass;
GType nm_modem_manager_get_type (void);
-NMModemManager *nm_modem_manager_get (void);
-
#endif /* NM_MODEM_MANAGER_H */
diff --git a/src/modem-manager/nm-modem-old-types.h b/src/devices/wwan/nm-modem-old-types.h
index 976605db2b..976605db2b 100644
--- a/src/modem-manager/nm-modem-old-types.h
+++ b/src/devices/wwan/nm-modem-old-types.h
diff --git a/src/modem-manager/nm-modem-old.c b/src/devices/wwan/nm-modem-old.c
index f8bbcebb85..f8bbcebb85 100644
--- a/src/modem-manager/nm-modem-old.c
+++ b/src/devices/wwan/nm-modem-old.c
diff --git a/src/modem-manager/nm-modem-old.h b/src/devices/wwan/nm-modem-old.h
index 828da6a6d4..828da6a6d4 100644
--- a/src/modem-manager/nm-modem-old.h
+++ b/src/devices/wwan/nm-modem-old.h
diff --git a/src/modem-manager/nm-modem.c b/src/devices/wwan/nm-modem.c
index 8327c1c5d9..2ff0200894 100644
--- a/src/modem-manager/nm-modem.c
+++ b/src/devices/wwan/nm-modem.c
@@ -29,7 +29,7 @@
#include "NetworkManagerUtils.h"
#include "nm-device-private.h"
#include "nm-dbus-glib-types.h"
-#include "nm-enum-types.h"
+#include "nm-modem-enum-types.h"
G_DEFINE_TYPE (NMModem, nm_modem, G_TYPE_OBJECT)
diff --git a/src/modem-manager/nm-modem.h b/src/devices/wwan/nm-modem.h
index f15be26769..f15be26769 100644
--- a/src/modem-manager/nm-modem.h
+++ b/src/devices/wwan/nm-modem.h
diff --git a/src/devices/wwan/nm-wwan-factory.c b/src/devices/wwan/nm-wwan-factory.c
new file mode 100644
index 0000000000..3a02fb1913
--- /dev/null
+++ b/src/devices/wwan/nm-wwan-factory.c
@@ -0,0 +1,160 @@
+/* -*- 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) 2014 Red Hat, Inc.
+ */
+
+#include <string.h>
+#include "config.h"
+#include "nm-device-factory.h"
+#include "nm-wwan-factory.h"
+#include "nm-modem-manager.h"
+#include "nm-device-modem.h"
+#include "nm-logging.h"
+
+static GType nm_wwan_factory_get_type (void);
+
+static void device_factory_interface_init (NMDeviceFactory *factory_iface);
+
+G_DEFINE_TYPE_EXTENDED (NMWwanFactory, nm_wwan_factory, G_TYPE_OBJECT, 0,
+ G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_FACTORY, device_factory_interface_init))
+
+#define NM_WWAN_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_WWAN_FACTORY, NMWwanFactoryPrivate))
+
+typedef struct {
+ NMModemManager *mm;
+} NMWwanFactoryPrivate;
+
+enum {
+ PROP_0,
+ PROP_DEVICE_TYPE,
+
+ LAST_PROP
+};
+
+/************************************************************************/
+
+#define PLUGIN_TYPE NM_DEVICE_TYPE_MODEM
+
+G_MODULE_EXPORT NMDeviceFactory *
+nm_device_factory_create (GError **error)
+{
+ return (NMDeviceFactory *) g_object_new (NM_TYPE_WWAN_FACTORY, NULL);
+}
+
+G_MODULE_EXPORT NMDeviceType
+nm_device_factory_get_device_type (void)
+{
+ return PLUGIN_TYPE;
+}
+
+/************************************************************************/
+
+static void
+modem_added_cb (NMModemManager *manager,
+ NMModem *modem,
+ gpointer user_data)
+{
+ NMWwanFactory *self = NM_WWAN_FACTORY (user_data);
+ NMDevice *device;
+ const char *driver, *port;
+
+ /* Do nothing if the modem was consumed by some other plugin */
+ if (nm_device_factory_emit_component_added (NM_DEVICE_FACTORY (self), G_OBJECT (modem)))
+ return;
+
+ driver = nm_modem_get_driver (modem);
+
+ /* If it was a Bluetooth modem and no bluetooth device claimed it, ignore
+ * it. The rfcomm port (and thus the modem) gets created automatically
+ * by the Bluetooth code during the connection process.
+ */
+ if (driver && strstr (driver, "bluetooth")) {
+ port = nm_modem_get_data_port (modem);
+ if (!port)
+ port = nm_modem_get_control_port (modem);
+ nm_log_info (LOGD_MB, "ignoring modem '%s' (no associated Bluetooth device)", port);
+ return;
+ }
+
+ /* Make the new modem device */
+ device = nm_device_modem_new (modem);
+ g_assert (device);
+ g_signal_emit_by_name (self, NM_DEVICE_FACTORY_DEVICE_ADDED, device);
+ g_object_unref (device);
+}
+
+static void
+nm_wwan_factory_init (NMWwanFactory *self)
+{
+ NMWwanFactoryPrivate *priv = NM_WWAN_FACTORY_GET_PRIVATE (self);
+
+ priv->mm = g_object_new (NM_TYPE_MODEM_MANAGER, NULL);
+ g_assert (priv->mm);
+ g_signal_connect (priv->mm,
+ NM_MODEM_MANAGER_MODEM_ADDED,
+ G_CALLBACK (modem_added_cb),
+ self);
+}
+
+static void
+device_factory_interface_init (NMDeviceFactory *factory_iface)
+{
+}
+
+static void
+get_property (GObject *object, guint prop_id,
+ GValue *value, GParamSpec *pspec)
+{
+ switch (prop_id) {
+ case PROP_DEVICE_TYPE:
+ g_value_set_uint (value, PLUGIN_TYPE);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+dispose (GObject *object)
+{
+ NMWwanFactory *self = NM_WWAN_FACTORY (object);
+ NMWwanFactoryPrivate *priv = NM_WWAN_FACTORY_GET_PRIVATE (self);
+
+ if (priv->mm)
+ g_signal_handlers_disconnect_by_func (priv->mm, modem_added_cb, self);
+ g_clear_object (&priv->mm);
+
+ /* Chain up to the parent class */
+ G_OBJECT_CLASS (nm_wwan_factory_parent_class)->dispose (object);
+}
+
+static void
+nm_wwan_factory_class_init (NMWwanFactoryClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (object_class, sizeof (NMWwanFactoryPrivate));
+
+ object_class->dispose = dispose;
+ object_class->get_property = get_property;
+
+ g_object_class_override_property (object_class,
+ PROP_DEVICE_TYPE,
+ NM_DEVICE_FACTORY_DEVICE_TYPE);
+}
diff --git a/src/devices/wwan/nm-wwan-factory.h b/src/devices/wwan/nm-wwan-factory.h
new file mode 100644
index 0000000000..b7aee01f15
--- /dev/null
+++ b/src/devices/wwan/nm-wwan-factory.h
@@ -0,0 +1,37 @@
+/* -*- 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) 2014 Red Hat, Inc.
+ */
+
+#ifndef NM_WWAN_FACTORY_H
+#define NM_WWAN_FACTORY_H
+
+#include <glib-object.h>
+
+#define NM_TYPE_WWAN_FACTORY (nm_wwan_factory_get_type ())
+#define NM_WWAN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WWAN_FACTORY, NMWwanFactory))
+
+typedef struct {
+ GObject parent;
+} NMWwanFactory;
+
+typedef struct {
+ GObjectClass parent;
+} NMWwanFactoryClass;
+
+#endif /* NM_WWAN_FACTORY_H */
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 2d6c0f1121..7e8ae75fa3 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -39,12 +39,10 @@
#include "nm-logging.h"
#include "nm-dbus-manager.h"
#include "nm-vpn-manager.h"
-#include "nm-modem-manager.h"
#include "nm-device.h"
#include "nm-device-ethernet.h"
#include "nm-device-wifi.h"
#include "nm-device-olpc-mesh.h"
-#include "nm-device-modem.h"
#include "nm-device-infiniband.h"
#include "nm-device-bond.h"
#include "nm-device-team.h"
@@ -213,9 +211,6 @@ typedef struct {
NMVPNManager *vpn_manager;
- NMModemManager *modem_manager;
- guint modem_added_id;
-
DBusGProxy *aipd_proxy;
NMSleepMonitor *sleep_monitor;
@@ -520,45 +515,6 @@ manager_sleeping (NMManager *self)
}
static void
-modem_added (NMModemManager *modem_manager,
- NMModem *modem,
- const char *driver,
- gpointer user_data)
-{
- NMManager *self = NM_MANAGER (user_data);
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
- NMDevice *device = NULL;
- const char *modem_iface;
- GSList *iter;
-
- /* Give Bluetooth DUN devices first chance to claim the modem */
- for (iter = priv->devices; iter; iter = iter->next) {
- if (nm_device_notify_component_added (device, G_OBJECT (modem)))
- return;
- }
-
- /* If it was a Bluetooth modem and no bluetooth device claimed it, ignore
- * it. The rfcomm port (and thus the modem) gets created automatically
- * by the Bluetooth code during the connection process.
- */
- if (driver && !strcmp (driver, "bluetooth")) {
- modem_iface = nm_modem_get_data_port (modem);
- if (!modem_iface)
- modem_iface = nm_modem_get_control_port (modem);
-
- nm_log_info (LOGD_MB, "ignoring modem '%s' (no associated Bluetooth device)", modem_iface);
- return;
- }
-
- /* Make the new modem device */
- device = nm_device_modem_new (modem, driver);
- if (device) {
- add_device (self, device, FALSE);
- g_object_unref (device);
- }
-}
-
-static void
set_state (NMManager *manager, NMState state)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
@@ -1838,7 +1794,7 @@ add_device (NMManager *self, NMDevice *device, gboolean generate_con)
G_CALLBACK (manager_ipw_rfkill_state_changed),
self);
} else if (devtype == NM_DEVICE_TYPE_MODEM) {
- g_signal_connect (device, NM_DEVICE_MODEM_ENABLE_CHANGED,
+ g_signal_connect (device, "enable-changed",
G_CALLBACK (manager_modem_enabled_changed),
self);
}
@@ -4716,10 +4672,6 @@ nm_manager_init (NMManager *manager)
G_CALLBACK (dbus_connection_changed_cb),
manager);
- priv->modem_manager = nm_modem_manager_get ();
- priv->modem_added_id = g_signal_connect (priv->modem_manager, "modem-added",
- G_CALLBACK (modem_added), manager);
-
priv->vpn_manager = nm_vpn_manager_get ();
g_connection = nm_dbus_manager_get_connection (priv->dbus_mgr);
@@ -4937,12 +4889,6 @@ dispose (GObject *object)
g_clear_object (&priv->settings);
g_clear_object (&priv->vpn_manager);
- if (priv->modem_added_id) {
- g_source_remove (priv->modem_added_id);
- priv->modem_added_id = 0;
- }
- g_clear_object (&priv->modem_manager);
-
/* Unregister property filter */
if (priv->dbus_mgr) {
bus = nm_dbus_manager_get_connection (priv->dbus_mgr);