Apply API version 52/212552/4 sandbox/noti_ex_porting
authorJusung Son <jusung07.son@samsung.com>
Fri, 23 Aug 2019 01:44:32 +0000 (10:44 +0900)
committerJusung Son <jusung07.son@samsung.com>
Tue, 8 Oct 2019 06:55:42 +0000 (15:55 +0900)
Change-Id: I98a5fa33fc1772f868da91bc4c0ac3ef20f4e170
Signed-off-by: Jusung Son <jusung07.son@samsung.com>
20 files changed:
notification-ex/abstract_item.cc
notification-ex/abstract_item.h
notification-ex/abstract_item_implementation.h
notification-ex/api/notification_ex_internal.h
notification-ex/db_manager.cc
notification-ex/db_manager.h
notification-ex/event_info.cc
notification-ex/event_info_implementation.h
notification-ex/event_info_internal.h
notification-ex/ievent_info.h
notification-ex/ievent_info_internal.h
notification-ex/iitem_info_internal.h
notification-ex/item_info.cc
notification-ex/item_info_internal.h
notification-ex/manager.cc
notification-ex/manager.h
notification-ex/manager_implementation.h
notification-ex/stub.cc
notification/src/notification_convert.c
unittest/src/test_abstract_item.cc

index f39331eaabe1eca9ffeaef8fbde979a553a67bd2..91d256fd047bfa79ea737a90abb55ffb1154d34a 100644 (file)
@@ -141,7 +141,7 @@ Bundle AbstractItem::Serialize() const {
   b.Add(ABSTRACT_ITEM_ID_KEY, impl_->id_);
   b.Add(ABSTRACT_ITEM_SENDER_APPID_KEY, GetSenderAppId().c_str());
   b.Add(ABSTRACT_ITEM_TYPE_KEY, to_string(GetType()));
-  b.Add(ABSTRACT_ITEM_VERSION_KEY, to_string(impl_->version_));
+  b.Add(ABSTRACT_ITEM_VERSION_KEY, to_string(static_cast<int>(impl_->version_)));
   b.Add(ABSTRACT_ITEM_HIDE_TIME_KEY, to_string(impl_->hide_time_));
   b.Add(ABSTRACT_ITEM_DELETE_TIME_KEY, to_string(impl_->delete_time_));
   b.Add(ABSTRACT_ITEM_UID_KEY, to_string(impl_->uid_));
@@ -246,7 +246,7 @@ void AbstractItem::Deserialize(Bundle b) {
   impl_->id_ = b.GetString(ABSTRACT_ITEM_ID_KEY);
   impl_->sender_appid_ = b.GetString(ABSTRACT_ITEM_SENDER_APPID_KEY);
   impl_->channel_ = b.GetString(ABSTRACT_ITEM_CHANNEL_KEY);
-  impl_->version_ = stoi(b.GetString(ABSTRACT_ITEM_VERSION_KEY));
+  impl_->version_ = static_cast<AbstractItem::Version>(stoi(b.GetString(ABSTRACT_ITEM_VERSION_KEY)));
   impl_->hide_time_ = stoi(b.GetString(ABSTRACT_ITEM_HIDE_TIME_KEY));
   impl_->delete_time_ = stoi(b.GetString(ABSTRACT_ITEM_DELETE_TIME_KEY));
   impl_->can_receive_ = b.GetString(ABSTRACT_ITEM_CAN_RECEIVE_KEY);
index e9961a75602451a9544b76e13f80cecaded37520..e2af2e819fdb513bf65d4130acf4c772aeb8cf2f 100644 (file)
@@ -375,6 +375,12 @@ class EXPORT_API AbstractItem {
     SimMode = 1 << 1,
   };
 
+  enum Version {
+    Legacy = 1 << 0,
+    Extension = 1 << 1,
+    ALL = Legacy | Extension
+  };
+
  public:
   /**
    * @brief Constructor
index 24a434b6b47da73a375fd221aa374e5605610736..92d851f33a07d9656c9b79aaa097cd85ebf2c6ea 100644 (file)
@@ -48,7 +48,7 @@ class AbstractItem::Impl {
   std::shared_ptr<Style> style_ = nullptr;
   bool visible_ = true;
   bool enable_ = true;
-  int version_ = 1;
+  AbstractItem::Version version_ = AbstractItem::Version::Extension;
   int hide_time_ = 0;
   int delete_time_ = 0;
   std::list<std::string> receiver_group_list_;
index da7ea5dd8e7c71e6c542a78f385f459e9ac95706..39dfa222339e0ca08a5ab10efb814d4bd71bba96 100644 (file)
 #define __TIZEN_APPFW_NOTIFICATION_EX_INTERNAL_H__
 
 #include <notification_ex_item.h>
+#include <notification_ex_manager.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+typedef enum _noti_ex_item_version {
+       NOTI_EX_ITEM_VERSION_LEGACY = 1 << 0,
+       NOTI_EX_ITEM_VERSION_EXTENSION = 1 << 1,
+       NOTI_EX_ITEM_VERSION_ALL = NOTI_EX_ITEM_VERSION_LEGACY
+                                       | NOTI_EX_ITEM_VERSION_EXTENSION
+} noti_ex_item_version_e;
+
 int noti_ex_item_get_version(noti_ex_item_h item, int *version);
 int noti_ex_item_set_version(noti_ex_item_h item, int version);
 int noti_ex_item_get_uid(noti_ex_item_h item, int *uid);
@@ -36,6 +44,8 @@ int noti_ex_item_get_hide_viewer_list(noti_ex_item_h item,
 int noti_ex_ptr_get(noti_ex_item_h item, void** ptr);
 int noti_ex_ptr_destroy(void* ptr);
 int noti_ex_item_create(noti_ex_item_h *handle, void* item);
+int noti_ex_manager_set_unified_mode(noti_ex_manager_h handle, bool mode);
+int noti_ex_manager_get_unified_mode(noti_ex_manager_h handle, bool* mode);
 
 #ifdef __cplusplus
 }
index 734d5b42cbbe6cfe1f7c4c68ac3289e542685db6..aafcadf33059b5ae29a7994692134529bf0d44a8 100644 (file)
@@ -48,6 +48,7 @@
   " priv_id INTEGER PRIMARY KEY,\n" \
   " pkg_id TEXT,\n" \
   " policy INTEGER,\n" \
+  " version INTEGER,\n" \
   " data TEXT NOT NULL,\n" \
   " insert_time INTEGER,\n" \
   " hide_list TEXT,\n" \
@@ -438,14 +439,15 @@ int DBManager::InsertNotification(list<shared_ptr<item::AbstractItem>> addedItem
     static_pointer_cast<IItemInfoInternal>(i->GetInfo())->SetPrivateId(seq);
     Bundle b = i->Serialize();
     query = sqlite3_mprintf("INSERT INTO noti_ex_list"
-          " (root_id, app_id, uid, priv_id, pkg_id, policy, data, insert_time)"
-          " VALUES (%Q, %Q, %d, %" PRId64 ", %Q, %d, %Q, %d)",
+          " (root_id, app_id, uid, priv_id, pkg_id, policy, version, data, insert_time)"
+          " VALUES (%Q, %Q, %d, %" PRId64 ", %Q, %d, %d, %Q, %d)",
           i->GetId().c_str(),
           i->GetSenderAppId().c_str(),
           uid,
           static_pointer_cast<IItemInfoInternal>(i->GetInfo())->GetPrivateId(),
           GetPkgId(i->GetSenderAppId(),uid).c_str(),
           static_cast<int>(i->GetPolicy()),
+          static_cast<int>(static_pointer_cast<IItemInfoInternal>(i->GetInfo())->GetVersion()),
           reinterpret_cast<char*>(b.ToRaw().first.get()),
           static_pointer_cast<IItemInfo>(i->GetInfo())->GetTime());
 
@@ -701,13 +703,15 @@ list<shared_ptr<item::AbstractItem>> DBManager::ExecuteGetList(char* query) {
   return item_list;
 }
 
-list<shared_ptr<item::AbstractItem>> DBManager::GetNotificationList(string app_id, int uid) {
+list<shared_ptr<item::AbstractItem>> DBManager::GetNotificationList(string app_id,
+      int uid, item::AbstractItem::Version version) {
   char* query;
   list<shared_ptr<item::AbstractItem>> item_list;
 
   query = sqlite3_mprintf("SELECT data FROM noti_ex_list"
-                    " WHERE uid = %d AND app_id = %Q ORDER BY insert_time DESC",
-                    uid, app_id.c_str());
+                    " WHERE uid = %d AND app_id = %Q AND (version & %d) != 0"
+                    " ORDER BY insert_time DESC",
+                    uid, app_id.c_str(), static_cast<int>(version));
   if (!query) {
     LOGE("OOM - sql query");
     return item_list;
@@ -744,7 +748,12 @@ list<shared_ptr<item::AbstractItem>> DBManager::GetNotificationList
   char* query;
   list<shared_ptr<item::AbstractItem>> item_list;
 
-  query = sqlite3_mprintf("SELECT data FROM noti_ex_list"
+  if (app_id.empty())
+    query = sqlite3_mprintf("SELECT data FROM noti_ex_list"
+      " WHERE uid = %d AND priv_id = %" PRId64 "",
+      uid, priv_id);
+  else
+    query = sqlite3_mprintf("SELECT data FROM noti_ex_list"
       " WHERE uid = %d AND app_id = %Q AND priv_id = %" PRId64 "",
       uid, app_id.c_str(), priv_id);
 
@@ -759,27 +768,35 @@ list<shared_ptr<item::AbstractItem>> DBManager::GetNotificationList
   return item_list;
 }
 
-list<shared_ptr<item::AbstractItem>> DBManager::GetNotificationList(int uid) {
-  int ret, sim_mode;
+list<shared_ptr<item::AbstractItem>> DBManager::GetNotificationList(int uid,
+      item::AbstractItem::Version version, item::AbstractItem::Policy policy, bool sim_check_mode) {
+  int ret, sim_status;
   char* query;
   list<shared_ptr<item::AbstractItem>> item_list;
+  string policy_query, sim_query;
 
+  if (sim_check_mode) {
   /* Check current sim status */
-  ret = vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT, &sim_mode);
-  if (ret < 0) {
-    sim_mode = VCONFKEY_TELEPHONY_SIM_INSERTED;
-    LOGI("vconf_get_int");
-  }
+    ret = vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT, &sim_status);
+    if (ret < 0) {
+      sim_status = VCONFKEY_TELEPHONY_SIM_INSERTED;
+      LOGI("vconf_get_int");
+    }
 
