Set the event system value into bt-core process 96/89996/1 accepted/tizen/common/20160928.164307 accepted/tizen/ivi/20160929.002010 accepted/tizen/mobile/20160929.001907 accepted/tizen/tv/20160929.001919 accepted/tizen/wearable/20160929.002046 submit/tizen/20160928.062430
authorDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 28 Sep 2016 04:23:06 +0000 (13:23 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 28 Sep 2016 04:23:06 +0000 (13:23 +0900)
Change-Id: Iee08cc51236ce732077a9c3e6bbf6be037df3742
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
bt-share/include/bt-share-ipc.h
bt-share/src/bt-share-common.c
bt-share/src/bt-share-ipc.c

index c007872..d28934b 100644 (file)
@@ -61,6 +61,10 @@ extern "C" {
 #define BT_SHARE_FRWK_INTERFACE "User.Bluetooth.FRWK"
 #define BT_SHARE_FRWK_SIGNAL_DEINIT "deinit"
 
+#define BT_CORE_NAME "org.projectx.bt_core"
+#define BT_CORE_PATH "/org/projectx/bt_core"
+#define BT_CORE_INTERFACE "org.projectx.btcore"
+
 #define BT_IPC_STRING_SIZE 256
 #define BT_ADDR_STR_LEN_MAX    18
 #define BT_MIME_TYPE_MAX_LEN   20
@@ -154,6 +158,8 @@ gboolean _bt_add_recv_transfer_status_data(char *device_name,
                        char *filepath, char *type,
                        unsigned int size, int status);
 
+int _bt_set_eventsystem_transfer_value(gboolean value);
+
 #ifdef __cplusplus
 }
 #endif
index 1041c7a..d7c2186 100644 (file)
@@ -33,7 +33,9 @@
 #include "vconf-keys.h"
 #include "applog.h"
 #include "bt-share-common.h"
+#include "bt-share-ipc.h"
 
+#if 0
 static int __bt_eventsystem_set_value(const char *event, const char *key, const char *value)
 {
        int ret;
@@ -51,6 +53,7 @@ static int __bt_eventsystem_set_value(const char *event, const char *key, const
 
        return ret;
 }
+#endif
 
 int _bt_share_block_sleep(gboolean is_block)
 {
@@ -133,9 +136,14 @@ int _bt_set_transfer_indicator(gboolean state)
 
        DBG("event_value: %s", event_val);
 
+       if (_bt_set_eventsystem_transfer_value(state) != BT_SHARE_ERROR_NONE)
+               ERR("Fail to set value");
+
+#if 0
        if (__bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_TRANSFERING_STATE,
                                                event_val) != ES_R_OK)
                ERR("Fail to set value");
+#endif
 
        ret = vconf_set_int(VCONFKEY_BT_STATUS, bt_device_state);
        if (ret != 0) {
index 46dfcb5..3176035 100644 (file)
@@ -28,6 +28,7 @@
 #include <aul.h>
 #include <vconf.h>
 #include <bundle_internal.h>
+#include <gio/gio.h>
 
 #include "applog.h"
 #include "bluetooth-api.h"
@@ -45,6 +46,8 @@
 
 GSList *bt_transfer_list = NULL;
 DBusConnection *dbus_connection = NULL;
+static GDBusConnection *system_gconn = NULL;
+static GDBusProxy *core_proxy = NULL;
 
 extern struct bt_appdata *app_state;
 
@@ -876,3 +879,76 @@ static void __bt_share_update_tr_info(int tr_uid, int tr_type)
        }
        return;
 }
+
+GDBusConnection *__bt_init_system_gconn(void)
+{
+       if (system_gconn == NULL)
+               system_gconn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
+
+       return system_gconn;
+}
+
+GDBusConnection *__bt_get_system_gconn(void)
+{
+       return (system_gconn) ? system_gconn : __bt_init_system_gconn();
+}
+
+GDBusProxy *__bt_init_core_proxy(void)
+{
+       GDBusProxy *proxy;
+       GDBusConnection *conn;
+
+       conn = __bt_get_system_gconn();
+       if (!conn)
+               return NULL;
+
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                       NULL,
+                                       BT_CORE_NAME,
+                                       BT_CORE_PATH,
+                                       BT_CORE_INTERFACE,
+                                       NULL, NULL);
+
+       if (!proxy)
+               return NULL;
+
+       core_proxy = proxy;
+
+       return proxy;
+}
+
+static GDBusProxy *__bt_get_core_proxy(void)
+{
+       return (core_proxy) ? core_proxy : __bt_init_core_proxy();
+}
+
+int _bt_set_eventsystem_transfer_value(gboolean value)
+{
+       GDBusProxy *proxy;
+       GError *error = NULL;
+       GVariant *reply;
+       int ret = BT_SHARE_ERROR_NONE;
+
+       DBG("+");
+
+       proxy = __bt_get_core_proxy();
+       if (!proxy)
+               return BT_SHARE_FAIL;
+
+       reply = g_dbus_proxy_call_sync(proxy, "SetTransferValue",
+                       g_variant_new("(b)", value),
+                       G_DBUS_CALL_FLAGS_NONE, -1,
+                       NULL, &error);
+
+       if (reply == NULL) {
+               ERR("Failed to Set tranfer value by bt core");
+               ret = BT_SHARE_FAIL;
+               if (error) {
+                       ERR("Error %s", error->message);
+                       g_error_free(error);
+               }
+       }
+       g_variant_unref(reply);
+
+       return ret;
+}