context: new '--test-session' allows launching the MM daemon in the session bus
This commit is contained in:
@@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
[D-BUS Service]
|
[D-BUS Service]
|
||||||
Name=org.freedesktop.ModemManager1
|
Name=org.freedesktop.ModemManager1
|
||||||
Exec=@abs_top_builddir@/src/ModemManager
|
Exec=@abs_top_builddir@/src/ModemManager --test-session
|
||||||
|
@@ -125,10 +125,11 @@ main (int argc, char *argv[])
|
|||||||
g_unix_signal_add (SIGTERM, quit_cb, NULL);
|
g_unix_signal_add (SIGTERM, quit_cb, NULL);
|
||||||
g_unix_signal_add (SIGINT, 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 */
|
/* 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,
|
MM_DBUS_SERVICE,
|
||||||
G_BUS_NAME_OWNER_FLAGS_NONE,
|
G_BUS_NAME_OWNER_FLAGS_NONE,
|
||||||
bus_acquired_cb,
|
bus_acquired_cb,
|
||||||
|
@@ -17,7 +17,9 @@
|
|||||||
|
|
||||||
#include "mm-context.h"
|
#include "mm-context.h"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
/* Application context */
|
/* Application context */
|
||||||
|
|
||||||
static gboolean debug;
|
static gboolean debug;
|
||||||
static const gchar *log_level;
|
static const gchar *log_level;
|
||||||
static const gchar *log_file;
|
static const gchar *log_file;
|
||||||
@@ -63,6 +65,38 @@ mm_context_get_relative_timestamps (void)
|
|||||||
return rel_ts;
|
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
|
void
|
||||||
mm_context_init (gint argc,
|
mm_context_init (gint argc,
|
||||||
gchar **argv)
|
gchar **argv)
|
||||||
@@ -70,17 +104,18 @@ mm_context_init (gint argc,
|
|||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GOptionContext *ctx;
|
GOptionContext *ctx;
|
||||||
|
|
||||||
ctx = g_option_context_new (NULL);
|
ctx = g_option_context_new (NULL);
|
||||||
g_option_context_set_summary (ctx, "DBus system service to communicate with modems.");
|
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_main_entries (ctx, entries, NULL);
|
||||||
|
g_option_context_add_group (ctx, test_get_option_group ());
|
||||||
|
|
||||||
if (!g_option_context_parse (ctx, &argc, &argv, &error)) {
|
if (!g_option_context_parse (ctx, &argc, &argv, &error)) {
|
||||||
g_warning ("%s\n", error->message);
|
g_warning ("%s\n", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_option_context_free (ctx);
|
g_option_context_free (ctx);
|
||||||
|
|
||||||
/* Additional setup to be done on debug mode */
|
/* Additional setup to be done on debug mode */
|
||||||
if (debug) {
|
if (debug) {
|
||||||
|
@@ -27,4 +27,7 @@ const gchar *mm_context_get_log_file (void);
|
|||||||
gboolean mm_context_get_timestamps (void);
|
gboolean mm_context_get_timestamps (void);
|
||||||
gboolean mm_context_get_relative_timestamps (void);
|
gboolean mm_context_get_relative_timestamps (void);
|
||||||
|
|
||||||
|
/* Testing support */
|
||||||
|
gboolean mm_context_get_test_session (void);
|
||||||
|
|
||||||
#endif /* MM_CONTEXT_H */
|
#endif /* MM_CONTEXT_H */
|
||||||
|
Reference in New Issue
Block a user