diff --git a/mms-engine/main.c b/mms-engine/main.c index 0c568f5..030748c 100644 --- a/mms-engine/main.c +++ b/mms-engine/main.c @@ -35,11 +35,8 @@ typedef struct mms_app_options { GBusType bus_type; int flags; - char* dir; - char* user_agent; - char* uaprof; - MMSConfig config; - MMSSettingsSimData settings; + MMSConfigCopy global; + MMSSettingsSimDataCopy settings; } MMSAppOptions; /* All known log modules */ @@ -163,50 +160,59 @@ mms_app_parse_options( gboolean ok; GError* error = NULL; gboolean session_bus = FALSE; + char* config_file = NULL; #ifdef MMS_VERSION_STRING gboolean print_version = FALSE; #endif + char* ua = NULL; + char* uaprof = NULL; + char* root_dir = NULL; gboolean log_modules = FALSE; gboolean keep_running = FALSE; gint size_limit_kb = -1; gdouble megapixels = -1; char* root_dir_help = g_strdup_printf( "Root directory for MMS files [%s]", - opt->config.root_dir); + opt->global.config.root_dir); char* retry_secs_help = g_strdup_printf( "Retry period in seconds [%d]", - opt->config.retry_secs); + opt->global.config.retry_secs); char* idle_secs_help = g_strdup_printf( "Inactivity timeout in seconds [%d]", - opt->config.idle_secs); + opt->global.config.idle_secs); char* description = gutil_log_description(NULL, 0); GOptionContext* options; GOptionEntry entries[] = { { "session", 0, 0, G_OPTION_ARG_NONE, &session_bus, "Use session bus (default is system)", NULL }, +#define OPT_CONFIG_INDEX 1 + { "config", 'c', 0, G_OPTION_ARG_FILENAME, + &config_file, "Use the specified config file [" + MMS_ENGINE_CONFIG_FILE "]", "FILE" }, { "root-dir", 'd', 0, G_OPTION_ARG_FILENAME, - &opt->dir, root_dir_help, "DIR" }, + &root_dir, root_dir_help, "DIR" }, { "retry-secs", 'r', 0, G_OPTION_ARG_INT, - &opt->config.retry_secs, retry_secs_help, "SEC" }, + &opt->global.config.retry_secs, retry_secs_help, "SEC" }, { "idle-secs", 'i', 0, G_OPTION_ARG_INT, - &opt->config.idle_secs, idle_secs_help, "SEC" }, + &opt->global.config.idle_secs, idle_secs_help, "SEC" }, { "size-limit", 's', 0, G_OPTION_ARG_INT, &size_limit_kb, "Maximum size for outgoing messages", "KB" }, { "pix-limit", 'p', 0, G_OPTION_ARG_DOUBLE, &megapixels, "Maximum pixel count for outgoing images", "MPIX" }, { "user-agent", 'u', 0, G_OPTION_ARG_STRING, - &opt->user_agent, "The value of the User-Agent header", "STRING" }, + &ua, "The value of the User-Agent header", "STRING" }, { "x-wap-profile", 'x', 0, G_OPTION_ARG_STRING, - &opt->uaprof, "User agent profile", "URL" }, + &uaprof, "User agent profile", "URL" }, { "keep-running", 'k', 0, G_OPTION_ARG_NONE, &keep_running, "Keep running after everything is done", NULL }, { "keep-temp-files", 't', 0, G_OPTION_ARG_NONE, - &opt->config.keep_temp_files, + &opt->global.config.keep_temp_files, "Don't delete temporary files", NULL }, { "attic", 'a', 0, G_OPTION_ARG_NONE, - &opt->config.attic_enabled, + &opt->global.config.attic_enabled, "Store unrecognized push messages in the attic", NULL }, +#define OPT_VERBOSE_INDEX 12 { "verbose", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, mms_app_option_verbose, "Be verbose (equivalent to -l=verbose)", NULL }, @@ -223,11 +229,65 @@ mms_app_parse_options( { NULL } }; + /* + * First pre-parse the command line to get the config file name. + * Only then we can initialize the defaults and parse the rest. + * Verbose option is handled here too, in order to allow verbose + * logging during config file parsing. + */ + GOptionContext* config_options; + GOptionEntry config_entries[3]; + memset(config_entries, 0, sizeof(config_entries)); + config_entries[0] = entries[OPT_VERBOSE_INDEX]; + config_entries[1] = entries[OPT_CONFIG_INDEX]; + + /* + * Initialize the main parsing context. We would still need it + * even if the preparsing fails - to print the help + */ options = g_option_context_new("- part of Jolla MMS system"); g_option_context_add_main_entries(options, entries, NULL); g_option_context_set_description(options, description); - ok = g_option_context_parse(options, &argc, &argv, &error); + + /* Pre-parsing context */ + config_options = g_option_context_new(NULL); + g_option_context_add_main_entries(config_options, config_entries, NULL); + g_option_context_set_help_enabled(config_options, FALSE); + g_option_context_set_ignore_unknown_options(config_options, TRUE); + ok = g_option_context_parse(config_options, &argc, &argv, &error); + + /* + * If pre-parsing succeeds, we need to read the config before + * parsing the rest of the command line, to allow command line + * options to overwrite those specified in the config file. + */ + if (ok) { + if (config_file) { + /* Config file was specified on the command line */ + ok = mms_settings_load_defaults(config_file, + &opt->global, &opt->settings, &error); + } else { + /* The default config file may be (and usually is) missing */ + if (g_file_test(MMS_ENGINE_CONFIG_FILE, G_FILE_TEST_EXISTS)) { + mms_settings_load_defaults(MMS_ENGINE_CONFIG_FILE, + &opt->global, &opt->settings, NULL); + } + } + if (ok) { + /* Parse the rest of the command line */ + ok = g_option_context_parse(options, &argc, &argv, &error); + } else if (error) { + /* Improve error message by prepending the file name */ + GError* details = g_error_new(error->domain, error->code, + "%s: %s", config_file, error->message); + g_error_free(error); + error = details; + } + } + g_option_context_free(options); + g_option_context_free(config_options); + g_free(config_file); g_free(root_dir_help); g_free(retry_secs_help); g_free(idle_secs_help); @@ -237,19 +297,18 @@ mms_app_parse_options( fprintf(stderr, "%s\n", GERRMSG(error)); g_error_free(error); *result = RET_ERR; - return FALSE; } else if (log_modules) { unsigned int i; for (i=0; iname); } *result = RET_OK; - return FALSE; + ok = FALSE; #ifdef MMS_VERSION_STRING } else if (print_version) { printf("MMS engine %s\n", MMS_VERSION_STRING); *result = RET_OK; - return FALSE; + ok = FALSE; #endif } else { #ifdef MMS_VERSION_STRING @@ -258,22 +317,30 @@ mms_app_parse_options( GINFO("Starting"); #endif if (size_limit_kb >= 0) { - opt->settings.size_limit = size_limit_kb * 1024; + opt->settings.data.size_limit = size_limit_kb * 1024; opt->flags |= MMS_ENGINE_FLAG_OVERRIDE_SIZE_LIMIT; } if (megapixels >= 0) { - opt->settings.max_pixels = (int)(megapixels*1000)*1000; + opt->settings.data.max_pixels = (int)(megapixels*1000)*1000; opt->flags |= MMS_ENGINE_FLAG_OVERRIDE_MAX_PIXELS; } - if (opt->user_agent) { - opt->settings.user_agent = opt->user_agent; + if (ua) { + g_free(opt->settings.user_agent); + opt->settings.data.user_agent = opt->settings.user_agent = ua; opt->flags |= MMS_ENGINE_FLAG_OVERRIDE_USER_AGENT; + ua = NULL; } - if (opt->uaprof) { - opt->settings.uaprof = opt->uaprof; + if (uaprof) { + g_free(opt->settings.uaprof); + opt->settings.data.uaprof = opt->settings.uaprof = uaprof; opt->flags |= MMS_ENGINE_FLAG_OVERRIDE_UAPROF; + uaprof = NULL; + } + if (root_dir) { + g_free(opt->global.root_dir); + opt->global.config.root_dir = opt->global.root_dir = root_dir; + root_dir = NULL; } - if (opt->dir) opt->config.root_dir = opt->dir; if (keep_running) opt->flags |= MMS_ENGINE_FLAG_KEEP_RUNNING; if (session_bus) { GDEBUG("Attaching to session bus"); @@ -283,24 +350,32 @@ mms_app_parse_options( opt->bus_type = G_BUS_TYPE_SYSTEM; } *result = RET_OK; - return TRUE; } + + g_free(ua); + g_free(uaprof); + g_free(root_dir); + return ok; } int main(int argc, char* argv[]) { int result = RET_ERR; - MMSAppOptions opt = {0}; + MMSAppOptions opt; + MMSConfig* config = &opt.global.config; + MMSSettingsSimData* settings = &opt.settings.data; + mms_lib_init(argv[0]); gofono_log.name = "mms-ofono"; gutil_log_default.name = MMS_APP_LOG_PREFIX; - mms_lib_default_config(&opt.config); - mms_settings_sim_data_default(&opt.settings); + memset(&opt, 0, sizeof(opt)); + mms_lib_default_config(config); + mms_settings_sim_data_default(settings); if (mms_app_parse_options(&opt, argc, argv, &result)) { MMSEngine* engine; /* Create engine instance. This may fail */ - engine = mms_engine_new(&opt.config, &opt.settings, opt.flags, + engine = mms_engine_new(config, settings, opt.flags, mms_app_log_modules, G_N_ELEMENTS(mms_app_log_modules)); if (engine) { @@ -329,9 +404,8 @@ int main(int argc, char* argv[]) if (gutil_log_func == gutil_log_syslog) { closelog(); } - g_free(opt.dir); - g_free(opt.user_agent); - g_free(opt.uaprof); + g_free(opt.global.root_dir); + mms_settings_sim_data_reset(&opt.settings); mms_lib_deinit(); return result; } diff --git a/mms-engine/mms_engine.c b/mms-engine/mms_engine.c index 0a4c97b..4c20655 100644 --- a/mms-engine/mms_engine.c +++ b/mms-engine/mms_engine.c @@ -463,7 +463,7 @@ mms_engine_handle_migrate_settings( MMSEngine* mms_engine_new( const MMSConfig* config, - const MMSSettingsSimData* override, + const MMSSettingsSimData* defaults, unsigned int flags, MMSLogModule* log_modules[], int log_count) @@ -472,28 +472,26 @@ mms_engine_new( if (cm) { MMSEngine* mms = g_object_new(MMS_TYPE_ENGINE, NULL); MMSHandler* handler = mms_handler_dbus_new(); - MMSSettings* settings = mms_settings_dconf_new(config); + MMSSettings* settings = mms_settings_dconf_new(config, defaults); MMSTransferList* txlist = mms_transfer_list_dbus_new(); + static const struct _mms_engine_settings_flags_map { +#define MAP_(x) \ + MMS_ENGINE_FLAG_OVERRIDE_##x, \ + MMS_SETTINGS_FLAG_OVERRIDE_##x + int engine_flag; + int settings_flag; + } flags_map [] = { + { MAP_(USER_AGENT)}, + { MAP_(UAPROF) }, + { MAP_(SIZE_LIMIT) }, + { MAP_(MAX_PIXELS) } + }; - if (flags & MMS_ENGINE_FLAG_OVERRIDE_USER_AGENT) { - settings->flags |= MMS_SETTINGS_FLAG_OVERRIDE_USER_AGENT; - g_free(settings->sim_defaults.user_agent); - settings->sim_defaults.data.user_agent = - settings->sim_defaults.user_agent = g_strdup(override->user_agent); - } - if (flags & MMS_ENGINE_FLAG_OVERRIDE_UAPROF) { - settings->flags |= MMS_SETTINGS_FLAG_OVERRIDE_UAPROF; - g_free(settings->sim_defaults.uaprof); - settings->sim_defaults.data.uaprof = - settings->sim_defaults.uaprof = g_strdup(override->uaprof); - } - if (flags & MMS_ENGINE_FLAG_OVERRIDE_SIZE_LIMIT) { - settings->flags |= MMS_SETTINGS_FLAG_OVERRIDE_SIZE_LIMIT; - settings->sim_defaults.data.size_limit = override->size_limit; - } - if (flags & MMS_ENGINE_FLAG_OVERRIDE_MAX_PIXELS) { - settings->flags |= MMS_SETTINGS_FLAG_OVERRIDE_MAX_PIXELS; - settings->sim_defaults.data.max_pixels = override->max_pixels; + unsigned int i; + for (i=0; iflags |= flags_map[i].settings_flag; + } } mms->dispatcher = mms_dispatcher_new(settings, cm, handler, txlist); diff --git a/mms-engine/mms_engine.h b/mms-engine/mms_engine.h index 88a8a11..9344452 100644 --- a/mms-engine/mms_engine.h +++ b/mms-engine/mms_engine.h @@ -10,7 +10,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * */ #ifndef JOLLA_MMS_ENGINE_H @@ -31,12 +30,17 @@ #define MMS_ENGINE_FLAG_OVERRIDE_MAX_PIXELS (0x08) #define MMS_ENGINE_FLAG_OVERRIDE_UAPROF (0x10) +#ifndef MMS_ENGINE_CONFIG_FILE +/* Default config file */ +# define MMS_ENGINE_CONFIG_FILE "/etc/mms-engine.conf" +#endif /* MMS_ENGINE_CONFIG_FILE */ + typedef struct mms_engine MMSEngine; MMSEngine* mms_engine_new( const MMSConfig* config, - const MMSSettingsSimData* settings, + const MMSSettingsSimData* defaults, unsigned int flags, MMSLogModule* log_modules[], int log_count); diff --git a/mms-lib/include/mms_lib_log.h b/mms-lib/include/mms_lib_log.h index 04c2093..00d2f70 100644 --- a/mms-lib/include/mms_lib_log.h +++ b/mms-lib/include/mms_lib_log.h @@ -20,6 +20,7 @@ #define MMS_LIB_LOG_MODULES(log) \ log(mms_dispatcher_log)\ log(mms_settings_log)\ + log(mms_settings_log_dconf)\ log(mms_transfer_list_log)\ log(mms_handler_log)\ log(mms_message_log)\ diff --git a/mms-lib/include/mms_settings.h b/mms-lib/include/mms_settings.h index 97ca0c2..382a53e 100644 --- a/mms-lib/include/mms_settings.h +++ b/mms-lib/include/mms_settings.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2014 Jolla Ltd. + * Copyright (C) 2014-2016 Jolla Ltd. + * Contact: Slava Monich * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -9,7 +10,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * */ #ifndef JOLLA_MMS_SETTINGS_H @@ -26,6 +26,15 @@ struct mms_config { gboolean attic_enabled; /* Keep unrecognized push message in attic */ }; +typedef struct mms_config_copy { + MMSConfig config; /* Config data */ + char* root_dir; /* Allocated copy of root_dir */ +} MMSConfigCopy; + +#define MMS_CONFIG_DEFAULT_ROOT_DIR "/tmp/mms" +#define MMS_CONFIG_DEFAULT_RETRY_SECS (15) +#define MMS_CONFIG_DEFAULT_IDLE_SECS (20) + /* Persistent mutable per-SIM settings */ struct mms_settings_sim_data { const char* user_agent; /* User agent string */ @@ -64,8 +73,8 @@ typedef struct mms_settings_class { const char* imsi); } MMSSettingsClass; -/* Default values. If the GSettings backend is used (mms-settings-dconf) - * then these should match the default values defined in the GSettings +/* Default values. If the GSettings backend is used then these + * should match the default values defined in the GSettings * schema (org.nemomobile.mms.sim.gschema.xml) */ #define MMS_SETTINGS_DEFAULT_USER_AGENT "Mozilla/5.0 (Sailfish; Jolla)" #define MMS_SETTINGS_DEFAULT_UAPROF "http://static.jolla.com/uaprof/Jolla.xml" @@ -99,6 +108,13 @@ void mms_settings_sim_data_default( MMSSettingsSimData* data); +gboolean +mms_settings_load_defaults( + const char* path, + MMSConfigCopy* config, + MMSSettingsSimDataCopy* simconfig, + GError** error); + void mms_settings_set_sim_defaults( MMSSettings* settings, diff --git a/mms-lib/src/mms_lib_util.c b/mms-lib/src/mms_lib_util.c index 872bdb3..9cd9202 100644 --- a/mms-lib/src/mms_lib_util.c +++ b/mms-lib/src/mms_lib_util.c @@ -1,5 +1,6 @@ /* - * Copyright (C) 2013-2014 Jolla Ltd. + * Copyright (C) 2013-2016 Jolla Ltd. + * Contact: Slava Monich * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -9,7 +10,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * */ #include "mms_lib_util.h" @@ -19,10 +19,6 @@ # include #endif -#define MMS_DEFAULT_ROOT_DIR "/tmp/mms" -#define MMS_DEFAULT_RETRY_SECS (15) -#define MMS_DEFAULT_IDLE_SECS (20) - /** * MMS error domain */ @@ -68,9 +64,9 @@ void mms_lib_default_config( MMSConfig* config) { - config->root_dir = MMS_DEFAULT_ROOT_DIR; - config->retry_secs = MMS_DEFAULT_RETRY_SECS; - config->idle_secs = MMS_DEFAULT_IDLE_SECS; + config->root_dir = MMS_CONFIG_DEFAULT_ROOT_DIR; + config->retry_secs = MMS_CONFIG_DEFAULT_RETRY_SECS; + config->idle_secs = MMS_CONFIG_DEFAULT_IDLE_SECS; config->keep_temp_files = FALSE; config->attic_enabled = FALSE; } diff --git a/mms-lib/src/mms_settings.c b/mms-lib/src/mms_settings.c index 592a5e9..cde4eb9 100644 --- a/mms-lib/src/mms_settings.c +++ b/mms-lib/src/mms_settings.c @@ -1,5 +1,6 @@ /* - * Copyright (C) 2014 Jolla Ltd. + * Copyright (C) 2014-2016 Jolla Ltd. + * Contact: Slava Monich * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -9,12 +10,29 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * */ #include "mms_settings.h" -G_DEFINE_TYPE(MMSSettings, mms_settings, G_TYPE_OBJECT); +/* Logging */ +#define GLOG_MODULE_NAME mms_settings_log +#include "mms_lib_log.h" +#include +GLOG_MODULE_DEFINE("mms-settings"); + +#define SETTINGS_GLOBAL_GROUP "Global" +#define SETTINGS_GLOBAL_KEY_ROOT_DIR "RootDir" +#define SETTINGS_GLOBAL_KEY_RETRY_SEC "RetryDelay" +#define SETTINGS_GLOBAL_KEY_IDLE_SEC "IdleTimeout" + +#define SETTINGS_DEFAULTS_GROUP "Defaults" +#define SETTINGS_DEFAULTS_KEY_USER_AGENT "UserAgent" +#define SETTINGS_DEFAULTS_KEY_UAPROF "UAProfile" +#define SETTINGS_DEFAULTS_KEY_SIZE_LIMIT "SizeLimit" +#define SETTINGS_DEFAULTS_KEY_MAX_PIXELS "MaxPixels" +#define SETTINGS_DEFAULTS_KEY_ALLOW_DR "SendDeliveryReport" + +G_DEFINE_TYPE(MMSSettings, mms_settings, G_TYPE_OBJECT) #define MMS_SETTINGS_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS((obj), MMS_TYPE_SETTINGS, MMSSettingsClass)) #define MMS_SETTINGS(obj) \ @@ -47,6 +65,124 @@ mms_settings_sim_data_default( data->allow_dr = MMS_SETTINGS_DEFAULT_ALLOW_DR; } +static +void +mms_settings_parse_global_config( + MMSConfigCopy* global, + GKeyFile* file) +{ + const char* group = SETTINGS_GLOBAL_GROUP; + GError* error = NULL; + char* s; + int i; + + s = g_key_file_get_string(file, group, + SETTINGS_GLOBAL_KEY_ROOT_DIR, NULL); + if (s) { + g_free(global->root_dir); + global->config.root_dir = global->root_dir = s; + GDEBUG("%s = %s", SETTINGS_GLOBAL_KEY_ROOT_DIR, s); + } + + i = g_key_file_get_integer(file, group, + SETTINGS_GLOBAL_KEY_RETRY_SEC, &error); + if (error) { + g_error_free(error); + error = NULL; + } else if (i >= 0) { + global->config.retry_secs = i; + GDEBUG("%s = %d", SETTINGS_GLOBAL_KEY_RETRY_SEC, i); + } + + i = g_key_file_get_integer(file, group, + SETTINGS_GLOBAL_KEY_IDLE_SEC, &error); + if (error) { + g_error_free(error); + error = NULL; + } else if (i >= 0) { + global->config.idle_secs = i; + GDEBUG("%s = %d", SETTINGS_GLOBAL_KEY_IDLE_SEC, i); + } +} + +static +void +mms_settings_parse_sim_config( + MMSSettingsSimDataCopy* defaults, + GKeyFile* file) +{ + const char* group = SETTINGS_DEFAULTS_GROUP; + GError* error = NULL; + gboolean b; + char* s; + int i; + + s = g_key_file_get_string(file, group, + SETTINGS_DEFAULTS_KEY_USER_AGENT, NULL); + if (s) { + g_free(defaults->user_agent); + defaults->data.user_agent = defaults->user_agent = s; + GDEBUG("%s = %s", SETTINGS_DEFAULTS_KEY_USER_AGENT, s); + } + + s = g_key_file_get_string(file, group, + SETTINGS_DEFAULTS_KEY_UAPROF, NULL); + if (s) { + g_free(defaults->uaprof); + defaults->data.uaprof = defaults->uaprof = s; + GDEBUG("%s = %s", SETTINGS_DEFAULTS_KEY_UAPROF, s); + } + + i = g_key_file_get_integer(file, group, + SETTINGS_DEFAULTS_KEY_SIZE_LIMIT, &error); + if (error) { + g_error_free(error); + error = NULL; + } else if (i > 0) { + defaults->data.size_limit = i; + GDEBUG("%s = %d", SETTINGS_DEFAULTS_KEY_SIZE_LIMIT, i); + } + + i = g_key_file_get_integer(file, group, + SETTINGS_DEFAULTS_KEY_MAX_PIXELS, &error); + if (error) { + g_error_free(error); + error = NULL; + } else if (i > 0) { + defaults->data.max_pixels = i; + GDEBUG("%s = %d", SETTINGS_DEFAULTS_KEY_MAX_PIXELS, i); + } + + b = g_key_file_get_boolean(file, group, + SETTINGS_DEFAULTS_KEY_ALLOW_DR, &error); + if (error) { + g_error_free(error); + error = NULL; + } else { + GDEBUG("%s = %s", SETTINGS_DEFAULTS_KEY_ALLOW_DR, b ? "on" : "off"); + defaults->data.allow_dr = b; + } +} + +gboolean +mms_settings_load_defaults( + const char* path, + MMSConfigCopy* config, + MMSSettingsSimDataCopy* data, + GError** error) +{ + gboolean ok = FALSE; + GKeyFile* file = g_key_file_new(); + if (g_key_file_load_from_file(file, path, 0, error)) { + GDEBUG("Loading %s", path); + mms_settings_parse_global_config(config, file); + mms_settings_parse_sim_config(data, file); + ok = TRUE; + } + g_key_file_free(file); + return ok; +} + void mms_settings_sim_data_copy( MMSSettingsSimDataCopy* dest, diff --git a/mms-settings-dconf/include/mms_settings_dconf.h b/mms-settings-dconf/include/mms_settings_dconf.h index 8596637..993bf7d 100644 --- a/mms-settings-dconf/include/mms_settings_dconf.h +++ b/mms-settings-dconf/include/mms_settings_dconf.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2014 Jolla Ltd. + * Copyright (C) 2014-2016 Jolla Ltd. + * Contact: Slava Monich * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -9,7 +10,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * */ #ifndef JOLLA_MMS_SETTINGS_DCONF_H @@ -19,7 +19,8 @@ MMSSettings* mms_settings_dconf_new( - const MMSConfig* config); + const MMSConfig* config, + const MMSSettingsSimData* defaults); #endif /* JOLLA_MMS_SETTINGS_DCONF_H */ diff --git a/mms-settings-dconf/src/mms_settings_dconf.c b/mms-settings-dconf/src/mms_settings_dconf.c index 0443f10..01dec7c 100644 --- a/mms-settings-dconf/src/mms_settings_dconf.c +++ b/mms-settings-dconf/src/mms_settings_dconf.c @@ -16,7 +16,7 @@ #include /* Logging */ -#define GLOG_MODULE_NAME mms_settings_log +#define GLOG_MODULE_NAME mms_settings_log_dconf #include "mms_lib_log.h" #include GLOG_MODULE_DEFINE("mms-settings-dconf"); @@ -439,9 +439,11 @@ mms_settings_dconf_init( */ MMSSettings* mms_settings_dconf_new( - const MMSConfig* config) + const MMSConfig* config, + const MMSSettingsSimData* defaults) { MMSSettings* settings = g_object_new(MMS_TYPE_SETTINGS_DCONF, NULL); + mms_settings_sim_data_copy(&settings->sim_defaults, defaults); settings->config = config; return settings; }