Move function definition to aul header
[platform/core/appfw/aul-1.git] / src / app_com.cc
index 6b78bf7..57c304d 100644 (file)
@@ -326,8 +326,8 @@ extern "C" API int aul_app_com_send(const char* endpoint, bundle* envelope) {
       .With(std::move(b))
       .SendSimply();
   if (type != BUNDLE_TYPE_NONE) {
-    b.Delete(AUL_K_COM_ENDPOINT);
-    b.Add(AUL_K_COM_ENDPOINT, com_endpoint);
+    bundle_del(envelope, AUL_K_COM_ENDPOINT);
+    bundle_add_str(envelope, AUL_K_COM_ENDPOINT, com_endpoint.c_str());
   }
 
   return ret;
@@ -346,22 +346,20 @@ extern "C" API int aul_app_com_leave(aul_app_com_connection_h connection) {
   std::lock_guard<std::recursive_mutex> lock(context.GetMutex());
   conn->Disable();
 
+  std::string endpoint = conn->GetEndpoint();
+  if (!context.ExistConnection(endpoint)) {
+    tizen_base::Bundle b { { AUL_K_COM_ENDPOINT, endpoint } };
+    int ret = AppRequest(APP_COM_LEAVE, getuid())
+      .With(std::move(b))
+      .SendSimply(AUL_SOCK_NOREPLY);
+    if (ret != 0)
+      _E("Failed to send leave request. error(%d)", ret);
+  }
+
   g_idle_add_full(G_PRIORITY_HIGH, [](gpointer user_data) -> gboolean {
         auto* conn = static_cast<AppComConnection*>(user_data);
         std::lock_guard<std::recursive_mutex> lock(context.GetMutex());
-        std::string endpoint = conn->GetEndpoint();
         context.RemoveConnection(conn);
-
-        if (context.ExistConnection(endpoint))
-          return G_SOURCE_REMOVE;
-
-        tizen_base::Bundle b { { AUL_K_COM_ENDPOINT, endpoint } };
-        int ret = AppRequest(APP_COM_LEAVE, getuid())
-            .With(std::move(b))
-            .SendSimply();
-        if (ret != 0)
-          _E("Failed to send leave request. error(%d)", ret);
-
         return G_SOURCE_REMOVE;
       }, connection, nullptr);