Add new func for extentsion data 70/217170/13
authormk5004.lee <mk5004.lee@samsung.com>
Thu, 7 Nov 2019 07:24:29 +0000 (16:24 +0900)
committermk5004.lee <mk5004.lee@samsung.com>
Wed, 22 Jan 2020 02:44:01 +0000 (11:44 +0900)
Change-Id: I2f73802e9750ae027e029408d71c0ce76ad6a40e
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
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/stub.cc
unittest/src/test_abstract_item.cc

index ccb177863393d43d311591cb401fcb6baf48a611..fe143fb1a0187b5fca1d0e4eb10f5e89b7a8599a 100644 (file)
@@ -88,6 +88,7 @@
 #define ABSTRACT_ITEM_MAIN_TYPE_KEY "__ABSTRACT_ITEM_MAIN_TYPE_KEY__"
 #define ABSTRACT_ITEM_MULTI_LANG_ARR_KEY "__ABSTRACT_ITEM_MULTI_LANG_ARR_KEY__"
 #define ABSTRACT_ITEM_MULTI_LANG_KEY "__ABSTRACT_ITEM_MULTI_LANG_KEY__"
+#define ABSTRACT_ITEM_EXTENSION_DATA_KEY "__ABSTRACT_ITEM_EXTENSION_DATA_KEY__"
 
 using namespace std;
 using namespace tizen_base;
@@ -285,6 +286,9 @@ Bundle AbstractItem::Serialize() const {
     b.Add(ABSTRACT_ITEM_HIDE_VIEWER_KEY, arr);
   }
 
+  b.Add(ABSTRACT_ITEM_EXTENSION_DATA_KEY,
+    reinterpret_cast<char*>(impl_->extension_data_.ToRaw().first.get()));
+
   return b;
 }
 
@@ -415,6 +419,8 @@ void AbstractItem::Deserialize(Bundle b) {
       impl_->hide_viewer_list_.push_back(str);
     }
   }
+
+  impl_->extension_data_ = Bundle(b.GetString(ABSTRACT_ITEM_EXTENSION_DATA_KEY));
 }
 
 void AbstractItem::SetId(std::string id) {
@@ -701,5 +707,20 @@ void AbstractItem::UpdateVibrationPrivatePath() {
   delete(shared_file);
 }
 
+tizen_base::Bundle AbstractItem::GetExtensionData(std::string key) {
+  if (impl_->extension_data_.GetString(key) == "")
+    return Bundle();
+  else
+    return Bundle(impl_->extension_data_.GetString(key));
+}
+
+void AbstractItem::SetExtensionData(std::string key, Bundle value) {
+  if (impl_->extension_data_.GetString(key) != "")
+    impl_->extension_data_.Delete(key);
+
+  impl_->extension_data_.Add(key,
+    reinterpret_cast<char*>(value.ToRaw().first.get()));
+}
+
 }  // namespace item
 }  // namespace notification
index 83bddb1e02ea88abb3cb5f5058eb2e8950c3ec98..c4e912d0ed96993ec75cf53807856ad699402268 100644 (file)
@@ -1070,6 +1070,22 @@ class EXPORT_API AbstractItem {
    */
   MainType GetMainType() const;
 
+  /**
+   * @brief Gets the extension data.
+   * @since_tizen 5.5
+   * @param[in] key
+   * @return Bundle
+   */
+  tizen_base::Bundle GetExtensionData(std::string key);
+
+  /**
+   * @brief Sets the extension data.
+   * @since_tizen 5.5
+   * @param[in] key key string
+   * @param[in] value Bundle
+   */
+  void SetExtensionData(std::string key, tizen_base::Bundle value);
+
  private:
   class Impl;
   std::unique_ptr<Impl> impl_;
index 2d38c2de9617f91b745285f322ff004e2a0f33b0..bf2b76959fb9e797ed9895b89075f58e30749af9 100644 (file)
@@ -74,6 +74,7 @@ class AbstractItem::Impl {
   std::string background_;
   bool ongoing_ = false;
   MainType main_type_ = MainNone;
+  tizen_base::Bundle extension_data_;
 };
 
 }  // namespace item
