aboutsummaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2014-02-05 08:40:16 +0100
committerGuido Günther <agx@sigxcpu.org>2014-02-05 08:40:16 +0100
commitfa2b467e288cb137ffd792becbf0c1e757d85be4 (patch)
treece308eb0886e93805e7d88bccce48c93797fd6dd /cli
parentafc4b839a31c530d73b91aa2483795f185eb7e52 (diff)
New upstream version 1.2.0upstream/1.2.0upstream
Diffstat (limited to 'cli')
-rw-r--r--cli/Makefile.am2
-rw-r--r--cli/Makefile.in63
-rw-r--r--cli/mmcli-common.c6
-rw-r--r--cli/mmcli-modem-3gpp.c2
-rw-r--r--cli/mmcli-modem-cdma.c130
-rw-r--r--cli/mmcli-modem-messaging.c57
-rw-r--r--cli/mmcli-modem-oma.c521
-rw-r--r--cli/mmcli-modem-signal.c324
-rw-r--r--cli/mmcli-modem-simple.c15
-rw-r--r--cli/mmcli-modem.c77
-rw-r--r--cli/mmcli-sms.c44
-rw-r--r--cli/mmcli.c22
-rw-r--r--cli/mmcli.h16
13 files changed, 1233 insertions, 46 deletions
diff --git a/cli/Makefile.am b/cli/Makefile.am
index 12126ec..1bb2a8d 100644
--- a/cli/Makefile.am
+++ b/cli/Makefile.am
@@ -23,6 +23,8 @@ mmcli_SOURCES = \
mmcli-modem-messaging.c \
mmcli-modem-time.c \
mmcli-modem-firmware.c \
+ mmcli-modem-signal.c \
+ mmcli-modem-oma.c \
mmcli-bearer.c \
mmcli-sim.c \
mmcli-sms.c
diff --git a/cli/Makefile.in b/cli/Makefile.in
index 23ba8ee..2c3caa4 100644
--- a/cli/Makefile.in
+++ b/cli/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.13.4 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
@@ -86,12 +86,13 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \
$(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/gtk-doc.m4 \
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \
- $(top_srcdir)/m4/intltool.m4 $(top_srcdir)/m4/lib-ld.m4 \
- $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
- $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+ $(top_srcdir)/m4/intltool.m4 $(top_srcdir)/m4/introspection.m4 \
+ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
+ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \
+ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/vapigen.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
@@ -110,8 +111,9 @@ am_mmcli_OBJECTS = mmcli-mmcli.$(OBJEXT) mmcli-mmcli-common.$(OBJEXT) \
mmcli-mmcli-modem-messaging.$(OBJEXT) \
mmcli-mmcli-modem-time.$(OBJEXT) \
mmcli-mmcli-modem-firmware.$(OBJEXT) \
- mmcli-mmcli-bearer.$(OBJEXT) mmcli-mmcli-sim.$(OBJEXT) \
- mmcli-mmcli-sms.$(OBJEXT)
+ mmcli-mmcli-modem-signal.$(OBJEXT) \
+ mmcli-mmcli-modem-oma.$(OBJEXT) mmcli-mmcli-bearer.$(OBJEXT) \
+ mmcli-mmcli-sim.$(OBJEXT) mmcli-mmcli-sms.$(OBJEXT)
mmcli_OBJECTS = $(am_mmcli_OBJECTS)
am__DEPENDENCIES_1 =
mmcli_DEPENDENCIES = $(am__DEPENDENCIES_1) \
@@ -239,6 +241,14 @@ INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@
INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@
INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@
+INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@
+INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@
+INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@
+INTROSPECTION_LIBS = @INTROSPECTION_LIBS@
+INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@
+INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@
+INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBICONV = @LIBICONV@
@@ -305,6 +315,9 @@ STRIP = @STRIP@
SYSTEMD_UNIT_DIR = @SYSTEMD_UNIT_DIR@
UDEV_BASE_DIR = @UDEV_BASE_DIR@
USE_NLS = @USE_NLS@
+VAPIGEN = @VAPIGEN@
+VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@
+VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@
VERSION = @VERSION@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
@@ -386,6 +399,8 @@ mmcli_SOURCES = \
mmcli-modem-messaging.c \
mmcli-modem-time.c \
mmcli-modem-firmware.c \
+ mmcli-modem-signal.c \
+ mmcli-modem-oma.c \
mmcli-bearer.c \
mmcli-sim.c \
mmcli-sms.c
@@ -496,6 +511,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmcli-mmcli-modem-firmware.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmcli-mmcli-modem-location.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmcli-mmcli-modem-messaging.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmcli-mmcli-modem-oma.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmcli-mmcli-modem-signal.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmcli-mmcli-modem-simple.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmcli-mmcli-modem-time.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmcli-mmcli-modem.Po@am__quote@
@@ -681,6 +698,34 @@ mmcli-mmcli-modem-firmware.obj: mmcli-modem-firmware.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmcli_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmcli-mmcli-modem-firmware.obj `if test -f 'mmcli-modem-firmware.c'; then $(CYGPATH_W) 'mmcli-modem-firmware.c'; else $(CYGPATH_W) '$(srcdir)/mmcli-modem-firmware.c'; fi`
+mmcli-mmcli-modem-signal.o: mmcli-modem-signal.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmcli_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mmcli-mmcli-modem-signal.o -MD -MP -MF $(DEPDIR)/mmcli-mmcli-modem-signal.Tpo -c -o mmcli-mmcli-modem-signal.o `test -f 'mmcli-modem-signal.c' || echo '$(srcdir)/'`mmcli-modem-signal.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mmcli-mmcli-modem-signal.Tpo $(DEPDIR)/mmcli-mmcli-modem-signal.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mmcli-modem-signal.c' object='mmcli-mmcli-modem-signal.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmcli_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmcli-mmcli-modem-signal.o `test -f 'mmcli-modem-signal.c' || echo '$(srcdir)/'`mmcli-modem-signal.c
+
+mmcli-mmcli-modem-signal.obj: mmcli-modem-signal.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmcli_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mmcli-mmcli-modem-signal.obj -MD -MP -MF $(DEPDIR)/mmcli-mmcli-modem-signal.Tpo -c -o mmcli-mmcli-modem-signal.obj `if test -f 'mmcli-modem-signal.c'; then $(CYGPATH_W) 'mmcli-modem-signal.c'; else $(CYGPATH_W) '$(srcdir)/mmcli-modem-signal.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mmcli-mmcli-modem-signal.Tpo $(DEPDIR)/mmcli-mmcli-modem-signal.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mmcli-modem-signal.c' object='mmcli-mmcli-modem-signal.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmcli_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmcli-mmcli-modem-signal.obj `if test -f 'mmcli-modem-signal.c'; then $(CYGPATH_W) 'mmcli-modem-signal.c'; else $(CYGPATH_W) '$(srcdir)/mmcli-modem-signal.c'; fi`
+
+mmcli-mmcli-modem-oma.o: mmcli-modem-oma.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmcli_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mmcli-mmcli-modem-oma.o -MD -MP -MF $(DEPDIR)/mmcli-mmcli-modem-oma.Tpo -c -o mmcli-mmcli-modem-oma.o `test -f 'mmcli-modem-oma.c' || echo '$(srcdir)/'`mmcli-modem-oma.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mmcli-mmcli-modem-oma.Tpo $(DEPDIR)/mmcli-mmcli-modem-oma.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mmcli-modem-oma.c' object='mmcli-mmcli-modem-oma.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmcli_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmcli-mmcli-modem-oma.o `test -f 'mmcli-modem-oma.c' || echo '$(srcdir)/'`mmcli-modem-oma.c
+
+mmcli-mmcli-modem-oma.obj: mmcli-modem-oma.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmcli_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mmcli-mmcli-modem-oma.obj -MD -MP -MF $(DEPDIR)/mmcli-mmcli-modem-oma.Tpo -c -o mmcli-mmcli-modem-oma.obj `if test -f 'mmcli-modem-oma.c'; then $(CYGPATH_W) 'mmcli-modem-oma.c'; else $(CYGPATH_W) '$(srcdir)/mmcli-modem-oma.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mmcli-mmcli-modem-oma.Tpo $(DEPDIR)/mmcli-mmcli-modem-oma.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mmcli-modem-oma.c' object='mmcli-mmcli-modem-oma.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmcli_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmcli-mmcli-modem-oma.obj `if test -f 'mmcli-modem-oma.c'; then $(CYGPATH_W) 'mmcli-modem-oma.c'; else $(CYGPATH_W) '$(srcdir)/mmcli-modem-oma.c'; fi`
+
mmcli-mmcli-bearer.o: mmcli-bearer.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmcli_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mmcli-mmcli-bearer.o -MD -MP -MF $(DEPDIR)/mmcli-mmcli-bearer.Tpo -c -o mmcli-mmcli-bearer.o `test -f 'mmcli-bearer.c' || echo '$(srcdir)/'`mmcli-bearer.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mmcli-mmcli-bearer.Tpo $(DEPDIR)/mmcli-mmcli-bearer.Po
diff --git a/cli/mmcli-common.c b/cli/mmcli-common.c
index 016d8bc..f7182d5 100644
--- a/cli/mmcli-common.c
+++ b/cli/mmcli-common.c
@@ -476,7 +476,7 @@ mmcli_get_bearer (GDBusConnection *connection,
ctx->result = g_simple_async_result_new (G_OBJECT (connection),
callback,
user_data,
- mmcli_get_modem);
+ mmcli_get_bearer);
mmcli_get_manager (connection,
cancellable,
(GAsyncReadyCallback)get_bearer_manager_ready,
@@ -714,7 +714,7 @@ mmcli_get_sim (GDBusConnection *connection,
ctx->result = g_simple_async_result_new (G_OBJECT (connection),
callback,
user_data,
- mmcli_get_modem);
+ mmcli_get_sim);
mmcli_get_manager (connection,
cancellable,
(GAsyncReadyCallback)get_sim_manager_ready,
@@ -977,7 +977,7 @@ mmcli_get_sms (GDBusConnection *connection,
ctx->result = g_simple_async_result_new (G_OBJECT (connection),
callback,
user_data,
- mmcli_get_modem);
+ mmcli_get_sms);
mmcli_get_manager (connection,
cancellable,
(GAsyncReadyCallback)get_sms_manager_ready,
diff --git a/cli/mmcli-modem-3gpp.c b/cli/mmcli-modem-3gpp.c
index f88ce62..5b745eb 100644
--- a/cli/mmcli-modem-3gpp.c
+++ b/cli/mmcli-modem-3gpp.c
@@ -76,7 +76,7 @@ static GOptionEntry entries[] = {
"[command]"
},
{ "3gpp-ussd-respond", 0, 0, G_OPTION_ARG_STRING, &ussd_respond_str,
- "Request a given modem to initiate a USSD session",
+ "Request a given modem to respond to a USSD request",
"[response]"
},
{ "3gpp-ussd-cancel", 0, 0, G_OPTION_ARG_NONE, &ussd_cancel_flag,
diff --git a/cli/mmcli-modem-cdma.c b/cli/mmcli-modem-cdma.c
index 8841f7e..1fc077e 100644
--- a/cli/mmcli-modem-cdma.c
+++ b/cli/mmcli-modem-cdma.c
@@ -45,12 +45,22 @@ static Context *ctx;
/* Options */
static gchar *activate_str;
+static gchar *activate_manual_str;
+static gchar *activate_manual_with_prl_str;
static GOptionEntry entries[] = {
{ "cdma-activate", 0, 0, G_OPTION_ARG_STRING, &activate_str,
"Provision the modem to use with a given carrier using OTA settings.",
"[CARRIER]"
},
+ { "cdma-activate-manual", 0, 0, G_OPTION_ARG_STRING, &activate_manual_str,
+ "Provision the modem with the given settings. 'spc', 'sid', 'mdn' and 'min' are mandatory, 'mn-ha-key' and 'mn-aaa-key' are optional.",
+ "[\"key=value,...\"]"
+ },
+ { "cdma-activate-manual-with-prl", 0, 0, G_OPTION_ARG_STRING, &activate_manual_with_prl_str,
+ "Use the given file contents as data for the PRL.",
+ "[File path]"
+ },
{ NULL }
};
@@ -78,13 +88,20 @@ mmcli_modem_cdma_options_enabled (void)
if (checked)
return !!n_actions;
- n_actions = (!!activate_str);
+ n_actions = (!!activate_str +
+ !!activate_manual_str);
if (n_actions > 1) {
g_printerr ("error: too many CDMA actions requested\n");
exit (EXIT_FAILURE);
}
+ if (activate_manual_with_prl_str && !activate_manual_str) {
+ g_printerr ("error: `--cdma-activate-manual-with-prl' must be given along "
+ "with `--cdma-activate-manual'\n");
+ exit (EXIT_FAILURE);
+ }
+
checked = TRUE;
return !!n_actions;
}
@@ -156,6 +173,81 @@ activate_ready (MMModemCdma *modem_cdma,
}
static void
+activate_manual_process_reply (gboolean result,
+ const GError *error)
+{
+ if (!result) {
+ g_printerr ("error: couldn't manually activate the modem: '%s'\n",
+ error ? error->message : "unknown error");
+ exit (EXIT_FAILURE);
+ }
+
+ g_print ("successfully activated the modem manually\n");
+}
+
+static void
+activate_manual_ready (MMModemCdma *modem_cdma,
+ GAsyncResult *result,
+ gpointer nothing)
+{
+ gboolean operation_result;
+ GError *error = NULL;
+
+ operation_result = mm_modem_cdma_activate_manual_finish (modem_cdma, result, &error);
+ activate_manual_process_reply (operation_result, error);
+
+ mmcli_async_operation_done ();
+}
+
+static MMCdmaManualActivationProperties *
+build_activate_manual_properties_from_input (const gchar *properties_string,
+ const gchar *prl_file)
+{
+ GError *error = NULL;
+ MMCdmaManualActivationProperties *properties;
+
+ properties = mm_cdma_manual_activation_properties_new_from_string (properties_string, &error);
+
+ if (!properties) {
+ g_printerr ("error: cannot parse properties string: '%s'\n", error->message);
+ exit (EXIT_FAILURE);
+ }
+
+ if (prl_file) {
+ gchar *path;
+ GFile *file;
+ gchar *contents;
+ gsize contents_size;
+
+ g_debug ("Reading data from file '%s'", prl_file);
+
+ file = g_file_new_for_commandline_arg (prl_file);
+ path = g_file_get_path (file);
+ if (!g_file_get_contents (path,
+ &contents,
+ &contents_size,
+ &error)) {
+ g_printerr ("error: cannot read from file '%s': '%s'\n",
+ prl_file, error->message);
+ exit (EXIT_FAILURE);
+ }
+ g_free (path);
+ g_object_unref (file);
+
+ if (!mm_cdma_manual_activation_properties_set_prl (properties,
+ (guint8 *)contents,
+ contents_size,
+ &error)) {
+ g_printerr ("error: cannot set PRL: '%s'\n", error->message);
+ exit (EXIT_FAILURE);
+ }
+ g_free (contents);
+ }
+
+ return properties;
+}
+
+static void
get_modem_ready (GObject *source,
GAsyncResult *result,
gpointer none)
@@ -180,6 +272,23 @@ get_modem_ready (GObject *source,
return;
}
+ /* Request to manually activate the modem? */
+ if (activate_manual_str) {
+ MMCdmaManualActivationProperties *properties;
+
+ properties = build_activate_manual_properties_from_input (activate_manual_str,
+ activate_manual_with_prl_str);
+
+ g_debug ("Asynchronously manually activating the modem...");
+ mm_modem_cdma_activate_manual (ctx->modem_cdma,
+ properties,
+ ctx->cancellable,
+ (GAsyncReadyCallback)activate_manual_ready,
+ NULL);
+ g_object_unref (properties);
+ return;
+ }
+
g_warn_if_reached ();
}
@@ -232,5 +341,24 @@ mmcli_modem_cdma_run_synchronous (GDBusConnection *connection)
return;
}
+ /* Request to manually activate the modem? */
+ if (activate_manual_str) {
+ MMCdmaManualActivationProperties *properties;
+ gboolean result;
+
+ properties = build_activate_manual_properties_from_input (activate_manual_str,
+ activate_manual_with_prl_str);
+
+ g_debug ("Synchronously manually activating the modem...");
+ result = mm_modem_cdma_activate_manual_sync (
+ ctx->modem_cdma,
+ properties,
+ NULL,
+ &error);
+ activate_manual_process_reply (result, error);
+ g_object_unref (properties);
+ return;
+ }
+
g_warn_if_reached ();
}
diff --git a/cli/mmcli-modem-messaging.c b/cli/mmcli-modem-messaging.c
index 75cb41a..381aca1 100644
--- a/cli/mmcli-modem-messaging.c
+++ b/cli/mmcli-modem-messaging.c
@@ -36,6 +36,7 @@
/* Context */
typedef struct {
+ GDBusConnection *connection;
MMManager *manager;
GCancellable *cancellable;
MMObject *object;
@@ -69,7 +70,7 @@ static GOptionEntry entries[] = {
},
{ "messaging-delete-sms", 0, 0, G_OPTION_ARG_STRING, &delete_str,
"Delete a SMS from a given modem",
- "[PATH]"
+ "[PATH|INDEX]"
},
{ NULL }
};
@@ -135,6 +136,8 @@ context_free (Context *ctx)
g_object_unref (ctx->object);
if (ctx->manager)
g_object_unref (ctx->manager);
+ if (ctx->connection)
+ g_object_unref (ctx->connection);
g_free (ctx);
}
@@ -336,6 +339,30 @@ delete_ready (MMModemMessaging *modem,
}
static void
+get_sms_to_delete_ready (GDBusConnection *connection,
+ GAsyncResult *res)
+{
+ MMSms *sms;
+ MMObject *obj = NULL;
+
+ sms = mmcli_get_sms_finish (res, NULL, &obj);
+ if (!g_str_equal (mm_object_get_path (obj), mm_modem_messaging_get_path (ctx->modem_messaging))) {
+ g_printerr ("error: SMS '%s' not owned by modem '%s'",
+ mm_sms_get_path (sms),
+ mm_modem_messaging_get_path (ctx->modem_messaging));
+ exit (EXIT_FAILURE);
+ }
+
+ mm_modem_messaging_delete (ctx->modem_messaging,
+ mm_sms_get_path (sms),
+ ctx->cancellable,
+ (GAsyncReadyCallback)delete_ready,
+ NULL);
+ g_object_unref (sms);
+ g_object_unref (obj);
+}
+
+static void
get_modem_ready (GObject *source,
GAsyncResult *result,
gpointer none)
@@ -380,11 +407,11 @@ get_modem_ready (GObject *source,
/* Request to delete a given SMS? */
if (delete_str) {
- mm_modem_messaging_delete (ctx->modem_messaging,
- delete_str,
- ctx->cancellable,
- (GAsyncReadyCallback)delete_ready,
- NULL);
+ mmcli_get_sms (ctx->connection,
+ delete_str,
+ ctx->cancellable,
+ (GAsyncReadyCallback)get_sms_to_delete_ready,
+ NULL);
return;
}
@@ -399,6 +426,7 @@ mmcli_modem_messaging_run_asynchronous (GDBusConnection *connection,
ctx = g_new0 (Context, 1);
if (cancellable)
ctx->cancellable = g_object_ref (cancellable);
+ ctx->connection = g_object_ref (connection);
/* Get proper modem */
mmcli_get_modem (connection,
@@ -465,11 +493,26 @@ mmcli_modem_messaging_run_synchronous (GDBusConnection *connection)
/* Request to delete a given SMS? */
if (delete_str) {
gboolean result;
+ MMSms *sms;
+ MMObject *obj = NULL;
+
+ sms = mmcli_get_sms_sync (connection,
+ delete_str,
+ NULL,
+ &obj);
+ if (!g_str_equal (mm_object_get_path (obj), mm_modem_messaging_get_path (ctx->modem_messaging))) {
+ g_printerr ("error: SMS '%s' not owned by modem '%s'",
+ mm_sms_get_path (sms),
+ mm_modem_messaging_get_path (ctx->modem_messaging));
+ exit (EXIT_FAILURE);
+ }
result = mm_modem_messaging_delete_sync (ctx->modem_messaging,
- delete_str,
+ mm_sms_get_path (sms),
NULL,
&error);
+ g_object_unref (sms);
+ g_object_unref (obj);
delete_process_reply (result, error);
return;
diff --git a/cli/mmcli-modem-oma.c b/cli/mmcli-modem-oma.c
new file mode 100644
index 0000000..a06eaa3
--- /dev/null
+++ b/cli/mmcli-modem-oma.c
@@ -0,0 +1,521 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * mmcli -- Control modem status & access information from the command line
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (C) 2013 Google, Inc.
+ */
+
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <locale.h>
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#define _LIBMM_INSIDE_MMCLI
+#include <libmm-glib.h>
+
+#include "mmcli.h"
+#include "mmcli-common.h"
+
+/* Context */
+typedef struct {
+ MMManager *manager;
+ GCancellable *cancellable;
+ MMObject *object;
+ MMModemOma *modem_oma;
+} Context;
+static Context *ctx;
+
+/* Options */
+static gboolean status_flag;
+static gchar *setup_str;
+static gchar *start_str;
+static gchar *accept_str;
+static gchar *reject_str;
+static gboolean cancel_flag;
+
+static GOptionEntry entries[] = {
+ { "oma-status", 0, 0, G_OPTION_ARG_NONE, &status_flag,
+ "Current status of the OMA device management",
+ NULL
+ },
+ { "oma-setup", 0, 0, G_OPTION_ARG_STRING, &setup_str,
+ "Setup OMA features",
+ "[FEATURE1|FEATURE2...]"
+ },
+ { "oma-start-client-initiated-session", 0, 0, G_OPTION_ARG_STRING, &start_str,
+ "Start client initiated OMA DM session",
+ "[Session type]"
+ },
+ { "oma-accept-network-initiated-session", 0, 0, G_OPTION_ARG_STRING, &accept_str,
+ "Accept network initiated OMA DM session",
+ "[Session ID]"
+ },
+ { "oma-reject-network-initiated-session", 0, 0, G_OPTION_ARG_STRING, &reject_str,
+ "Reject network initiated OMA DM session",
+ "[Session ID]"
+ },
+ { "oma-cancel-session", 0, 0, G_OPTION_ARG_NONE, &cancel_flag,
+ "Cancel current OMA DM session",
+ NULL
+ },
+
+ { NULL }
+};
+
+GOptionGroup *
+mmcli_modem_oma_get_option_group (void)
+{
+ GOptionGroup *group;
+
+ group = g_option_group_new ("oma",
+ "OMA options",
+ "Show OMA options",
+ NULL,
+ NULL);
+ g_option_group_add_entries (group, entries);
+
+ return group;
+}
+
+gboolean
+mmcli_modem_oma_options_enabled (void)
+{
+ static guint n_actions = 0;
+ static gboolean checked = FALSE;
+
+ if (checked)
+ return !!n_actions;
+
+ n_actions = (status_flag +
+ !!setup_str +
+ !!start_str +
+ !!accept_str +
+ !!reject_str +
+ cancel_flag);
+
+ if (n_actions > 1) {
+ g_printerr ("error: too many OMA actions requested\n");
+ exit (EXIT_FAILURE);
+ }
+
+ if (status_flag)
+ mmcli_force_sync_operation ();
+
+ checked = TRUE;
+ return !!n_actions;
+}
+
+static void
+context_free (Context *ctx)
+{
+ if (!ctx)
+ return;
+
+ if (ctx->cancellable)
+ g_object_unref (ctx->cancellable);
+ if (ctx->modem_oma)
+ g_object_unref (ctx->modem_oma);
+ if (ctx->object)
+ g_object_unref (ctx->object);
+ if (ctx->manager)
+ g_object_unref (ctx->manager);
+ g_free (ctx);
+}
+
+static void
+ensure_modem_oma (void)
+{
+ if (!ctx->modem_oma) {
+ g_printerr ("error: modem has no OMA capabilities\n");
+ exit (EXIT_FAILURE);
+ }
+
+ /* Success */
+}
+
+void
+mmcli_modem_oma_shutdown (void)
+{
+ context_free (ctx);
+}
+
+static void
+print_oma_status (void)
+{
+ gchar *features_str;
+ const MMOmaPendingNetworkInitiatedSession *pending_sessions;
+ guint n_pending_sessions;
+
+#undef VALIDATE_UNKNOWN
+#define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
+
+ features_str = mm_oma_feature_build_string_from_mask (mm_modem_oma_get_features (ctx->modem_oma));
+
+ /* Global IDs */
+ g_print ("\n"
+ "%s\n",
+ VALIDATE_UNKNOWN (mm_modem_oma_get_path (ctx->modem_oma)));
+
+ /* Overall setup */
+ g_print (" -------------------------\n"
+ " Setup | features: '%s'\n",
+ VALIDATE_UNKNOWN (features_str));
+
+ /* Current session */
+ if (mm_modem_oma_get_session_type (ctx->modem_oma) != MM_OMA_SESSION_TYPE_UNKNOWN) {
+ g_print (" -------------------------\n"
+ " Current session | type: '%s'\n"
+ " | state: '%s'\n",
+ VALIDATE_UNKNOWN (mm_oma_session_type_get_string (mm_modem_oma_get_session_type (ctx->modem_oma))),
+ VALIDATE_UNKNOWN (mm_oma_session_state_get_string (mm_modem_oma_get_session_state (ctx->modem_oma))));
+ }
+
+ /* If 1 or more pending sessions... */
+ if (mm_modem_peek_pending_network_initiated_sessions (ctx->modem_oma, &pending_sessions, &n_pending_sessions) &&
+ n_pending_sessions > 0) {
+ guint i;
+
+ g_print (" -------------------------\n"
+ " Pending sessions |\n");
+ for (i = 0; i < n_pending_sessions; i++) {
+ g_print (" [%u] | type: '%s'\n"
+ " | id: '%u'\n",
+ i,
+ VALIDATE_UNKNOWN (mm_oma_session_type_get_string (pending_sessions[i].session_type)),
+ pending_sessions[i].session_id);
+ }
+ }
+
+ g_free (features_str);
+}
+
+static void
+setup_process_reply (gboolean result,
+ const GError *error)
+{
+ if (!result) {
+ g_printerr ("error: couldn't setup OMA features: '%s'\n",
+ error ? error->message : "unknown error");
+ exit (EXIT_FAILURE);
+ }
+
+ g_print ("Successfully setup OMA features\n");
+}
+
+static void
+setup_ready (MMModemOma *modem,
+ GAsyncResult *result)
+{
+ gboolean res;
+ GError *error = NULL;
+
+ res = mm_modem_oma_setup_finish (modem, result, &error);
+ setup_process_reply (res, error);
+
+ mmcli_async_operation_done ();
+}
+
+static void
+start_process_reply (gboolean result,
+ const GError *error)
+{
+ if (!result) {
+ g_printerr ("error: couldn't start OMA session: '%s'\n",
+ error ? error->message : "unknown error");
+ exit (EXIT_FAILURE);
+ }
+
+ g_print ("Successfully started OMA session\n");
+}
+
+static void
+start_ready (MMModemOma *modem,
+ GAsyncResult *result)
+{
+ gboolean res;
+ GError *error = NULL;
+
+ res = mm_modem_oma_start_client_initiated_session_finish (modem, result, &error);
+ start_process_reply (res, error);
+
+ mmcli_async_operation_done ();
+}
+
+static void
+accept_process_reply (gboolean result,
+ const GError *error)
+{
+ if (!result) {
+ g_printerr ("error: couldn't %s OMA session: '%s'\n",
+ accept_str ? "accept" : "reject",
+ error ? error->message : "unknown error");
+ exit (EXIT_FAILURE);
+ }
+
+ g_print ("Successfully %s OMA session\n",
+ accept_str ? "accepted" : "rejected");
+}
+
+static void
+accept_ready (MMModemOma *modem,
+ GAsyncResult *result)
+{
+ gboolean res;
+ GError *error = NULL;
+
+ res = mm_modem_oma_accept_network_initiated_session_finish (modem, result, &error);
+ accept_process_reply (res, error);
+
+ mmcli_async_operation_done ();
+}
+
+static void
+cancel_process_reply (gboolean result,
+ const GError *error)
+{
+ if (!result) {
+ g_printerr ("error: couldn't cancel OMA session: '%s'\n",
+ error ? error->message : "unknown error");
+ exit (EXIT_FAILURE);
+ }
+
+ g_print ("Successfully cancelled OMA session\n");
+}
+
+static void
+cancel_ready (MMModemOma *modem,
+ GAsyncResult *result)
+{
+ gboolean res;
+ GError *error = NULL;
+
+ res = mm_modem_oma_cancel_session_finish (modem, result, &error);
+ cancel_process_reply (res, error);
+
+ mmcli_async_operation_done ();
+}
+
+static void
+get_modem_ready (GObject *source,
+ GAsyncResult *result)
+{
+ ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
+ ctx->modem_oma = mm_object_get_modem_oma (ctx->object);
+
+ /* Setup operation timeout */
+ if (ctx->modem_oma)
+ mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_oma));
+
+ ensure_modem_oma ();
+
+ g_assert (!status_flag);
+
+ /* Request to setup OMA features? */
+ if (setup_str) {
+ GError *error = NULL;
+ MMOmaFeature features;
+
+ features = mm_common_get_oma_features_from_string (setup_str, &error);
+ if (error) {
+ g_printerr ("Error parsing OMA features string: '%s'\n", error->message);
+ exit (EXIT_FAILURE);
+ }
+
+ g_debug ("Asynchronously setting up OMA features...");
+ mm_modem_oma_setup (ctx->modem_oma,
+ features,
+ ctx->cancellable,
+ (GAsyncReadyCallback)setup_ready,
+ NULL);
+ return;
+ }
+
+ /* Request to start session? */
+ if (start_str) {
+ GError *error = NULL;
+ MMOmaSessionType session_type;
+
+ session_type = mm_common_get_oma_session_type_from_string (start_str, &error);
+ if (error) {
+ g_printerr ("Error parsing OMA session type string: '%s'\n", error->message);
+ exit (EXIT_FAILURE);
+ }
+
+ g_debug ("Asynchronously starting OMA session...");
+ mm_modem_oma_start_client_initiated_session (ctx->modem_oma,
+ session_type,
+ ctx->cancellable,
+ (GAsyncReadyCallback)start_ready,
+ NULL);
+ return;
+ }
+
+ /* Request to accept or reject session? */
+ if (accept_str || reject_str) {
+ guint session_id;
+
+ if (!mm_get_uint_from_str (accept_str ? accept_str : reject_str, &session_id)) {
+ g_printerr ("Error parsing OMA session id string: not a number");
+ exit (EXIT_FAILURE);
+ }
+
+ g_debug ("Asynchronously %s OMA session...", accept_str ? "accepting" : "rejecting");
+ mm_modem_oma_accept_network_initiated_session (ctx->modem_oma,
+ session_id,
+ !!accept_str,
+ ctx->cancellable,
+ (GAsyncReadyCallback)accept_ready,
+ NULL);
+ return;
+ }
+
+ /* Request to cancel a session? */
+ if (cancel_flag) {
+ g_debug ("Asynchronously cancelling OMA session...");
+ mm_modem_oma_cancel_session (ctx->modem_oma,
+ ctx->cancellable,
+ (GAsyncReadyCallback)cancel_ready,
+ NULL);
+ return;
+ }
+
+ g_warn_if_reached ();
+}
+
+void
+mmcli_modem_oma_run_asynchronous (GDBusConnection *connection,
+ GCancellable *cancellable)
+{
+ /* Initialize context */
+ ctx = g_new0 (Context, 1);
+ if (cancellable)
+ ctx->cancellable = g_object_ref (cancellable);
+
+ /* Get proper modem */
+ mmcli_get_modem (connection,
+ mmcli_get_common_modem_string (),
+ cancellable,
+ (GAsyncReadyCallback)get_modem_ready,
+ NULL);
+}
+
+void
+mmcli_modem_oma_run_synchronous (GDBusConnection *connection)
+{
+ GError *error = NULL;
+
+ /* Initialize context */
+ ctx = g_new0 (Context, 1);
+ ctx->object = mmcli_get_modem_sync (connection,
+ mmcli_get_common_modem_string (),
+ &ctx->manager);
+ ctx->modem_oma = mm_object_get_modem_oma (ctx->object);
+
+ /* Setup operation timeout */
+ if (ctx->modem_oma)
+ mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_oma));
+
+ ensure_modem_oma ();
+
+ /* Request to get status? */
+ if (status_flag) {
+ g_debug ("Printing OMA status...");
+ print_oma_status ();
+ return;
+ }
+
+ /* Request to setup OMA features? */
+ if (setup_str) {
+ gboolean result;
+ GError *error = NULL;
+ MMOmaFeature features;
+
+ features = mm_common_get_oma_features_from_string (setup_str, &error);
+ if (error) {
+ g_printerr ("Error parsing OMA features string: '%s'\n", error->message);
+ exit (EXIT_FAILURE);
+ }
+
+ g_debug ("Synchronously setting up OMA features...");
+ result = mm_modem_oma_setup_sync (ctx->modem_oma,
+ features,
+ NULL,
+ &error);
+ setup_process_reply (result, error);
+ return;
+ }
+
+ /* Request to start session? */
+ if (start_str) {
+ gboolean result;
+ GError *error = NULL;
+ MMOmaSessionType session_type;
+
+ session_type = mm_common_get_oma_session_type_from_string (start_str, &error);
+ if (error) {
+ g_printerr ("Error parsing OMA session type string: '%s'\n", error->message);
+ exit (EXIT_FAILURE);
+ }
+
+ g_debug ("Synchronously starting OMA session...");
+ result = mm_modem_oma_start_client_initiated_session_sync (ctx->modem_oma,
+ session_type,
+ NULL,
+ &error);
+ start_process_reply (result, error);
+ return;
+ }
+
+ /* Request to accept or reject session? */
+ if (accept_str || reject_str) {
+ gboolean result;
+ GError *error = NULL;
+ guint session_id;
+
+ if (!mm_get_uint_from_str (accept_str ? accept_str : reject_str, &session_id)) {
+ g_printerr ("Error parsing OMA session id string: not a number");
+ exit (EXIT_FAILURE);
+ }
+
+ g_debug ("Synchronously %s OMA session...", accept_str ? "accepting" : "rejecting");
+ result = mm_modem_oma_accept_network_initiated_session_sync (ctx->modem_oma,
+ session_id,
+ !!accept_str,
+ NULL,
+ &error);
+ accept_process_reply (result, error);
+ return;
+ }
+
+ /* Request to cancel a session? */
+ if (cancel_flag) {
+ gboolean result;
+
+ g_debug ("Synchronously cancelling OMA session...");
+ result = mm_modem_oma_cancel_session_sync (ctx->modem_oma,
+ NULL,
+ &error);
+ cancel_process_reply (result, error);
+ return;
+ }
+
+ g_warn_if_reached ();
+}
diff --git a/cli/mmcli-modem-signal.c b/cli/mmcli-modem-signal.c
new file mode 100644
index 0000000..e1def05
--- /dev/null
+++ b/cli/mmcli-modem-signal.c
@@ -0,0 +1,324 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * mmcli -- Control modem status & access information from the command line
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (C) 2013 Aleksander Morgado <aleksander@gnu.org>
+ */
+
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <locale.h>
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#define _LIBMM_INSIDE_MMCLI
+#include <libmm-glib.h>
+
+#include "mmcli.h"
+#include "mmcli-common.h"
+
+/* Context */
+typedef struct {
+ MMManager *manager;
+ GCancellable *cancellable;
+ MMObject *object;
+ MMModemSignal *modem_signal;
+} Context;
+static Context *ctx;
+
+/* Options */
+static gboolean get_flag;
+static gchar *setup_str;
+
+static GOptionEntry entries[] = {
+ { "signal-setup", 0, 0, G_OPTION_ARG_STRING, &setup_str,
+ "Setup extended signal information retrieval",
+ "[Rate]"
+ },
+ { "signal-get", 0, 0, G_OPTION_ARG_NONE, &get_flag,
+ "Get all extended signal quality information",
+ NULL
+ },
+ { NULL }
+};
+
+GOptionGroup *
+mmcli_modem_signal_get_option_group (void)
+{
+ GOptionGroup *group;
+
+ group = g_option_group_new ("signal",
+ "Signal options",
+ "Show Signal options",
+ NULL,
+ NULL);
+ g_option_group_add_entries (group, entries);
+
+ return group;
+}
+
+gboolean
+mmcli_modem_signal_options_enabled (void)
+{
+ static guint n_actions = 0;
+ static gboolean checked = FALSE;
+
+ if (checked)
+ return !!n_actions;
+
+ n_actions = (!!setup_str +
+ get_flag);
+
+ if (n_actions > 1) {
+ g_printerr ("error: too many Signal actions requested\n");
+ exit (EXIT_FAILURE);
+ }
+
+ if (get_flag)
+ mmcli_force_sync_operation ();
+
+ checked = TRUE;
+ return !!n_actions;
+}
+
+static void
+context_free (Context *ctx)
+{
+ if (!ctx)
+ return;
+
+ if (ctx->cancellable)
+ g_object_unref (ctx->cancellable);
+ if (ctx->modem_signal)
+ g_object_unref (ctx->modem_signal);
+ if (ctx->object)
+ g_object_unref (ctx->object);
+ if (ctx->manager)
+ g_object_unref (ctx->manager);
+ g_free (ctx);
+}
+
+static void
+ensure_modem_signal (void)
+{
+ if (!ctx->modem_signal) {
+ g_printerr ("error: modem has no extended signal capabilities\n");
+ exit (EXIT_FAILURE);
+ }
+
+ /* Success */
+}
+
+void
+mmcli_modem_signal_shutdown (void)
+{
+ context_free (ctx);
+}
+
+static void
+print_signal_info (void)
+{
+ MMSignal *signal;
+
+ g_print ("\n"
+ "%s\n"
+ " -------------------------\n"
+ " Refresh rate: '%u' seconds\n",
+ mm_modem_signal_get_path (ctx->modem_signal),
+ mm_modem_signal_get_rate (ctx->modem_signal));
+
+ /* CDMA */
+ signal = mm_modem_signal_peek_cdma (ctx->modem_signal);
+ if (signal)
+ g_print (" -------------------------\n"
+ " CDMA1x | RSSI: '%.2lf' dBm\n"
+ " | EcIo: '%.2lf' dBm\n",
+ mm_signal_get_rssi (signal),
+ mm_signal_get_ecio (signal));
+
+ /* EVDO */
+ signal = mm_modem_signal_peek_evdo (ctx->modem_signal);
+ if (signal)
+ g_print (" -------------------------\n"
+ " EV-DO | RSSI: '%.2lf' dBm\n"
+ " | EcIo: '%.2lf' dBm\n"
+ " | SINR: '%.2lf' dBm\n"
+ " | Io: '%.2lf' dB\n",
+ mm_signal_get_rssi (signal),
+ mm_signal_get_ecio (signal),
+ mm_signal_get_sinr (signal),
+ mm_signal_get_io (signal));
+
+ /* GSM */
+ signal = mm_modem_signal_peek_gsm (ctx->modem_signal);
+ if (signal)
+ g_print (" -------------------------\n"
+ " GSM | RSSI: '%.2lf' dBm\n",
+ mm_signal_get_rssi (signal));
+
+ /* UMTS */
+ signal = mm_modem_signal_peek_umts (ctx->modem_signal);
+ if (signal)
+ g_print (" -------------------------\n"
+ " UMTS | RSSI: '%.2lf' dBm\n"
+ " | EcIo: '%.2lf' dBm\n",
+ mm_signal_get_rssi (signal),
+ mm_signal_get_ecio (signal));
+
+ /* LTE */
+ signal = mm_modem_signal_peek_lte (ctx->modem_signal);
+ if (signal)
+ g_print (" -------------------------\n"
+ " LTE | RSSI: '%.2lf' dBm\n"
+ " | RSRQ: '%.2lf' dB\n"
+ " | RSRP: '%.2lf' dBm\n"
+ " | SNR: '%.2lf' dB\n",
+ mm_signal_get_rssi (signal),
+ mm_signal_get_rsrq (signal),
+ mm_signal_get_rsrp (signal),
+ mm_signal_get_snr (signal));
+}
+
+static void
+setup_process_reply (gboolean result,
+ const GError *error)
+{
+ if (!result) {
+ g_printerr ("error: couldn't setup extended signal information retrieval: '%s'\n",
+ error ? error->message : "unknown error");
+ exit (EXIT_FAILURE);
+ }
+
+ g_print ("Successfully setup extended signal information retrieval\n");
+}
+
+static void
+setup_ready (MMModemSignal *modem,
+ GAsyncResult *result)
+{
+ gboolean res;
+ GError *error = NULL;
+
+ res = mm_modem_signal_setup_finish (modem, result, &error);
+ setup_process_reply (res, error);
+
+ mmcli_async_operation_done ();
+}
+
+static void
+get_modem_ready (GObject *source,
+ GAsyncResult *result)
+{
+ ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
+ ctx->modem_signal = mm_object_get_modem_signal (ctx->object);
+
+ /* Setup operation timeout */
+ if (ctx->modem_signal)
+ mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_signal));
+
+ ensure_modem_signal ();
+
+ if (get_flag)
+ g_assert_not_reached ();
+
+ /* Request to setup? */
+ if (setup_str) {
+ guint rate;
+
+ if (!mm_get_uint_from_str (setup_str, &rate)) {
+ g_printerr ("error: invalid rate value '%s'", setup_str);
+ exit (EXIT_FAILURE);
+ }
+
+ g_debug ("Asynchronously setting up extended signal quality information retrieval...");
+ mm_modem_signal_setup (ctx->modem_signal,
+ rate,
+ ctx->cancellable,
+ (GAsyncReadyCallback)setup_ready,
+ NULL);
+ return;
+ }
+
+ g_warn_if_reached ();
+}
+
+void
+mmcli_modem_signal_run_asynchronous (GDBusConnection *connection,
+ GCancellable *cancellable)
+{
+ /* Initialize context */
+ ctx = g_new0 (Context, 1);
+ if (cancellable)
+ ctx->cancellable = g_object_ref (cancellable);
+
+ /* Get proper modem */
+ mmcli_get_modem (connection,
+ mmcli_get_common_modem_string (),
+ cancellable,
+ (GAsyncReadyCallback)get_modem_ready,
+ NULL);
+}
+
+void
+mmcli_modem_signal_run_synchronous (GDBusConnection *connection)
+{
+ GError *error = NULL;
+
+ /* Initialize context */
+ ctx = g_new0 (Context, 1);
+ ctx->object = mmcli_get_modem_sync (connection,
+ mmcli_get_common_modem_string (),
+ &ctx->manager);
+ ctx->modem_signal = mm_object_get_modem_signal (ctx->object);
+
+ /* Setup operation timeout */
+ if (ctx->modem_signal)
+ mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_signal));
+
+ ensure_modem_signal ();
+
+ /* Request to get signal info? */
+ if (get_flag) {
+ print_signal_info ();
+ return;
+ }
+
+ /* Request to set rate? */
+ if (setup_str) {
+ guint rate;
+ gboolean result;
+
+ if (!mm_get_uint_from_str (setup_str, &rate)) {
+ g_printerr ("error: invalid rate value '%s'", setup_str);
+ exit (EXIT_FAILURE);
+ }
+
+ g_debug ("Synchronously setting up extended signal quality information retrieval...");
+ result = mm_modem_signal_setup_sync (ctx->modem_signal,
+ rate,
+ NULL,
+ &error);
+ setup_process_reply (result, error);
+ return;
+ }
+
+
+ g_warn_if_reached ();
+}
diff --git a/cli/mmcli-modem-simple.c b/cli/mmcli-modem-simple.c
index 22976a9..7b99792 100644
--- a/cli/mmcli-modem-simple.c
+++ b/cli/mmcli-modem-simple.c
@@ -251,13 +251,16 @@ status_process_reply (MMSimpleStatus *result,
(mm_simple_status_get_3gpp_registration_state (result) ==
MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING)) {
g_print (" -------------------------\n"
- " 3GPP | registration: '%s'\n"
+ " 3GPP | registration: '%s'\n"
" | operator code: '%s'\n"
- " | operator name: '%s'\n",
+ " | operator name: '%s'\n"
+ " | subscription: '%s'\n",
mm_modem_3gpp_registration_state_get_string (
mm_simple_status_get_3gpp_registration_state (result)),
VALIDATE_UNKNOWN (mm_simple_status_get_3gpp_operator_code (result)),
- VALIDATE_UNKNOWN (mm_simple_status_get_3gpp_operator_name (result)));
+ VALIDATE_UNKNOWN (mm_simple_status_get_3gpp_operator_name (result)),
+ mm_modem_3gpp_subscription_state_get_string (
+ mm_simple_status_get_3gpp_subscription_state (result)));
}
if ((mm_simple_status_get_cdma_cdma1x_registration_state (result) !=
@@ -296,8 +299,14 @@ status_process_reply (MMSimpleStatus *result,
g_free (access_tech_str);
g_free (bands_str);
+ } else {
+ g_print (" -------------------------\n"
+ " 3GPP | subscription: '%s'\n",
+ mm_modem_3gpp_subscription_state_get_string (
+ mm_simple_status_get_3gpp_subscription_state (result)));
}
+
g_print ("\n");
g_object_unref (result);
}
diff --git a/cli/mmcli-modem.c b/cli/mmcli-modem.c
index 18e7356..b7e260b 100644
--- a/cli/mmcli-modem.c
+++ b/cli/mmcli-modem.c
@@ -35,6 +35,7 @@
/* Context */
typedef struct {
+ GDBusConnection *connection;
MMManager *manager;
GCancellable *cancellable;
MMObject *object;
@@ -105,7 +106,7 @@ static GOptionEntry entries[] = {
},
{ "delete-bearer", 0, 0, G_OPTION_ARG_STRING, &delete_bearer_str,
"Delete a data bearer from a given modem",
- "[PATH]"
+ "[PATH|INDEX]"
},
{ "set-current-capabilities", 0, 0, G_OPTION_ARG_STRING, &set_current_capabilities_str,
"Set current modem capabilities.",
@@ -214,6 +215,8 @@ context_free (Context *ctx)
g_object_unref (ctx->object);
if (ctx->manager)
g_object_unref (ctx->manager);
+ if (ctx->connection)
+ g_object_unref (ctx->connection);
g_free (ctx);
}
@@ -266,6 +269,7 @@ print_modem_info (void)
MMUnlockRetries *unlock_retries;
guint signal_quality = 0;
gboolean signal_quality_recent = FALSE;
+ gchar *bearer_paths_string;
/* Not the best thing to do, as we may be doing _get() calls twice, but
* easiest to maintain */
@@ -351,6 +355,15 @@ print_modem_info (void)
/* Get signal quality info */
signal_quality = mm_modem_get_signal_quality (ctx->modem, &signal_quality_recent);
+ if (mm_modem_get_bearer_paths (ctx->modem)) {
+ bearer_paths_string = g_strjoinv (", ", (gchar **)mm_modem_get_bearer_paths (ctx->modem));
+ if (!bearer_paths_string[0]) {
+ g_free (bearer_paths_string);
+ bearer_paths_string = NULL;
+ }
+ } else
+ bearer_paths_string = NULL;
+
/* Global IDs */
g_print ("\n"
"%s (device id '%s')\n",
@@ -441,11 +454,14 @@ print_modem_info (void)
" | enabled locks: '%s'\n"
" | operator id: '%s'\n"
" | operator name: '%s'\n"
+ " | subscription: '%s'\n"
" | registration: '%s'\n",
VALIDATE_UNKNOWN (mm_modem_3gpp_get_imei (ctx->modem_3gpp)),
facility_locks,
VALIDATE_UNKNOWN (mm_modem_3gpp_get_operator_code (ctx->modem_3gpp)),
VALIDATE_UNKNOWN (mm_modem_3gpp_get_operator_name (ctx->modem_3gpp)),
+ mm_modem_3gpp_subscription_state_get_string (
+ mm_modem_3gpp_get_subscription_state ((ctx->modem_3gpp))),
mm_modem_3gpp_registration_state_get_string (
mm_modem_3gpp_get_registration_state ((ctx->modem_3gpp))));
@@ -497,6 +513,12 @@ print_modem_info (void)
VALIDATE_PATH (mm_modem_get_sim_path (ctx->modem)));
g_print ("\n");
+ /* Bearers */
+ g_print (" -------------------------\n"
+ " Bearers | paths: '%s'\n",
+ VALIDATE_PATH (bearer_paths_string));
+ g_print ("\n");
+
g_free (ports_string);
g_free (supported_ip_families_string);
g_free (current_bands_string);
@@ -511,6 +533,7 @@ print_modem_info (void)
g_free (unlock_retries_string);
g_free (own_numbers_string);
g_free (drivers_string);
+ g_free (bearer_paths_string);
}
static void
@@ -791,6 +814,30 @@ delete_bearer_ready (MMModem *modem,
}
static void
+get_bearer_to_delete_ready (GDBusConnection *connection,
+ GAsyncResult *res)
+{
+ MMBearer *bearer;
+ MMObject *obj = NULL;
+
+ bearer = mmcli_get_bearer_finish (res, NULL, &obj);
+ if (!g_str_equal (mm_object_get_path (obj), mm_modem_get_path (ctx->modem))) {
+ g_printerr ("error: bearer '%s' not owned by modem '%s'",
+ mm_bearer_get_path (bearer),
+ mm_modem_get_path (ctx->modem));
+ exit (EXIT_FAILURE);
+ }
+
+ mm_modem_delete_bearer (ctx->modem,
+ mm_bearer_get_path (bearer),
+ ctx->cancellable,
+ (GAsyncReadyCallback)delete_bearer_ready,
+ NULL);
+ g_object_unref (bearer);
+ g_object_unref (obj);
+}
+
+static void
set_current_capabilities_process_reply (gboolean result,
const GError *error)
{
@@ -1096,11 +1143,11 @@ get_modem_ready (GObject *source,
/* Request to delete a given bearer? */
if (delete_bearer_str) {
- mm_modem_delete_bearer (ctx->modem,
- delete_bearer_str,
- ctx->cancellable,
- (GAsyncReadyCallback)delete_bearer_ready,
- NULL);
+ mmcli_get_bearer (ctx->connection,
+ delete_bearer_str,
+ ctx->cancellable,
+ (GAsyncReadyCallback)get_bearer_to_delete_ready,
+ NULL);
return;
}
@@ -1159,6 +1206,7 @@ mmcli_modem_run_asynchronous (GDBusConnection *connection,
ctx = g_new0 (Context, 1);
if (cancellable)
ctx->cancellable = g_object_ref (cancellable);
+ ctx->connection = g_object_ref (connection);
/* Get proper modem */
mmcli_get_modem (connection,
@@ -1319,11 +1367,26 @@ mmcli_modem_run_synchronous (GDBusConnection *connection)
/* Request to delete a given bearer? */
if (delete_bearer_str) {
gboolean result;
+ MMBearer *bearer;
+ MMObject *obj = NULL;
+
+ bearer = mmcli_get_bearer_sync (connection,
+ delete_bearer_str,
+ NULL,
+ &obj);
+ if (!g_str_equal (mm_object_get_path (obj), mm_modem_get_path (ctx->modem))) {
+ g_printerr ("error: bearer '%s' not owned by modem '%s'",
+ mm_bearer_get_path (bearer),
+ mm_modem_get_path (ctx->modem));
+ exit (EXIT_FAILURE);
+ }
result = mm_modem_delete_bearer_sync (ctx->modem,
- delete_bearer_str,
+ mm_bearer_get_path (bearer),
NULL,
&error);
+ g_object_unref (bearer);
+ g_object_unref (obj);
delete_bearer_process_reply (result, error);
return;
diff --git a/cli/mmcli-sms.c b/cli/mmcli-sms.c
index 4124f66..c49c8e8 100644
--- a/cli/mmcli-sms.c
+++ b/cli/mmcli-sms.c
@@ -180,42 +180,56 @@ print_sms_info (MMSms *sms)
g_print (" -----------------------------------\n"
" Properties | PDU type: '%s'\n"
- " | state: '%s'\n"
- " | smsc: '%s'\n",
+ " | state: '%s'\n",
mm_sms_pdu_type_get_string (pdu_type),
- mm_sms_state_get_string (mm_sms_get_state (sms)),
- VALIDATE (mm_sms_get_smsc (sms)));
+ mm_sms_state_get_string (mm_sms_get_state (sms)));
if (mm_sms_get_validity_type (sms) == MM_SMS_VALIDITY_TYPE_RELATIVE)
g_print (" | validity (relative): '%u'\n",
mm_sms_get_validity_relative (sms));
- g_print (" | class: '%d'\n"
- " | storage: '%s'\n",
- mm_sms_get_class (sms),
+ g_print (" | storage: '%s'\n",
mm_sms_storage_get_string (mm_sms_get_storage (sms)));
+ /* Print properties which are set, regardless of the pdu type */
+
+ if (mm_sms_get_smsc (sms))
+ g_print (" | smsc: '%s'\n",
+ mm_sms_get_smsc (sms));
+
+ if (mm_sms_get_class (sms) >= 0)
+ g_print (" | class: '%d'\n",
+ mm_sms_get_class (sms));
+
+ if (mm_sms_get_teleservice_id (sms) != MM_SMS_CDMA_TELESERVICE_ID_UNKNOWN)
+ g_print (" | teleservice id: '%s'\n",
+ mm_sms_cdma_teleservice_id_get_string (mm_sms_get_teleservice_id (sms)));
+
+ if (mm_sms_get_service_category (sms) != MM_SMS_CDMA_SERVICE_CATEGORY_UNKNOWN)
+ g_print (" | service category: '%s'\n",
+ mm_sms_cdma_service_category_get_string (mm_sms_get_service_category (sms)));
+
+ /* Delivery report request just in 3GPP submit PDUs */
if (pdu_type == MM_SMS_PDU_TYPE_SUBMIT)
g_print (" | delivery report: '%s'\n",
mm_sms_get_delivery_report_request (sms) ? "requested" : "not requested");
- if (pdu_type == MM_SMS_PDU_TYPE_STATUS_REPORT ||
- pdu_type == MM_SMS_PDU_TYPE_SUBMIT)
+ if (mm_sms_get_message_reference (sms) != 0)
g_print (" | message reference: '%u'\n",
mm_sms_get_message_reference (sms));
- if (pdu_type == MM_SMS_PDU_TYPE_STATUS_REPORT ||
- pdu_type == MM_SMS_PDU_TYPE_DELIVER)
+ if (mm_sms_get_timestamp (sms))
g_print (" | timestamp: '%s'\n",
- VALIDATE (mm_sms_get_timestamp (sms)));
+ mm_sms_get_timestamp (sms));
- if (pdu_type == MM_SMS_PDU_TYPE_STATUS_REPORT) {
+ if (mm_sms_get_delivery_state (sms) != MM_SMS_DELIVERY_STATE_UNKNOWN)
g_print (" | delivery state: '%s' (0x%X)\n",
VALIDATE (mm_sms_delivery_state_get_string_extended (mm_sms_get_delivery_state (sms))),
mm_sms_get_delivery_state (sms));
+
+ if (mm_sms_get_discharge_timestamp (sms))
g_print (" | discharge timestamp: '%s'\n",
- VALIDATE (mm_sms_get_discharge_timestamp (sms)));
- }
+ mm_sms_get_discharge_timestamp (sms));
}
static void
diff --git a/cli/mmcli.c b/cli/mmcli.c
index da68780..aeb1bd4 100644
--- a/cli/mmcli.c
+++ b/cli/mmcli.c
@@ -209,6 +209,10 @@ main (gint argc, gchar **argv)
g_option_context_add_group (context,
mmcli_modem_firmware_get_option_group ());
g_option_context_add_group (context,
+ mmcli_modem_signal_get_option_group ());
+ g_option_context_add_group (context,
+ mmcli_modem_oma_get_option_group ());
+ g_option_context_add_group (context,
mmcli_sim_get_option_group ());
g_option_context_add_group (context,
mmcli_bearer_get_option_group ());
@@ -325,6 +329,20 @@ main (gint argc, gchar **argv)
else
mmcli_modem_firmware_run_synchronous (connection);
}
+ /* Modem Signal options? */
+ else if (mmcli_modem_signal_options_enabled ()) {
+ if (async_flag)
+ mmcli_modem_signal_run_asynchronous (connection, cancellable);
+ else
+ mmcli_modem_signal_run_synchronous (connection);
+ }
+ /* Modem Oma options? */
+ else if (mmcli_modem_oma_options_enabled ()) {
+ if (async_flag)
+ mmcli_modem_oma_run_asynchronous (connection, cancellable);
+ else
+ mmcli_modem_oma_run_synchronous (connection);
+ }
/* Modem options?
* NOTE: let this check be always the last one, as other groups also need
* having a modem specified, and therefore if -m is set, modem options
@@ -361,6 +379,10 @@ main (gint argc, gchar **argv)
mmcli_modem_time_shutdown ();
} else if (mmcli_modem_firmware_options_enabled ()) {
mmcli_modem_firmware_shutdown ();
+ } else if (mmcli_modem_signal_options_enabled ()) {
+ mmcli_modem_signal_shutdown ();
+ } else if (mmcli_modem_oma_options_enabled ()) {
+ mmcli_modem_oma_shutdown ();
} else if (mmcli_sim_options_enabled ()) {
mmcli_sim_shutdown ();
} else if (mmcli_bearer_options_enabled ()) {
diff --git a/cli/mmcli.h b/cli/mmcli.h
index 5243969..6b7b553 100644
--- a/cli/mmcli.h
+++ b/cli/mmcli.h
@@ -101,6 +101,22 @@ void mmcli_modem_firmware_run_asynchronous (GDBusConnection *connecti
void mmcli_modem_firmware_run_synchronous (GDBusConnection *connection);
void mmcli_modem_firmware_shutdown (void);
+/* Signal group */
+GOptionGroup *mmcli_modem_signal_get_option_group (void);
+gboolean mmcli_modem_signal_options_enabled (void);
+void mmcli_modem_signal_run_asynchronous (GDBusConnection *connection,
+ GCancellable *cancellable);
+void mmcli_modem_signal_run_synchronous (GDBusConnection *connection);
+void mmcli_modem_signal_shutdown (void);
+
+/* Oma group */
+GOptionGroup *mmcli_modem_oma_get_option_group (void);
+gboolean mmcli_modem_oma_options_enabled (void);
+void mmcli_modem_oma_run_asynchronous (GDBusConnection *connection,
+ GCancellable *cancellable);
+void mmcli_modem_oma_run_synchronous (GDBusConnection *connection);
+void mmcli_modem_oma_shutdown (void);
+
/* Bearer group */
GOptionGroup *mmcli_bearer_get_option_group (void);
gboolean mmcli_bearer_options_enabled (void);