Add internal api to support C# 83/217483/5
authorhyunho <hhstark.kang@samsung.com>
Tue, 12 Nov 2019 05:36:28 +0000 (14:36 +0900)
committerhyunho <hhstark.kang@samsung.com>
Tue, 19 Nov 2019 06:44:35 +0000 (15:44 +0900)
- Free string list

Change-Id: I72b06a6559e844254ea26a07927422db78f4d718
Signed-off-by: hyunho <hhstark.kang@samsung.com>
notification-ex/abstract_item.h
notification-ex/api/notification_ex_internal.h [new file with mode: 0644]
notification-ex/group_item.cc
notification-ex/group_item.h
notification-ex/stub.cc
notification-ex/time_item.cc
notification-ex/time_item.h

index a5cef50..83bddb1 100644 (file)
@@ -694,6 +694,10 @@ class EXPORT_API LEDInfo {
     return color_;
   }
 
+  void SetColor(std::shared_ptr<Color> color) {
+    color_ = std::move(color);
+  }
+
  private:
   std::shared_ptr<Color> color_;
   int on_period_ = 0;
diff --git a/notification-ex/api/notification_ex_internal.h b/notification-ex/api/notification_ex_internal.h
new file mode 100644 (file)
index 0000000..eda78a1
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_APPFW_NOTIFICATION_EX_INTERNAL_H__
+#define __TIZEN_APPFW_NOTIFICATION_EX_INTERNAL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int noti_ex_item_free_string_list(char** list, int count);
+int noti_ex_item_group_remove_children(noti_ex_item_h handle);
+int noti_ex_item_time_set_time(noti_ex_item_h handle,
+        time_t time);
+
+int noti_ex_style_set_geometry(
+    noti_ex_style_h handle, noti_ex_geometry_h geometry);
+int noti_ex_style_set_color(
+    noti_ex_style_h handle, noti_ex_color_h color);
+int noti_ex_style_set_padding(noti_ex_style_h handle,
+    noti_ex_padding_h padding);
+
+int noti_ex_led_info_set_color(
+    noti_ex_led_info_h handle, noti_ex_color_h color);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif  /* __TIZEN_APPFW_NOTIFICATION_EX_INTERNAL_H__ */
\ No newline at end of file
index cd2569e..965e6c8 100644 (file)
@@ -192,6 +192,12 @@ void GroupItem::RemoveChild(string itemId) {
   }
 }
 
+void GroupItem::RemoveChildren() {
+  for (auto& i : impl_->children_list_) {
+    impl_->children_list_.remove(i);
+  }
+}
+
 list<shared_ptr<AbstractItem>> GroupItem::GetChildren() {
   return impl_->children_list_;
 }