index eda78a12211bff940bda0c6b1a6c7777b9a65798..5a2c1f2582dbfd22c37855d6263275198724ca1e 100644 (file)
@@ -36,8 +36,12 @@ int noti_ex_style_set_padding(noti_ex_style_h handle,
 int noti_ex_led_info_set_color(
     noti_ex_led_info_h handle, noti_ex_color_h color);
 
+int noti_ex_item_get_extension_data(noti_ex_item_h handle, const char *key,
+               bundle **value);
+int noti_ex_item_set_extension_data(noti_ex_item_h handle, const char *key,
+               bundle *value);
 
 #ifdef __cplusplus
 }
 #endif
-#endif  /* __TIZEN_APPFW_NOTIFICATION_EX_INTERNAL_H__ */
\ No newline at end of file
+#endif  /* __TIZEN_APPFW_NOTIFICATION_EX_INTERNAL_H__ */
index 0f0d6d635407ca476215044bcb37cfb29ea7e77e..b11bd927bb1ac0ab1c73fae09317c60df83598f9 100644 (file)
@@ -2509,6 +2509,39 @@ extern "C" EXPORT_API int noti_ex_item_find_by_main_type(noti_ex_item_h handle,
   return NOTI_EX_ERROR_NONE;
 }
 
+extern "C" EXPORT_API int noti_ex_item_get_extension_data(noti_ex_item_h handle,
+    const char *key, bundle **value) {
+  if (handle == nullptr || key == nullptr || value == nullptr) {
+    LOGE("Invalid handle type");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+
+  Handle* p = static_cast<Handle*>(handle);
+
+  Bundle b = p->Get()->GetExtensionData(key);
+  if (b.GetCount() == 0)
+    *value = nullptr;
+  else
+    *value = b.GetHandle();
+
+  return NOTI_EX_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int noti_ex_item_set_extension_data(noti_ex_item_h handle,
+    const char *key, bundle *value) {
+  if (handle == nullptr || key == nullptr || value == nullptr) {
+    LOGE("Invalid handle type");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+
+  Bundle b = Bundle(value);
+
+  Handle* p = static_cast<Handle*>(handle);
+  p->Get()->SetExtensionData(key, b);
+
+  return NOTI_EX_ERROR_NONE;
+}
+
 extern "C" EXPORT_API int noti_ex_manager_create(noti_ex_manager_h *handle,
     const char *receiver_group, noti_ex_manager_events_s event_callbacks,
     void *data) {
index 58b5d1c6ab330d56330469a0b5e1cbd11d0c543d..ef3650eae6e187cb4dc5873419d4f6b3e9b5c9fc 100644 (file)
@@ -94,6 +94,7 @@ TEST_F(AbstractItemTest, SerializeDeserialize) {
   app_control_h app_control, app_control_1;
   char* app_id = NULL;
   time_t current_time;
+  Bundle extension_b;
 
   app_control_create(&app_control);
   app_control_set_app_id(app_control, "new_appid");
@@ -141,6 +142,9 @@ TEST_F(AbstractItemTest, SerializeDeserialize) {
   item.SetLEDInfo(led);
   item.SetOnGoingState(true);
 
+  extension_b.Add("test_key", "test_value");
+  item.SetExtensionData("extension_key", extension_b);
+
   /* Deserialize */
   Bundle b = item.Serialize();
 
@@ -235,6 +239,9 @@ TEST_F(AbstractItemTest, SerializeDeserialize) {
 
   ASSERT_STREQ(app_id, "new_appid_1");
   ASSERT_EQ(gen_test->GetOnGoingState(), true);
+
+  Bundle extension_b2 = gen_test->GetExtensionData("extension_key");
+  ASSERT_EQ(extension_b2.GetString("test_key"), "test_value");
 }
 
 TEST_F(AbstractItemTest, SerializeDeserialize2) {