diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2022-02-16 00:02:44 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2022-02-16 00:10:49 +0100 |
commit | dc9e28f3a690fe66c6a1a9d3359d35d802264c3b (patch) | |
tree | abed080b3c6c0bef9eee2d5ab1e5d576bebcd20c /cli | |
parent | 7c713b53a411629f297332fc189472ee8ec06b72 (diff) | |
download | ModemManager-dc9e28f3a690fe66c6a1a9d3359d35d802264c3b.tar.gz |
cli: new --test-session option to use the session bus
Diffstat (limited to 'cli')
-rw-r--r-- | cli/mmcli.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/cli/mmcli.c b/cli/mmcli.c index e10267a37..b86c8d92f 100644 --- a/cli/mmcli.c +++ b/cli/mmcli.c @@ -43,7 +43,7 @@ static GMainLoop *loop; static GCancellable *cancellable; -/* Context */ +/* Main context */ static gboolean output_keyvalue_flag; static gboolean output_json_flag; static gboolean verbose_flag; @@ -79,6 +79,31 @@ static GOptionEntry main_entries[] = { { NULL } }; +/* Test context */ +static gboolean test_session_flag; + +static GOptionEntry test_entries[] = { + { "test-session", 0, 0, G_OPTION_ARG_NONE, &test_session_flag, + "Run in session DBus", + NULL + }, + { NULL } +}; + +static GOptionGroup * +test_get_option_group (void) +{ + GOptionGroup *group; + + group = g_option_group_new ("test", + "Test options:", + "Show test options", + NULL, + NULL); + g_option_group_add_entries (group, test_entries); + return group; +} + static void signals_handler (int signum) { @@ -243,6 +268,8 @@ main (gint argc, gchar **argv) mmcli_sms_get_option_group ()); g_option_context_add_group (context, mmcli_call_get_option_group ()); + g_option_context_add_group (context, + test_get_option_group ()); g_option_context_add_main_entries (context, main_entries, NULL); g_option_context_parse (context, &argc, &argv, NULL); g_option_context_free (context); @@ -281,7 +308,7 @@ main (gint argc, gchar **argv) signal (SIGTERM, signals_handler); /* Setup dbus connection to use */ - connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); + connection = g_bus_get_sync (test_session_flag ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM, NULL, &error); if (!connection) { g_printerr ("error: couldn't get bus: %s\n", error ? error->message : "unknown error"); |