summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseungha.son <seungha.son@samsung.com>2016-05-25 19:38:16 +0900
committerseungha.son <seungha.son@samsung.com>2016-05-26 15:22:11 +0900
commitde42b5b1e1482cbb5c4b348e3b040f00fa5cce73 (patch)
tree05f202a8c8d0e3e167ca3c7f0f4595add50e5a90
parent9f89a19648c00c0366711a97a141e7798d00d77b (diff)
downloadshortcut-de42b5b1e1482cbb5c4b348e3b040f00fa5cce73.tar.gz
shortcut-de42b5b1e1482cbb5c4b348e3b040f00fa5cce73.tar.bz2
shortcut-de42b5b1e1482cbb5c4b348e3b040f00fa5cce73.zip
Add code for check the privilege of async API. Signed-off-by: seungha.son <seungha.son@samsung.com> Change-Id: I68a06d36474610d8610a193fd7f724dcd2c11bd8
-rwxr-xr-xlib/src/shortcut_manager.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/lib/src/shortcut_manager.c b/lib/src/shortcut_manager.c
index b722687..f1506ee 100755
--- a/lib/src/shortcut_manager.c
+++ b/lib/src/shortcut_manager.c
@@ -339,7 +339,7 @@ static void _send_message_with_reply_sync_cb(GDBusConnection *connection,
free(cb_item);
}
-static int _send_async_noti(GVariant *body, struct result_cb_item *cb_item, char *cmd)
+static int _send_async_shortcut(GVariant *body, struct result_cb_item *cb_item, char *cmd)
{
GDBusMessage *msg;
msg = g_dbus_message_new_method_call(
@@ -367,7 +367,7 @@ static int _send_async_noti(GVariant *body, struct result_cb_item *cb_item, char
g_object_unref(msg);
- DbgPrint("_send_async_noti done !!");
+ DbgPrint("_send_async_shortcut done !!");
return SHORTCUT_ERROR_NONE;
}
@@ -387,6 +387,19 @@ static void _on_name_vanished(GDBusConnection *connection,
DbgPrint("name vanished : %s", name);
}
+static int _check_privilege(void)
+{
+ GDBusMessage *reply = NULL;
+ int ret = SHORTCUT_ERROR_NONE;
+
+ ret = _send_sync_shortcut(NULL, &reply, "check_privilege");
+
+ if (reply)
+ g_object_unref(reply);
+
+ return ret;
+}
+
EAPI int shortcut_set_request_cb(shortcut_request_cb request_cb, void *data)
{
int ret = _dbus_init();
@@ -452,6 +465,10 @@ EAPI int shortcut_add_to_home(const char *name, shortcut_type type, const char *
return ret;
}
+ ret = _check_privilege();
+ if (ret != SHORTCUT_ERROR_NONE)
+ return ret;
+
appid = _shortcut_get_pkgname_by_pid();
item = malloc(sizeof(struct result_cb_item));
if (!item) {
@@ -476,7 +493,8 @@ EAPI int shortcut_add_to_home(const char *name, shortcut_type type, const char *
icon = "";
body = g_variant_new("(ississi)", getpid(), appid, name, type, uri, icon, allow_duplicate);
- ret = _send_async_noti(body, item, "add_shortcut");
+
+ ret = _send_async_shortcut(body, item, "add_shortcut");
if (ret != SHORTCUT_ERROR_NONE) {
free(item);
item = NULL;
@@ -514,6 +532,10 @@ EAPI int shortcut_add_to_home_widget(const char *name, shortcut_widget_size_e si
return ret;
}
+ ret = _check_privilege();
+ if (ret != SHORTCUT_ERROR_NONE)
+ return ret;
+
appid = _shortcut_get_pkgname_by_pid();
item = malloc(sizeof(struct result_cb_item));
if (!item) {
@@ -529,7 +551,7 @@ EAPI int shortcut_add_to_home_widget(const char *name, shortcut_widget_size_e si
item->data = data;
body = g_variant_new("(ississdi)", getpid(), widget_id, name, size, NULL, icon, period, allow_duplicate);
- ret = _send_async_noti(body, item, "add_shortcut_widget");
+ ret = _send_async_shortcut(body, item, "add_shortcut_widget");
if (ret != SHORTCUT_ERROR_NONE) {
free(item);