Commit 9eaae2e3 authored by Slava Monich's avatar Slava Monich

[mms-engine] Added getVersion D-Bus API

Allows applications to determine which version of mms-engine is installed.
parent 374ba410
......@@ -160,7 +160,7 @@ mms_app_parse_options(
gboolean ok;
GError* error = NULL;
gboolean session_bus = FALSE;
#ifdef MMS_ENGINE_VERSION
#ifdef MMS_VERSION_STRING
gboolean print_version = FALSE;
#endif
gboolean log_modules = FALSE;
......@@ -213,7 +213,7 @@ mms_app_parse_options(
"Set log level (repeatable)", "[MODULE:]LEVEL" },
{ "log-modules", 0, 0, G_OPTION_ARG_NONE, &log_modules,
"List available log modules", NULL },
#ifdef MMS_ENGINE_VERSION
#ifdef MMS_VERSION_STRING
{ "version", 0, 0, G_OPTION_ARG_NONE, &print_version,
"Print program version and exit", NULL },
#endif
......@@ -242,18 +242,15 @@ mms_app_parse_options(
}
*result = RET_OK;
return FALSE;
#ifdef MMS_ENGINE_VERSION
# define MMS_STRING__(x) #x
# define MMS_STRING_(x) MMS_STRING__(x)
# define MMS_VERVION_STRING MMS_STRING_(MMS_ENGINE_VERSION)
#ifdef MMS_VERSION_STRING
} else if (print_version) {
printf("MMS engine %s\n", MMS_VERVION_STRING);
printf("MMS engine %s\n", MMS_VERSION_STRING);
*result = RET_OK;
return FALSE;
#endif
} else {
#ifdef MMS_ENGINE_VERSION
MMS_INFO("Version %s starting", MMS_VERVION_STRING);
#ifdef MMS_VERSION_STRING
MMS_INFO("Version %s starting", MMS_VERSION_STRING);
#else
MMS_INFO("Starting");
#endif
......
......@@ -45,6 +45,7 @@ struct mms_engine {
gulong cancel_signal_id;
gulong set_log_level_signal_id;
gulong set_log_type_signal_id;
gulong get_version_signal_id;
};
typedef GObjectClass MMSEngineClass;
......@@ -385,6 +386,32 @@ mms_engine_handle_set_log_type(
return TRUE;
}
/* org.nemomobile.MmsEngine.getVersion */
static
gboolean
mms_engine_handle_get_version(
OrgNemomobileMmsEngine* proxy,
GDBusMethodInvocation* call,
MMSEngine* engine)
{
#ifdef MMS_VERSION_STRING
int v1 = 0, v2 = 0, v3 = 0;
char* s = g_malloc(strlen(MMS_VERSION_STRING)+1);
s[0] = 0;
if (sscanf(MMS_VERSION_STRING, "%d.%d.%d%s", &v1, &v2, &v3, s) < 3) {
MMS_WARN_("unable to parse version %s", MMS_VERSION_STRING);
} else {
MMS_DEBUG_("version %d.%d.%d%s", v1, v2, v3, s);
}
org_nemomobile_mms_engine_complete_get_version(proxy, call, v1, v2, v3, s);
g_free(s);
#else
MMS_DEBUG_("oops");
org_nemomobile_mms_engine_complete_get_version(proxy, call, 0, 0, 0, "");
#endif
return TRUE;
}
MMSEngine*
mms_engine_new(
const MMSConfig* config,
......@@ -459,6 +486,9 @@ mms_engine_new(
mms->set_log_type_signal_id =
g_signal_connect(mms->proxy, "handle-set-log-type",
G_CALLBACK(mms_engine_handle_set_log_type), mms);
mms->get_version_signal_id =
g_signal_connect(mms->proxy, "handle-get-version",
G_CALLBACK(mms_engine_handle_get_version), mms);
return mms;
}
......@@ -580,6 +610,7 @@ mms_engine_dispose(
g_signal_handler_disconnect(e->proxy, e->cancel_signal_id);
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_object_unref(e->proxy);
e->proxy = NULL;
}
......
......@@ -18,6 +18,12 @@
#include <gio/gio.h>
#include "mms_settings.h"
#ifdef MMS_ENGINE_VERSION
# define MMS_STRING__(x) #x
# define MMS_STRING_(x) MMS_STRING__(x)
# define MMS_VERSION_STRING MMS_STRING_(MMS_ENGINE_VERSION)
#endif
#define MMS_APP_LOG_PREFIX "mms-engine"
#define MMS_ENGINE_SERVICE "org.nemomobile.MmsEngine"
......
......@@ -198,5 +198,13 @@
<arg type="s" name="type" direction="in"/>
</method>
<!-- Since 1.0.22 -->
<method name="getVersion">
<arg type="i" name="major" direction="out"/>
<arg type="i" name="minor" direction="out"/>
<arg type="i" name="micro" direction="out"/>
<arg type="s" name="suffix" direction="out"/>
</method>
</interface>
</node>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment