diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-01-09 21:07:10 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-15 14:14:48 +0100 |
commit | a71393f227da1d4aa2ca1b237ec9c5061c25434f (patch) | |
tree | 430d6421ecfddbeccca3ad360f89a4471136a169 /libmm-glib | |
parent | 713937f1f0b317ca3d911274a3600baa64835979 (diff) |
libmm-glib: handle the CDMA interface
Diffstat (limited to 'libmm-glib')
-rw-r--r-- | libmm-glib/Makefile.am | 2 | ||||
-rw-r--r-- | libmm-glib/mm-modem-cdma.c | 212 | ||||
-rw-r--r-- | libmm-glib/mm-modem-cdma.h | 53 | ||||
-rw-r--r-- | libmm-glib/mm-object.c | 16 | ||||
-rw-r--r-- | libmm-glib/mm-object.h | 3 |
5 files changed, 286 insertions, 0 deletions
diff --git a/libmm-glib/Makefile.am b/libmm-glib/Makefile.am index 43039af3..f11240aa 100644 --- a/libmm-glib/Makefile.am +++ b/libmm-glib/Makefile.am @@ -20,6 +20,8 @@ libmm_glib_la_SOURCES = \ mm-modem.c \ mm-modem-3gpp.h \ mm-modem-3gpp.c \ + mm-modem-cdma.h \ + mm-modem-cdma.c \ mm-modem-simple-connect-properties.h \ mm-modem-simple-connect-properties.c \ mm-modem-simple-status-properties.h \ diff --git a/libmm-glib/mm-modem-cdma.c b/libmm-glib/mm-modem-cdma.c new file mode 100644 index 00000000..f4fcc94f --- /dev/null +++ b/libmm-glib/mm-modem-cdma.c @@ -0,0 +1,212 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem 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 Aleksander Morgado <aleksander@gnu.org> + */ + +#include <gio/gio.h> + +#include "mm-helpers.h" +#include "mm-modem-cdma.h" + +/** + * mm_modem_cdma_get_path: + * @self: A #MMModemCdma. + * + * Gets the DBus path of the #MMObject which implements this interface. + * + * Returns: (transfer none): The DBus path of the #MMObject object. + */ +const gchar * +mm_modem_cdma_get_path (MMModemCdma *self) +{ + g_return_val_if_fail (G_IS_DBUS_PROXY (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + g_dbus_proxy_get_object_path (G_DBUS_PROXY (self))); +} + +/** + * mm_modem_cdma_dup_path: + * @self: A #MMModemCdma. + * + * Gets a copy of the DBus path of the #MMObject object which implements this interface. + * + * Returns: (transfer full): The DBus path of the #MMObject. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_cdma_dup_path (MMModemCdma *self) +{ + gchar *value; + + g_return_val_if_fail (G_IS_DBUS_PROXY (self), NULL); + + g_object_get (G_OBJECT (self), + "g-object-path", &value, + NULL); + RETURN_NON_EMPTY_STRING (value); +} + +/** + * mm_modem_cdma_get_meid: + * @self: A #MMModemCdma. + * + * Gets the <ulink url="http://en.wikipedia.org/wiki/MEID">Mobile Equipment Identifier</ulink>, + * as reported by this #MMModem. + * + * <warning>It is only safe to use this function on the thread where @self was constructed. Use mm_modem_cdma_dup_meid() if on another thread.</warning> + * + * Returns: (transfer none): The MEID, or %NULL if none available. + */ +const gchar * +mm_modem_cdma_get_meid (MMModemCdma *self) +{ + g_return_val_if_fail (MM_GDBUS_IS_MODEM_CDMA (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_modem_cdma_get_meid (self)); +} + +/** + * mm_modem_cdma_dup_meid: + * @self: A #MMModemCdma. + * + * Gets a copy of the <ulink url="http://en.wikipedia.org/wiki/MEID">Mobile Equipment Identifier</ulink>, + * as reported by this #MMModem. + * + * Returns: (transfer full): The MEID, or %NULL if none available. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_cdma_dup_meid (MMModemCdma *self) +{ + g_return_val_if_fail (MM_GDBUS_IS_MODEM_CDMA (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem_cdma_dup_meid (self)); +} + +/** + * mm_modem_cdma_get_esn: + * @self: A #MMModemCdma. + * + * Gets the <ulink url="http://en.wikipedia.org/wiki/Electronic_serial_number">Electronic Serial Number</ulink>, + * as reported by this #MMModem. + * + * The ESN is superceded by MEID, but still used in older devices. + * + * <warning>It is only safe to use this function on the thread where @self was constructed. Use mm_modem_cdma_dup_esn() if on another thread.</warning> + * + * Returns: (transfer none): The ESN, or %NULL if none available. + */ +const gchar * +mm_modem_cdma_get_esn (MMModemCdma *self) +{ + g_return_val_if_fail (MM_GDBUS_IS_MODEM_CDMA (self), NULL); + + RETURN_NON_EMPTY_CONSTANT_STRING ( + mm_gdbus_modem_cdma_get_esn (self)); +} + +/** + * mm_modem_cdma_dup_esn: + * @self: A #MMModemCdma. + * + * Gets a copy of the <ulink url="http://en.wikipedia.org/wiki/Electronic_serial_number">Electronic Serial Number</ulink>, + * as reported by this #MMModem. + * + * The ESN is superceded by MEID, but still used in older devices. + * + * Returns: (transfer full): The ESN, or %NULL if none available. The returned value should be freed with g_free(). + */ +gchar * +mm_modem_cdma_dup_esn (MMModemCdma *self) +{ + g_return_val_if_fail (MM_GDBUS_IS_MODEM_CDMA (self), NULL); + + RETURN_NON_EMPTY_STRING ( + mm_gdbus_modem_cdma_dup_esn (self)); +} + +/** + * mm_modem_cdma_get_sid: + * @self: A #MMModemCdma. + * + * Gets the <ulink url="http://en.wikipedia.org/wiki/System_Identification_Number">System Identifier</ulink> + * of the serving CDMA 1x network, if known, and if the modem is registered with + * a CDMA 1x network. + * + * Returns: The SID, or %MM_MODEM_CDMA_SID_UNKNOWN. + */ +guint +mm_modem_cdma_get_sid (MMModemCdma *self) +{ + g_return_val_if_fail (MM_GDBUS_IS_MODEM_CDMA (self), MM_MODEM_CDMA_SID_UNKNOWN); + + return mm_gdbus_modem_cdma_get_sid (self); +} + +/** + * mm_modem_cdma_get_nid: + * @self: A #MMModemCdma. + * + * Gets the <ulink url="http://en.wikipedia.org/wiki/Network_Identification_Number">Network Identifier</ulink> + * of the serving CDMA 1x network, if known, and if the modem is registered with + * a CDMA 1x network. + * + * Returns: The NID, or %MM_MODEM_CDMA_NID_UNKNOWN. + */ +guint +mm_modem_cdma_get_nid (MMModemCdma *self) +{ + g_return_val_if_fail (MM_GDBUS_IS_MODEM_CDMA (self), MM_MODEM_CDMA_NID_UNKNOWN); + + return mm_gdbus_modem_cdma_get_nid (self); +} + +/** + * mm_modem_cdma_get_cdma1x_registration_state: + * @self: A #MMModemCdma. + * + * Gets the state of the registration in the CDMA 1x network. + * + * Returns: a #MMModemCdmaRegistrationState. + */ +MMModemCdmaRegistrationState +mm_modem_cdma_get_cdma1x_registration_state (MMModemCdma *self) +{ + g_return_val_if_fail (MM_GDBUS_IS_MODEM_CDMA (self), MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN); + + return mm_gdbus_modem_cdma_get_cdma1x_registration_state (self); +} + +/** + * mm_modem_cdma_get_evdo_registration_state: + * @self: A #MMModemCdma. + * + * Gets the state of the registration in the EV-DO network. + * + * Returns: a #MMModemCdmaRegistrationState. + */ +MMModemCdmaRegistrationState +mm_modem_cdma_get_evdo_registration_state (MMModemCdma *self) +{ + g_return_val_if_fail (MM_GDBUS_IS_MODEM_CDMA (self), MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN); + + return mm_gdbus_modem_cdma_get_evdo_registration_state (self); +} diff --git a/libmm-glib/mm-modem-cdma.h b/libmm-glib/mm-modem-cdma.h new file mode 100644 index 00000000..279d4c58 --- /dev/null +++ b/libmm-glib/mm-modem-cdma.h @@ -0,0 +1,53 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libmm -- Access modem 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 Aleksander Morgado <aleksander@gnu.org> + */ + +#ifndef _MM_MODEM_CDMA_H_ +#define _MM_MODEM_CDMA_H_ + +#include <ModemManager.h> +#include <mm-gdbus-modem.h> + +G_BEGIN_DECLS + +#define MM_MODEM_CDMA_SID_UNKNOWN 99999 +#define MM_MODEM_CDMA_NID_UNKNOWN 99999 + +typedef MmGdbusModemCdma MMModemCdma; +#define MM_TYPE_MODEM_CDMA(o) MM_GDBUS_TYPE_MODEM_CDMA (o) +#define MM_MODEM_CDMA(o) MM_GDBUS_MODEM_CDMA(o) +#define MM_IS_MODEM_CDMA(o) MM_GDBUS_IS_MODEM_CDMA(o) + +const gchar *mm_modem_cdma_get_path (MMModemCdma *self); +gchar *mm_modem_cdma_dup_path (MMModemCdma *self); + +const gchar *mm_modem_cdma_get_meid (MMModemCdma *self); +gchar *mm_modem_cdma_dup_meid (MMModemCdma *self); +const gchar *mm_modem_cdma_get_esn (MMModemCdma *self); +gchar *mm_modem_cdma_dup_esn (MMModemCdma *self); +guint mm_modem_cdma_get_sid (MMModemCdma *self); +guint mm_modem_cdma_get_nid (MMModemCdma *self); +MMModemCdmaRegistrationState mm_modem_cdma_get_cdma1x_registration_state (MMModemCdma *self); +MMModemCdmaRegistrationState mm_modem_cdma_get_evdo_registration_state (MMModemCdma *self); + +G_END_DECLS + +#endif /* _MM_MODEM_CDMA_H_ */ diff --git a/libmm-glib/mm-object.c b/libmm-glib/mm-object.c index 7217fef4..ea924370 100644 --- a/libmm-glib/mm-object.c +++ b/libmm-glib/mm-object.c @@ -93,6 +93,22 @@ mm_object_get_modem_3gpp (MMObject *object) } /** + * mm_object_get_modem_cdma: + * @object: A #MMObject. + * + * Gets the #MMModemCdma instance for the D-Bus interface <link linkend="gdbus-interface-org-freedesktop-ModemManager1-Modem-ModemCdma.top_of_page">org.freedesktop.ModemManager1.Modem.ModemCdma</link> on @object, if any. + * + * Returns: (transfer full): A #MMModemCdma that must be freed with g_object_unref() or %NULL if @object does not implement the interface. + */ +MMModemCdma * +mm_object_get_modem_cdma (MMObject *object) +{ + g_return_val_if_fail (MM_GDBUS_IS_OBJECT (object), NULL); + + return mm_gdbus_object_get_modem_cdma (object); +} + +/** * mm_object_get_modem_simple: * @object: A #MMObject. * diff --git a/libmm-glib/mm-object.h b/libmm-glib/mm-object.h index d83c7ac2..54796455 100644 --- a/libmm-glib/mm-object.h +++ b/libmm-glib/mm-object.h @@ -28,6 +28,7 @@ #include "mm-modem.h" #include "mm-modem-3gpp.h" +#include "mm-modem-cdma.h" #include "mm-modem-simple.h" G_BEGIN_DECLS @@ -42,10 +43,12 @@ gchar *mm_object_dup_path (MMObject *self); MMModem *mm_object_get_modem (MMObject *object); MMModem3gpp *mm_object_get_modem_3gpp (MMObject *object); +MMModemCdma *mm_object_get_modem_cdma (MMObject *object); MMModemSimple *mm_object_get_modem_simple (MMObject *object); MMModem *mm_object_peek_modem (MMObject *object); MMModem3gpp *mm_object_peek_modem_3gpp (MMObject *object); +MMModemCdma *mm_object_peek_modem_cdma (MMObject *object); MMModemSimple *mm_object_peek_modem_simple (MMObject *object); G_END_DECLS |