static char *g_engine_app_id;
static char *g_engine_name;
+
static void _server_appeared_cb(GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer user_data)
{
LOGD("name : %s, name_owner : %s", name, name_owner);
return ret;
}
-static int _monitor_register(GDBusConnection *gdbus_connection)
+static int _monitor_register(GDBusConnection *gdbus_connection, const char *uid, const char *smack_label)
{
int ret;
GDBusMessage *reply = NULL;
GVariant *client_body = NULL;
char appid[1024] = {0, };
- ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid));
+ int pid = getpid();
+ ret = aul_app_get_appid_bypid(pid, appid, sizeof(appid));
if (ret != 0) {
LOGE("aul_app_get_appid_bypid() failed : %d", ret);
}
- client_body = g_variant_new("(iis)", 11, GESTURE_CLIENT_LIB_GESTURE, appid);
+ LOGI("[INFO] appid(%s), pid(%d), uid(%s), smack_label(%s)", appid, pid, uid, smack_label);
+
+ client_body = g_variant_new("(iisiss)", 11, GESTURE_CLIENT_LIB_GESTURE, appid, pid, uid, smack_label);
ret = gdbus_send_message_with_sync(gdbus_connection, client_body, &reply, GESTURE_MSG_SERVICE_REGISTER);
if (reply)
const gchar *name_owner,
gpointer user_data)
{
- if (is_server_started == 0)
- _monitor_register(connection);
+ struct hand_gesture_s *_struct = user_data;
+
+ if (is_server_started == 0) {
+ LOGI("uid(%s), smack_label(%s)", _struct->uid, _struct->smack_label);
+ _monitor_register(connection, _struct->uid, _struct->smack_label);
+ }
}
static void _on_name_vanished(GDBusConnection *connection,
}
int gesture_client_dbus_init(GDBusConnection **gdbus_connection, guint *server_watcher_id,
- int *monitor_id, int *server_monitor_id, CLIENT_LIB lib, void *data)
+ int *monitor_id, int *server_monitor_id, CLIENT_LIB lib, const char *uid, const char *smack_label, void *data)
{
LOGD("gesture_client_dbus_init start");
return ret;
}
- ret = _monitor_register(*gdbus_connection);
+ ret = _monitor_register(*gdbus_connection, uid, smack_label);
if (ret != HAND_GESTURE_ERROR_NONE) {
LOGE("_monitor_register() failed : %d", ret);
return ret;
G_BUS_NAME_WATCHER_FLAGS_NONE,
_on_name_appeared,
_on_name_vanished,
- NULL,
+ data,
NULL);
if (*server_monitor_id == 0) {
g_dbus_connection_signal_unsubscribe(*gdbus_connection, *monitor_id);
GDBusMessage *reply = NULL;
GVariant *body = NULL;
- body = g_variant_new("()");
+ body = g_variant_new("(i)", gesture);
ret = gdbus_send_message_with_sync(gdbus_connection, body, &reply, GESTURE_CLIENT_MSG_IS_SUPPORT_GESTURE_TYPE);
- if (ret != HAND_GESTURE_ERROR_NONE)
+ if (ret != HAND_GESTURE_ERROR_NONE || NULL == reply) {
LOGE("failed to is_supported_gesture_type");
+ } else {
+ LOGD("Check reply from server");
+ GVariant *reply_body = g_dbus_message_get_body(reply);
+ if (NULL == reply_body) {
+ LOGE("There is no return value");
+ ret = HAND_GESTURE_ERROR_OPERATION_FAILED;
+ } else {
+ g_variant_get(reply_body, "(b)", supported);
+ LOGD("supported(%d)", *supported);
+ }
+ }
if (body)
g_variant_unref(body);
int ret;
GDBusMessage *reply = NULL;
GVariant *body = NULL;
- g_engine_app_id = *engine_app_id;
- g_engine_name = *engine_name;
body = g_variant_new("()");
ret = gdbus_send_message_with_sync(gdbus_connection, body, &reply, GESTURE_CLIENT_MSG_ENGINE_GET_INFO);
if (ret != HAND_GESTURE_ERROR_NONE)
- LOGE("failed to engine_get_info");
+ LOGE("Fail to send message");
+
+ GVariant *reply_body = g_dbus_message_get_body(reply);
+ if (NULL == reply_body) {
+ LOGE("There is no return value");
+ ret = HAND_GESTURE_ERROR_OPERATION_FAILED;
+ } else {
+ g_variant_get(reply_body, "(ss)", engine_app_id, engine_name);
+ if (NULL == engine_app_id || NULL == engine_name) {
+ LOGE("Fail to get engine info");
+ ret = HAND_GESTURE_ERROR_OPERATION_FAILED;
+ } else {
+ if (NULL != g_engine_app_id) {
+ free(g_engine_app_id);
+ }
+
+ if (NULL != g_engine_name) {
+ free(g_engine_name);
+ }
+
+ g_engine_app_id = *engine_app_id;
+ g_engine_name = *engine_name;
+ LOGD("APP ID(%s), Name(%s)", *engine_app_id, *engine_name);
+ }
+ }
if (body)
g_variant_unref(body);