Change some api of manager/reporter to method_call 55/230955/30
authormk5004.lee <mk5004.lee@samsung.com>
Wed, 13 May 2020 07:50:18 +0000 (16:50 +0900)
committerMyungKi Lee <mk5004.lee@samsung.com>
Mon, 8 Jun 2020 10:13:11 +0000 (10:13 +0000)
Change-Id: I9bd5247ef49f14cbc4221b74c13fd9b15864278f
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
Signed-off-by: Jusung Son <jusung07.son@samsung.com>
notification-ex/dbus_event_listener.cc
notification-ex/dbus_event_listener_implementation.h
notification-ex/dbus_sender.cc
notification-ex/dbus_sender.h
notification-ex/dbus_sender_implementation.h
notification-ex/event_sender_interface.h
notification-ex/manager.cc
notification-ex/manager.h
notification-ex/reporter.cc
notification-ex/reporter.h
notification-ex/stub.cc

index 38a20e3..a075622 100644 (file)
@@ -19,6 +19,7 @@
 #include <unistd.h>
 
 #include <string>
+#include <map>
 #include <list>
 
 #include "notification-ex/dbus_connection_manager.h"
@@ -35,6 +36,7 @@
 #define LOG_TAG "NOTIFICATION_EX"
 #define MAX_PACKAGE_STR_SIZE 512
 #define NORMAL_UID_BASE 5000
+#define MAX_CACHE_COUNT 20
 
 #define DBUS_NAME "org.freedesktop.DBus"
 #define DBUS_OBJECT_PATH "/org/freedesktop/DBus"
