cli: allow modifying default DBus timeout with `--timeout'
By default 30s will be used for every operation.
This commit is contained in:
@@ -248,6 +248,9 @@ get_manager_ready (GObject *source,
|
|||||||
{
|
{
|
||||||
ctx->manager = mmcli_get_manager_finish (result);
|
ctx->manager = mmcli_get_manager_finish (result);
|
||||||
|
|
||||||
|
/* Setup operation timeout */
|
||||||
|
mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->manager));
|
||||||
|
|
||||||
/* Request to set log level? */
|
/* Request to set log level? */
|
||||||
if (set_logging_str) {
|
if (set_logging_str) {
|
||||||
mm_manager_set_logging (ctx->manager,
|
mm_manager_set_logging (ctx->manager,
|
||||||
@@ -327,6 +330,9 @@ mmcli_manager_run_synchronous (GDBusConnection *connection)
|
|||||||
ctx = g_new0 (Context, 1);
|
ctx = g_new0 (Context, 1);
|
||||||
ctx->manager = mmcli_get_manager_sync (connection);
|
ctx->manager = mmcli_get_manager_sync (connection);
|
||||||
|
|
||||||
|
/* Setup operation timeout */
|
||||||
|
mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->manager));
|
||||||
|
|
||||||
/* Request to set log level? */
|
/* Request to set log level? */
|
||||||
if (set_logging_str) {
|
if (set_logging_str) {
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
@@ -405,6 +405,12 @@ get_modem_ready (GObject *source,
|
|||||||
ctx->modem_3gpp = mm_object_get_modem_3gpp (ctx->object);
|
ctx->modem_3gpp = mm_object_get_modem_3gpp (ctx->object);
|
||||||
ctx->modem_3gpp_ussd = mm_object_get_modem_3gpp_ussd (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 ();
|
ensure_modem_3gpp ();
|
||||||
|
|
||||||
if (ussd_status_flag)
|
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 = mm_object_get_modem_3gpp (ctx->object);
|
||||||
ctx->modem_3gpp_ussd = mm_object_get_modem_3gpp_ussd (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 ();
|
ensure_modem_3gpp ();
|
||||||
|
|
||||||
if (scan_flag)
|
if (scan_flag)
|
||||||
|
@@ -162,6 +162,10 @@ get_modem_ready (GObject *source,
|
|||||||
ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
|
ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
|
||||||
ctx->modem_cdma = mm_object_get_modem_cdma (ctx->object);
|
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 ();
|
ensure_modem_cdma ();
|
||||||
|
|
||||||
/* Request to activate the modem? */
|
/* Request to activate the modem? */
|
||||||
@@ -207,6 +211,10 @@ mmcli_modem_cdma_run_synchronous (GDBusConnection *connection)
|
|||||||
&ctx->manager);
|
&ctx->manager);
|
||||||
ctx->modem_cdma = mm_object_get_modem_cdma (ctx->object);
|
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 ();
|
ensure_modem_cdma ();
|
||||||
|
|
||||||
/* Request to activate the modem? */
|
/* Request to activate the modem? */
|
||||||
|
@@ -407,6 +407,10 @@ get_modem_ready (GObject *source,
|
|||||||
ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
|
ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
|
||||||
ctx->modem_location = mm_object_get_modem_location (ctx->object);
|
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 ();
|
ensure_modem_location ();
|
||||||
|
|
||||||
if (status_flag)
|
if (status_flag)
|
||||||
@@ -473,6 +477,10 @@ mmcli_modem_location_run_synchronous (GDBusConnection *connection)
|
|||||||
&ctx->manager);
|
&ctx->manager);
|
||||||
ctx->modem_location = mm_object_get_modem_location (ctx->object);
|
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 ();
|
ensure_modem_location ();
|
||||||
|
|
||||||
/* Request to get location status? */
|
/* Request to get location status? */
|
||||||
|
@@ -252,6 +252,10 @@ get_modem_ready (GObject *source,
|
|||||||
ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
|
ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
|
||||||
ctx->modem_messaging = mm_object_get_modem_messaging (ctx->object);
|
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 ();
|
ensure_modem_messaging ();
|
||||||
|
|
||||||
/* Request to list SMS? */
|
/* Request to list SMS? */
|
||||||
@@ -327,6 +331,10 @@ mmcli_modem_messaging_run_synchronous (GDBusConnection *connection)
|
|||||||
&ctx->manager);
|
&ctx->manager);
|
||||||
ctx->modem_messaging = mm_object_get_modem_messaging (ctx->object);
|
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 ();
|
ensure_modem_messaging ();
|
||||||
|
|
||||||
/* Request to list the SMS? */
|
/* Request to list the SMS? */
|
||||||
|
@@ -323,6 +323,10 @@ get_modem_ready (GObject *source,
|
|||||||
ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
|
ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
|
||||||
ctx->modem_simple = mm_object_get_modem_simple (ctx->object);
|
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 ();
|
ensure_modem_simple ();
|
||||||
|
|
||||||
/* Request to connect the modem? */
|
/* Request to connect the modem? */
|
||||||
@@ -402,6 +406,10 @@ mmcli_modem_simple_run_synchronous (GDBusConnection *connection)
|
|||||||
&ctx->manager);
|
&ctx->manager);
|
||||||
ctx->modem_simple = mm_object_get_modem_simple (ctx->object);
|
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 ();
|
ensure_modem_simple ();
|
||||||
|
|
||||||
if (connect_str)
|
if (connect_str)
|
||||||
|
@@ -202,6 +202,10 @@ get_modem_ready (GObject *source,
|
|||||||
ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
|
ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
|
||||||
ctx->modem_time = mm_object_get_modem_time (ctx->object);
|
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 ();
|
ensure_modem_time ();
|
||||||
|
|
||||||
/* Request to get network time from the modem? */
|
/* Request to get network time from the modem? */
|
||||||
@@ -247,6 +251,10 @@ mmcli_modem_time_run_synchronous (GDBusConnection *connection)
|
|||||||
&ctx->manager);
|
&ctx->manager);
|
||||||
ctx->modem_time = mm_object_get_modem_time (ctx->object);
|
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 ();
|
ensure_modem_time ();
|
||||||
|
|
||||||
/* Request to get network time from the modem? */
|
/* Request to get network time from the modem? */
|
||||||
|
@@ -771,6 +771,14 @@ get_modem_ready (GObject *source,
|
|||||||
ctx->modem_3gpp = mm_object_get_modem_3gpp (ctx->object);
|
ctx->modem_3gpp = mm_object_get_modem_3gpp (ctx->object);
|
||||||
ctx->modem_cdma = mm_object_get_modem_cdma (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)
|
if (info_flag)
|
||||||
g_assert_not_reached ();
|
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_3gpp = mm_object_get_modem_3gpp (ctx->object);
|
||||||
ctx->modem_cdma = mm_object_get_modem_cdma (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? */
|
/* Request to get info from modem? */
|
||||||
if (info_flag) {
|
if (info_flag) {
|
||||||
g_debug ("Printing modem info...");
|
g_debug ("Printing modem info...");
|
||||||
|
@@ -315,6 +315,9 @@ get_sim_ready (GObject *source,
|
|||||||
&ctx->manager,
|
&ctx->manager,
|
||||||
&ctx->object);
|
&ctx->object);
|
||||||
|
|
||||||
|
/* Setup operation timeout */
|
||||||
|
mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->sim));
|
||||||
|
|
||||||
if (info_flag)
|
if (info_flag)
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
|
|
||||||
@@ -402,6 +405,9 @@ mmcli_sim_run_synchronous (GDBusConnection *connection)
|
|||||||
&ctx->manager,
|
&ctx->manager,
|
||||||
&ctx->object);
|
&ctx->object);
|
||||||
|
|
||||||
|
/* Setup operation timeout */
|
||||||
|
mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->sim));
|
||||||
|
|
||||||
/* Request to get info from SIM? */
|
/* Request to get info from SIM? */
|
||||||
if (info_flag) {
|
if (info_flag) {
|
||||||
g_debug ("Printing sim info...");
|
g_debug ("Printing sim info...");
|
||||||
|
@@ -220,6 +220,8 @@ get_sms_ready (GObject *source,
|
|||||||
ctx->sms = mmcli_get_sms_finish (result,
|
ctx->sms = mmcli_get_sms_finish (result,
|
||||||
&ctx->manager,
|
&ctx->manager,
|
||||||
&ctx->object);
|
&ctx->object);
|
||||||
|
/* Setup operation timeout */
|
||||||
|
mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->sms));
|
||||||
|
|
||||||
if (info_flag)
|
if (info_flag)
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
@@ -274,6 +276,9 @@ mmcli_sms_run_synchronous (GDBusConnection *connection)
|
|||||||
&ctx->manager,
|
&ctx->manager,
|
||||||
&ctx->object);
|
&ctx->object);
|
||||||
|
|
||||||
|
/* Setup operation timeout */
|
||||||
|
mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->sms));
|
||||||
|
|
||||||
/* Request to get info from SMS? */
|
/* Request to get info from SMS? */
|
||||||
if (info_flag) {
|
if (info_flag) {
|
||||||
g_debug ("Printing SMS info...");
|
g_debug ("Printing SMS info...");
|
||||||
|
11
cli/mmcli.c
11
cli/mmcli.c
@@ -45,6 +45,7 @@ static GCancellable *cancellable;
|
|||||||
static gboolean verbose_flag;
|
static gboolean verbose_flag;
|
||||||
static gboolean version_flag;
|
static gboolean version_flag;
|
||||||
static gboolean async_flag;
|
static gboolean async_flag;
|
||||||
|
static gint timeout = 30; /* by default, use 30s for all operations */
|
||||||
|
|
||||||
static GOptionEntry main_entries[] = {
|
static GOptionEntry main_entries[] = {
|
||||||
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose_flag,
|
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose_flag,
|
||||||
@@ -59,6 +60,10 @@ static GOptionEntry main_entries[] = {
|
|||||||
"Use asynchronous methods",
|
"Use asynchronous methods",
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
|
{ "timeout", 0, 0, G_OPTION_ARG_INT, &timeout,
|
||||||
|
"Timeout for the operation",
|
||||||
|
"[SECONDS]"
|
||||||
|
},
|
||||||
{ NULL }
|
{ 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
|
gint
|
||||||
main (gint argc, gchar **argv)
|
main (gint argc, gchar **argv)
|
||||||
{
|
{
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
void mmcli_async_operation_done (void);
|
void mmcli_async_operation_done (void);
|
||||||
void mmcli_force_async_operation (void);
|
void mmcli_force_async_operation (void);
|
||||||
void mmcli_force_sync_operation (void);
|
void mmcli_force_sync_operation (void);
|
||||||
|
void mmcli_force_operation_timeout (GDBusProxy *proxy);
|
||||||
|
|
||||||
/* Manager group */
|
/* Manager group */
|
||||||
GOptionGroup *mmcli_manager_get_option_group (void);
|
GOptionGroup *mmcli_manager_get_option_group (void);
|
||||||
|
Reference in New Issue
Block a user