-  if (sim_mode == VCONFKEY_TELEPHONY_SIM_INSERTED) {
-    query = sqlite3_mprintf("SELECT data FROM noti_ex_list WHERE uid = %d"
-                            " ORDER BY insert_time DESC", uid);
-  } else {
-    query = sqlite3_mprintf("SELECT data FROM noti_ex_list"
-            " WHERE  uid = %d AND (policy & %d) == 0 ORDER BY insert_time DESC",
-            uid, static_cast<int>(item::AbstractItem::Policy::SimMode));
+    if (sim_status != VCONFKEY_TELEPHONY_SIM_INSERTED)
+      sim_query = " AND (policy & " +
+          to_string(static_cast<int>(item::AbstractItem::Policy::SimMode)) +
+          ") == 0";
   }
 
+  if (policy != item::AbstractItem::Policy::None)
+    policy_query = " AND (policy & " + to_string(static_cast<int>(policy)) + ") != 0";
+
+  string query_str = "SELECT data FROM noti_ex_list WHERE uid == %d AND (version & %d) != 0 " +
+        policy_query + sim_query;
+
+  query = sqlite3_mprintf(query_str.c_str(), uid, static_cast<int>(version));
+
   if (!query) {
     LOGE("OOM - sql query");
     return item_list;
index 0817dfa13fac1a0f6d2c1aaee7568ccaad31348a..48878db20aacf92cd28640014a28d7a76425ccc3 100644 (file)
@@ -43,10 +43,16 @@ class EXPORT_API DBManager {
   static int GetCount(int64_t priv_id, const std::string& root_id, const std::string& app_id, int uid, int* count);
   static int GetCount(const std::string& app_id, int uid, int* count);
   static int DeleteNotification(std::shared_ptr<item::AbstractItem> deletedItem);
-  static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(int uid);
-  static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(std::string app_id, int uid);
-  static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(std::string app_id, std::string root_id, int uid);
-  static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(std::string app_id, int64_t private_id, int uid);
+  static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(
+                     int uid, item::AbstractItem::Version version,
+                     item::AbstractItem::Policy policy, bool sim_check_mode);
+  static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(
+                     std::string app_id, int uid,
+                     item::AbstractItem::Version version);
+  static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(
+                     std::string app_id, std::string root_id, int uid);
+  static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(
+                     std::string app_id, int64_t private_id, int uid);
 
  private:
   DBManager(); /* LCOV_EXCL_LINE */
index fda2de5c2396f58001aecd1c4c7b234cffd2b208..9eaeb18e1b950256e8f6e1c61cc218760d0e032d 100644 (file)
@@ -35,6 +35,7 @@
 #define NOTIFICATION_EX_EVENT_UID_KEY "__NOTIFICATION_EX_EVENT_UID_KEY__"
 #define NOTIFICATION_EX_EVENT_REQUEST_ID_KEY "__NOTIFICATION_EX_EVENT_REQUEST_ID_KEY__"
 #define NOTIFICATION_EX_EVENT_ERROR_KEY "__NOTIFICATION_EX_EVENT_ERROR_KEY__"
+#define NOTIFICATION_EX_EVENT_REQUEST_VERSION_KEY "__NOTIFICATION_EX_EVENT_REQUEST_VERSION_KEY__"
 
 using namespace std;
 namespace notification {
@@ -71,6 +72,8 @@ EventInfo::EventInfo(Bundle serialized)
   string error_str =
       serialized.GetString(NOTIFICATION_EX_EVENT_ERROR_KEY);
   impl_->error_ = (NotificationError)strtol(error_str.c_str(), NULL, 10);
+  impl_->request_version_ = static_cast<item::AbstractItem::Version>
+      (stoi(serialized.GetString(NOTIFICATION_EX_EVENT_REQUEST_VERSION_KEY)));
 }
 
 string EventInfo::GetString(int type) {
@@ -105,6 +108,8 @@ Bundle EventInfo::Serialize() const {
       NOTIFICATION_EX_EVENT_REQUEST_ID_KEY, to_string(impl_->request_id_));
   serialized.Add(
       NOTIFICATION_EX_EVENT_ERROR_KEY, to_string(impl_->error_));
+  serialized.Add(NOTIFICATION_EX_EVENT_REQUEST_VERSION_KEY,
+      to_string(static_cast<int>(impl_->request_version_)));
 
   return serialized;
 }
@@ -149,4 +154,11 @@ void EventInfo::SetError(NotificationError error) {
   impl_->error_ = error;
 }
 
+void EventInfo::SetRequestVersion(item::AbstractItem::Version version) {
+  impl_->request_version_ = version;
+}
+
+item::AbstractItem::Version EventInfo::GetRequestVersion() const {
+  return impl_->request_version_;
+}
 }  // namespace notification
index 41ef31fd82a3bbc8b87e6ce255f13128620690f5..b1a8cde7988358a0ec2a99d0f805e17f607e9d5e 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <sys/types.h>
 
+#include "notification-ex/abstract_item.h"
 #include "notification-ex/dbus_sender.h"
 #include "notification-ex/ievent_info.h"
 #include "notification-ex/common.h"
@@ -47,6 +48,7 @@ class EventInfo::Impl {
   int request_id_;
   NotificationError error_;
   EventInfo* parent_;
+  item::AbstractItem::Version request_version_ = item::AbstractItem::Version::Extension;
 };
 
 }  // namespace notification
