cdma: implement GetEsn()
This commit is contained in:
@@ -16,6 +16,19 @@
|
||||
</arg>
|
||||
</method>
|
||||
|
||||
<method name="GetEsn">
|
||||
<tp:docstring>
|
||||
Get the Electronic Serial Number of the card.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_modem_cdma_get_esn"/>
|
||||
<arg name="esn" type="s" direction="out">
|
||||
<tp:docstring>
|
||||
The ESN.
|
||||
</tp:docstring>
|
||||
</arg>
|
||||
</method>
|
||||
|
||||
<signal name="SignalQuality">
|
||||
<tp:docstring>
|
||||
The signal quality changed.
|
||||
|
||||
+49
-15
@@ -42,6 +42,20 @@ mm_generic_cdma_new (const char *device,
|
||||
NULL));
|
||||
}
|
||||
|
||||
static const char *
|
||||
strip_response (const char *resp, const char *cmd)
|
||||
{
|
||||
const char *p = resp;
|
||||
|
||||
if (p) {
|
||||
if (!strncmp (p, cmd, strlen (cmd)))
|
||||
p += strlen (cmd);
|
||||
while (*p == ' ')
|
||||
p++;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
@@ -260,18 +274,6 @@ card_info_invoke (MMCallbackInfo *info)
|
||||
info->error, info->user_data);
|
||||
}
|
||||
|
||||
static const char *
|
||||
strip_info_response (const char *resp, const char *cmd)
|
||||
{
|
||||
const char *p = resp;
|
||||
|
||||
if (p) {
|
||||
if (!strncmp (p, cmd, strlen (cmd)))
|
||||
p += strlen (cmd);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
static void
|
||||
get_version_done (MMSerialPort *port,
|
||||
GString *response,
|
||||
@@ -282,7 +284,7 @@ get_version_done (MMSerialPort *port,
|
||||
const char *p;
|
||||
|
||||
if (!error) {
|
||||
p = strip_info_response (response->str, "+GMR:");
|
||||
p = strip_response (response->str, "+GMR:");
|
||||
mm_callback_info_set_data (info, "card-info-version", g_strdup (p), g_free);
|
||||
} else if (!info->error)
|
||||
info->error = g_error_copy (error);
|
||||
@@ -300,7 +302,7 @@ get_model_done (MMSerialPort *port,
|
||||
const char *p;
|
||||
|
||||
if (!error) {
|
||||
p = strip_info_response (response->str, "+GMM:");
|
||||
p = strip_response (response->str, "+GMM:");
|
||||
mm_callback_info_set_data (info, "card-info-model", g_strdup (p), g_free);
|
||||
} else if (!info->error)
|
||||
info->error = g_error_copy (error);
|
||||
@@ -316,7 +318,7 @@ get_manufacturer_done (MMSerialPort *port,
|
||||
const char *p;
|
||||
|
||||
if (!error) {
|
||||
p = strip_info_response (response->str, "+GMI:");
|
||||
p = strip_response (response->str, "+GMI:");
|
||||
mm_callback_info_set_data (info, "card-info-manufacturer", g_strdup (p), g_free);
|
||||
} else
|
||||
info->error = g_error_copy (error);
|
||||
@@ -391,6 +393,37 @@ get_signal_quality (MMModemCdma *modem,
|
||||
get_signal_quality_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
get_string_done (MMSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
|
||||
const char *p;
|
||||
|
||||
if (error)
|
||||
info->error = g_error_copy (error);
|
||||
else {
|
||||
p = strip_response (response->str, "+GSN:");
|
||||
mm_callback_info_set_result (info, g_strdup (p), g_free);
|
||||
}
|
||||
|
||||
mm_callback_info_schedule (info);
|
||||
}
|
||||
|
||||
static void
|
||||
get_esn (MMModemCdma *modem,
|
||||
MMModemStringFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMGenericCdmaPrivate *priv = MM_GENERIC_CDMA_GET_PRIVATE (modem);
|
||||
MMCallbackInfo *info;
|
||||
|
||||
info = mm_callback_info_string_new (MM_MODEM (modem), callback, user_data);
|
||||
mm_serial_port_queue_command_cached (priv->primary, "+GSN", 3, get_string_done, info);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* MMModemSimple interface */
|
||||
|
||||
@@ -557,6 +590,7 @@ static void
|
||||
modem_cdma_init (MMModemCdma *cdma_modem_class)
|
||||
{
|
||||
cdma_modem_class->get_signal_quality = get_signal_quality;
|
||||
cdma_modem_class->get_esn = get_esn;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "mm-callback-info.h"
|
||||
|
||||
static void impl_modem_cdma_get_signal_quality (MMModemCdma *modem, DBusGMethodInvocation *context);
|
||||
static void impl_modem_cdma_get_esn (MMModemCdma *modem, DBusGMethodInvocation *context);
|
||||
|
||||
#include "mm-modem-cdma-glue.h"
|
||||
|
||||
@@ -18,6 +19,32 @@ enum {
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
|
||||
static void
|
||||
str_call_done (MMModem *modem, const char *result, GError *error, gpointer user_data)
|
||||
{
|
||||
DBusGMethodInvocation *context = (DBusGMethodInvocation *) user_data;
|
||||
|
||||
if (error)
|
||||
dbus_g_method_return_error (context, error);
|
||||
else
|
||||
dbus_g_method_return (context, result);
|
||||
}
|
||||
|
||||
static void
|
||||
str_call_not_supported (MMModemCdma *self,
|
||||
MMModemStringFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
|
||||
info = mm_callback_info_string_new (MM_MODEM (self), callback, user_data);
|
||||
info->error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_OPERATION_NOT_SUPPORTED,
|
||||
"Operation not supported");
|
||||
|
||||
mm_callback_info_schedule (info);
|
||||
}
|
||||
|
||||
static void
|
||||
uint_op_not_supported (MMModem *self,
|
||||
MMModemUIntFn callback,
|
||||
@@ -42,6 +69,27 @@ uint_call_done (MMModem *modem, guint32 result, GError *error, gpointer user_dat
|
||||
dbus_g_method_return (context, result);
|
||||
}
|
||||
|
||||
void
|
||||
mm_modem_cdma_get_esn (MMModemCdma *self,
|
||||
MMModemStringFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (MM_IS_MODEM_CDMA (self));
|
||||
g_return_if_fail (callback != NULL);
|
||||
|
||||
if (MM_MODEM_CDMA_GET_INTERFACE (self)->get_esn)
|
||||
MM_MODEM_CDMA_GET_INTERFACE (self)->get_esn (self, callback, user_data);
|
||||
else
|
||||
str_call_not_supported (self, callback, user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
impl_modem_cdma_get_esn (MMModemCdma *modem,
|
||||
DBusGMethodInvocation *context)
|
||||
{
|
||||
mm_modem_cdma_get_esn (modem, str_call_done, context);
|
||||
}
|
||||
|
||||
void
|
||||
mm_modem_cdma_get_signal_quality (MMModemCdma *self,
|
||||
MMModemUIntFn callback,
|
||||
|
||||
@@ -20,6 +20,10 @@ struct _MMModemCdma {
|
||||
MMModemUIntFn callback,
|
||||
gpointer user_data);
|
||||
|
||||
void (*get_esn) (MMModemCdma *self,
|
||||
MMModemStringFn callback,
|
||||
gpointer user_data);
|
||||
|
||||
/* Signals */
|
||||
void (*signal_quality) (MMModemCdma *self,
|
||||
guint32 quality);
|
||||
@@ -31,6 +35,10 @@ void mm_modem_cdma_get_signal_quality (MMModemCdma *self,
|
||||
MMModemUIntFn callback,
|
||||
gpointer user_data);
|
||||
|
||||
void mm_modem_cdma_get_esn (MMModemCdma *self,
|
||||
MMModemStringFn callback,
|
||||
gpointer user_data);
|
||||
|
||||
/* Protected */
|
||||
|
||||
void mm_modem_cdma_signal_quality (MMModemCdma *self,
|
||||
|
||||
@@ -8,10 +8,16 @@ MM_DBUS_SERVICE='org.freedesktop.ModemManager'
|
||||
MM_DBUS_PATH='/org/freedesktop/ModemManager'
|
||||
MM_DBUS_INTERFACE='org.freedesktop.ModemManager'
|
||||
MM_DBUS_INTERFACE_MODEM='org.freedesktop.ModemManager.Modem'
|
||||
MM_DBUS_INTERFACE_MODEM_CDMA='org.freedesktop.ModemManager.Modem.Cdma'
|
||||
MM_DBUS_INTERFACE_MODEM_GSM_CARD='org.freedesktop.ModemManager.Modem.Gsm.Card'
|
||||
MM_DBUS_INTERFACE_MODEM_GSM_NETWORK='org.freedesktop.ModemManager.Modem.Gsm.Network'
|
||||
|
||||
def inspect_cdma(proxy):
|
||||
cdma = dbus.Interface(proxy, dbus_interface=MM_DBUS_INTERFACE_MODEM_CDMA)
|
||||
try:
|
||||
print "ESN: %s" % cdma.GetEsn()
|
||||
except dbus.exceptions.DBusException:
|
||||
pass
|
||||
return
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user