Add the way to notify through event publish 20/229920/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 6 Apr 2020 09:27:47 +0000 (18:27 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 6 Apr 2020 11:15:21 +0000 (20:15 +0900)
Change-Id: Ie2c4ee63ddfa278b65fd775d813814934350795d
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
packaging/capi-ui-sticker.spec
receiver/CMakeLists.txt
receiver/src/message.cpp

index 8f3c329..3ad6b90 100644 (file)
@@ -11,6 +11,7 @@ Source3:    capi-ui-sticker.conf
 BuildRequires:  cmake, coreutils
 BuildRequires:  pkgconfig(capi-appfw-app-common)
 BuildRequires:  pkgconfig(capi-appfw-package-manager)
+BuildRequires:  pkgconfig(capi-appfw-event)
 BuildRequires:  pkgconfig(capi-system-info)
 BuildRequires:  pkgconfig(cynara-client)
 BuildRequires:  pkgconfig(cynara-session)
index 49b6d42..d415064 100644 (file)
@@ -18,6 +18,7 @@ pkg_check_modules(pkgs_test REQUIRED
     capi-message-port
     capi-appfw-app-common
     capi-appfw-alarm
+    capi-appfw-event
     capi-system-device
     sap-client-stub-api
     json-glib-1.0
index 0ca7d32..79b04fd 100644 (file)
  */
 
 #include <stdlib.h>
+#include <app_event.h>
 
 #include "message.h"
 #include "log.h"
 #include "config.h"
 
+#define EVENT_NAME "event.org.tizen.sticker-receiver.user_event"
+
 static int port_id = -1;
 
 bool message_sink_init(message_port_message_cb callback, void *user_data)
@@ -62,24 +65,39 @@ bool send_message(const char *cmd, const char *data)
 
     LOGD("command: %s, data: %s", cmd, data);
 
-    message_port_check_remote_port(REMOTE_APP_ID, MESSAGE_PORT_REMOTE_NAME, &found);
-    if (!found) {
-        LOGW("Can't find remote port");
-        return false;
-    }
-
     bundle *b = bundle_create();
     bundle_add_str(b, "command", cmd);
     if (data)
         bundle_add_str(b, "data", data);
-    ret = message_port_send_message(REMOTE_APP_ID, MESSAGE_PORT_REMOTE_NAME, b);
-    if (ret != MESSAGE_PORT_ERROR_NONE) {
-        LOGW("message port send message error. err : %d", ret);
+
+    message_port_check_remote_port(REMOTE_APP_ID, MESSAGE_PORT_REMOTE_NAME, &found);
+    if (found) {
+        ret = message_port_send_message(REMOTE_APP_ID, MESSAGE_PORT_REMOTE_NAME, b);
+        if (ret != MESSAGE_PORT_ERROR_NONE)
+        {
+            LOGW("message port send message error. err : %d", ret);
+            result = false;
+        }
+        else
+        {
+            LOGI("Succeed to send message.");
+            result = true;
+        }
+    }
+    else
+    {
+        LOGW("Can't find remote port");
+        result = false;
+    }
+
+    ret = event_publish_app_event(EVENT_NAME, b);
+    if (ret != EVENT_ERROR_NONE) {
         result = false;
+        LOGE("Failed to send message by event publish. error : %d", ret);
     }
     else
     {
-        LOGI("Succeed to send message.");
+        LOGD("Succeed to send message through event publish");
         result = true;
     }