index c13f4a9b9aa20209007aeb386a013081edd7fbe6..622f79c3184ebddaa1d3d108d4b2be2e6ab8837e 100644 (file)
@@ -47,6 +47,8 @@ class EXPORT_API EventInfo : public IEventInfoInternal {
   std::string GetItemId() const override;
   int GetRequestId() const override;
   Bundle Serialize() const override;
+  void SetRequestVersion(item::AbstractItem::Version) override;
+  item::AbstractItem::Version GetRequestVersion() const override;
   static std::string GetString(int type);
 
  private:
index c4e13e69f2444c68472bdbaa92b15523f1df63a1..f0f51766a51fb478845d69dadac5a161e8c00890 100644 (file)
@@ -18,6 +18,7 @@
 #define NOTIFICATION_EX_IEVENT_INFO_H_
 
 #include "notification-ex/ex_bundle.h"
+#include "notification-ex/abstract_item.h"
 
 namespace notification {
 
@@ -44,6 +45,7 @@ class EXPORT_API IEventInfo {
   virtual std::string GetItemId() const = 0;
   virtual int GetRequestId() const = 0;
   virtual Bundle Serialize() const = 0;
+  virtual item::AbstractItem::Version GetRequestVersion() const = 0;
 };
 
 }  // namespace notification
index d5ef3a639f9a47cb8043acfa3a5a76b5eee3e30e..3febc07f695afafd1b383be37117e6750504010f 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "notification-ex/common.h"
 #include "notification-ex/ievent_info.h"
+#include "notification-ex/abstract_item.h"
 
 namespace notification {
 
@@ -30,6 +31,7 @@ class IEventInfoInternal : public IEventInfo {
   virtual NotificationError GetError() const = 0;
   virtual void SetError(NotificationError error) = 0;
   virtual void SetEventType(int type) = 0;
+  virtual void SetRequestVersion(item::AbstractItem::Version version) = 0;
 };
 
 }  // namespace notification
index 597debcef9612c2a588c6f12e414d19c22e359e2..e2facd5c3d4ac40892e312c05c89873b852f5905 100644 (file)
@@ -33,12 +33,12 @@ class EXPORT_API IItemInfoInternal : public IItemInfo {
   virtual void SetUid(int uid) = 0;
   virtual int64_t GetPrivateId() const = 0;
   virtual void SetPrivateId(int64_t private_id) = 0;
-  virtual int GetVersion() const = 0;
-  virtual void SetVersion(int ver) = 0;
+  virtual AbstractItem::Version GetVersion() const = 0;
+  virtual void SetVersion(AbstractItem::Version ver) = 0;
   virtual void AddHideViewer(std::string appid) = 0;
   virtual std::list<std::string> GetHideViewerList() const = 0;
   virtual void SetTime(time_t time) = 0;
-  virtual bool CanReceive(std::string receiver_group) const = 0;
+  virtual bool CanReceive(std::string receiver_group, bool unified_mode) const = 0;
 };
 
 }  // namespace item
