Add noti_ex_item_button_set/get_contents api 83/228583/1
authormk5004.lee <mk5004.lee@samsung.com>
Tue, 24 Mar 2020 05:01:40 +0000 (14:01 +0900)
committermk5004.lee <mk5004.lee@samsung.com>
Tue, 24 Mar 2020 05:01:40 +0000 (14:01 +0900)
Change-Id: I008a0b50de9ffce9a2833b360ba912138818b36b
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
notification-ex/api/notification_ex_internal.h [changed mode: 0755->0644]
notification-ex/button_item.cc
notification-ex/button_item.h
notification-ex/button_item_implementation.h
notification-ex/stub.cc

old mode 100755 (executable)
new mode 100644 (file)
index 52ad052..c3e325a
@@ -42,6 +42,8 @@ int noti_ex_item_icon_get_icon_path(noti_ex_item_h handle, char **icon_path);
 
 int noti_ex_item_button_set_image(noti_ex_item_h handle, const char *path);
 int noti_ex_item_button_get_image(noti_ex_item_h handle, char **path);
+int noti_ex_item_button_set_contents(noti_ex_item_h handle, const char *contents);
+int noti_ex_item_button_get_contents(noti_ex_item_h handle, char **contents);
 
 int noti_ex_reporter_find_by_channel(noti_ex_reporter_h handle,
                const char *channel, noti_ex_item_h **noti_list, int *count);
index 9e7cd4c..f69b68d 100644 (file)
@@ -29,6 +29,7 @@
 #define LOG_TAG "NOTIFICATION_EX"
 #define BUTTON_TITLE_KEY "__BUTTON_TITLE_KEY__"
 #define BUTTON_IMAGE_KEY "__BUTTON_IMAGE_KEY__"
+#define BUTTON_CONTENTS_KEY "__BUTTON_CONTENTS_KEY__"
 
 using namespace std;
 using namespace tizen_base;
@@ -63,6 +64,8 @@ Bundle ButtonItem::Serialize() const {
   b.Add(BUTTON_TITLE_KEY, impl_->title_);
   if (!impl_->img_path_.empty())
     b.Add(BUTTON_IMAGE_KEY, impl_->img_path_);
+  if (!impl_->contents_.empty())
+    b.Add(BUTTON_CONTENTS_KEY, impl_->contents_);
   return b;
 }
 
@@ -70,6 +73,7 @@ void ButtonItem::Deserialize(Bundle b) {
   AbstractItem::Deserialize(b);
   impl_->title_ = b.GetString(BUTTON_TITLE_KEY);
   impl_->img_path_ = b.GetString(BUTTON_IMAGE_KEY);
+  impl_->contents_ = b.GetString(BUTTON_CONTENTS_KEY);
 }
 
 bool ButtonItem::IsItemTypeExist(int type) {
@@ -90,5 +94,13 @@ std::string ButtonItem::GetImgPath() const {
   return impl_->img_path_;
 }
 
+void ButtonItem::SetContents(std::string contents) {
+  impl_->contents_ = contents;
+}
+
+std::string ButtonItem::GetContents() const {
+  return impl_->contents_;
+}
+
 }  // namespace item
 }  // namespace notification
index 620122f..95880f3 100644 (file)
@@ -110,6 +110,20 @@ class EXPORT_API ButtonItem : public AbstractItem {
    */
   void SetImgPath(std::string path);
 
+  /**
+   * @brief Gets the contents of ButtonItem.
+   * @since_tizen 5.5
+   * @return The contents string
+   */
+  std::string GetContents() const;
+
+  /**
+   * @brief Sets the contents of ButtonItem.
+   * @since_tizen 5.5
+   * @param[in] contents The contents string
+   */
+  void SetContents(std::string contents);
+
  private:
   class Impl;
   std::unique_ptr<Impl> impl_;
index 701bd58..d454640 100644 (file)
@@ -38,6 +38,7 @@ class ButtonItem::Impl {
 
   std::string title_;
   std::string img_path_;
+  std::string contents_;
   ButtonItem* parent_;
 };
 
index 82d79fe..34d9db2 100644 (file)
@@ -473,6 +473,47 @@ extern "C" EXPORT_API int noti_ex_item_button_get_image(
   return NOTI_EX_ERROR_NONE;
 }
 
+extern "C" EXPORT_API int noti_ex_item_button_set_contents(
+    noti_ex_item_h handle, const char *contents) {
+  if (handle == nullptr || contents == nullptr) {
+    LOGE("Invalid parameter");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+
+  Handle* h = static_cast<Handle*>(handle);
+  if (!h->IsValidType(AbstractItem::Button)) {
+    LOGE("Invalid handle type");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+
+  ButtonItem* p = static_cast<ButtonItem*>(h->Get());
+  p->SetContents(std::string(contents));
+
+  return NOTI_EX_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int noti_ex_item_button_get_contents(
+    noti_ex_item_h handle, char **contents) {
+  if (handle == nullptr || contents == nullptr) {
+    LOGE("Invalid parameter");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+
+  Handle* h = static_cast<Handle*>(handle);
+  if (!h->IsValidType(AbstractItem::Button)) {
+    LOGE("Invalid handle type");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+
+  ButtonItem* p = static_cast<ButtonItem*>(h->Get());
+  if (!p->GetContents().empty())
+    *contents = strdup(p->GetContents().c_str());
+  else
+    *contents = nullptr;
+
+  return NOTI_EX_ERROR_NONE;
+}
+
 extern "C" EXPORT_API int noti_ex_item_chat_message_create(
     noti_ex_item_h *handle, const char *id, noti_ex_item_h name,
     noti_ex_item_h text, noti_ex_item_h image, noti_ex_item_h time,