index dd29fbb..29d38ba 100644 (file)
@@ -167,6 +167,12 @@ class EXPORT_API GroupItem : public AbstractItem {
   void RemoveChild(std::string itemId);
 
   /**
+   * @brief Removes children.
+   * @since_tizen 5.5
+   */
+  void RemoveChildren();
+
+  /**
    * @brief Gets the list of children item of GroupItem.
    * @since_tizen 5.5
    * @return The list of AbstractItem
index 0e37fe1..7ca6841 100644 (file)
@@ -38,6 +38,8 @@
 #include "api/notification_ex_text.h"
 #include "api/notification_ex_time.h"
 #include "api/notification_ex_visibility_action.h"
+#include "api/notification_ex_visibility_action.h"
+#include "api/notification_ex_internal.h"
 #include "notification-ex/reporter.h"
 #include "notification-ex/app_control_action.h"
 #include "notification-ex/button_item.h"
@@ -1460,6 +1462,26 @@ extern "C" EXPORT_API int noti_ex_style_get_padding(noti_ex_style_h handle,
   return NOTI_EX_ERROR_NONE;
 }
 
+
+extern "C" EXPORT_API int noti_ex_style_set_padding(noti_ex_style_h handle,
+    noti_ex_padding_h padding) {
+  if (handle == nullptr) {
+    LOGE("Invalid parameter");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+
+  shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
+  if (padding == nullptr) {
+    (*p)->SetPadding(nullptr);
+    return NOTI_EX_ERROR_NONE;
+  }
+
+  shared_ptr<Padding>* padd = static_cast<shared_ptr<Padding>*>(padding);
+  (*p)->SetPadding(*padd);
+
+  return NOTI_EX_ERROR_NONE;
+}
+
 extern "C" EXPORT_API int noti_ex_style_get_color(noti_ex_style_h handle,
     noti_ex_color_h *color) {
   if (handle == nullptr || color == nullptr) {
@@ -1485,6 +1507,25 @@ extern "C" EXPORT_API int noti_ex_style_get_color(noti_ex_style_h handle,
   return NOTI_EX_ERROR_NONE;
 }
 
+extern "C" EXPORT_API int noti_ex_style_set_color(
+    noti_ex_style_h handle, noti_ex_color_h color) {
+  if (handle == nullptr) {
+    LOGE("Invalid parameter");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+
+  shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
+  if (color == nullptr) {
+    (*p)->SetColor(nullptr);
+    return NOTI_EX_ERROR_NONE;
+  }
+
+  shared_ptr<Color>* col = static_cast<shared_ptr<Color>*>(color);
+  (*p)->SetColor(*col);
+
+  return NOTI_EX_ERROR_NONE;
+}
+
 extern "C" EXPORT_API int noti_ex_style_get_geometry(noti_ex_style_h handle,
     noti_ex_geometry_h *geometry) {
   if (handle == nullptr || geometry == nullptr) {
@@ -1510,6 +1551,25 @@ extern "C" EXPORT_API int noti_ex_style_get_geometry(noti_ex_style_h handle,
   return NOTI_EX_ERROR_NONE;
 }
 
+extern "C" EXPORT_API int noti_ex_style_set_geometry(
+    noti_ex_style_h handle, noti_ex_geometry_h geometry) {
+  if (handle == nullptr) {
+    LOGE("Invalid parameter");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+
+  shared_ptr<Style>* p = static_cast<shared_ptr<Style>*>(handle);
+  if (geometry == nullptr) {
+    (*p)->SetGeometry(nullptr);
+    return NOTI_EX_ERROR_NONE;
+  }
+
+  shared_ptr<Geometry>* geo = static_cast<shared_ptr<Geometry>*>(geometry);
+  (*p)->SetGeometry(*geo);
+
+  return NOTI_EX_ERROR_NONE;
+}
+
 extern "C" EXPORT_API int noti_ex_style_get_background_image(
     noti_ex_style_h handle, char** background_image) {
   if (handle == nullptr || background_image == nullptr) {
@@ -1689,6 +1749,25 @@ extern "C" EXPORT_API int noti_ex_led_info_get_color(
   return NOTI_EX_ERROR_NONE;
 }
 
+extern "C" EXPORT_API int noti_ex_led_info_set_color(
+    noti_ex_led_info_h handle, noti_ex_color_h color) {
+  if (handle == nullptr) {
+    LOGE("Invalid parameter");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+
+  shared_ptr<LEDInfo>* p = static_cast<shared_ptr<LEDInfo>*>(handle);
+  if (color == nullptr) {
+    (*p)->SetColor(nullptr);
+    return NOTI_EX_ERROR_NONE;
+  }
+
+  shared_ptr<Color>* col = static_cast<shared_ptr<Color>*>(color);
+  (*p)->SetColor(*col);
+
+  return NOTI_EX_ERROR_NONE;
+}
+
 extern "C" EXPORT_API int noti_ex_action_destroy(noti_ex_action_h handle) {
   if (handle == nullptr) {
     LOGE("Invalid parameter");
@@ -2142,6 +2221,10 @@ extern "C" EXPORT_API int noti_ex_item_set_led_info(noti_ex_item_h handle,
   }
 
   Handle* p = static_cast<Handle*>(handle);
+  if (led == nullptr) {
+     p->Get()->SetLEDInfo(nullptr);
+     return NOTI_EX_ERROR_NONE;
+  }
   shared_ptr<LEDInfo>* led_ptr =
       reinterpret_cast<shared_ptr<LEDInfo>*>(led);
   p->Get()->SetLEDInfo(*led_ptr);
@@ -3083,6 +3166,23 @@ extern "C" EXPORT_API int noti_ex_item_time_get_time(noti_ex_item_h handle,
   return NOTI_EX_ERROR_NONE;
 }
 
+extern "C" EXPORT_API int noti_ex_item_time_set_time(noti_ex_item_h handle,
+    time_t time) {
+  if (handle == nullptr) {
+    LOGE("Invalid parameter");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+  Handle* h = static_cast<Handle*>(handle);
+  if (!h->IsValidType(AbstractItem::Time)) {
+    LOGE("Invalid handle type");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+  TimeItem* p = static_cast<TimeItem*>(h->Get());
+  p->SetTime(time);
+
+  return NOTI_EX_ERROR_NONE;
+}
+
 extern "C" EXPORT_API int noti_ex_action_visibility_create(
     noti_ex_action_h *handle, const char *extra) {
   if (handle == nullptr) {
@@ -3207,3 +3307,33 @@ extern "C" EXPORT_API int noti_ex_item_set_private_id(
 
   return NOTI_EX_ERROR_NONE;
 }
+
+extern "C" EXPORT_API int noti_ex_item_free_string_list(char** list, int count) {
+  if (list == nullptr) {
+    LOGE("Invalid parameter");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+
+  LOGI("Free strings (%d)", count);
+  for (int i = 0; i < count; i++)
+    free(list[i]);
+  free(list);
+
+  return NOTI_EX_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int noti_ex_item_group_remove_children(noti_ex_item_h handle) {
+  if (handle == nullptr) {
+    LOGE("Invalid parameter");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+  Handle* h = static_cast<Handle*>(handle);
+  if (!h->IsValidType(AbstractItem::Group)) {
+    LOGE("Invalid handle type");
+    return NOTI_EX_ERROR_INVALID_PARAMETER;
+  }
+  GroupItem* p = static_cast<GroupItem*>(h->Get());
+  p->RemoveChildren();
+
+  return NOTI_EX_ERROR_NONE;
+}
index 8bac87c..9047e52 100644 (file)
@@ -98,6 +98,10 @@ time_t TimeItem::GetTime() const {
   return impl_->time_;
 }
 
+void TimeItem::SetTime(time_t time) {
+  impl_->time_ = time;
+}
+
 TimeItem::~TimeItem() = default;
 TimeItem::Impl::~Impl() = default;
 
index bc76b75..9816e38 100644 (file)
@@ -103,6 +103,7 @@ class EXPORT_API TimeItem : public AbstractItem {
    * @return The time state of TimeItem.
    */
   time_t GetTime() const;
+  void SetTime(time_t time);
 
  private:
   class Impl;