index 60da396d352bb221f9594e25711c1406108454b3..0f64c0560e1e8c3fa02c6ac22c4face54346d4d8 100644 (file)
@@ -59,11 +59,11 @@ void AbstractItem::Impl::ItemInfo::SetTime(time_t time) {
   impl_->time_ = time;
 }
 
-int AbstractItem::Impl::ItemInfo::GetVersion() const {
+AbstractItem::Version AbstractItem::Impl::ItemInfo::GetVersion() const {
   return impl_->version_;
 }
 
-void AbstractItem::Impl::ItemInfo::SetVersion(int ver) {
+void AbstractItem::Impl::ItemInfo::SetVersion(AbstractItem::Version ver) {
   impl_->version_ = ver;
 }
 
@@ -92,7 +92,10 @@ void AbstractItem::Impl::ItemInfo::AddHideViewer(std::string appid) {
   impl_->hide_viewer_list_.push_back(appid);
 }
 
-bool AbstractItem::Impl::ItemInfo::CanReceive(std::string receiver_group) const {
+bool AbstractItem::Impl::ItemInfo::CanReceive(std::string receiver_group, bool unified_mode) const {
+  if (unified_mode == false && impl_->version_ < AbstractItem::Version::Extension)
+    return false;
+
   if (impl_->receiver_group_list_.size() != 0 && !receiver_group.empty()) {
     list<string>::iterator iter =
       std::find(impl_->receiver_group_list_.begin(),
index c40af758f43e88dba7ec459bfd308b3d4628e715..4bc2bf13543d586bfdf016f6a9973ce0da07e5a2 100644 (file)
@@ -33,15 +33,15 @@ class AbstractItem::Impl::ItemInfo : public IItemInfoInternal {
   void SetUid(int uid) override;
   time_t GetTime() const override;
   void SetTime(time_t time) override;
-  int GetVersion() const override;
-  void SetVersion(int ver) override;
+  AbstractItem::Version GetVersion() const override;
+  void SetVersion(AbstractItem::Version ver) override;
   void SetHideTime(int hide_time) override;
   int GetHideTime() const override;
   void SetDeleteTime(int delete_time) override;
   int GetDeleteTime() const override;
   void AddHideViewer(std::string appid) override;
   std::list<std::string> GetHideViewerList() const override;
-  bool CanReceive(std::string receiver_group) const override;
+  bool CanReceive(std::string receiver_group, bool unified_mode) const override;
 
  private:
   AbstractItem::Impl* impl_;
index 8067aa6b9e6b7ab7f9cf684ada082fe6ed124e94..2f1856300583cd6b5f021ca5e6e32628ac2164d2 100644 (file)
@@ -64,6 +64,9 @@ int Manager::Impl::SendNotify(shared_ptr<item::AbstractItem> noti,
     IEventInfo::EventType type) {
   Bundle serialized = noti->Serialize();
   EventInfo info(type, util::GetAppId(), noti->GetChannel(), noti->GetId());
+  if (unified_mode_)
+    info.SetRequestVersion(AbstractItem::Version::ALL);
+
   list<Bundle> serialized_list {serialized};
 
   /* Reply to Sender */
@@ -97,10 +100,21 @@ int Manager::DeleteAll() {
 
 int Manager::GetCount() const {
   EventInfo info(EventInfo::Count, util::GetAppId(), "");
+  if (GetUnifiedMode())
+    info.SetRequestVersion(AbstractItem::Version::ALL);
+
   int num = impl_->sender_->RequestNumber(info);
   return num;
 }
 
+void Manager::SetUnifiedMode(bool mode) {
+  impl_->unified_mode_ = mode;
+}
+
+bool Manager::GetUnifiedMode() const {
+  return impl_->unified_mode_;
+}
+
 int Manager::Hide(shared_ptr<item::AbstractItem> noti) {
   (reinterpret_cast<IItemInfoInternal*>(noti->GetInfo().get()))->AddHideViewer(util::GetAppId());
   return impl_->SendNotify(noti, EventInfo::Update);
@@ -120,6 +134,9 @@ unique_ptr<item::AbstractItem> Manager::FindByRootID(string id) {
 
 list<unique_ptr<item::AbstractItem>> Manager::Get() {
   EventInfo info(EventInfo::Get, util::GetAppId(), "");
+  if (GetUnifiedMode())
+    info.SetRequestVersion(AbstractItem::Version::ALL);
+
   list<Bundle> result = impl_->sender_->Request(info);
   list<unique_ptr<item::AbstractItem>> gen_list;
   for (auto& i : result) {
@@ -143,7 +160,7 @@ list<Bundle> Manager::OnRequest(const IEventInfo& info) {
   list<Bundle> serialized_list;
   for (auto& i : item_list) {
     if (std::static_pointer_cast<IItemInfoInternal>(i->GetInfo())
-          ->CanReceive(impl_->receiver_group_))
+          ->CanReceive(impl_->receiver_group_, GetUnifiedMode()))
       serialized_list.push_back(i->Serialize());
   }
   return serialized_list;
@@ -170,7 +187,7 @@ void Manager::OnEvent(const IEventInfo& info, list<Bundle> serialized) {
       for (auto& i : serialized) {
         gen_item = ItemInflator::Create(i);
         if (std::static_pointer_cast<IItemInfoInternal>(gen_item->GetInfo())
-              ->CanReceive(impl_->receiver_group_))
+              ->CanReceive(impl_->receiver_group_, GetUnifiedMode()))
           added.emplace_back(gen_item);
       }
       if (added.size() > 0)
@@ -181,7 +198,7 @@ void Manager::OnEvent(const IEventInfo& info, list<Bundle> serialized) {
       for (auto& i : serialized) {
         gen_item = ItemInflator::Create(i);
         if (std::static_pointer_cast<IItemInfoInternal>(gen_item->GetInfo())
-              ->CanReceive(impl_->receiver_group_))
+              ->CanReceive(impl_->receiver_group_, GetUnifiedMode()))
           OnUpdate(info, gen_item);
       }
       break;
@@ -190,7 +207,7 @@ void Manager::OnEvent(const IEventInfo& info, list<Bundle> serialized) {
       for (auto& i : serialized) {
         gen_item = ItemInflator::Create(i);
         if (std::static_pointer_cast<IItemInfoInternal>(gen_item->GetInfo())
-              ->CanReceive(impl_->receiver_group_))
+              ->CanReceive(impl_->receiver_group_, GetUnifiedMode()))
           OnDelete(info, gen_item);
       }
       break;
index 9fd69a3188fb7ce674881826824d1fc91f00f79e..68bf2f312be55e6731856a50ac140b1db6072fb3 100644 (file)
@@ -51,6 +51,8 @@ class EXPORT_API Manager : public IEventObserver {
   int OnRequestNumber(const IEventInfo& info) override;
   void SendError(const IEventInfo& info, NotificationError error);
   int GetCount() const;
+  void SetUnifiedMode(bool mode);
+  bool GetUnifiedMode() const;
   static std::string GetPath();
 
  protected:
index 55028222356262d22099ed6ba69873495c7dcfa3..b2af8d695683ba80ba2c60a49632da315797ce69 100644 (file)
@@ -41,6 +41,7 @@ class Manager::Impl {
   std::unique_ptr<IEventListener> listener_;
   std::string receiver_group_;
   Manager* parent_;
+  bool unified_mode_ = false;
 };
 
 }  // namespace notification
index 81aa45862e240f4d25425e26f699c3e9207deb5b..1f3eca49cfc561ae7d6195eba950fea8f15cd5e7 100644 (file)
@@ -2641,8 +2641,9 @@ extern "C" EXPORT_API int noti_ex_item_get_version(
   }
 
   Handle* h = static_cast<Handle*>(item);
-  *version =
-    static_pointer_cast<IItemInfoInternal>(h->Get()->GetInfo())->GetVersion();
+  *version = static_cast<int>(
+    static_pointer_cast<IItemInfoInternal>(h->Get()->GetInfo())
+    ->GetVersion());
 
   return NOTI_EX_ERROR_NONE;
 }
@@ -2655,7 +2656,8 @@ extern "C" EXPORT_API int noti_ex_item_set_version(
   }
 
   Handle* h = static_cast<Handle*>(item);
-  static_pointer_cast<IItemInfoInternal>(h->Get()->GetInfo())->SetVersion(version);
+  static_pointer_cast<IItemInfoInternal>(h->Get()->GetInfo())
+    ->SetVersion(static_cast<AbstractItem::Version>(version));
 
   return NOTI_EX_ERROR_NONE;
 }
@@ -2813,3 +2815,42 @@ extern "C" EXPORT_API int noti_ex_item_create(
 
   return NOTI_EX_ERROR_NONE;
 }
+
+extern "C" EXPORT_API int noti_ex_manager_set_unified_mode(
+    noti_ex_manager_h handle, bool mode)
+{
+  if (handle == nullptr) {
+    LOGE("Invalid parameter");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+
+  try {
+    ManagerStub* stub = static_cast<ManagerStub*>(handle);
+    stub->SetUnifiedMode(mode);
+  } catch (Exception &ex) {
+    LOGE("%s %d", ex.what(), ex.GetErrorCode());
+    return NOTI_EX_ERROR_IO_ERROR;
+  }
+
+  return NOTI_EX_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int noti_ex_manager_get_unified_mode(
+    noti_ex_manager_h handle, bool* mode)
+{
+  if (handle == nullptr || mode == nullptr) {
+    LOGE("Invalid parameter");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+
+  try {
+    ManagerStub* stub = static_cast<ManagerStub*>(handle);
+    *mode = stub->GetUnifiedMode();
+  } catch (Exception &ex) {
+     LOGE("%s %d", ex.what(), ex.GetErrorCode());
+     return NOTI_EX_ERROR_IO_ERROR;
+  }
+
+  return NOTI_EX_ERROR_NONE;
+}
+
index c110cabd45ba9a333428851d928c750df0761628..7a23e0e9fee56862a8dbb32b816b8a7b3cdebf34 100644 (file)
@@ -494,7 +494,7 @@ int _convert_to_ex_text(notification_h noti, noti_ex_item_h group)
                        return notification_convert_to_ex_error(ret);
                }
 
-               if (text == NULL)
+               if (text == NULL || strlen(text) == 0)
                        continue;
 
                ret = noti_ex_item_text_create(&item, text_type_arr[i], text, NULL);
@@ -964,7 +964,7 @@ int _make_legacy_action(noti_ex_item_h group, int index,
                return ret;
 
        ret = noti_ex_item_get_action(item, &appcontrol_action);
-       if (ret != NOTI_EX_ERROR_NONE) {
+       if (ret != NOTI_EX_ERROR_NONE || appcontrol_action == NULL) {
                ERR("failed to convert(%d)", ret);
                return ret;
        }
@@ -1370,7 +1370,7 @@ int _convert_to_ex_receiver(notification_h noti, noti_ex_item_h group)
                return notification_convert_to_ex_error(ret);
        }
 
-       if (display_applist & NOTIFICATION_DISPLAY_APP_ALL
+       if ((display_applist & NOTIFICATION_DISPLAY_APP_ALL)
                != NOTIFICATION_DISPLAY_APP_ALL) {
                for (i = 0; i < sizeof(display_arr) / sizeof(display_arr[0]); i++) {
                        if (display_applist & display_arr[i]) {
@@ -1492,7 +1492,7 @@ EXPORT_API int notification_convert_to_legacy(
        }
 
        noti_ex_item_get_private_id(item, &priv_id);
-       ret = notification_set_priv_id(notification, priv_id);
+       ret = notification_set_priv_id(notification, (int)priv_id);
        if (ret != NOTI_EX_ERROR_NONE) {
                ERR("failed to convert(%d)", ret);
                goto out;
@@ -1560,6 +1560,12 @@ EXPORT_API int notification_convert_to_ex(
                return ret;
        }
 
+       ret = noti_ex_item_set_version(group_item, NOTI_EX_ITEM_VERSION_LEGACY);
+       if (ret != NOTI_EX_ERROR_NONE) {
+               ERR("failed to convert(%d)", ret);
+               return ret;
+       }
+
        notification_get_pkgname(noti, (char **)&id);
        ret = noti_ex_item_set_sender_app_id(group_item, id);
        if (ret != NOTI_EX_ERROR_NONE) {
index 0a7ed6f6dd7fe2636263ccfbda31ee78c41233af..2cdb01d6fb3ce4dcecab2a5b076ca3eb47da7db2 100644 (file)
@@ -110,7 +110,7 @@ TEST_F(AbstractItemTest, SerializeDeserialize) {
   std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->AddHideViewer("hide_1");
   std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->AddHideViewer("hide_2");
   item.SetPolicy(AbstractItem::Policy::OnBootClear);
-  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->SetVersion(3);
+  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->SetVersion(AbstractItem::Version::ALL);
   item.GetInfo()->SetHideTime(5);
   item.GetInfo()->SetDeleteTime(9);
   item.SetChannel("channel99");
@@ -143,7 +143,7 @@ TEST_F(AbstractItemTest, SerializeDeserialize) {
   ASSERT_EQ(gen_test->GetEnable(), false);
   ASSERT_EQ(gen_test->GetVisible(),false);
   ASSERT_EQ(gen_test->GetPolicy(), AbstractItem::Policy::OnBootClear);
-  ASSERT_EQ(std::static_pointer_cast<IItemInfoInternal>(gen_test->GetInfo())->GetVersion(), 3);
+  ASSERT_EQ(std::static_pointer_cast<IItemInfoInternal>(gen_test->GetInfo())->GetVersion(), AbstractItem::Version::ALL);
   ASSERT_EQ(gen_test->GetInfo()->GetHideTime(), 5);
   ASSERT_EQ(gen_test->GetInfo()->GetDeleteTime(), 9);
   ASSERT_EQ(gen_test->GetChannel(), "channel99");
@@ -225,9 +225,9 @@ TEST_F(AbstractItemTest, ItemInfoCanReceive) {
   item.AddReceiver(ReceiverGroup::Panel);
   item.AddReceiver(ReceiverGroup::LockScreen);
 
-  ASSERT_TRUE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::Panel));
-  ASSERT_TRUE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::LockScreen));
-  ASSERT_FALSE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::Popup));
+  ASSERT_TRUE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::Panel, true));
+  ASSERT_TRUE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::LockScreen, true));
+  ASSERT_FALSE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::Popup, true));
 }
 
 }  // namespace
\ No newline at end of file