Skip to content

Commit

Permalink
[mms-engine] Added migrateSettings D-Bus API
Browse files Browse the repository at this point in the history
  • Loading branch information
monich committed Jul 16, 2014
1 parent 518b8e0 commit 5f74c47
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
43 changes: 41 additions & 2 deletions mms-engine/mms_engine.c
Expand Up @@ -27,6 +27,8 @@
struct mms_engine {
GObject parent;
const MMSConfig* config;
MMSConnMan* cm;
MMSSettings* settings;
MMSDispatcher* dispatcher;
MMSDispatcherDelegate dispatcher_delegate;
MMSLogModule** log_modules;
Expand All @@ -46,6 +48,7 @@ struct mms_engine {
gulong set_log_level_signal_id;
gulong set_log_type_signal_id;
gulong get_version_signal_id;
gulong migrate_settings_signal_id;
};

typedef GObjectClass MMSEngineClass;
Expand Down Expand Up @@ -412,6 +415,30 @@ mms_engine_handle_get_version(
return TRUE;
}

/* org.nemomobile.MmsEngine.migrateSettings */
static
gboolean
mms_engine_handle_migrate_settings(
OrgNemomobileMmsEngine* proxy,
GDBusMethodInvocation* call,
const char* imsi,
MMSEngine* engine)
{
char* tmp = NULL;
/* Querying settings will migrate per-SIM settings after upgrading
* from 1.0.21 or older version of mme-engine */
MMS_DEBUG_("%s", imsi);
if (!imsi || !imsi[0]) {
imsi = tmp = mms_connman_default_imsi(engine->cm);
}
if (imsi) {
mms_settings_get_sim_data(engine->settings, imsi);
}
org_nemomobile_mms_engine_complete_migrate_settings(proxy, call);
g_free(tmp);
return TRUE;
}

MMSEngine*
mms_engine_new(
const MMSConfig* config,
Expand Down Expand Up @@ -448,8 +475,6 @@ mms_engine_new(
}

mms->dispatcher = mms_dispatcher_new(settings, cm, handler);
mms_settings_unref(settings);
mms_connman_unref(cm);
mms_handler_unref(handler);
mms_dispatcher_set_delegate(mms->dispatcher,
&mms->dispatcher_delegate);
Expand All @@ -458,7 +483,9 @@ mms_engine_new(
mms->keep_running = TRUE;
}

mms->cm = cm;
mms->config = config;
mms->settings = settings;
mms->log_modules = log_modules;
mms->log_count = log_count;
mms->proxy = org_nemomobile_mms_engine_skeleton_new();
Expand Down Expand Up @@ -489,6 +516,9 @@ mms_engine_new(
mms->get_version_signal_id =
g_signal_connect(mms->proxy, "handle-get-version",
G_CALLBACK(mms_engine_handle_get_version), mms);
mms->migrate_settings_signal_id =
g_signal_connect(mms->proxy, "handle-migrate-settings",
G_CALLBACK(mms_engine_handle_migrate_settings), mms);

return mms;
}
Expand Down Expand Up @@ -611,6 +641,7 @@ mms_engine_dispose(
g_signal_handler_disconnect(e->proxy, e->set_log_level_signal_id);
g_signal_handler_disconnect(e->proxy, e->set_log_type_signal_id);
g_signal_handler_disconnect(e->proxy, e->get_version_signal_id);
g_signal_handler_disconnect(e->proxy, e->migrate_settings_signal_id);
g_object_unref(e->proxy);
e->proxy = NULL;
}
Expand All @@ -619,6 +650,14 @@ mms_engine_dispose(
mms_dispatcher_unref(e->dispatcher);
e->dispatcher = NULL;
}
if (e->settings) {
mms_settings_unref(e->settings);
e->settings = NULL;
}
if (e->cm) {
mms_connman_unref(e->cm);
e->cm = NULL;
}
G_OBJECT_CLASS(mms_engine_parent_class)->dispose(object);
}

Expand Down
5 changes: 5 additions & 0 deletions mms-engine/org.nemomobile.MmsEngine.xml
Expand Up @@ -206,5 +206,10 @@
<arg type="s" name="suffix" direction="out"/>
</method>

<!-- Since 1.0.22 -->
<method name="migrateSettings">
<arg type="s" name="imsi" direction="in"/>
</method>

</interface>
</node>

0 comments on commit 5f74c47

Please sign in to comment.