diff options
33 files changed, 466 insertions, 1052 deletions
diff --git a/cli/src/connections.c b/cli/src/connections.c index d08abccce7..a28004dbe6 100644 --- a/cli/src/connections.c +++ b/cli/src/connections.c @@ -46,8 +46,7 @@ #if WITH_WIMAX #include <nm-device-wimax.h> #endif -#include <nm-gsm-device.h> -#include <nm-cdma-device.h> +#include <nm-device-modem.h> #include <nm-device-bt.h> //#include <nm-device-olpc-mesh.h> #include <nm-remote-settings.h> @@ -922,54 +921,46 @@ check_wimax_compatible (NMDeviceWimax *device, NMConnection *connection, GError #endif static gboolean -check_gsm_compatible (NMGsmDevice *device, NMConnection *connection, GError **error) +check_modem_compatible (NMDeviceModem *device, NMConnection *connection, GError **error) { NMSettingConnection *s_con; NMSettingGsm *s_gsm; - - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION)); - g_assert (s_con); - - if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_GSM_SETTING_NAME)) { - g_set_error (error, 0, 0, - "The connection was not a GSM connection."); - return FALSE; - } - - s_gsm = NM_SETTING_GSM (nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM)); - if (!s_gsm) { - g_set_error (error, 0, 0, - "The connection was not a valid GSM connection."); - return FALSE; - } - - return TRUE; -} - -static gboolean -check_cdma_compatible (NMCdmaDevice *device, NMConnection *connection, GError **error) -{ - NMSettingConnection *s_con; NMSettingCdma *s_cdma; + NMDeviceModemCapabilities caps = NM_DEVICE_MODEM_CAPABILITY_NONE; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION)); g_assert (s_con); - if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_CDMA_SETTING_NAME)) { - g_set_error (error, 0, 0, - "The connection was not a CDMA connection."); - return FALSE; - } + /* Figure out what the modem supports */ + caps = nm_device_modem_get_current_capabilities (device); + if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) { + if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_GSM_SETTING_NAME)) { + g_set_error (error, 0, 0, + "The connection was not a GSM connection."); + return FALSE; + } - s_cdma = NM_SETTING_CDMA (nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA)); - if (!s_cdma) { - g_set_error (error, 0, 0, - "The connection was not a valid CDMA connection."); - return FALSE; + s_gsm = NM_SETTING_GSM (nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM)); + if (!s_gsm) { + g_set_error (error, 0, 0, + "The connection was not a valid GSM connection."); + return FALSE; + } + } else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) { + if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_CDMA_SETTING_NAME)) { + g_set_error (error, 0, 0, + "The connection was not a CDMA connection."); + return FALSE; + } + + s_cdma = NM_SETTING_CDMA (nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA)); + if (!s_cdma) { + g_set_error (error, 0, 0, + "The connection was not a valid CDMA connection."); + return FALSE; + } } return TRUE; @@ -993,10 +984,8 @@ nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection, else if (NM_IS_DEVICE_WIMAX (device)) return check_wimax_compatible (NM_DEVICE_WIMAX (device), connection, error); #endif - else if (NM_IS_GSM_DEVICE (device)) - return check_gsm_compatible (NM_GSM_DEVICE (device), connection, error); - else if (NM_IS_CDMA_DEVICE (device)) - return check_cdma_compatible (NM_CDMA_DEVICE (device), connection, error); + else if (NM_IS_DEVICE_MODEM (device)) + return check_modem_compatible (NM_DEVICE_MODEM (device), connection, error); g_set_error (error, 0, 0, "unhandled device type '%s'", G_OBJECT_TYPE_NAME (device)); return FALSE; diff --git a/cli/src/devices.c b/cli/src/devices.c index 991bf3b9bb..d0fa6b4fb4 100644 --- a/cli/src/devices.c +++ b/cli/src/devices.c @@ -33,8 +33,7 @@ #include <nm-device.h> #include <nm-device-ethernet.h> #include <nm-device-wifi.h> -#include <nm-gsm-device.h> -#include <nm-cdma-device.h> +#include <nm-device-modem.h> #include <nm-device-bt.h> //#include <nm-device-olpc-mesh.h> #if WITH_WIMAX @@ -312,17 +311,22 @@ device_state_to_string (NMDeviceState state) * connection type names. */ static const char * -device_type_to_string (NMDeviceType device_type) +device_type_to_string (NMDevice *device) { - switch (device_type) { + NMDeviceModemCapabilities caps = NM_DEVICE_MODEM_CAPABILITY_NONE; + + switch (nm_device_get_device_type (device)) { case NM_DEVICE_TYPE_ETHERNET: return NM_SETTING_WIRED_SETTING_NAME; case NM_DEVICE_TYPE_WIFI: return NM_SETTING_WIRELESS_SETTING_NAME; - case NM_DEVICE_TYPE_GSM: - return NM_SETTING_GSM_SETTING_NAME; - case NM_DEVICE_TYPE_CDMA: - return NM_SETTING_CDMA_SETTING_NAME; + case NM_DEVICE_TYPE_MODEM: + caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)); + if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) + return NM_SETTING_GSM_SETTING_NAME; + else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) + return NM_SETTING_CDMA_SETTING_NAME; + return _("Unknown"); case NM_DEVICE_TYPE_BT: return NM_SETTING_BLUETOOTH_SETTING_NAME; // case NM_DEVICE_TYPE_OLPC_MESH: @@ -647,7 +651,7 @@ show_device_info (gpointer data, gpointer user_data) nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[0].name; /* "GENERAL"*/ nmc->allowed_fields[1].value = nm_device_get_iface (device); - nmc->allowed_fields[2].value = device_type_to_string (nm_device_get_device_type (device)); + nmc->allowed_fields[2].value = device_type_to_string (device); nmc->allowed_fields[3].value = nm_device_get_driver (device) ? nm_device_get_driver (device) : _("(unknown)"); nmc->allowed_fields[4].value = hwaddr ? hwaddr : _("unknown)"); nmc->allowed_fields[5].value = device_state_to_string (state); @@ -956,7 +960,7 @@ static void show_device_status (NMDevice *device, NmCli *nmc) { nmc->allowed_fields[0].value = nm_device_get_iface (device); - nmc->allowed_fields[1].value = device_type_to_string (nm_device_get_device_type (device)); + nmc->allowed_fields[1].value = device_type_to_string (device); nmc->allowed_fields[2].value = device_state_to_string (nm_device_get_state (device)); nmc->allowed_fields[3].value = nm_object_get_path (NM_OBJECT (device)); diff --git a/docs/libnm-glib/Makefile.am b/docs/libnm-glib/Makefile.am index 66826cb8af..a7dc71f3ba 100644 --- a/docs/libnm-glib/Makefile.am +++ b/docs/libnm-glib/Makefile.am @@ -43,6 +43,7 @@ IGNORE_HFILES= \ nm-device-bt-bindings.h \ nm-device-ethernet-bindings.h \ nm-device-wifi-bindings.h \ + nm-device-modem-bindings.h \ nm-dhcp4-config-bindings.h \ nm-dhcp6-config-bindings.h \ nm-settings-connection-glue.h \ diff --git a/docs/libnm-glib/libnm-glib-docs.sgml b/docs/libnm-glib/libnm-glib-docs.sgml index 85e626e280..2c055c04f1 100644 --- a/docs/libnm-glib/libnm-glib-docs.sgml +++ b/docs/libnm-glib/libnm-glib-docs.sgml @@ -18,9 +18,7 @@ <xi:include href="xml/nm-device.xml"/> <xi:include href="xml/nm-device-ethernet.xml"/> <xi:include href="xml/nm-device-wifi.xml"/> - <xi:include href="xml/nm-serial-device.xml"/> - <xi:include href="xml/nm-gsm-device.xml"/> - <xi:include href="xml/nm-cdma-device.xml"/> + <xi:include href="xml/nm-device-modem.xml"/> <xi:include href="xml/nm-device-bt.xml"/> <xi:include href="xml/nm-device-wimax.xml"/> <xi:include href="xml/nm-access-point.xml"/> diff --git a/docs/libnm-glib/libnm-glib.types b/docs/libnm-glib/libnm-glib.types index 99783ba696..5ee8a39e10 100644 --- a/docs/libnm-glib/libnm-glib.types +++ b/docs/libnm-glib/libnm-glib.types @@ -1,9 +1,7 @@ #include <nm-client.h> #include <nm-device-ethernet.h> #include <nm-device-wifi.h> -#include <nm-cdma-device.h> -#include <nm-gsm-device.h> -#include <nm-serial-device.h> +#include <nm-device-modem.h> #include <nm-access-point.h> #include <nm-ip4-config.h> #include <nm-ip6-config.h> @@ -15,9 +13,7 @@ nm_client_get_type nm_device_get_type nm_device_ethernet_get_type nm_device_wifi_get_type -nm_gsm_device_get_type -nm_cdma_device_get_type -nm_serial_device_get_type +nm_device_modem_get_type nm_access_point_get_type nm_ip4_config_get_type nm_active_connection_get_type diff --git a/include/NetworkManager.h b/include/NetworkManager.h index 4b68731536..1ff9111582 100644 --- a/include/NetworkManager.h +++ b/include/NetworkManager.h @@ -36,9 +36,7 @@ #define NM_DBUS_INTERFACE_DEVICE_BLUETOOTH NM_DBUS_INTERFACE_DEVICE ".Bluetooth" #define NM_DBUS_PATH_ACCESS_POINT NM_DBUS_PATH "/AccessPoint" #define NM_DBUS_INTERFACE_ACCESS_POINT NM_DBUS_INTERFACE ".AccessPoint" -#define NM_DBUS_INTERFACE_SERIAL_DEVICE NM_DBUS_INTERFACE_DEVICE ".Serial" -#define NM_DBUS_INTERFACE_GSM_DEVICE NM_DBUS_INTERFACE_DEVICE ".Gsm" -#define NM_DBUS_INTERFACE_CDMA_DEVICE NM_DBUS_INTERFACE_DEVICE ".Cdma" +#define NM_DBUS_INTERFACE_DEVICE_MODEM NM_DBUS_INTERFACE_DEVICE ".Modem" #define NM_DBUS_INTERFACE_DEVICE_WIMAX NM_DBUS_INTERFACE_DEVICE ".WiMax" #define NM_DBUS_INTERFACE_WIMAX_NSP NM_DBUS_INTERFACE ".WiMax.Nsp" #define NM_DBUS_PATH_WIMAX_NSP NM_DBUS_PATH "/Nsp" @@ -94,11 +92,12 @@ typedef enum { NM_DEVICE_TYPE_UNKNOWN = 0, NM_DEVICE_TYPE_ETHERNET = 1, NM_DEVICE_TYPE_WIFI = 2, - NM_DEVICE_TYPE_GSM = 3, - NM_DEVICE_TYPE_CDMA = 4, + NM_DEVICE_TYPE_UNUSED1 = 3, + NM_DEVICE_TYPE_UNUSED2 = 4, NM_DEVICE_TYPE_BT = 5, /* Bluetooth */ NM_DEVICE_TYPE_OLPC_MESH = 6, - NM_DEVICE_TYPE_WIMAX = 7 + NM_DEVICE_TYPE_WIMAX = 7, + NM_DEVICE_TYPE_MODEM = 8, } NMDeviceType; /* General device capability flags */ @@ -173,6 +172,30 @@ typedef enum { NM_BT_CAPABILITY_NAP = 0x00000002, } NMBluetoothCapabilities; +/** + * NMDeviceModemCapabilities: + * @NM_DEVICE_MODEM_CAPABILITY_NONE: modem has no usable capabilities + * @NM_DEVICE_MODEM_CAPABILITY_POTS: modem uses the analog wired telephone + * network and is not a wireless/cellular device + * @NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO: modem supports at least one of CDMA + * 1xRTT, EVDO revision 0, EVDO revision A, or EVDO revision B + * @NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS: modem supports at least one of GSM, + * GPRS, EDGE, UMTS, HSDPA, HSUPA, or HSPA+ packet switched data capability + * @NM_DEVICE_MODEM_CAPABILITY_LTE: modem has LTE data capability + * + * #NMDeviceModemCapabilities values indicate the generic radio access + * technology families a modem device supports. For more information on the + * specific access technologies the device supports use the ModemManager D-Bus + * API. + */ +typedef enum { + NM_DEVICE_MODEM_CAPABILITY_NONE = 0x00000000, + NM_DEVICE_MODEM_CAPABILITY_POTS = 0x00000001, + NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO = 0x00000002, + NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS = 0x00000004, + NM_DEVICE_MODEM_CAPABILITY_LTE = 0x00000008, +} NMDeviceModemCapabilities; + /** * NMDeviceState: diff --git a/introspection/Makefile.am b/introspection/Makefile.am index a469a87976..320245eee1 100644 --- a/introspection/Makefile.am +++ b/introspection/Makefile.am @@ -8,9 +8,7 @@ EXTRA_DIST = \ nm-device-wifi.xml \ nm-device-olpc-mesh.xml \ nm-device-ethernet.xml \ - nm-device-cdma.xml \ - nm-device-gsm.xml \ - nm-device-serial.xml \ + nm-device-modem.xml \ nm-device-wimax.xml \ nm-device.xml \ nm-ip4-config.xml \ diff --git a/introspection/all.xml b/introspection/all.xml index 61ef156a57..5d1baf01c9 100644 --- a/introspection/all.xml +++ b/introspection/all.xml @@ -30,9 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ <xi:include href="nm-device.xml"/> <xi:include href="nm-device-ethernet.xml"/> <xi:include href="nm-device-wifi.xml"/> -<xi:include href="nm-device-cdma.xml"/> -<xi:include href="nm-device-gsm.xml"/> -<xi:include href="nm-device-serial.xml"/> +<xi:include href="nm-device-modem.xml"/> <xi:include href="nm-device-bt.xml"/> <xi:include href="nm-device-olpc-mesh.xml"/> <xi:include href="nm-device-wimax.xml"/> diff --git a/introspection/nm-device-modem.xml b/introspection/nm-device-modem.xml new file mode 100644 index 0000000000..0ca101fd74 --- /dev/null +++ b/introspection/nm-device-modem.xml @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + <interface name="org.freedesktop.NetworkManager.Device.Modem"> + + <signal name="PropertiesChanged"> + <arg name="properties" type="a{sv}" tp:type="String_Variant_Map"> + <tp:docstring> + A dictionary mapping property names to variant boxed values + </tp:docstring> + </arg> + </signal> + + <property name="ModemCapabilities" type="u" access="read" tp:type="NM_DEVICE_MODEM_CAPABILITIES"> + <tp:docstring> + The generic family of access technologies the modem supports. Not all + capabilities are available at the same time however; some modems require + a firmware reload or other reinitialization to switch between eg CDMA/EVDO + and GSM/UMTS. + </tp:docstring> + </property> + + <property name="CurrentCapabilities" type="u" access="read" tp:type="NM_DEVICE_MODEM_CAPABILITIES"> + <tp:docstring> + The generic family of access technologies the modem currently supports + without a firmware reload or reinitialization. + </tp:docstring> + </property> + + <tp:flags name="NM_DEVICE_MODEM_CAPABILITIES" value-prefix="NM_DEVICE_MODEM_CAPABILITY" type="u"> + <tp:docstring> + Flags describing one or more of the general access technology families + that a modem device supports. + </tp:docstring> + <tp:flag suffix="NONE" value="0x0"> + <tp:docstring>Modem has no capabilties.</tp:docstring> + </tp:flag> + <tp:flag suffix="POTS" value="0x1"> + <tp:docstring> + Modem supports the analog wired telephone network (ie 56k dialup) and + does not have wireless/cellular capabilities. + </tp:docstring> + </tp:flag> + <tp:flag suffix="CDMA_EVDO" value="0x2"> + <tp:docstring> + Modem supports at least one of CDMA 1xRTT, EVDO revision 0, EVDO + revision A, or EVDO revision B. + </tp:docstring> + </tp:flag> + <tp:flag suffix="GSM_UMTS" value="0x4"> + <tp:docstring> + Modem supports at least one of GSM, GPRS, EDGE, UMTS, HSDPA, HSUPA, or + HSPA+ packet switched data capability. + </tp:docstring> + </tp:flag> + <tp:flag suffix="LTE" value="0x8"> + <tp:docstring> + Modem has at LTE data capability. + </tp:docstring> + </tp:flag> + </tp:flags> + + </interface> +</node> diff --git a/introspection/nm-device-serial.xml b/introspection/nm-device-serial.xml deleted file mode 100644 index 13b0853737..0000000000 --- a/introspection/nm-device-serial.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> - -<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> - <interface name="org.freedesktop.NetworkManager.Device.Serial"> - - <signal name="PppStats"> - <arg name="in_bytes" type="u"> - <tp:docstring> - Bytes received - </tp:docstring> - </arg> - <arg name="out_bytes" type="u"> - <tp:docstring> - Bytes sent - </tp:docstring> - </arg> - </signal> - - </interface> -</node> diff --git a/libnm-glib/Makefile.am b/libnm-glib/Makefile.am index 02b9fdef6e..af258a6568 100644 --- a/libnm-glib/Makefile.am +++ b/libnm-glib/Makefile.am @@ -14,6 +14,7 @@ BUILT_SOURCES = \ nm-device-bt-bindings.h \ nm-settings-connection-bindings.h \ nm-device-wimax-bindings.h \ + nm-device-modem-bindings.h \ nm-settings-bindings.h \ nm-vpn-connection-bindings.h \ nm-vpn-plugin-glue.h \ @@ -73,9 +74,7 @@ libnminclude_HEADERS = \ nm-device-bt.h \ nm-access-point.h \ nm-ip4-config.h \ - nm-gsm-device.h \ - nm-cdma-device.h \ - nm-serial-device.h \ + nm-device-modem.h \ nm-vpn-connection.h \ nm-types.h \ nm-active-connection.h \ @@ -103,9 +102,7 @@ libnm_glib_la_csources = \ nm-device-bt.c \ nm-access-point.c \ nm-ip4-config.c \ - nm-gsm-device.c \ - nm-cdma-device.c \ - nm-serial-device.c \ + nm-device-modem.c \ nm-vpn-connection.c \ nm-types.c \ nm-object-cache.c \ @@ -232,6 +229,9 @@ nm-secret-agent-glue.h: $(top_srcdir)/introspection/nm-secret-agent.xml nm-device-wimax-bindings.h: $(top_srcdir)/introspection/nm-device-wimax.xml dbus-binding-tool --prefix=nm_device_wimax --mode=glib-client --output=$@ $< +nm-device-modem-bindings.h: $(top_srcdir)/introspection/nm-device-modem.xml + dbus-binding-tool --prefix=nm_device_modem --mode=glib-client --output=$@ $< + pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libnm-glib.pc libnm-glib-vpn.pc diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver index ffe3c6fafd..3db1a92fec 100644 --- a/libnm-glib/libnm-glib.ver +++ b/libnm-glib/libnm-glib.ver @@ -24,8 +24,6 @@ global: nm_active_connection_get_state; nm_active_connection_get_type; nm_active_connection_new; - nm_cdma_device_get_type; - nm_cdma_device_new; nm_client_activate_connection; nm_client_add_and_activate_connection; nm_client_deactivate_connection; @@ -85,6 +83,9 @@ global: nm_device_get_udi; nm_device_get_vendor; nm_device_new; + nm_device_modem_get_type; + nm_device_modem_get_modem_capabilities; + nm_device_modem_get_current_capabilities; nm_device_wifi_get_access_point_by_path; nm_device_wifi_get_access_points; nm_device_wifi_get_active_access_point; @@ -114,8 +115,6 @@ global: nm_dhcp6_config_get_options; nm_dhcp6_config_get_type; nm_dhcp6_config_new; - nm_gsm_device_get_type; - nm_gsm_device_new; nm_ip4_config_get_addresses; nm_ip4_config_get_domains; nm_ip4_config_get_hostname; diff --git a/libnm-glib/nm-cdma-device.c b/libnm-glib/nm-cdma-device.c deleted file mode 100644 index 31b2e99c34..0000000000 --- a/libnm-glib/nm-cdma-device.c +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * libnm_glib -- Access network status & information from glib applications - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Red Hat, Inc. - * Copyright (C) 2008 Novell, Inc. - */ - -#include "nm-cdma-device.h" -#include "nm-device-private.h" -#include "nm-object-private.h" - -G_DEFINE_TYPE (NMCdmaDevice, nm_cdma_device, NM_TYPE_SERIAL_DEVICE) - -#define NM_CDMA_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CDMA_DEVICE, NMCdmaDevicePrivate)) - -typedef struct { - DBusGProxy *proxy; - - gboolean disposed; -} NMCdmaDevicePrivate; - -static void -nm_cdma_device_init (NMCdmaDevice *device) -{ -} - -static void -register_for_property_changed (NMCdmaDevice *device) -{ - NMCdmaDevicePrivate *priv = NM_CDMA_DEVICE_GET_PRIVATE (device); - const NMPropertiesChangedInfo property_changed_info[] = { - { NULL }, - }; - - _nm_object_handle_properties_changed (NM_OBJECT (device), - priv->proxy, - property_changed_info); -} - -static GObject* -constructor (GType type, - guint n_construct_params, - GObjectConstructParam *construct_params) -{ - GObject *object; - NMCdmaDevicePrivate *priv; - - object = G_OBJECT_CLASS (nm_cdma_device_parent_class)->constructor (type, - n_construct_params, - construct_params); - if (!object) - return NULL; - - priv = NM_CDMA_DEVICE_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_CDMA_DEVICE); - - register_for_property_changed (NM_CDMA_DEVICE (object)); - - return object; -} - -static void -dispose (GObject *object) -{ - NMCdmaDevicePrivate *priv = NM_CDMA_DEVICE_GET_PRIVATE (object); - - if (priv->disposed) { - G_OBJECT_CLASS (nm_cdma_device_parent_class)->dispose (object); - return; - } - - priv->disposed = TRUE; - - g_object_unref (priv->proxy); - - G_OBJECT_CLASS (nm_cdma_device_parent_class)->dispose (object); -} - -static void -nm_cdma_device_class_init (NMCdmaDeviceClass *device_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (device_class); - - g_type_class_add_private (device_class, sizeof (NMCdmaDevicePrivate)); - - /* virtual methods */ - object_class->constructor = constructor; - object_class->dispose = dispose; -} - -/** - * nm_cdma_device_new: - * @connection: the #DBusGConnection - * @path: the DBus object path of the device - * - * Creates a new #NMCdmaDevice. - * - * Returns: a new device - **/ -GObject * -nm_cdma_device_new (DBusGConnection *connection, const char *path) -{ - g_return_val_if_fail (connection != NULL, NULL); - g_return_val_if_fail (path != NULL, NULL); - - return g_object_new (NM_TYPE_CDMA_DEVICE, - NM_OBJECT_DBUS_CONNECTION, connection, - NM_OBJECT_DBUS_PATH, path, - NULL); -} diff --git a/libnm-glib/nm-cdma-device.h b/libnm-glib/nm-cdma-device.h deleted file mode 100644 index f40124ace7..0000000000 --- a/libnm-glib/nm-cdma-device.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * libnm_glib -- Access network status & information from glib applications - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Red Hat, Inc. - * Copyright (C) 2008 Novell, Inc. - */ - -#ifndef NM_CDMA_DEVICE_H -#define NM_CDMA_DEVICE_H - -#include "nm-serial-device.h" - -G_BEGIN_DECLS - -#define NM_TYPE_CDMA_DEVICE (nm_cdma_device_get_type ()) -#define NM_CDMA_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CDMA_DEVICE, NMCdmaDevice)) -#define NM_CDMA_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_CDMA_DEVICE, NMCdmaDeviceClass)) -#define NM_IS_CDMA_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CDMA_DEVICE)) -#define NM_IS_CDMA_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_CDMA_DEVICE)) -#define NM_CDMA_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_CDMA_DEVICE, NMCdmaDeviceClass)) - -typedef struct { - NMSerialDevice parent; -} NMCdmaDevice; - -typedef struct { - NMSerialDeviceClass parent; - - /* Padding for future expansion */ - void (*_reserved1) (void); - void (*_reserved2) (void); - void (*_reserved3) (void); - void (*_reserved4) (void); - void (*_reserved5) (void); - void (*_reserved6) (void); -} NMCdmaDeviceClass; - -GType nm_cdma_device_get_type (void); - -GObject *nm_cdma_device_new (DBusGConnection *connection, const char *path); - -G_END_DECLS - -#endif /* NM_CDMA_DEVICE_H */ diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c index b63b818d05..9a49d3a524 100644 --- a/libnm-glib/nm-client.c +++ b/libnm-glib/nm-client.c @@ -28,8 +28,6 @@ #include "nm-client.h" #include "nm-device-ethernet.h" #include "nm-device-wifi.h" -#include "nm-gsm-device.h" -#include "nm-cdma-device.h" #include "nm-device-private.h" #include "nm-marshal.h" #include "nm-types-private.h" diff --git a/libnm-glib/nm-device-modem.c b/libnm-glib/nm-device-modem.c new file mode 100644 index 0000000000..46a2fd476f --- /dev/null +++ b/libnm-glib/nm-device-modem.c @@ -0,0 +1,186 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * libnm_glib -- Access network status & information from glib applications + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright (C) 2011 Red Hat, Inc. + * Copyright (C) 2008 Novell, Inc. + */ + +#include "nm-device-modem.h" +#include "nm-device-private.h" +#include "nm-object-private.h" +#include "nm-marshal.h" + +G_DEFINE_TYPE (NMDeviceModem, nm_device_modem, NM_TYPE_DEVICE) + +#define NM_DEVICE_MODEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ + NM_TYPE_DEVICE_MODEM, \ + NMDeviceModemPrivate)) + +typedef struct { + DBusGProxy *proxy; + + NMDeviceModemCapabilities caps; + NMDeviceModemCapabilities current_caps; + + gboolean disposed; +} NMDeviceModemPrivate; + +enum { + PROP_0, + PROP_MODEM_CAPABILITIES, + PROP_CURRENT_CAPABILITIES, + LAST_PROP +}; + +#define DBUS_PROP_MODEM_CAPS "ModemCapabilities" +#define DBUS_PROP_CURRENT_CAPS "CurrentCapabilities" + +/** + * nm_device_modem_get_modem_capabilities: + * @self: a #NMDeviceModem + * + * Returns a bitfield of the generic access technology families the modem + * supports. Not all capabilities are available concurrently however; some + * may require a firmware reload or reinitialization. + * + * Returns: the generic access technology families the modem supports + **/ +NMDeviceModemCapabilities +nm_device_modem_get_modem_capabilities (NMDeviceModem *self) +{ + NMDeviceModemPrivate *priv; + + g_return_val_if_fail (self != NULL, NM_DEVICE_MODEM_CAPABILITY_NONE); + g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NM_DEVICE_MODEM_CAPABILITY_NONE); + + priv = NM_DEVICE_MODEM_GET_PRIVATE (self); + if (!priv->caps) { + priv->caps = _nm_object_get_uint_property (NM_OBJECT (self), + NM_DBUS_INTERFACE_DEVICE_MODEM, + DBUS_PROP_MODEM_CAPS, + NULL); + } + + return priv->caps; +} + +/** + * nm_device_modem_get_current_capabilities: + * @self: a #NMDeviceModem + * + * Returns a bitfield of the generic access technology families the modem + * supports without a firmware reload or reinitialization. This value + * represents the network types the modem can immediately connect to. + * + * Returns: the generic access technology families the modem supports without + * a firmware reload or other reinitialization + **/ +NMDeviceModemCapabilities +nm_device_modem_get_current_capabilities (NMDeviceModem *self) +{ + NMDeviceModemPrivate *priv; + + g_return_val_if_fail (self != NULL, NM_DEVICE_MODEM_CAPABILITY_NONE); + g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NM_DEVICE_MODEM_CAPABILITY_NONE); + + priv = NM_DEVICE_MODEM_GET_PRIVATE (self); + if (!priv->current_caps) { + priv->current_caps = _nm_object_get_uint_property (NM_OBJECT (self), + NM_DBUS_INTERFACE_DEVICE_MODEM, + DBUS_PROP_CURRENT_CAPS, + NULL); + } + + return priv->current_caps; +} + +static void +register_for_property_changed (NMDeviceModem *device) +{ + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device); + const NMPropertiesChangedInfo property_changed_info[] = { + { NM_DEVICE_MODEM_MODEM_CAPABILITIES, _nm_object_demarshal_generic, &priv->caps }, + { NM_DEVICE_MODEM_CURRENT_CAPABILITIES, _nm_object_demarshal_generic, &priv->current_caps }, + { NULL }, + }; + + _nm_object_handle_properties_changed (NM_OBJECT (device), + priv->proxy, + property_changed_info); +} + +static GObject* +constructor (GType type, + guint n_construct_params, + GObjectConstructParam *construct_params) +{ + GObject *object; + NMDeviceModemPrivate *priv; + + object = G_OBJECT_CLASS (nm_device_modem_parent_class)->constructor (type, + n_construct_params, + construct_params); + if (object) { + priv = NM_DEVICE_MODEM_GET_PRIVATE (object); + + priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), + NM_DBUS_SERVICE, + nm_object_get_path (NM_OBJECT (object)), + NM_DBUS_INTERFACE_DEVICE_MODEM); + + register_for_property_changed (NM_DEVICE_MODEM (object)); + } + + return object; +} + +static void +nm_device_modem_init (NMDeviceModem *device) +{ +} + +static void +dispose (GObject *object) +{ + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object); + + if (priv->disposed) { + G_OBJECT_CLASS (nm_device_modem_parent_class)->dispose (object); + return; + } + + priv->disposed = TRUE; + + g_object_unref (priv->proxy); + + G_OBJECT_CLASS (nm_device_modem_parent_class)->dispose (object); +} + +static void +nm_device_modem_class_init (NMDeviceModemClass *device_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (device_class); + + g_type_class_add_private (device_class, sizeof (NMDeviceModemPrivate)); + + /* virtual methods */ + object_class->constructor = constructor; + object_class->dispose = dispose; +} + diff --git a/libnm-glib/nm-serial-device.h b/libnm-glib/nm-device-modem.h index 51f08df33f..7a4759f2e3 100644 --- a/libnm-glib/nm-serial-device.h +++ b/libnm-glib/nm-device-modem.h @@ -17,33 +17,34 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA. * + * Copyright (C) 2011 Red Hat, Inc. * Copyright (C) 2008 Novell, Inc. */ -#ifndef NM_SERIAL_DEVICE_H -#define NM_SERIAL_DEVICE_H +#ifndef NM_DEVICE_MODEM_H +#define NM_DEVICE_MODEM_H #include "nm-device.h" G_BEGIN_DECLS -#define NM_TYPE_SERIAL_DEVICE (nm_serial_device_get_type ()) -#define NM_SERIAL_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SERIAL_DEVICE, NMSerialDevice)) -#define NM_SERIAL_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SERIAL_DEVICE, NMSerialDeviceClass)) -#define NM_IS_SERIAL_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SERIAL_DEVICE)) -#define NM_IS_SERIAL_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_SERIAL_DEVICE)) -#define NM_SERIAL_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SERIAL_DEVICE, NMSerialDeviceClass)) +#define NM_TYPE_DEVICE_MODEM (nm_device_modem_get_type ()) +#define NM_DEVICE_MODEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_MODEM, NMDeviceModem)) +#define NM_DEVICE_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_MODEM, NMDeviceModemClass)) +#define NM_IS_DEVICE_MODEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_MODEM)) +#define NM_IS_DEVICE_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_DEVICE_MODEM)) +#define NM_DEVICE_MODEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_MODEM, NMDeviceModemClass)) + +#define NM_DEVICE_MODEM_MODEM_CAPABILITIES "modem-capabilities" +#define NM_DEVICE_MODEM_CURRENT_CAPABILITIES "current-capabilities" typedef struct { NMDevice parent; -} NMSerialDevice; +} NMDeviceModem; typedef struct { NMDeviceClass parent; - /* Signals */ - void (*ppp_stats) (NMSerialDevice *self, guint32 in_bytes, guint32 out_bytes); - /* Padding for future expansion */ void (*_reserved1) (void); void (*_reserved2) (void); @@ -51,13 +52,13 @@ typedef struct { void (*_reserved4) (void); void (*_reserved5) (void); void (*_reserved6) (void); -} NMSerialDeviceClass; +} NMDeviceModemClass; -GType nm_serial_device_get_type (void); +GType nm_device_modem_get_type (void); -guint32 nm_serial_device_get_bytes_received (NMSerialDevice *self); -guint32 nm_serial_device_get_bytes_sent (NMSerialDevice *self); +NMDeviceModemCapabilities nm_device_modem_get_modem_capabilities (NMDeviceModem *modem); +NMDeviceModemCapabilities nm_device_modem_get_current_capabilities (NMDeviceModem *modem); G_END_DECLS -#endif /* NM_SERIAL_DEVICE_H */ +#endif /* NM_DEVICE_MODEM_H */ diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c index cea53ef6f3..7f0e5aa5c4 100644 --- a/libnm-glib/nm-device.c +++ b/libnm-glib/nm-device.c @@ -29,8 +29,7 @@ #include "NetworkManager.h" #include "nm-device-ethernet.h" #include "nm-device-wifi.h" -#include "nm-gsm-device.h" -#include "nm-cdma-device.h" +#include "nm-device-modem.h" #include "nm-device-bt.h" #include "nm-device-wimax.h" #include "nm-device.h" @@ -748,11 +747,8 @@ nm_device_new (DBusGConnection *connection, const char *path) case NM_DEVICE_TYPE_WIFI: dtype = NM_TYPE_DEVICE_WIFI; break; - case NM_DEVICE_TYPE_GSM: - dtype = NM_TYPE_GSM_DEVICE; - break; - case NM_DEVICE_TYPE_CDMA: - dtype = NM_TYPE_CDMA_DEVICE; + case NM_DEVICE_TYPE_MODEM: + dtype = NM_TYPE_DEVICE_MODEM; break; case NM_DEVICE_TYPE_BT: dtype = NM_TYPE_DEVICE_BT; diff --git a/libnm-glib/nm-gsm-device.c b/libnm-glib/nm-gsm-device.c deleted file mode 100644 index aacbbb8262..0000000000 --- a/libnm-glib/nm-gsm-device.c +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * libnm_glib -- Access network status & information from glib applications - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2008 Red Hat, Inc. - */ - -#include "nm-gsm-device.h" -#include "nm-device-private.h" -#include "nm-object-private.h" - -G_DEFINE_TYPE (NMGsmDevice, nm_gsm_device, NM_TYPE_SERIAL_DEVICE) - -#define NM_GSM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_GSM_DEVICE, NMGsmDevicePrivate)) - -typedef struct { - DBusGProxy *proxy; - - gboolean disposed; -} NMGsmDevicePrivate; - -static void -nm_gsm_device_init (NMGsmDevice *device) -{ -} - -static void -register_for_property_changed (NMGsmDevice *device) -{ - NMGsmDevicePrivate *priv = NM_GSM_DEVICE_GET_PRIVATE (device); - const NMPropertiesChangedInfo property_changed_info[] = { - { NULL }, - }; - - _nm_object_handle_properties_changed (NM_OBJECT (device), - priv->proxy, - property_changed_info); -} - -static GObject* -constructor (GType type, - guint n_construct_params, - GObjectConstructParam *construct_params) -{ - GObject *object; - NMGsmDevicePrivate *priv; - - object = G_OBJECT_CLASS (nm_gsm_device_parent_class)->constructor (type, - n_construct_params, - construct_params); - if (!object) - return NULL; - - priv = NM_GSM_DEVICE_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_GSM_DEVICE); - - register_for_property_changed (NM_GSM_DEVICE (object)); - - return object; -} - -static void -dispose (GObject *object) -{ - NMGsmDevicePrivate *priv = NM_GSM_DEVICE_GET_PRIVATE (object); - - if (priv->disposed) { - G_OBJECT_CLASS (nm_gsm_device_parent_class)->dispose (object); - return; - } - - priv->disposed = TRUE; - - g_object_unref (priv->proxy); - - G_OBJECT_CLASS (nm_gsm_device_parent_class)->dispose (object); -} - -static void -nm_gsm_device_class_init (NMGsmDeviceClass *device_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (device_class); - - g_type_class_add_private (device_class, sizeof (NMGsmDevicePrivate)); - - /* virtual methods */ - object_class->constructor = constructor; - object_class->dispose = dispose; -} - -/** - * nm_gsm_device_new: - * @connection: the #DBusGConnection - * @path: the DBus object path of the device - * - * Creates a new #NMGsmDevice. - * - * Returns: a new device - **/ -NMGsmDevice * -nm_gsm_device_new (DBusGConnection *connection, const char *path) -{ - g_return_val_if_fail (connection != NULL, NULL); - g_return_val_if_fail (path != NULL, NULL); - - return (NMGsmDevice *) g_object_new (NM_TYPE_GSM_DEVICE, - NM_OBJECT_DBUS_CONNECTION, connection, - NM_OBJECT_DBUS_PATH, path, - NULL); -} diff --git a/libnm-glib/nm-gsm-device.h b/libnm-glib/nm-gsm-device.h deleted file mode 100644 index d8440973f7..0000000000 --- a/libnm-glib/nm-gsm-device.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * libnm_glib -- Access network status & information from glib applications - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2008 Red Hat, Inc. - */ - -#ifndef NM_GSM_DEVICE_H -#define NM_GSM_DEVICE_H - -#include "nm-serial-device.h" - -G_BEGIN_DECLS - -#define NM_TYPE_GSM_DEVICE (nm_gsm_device_get_type ()) -#define NM_GSM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_GSM_DEVICE, NMGsmDevice)) -#define NM_GSM_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_GSM_DEVICE, NMGsmDeviceClass)) -#define NM_IS_GSM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_GSM_DEVICE)) -#define NM_IS_GSM_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_GSM_DEVICE)) -#define NM_GSM_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_GSM_DEVICE, NMGsmDeviceClass)) - -typedef struct { - NMSerialDevice parent; -} NMGsmDevice; - -typedef struct { - NMSerialDeviceClass parent; - - /* Padding for future expansion */ - void (*_reserved1) (void); - void (*_reserved2) (void); - void (*_reserved3) (void); - void (*_reserved4) (void); - void (*_reserved5) (void); - void (*_reserved6) (void); -} NMGsmDeviceClass; - -GType nm_gsm_device_get_type (void); - -NMGsmDevice *nm_gsm_device_new (DBusGConnection *connection, - const char *path); - -G_END_DECLS - -#endif /* NM_GSM_DEVICE_H */ diff --git a/libnm-glib/nm-serial-device.c b/libnm-glib/nm-serial-device.c deleted file mode 100644 index bb45d7c43f..0000000000 --- a/libnm-glib/nm-serial-device.c +++ /dev/null @@ -1,207 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * libnm_glib -- Access network status & information from glib applications - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2008 Novell, Inc. - */ - -#include "nm-serial-device.h" -#include "nm-device-private.h" -#include "nm-object-private.h" -#include "nm-marshal.h" - -G_DEFINE_ABSTRACT_TYPE (NMSerialDevice, nm_serial_device, NM_TYPE_DEVICE) - -#define NM_SERIAL_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SERIAL_DEVICE, NMSerialDevicePrivate)) - -typedef struct { - DBusGProxy *proxy; - - guint32 in_bytes; - guint32 out_bytes; - - gboolean disposed; -} NMSerialDevicePrivate; - -enum { - PPP_STATS, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -/** - * nm_serial_device_get_bytes_received: - * @self: a #NMSerialDevice - * - * Gets the amount of bytes received by the serial device. - * This counter is reset when the device is activated. - * - * Returns: bytes received - **/ -guint32 -nm_serial_device_get_bytes_received (NMSerialDevice *self) -{ - g_return_val_if_fail (NM_IS_SERIAL_DEVICE (self), 0); - - return NM_SERIAL_DEVICE_GET_PRIVATE (self)->in_bytes; -} - -/** - * nm_serial_device_get_bytes_sent: - * @self: a #NMSerialDevice - * - * Gets the amount of bytes sent by the serial device. - * This counter is reset when the device is activated. - * - * Returns: bytes sent - **/ -guint32 -nm_serial_device_get_bytes_sent (NMSerialDevice *self) -{ - g_return_val_if_fail (NM_IS_SERIAL_DEVICE (self), 0); - - return NM_SERIAL_DEVICE_GET_PRIVATE (self)->out_bytes; -} - -static void -ppp_stats (DBusGProxy *proxy, - guint32 in_bytes, - guint32 out_bytes, - gpointer user_data) -{ - NMSerialDevice *self = NM_SERIAL_DEVICE (user_data); - NMSerialDevicePrivate *priv = NM_SERIAL_DEVICE_GET_PRIVATE (self); - - priv->in_bytes = in_bytes; - priv->out_bytes = out_bytes; - - g_signal_emit (self, signals[PPP_STATS], 0, in_bytes, out_bytes); -} - -static void -device_state_changed (NMDevice *device, GParamSpec *pspec, gpointer user_data) -{ - NMSerialDevicePrivate *priv; - - switch (nm_device_get_state (device)) { - case NM_DEVICE_STATE_UNMANAGED: - case NM_DEVICE_STATE_UNAVAILABLE: - case NM_DEVICE_STATE_DISCONNECTED: - priv = NM_SERIAL_DEVICE_GET_PRIVATE (device); - priv->in_bytes = priv->out_bytes = 0; - break; - default: - break; - } -} - -static void -nm_serial_device_init (NMSerialDevice *device) -{ -} - -static GObject* -constructor (GType type, - guint n_construct_params, - GObjectConstructParam *construct_params) -{ - GObject *object; - NMSerialDevicePrivate *priv; - - object = G_OBJECT_CLASS (nm_serial_device_parent_class)->constructor (type, - n_construct_params, - construct_params); - if (!object) - return NULL; - - priv = NM_SERIAL_DEVICE_GET_PRIVATE (object); - - priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), - NM_DBUS_SERVICE, - nm_object_get_path (NM_OBJECT (object)), - NM_DBUS_INTERFACE_SERIAL_DEVICE); - - dbus_g_object_register_marshaller (_nm_marshal_VOID__UINT_UINT, - G_TYPE_NONE, - G_TYPE_UINT, G_TYPE_UINT, - G_TYPE_INVALID); - - dbus_g_proxy_add_signal (priv->proxy, "PppStats", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (priv->proxy, "PppStats", - G_CALLBACK (ppp_stats), - object, - NULL); - - /* Catch NMDevice::state changes to reset the counters */ - g_signal_connect (object, "notify::state", - G_CALLBACK (device_state_changed), - object); - - return object; -} - -static void -dispose (GObject *object) -{ - NMSerialDevicePrivate *priv = NM_SERIAL_DEVICE_GET_PRIVATE (object); - - if (priv->disposed) { - G_OBJECT_CLASS (nm_serial_device_parent_class)->dispose (object); - return; - } - - priv->disposed = TRUE; - - g_object_unref (priv->proxy); - - G_OBJECT_CLASS (nm_serial_device_parent_class)->dispose (object); -} - -static void -nm_serial_device_class_init (NMSerialDeviceClass *device_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (device_class); - - g_type_class_add_private (device_class, sizeof (NMSerialDevicePrivate)); - - /* virtual methods */ - object_class->constructor = constructor; - object_class->dispose = dispose; - - /* Signals */ - - /** - * NMSerialDevice::ppp-stats: - * @device: the serial device that received the signal - * @in_bytes: the amount of bytes received - * @out_bytes: the amount of bytes sent - * - * Notifies that a #NMAccessPoint is added to the wifi device. - **/ - signals[PPP_STATS] = - g_signal_new ("ppp-stats", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSerialDeviceClass, ppp_stats), - NULL, NULL, - _nm_marshal_VOID__UINT_UINT, - G_TYPE_NONE, 2, - G_TYPE_UINT, G_TYPE_UINT); -} diff --git a/src/Makefile.am b/src/Makefile.am index 8a04d81152..94e1a8c0c1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -126,10 +126,6 @@ NetworkManager_SOURCES = \ nm-device-bt.h \ nm-device-modem.h \ nm-device-modem.c \ - nm-device-cdma.c \ - nm-device-cdma.h \ - nm-device-gsm.c \ - nm-device-gsm.h \ nm-wifi-ap.c \ nm-wifi-ap.h \ nm-wifi-ap-utils.c \ @@ -213,11 +209,8 @@ nm-dhcp4-config-glue.h: $(top_srcdir)/introspection/nm-dhcp4-config.xml nm-dhcp6-config-glue.h: $(top_srcdir)/introspection/nm-dhcp6-config.xml $(AM_V_GEN) dbus-binding-tool --prefix=nm_dhcp6_config --mode=glib-server --output=$@ $< -nm-device-cdma-glue.h: $(top_srcdir)/introspection/nm-device-cdma.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_device_cdma --mode=glib-server --output=$@ $< - -nm-device-gsm-glue.h: $(top_srcdir)/introspection/nm-device-gsm.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_device_gsm --mode=glib-server --output=$@ $< +nm-device-modem-glue.h: $(top_srcdir)/introspection/nm-device-modem.xml + $(AM_V_GEN) dbus-binding-tool --prefix=nm_device_modem --mode=glib-server --output=$@ $< BUILT_SOURCES = \ nm-access-point-glue.h \ @@ -227,8 +220,7 @@ BUILT_SOURCES = \ nm-device-wifi-glue.h \ nm-device-olpc-mesh-glue.h \ nm-device-bt-glue.h \ - nm-device-cdma-glue.h \ - nm-device-gsm-glue.h \ + nm-device-modem-glue.h \ nm-ip4-config-glue.h \ nm-ip6-config-glue.h \ nm-active-connection-glue.h \ diff --git a/src/modem-manager/Makefile.am b/src/modem-manager/Makefile.am index 22ed809fe8..db680aeaed 100644 --- a/src/modem-manager/Makefile.am +++ b/src/modem-manager/Makefile.am @@ -26,10 +26,3 @@ libmodem_manager_la_LIBADD = \ $(top_builddir)/src/logging/libnm-logging.la \ $(DBUS_LIBS) -nm-serial-device-glue.h: $(top_srcdir)/introspection/nm-device-serial.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_serial_device --mode=glib-server --output=$@ $< - -BUILT_SOURCES = \ - nm-serial-device-glue.h - -CLEANFILES = $(BUILT_SOURCES) diff --git a/src/modem-manager/nm-modem.c b/src/modem-manager/nm-modem.c index 17f78b452b..2f20f81bfb 100644 --- a/src/modem-manager/nm-modem.c +++ b/src/modem-manager/nm-modem.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 - 2011 Red Hat, Inc. * Copyright (C) 2009 Novell, Inc. */ @@ -33,8 +33,6 @@ #include "nm-device-interface.h" #include "nm-dbus-glib-types.h" -#include "nm-serial-device-glue.h" - G_DEFINE_TYPE (NMModem, nm_modem, G_TYPE_OBJECT) #define NM_MODEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_MODEM, NMModemPrivate)) @@ -1184,9 +1182,3 @@ nm_modem_class_init (NMModemClass *klass) G_TYPE_NONE, 1, G_TYPE_POINTER); } -const DBusGObjectInfo * -nm_modem_get_serial_dbus_info (void) -{ - return &dbus_glib_nm_serial_device_object_info; -} - diff --git a/src/modem-manager/nm-modem.h b/src/modem-manager/nm-modem.h index 177cde6dc9..a46a198c16 100644 --- a/src/modem-manager/nm-modem.h +++ b/src/modem-manager/nm-modem.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 - 2010 Red Hat, Inc. + * Copyright (C) 2009 - 2011 Red Hat, Inc. * Copyright (C) 2009 Novell, Inc. */ @@ -152,8 +152,6 @@ gboolean nm_modem_hw_is_up (NMModem *modem, NMDevice *device); gboolean nm_modem_hw_bring_up (NMModem *modem, NMDevice *device, gboolean *no_firmware); -const DBusGObjectInfo *nm_modem_get_serial_dbus_info (void); - gboolean nm_modem_get_mm_enabled (NMModem *self); void nm_modem_set_mm_enabled (NMModem *self, gboolean enabled); diff --git a/src/nm-device-cdma.c b/src/nm-device-cdma.c deleted file mode 100644 index 45771f4291..0000000000 --- a/src/nm-device-cdma.c +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2009 - 2010 Red Hat, Inc. - */ - -#include <string.h> - -#include "nm-modem-cdma.h" -#include "nm-device-interface.h" -#include "nm-device-cdma.h" -#include "nm-properties-changed-signal.h" -#include "nm-rfkill.h" - -#include "nm-device-cdma-glue.h" - -G_DEFINE_TYPE (NMDeviceCdma, nm_device_cdma, NM_TYPE_DEVICE_MODEM) - -enum { - PROPERTIES_CHANGED, - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL] = { 0 }; - -NMDevice * -nm_device_cdma_new (NMModemCdma *modem, const char *driver) -{ - g_return_val_if_fail (modem != NULL, NULL); - g_return_val_if_fail (NM_IS_MODEM_CDMA (modem), NULL); - g_return_val_if_fail (driver != NULL, NULL); - - return (NMDevice *) g_object_new (NM_TYPE_DEVICE_CDMA, - NM_DEVICE_INTERFACE_UDI, nm_modem_get_path (NM_MODEM (modem)), - NM_DEVICE_INTERFACE_IFACE, nm_modem_get_iface (NM_MODEM (modem)), - NM_DEVICE_INTERFACE_DRIVER, driver, - NM_DEVICE_INTERFACE_TYPE_DESC, "CDMA", - NM_DEVICE_INTERFACE_DEVICE_TYPE, NM_DEVICE_TYPE_CDMA, - NM_DEVICE_INTERFACE_RFKILL_TYPE, RFKILL_TYPE_WWAN, - NM_DEVICE_MODEM_MODEM, modem, - NULL); -} - -static void -nm_device_cdma_init (NMDeviceCdma *self) -{ -} - -static void -nm_device_cdma_class_init (NMDeviceCdmaClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - /* Signals */ - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMDeviceCdmaClass, properties_changed)); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), - &dbus_glib_nm_device_cdma_object_info); -} - diff --git a/src/nm-device-cdma.h b/src/nm-device-cdma.h deleted file mode 100644 index f0bf34567c..0000000000 --- a/src/nm-device-cdma.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2009 Red Hat, Inc. - */ - -#ifndef NM_DEVICE_CDMA_H -#define NM_DEVICE_CDMA_H - -#include "nm-device-modem.h" -#include "nm-modem-cdma.h" - -G_BEGIN_DECLS - -#define NM_TYPE_DEVICE_CDMA (nm_device_cdma_get_type ()) -#define NM_DEVICE_CDMA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_CDMA, NMDeviceCdma)) -#define NM_DEVICE_CDMA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_CDMA, NMDeviceCdmaClass)) -#define NM_IS_DEVICE_CDMA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_CDMA)) -#define NM_IS_DEVICE_CDMA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_CDMA)) -#define NM_DEVICE_CDMA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_CDMA, NMDeviceCdmaClass)) - -typedef struct { - NMDeviceModem parent; -} NMDeviceCdma; - -typedef struct { - NMDeviceModemClass parent; - - /* Signals */ - void (*signal_quality) (NMDeviceCdma *self, guint32 quality); - - void (*properties_changed) (NMDeviceCdma *self, GHashTable *properties); -} NMDeviceCdmaClass; - -GType nm_device_cdma_get_type (void); - -NMDevice *nm_device_cdma_new (NMModemCdma *modem, const char *driver); - -G_END_DECLS - -#endif /* NM_DEVICE_CDMA_H */ diff --git a/src/nm-device-gsm.c b/src/nm-device-gsm.c deleted file mode 100644 index 2a98a41f4e..0000000000 --- a/src/nm-device-gsm.c +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2009 - 2010 Red Hat, Inc. - */ - -#include <string.h> - -#include "nm-modem-gsm.h" -#include "nm-device-interface.h" -#include "nm-device-gsm.h" -#include "nm-properties-changed-signal.h" -#include "nm-rfkill.h" - -#include "nm-device-gsm-glue.h" - -G_DEFINE_TYPE (NMDeviceGsm, nm_device_gsm, NM_TYPE_DEVICE_MODEM) - -enum { - PROPERTIES_CHANGED, - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL] = { 0 }; - -NMDevice * -nm_device_gsm_new (NMModemGsm *modem, const char *driver) -{ - g_return_val_if_fail (modem != NULL, NULL); - g_return_val_if_fail (NM_IS_MODEM_GSM (modem), NULL); - g_return_val_if_fail (driver != NULL, NULL); - - return (NMDevice *) g_object_new (NM_TYPE_DEVICE_GSM, - NM_DEVICE_INTERFACE_UDI, nm_modem_get_path (NM_MODEM (modem)), - NM_DEVICE_INTERFACE_IFACE, nm_modem_get_iface (NM_MODEM (modem)), - NM_DEVICE_INTERFACE_DRIVER, driver, - NM_DEVICE_INTERFACE_TYPE_DESC, "GSM", - NM_DEVICE_INTERFACE_DEVICE_TYPE, NM_DEVICE_TYPE_GSM, - NM_DEVICE_INTERFACE_RFKILL_TYPE, RFKILL_TYPE_WWAN, - NM_DEVICE_MODEM_MODEM, modem, - NULL); -} - -static void -nm_device_gsm_init (NMDeviceGsm *self) -{ -} - -static void -nm_device_gsm_class_init (NMDeviceGsmClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - /* Signals */ - signals[PROPERTIES_CHANGED] = - nm_properties_changed_signal_new (object_class, - G_STRUCT_OFFSET (NMDeviceGsmClass, properties_changed)); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), - &dbus_glib_nm_device_gsm_object_info); -} - diff --git a/src/nm-device-gsm.h b/src/nm-device-gsm.h deleted file mode 100644 index 9b403c63a7..0000000000 --- a/src/nm-device-gsm.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2009 Red Hat, Inc. - */ - -#ifndef NM_DEVICE_GSM_H -#define NM_DEVICE_GSM_H - -#include "nm-device-modem.h" -#include "nm-modem-gsm.h" - -G_BEGIN_DECLS - -#define NM_TYPE_DEVICE_GSM (nm_device_gsm_get_type ()) -#define NM_DEVICE_GSM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_GSM, NMDeviceGsm)) -#define NM_DEVICE_GSM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_GSM, NMDeviceGsmClass)) -#define NM_IS_DEVICE_GSM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_GSM)) -#define NM_IS_DEVICE_GSM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_GSM)) -#define NM_DEVICE_GSM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_GSM, NMDeviceGsmClass)) - -typedef struct { - NMDeviceModem parent; -} NMDeviceGsm; - -typedef struct { - NMDeviceModemClass parent; - - /* Signals */ - void (*signal_quality) (NMDeviceGsm *self, guint32 quality); - - void (*properties_changed) (NMDeviceGsm *self, GHashTable *properties); -} NMDeviceGsmClass; - -GType nm_device_gsm_get_type (void); - -NMDevice *nm_device_gsm_new (NMModemGsm *modem, const char *driver); - -G_END_DECLS - -#endif /* NM_DEVICE_GSM_H */ diff --git a/src/nm-device-modem.c b/src/nm-device-modem.c index 86870244fe..ce1757e8e2 100644 --- a/src/nm-device-modem.c +++ b/src/nm-device-modem.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 - 2011 Red Hat, Inc. */ #include <glib.h> @@ -23,29 +23,38 @@ #include "nm-device-modem.h" #include "nm-device-interface.h" #include "nm-modem.h" +#include "nm-modem-cdma.h" +#include "nm-modem-gsm.h" #include "nm-device-private.h" #include "nm-properties-changed-signal.h" +#include "nm-rfkill.h" #include "nm-marshal.h" #include "nm-logging.h" static void device_interface_init (NMDeviceInterface *iface_class); -G_DEFINE_TYPE_EXTENDED (NMDeviceModem, nm_device_modem, NM_TYPE_DEVICE, G_TYPE_FLAG_ABSTRACT, +G_DEFINE_TYPE_EXTENDED (NMDeviceModem, nm_device_modem, NM_TYPE_DEVICE, 0, G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_INTERFACE, device_interface_init)) #define NM_DEVICE_MODEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_MODEM, NMDeviceModemPrivate)) +#include "nm-device-modem-glue.h" + typedef struct { NMModem *modem; + NMDeviceModemCapabilities caps; + NMDeviceModemCapabilities current_caps; } NMDeviceModemPrivate; enum { PROP_0, - PROP_MODEM + PROP_MODEM, + PROP_CAPABILITIES, + PROP_CURRENT_CAPABILITIES, }; enum { - PPP_STATS, + PROPERTIES_CHANGED, ENABLE_CHANGED, LAST_SIGNAL }; @@ -56,15 +65,6 @@ static void real_set_enabled (NMDeviceInterface *device, gboolean enabled); /*****************************************************************************/ static void -ppp_stats (NMModem *modem, - guint32 in_bytes, - guint32 out_bytes, - gpointer user_data) -{ - g_signal_emit (G_OBJECT (user_data), signals[PPP_STATS], 0, in_bytes, out_bytes); -} - -static void ppp_failed (NMModem *modem, NMDeviceStateReason reason, gpointer user_data) { NMDevice *device = NM_DEVICE (user_data); @@ -324,6 +324,40 @@ real_set_enabled (NMDeviceInterface *device, gboolean enabled) /*****************************************************************************/ +NMDevice * +nm_device_modem_new (NMModem *modem, const char *driver) +{ + NMDeviceModemCapabilities caps = NM_DEVICE_MODEM_CAPABILITY_NONE; + const char *type_desc = NULL; + + g_return_val_if_fail (modem != NULL, NULL); + g_return_val_if_fail (NM_IS_MODEM (modem), NULL); + g_return_val_if_fail (driver != NULL, NULL); + + if (NM_IS_MODEM_CDMA (modem)) { + caps = NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO; + type_desc = "CDMA/EVDO"; + } else if (NM_IS_MODEM_GSM (modem)) { + caps = NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS; + type_desc = "GSM/UMTS"; + } else { + nm_log_warn (LOGD_MB, "unhandled modem type %s", G_OBJECT_TYPE_NAME (modem)); + return NULL; + } + + return (NMDevice *) g_object_new (NM_TYPE_DEVICE_MODEM, + NM_DEVICE_INTERFACE_UDI, nm_modem_get_path (modem), + NM_DEVICE_INTERFACE_IFACE, nm_modem_get_iface (modem), + NM_DEVICE_INTERFACE_DRIVER, driver, + NM_DEVICE_INTERFACE_TYPE_DESC, type_desc, + NM_DEVICE_INTERFACE_DEVICE_TYPE, NM_DEVICE_TYPE_MODEM, + NM_DEVICE_INTERFACE_RFKILL_TYPE, RFKILL_TYPE_WWAN, + NM_DEVICE_MODEM_MODEM, modem, + NM_DEVICE_MODEM_CAPABILITIES, caps, + NM_DEVICE_MODEM_CURRENT_CAPABILITIES, caps, + NULL); +} + static void device_interface_init (NMDeviceInterface *iface_class) { @@ -346,7 +380,6 @@ set_modem (NMDeviceModem *self, NMModem *modem) priv->modem = g_object_ref (modem); - g_signal_connect (modem, NM_MODEM_PPP_STATS, G_CALLBACK (ppp_stats), self); g_signal_connect (modem, NM_MODEM_PPP_FAILED, G_CALLBACK (ppp_failed), self); g_signal_connect (modem, NM_MODEM_PREPARE_RESULT, G_CALLBACK (modem_prepare_result), self); g_signal_connect (modem, NM_MODEM_IP4_CONFIG_RESULT, G_CALLBACK (modem_ip4_config_result), self); @@ -359,11 +392,19 @@ static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object); + switch (prop_id) { case PROP_MODEM: /* construct-only */ set_modem (NM_DEVICE_MODEM (object), g_value_get_object (value)); break; + case PROP_CAPABILITIES: + priv->caps = g_value_get_uint (value); + break; + case PROP_CURRENT_CAPABILITIES: + priv->current_caps = g_value_get_uint (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -380,6 +421,12 @@ get_property (GObject *object, guint prop_id, case PROP_MODEM: g_value_set_object (value, priv->modem); break; + case PROP_CAPABILITIES: + g_value_set_uint (value, priv->caps); + break; + case PROP_CURRENT_CAPABILITIES: + g_value_set_uint (value, priv->current_caps); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -431,27 +478,34 @@ nm_device_modem_class_init (NMDeviceModemClass *mclass) NM_TYPE_MODEM, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT)); + g_object_class_install_property (object_class, PROP_CAPABILITIES, + g_param_spec_uint (NM_DEVICE_MODEM_CAPABILITIES, + "Modem Capabilities", + "Modem Capabilities", + 0, G_MAXUINT32, NM_DEVICE_MODEM_CAPABILITY_NONE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property (object_class, PROP_CURRENT_CAPABILITIES, + g_param_spec_uint (NM_DEVICE_MODEM_CURRENT_CAPABILITIES, + "Current modem Capabilities", + "Current modem Capabilities", + 0, G_MAXUINT32, NM_DEVICE_MODEM_CAPABILITY_NONE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + /* Signals */ - signals[PPP_STATS] = - g_signal_new ("ppp-stats", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMDeviceModemClass, ppp_stats), - NULL, NULL, - _nm_marshal_VOID__UINT_UINT, - G_TYPE_NONE, 2, - G_TYPE_UINT, G_TYPE_UINT); + signals[PROPERTIES_CHANGED] = + nm_properties_changed_signal_new (object_class, + G_STRUCT_OFFSET (NMDeviceModemClass, properties_changed)); signals[ENABLE_CHANGED] = g_signal_new (NM_DEVICE_MODEM_ENABLE_CHANGED, G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, + 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (mclass), - nm_modem_get_serial_dbus_info ()); + &dbus_glib_nm_device_modem_object_info); } diff --git a/src/nm-device-modem.h b/src/nm-device-modem.h index 806676e5be..8453e3d945 100644 --- a/src/nm-device-modem.h +++ b/src/nm-device-modem.h @@ -35,6 +35,8 @@ #define NM_DEVICE_MODEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_MODEM, NMDeviceModemClass)) #define NM_DEVICE_MODEM_MODEM "modem" +#define NM_DEVICE_MODEM_CAPABILITIES "modem-capabilities" +#define NM_DEVICE_MODEM_CURRENT_CAPABILITIES "current-capabilities" #define NM_DEVICE_MODEM_ENABLE_CHANGED "enable-changed" @@ -45,11 +47,13 @@ typedef struct { typedef struct { NMDeviceClass parent; - void (*ppp_stats) (NMDeviceModem *self, guint32 in_bytes, guint32 out_bytes); + void (*properties_changed) (NMDeviceModem *self, GHashTable *properties); } NMDeviceModemClass; GType nm_device_modem_get_type (void); +NMDevice *nm_device_modem_new (NMModem *modem, const char *driver); + /* Private for subclases */ NMModem *nm_device_modem_get_modem (NMDeviceModem *self); diff --git a/src/nm-manager.c b/src/nm-manager.c index f8c7bd782f..24a4a218f1 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -42,8 +42,7 @@ #if WITH_WIMAX #include "nm-device-wimax.h" #endif -#include "nm-device-cdma.h" -#include "nm-device-gsm.h" +#include "nm-device-modem.h" #include "nm-system.h" #include "nm-properties-changed-signal.h" #include "nm-setting-bluetooth.h" @@ -421,14 +420,8 @@ modem_added (NMModemManager *modem_manager, return; } - /* Otherwise make a new top-level NMDevice for it */ - if (NM_IS_MODEM_GSM (modem)) - device = nm_device_gsm_new (NM_MODEM_GSM (modem), driver); - else if (NM_IS_MODEM_CDMA (modem)) - device = nm_device_cdma_new (NM_MODEM_CDMA (modem), driver); - else - nm_log_info (LOGD_MB, "unhandled modem '%s'", ip_iface); - + /* Make the new modem device */ + device = nm_device_modem_new (modem, driver); if (device) add_device (self, device); } diff --git a/test/nm-tool.c b/test/nm-tool.c index 5286aca734..4c3b0f4297 100644 --- a/test/nm-tool.c +++ b/test/nm-tool.c @@ -37,8 +37,7 @@ #include <nm-device.h> #include <nm-device-ethernet.h> #include <nm-device-wifi.h> -#include <nm-gsm-device.h> -#include <nm-cdma-device.h> +#include <nm-device-modem.h> #include <nm-device-bt.h> #if WITH_WIMAX #include <nm-device-wimax.h> @@ -372,11 +371,17 @@ detail_device (gpointer data, gpointer user_data) print_string ("Type", "Wired"); else if (NM_IS_DEVICE_WIFI (device)) print_string ("Type", "802.11 WiFi"); - else if (NM_IS_GSM_DEVICE (device)) - print_string ("Type", "Mobile Broadband (GSM)"); - else if (NM_IS_CDMA_DEVICE (device)) - print_string ("Type", "Mobile Broadband (CDMA)"); - else if (NM_IS_DEVICE_BT (device)) + else if (NM_IS_DEVICE_MODEM (device)) { + NMDeviceModemCapabilities modem_caps; + + modem_caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)); + if (modem_caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) + print_string ("Type", "Mobile Broadband (GSM)"); + else if (modem_caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) + print_string ("Type", "Mobile Broadband (CDMA)"); + else + print_string ("Type", "Mobile Broadband (unknown)"); + } else if (NM_IS_DEVICE_BT (device)) print_string ("Type", "Bluetooth"); #if WITH_WIMAX else if (NM_IS_DEVICE_WIMAX (device)) |