summaryrefslogtreecommitdiff
path: root/lib/src/shortcut_manager.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/src/shortcut_manager.c')
-rwxr-xr-xlib/src/shortcut_manager.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/lib/src/shortcut_manager.c b/lib/src/shortcut_manager.c
index dcb164c..04975ee 100755
--- a/lib/src/shortcut_manager.c
+++ b/lib/src/shortcut_manager.c
@@ -20,6 +20,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
+#include <time.h>
#include <aul.h>
#include <dlog.h>
@@ -33,6 +34,7 @@
#include "shortcut_internal.h"
#define SHORTCUT_IS_WIDGET_SIZE(size) (!!((size) & WIDGET_SIZE_DEFAULT))
+#define REQUEST_ID_LEN 40
EAPI int shortcut_set_request_cb(shortcut_request_cb request_cb, void *data)
{
@@ -132,6 +134,19 @@ EAPI void shortcut_unset_remove_cb(void)
_unset_remove_cb();
}
+static char *_make_request_id()
+{
+ static int id = 0;
+ char request_id[REQUEST_ID_LEN] = { 0, };
+
+ g_atomic_int_inc(&id);
+ snprintf(request_id, sizeof(request_id), "%d@%d", getpid(), id);
+
+ SHORTCUT_DBG("The request_id of shortcut is [%s]", request_id);
+
+ return strdup(request_id);
+}
+
EAPI int shortcut_add_to_home(const char *name, shortcut_type type, const char *uri,
const char *icon, int allow_duplicate, result_cb_t result_cb, void *data)
{
@@ -139,6 +154,7 @@ EAPI int shortcut_add_to_home(const char *name, shortcut_type type, const char *
char *appid;
int ret;
GVariant *body;
+ char *request_id = NULL;
if (ADD_TO_HOME_IS_DYNAMICBOX(type)) {
/* LCOV_EXCL_START */
@@ -191,7 +207,8 @@ EAPI int shortcut_add_to_home(const char *name, shortcut_type type, const char *
if (!icon)
icon = "";
- body = g_variant_new("(ississi)", getpid(), appid, name, type, uri, icon, allow_duplicate);
+ request_id = _make_request_id();
+ body = g_variant_new("(sississi)", request_id, getpid(), appid, name, type, uri, icon, allow_duplicate);
ret = _send_async_shortcut(body, item, "add_shortcut");
if (ret != SHORTCUT_ERROR_NONE) {
@@ -205,6 +222,8 @@ EAPI int shortcut_add_to_home(const char *name, shortcut_type type, const char *
free(appid);
if (body)
g_variant_unref(body);
+ if (request_id)
+ free(request_id);
return ret;
}
@@ -216,6 +235,7 @@ EAPI int shortcut_add_to_home_widget(const char *name, shortcut_widget_size_e si
char *appid;
int ret;
GVariant *body;
+ char *request_id = NULL;
if (name == NULL) {
SHORTCUT_ERR("AppID is null\n");
@@ -264,7 +284,8 @@ EAPI int shortcut_add_to_home_widget(const char *name, shortcut_widget_size_e si
item->result_internal_cb = NULL;
item->data = data;
- body = g_variant_new("(ississdi)", getpid(), widget_id, name, size, NULL, icon, period, allow_duplicate);
+ request_id = _make_request_id();
+ body = g_variant_new("(sississdi)", request_id, getpid(), widget_id, name, size, NULL, icon, period, allow_duplicate);
ret = _send_async_shortcut(body, item, "add_shortcut_widget");
if (ret != SHORTCUT_ERROR_NONE) {
@@ -278,6 +299,8 @@ EAPI int shortcut_add_to_home_widget(const char *name, shortcut_widget_size_e si
free(appid);
if (body)
g_variant_unref(body);
+ if (request_id)
+ free(request_id);
return ret;
}
@@ -288,6 +311,7 @@ EAPI int shortcut_remove_from_home(const char *name, result_cb_t result_cb, void
char *appid;
int ret;
GVariant *body;
+ char *request_id = NULL;
if (name == NULL) {
SHORTCUT_ERR("name is NULL.");
@@ -329,7 +353,8 @@ EAPI int shortcut_remove_from_home(const char *name, result_cb_t result_cb, void
item->result_internal_cb = NULL;
item->data = user_data;
- body = g_variant_new("(iss)", getpid(), appid, name);
+ request_id = _make_request_id();
+ body = g_variant_new("(siss)", request_id, getpid(), appid, name);
ret = _send_async_shortcut(body, item, "remove_shortcut");
if (ret != SHORTCUT_ERROR_NONE) {
@@ -343,6 +368,8 @@ EAPI int shortcut_remove_from_home(const char *name, result_cb_t result_cb, void
free(appid);
if (body)
g_variant_unref(body);
+ if (request_id)
+ free(request_id);
return ret;
}