diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-10-19 00:58:36 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-10-19 00:58:36 +0200 |
commit | 79fdddccbfccd50f2c4d98d90fc707061c39d1f5 (patch) | |
tree | 49e2eb7f44cf05b8d869ceeeebe0164c9a512ee8 | |
parent | e123c7d5b43cd4fb63d7f1fbdb44fbb641e410ac (diff) |
api,modem: new 'PrimaryPort' property
We do need to specify which is the primary port being used for controlling the
modem. This allows us to match the device with an already existing bluetooth
device in NetworkManager.
-rw-r--r-- | cli/mmcli-modem.c | 6 | ||||
-rw-r--r-- | docs/reference/libmm-glib/libmm-glib-sections.txt | 5 | ||||
-rw-r--r-- | introspection/org.freedesktop.ModemManager1.Modem.xml | 7 | ||||
-rw-r--r-- | libmm-glib/mm-modem.c | 41 | ||||
-rw-r--r-- | libmm-glib/mm-modem.h | 3 | ||||
-rw-r--r-- | src/mm-iface-modem.c | 15 |
6 files changed, 75 insertions, 2 deletions
diff --git a/cli/mmcli-modem.c b/cli/mmcli-modem.c index 981421b6..154414b9 100644 --- a/cli/mmcli-modem.c +++ b/cli/mmcli-modem.c @@ -323,10 +323,12 @@ print_modem_info (void) g_print (" -------------------------\n" " System | device: '%s'\n" " | drivers: '%s'\n" - " | plugin: '%s'\n", + " | plugin: '%s'\n" + " | primary port: '%s'\n", VALIDATE_UNKNOWN (mm_modem_get_device (ctx->modem)), VALIDATE_UNKNOWN (drivers_string), - VALIDATE_UNKNOWN (mm_modem_get_plugin (ctx->modem))); + VALIDATE_UNKNOWN (mm_modem_get_plugin (ctx->modem)), + VALIDATE_UNKNOWN (mm_modem_get_primary_port (ctx->modem))); /* Numbers related stuff */ g_print (" -------------------------\n" diff --git a/docs/reference/libmm-glib/libmm-glib-sections.txt b/docs/reference/libmm-glib/libmm-glib-sections.txt index 181d6604..f37e7a3d 100644 --- a/docs/reference/libmm-glib/libmm-glib-sections.txt +++ b/docs/reference/libmm-glib/libmm-glib-sections.txt @@ -89,6 +89,8 @@ mm_modem_get_drivers mm_modem_dup_drivers mm_modem_get_plugin mm_modem_dup_plugin +mm_modem_get_primary_port +mm_modem_dup_primary_port mm_modem_get_device mm_modem_dup_device mm_modem_get_equipment_identifier @@ -1389,6 +1391,8 @@ mm_gdbus_modem_get_own_numbers mm_gdbus_modem_dup_own_numbers mm_gdbus_modem_get_plugin mm_gdbus_modem_dup_plugin +mm_gdbus_modem_get_primary_port +mm_gdbus_modem_dup_primary_port mm_gdbus_modem_get_preferred_mode mm_gdbus_modem_get_revision mm_gdbus_modem_dup_revision @@ -1447,6 +1451,7 @@ mm_gdbus_modem_set_model mm_gdbus_modem_set_modem_capabilities mm_gdbus_modem_set_own_numbers mm_gdbus_modem_set_plugin +mm_gdbus_modem_set_primary_port mm_gdbus_modem_set_preferred_mode mm_gdbus_modem_set_revision mm_gdbus_modem_set_signal_quality diff --git a/introspection/org.freedesktop.ModemManager1.Modem.xml b/introspection/org.freedesktop.ModemManager1.Modem.xml index 06c4116b..9a1a5126 100644 --- a/introspection/org.freedesktop.ModemManager1.Modem.xml +++ b/introspection/org.freedesktop.ModemManager1.Modem.xml @@ -297,6 +297,13 @@ <property name="Plugin" type="s" access="read" /> <!-- + PrimaryPort: + + The name of the primary port using to control the modem. + --> + <property name="PrimaryPort" type="s" access="read" /> + + <!-- EquipmentIdentifier: The identity of the device. diff --git a/libmm-glib/mm-modem.c b/libmm-glib/mm-modem.c index 6b9357a0..b575a300 100644 --- a/libmm-glib/mm-modem.c +++ b/libmm-glib/mm-modem.c @@ -538,6 +538,47 @@ mm_modem_dup_plugin (MMModem *self) /*****************************************************************************/ /** + * mm_modem_get_primary_port: + * @self: A #MMModem. + * + * Gets the name of the primary port controlling this #MMModem. + * + * <warning>The returned value is only valid until the property changes so + * it is only safe to use this function on the thread where + * @self was constructed. Use mm_modem_dup_primary_port() if on another + * thread.</warning> + * + * Returns: (transfer none): The name of the primary port. Do not free the returned value, it belongs to @self. + */ +const gchar * +mm_modem_get_primary_port (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_modem_get_primary_port (MM_GDBUS_MODEM (self))); +} + +/** + * mm_modem_dup_primary_port: + * @self: A #MMModem. + * + * Gets a copy of the name of the primary port controlling this #MMModem. + * + * Returns: (transfer full): The name of the primary port. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_dup_primary_port (MMModem *self) +{ + g_return_val_if_fail (MM_IS_MODEM (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem_dup_primary_port (MM_GDBUS_MODEM (self))); +} + +/*****************************************************************************/ + +/** * mm_modem_get_equipment_identifier: * @self: A #MMModem. * diff --git a/libmm-glib/mm-modem.h b/libmm-glib/mm-modem.h index 480c3fe4..46609ca4 100644 --- a/libmm-glib/mm-modem.h +++ b/libmm-glib/mm-modem.h @@ -102,6 +102,9 @@ gchar **mm_modem_dup_drivers (MMModem *self); const gchar *mm_modem_get_plugin (MMModem *self); gchar *mm_modem_dup_plugin (MMModem *self); +const gchar *mm_modem_get_primary_port (MMModem *self); +gchar *mm_modem_dup_primary_port (MMModem *self); + const gchar *mm_modem_get_equipment_identifier (MMModem *self); gchar *mm_modem_dup_equipment_identifier (MMModem *self); diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index 4222dda6..68b6ba55 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -3328,6 +3328,21 @@ interface_initialization_step (InitializationContext *ctx) mm_gdbus_modem_set_plugin (ctx->skeleton, plugin); g_free (plugin); } + /* Load primary port if not done before */ + if (!mm_gdbus_modem_get_primary_port (ctx->skeleton)) { + MMPort *primary; + +#if defined WITH_QMI + primary = MM_PORT (mm_base_modem_peek_port_qmi (MM_BASE_MODEM (ctx->self))); + if (!primary) + primary = MM_PORT (mm_base_modem_peek_port_primary (MM_BASE_MODEM (ctx->self))); +#else + primary = MM_PORT (mm_base_modem_peek_port_primary (MM_BASE_MODEM (ctx->self))); +#endif + + g_assert (primary != NULL); + mm_gdbus_modem_set_primary_port (ctx->skeleton, mm_port_get_device (primary)); + } /* Fall down to next step */ ctx->step++; |