From 16c6b2f8f3cf7f5770e3ba32a4692e79ecadb18a Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Tue, 7 Jul 2020 16:46:05 +0300 Subject: [PATCH] [mms-engine] Read D-Bus type from the config file Now that it's a particularly useful feature but somehow it was missed, let it be there for completeness sake. --- mms-engine/main.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/mms-engine/main.c b/mms-engine/main.c index a4121a3..d0ac496 100644 --- a/mms-engine/main.c +++ b/mms-engine/main.c @@ -1,6 +1,6 @@ /* - * Copyright (C) 2013-2019 Jolla Ltd. - * Copyright (C) 2013-2019 Slava Monich + * Copyright (C) 2013-2020 Jolla Ltd. + * Copyright (C) 2013-2020 Slava Monich * Copyright (C) 2019 Open Mobile Platform LLC. * * This program is free software; you can redistribute it and/or modify @@ -302,6 +302,7 @@ void mms_app_dbus_config_init( MMSEngineDbusConfig* dbus) { + dbus->type = G_BUS_TYPE_SYSTEM; dbus->engine_access = mms_app_dbus_policy_new(&mms_engine_default_dbus_policy); dbus->tx_list_access = @@ -327,7 +328,21 @@ mms_app_dbus_config_parse( MMSEngineDbusConfig* dbus) { const char* group = SETTINGS_DBUS_GROUP; + char* type = g_key_file_get_string(file, group, SETTINGS_DBUS_TYPE, NULL); + if (type) { + static const char SYSTEM_BUS[] = "system"; + static const char SESSION_BUS[] = "session"; + + if (!g_strcmp0(type, SYSTEM_BUS)) { + dbus->type = G_BUS_TYPE_SYSTEM; + } else if (!g_strcmp0(type, SESSION_BUS)) { + dbus->type = G_BUS_TYPE_SESSION; + } else { + GWARN("Invalid D-Bys type \"%s\"", type); + } + g_free(type); + } dbus->engine_access = mms_app_dbus_config_update(dbus->engine_access, file, group, SETTINGS_DBUS_ENGINE_ACCESS, &mms_engine_default_dbus_policy); @@ -493,6 +508,7 @@ mms_app_parse_options( } if (ok) { /* Parse the rest of the command line */ + session_bus = (opt->dbus.type == G_BUS_TYPE_SESSION); ok = g_option_context_parse(options, &argc, &argv, &error); } else if (error) { /* Improve error message by prepending the file name */