@@ -63,6 +65,11 @@ DBusEventListener::Impl::Impl(DBusEventListener* parent, string path)
 
 uid_t DBusEventListener::Impl::GetSenderUid(GDBusConnection* connection,
                 const char* sender_name) {
+  static std::map<std::string, uid_t> cache;
+  auto cp = cache.find(sender_name);
+  if (cp != cache.end())
+    return cp->second;
+
   GDBusMessage* msg = nullptr;
   GDBusMessage* reply = nullptr;
   GError* err = nullptr;
@@ -91,6 +98,11 @@ uid_t DBusEventListener::Impl::GetSenderUid(GDBusConnection* connection,
   body = g_dbus_message_get_body(reply);
   g_variant_get(body, "(u)", &uid);
 
+  if (cache.size() >= MAX_CACHE_COUNT)
+    cache.clear();
+
+  cache[sender_name] = uid;
+
 out:
   if (msg)
     g_object_unref(msg);
@@ -101,7 +113,12 @@ out:
 }
 
 pid_t DBusEventListener::Impl::GetSenderPid(GDBusConnection* connection,
-               const char* sender_name) {
+                const char* sender_name) {
+  static std::map<std::string, pid_t> cache;
+  auto cp = cache.find(sender_name);
+  if (cp != cache.end())
+    return cp->second;
+
   GDBusMessage* msg = nullptr;
   GDBusMessage* reply = nullptr;
   GError* err = nullptr;
@@ -130,6 +147,11 @@ pid_t DBusEventListener::Impl::GetSenderPid(GDBusConnection* connection,
   body = g_dbus_message_get_body(reply);
   g_variant_get(body, "(u)", &pid);
 
+  if (cache.size() >= MAX_CACHE_COUNT)
+    cache.clear();
+
+  cache[sender_name] = pid;
+
 out:
   if (msg)
     g_object_unref(msg);
@@ -189,18 +211,83 @@ void DBusEventListener::Impl::SignalCb(GDBusConnection* connection,
   }
 }
 
+void DBusEventListener::Impl::MethodCallHandler(GVariant* parameters,
+            DBusEventListener::Impl* dl, pid_t pid, uid_t uid) {
+  char* appid = nullptr;
+  GVariantIter* iter = nullptr;
+  char* event_info_raw = nullptr;
+
+  g_variant_get(parameters, "(ssa(s))", &appid, &event_info_raw, &iter);
+
+  string sender_appid = string(appid);
+  string cur_appid = util::GetAppId();
+  LOGI("MethodCallHandler!! appid(%s), sender(%s), cur(%s)", appid,
+    sender_appid.c_str(), cur_appid.c_str());
+
+  if (sender_appid == cur_appid)
+    return;
+
+  if ((!DBusConnectionManager::GetInst().IsDataProviderMaster(cur_appid)
+    && !DBusConnectionManager::GetInst().IsDataProviderMaster(sender_appid))
+    || (cur_appid == sender_appid))
+    return;
+
+  char* raw = nullptr;
+  list<Bundle> ret_list;
+  while (g_variant_iter_loop(iter, "(s)", &raw) && raw != nullptr) {
+    Bundle ret(raw);
+    ret_list.emplace_back(ret);
+  }
+
+  Bundle b(event_info_raw);
+  EventInfo info(b);
+
+  if (info.GetEventType() == EventInfo::Post
+        || info.GetEventType() == EventInfo::Update) {
+    if (uid >= NORMAL_UID_BASE) {
+      info.SetValidatedOwner(util::GetAppId(pid));
+      info.SetValidatedUid(uid);
+    }
+  }
+
+  dl->parent_->NotifyObserver(info, ret_list);
+}
+
 void DBusEventListener::Impl::OnMethodCall(
-    GDBusConnection *conn, const gchar *sender, const gchar *object_path,
-    const gchar *iface_name, const gchar *method_name,
-    GVariant *parameters, GDBusMethodInvocation *invocation,
+    GDBusConnection* conn, const gchar* sender, const gchar* object_path,
+    const gchar* iface_name, const gchar* method_name,
+    GVariant* parameters, GDBusMethodInvocation* invocation,
     gpointer user_data) {
   LOGI("method_name[%s] sender[%s]", method_name, sender);
   DBusEventListener::Impl* dl = static_cast<DBusEventListener::Impl*>(user_data);
-  GVariant *reply_body = NULL;
+  GVariantreply_body = NULL;
   try {
     char* appid = NULL;
     char* serialized = NULL;
-    if (g_strcmp0(method_name, "Get") == 0) {
+
+    uid_t uid = GetSenderUid(conn, sender);
+    pid_t pid = GetSenderPid(conn, sender);
+
+    if (g_strcmp0(method_name, "Post") == 0
+           || g_strcmp0(method_name, "Update") == 0
+           || g_strcmp0(method_name, "Delete") == 0
+           || g_strcmp0(method_name, "Error") == 0
+           || g_strcmp0(method_name, "DeleteAll") == 0
+           || g_strcmp0(method_name, "Register") == 0
+           || g_strcmp0(method_name, "Unregister") == 0) {
+      parameters = g_variant_ref(parameters);
+      g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", 0));
+      MethodCallHandler(parameters, dl, pid, uid);
+      g_variant_unref(parameters);
+      return;
+    } else if (g_strcmp0(method_name, "Count") == 0) {
+      g_variant_get(parameters, "(&s&s)", &appid, &serialized);
+
+      Bundle b(serialized);
+      EventInfo info(b);
+      int num = dl->parent_->NotifyNumberRequest(info);
+      reply_body = g_variant_new("(i)", num);
+    } else if (g_strcmp0(method_name, "Get") == 0) {
       g_variant_get(parameters, "(&s&s)", &appid, &serialized);
 
       Bundle b(serialized);
@@ -213,15 +300,14 @@ void DBusEventListener::Impl::OnMethodCall(
       }
       reply_body = g_variant_new("(a(s))", builder);
       g_variant_builder_unref(builder);
-    } else if (g_strcmp0(method_name, "Count") == 0) {
-      g_variant_get(parameters, "(&s&s)", &appid, &serialized);
-
-      Bundle b(serialized);
-      EventInfo info(b);
-      int num = dl->parent_->NotifyNumberRequest(info);
-      reply_body = g_variant_new("(i)", num);
+    } else {
+      g_dbus_method_invocation_return_error(invocation, noti_ex_error_quark(),
+            ERROR_IO_ERROR, "invalid operation");
+      return;
     }
+
     g_dbus_method_invocation_return_value(invocation, reply_body);
+
   } catch (Exception &ex) {
     LOGE("%s %d", ex.what(), ex.GetErrorCode());
     g_dbus_method_invocation_return_error(invocation, noti_ex_error_quark(),
@@ -238,16 +324,58 @@ int DBusEventListener::Impl::RegisterGDBusInterface() {
   static gchar introspection_xml[] =
     "  <node>"
     "  <interface name='org.tizen.notification_ex'>"
+    "        <method name='Post'>"
+    "          <arg type='s' name='appid' direction='in'/>"
+    "          <arg type='s' name='info' direction='in'/>"
+    "          <arg type='a(s)' name='serialized' direction='in'/>"
+    "          <arg type='i' name='ret' direction='out'/>"
+    "        </method>"
+    "        <method name='Update'>"
+    "          <arg type='s' name='appid' direction='in'/>"
+    "          <arg type='s' name='info' direction='in'/>"
+    "          <arg type='a(s)' name='serialized' direction='in'/>"
+    "          <arg type='i' name='ret' direction='out'/>"
+    "        </method>"
+    "        <method name='Delete'>"
+    "          <arg type='s' name='appid' direction='in'/>"
+    "          <arg type='s' name='info' direction='in'/>"
+    "          <arg type='a(s)' name='serialized' direction='in'/>"
+    "          <arg type='i' name='ret' direction='out'/>"
+    "        </method>"
     "        <method name='Get'>"
     "          <arg type='s' name='appid' direction='in'/>"
     "          <arg type='s' name='serialized' direction='in'/>"
     "          <arg type='a(s)' name='noti_arr' direction='out'/>"
     "        </method>"
+    "        <method name='Error'>"
+    "          <arg type='s' name='appid' direction='in'/>"
+    "          <arg type='s' name='info' direction='in'/>"
+    "          <arg type='a(s)' name='serialized' direction='in'/>"
+    "          <arg type='i' name='ret' direction='out'/>"
+    "        </method>"
     "        <method name='Count'>"
     "          <arg type='s' name='appid' direction='in'/>"
     "          <arg type='s' name='serialized' direction='in'/>"
     "          <arg type='i' name='num' direction='out'/>"
     "        </method>"
+    "        <method name='DeleteAll'>"
+    "          <arg type='s' name='appid' direction='in'/>"
+    "          <arg type='s' name='info' direction='in'/>"
+    "          <arg type='a(s)' name='serialized' direction='in'/>"
+    "          <arg type='i' name='ret' direction='out'/>"
+    "        </method>"
+    "        <method name='Register'>"
+    "          <arg type='s' name='appid' direction='in'/>"
+    "          <arg type='s' name='info' direction='in'/>"
+    "          <arg type='a(s)' name='serialized' direction='in'/>"
+    "          <arg type='i' name='ret' direction='out'/>"
+    "        </method>"
+    "        <method name='Unregister'>"
+    "          <arg type='s' name='appid' direction='in'/>"
+    "          <arg type='s' name='info' direction='in'/>"
+    "          <arg type='a(s)' name='serialized' direction='in'/>"
+    "          <arg type='i' name='ret' direction='out'/>"
+    "        </method>"
     "  </interface>"
     "  </node>";
   GError *error = NULL;
index 9ff7885..5fb25da 100644 (file)
@@ -41,6 +41,7 @@ class DBusEventListener::Impl {
     const gchar *iface_name, const gchar *method_name,
     GVariant *parameters, GDBusMethodInvocation *invocation,
     gpointer user_data);
+  static void MethodCallHandler(GVariant *parameters, Impl* dl, pid_t pid, uid_t uid);
 
   static GDBusInterfaceVTable InterfaceVtable;
   static void SignalCb(GDBusConnection* connection,
index cb42df3..88ddbec 100644 (file)
@@ -107,7 +107,6 @@ void DBusSender::Notify(const IEventInfo& info, list<Bundle> serialized,
 
 GDBusMessage* DBusSender::Impl::MethodCall(string appid, string method_name,
     Bundle serialized) {
-  GError* err = nullptr;
   GDBusMessage* msg = g_dbus_message_new_method_call(
       DBusConnectionManager::GetInst().GetDataProviderMasterName().c_str(),
       path_.c_str(),
@@ -127,13 +126,101 @@ GDBusMessage* DBusSender::Impl::MethodCall(string appid, string method_name,
 
   LOGI("send message !! (%s) (%s) (%s)",
       path_.c_str(), method_name.c_str(), appid.c_str());
+
+  GError* err = nullptr;
   GDBusMessage* reply = g_dbus_connection_send_message_with_reply_sync(
       DBusConnectionManager::GetInst().GetConnection(), msg,
       G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &err);
+  if (err != NULL) {
+    LOGE("MethodCall, err[%s]", err->message);
+    if (err->code == G_DBUS_ERROR_ACCESS_DENIED)
+      set_last_result(ERROR_PERMISSION_DENIED);
+    else
+      set_last_result(ERROR_IO_ERROR);
+    g_error_free(err);
+  }
 
   return reply;
 }
 
+GDBusMessage* DBusSender::Impl::MethodCall(string appid, const IEventInfo& info,
+    list<Bundle> serialized) {
+  GDBusMessage* msg = g_dbus_message_new_method_call(
+      DBusConnectionManager::GetInst().GetDataProviderMasterName().c_str(),
+      path_.c_str(),
+      DBusConnectionManager::GetInst().GetInterfaceName().c_str(),
+      EventInfo::GetString(info.GetEventType()).c_str());
+  if (!msg) {
+    LOGE("Can't allocate new method call");
+    return nullptr;
+  }
+
+  GVariantBuilder* builder = g_variant_builder_new(G_VARIANT_TYPE("a(s)"));
+  for (auto& i : serialized) {
+    g_variant_builder_add(builder, "(s)",
+        reinterpret_cast<char*>(i.ToRaw().first.get()));
+  }
+
+  g_dbus_message_set_body(msg,
+      g_variant_new("(ssa(s))",
+          appid.c_str(),
+          reinterpret_cast<char*>(info.Serialize().ToRaw().first.get()),
+          builder
+      )
+  );
+
+  LOGI("send message !! (%s) (%s) (%s)",
+      path_.c_str(), EventInfo::GetString(info.GetEventType()).c_str(), appid.c_str());
+
+  GError* err = nullptr;
+  GDBusMessage* reply = g_dbus_connection_send_message_with_reply_sync(
+      DBusConnectionManager::GetInst().GetConnection(), msg,
+      G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &err);
+  if (err != NULL) {
+    LOGE("MethodCall, err[%s]", err->message);
+    if (err->code == G_DBUS_ERROR_ACCESS_DENIED)
+      set_last_result(ERROR_PERMISSION_DENIED);
+    else
+      set_last_result(ERROR_IO_ERROR);
+    g_error_free(err);
+  }
+
+  g_variant_builder_unref(builder);
+  return reply;
+}
+
+int DBusSender::SendMessage(const IEventInfo& info, list<Bundle> serialized,
+    string dest_appid) {
+  string appid = info.GetOwner();
+  if (appid.length() == 0)
+    appid = util::GetAppId();
+
+  GDBusMessage* reply = impl_->MethodCall(appid, info, serialized);
+  if (!reply)
+    return ERROR_IO_ERROR;
+
+  int ret = ERROR_NONE;
+  GError* err = nullptr;
+  if (g_dbus_message_to_gerror(reply, &err)) {
+    LOGE("SendMessage got error %s", err->message);
+    if (err->code == G_DBUS_ERROR_ACCESS_DENIED) {
+      set_last_result(ERROR_PERMISSION_DENIED);
+      ret = ERROR_PERMISSION_DENIED;
+    } else {
+      set_last_result(ERROR_IO_ERROR);
+      ret = ERROR_IO_ERROR;
+    }
+    g_error_free(err);
+    return ret;
+  } else {
+    set_last_result(ERROR_NONE);
+  }
+
+  GVariant *reply_body = g_dbus_message_get_body(reply);
+  g_variant_get(reply_body, "(i)", &ret);
+  return ret;
+}
+
 std::list<Bundle> DBusSender::Request(const IEventInfo& info) {
   string appid = info.GetOwner();
   if (appid.length() == 0)
@@ -142,11 +229,27 @@ std::list<Bundle> DBusSender::Request(const IEventInfo& info) {
   string method_name = EventInfo::GetString(info.GetEventType());
   Bundle serialized = info.Serialize();
 
+  list<Bundle> ret_list;
   GDBusMessage* reply = impl_->MethodCall(appid, method_name, serialized);
-  GVariant *reply_body = g_dbus_message_get_body(reply);
+  if (!reply)
+    return ret_list;
+
+  GError* err = nullptr;
+  if (g_dbus_message_to_gerror(reply, &err)) {
+    LOGE("Request got error %s", err->message);
+    if (err->code == G_DBUS_ERROR_ACCESS_DENIED)
+      set_last_result(ERROR_PERMISSION_DENIED);
+    else
+      set_last_result(ERROR_IO_ERROR);
 
+    g_error_free(err);
+    return ret_list;
+  } else {
+    set_last_result(ERROR_NONE);
+  }
+
+  GVariant *reply_body = g_dbus_message_get_body(reply);
   GVariantIter *iter = nullptr;
-  list<Bundle> ret_list;
   g_variant_get(reply_body, "(a(s))", &iter);
   char* raw = nullptr;
   while (g_variant_iter_loop(iter, "(s)", &raw) && raw != nullptr) {
@@ -166,9 +269,25 @@ int DBusSender::RequestNumber(const IEventInfo& info) {
   Bundle serialized = info.Serialize();
 
   GDBusMessage* reply = impl_->MethodCall(appid, method_name, serialized);
-  GVariant *reply_body = g_dbus_message_get_body(reply);
+  if (!reply)
+    return 0;
+
+  GError* err = nullptr;
+  if (g_dbus_message_to_gerror(reply, &err)) {
+    LOGE("RequestNumber got error %s", err->message);
+    if (err->code == G_DBUS_ERROR_ACCESS_DENIED)
+      set_last_result(ERROR_PERMISSION_DENIED);
+    else
+      set_last_result(ERROR_IO_ERROR);
+
+    g_error_free(err);
+    return 0;
+  } else {
+    set_last_result(ERROR_NONE);
+  }
 
   int num;
+  GVariant *reply_body = g_dbus_message_get_body(reply);
   g_variant_get(reply_body, "(i)", &num);
   return num;
 }
index 8f95d25..894cc57 100644 (file)
@@ -37,6 +37,8 @@ class EXPORT_API DBusSender : public IEventSender {
   virtual ~DBusSender();
   void Notify(const IEventInfo& info, std::list<tizen_base::Bundle> serialized,
       std::string dest_appid = "") override;
+  int SendMessage(const IEventInfo& info, std::list<tizen_base::Bundle> serialized,
+      std::string dest_appid = "") override;
   std::list<tizen_base::Bundle> Request(const IEventInfo& info) override;
   int RequestNumber(const IEventInfo& info) override;
 
index cef9c70..d7f0d5b 100644 (file)
@@ -24,6 +24,7 @@
 #include <list>
 
 #include "notification-ex/dbus_sender.h"
+#include "notification-ex/ievent_info.h"
 
 namespace notification {
 
@@ -41,6 +42,8 @@ class DBusSender::Impl {
   bool EmitSignal(std::string bus_name, std::string signal_name, GVariant* data);
   GDBusMessage* MethodCall(std::string appid, std::string method_name,
       tizen_base::Bundle serialized);
+  GDBusMessage* MethodCall(std::string appid, const IEventInfo& info,
+      std::list<tizen_base::Bundle> serialized);
   std::string path_;
   DBusSender* parent_;
 };
index dadfc6c..523d656 100644 (file)
@@ -36,8 +36,11 @@ class EXPORT_API IEventSender {
   virtual void Notify(const IEventInfo& info,
       std::list<tizen_base::Bundle> serialized,
       std::string dest_appid = "") = 0;
-  virtual std::list<tizen_base::Bundle> Request(const IEventInfo &info) = 0;
-  virtual int RequestNumber(const IEventInfo &info) = 0;
+  virtual int SendMessage(const IEventInfo& info,
+      std::list<tizen_base::Bundle> serialized,
+      std::string dest_appid = "") = 0;
+  virtual std::list<tizen_base::Bundle> Request(const IEventInfo& info) = 0;
+  virtual int RequestNumber(const IEventInfo& info) = 0;
 };
 
 }  // namespace notification
index 5243dfb..e8fab13 100644 (file)
@@ -53,9 +53,9 @@ Manager::~Manager() = default;
 Manager::Impl::~Impl() {
   listener_->UnRegisterObserver(parent_);
 
-  list<Bundle> dummy_list {};
+  list<Bundle> serialized_list {};
   EventInfo info(EventInfo::Unregister, util::GetAppId(), "", "");
-  sender_->Notify(info, dummy_list, DATA_PROVIDER_MASTER_ID);
+  sender_->SendMessage(info, serialized_list, DATA_PROVIDER_MASTER_ID);
 }
 Manager::Impl::Impl(Manager* parent,
     unique_ptr<IEventSender> sender,
@@ -66,9 +66,12 @@ Manager::Impl::Impl(Manager* parent,
   LOGI("impl created");
   listener_->RegisterObserver(parent_);
 
+  if (DBusConnectionManager::GetInst().IsDataProviderMaster(util::GetAppId()))
+    return;
+
   list<Bundle> serialized_list {};
   EventInfo info(EventInfo::Register, util::GetAppId(), receiver_group, "");
-  sender_->Notify(info, serialized_list, DATA_PROVIDER_MASTER_ID);
+  sender_->SendMessage(info, serialized_list, DATA_PROVIDER_MASTER_ID);
 }
 
 int Manager::Impl::SendNotify(shared_ptr<item::AbstractItem> noti,
@@ -87,39 +90,52 @@ void Manager::SendError(const IEventInfo& info, NotificationError error) {
   IEventInfo& i = const_cast<IEventInfo&>(info);
   static_cast<IEventInfoInternal&>(i).SetError(error);
   static_cast<IEventInfoInternal&>(i).SetEventType(EventInfo::Error);
-  impl_->sender_->Notify(info, serialized_list, info.GetOwner());
+  impl_->sender_->SendMessage(info, serialized_list, info.GetOwner());
 }
 
-int Manager::Update(shared_ptr<item::AbstractItem> noti) {
-  return impl_->SendNotify(noti, EventInfo::Update);
+int Manager::Update(shared_ptr<item::AbstractItem> noti, int& request_id) {
+  Bundle serialized = noti->Serialize();
+  EventInfo info(EventInfo::Update, util::GetAppId(), noti->GetChannel(), noti->GetId());
+  list<Bundle> serialized_list {serialized};
+
+  request_id = info.GetRequestId();
+  return impl_->sender_->SendMessage(info, serialized_list, noti->GetSenderAppId());
 }
 
-int Manager::Delete(shared_ptr<item::AbstractItem> noti) {
-  return impl_->SendNotify(noti, EventInfo::Delete);
+int Manager::Delete(shared_ptr<item::AbstractItem> noti, int& request_id) {
+  Bundle serialized = noti->Serialize();
+  EventInfo info(EventInfo::Delete, util::GetAppId(), noti->GetChannel(), noti->GetId());
+  list<Bundle> serialized_list {serialized};
+
+  request_id = info.GetRequestId();
+  return impl_->sender_->SendMessage(info, serialized_list, noti->GetSenderAppId());
 }
 
-int Manager::DeleteAll() {
+int Manager::DeleteAll(int& request_id) {
   Bundle serialized;
   EventInfo info(EventInfo::DeleteAll, util::GetAppId(), "");
   list<Bundle> serialized_list {serialized};
-  impl_->sender_->Notify(info, serialized_list, util::GetAppId());
-  return info.GetRequestId();
+
+  request_id = info.GetRequestId();
+  return impl_->sender_->SendMessage(info, serialized_list, util::GetAppId());
 }
 
-int Manager::DeleteByChannel(string channel) {
+int Manager::DeleteByChannel(string channel, int& request_id) {
   Bundle serialized;
   EventInfo info(EventInfo::DeleteAll, util::GetAppId(), channel);
   list<Bundle> serialized_list {serialized};
-  impl_->sender_->Notify(info, serialized_list, util::GetAppId());
-  return info.GetRequestId();
+
+  request_id = info.GetRequestId();
+  return impl_->sender_->SendMessage(info, serialized_list, util::GetAppId());
 }
 
-int Manager::DeleteByAppId(string appId) {
+int Manager::DeleteByAppId(string appId, int& request_id) {
   Bundle serialized;
   EventInfo info(EventInfo::DeleteAll, util::GetAppId(), "", appId);
   list<Bundle> serialized_list {serialized};
-  impl_->sender_->Notify(info, serialized_list, util::GetAppId());
-  return info.GetRequestId();
+
+  request_id = info.GetRequestId();
+  return impl_->sender_->SendMessage(info, serialized_list, util::GetAppId());
 }
 
 int Manager::GetCount() const {
@@ -128,9 +144,15 @@ int Manager::GetCount() const {
   return num;
 }
 
-int Manager::Hide(shared_ptr<item::AbstractItem> noti) {
+int Manager::Hide(shared_ptr<item::AbstractItem> noti, int& request_id) {
   (reinterpret_cast<IItemInfoInternal*>(noti->GetInfo().get()))->AddHideViewer(util::GetAppId());
-  return impl_->SendNotify(noti, EventInfo::Update);
+
+  EventInfo info(EventInfo::Update, util::GetAppId(), noti->GetChannel(), noti->GetId());
+  Bundle serialized = noti->Serialize();
+  list<Bundle> serialized_list {serialized};
+
+  request_id = info.GetRequestId();
+  return impl_->sender_->SendMessage(info, serialized_list, noti->GetSenderAppId());
 }
 
 unique_ptr<item::AbstractItem> Manager::FindByRootID(string id) {
@@ -158,6 +180,7 @@ list<unique_ptr<item::AbstractItem>> Manager::Get(string channel) {
 
 int Manager::SendEvent(const IEventInfo& info,
     shared_ptr<item::AbstractItem> noti) {
+  LOGI("manager-sendevent");
   Bundle serialized = noti->Serialize();
   Bundle serialized_info = info.Serialize();
   list<Bundle> serialized_list {serialized};
@@ -167,6 +190,7 @@ int Manager::SendEvent(const IEventInfo& info,
 
 int Manager::SendEvent(const IEventInfo& info,
     list<shared_ptr<item::AbstractItem>> notiList) {
+  LOGI("manager-sendevent - list");
   list<Bundle> serialized_list;
   for (auto& i : notiList) {
     Bundle b = i->Serialize();
index 5134dee..e303c60 100644 (file)
@@ -40,12 +40,12 @@ class EXPORT_API Manager : public IEventObserver {
   virtual ~Manager();
 
   std::list<std::unique_ptr<item::AbstractItem>> Get(std::string channel = "");
-  int Update(std::shared_ptr<item::AbstractItem> noti);
-  int Delete(std::shared_ptr<item::AbstractItem> noti);
-  int DeleteAll();
-  int DeleteByChannel(std::string channel);
-  int DeleteByAppId(std::string appId);
-  int Hide(std::shared_ptr<item::AbstractItem> noti);
+  int Update(std::shared_ptr<item::AbstractItem> noti, int& request_id);
+  int Delete(std::shared_ptr<item::AbstractItem> noti, int& request_id);
+  int DeleteAll(int& request_id);
+  int DeleteByChannel(std::string channel, int& request_id);
+  int DeleteByAppId(std::string appId, int& request_id);
+  int Hide(std::shared_ptr<item::AbstractItem> noti, int& request_id);
   std::unique_ptr<item::AbstractItem> FindByRootID(std::string id);
   int SendEvent(const IEventInfo& info, std::shared_ptr<item::AbstractItem> noti);
   int SendEvent(const IEventInfo& info, std::list<std::shared_ptr<item::AbstractItem>> notiList);
index 40b8929..c8cef07 100644 (file)
@@ -72,18 +72,24 @@ void Reporter::SendError(const IEventInfo& info, NotificationError error) {
   IEventInfo& i = const_cast<IEventInfo&>(info);
   static_cast<IEventInfoInternal&>(i).SetError(error);
   static_cast<IEventInfoInternal&>(i).SetEventType(EventInfo::Error);
-  impl_->sender_->Notify(info, serialized_list, info.GetOwner());
+  impl_->sender_->SendMessage(info, serialized_list, info.GetOwner());
 }
 
-int Reporter::Post(std::shared_ptr<item::AbstractItem> noti) {
+int Reporter::Post(std::shared_ptr<item::AbstractItem> noti, int& request_id) {
   LOGI("Post noti");
   static_pointer_cast<IItemInfoInternal>(noti->GetInfo())->SetTime(time(NULL));
+  Bundle serialized = noti->Serialize();
+
+  EventInfo info(EventInfo::Post, util::GetAppId(), noti->GetChannel(), noti->GetId());
+  list<Bundle> serialized_list {serialized};
   SharedFile::CopyPrivateFile(noti);
 
-  return impl_->SendNotify(noti, EventInfo::Post);
+  request_id = info.GetRequestId();
+  return impl_->sender_->SendMessage(info, serialized_list);
 }
 
-int Reporter::Post(std::list<std::shared_ptr<AbstractItem>> notiList) {
+int Reporter::Post(std::list<std::shared_ptr<AbstractItem>> notiList, int& request_id) {
+  LOGI("Post noti list");
   EventInfo info(EventInfo::Post, util::GetAppId(), "");
   list<Bundle> serialized_list;
   for (auto& i : notiList) {
@@ -92,18 +98,24 @@ int Reporter::Post(std::list<std::shared_ptr<AbstractItem>> notiList) {
     serialized_list.push_back(b);
     SharedFile::CopyPrivateFile(i);
   }
-  impl_->sender_->Notify(info, serialized_list);
-  return info.GetRequestId();
+
+  request_id = info.GetRequestId();
+  return impl_->sender_->SendMessage(info, serialized_list);
 }
 
-int Reporter::Update(std::shared_ptr<AbstractItem> noti) {
+int Reporter::Update(std::shared_ptr<AbstractItem> noti, int& request_id) {
   static_pointer_cast<IItemInfoInternal>(noti->GetInfo())->SetTime(time(NULL));
+  Bundle serialized = noti->Serialize();
+
+  EventInfo info(EventInfo::Update, util::GetAppId(), noti->GetChannel(), noti->GetId());
+  list<Bundle> serialized_list {serialized};
   SharedFile::CopyPrivateFile(noti);
 
-  return impl_->SendNotify(noti, EventInfo::Update);
+  request_id = info.GetRequestId();
+  return impl_->sender_->SendMessage(info, serialized_list);
 }
 
-int Reporter::Update(std::list<std::shared_ptr<AbstractItem>> notiList) {
+int Reporter::Update(std::list<std::shared_ptr<AbstractItem>> notiList, int& request_id) {
   EventInfo info(EventInfo::Update, util::GetAppId(), "");
   list<Bundle> serialized_list;
   for (auto& i : notiList) {
@@ -112,15 +124,21 @@ int Reporter::Update(std::list<std::shared_ptr<AbstractItem>> notiList) {
     serialized_list.push_back(b);
     SharedFile::CopyPrivateFile(i);
   }
-  impl_->sender_->Notify(info, serialized_list);
-  return info.GetRequestId();
+
+  request_id = info.GetRequestId();
+  return impl_->sender_->SendMessage(info, serialized_list);
 }
 
-int Reporter::Delete(std::shared_ptr<AbstractItem> noti) {
-  return impl_->SendNotify(noti, EventInfo::Delete);
+int Reporter::Delete(std::shared_ptr<AbstractItem> noti, int& request_id) {
+  Bundle serialized = noti->Serialize();
+  EventInfo info(EventInfo::Delete, util::GetAppId(), noti->GetChannel(), noti->GetId());
+  list<Bundle> serialized_list {serialized};
+
+  request_id = info.GetRequestId();
+  return impl_->sender_->SendMessage(info, serialized_list, noti->GetSenderAppId());
 }
 
-int Reporter::Delete(std::list<std::shared_ptr<AbstractItem>> notiList) {
+int Reporter::Delete(std::list<std::shared_ptr<AbstractItem>> notiList, int& request_id) {
   EventInfo info(EventInfo::Delete, util::GetAppId(), "");
   list<Bundle> serialized_list;
   for (auto& i : notiList) {
@@ -129,24 +147,27 @@ int Reporter::Delete(std::list<std::shared_ptr<AbstractItem>> notiList) {
     serialized_list.push_back(b);
     SharedFile::CopyPrivateFile(i);
   }
-  impl_->sender_->Notify(info, serialized_list);
-  return info.GetRequestId();
+
+  request_id = info.GetRequestId();
+  return impl_->sender_->SendMessage(info, serialized_list);
 }
 
-int Reporter::DeleteAll() {
+int Reporter::DeleteAll(int& request_id) {
   Bundle serialized;
   EventInfo info(EventInfo::DeleteAll, util::GetAppId(), "");
   list<Bundle> serialized_list {serialized};
-  impl_->sender_->Notify(info, serialized_list, util::GetAppId());
-  return info.GetRequestId();
+
+  request_id = info.GetRequestId();
+  return impl_->sender_->SendMessage(info, serialized_list, util::GetAppId());
 }
 
-int Reporter::DeleteByChannel(string channel) {
+int Reporter::DeleteByChannel(string channel, int& request_id) {
   Bundle serialized;
   EventInfo info(EventInfo::DeleteAll, util::GetAppId(), channel);
   list<Bundle> serialized_list {serialized};
-  impl_->sender_->Notify(info, serialized_list, util::GetAppId());
-  return info.GetRequestId();
+
+  request_id = info.GetRequestId();
+  return impl_->sender_->SendMessage(info, serialized_list, util::GetAppId());
 }
 
 std::unique_ptr<AbstractItem> Reporter::FindByRootID(std::string id) {
index 36e6840..ba6f4b3 100644 (file)
@@ -43,14 +43,14 @@ class EXPORT_API Reporter : public IEventObserver {
   int SendEvent(const IEventInfo& info,
       std::list<std::shared_ptr<item::AbstractItem>> notiList);
   void SendError(const IEventInfo& info, NotificationError error);
-  int Post(std::shared_ptr<item::AbstractItem> noti);
-  int Post(std::list<std::shared_ptr<item::AbstractItem>> notiList);
-  int Update(std::shared_ptr<item::AbstractItem> noti);
-  int Update(std::list<std::shared_ptr<item::AbstractItem>> notiList);
-  int Delete(std::shared_ptr<item::AbstractItem> noti);
-  int Delete(std::list<std::shared_ptr<item::AbstractItem>> notiList);
-  int DeleteAll();
-  int DeleteByChannel(std::string channel);
+  int Post(std::shared_ptr<item::AbstractItem> noti, int& request_id);
+  int Post(std::list<std::shared_ptr<item::AbstractItem>> notiList, int& request_id);
+  int Update(std::shared_ptr<item::AbstractItem> noti, int& request_id);
+  int Update(std::list<std::shared_ptr<item::AbstractItem>> notiList, int& request_id);
+  int Delete(std::shared_ptr<item::AbstractItem> noti, int& request_id);
+  int Delete(std::list<std::shared_ptr<item::AbstractItem>> notiList, int& request_id);
+  int DeleteAll(int& request_id);
+  int DeleteByChannel(std::string channel, int& request_id);
   std::unique_ptr<item::AbstractItem> FindByRootID(std::string id);
   std::list<std::unique_ptr<item::AbstractItem>> FindByChannel(std::string channel);
   std::list<std::unique_ptr<item::AbstractItem>> FindAll();
index bb24f2e..52564fd 100644 (file)
@@ -2626,6 +2626,13 @@ extern "C" EXPORT_API int noti_ex_manager_create(noti_ex_manager_h *handle,
     LOGE("Fail to create manager");
     return NOTI_EX_ERROR_IO_ERROR;
   }
+
+  int ret = get_last_result();
+  if (ret == ERROR_PERMISSION_DENIED || ret == ERROR_IO_ERROR) {
+    LOGE("error(%d)", ret);
+    delete stub;
+    return ret;
+  }
   stub->SetManagerCallbackInfo(unique_ptr<ManagerCallbackInfo>(
       new ManagerCallbackInfo(event_callbacks, data)));
   *handle = static_cast<noti_ex_manager_h>(stub);
@@ -2653,11 +2660,20 @@ extern "C" EXPORT_API int noti_ex_manager_get(noti_ex_manager_h handle,
   try {
     ManagerStub* stub = static_cast<ManagerStub*>(handle);
     list<unique_ptr<item::AbstractItem>> item_list = stub->Get();
+    int ret = get_last_result();
+    if (ret == ERROR_PERMISSION_DENIED || ret == ERROR_IO_ERROR) {
+      LOGE("error(%d)", ret);
+      *items = nullptr;
+      *count = 0;
+      return ret;
+    }
+
     if (item_list.size() == 0) {
       *items = nullptr;
       *count = 0;
       return NOTI_EX_ERROR_NONE;
     }
+
     noti_ex_item_h* added_item =
         (noti_ex_item_h*)calloc(item_list.size(), sizeof(noti_ex_item_h));
     if (added_item == nullptr) {
@@ -2689,6 +2705,14 @@ extern "C" EXPORT_API int noti_ex_manager_get_by_channel(
   try {
     ManagerStub* stub = static_cast<ManagerStub*>(handle);
     list<unique_ptr<item::AbstractItem>> item_list = stub->Get(channel);
+    int ret = get_last_result();
+    if (ret == ERROR_PERMISSION_DENIED || ret == ERROR_IO_ERROR) {
+      LOGE("error(%d)", ret);
+      *items = nullptr;
+      *count = 0;
+      return ret;
+    }
+
     if (item_list.size() == 0) {
       *items = nullptr;
       *count = 0;
@@ -2717,6 +2741,8 @@ extern "C" EXPORT_API int noti_ex_manager_get_by_channel(
 
 extern "C" EXPORT_API int noti_ex_manager_update(noti_ex_manager_h handle,
     noti_ex_item_h noti, int *request_id) {
+  int ret = ERROR_NONE;
+
   if (handle == nullptr || noti == nullptr || request_id == nullptr) {
     LOGE("Invalid parameter");
     return NOTI_EX_ERROR_INVALID_PARAMETER;
@@ -2728,21 +2754,24 @@ extern "C" EXPORT_API int noti_ex_manager_update(noti_ex_manager_h handle,
       LOGE("Invalid noti reference can not be sended");
       return NOTI_EX_ERROR_INVALID_PARAMETER;
     } else {
-      *request_id = stub->Update(sp->GetPtr());
+      ret = stub->Update(sp->GetPtr(), *request_id);
     }
   } catch (Exception &ex) {
     LOGE("%s %d", ex.what(), ex.GetErrorCode());
     return NOTI_EX_ERROR_IO_ERROR;
   }
-  return NOTI_EX_ERROR_NONE;
+  return ret;
 }
 
 extern "C" EXPORT_API int noti_ex_manager_delete(noti_ex_manager_h handle,
     noti_ex_item_h noti, int *request_id) {
+  int ret = ERROR_NONE;
+
   if (handle == nullptr || noti == nullptr || request_id == nullptr) {
     LOGE("Invalid parameter");
     return NOTI_EX_ERROR_INVALID_PARAMETER;
   }
+
   try {
     ManagerStub* stub = static_cast<ManagerStub*>(handle);
     Handle* item = static_cast<Handle*>(noti);
@@ -2750,33 +2779,38 @@ extern "C" EXPORT_API int noti_ex_manager_delete(noti_ex_manager_h handle,
       LOGE("Invalid noti reference can not be sended");
       return NOTI_EX_ERROR_INVALID_PARAMETER;
     } else {
-      *request_id = stub->Delete(item->GetPtr());
+      ret = stub->Delete(item->GetPtr(), *request_id);
     }
   } catch (Exception &ex) {
     LOGE("%s %d", ex.what(), ex.GetErrorCode());
     return NOTI_EX_ERROR_IO_ERROR;
   }
-  return NOTI_EX_ERROR_NONE;
+
+  return ret;
 }
 
 extern "C" EXPORT_API int noti_ex_manager_delete_all(noti_ex_manager_h handle,
     int *request_id) {
+  int ret = ERROR_NONE;
+
   if (handle == nullptr || request_id == nullptr) {
     LOGE("Invalid parameter");
     return NOTI_EX_ERROR_INVALID_PARAMETER;
   }
   try {
     ManagerStub* stub = static_cast<ManagerStub*>(handle);
-    *request_id = stub->DeleteAll();
+    ret = stub->DeleteAll(*request_id);
   } catch (Exception &ex) {
     LOGE("%s %d", ex.what(), ex.GetErrorCode());
     return NOTI_EX_ERROR_IO_ERROR;
   }
-  return NOTI_EX_ERROR_NONE;
+  return ret;
 }
 
 extern "C" EXPORT_API int noti_ex_manager_delete_by_channel(
     noti_ex_manager_h handle, const char* channel, int* request_id) {
+  int ret = ERROR_NONE;
+
   if (handle == nullptr || channel == nullptr || request_id == nullptr) {
     LOGE("Invalid parameter");
     return NOTI_EX_ERROR_INVALID_PARAMETER;
@@ -2784,17 +2818,19 @@ extern "C" EXPORT_API int noti_ex_manager_delete_by_channel(
 
   try {
     ManagerStub* stub = static_cast<ManagerStub*>(handle);
-    *request_id = stub->DeleteByChannel(channel);
+    ret = stub->DeleteByChannel(channel, *request_id);
   } catch (Exception &ex) {
     LOGE("%s %d", ex.what(), ex.GetErrorCode());
     return NOTI_EX_ERROR_IO_ERROR;
   }
 
-  return NOTI_EX_ERROR_NONE;
+  return ret;
 }
 
 extern "C" EXPORT_API int noti_ex_manager_delete_by_appid(
     noti_ex_manager_h handle, const char* app_id, int* request_id) {
+  int ret = ERROR_NONE;
+
   if (handle == nullptr || app_id == nullptr || request_id == nullptr) {
     LOGE("Invalid parameter");
     return NOTI_EX_ERROR_INVALID_PARAMETER;
@@ -2802,17 +2838,19 @@ extern "C" EXPORT_API int noti_ex_manager_delete_by_appid(
 
   try {
     ManagerStub* stub = static_cast<ManagerStub*>(handle);
-    *request_id = stub->DeleteByAppId(app_id);
+    ret = stub->DeleteByAppId(app_id, *request_id);
   } catch (Exception &ex) {
     LOGE("%s %d", ex.what(), ex.GetErrorCode());
     return NOTI_EX_ERROR_IO_ERROR;
   }
 
-  return NOTI_EX_ERROR_NONE;
+  return ret;
 }
 
 extern "C" EXPORT_API int noti_ex_manager_hide(noti_ex_manager_h handle,
     noti_ex_item_h noti, int *request_id) {
+  int ret = ERROR_NONE;
+
   if (handle == nullptr || noti == nullptr || request_id == nullptr) {
     LOGE("Invalid parameter");
     return NOTI_EX_ERROR_INVALID_PARAMETER;
@@ -2824,13 +2862,13 @@ extern "C" EXPORT_API int noti_ex_manager_hide(noti_ex_manager_h handle,
       LOGE("Invalid noti reference can not be sended");
       return NOTI_EX_ERROR_INVALID_PARAMETER;
     } else {
-      *request_id = stub->Hide(item->GetPtr());
+      ret = stub->Hide(item->GetPtr(), *request_id);
     }
   } catch (Exception &ex) {
     LOGE("%s %d", ex.what(), ex.GetErrorCode());
     return NOTI_EX_ERROR_IO_ERROR;
   }
-  return NOTI_EX_ERROR_NONE;
+  return ret;
 }
 
 extern "C" EXPORT_API int noti_ex_manager_find_by_root_id(
@@ -2842,6 +2880,12 @@ extern "C" EXPORT_API int noti_ex_manager_find_by_root_id(
   try {
     ManagerStub* stub = static_cast<ManagerStub*>(handle);
     shared_ptr<AbstractItem> ptr = stub->FindByRootID(root_id);
+    int ret = get_last_result();
+    if (ret == ERROR_PERMISSION_DENIED || ret == ERROR_IO_ERROR) {
+      LOGE("error(%d)", ret);
+      return ret;
+    }
+
     if (ptr == nullptr) {
       LOGW("Not exist ID");
       *item = nullptr;
@@ -2866,6 +2910,12 @@ extern "C" EXPORT_API int noti_ex_manager_send_error(noti_ex_manager_h handle,
     IEventInfo* c_info = static_cast<IEventInfo*>(info);
     stub->SendError(static_cast<const IEventInfo&>(*c_info),
         static_cast<NotificationError>(error));
+
+    int ret = get_last_result();
+    if (ret == ERROR_PERMISSION_DENIED || ret == ERROR_IO_ERROR) {
+      LOGE("error(%d)", ret);
+      return ret;
+    }
   } catch (Exception &ex) {
     LOGE("%s %d", ex.what(), ex.GetErrorCode());
     return NOTI_EX_ERROR_IO_ERROR;
@@ -2882,6 +2932,12 @@ extern "C" EXPORT_API int noti_ex_manager_get_notification_count(
   try {
     ManagerStub* stub = static_cast<ManagerStub*>(handle);
     *count = stub->GetCount();
+
+    int ret = get_last_result();
+    if (ret == ERROR_PERMISSION_DENIED || ret == ERROR_IO_ERROR) {
+      LOGE("error(%d)", ret);
+      return ret;
+    }
   } catch (Exception &ex) {
     LOGE("%s %d", ex.what(), ex.GetErrorCode());
     return NOTI_EX_ERROR_IO_ERROR;
@@ -3073,6 +3129,8 @@ extern "C" EXPORT_API int noti_ex_reporter_send_error(noti_ex_reporter_h handle,
 
 extern "C" EXPORT_API int noti_ex_reporter_post(noti_ex_reporter_h handle,
     noti_ex_item_h noti, int *request_id) {
+  int ret = NOTI_EX_ERROR_NONE;
+
   if (handle == nullptr || noti == nullptr || request_id == nullptr) {
     LOGE("Invalid parameter");
     return NOTI_EX_ERROR_INVALID_PARAMETER;
@@ -3084,17 +3142,18 @@ extern "C" EXPORT_API int noti_ex_reporter_post(noti_ex_reporter_h handle,
       LOGE("Invalid noti reference can not be sended");
       return NOTI_EX_ERROR_INVALID_PARAMETER;
     } else {
-      *request_id = stub->Post(h->GetPtr());
+      ret = stub->Post(h->GetPtr(), *request_id);
     }
   } catch (Exception &ex) {
     LOGE("%s %d", ex.what(), ex.GetErrorCode());
     return NOTI_EX_ERROR_IO_ERROR;
   }
-  return NOTI_EX_ERROR_NONE;
+  return ret;
 }
 
 extern "C" EXPORT_API int noti_ex_reporter_post_list(noti_ex_reporter_h handle,
     noti_ex_item_h *noti_list, int count, int *request_id) {
+  int ret = NOTI_EX_ERROR_NONE;
 
   if (handle == nullptr || noti_list == nullptr || request_id == nullptr) {
     LOGE("Invalid parameter");
@@ -3107,16 +3166,18 @@ extern "C" EXPORT_API int noti_ex_reporter_post_list(noti_ex_reporter_h handle,
       Handle* item = static_cast<Handle*>(noti_list[i]);
       notiList.push_back(item->GetPtr());
     }
-    *request_id = stub->Post(notiList);
+    ret = stub->Post(notiList, *request_id);
   } catch (Exception &ex) {
     LOGE("%s %d", ex.what(), ex.GetErrorCode());
     return NOTI_EX_ERROR_IO_ERROR;
   }
-  return NOTI_EX_ERROR_NONE;
+  return ret;
 }
 
 extern "C" EXPORT_API int noti_ex_reporter_update(noti_ex_reporter_h handle,
     noti_ex_item_h noti, int *request_id) {
+  int ret = NOTI_EX_ERROR_NONE;
+
   if (handle == nullptr || noti == nullptr || request_id == nullptr) {
     LOGE("Invalid parameter");
     return NOTI_EX_ERROR_INVALID_PARAMETER;
@@ -3128,39 +3189,43 @@ extern "C" EXPORT_API int noti_ex_reporter_update(noti_ex_reporter_h handle,
       LOGE("Invalid noti reference can not be sended");
       return NOTI_EX_ERROR_INVALID_PARAMETER;
     } else {
-      *request_id = stub->Update(item->GetPtr());
+      ret = stub->Update(item->GetPtr(), *request_id);
     }
   } catch (Exception &ex) {
     LOGE("%s %d", ex.what(), ex.GetErrorCode());
     return NOTI_EX_ERROR_IO_ERROR;
   }
-  return NOTI_EX_ERROR_NONE;
+  return ret;
 }
 
 extern "C" EXPORT_API int noti_ex_reporter_update_list(
     noti_ex_reporter_h handle, noti_ex_item_h *noti_list, int count,
     int *request_id) {
-    if (handle == nullptr || noti_list == nullptr || request_id == nullptr) {
-      LOGE("Invalid parameter");
-      return NOTI_EX_ERROR_INVALID_PARAMETER;
-    }
-    try {
-      ReporterStub* stub = static_cast<ReporterStub*>(handle);
-      list<shared_ptr<item::AbstractItem>> notiList;
-      for (int i = 0; i < count; i++) {
-        Handle* item = static_cast<Handle*>(noti_list[i]);
-        notiList.push_back(item->GetPtr());
-      }
-      *request_id = stub->Update(notiList);
-    } catch (Exception &ex) {
-      LOGE("%s %d", ex.what(), ex.GetErrorCode());
-      return NOTI_EX_ERROR_IO_ERROR;
+  int ret = NOTI_EX_ERROR_NONE;
+
+  if (handle == nullptr || noti_list == nullptr || request_id == nullptr) {
+    LOGE("Invalid parameter");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+  try {
+    ReporterStub* stub = static_cast<ReporterStub*>(handle);
+    list<shared_ptr<item::AbstractItem>> notiList;
+    for (int i = 0; i < count; i++) {
+      Handle* item = static_cast<Handle*>(noti_list[i]);
+      notiList.push_back(item->GetPtr());
     }
-    return NOTI_EX_ERROR_NONE;
+    ret = stub->Update(notiList, *request_id);
+  } catch (Exception &ex) {
+    LOGE("%s %d", ex.what(), ex.GetErrorCode());
+    return NOTI_EX_ERROR_IO_ERROR;
+  }
+  return ret;
 }
 
 extern "C" EXPORT_API int noti_ex_reporter_delete(noti_ex_reporter_h handle,
     noti_ex_item_h noti, int *request_id) {
+  int ret = NOTI_EX_ERROR_NONE;
+
   if (handle == nullptr || noti == nullptr || request_id == nullptr) {
     LOGE("Invalid parameter");
     return NOTI_EX_ERROR_INVALID_PARAMETER;
@@ -3172,55 +3237,65 @@ extern "C" EXPORT_API int noti_ex_reporter_delete(noti_ex_reporter_h handle,
       LOGE("Invalid noti reference can not be sended");
       return NOTI_EX_ERROR_INVALID_PARAMETER;
     } else {
-      *request_id = stub->Delete(item->GetPtr());
+      ret = stub->Delete(item->GetPtr(), *request_id);
     }
   } catch (Exception &ex) {
     LOGE("%s %d", ex.what(), ex.GetErrorCode());
     return NOTI_EX_ERROR_IO_ERROR;
   }
-  return NOTI_EX_ERROR_NONE;
+  return ret;
 }
 
 extern "C" EXPORT_API int noti_ex_reporter_delete_list(
     noti_ex_reporter_h handle, noti_ex_item_h *noti_list, int count,
     int *request_id) {
-    if (handle == nullptr || noti_list == nullptr || request_id == nullptr) {
-      LOGE("Invalid parameter");
-      return NOTI_EX_ERROR_INVALID_PARAMETER;
-    }
-    try {
-      ReporterStub* stub = static_cast<ReporterStub*>(handle);
-      list<shared_ptr<item::AbstractItem>> notiList;
-      for (int i = 0; i < count; i++) {
-        Handle* item = static_cast<Handle*>(noti_list[i]);
-        notiList.push_back(item->GetPtr());
-      }
-      *request_id = stub->Delete(notiList);
-    } catch (Exception &ex) {
-      LOGE("%s %d", ex.what(), ex.GetErrorCode());
-      return NOTI_EX_ERROR_IO_ERROR;
+  int ret = NOTI_EX_ERROR_NONE;
+
+  if (handle == nullptr || noti_list == nullptr || request_id == nullptr) {
+    LOGE("Invalid parameter");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+
+  try {
+    ReporterStub* stub = static_cast<ReporterStub*>(handle);
+    list<shared_ptr<item::AbstractItem>> notiList;
+    for (int i = 0; i < count; i++) {
+      Handle* item = static_cast<Handle*>(noti_list[i]);
+      notiList.push_back(item->GetPtr());
     }
-    return NOTI_EX_ERROR_NONE;
+    ret = stub->Delete(notiList, *request_id);
+  } catch (Exception &ex) {
+    LOGE("%s %d", ex.what(), ex.GetErrorCode());
+    return NOTI_EX_ERROR_IO_ERROR;
+  }
+
+  return ret;
 }
 
 extern "C" EXPORT_API int noti_ex_reporter_delete_all(
     noti_ex_reporter_h handle, int *request_id) {
+  int ret = NOTI_EX_ERROR_NONE;
+
   if (handle == nullptr || request_id == nullptr) {
     LOGE("Invalid parameter");
     return NOTI_EX_ERROR_INVALID_PARAMETER;
   }
+
   try {
     ReporterStub* stub = static_cast<ReporterStub*>(handle);
-    *request_id = stub->DeleteAll();
+    ret = stub->DeleteAll(*request_id);
   } catch (Exception &ex) {
     LOGE("%s %d", ex.what(), ex.GetErrorCode());
     return NOTI_EX_ERROR_IO_ERROR;
   }
-  return NOTI_EX_ERROR_NONE;
+
+  return ret;
 }
 
 extern "C" EXPORT_API int noti_ex_reporter_delete_by_channel(
     noti_ex_reporter_h handle, const char* channel, int* request_id) {
+  int ret = NOTI_EX_ERROR_NONE;
+
   if (handle == nullptr || channel == nullptr || request_id == nullptr) {
     LOGE("Invalid parameter");
     return NOTI_EX_ERROR_INVALID_PARAMETER;
@@ -3228,13 +3303,13 @@ extern "C" EXPORT_API int noti_ex_reporter_delete_by_channel(
 
   try {
     ReporterStub* stub = static_cast<ReporterStub*>(handle);
-    *request_id = stub->DeleteByChannel(channel);
+    ret = stub->DeleteByChannel(channel, *request_id);
   } catch (Exception &ex) {
     LOGE("%s %d", ex.what(), ex.GetErrorCode());
     return NOTI_EX_ERROR_IO_ERROR;
   }
 
-  return NOTI_EX_ERROR_NONE;
+  return ret;
 }
 
 extern "C" EXPORT_API int noti_ex_reporter_find_by_root_id(