context: new '--test-session' allows launching the MM daemon in the session bus

This commit is contained in:
Aleksander Morgado
2013-11-22 11:27:14 +01:00
parent 46ff06ff80
commit bf57da537d
4 changed files with 49 additions and 10 deletions

View File

@@ -2,4 +2,4 @@
[D-BUS Service]
Name=org.freedesktop.ModemManager1
Exec=@abs_top_builddir@/src/ModemManager
Exec=@abs_top_builddir@/src/ModemManager --test-session

View File

@@ -125,10 +125,11 @@ main (int argc, char *argv[])
g_unix_signal_add (SIGTERM, quit_cb, NULL);
g_unix_signal_add (SIGINT, quit_cb, NULL);
mm_info ("ModemManager (version " MM_DIST_VERSION ") starting...");
mm_info ("ModemManager (version " MM_DIST_VERSION ") starting in %s bus...",
mm_context_get_test_session () ? "session" : "system");
/* Acquire name, don't allow replacement */
name_id = g_bus_own_name (G_BUS_TYPE_SYSTEM,
name_id = g_bus_own_name (mm_context_get_test_session () ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM,
MM_DBUS_SERVICE,
G_BUS_NAME_OWNER_FLAGS_NONE,
bus_acquired_cb,

View File

@@ -17,7 +17,9 @@
#include "mm-context.h"
/*****************************************************************************/
/* Application context */
static gboolean debug;
static const gchar *log_level;
static const gchar *log_file;
@@ -63,6 +65,38 @@ mm_context_get_relative_timestamps (void)
return rel_ts;
}
/*****************************************************************************/
/* Test context */
static gboolean test_session;
static const GOptionEntry test_entries[] = {
{ "test-session", 0, 0, G_OPTION_ARG_NONE, &test_session, "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;
}
gboolean
mm_context_get_test_session (void)
{
return test_session;
}
/*****************************************************************************/
void
mm_context_init (gint argc,
gchar **argv)
@@ -73,6 +107,7 @@ mm_context_init (gint argc,
ctx = g_option_context_new (NULL);
g_option_context_set_summary (ctx, "DBus system service to communicate with modems.");
g_option_context_add_main_entries (ctx, entries, NULL);
g_option_context_add_group (ctx, test_get_option_group ());
if (!g_option_context_parse (ctx, &argc, &argv, &error)) {
g_warning ("%s\n", error->message);

View File

@@ -27,4 +27,7 @@ const gchar *mm_context_get_log_file (void);
gboolean mm_context_get_timestamps (void);
gboolean mm_context_get_relative_timestamps (void);
/* Testing support */
gboolean mm_context_get_test_session (void);
#endif /* MM_CONTEXT_H */