diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-25 10:04:20 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-25 11:44:01 +0200 |
commit | 8f8bcd7724e8c75cf7e0460946c04624ce6ed46a (patch) | |
tree | bd2d0a9050977197fb0ac2e50eeb75e8f8dd2f5e /cli | |
parent | 8a34e417943df90f6b43a0de08550def557c7db7 (diff) |
cli: allow modifying default DBus timeout with `--timeout'
By default 30s will be used for every operation.
Diffstat (limited to 'cli')
-rw-r--r-- | cli/mmcli-manager.c | 6 | ||||
-rw-r--r-- | cli/mmcli-modem-3gpp.c | 12 | ||||
-rw-r--r-- | cli/mmcli-modem-cdma.c | 8 | ||||
-rw-r--r-- | cli/mmcli-modem-location.c | 8 | ||||
-rw-r--r-- | cli/mmcli-modem-messaging.c | 8 | ||||
-rw-r--r-- | cli/mmcli-modem-simple.c | 8 | ||||
-rw-r--r-- | cli/mmcli-modem-time.c | 8 | ||||
-rw-r--r-- | cli/mmcli-modem.c | 16 | ||||
-rw-r--r-- | cli/mmcli-sim.c | 6 | ||||
-rw-r--r-- | cli/mmcli-sms.c | 5 | ||||
-rw-r--r-- | cli/mmcli.c | 11 | ||||
-rw-r--r-- | cli/mmcli.h | 7 |
12 files changed, 100 insertions, 3 deletions
diff --git a/cli/mmcli-manager.c b/cli/mmcli-manager.c index e9d9a93c..6dd00ac5 100644 --- a/cli/mmcli-manager.c +++ b/cli/mmcli-manager.c @@ -248,6 +248,9 @@ get_manager_ready (GObject *source, { ctx->manager = mmcli_get_manager_finish (result); + /* Setup operation timeout */ + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->manager)); + /* Request to set log level? */ if (set_logging_str) { mm_manager_set_logging (ctx->manager, @@ -327,6 +330,9 @@ mmcli_manager_run_synchronous (GDBusConnection *connection) ctx = g_new0 (Context, 1); ctx->manager = mmcli_get_manager_sync (connection); + /* Setup operation timeout */ + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->manager)); + /* Request to set log level? */ if (set_logging_str) { gboolean result; diff --git a/cli/mmcli-modem-3gpp.c b/cli/mmcli-modem-3gpp.c index 22323eda..6d7be868 100644 --- a/cli/mmcli-modem-3gpp.c +++ b/cli/mmcli-modem-3gpp.c @@ -405,6 +405,12 @@ get_modem_ready (GObject *source, ctx->modem_3gpp = mm_object_get_modem_3gpp (ctx->object); ctx->modem_3gpp_ussd = mm_object_get_modem_3gpp_ussd (ctx->object); + /* Setup operation timeout */ + if (ctx->modem_3gpp) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_3gpp)); + if (ctx->modem_3gpp_ussd) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_3gpp_ussd)); + ensure_modem_3gpp (); if (ussd_status_flag) @@ -502,6 +508,12 @@ mmcli_modem_3gpp_run_synchronous (GDBusConnection *connection) ctx->modem_3gpp = mm_object_get_modem_3gpp (ctx->object); ctx->modem_3gpp_ussd = mm_object_get_modem_3gpp_ussd (ctx->object); + /* Setup operation timeout */ + if (ctx->modem_3gpp) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_3gpp)); + if (ctx->modem_3gpp_ussd) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_3gpp_ussd)); + ensure_modem_3gpp (); if (scan_flag) diff --git a/cli/mmcli-modem-cdma.c b/cli/mmcli-modem-cdma.c index 77df70cf..b5183462 100644 --- a/cli/mmcli-modem-cdma.c +++ b/cli/mmcli-modem-cdma.c @@ -162,6 +162,10 @@ get_modem_ready (GObject *source, ctx->object = mmcli_get_modem_finish (result, &ctx->manager); ctx->modem_cdma = mm_object_get_modem_cdma (ctx->object); + /* Setup operation timeout */ + if (ctx->modem_cdma) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_cdma)); + ensure_modem_cdma (); /* Request to activate the modem? */ @@ -207,6 +211,10 @@ mmcli_modem_cdma_run_synchronous (GDBusConnection *connection) &ctx->manager); ctx->modem_cdma = mm_object_get_modem_cdma (ctx->object); + /* Setup operation timeout */ + if (ctx->modem_cdma) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_cdma)); + ensure_modem_cdma (); /* Request to activate the modem? */ diff --git a/cli/mmcli-modem-location.c b/cli/mmcli-modem-location.c index ed2b2f77..0b83a419 100644 --- a/cli/mmcli-modem-location.c +++ b/cli/mmcli-modem-location.c @@ -407,6 +407,10 @@ get_modem_ready (GObject *source, ctx->object = mmcli_get_modem_finish (result, &ctx->manager); ctx->modem_location = mm_object_get_modem_location (ctx->object); + /* Setup operation timeout */ + if (ctx->modem_location) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_location)); + ensure_modem_location (); if (status_flag) @@ -473,6 +477,10 @@ mmcli_modem_location_run_synchronous (GDBusConnection *connection) &ctx->manager); ctx->modem_location = mm_object_get_modem_location (ctx->object); + /* Setup operation timeout */ + if (ctx->modem_location) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_location)); + ensure_modem_location (); /* Request to get location status? */ diff --git a/cli/mmcli-modem-messaging.c b/cli/mmcli-modem-messaging.c index 3c62408b..60f03efb 100644 --- a/cli/mmcli-modem-messaging.c +++ b/cli/mmcli-modem-messaging.c @@ -252,6 +252,10 @@ get_modem_ready (GObject *source, ctx->object = mmcli_get_modem_finish (result, &ctx->manager); ctx->modem_messaging = mm_object_get_modem_messaging (ctx->object); + /* Setup operation timeout */ + if (ctx->modem_messaging) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_messaging)); + ensure_modem_messaging (); /* Request to list SMS? */ @@ -327,6 +331,10 @@ mmcli_modem_messaging_run_synchronous (GDBusConnection *connection) &ctx->manager); ctx->modem_messaging = mm_object_get_modem_messaging (ctx->object); + /* Setup operation timeout */ + if (ctx->modem_messaging) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_messaging)); + ensure_modem_messaging (); /* Request to list the SMS? */ diff --git a/cli/mmcli-modem-simple.c b/cli/mmcli-modem-simple.c index 53277038..b961a6e2 100644 --- a/cli/mmcli-modem-simple.c +++ b/cli/mmcli-modem-simple.c @@ -323,6 +323,10 @@ get_modem_ready (GObject *source, ctx->object = mmcli_get_modem_finish (result, &ctx->manager); ctx->modem_simple = mm_object_get_modem_simple (ctx->object); + /* Setup operation timeout */ + if (ctx->modem_simple) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_simple)); + ensure_modem_simple (); /* Request to connect the modem? */ @@ -402,6 +406,10 @@ mmcli_modem_simple_run_synchronous (GDBusConnection *connection) &ctx->manager); ctx->modem_simple = mm_object_get_modem_simple (ctx->object); + /* Setup operation timeout */ + if (ctx->modem_simple) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_simple)); + ensure_modem_simple (); if (connect_str) diff --git a/cli/mmcli-modem-time.c b/cli/mmcli-modem-time.c index d17c1dee..6918833c 100644 --- a/cli/mmcli-modem-time.c +++ b/cli/mmcli-modem-time.c @@ -202,6 +202,10 @@ get_modem_ready (GObject *source, ctx->object = mmcli_get_modem_finish (result, &ctx->manager); ctx->modem_time = mm_object_get_modem_time (ctx->object); + /* Setup operation timeout */ + if (ctx->modem_time) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_time)); + ensure_modem_time (); /* Request to get network time from the modem? */ @@ -247,6 +251,10 @@ mmcli_modem_time_run_synchronous (GDBusConnection *connection) &ctx->manager); ctx->modem_time = mm_object_get_modem_time (ctx->object); + /* Setup operation timeout */ + if (ctx->modem_time) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_time)); + ensure_modem_time (); /* Request to get network time from the modem? */ diff --git a/cli/mmcli-modem.c b/cli/mmcli-modem.c index e3271a97..63542134 100644 --- a/cli/mmcli-modem.c +++ b/cli/mmcli-modem.c @@ -771,6 +771,14 @@ get_modem_ready (GObject *source, ctx->modem_3gpp = mm_object_get_modem_3gpp (ctx->object); ctx->modem_cdma = mm_object_get_modem_cdma (ctx->object); + /* Setup operation timeout */ + if (ctx->modem) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem)); + if (ctx->modem_3gpp) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_3gpp)); + if (ctx->modem_cdma) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_cdma)); + if (info_flag) g_assert_not_reached (); @@ -958,6 +966,14 @@ mmcli_modem_run_synchronous (GDBusConnection *connection) ctx->modem_3gpp = mm_object_get_modem_3gpp (ctx->object); ctx->modem_cdma = mm_object_get_modem_cdma (ctx->object); + /* Setup operation timeout */ + if (ctx->modem) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem)); + if (ctx->modem_3gpp) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_3gpp)); + if (ctx->modem_cdma) + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_cdma)); + /* Request to get info from modem? */ if (info_flag) { g_debug ("Printing modem info..."); diff --git a/cli/mmcli-sim.c b/cli/mmcli-sim.c index aa39a91c..1bde2b74 100644 --- a/cli/mmcli-sim.c +++ b/cli/mmcli-sim.c @@ -315,6 +315,9 @@ get_sim_ready (GObject *source, &ctx->manager, &ctx->object); + /* Setup operation timeout */ + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->sim)); + if (info_flag) g_assert_not_reached (); @@ -402,6 +405,9 @@ mmcli_sim_run_synchronous (GDBusConnection *connection) &ctx->manager, &ctx->object); + /* Setup operation timeout */ + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->sim)); + /* Request to get info from SIM? */ if (info_flag) { g_debug ("Printing sim info..."); diff --git a/cli/mmcli-sms.c b/cli/mmcli-sms.c index 8de3350c..e3e02104 100644 --- a/cli/mmcli-sms.c +++ b/cli/mmcli-sms.c @@ -220,6 +220,8 @@ get_sms_ready (GObject *source, ctx->sms = mmcli_get_sms_finish (result, &ctx->manager, &ctx->object); + /* Setup operation timeout */ + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->sms)); if (info_flag) g_assert_not_reached (); @@ -274,6 +276,9 @@ mmcli_sms_run_synchronous (GDBusConnection *connection) &ctx->manager, &ctx->object); + /* Setup operation timeout */ + mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->sms)); + /* Request to get info from SMS? */ if (info_flag) { g_debug ("Printing SMS info..."); diff --git a/cli/mmcli.c b/cli/mmcli.c index 78284ca9..b05df9bc 100644 --- a/cli/mmcli.c +++ b/cli/mmcli.c @@ -45,6 +45,7 @@ static GCancellable *cancellable; static gboolean verbose_flag; static gboolean version_flag; static gboolean async_flag; +static gint timeout = 30; /* by default, use 30s for all operations */ static GOptionEntry main_entries[] = { { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose_flag, @@ -59,6 +60,10 @@ static GOptionEntry main_entries[] = { "Use asynchronous methods", NULL }, + { "timeout", 0, 0, G_OPTION_ARG_INT, &timeout, + "Timeout for the operation", + "[SECONDS]" + }, { NULL } }; @@ -163,6 +168,12 @@ mmcli_force_sync_operation (void) } } +void +mmcli_force_operation_timeout (GDBusProxy *proxy) +{ + g_dbus_proxy_set_default_timeout (proxy, timeout * 1000); +} + gint main (gint argc, gchar **argv) { diff --git a/cli/mmcli.h b/cli/mmcli.h index 8bc16396..441bb8e3 100644 --- a/cli/mmcli.h +++ b/cli/mmcli.h @@ -24,9 +24,10 @@ #define __MMCLI_H__ /* Common */ -void mmcli_async_operation_done (void); -void mmcli_force_async_operation (void); -void mmcli_force_sync_operation (void); +void mmcli_async_operation_done (void); +void mmcli_force_async_operation (void); +void mmcli_force_sync_operation (void); +void mmcli_force_operation_timeout (GDBusProxy *proxy); /* Manager group */ GOptionGroup *mmcli_manager_get_option_group (void); |