Initialize Noti-ex 43/198643/23
authormk5004.lee <mk5004.lee@samsung.com>
Mon, 28 Jan 2019 10:25:41 +0000 (19:25 +0900)
committermk5004.lee <mk5004.lee@samsung.com>
Mon, 11 Feb 2019 04:04:45 +0000 (13:04 +0900)
Change-Id: I96813e041aee48027806f97fef8a28bdc5d49c27
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
72 files changed:
CMakeLists.txt
notification-ex.manifest [new file with mode: 0644]
notification-ex/CMakeLists.txt [new file with mode: 0644]
notification-ex/abstract_action.h [new file with mode: 0644]
notification-ex/abstract_item.h [new file with mode: 0644]
notification-ex/action.cc [new file with mode: 0644]
notification-ex/action.h [new file with mode: 0644]
notification-ex/bundle.cc [new file with mode: 0644]
notification-ex/bundle.h [new file with mode: 0644]
notification-ex/common.h [new file with mode: 0644]
notification-ex/dbus_listener.h [new file with mode: 0644]
notification-ex/dbus_manager.h [new file with mode: 0644]
notification-ex/dbus_sender.h [new file with mode: 0644]
notification-ex/event_info.h [new file with mode: 0644]
notification-ex/event_listener_interface.h [new file with mode: 0644]
notification-ex/event_sender_interface.h [new file with mode: 0644]
notification-ex/exception.h [new file with mode: 0644]
notification-ex/item.cc [new file with mode: 0644]
notification-ex/item.h [new file with mode: 0644]
notification-ex/manager.h [new file with mode: 0644]
notification-ex/mock_listener.h [new file with mode: 0644]
notification-ex/mock_sender.h [new file with mode: 0644]
notification-ex/notification-ex.pc.in [new file with mode: 0644]
notification-ex/observer_interface.h [new file with mode: 0644]
notification-ex/repoter.h [new file with mode: 0644]
notification/11_notification-add.post [moved from 11_notification-add.post with 100% similarity]
notification/CMakeLists.txt [new file with mode: 0644]
notification/include/notification.h [moved from include/notification.h with 100% similarity]
notification/include/notification_db.h [moved from include/notification_db.h with 100% similarity]
notification/include/notification_debug.h [moved from include/notification_debug.h with 100% similarity]
notification/include/notification_error.h [moved from include/notification_error.h with 100% similarity]
notification/include/notification_group.h [moved from include/notification_group.h with 100% similarity]
notification/include/notification_internal.h [moved from include/notification_internal.h with 100% similarity]
notification/include/notification_ipc.h [moved from include/notification_ipc.h with 100% similarity]
notification/include/notification_list.h [moved from include/notification_list.h with 100% similarity]
notification/include/notification_noti.h [moved from include/notification_noti.h with 100% similarity]
notification/include/notification_ongoing.h [moved from include/notification_ongoing.h with 100% similarity]
notification/include/notification_ongoing_flag.h [moved from include/notification_ongoing_flag.h with 100% similarity]
notification/include/notification_private.h [moved from include/notification_private.h with 100% similarity]
notification/include/notification_setting.h [moved from include/notification_setting.h with 100% similarity]
notification/include/notification_setting_internal.h [moved from include/notification_setting_internal.h with 100% similarity]
notification/include/notification_setting_service.h [moved from include/notification_setting_service.h with 100% similarity]
notification/include/notification_shared_file.h [moved from include/notification_shared_file.h with 100% similarity]
notification/include/notification_status.h [moved from include/notification_status.h with 100% similarity]
notification/include/notification_status_internal.h [moved from include/notification_status_internal.h with 100% similarity]
notification/include/notification_text_domain.h [moved from include/notification_text_domain.h with 100% similarity]
notification/include/notification_type.h [moved from include/notification_type.h with 100% similarity]
notification/include/notification_type_internal.h [moved from include/notification_type_internal.h with 100% similarity]
notification/include/notification_viewer.h [moved from include/notification_viewer.h with 100% similarity]
notification/notification.pc.in [moved from notification.pc.in with 100% similarity]
notification/src/notification.c [moved from src/notification.c with 100% similarity]
notification/src/notification_db.c [moved from src/notification_db.c with 100% similarity]
notification/src/notification_db_query.h [moved from src/notification_db_query.h with 100% similarity]
notification/src/notification_error.c [moved from src/notification_error.c with 100% similarity]
notification/src/notification_group.c [moved from src/notification_group.c with 100% similarity]
notification/src/notification_init.c [moved from src/notification_init.c with 100% similarity]
notification/src/notification_internal.c [moved from src/notification_internal.c with 100% similarity]
notification/src/notification_ipc.c [moved from src/notification_ipc.c with 100% similarity]
notification/src/notification_ipc_socket.c [moved from src/notification_ipc_socket.c with 100% similarity]
notification/src/notification_list.c [moved from src/notification_list.c with 100% similarity]
notification/src/notification_noti.c [moved from src/notification_noti.c with 100% similarity]
notification/src/notification_ongoing.c [moved from src/notification_ongoing.c with 100% similarity]
notification/src/notification_setting.c [moved from src/notification_setting.c with 100% similarity]
notification/src/notification_setting_service.c [moved from src/notification_setting_service.c with 100% similarity]
notification/src/notification_shared_file.c [moved from src/notification_shared_file.c with 100% similarity]
notification/src/notification_status.c [moved from src/notification_status.c with 100% similarity]
notification/src/notification_viewer.c [moved from src/notification_viewer.c with 100% similarity]
notification/test-app/CMakeLists.txt [moved from test-app/CMakeLists.txt with 100% similarity]
notification/test-app/main.c [moved from test-app/main.c with 99% similarity]
packaging/notification.spec
unittest/CMakeLists.txt [new file with mode: 0644]
unittest/src/test_main.cc [new file with mode: 0644]

index f528db1..e85ca6c 100644 (file)
@@ -1,68 +1,5 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(notification C)
 
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(EXEC_PREFIX "\${prefix}")
-SET(LIBDIR ${LIB_INSTALL_DIR})
-SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}")
-
-#ADD_SUBDIRECTORY(test-app)
-
-SET(INIT-SRCS
-       ./src/notification_init.c
-)
-
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
-AUX_SOURCE_DIRECTORY(src SRCS)
-LIST(REMOVE_ITEM SRCS ${INIT-SRCS})
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED
-       sqlite3
-       vconf
-       bundle
-       dlog
-       aul
-       dbus-1
-       capi-appfw-app-control
-       capi-appfw-package-manager
-       pkgmgr-info
-       libtzplatform-config
-       glib-2.0
-       gio-2.0
-       gio-unix-2.0
-       iniparser
-       security-manager
-       libsmack
-)
-
-FOREACH(flag ${pkgs_CFLAGS})
-       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -g -Wall")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
-
-SET(CMAKE_SKIP_BUILD_RPATH TRUE)
-
-ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${MAJORVER})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${FULLVER})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
-
-ADD_EXECUTABLE(notification_init ${INIT-SRCS})
-TARGET_LINK_LIBRARIES(notification_init ${pkgs_LDFLAGS} notification "-pie")
-
-CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
-INSTALL(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/
-        DESTINATION include/notification
-        FILES_MATCHING
-               PATTERN "*_private.h" EXCLUDE
-               PATTERN "*_group.h" EXCLUDE
-               PATTERN "*_debug.h" EXCLUDE
-        PATTERN "*.h")
-
-INSTALL(FILES ${CMAKE_BINARY_DIR}/11_notification-add.post DESTINATION ${SYSCONF_INSTALL_DIR}/gumd/useradd.d/)
-INSTALL(TARGETS notification_init DESTINATION bin)
+ADD_SUBDIRECTORY(notification)
+ADD_SUBDIRECTORY(notification-ex)
+ADD_SUBDIRECTORY(unittest)
diff --git a/notification-ex.manifest b/notification-ex.manifest
new file mode 100644 (file)
index 0000000..6c61ae0
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+           <domain name="_"/>
+       </request>
+</manifest>
diff --git a/notification-ex/CMakeLists.txt b/notification-ex/CMakeLists.txt
new file mode 100644 (file)
index 0000000..be66165
--- /dev/null
@@ -0,0 +1,47 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(notification-ex CXX)
+
+SET(PREFIX "${CMAKE_INSTALL_PREFIX}")
+SET(EXEC_PREFIX "\${prefix}")
+SET(PROJECT_NAME "${PROJECT_NAME}")
+SET(LIBDIR ${LIB_INSTALL_DIR})
+SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}")
+SET(VERSION_MAJOR 1)
+SET(VERSION "${VERSION_MAJOR}.0.0")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(notification-ex REQUIRED
+       glib-2.0
+       bundle
+       dlog
+       capi-appfw-app-control
+)
+
+FOREACH(flag ${notification-ex_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline -std=c++11")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../)
+
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCES)
+ADD_LIBRARY (${PROJECT_NAME} SHARED ${SOURCES})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${notification-ex_LDFLAGS} "-lpthread")
+
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc")
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/item.h DESTINATION include/${PROJECT_NAME})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/manager.h DESTINATION include/${PROJECT_NAME})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/repoter.h DESTINATION include/${PROJECT_NAME})
+#INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION include/${PROJECT_NAME}
+#      FILES_MATCHING PATTERN "*.h")
diff --git a/notification-ex/abstract_action.h b/notification-ex/abstract_action.h
new file mode 100644 (file)
index 0000000..a5431b1
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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 NOTIFICATION_EX_ABSTRACT_ACTION_H_
+#define NOTIFICATION_EX_ABSTRACT_ACTION_H_
+
+#include <app_control.h>
+
+#include <memory>
+#include <string>
+
+#include "notification-ex/bundle.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace notification {
+namespace item {
+
+class AbstractItem;
+
+class EXPORT_API AbstractAction {
+ public:
+  AbstractAction();
+  virtual ~AbstractAction();
+
+  virtual bool IsLocal() const = 0;
+  virtual void Execute(std::shared_ptr<AbstractItem> item) = 0;
+  virtual Bundle Serialize() = 0;
+  virtual void Deserialize(Bundle b) = 0;
+  virtual std::string GetExtra() const = 0;
+};
+
+}  // namespace item
+}  // namespace notification
+
+#endif  // NOTIFICATION_EX_ABSTRACT_ACTION_H_
diff --git a/notification-ex/abstract_item.h b/notification-ex/abstract_item.h
new file mode 100644 (file)
index 0000000..9069ee0
--- /dev/null
@@ -0,0 +1,217 @@
+/*
+ * 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 NOTIFICATION_EX_ABSTRACT_ITEM_H_
+#define NOTIFICATION_EX_ABSTRACT_ITEM_H_
+
+#include <time.h>
+
+#include <memory>
+#include <string>
+
+#include "notification-ex/abstract_action.h"
+#include "notification-ex/bundle.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace notification {
+namespace item {
+
+class EXPORT_API Color {
+ public:
+  Color() {
+    a_ = 0;
+    r_ = 0;
+    g_ = 0;
+    b_ = 0;
+  }
+  Color(unsigned char a, unsigned char r, unsigned char g, unsigned char b)
+    : a_(a), r_(r), g_(g), b_(b) {
+  }
+  virtual ~Color();
+
+  unsigned char GetAVal() const {
+    return a_;
+  }
+  unsigned char GetRVal() const {
+    return r_;
+  }
+  unsigned char GetGVal() const {
+    return g_;
+  }
+  unsigned char GetBVal() const {
+    return b_;
+  }
+
+ private:
+  unsigned char a_;
+  unsigned char r_;
+  unsigned char g_;
+  unsigned char b_;
+};  // class Color
+
+class EXPORT_API Padding {
+ public:
+  Padding() {
+    left_ = 0;
+    top_ = 0;
+    right_ = 0;
+    bottom_ = 0;
+  }
+  Padding(int left, int top, int right, int bottom)
+    : left_(left), top_(top), right_(right), bottom_(bottom) {
+  }
+  virtual ~Padding();
+
+  int GeLeft() const {
+    return left_;
+  }
+  int GetTop() const {
+    return top_;
+  }
+  int GetRight() const {
+    return right_;
+  }
+  int GetBottom() const {
+    return bottom_;
+  }
+
+ private:
+  int left_;
+  int top_;
+  int right_;
+  int bottom_;
+};  // class  Padding
+
+class EXPORT_API Geometry {
+ public:
+  Geometry() {
+    x_ = 0;
+    y_ = 0;
+    w_ = 0;
+    h_ = 0;
+  }
+  Geometry(int x, int y, int w, int h) : x_(x), y_(y), w_(w), h_(h) {
+  }
+  virtual ~Geometry();
+
+  int GetX() const {
+    return x_;
+  }
+  int GetY() const {
+    return y_;
+  }
+  int GetWidth() const {
+    return w_;
+  }
+  int GetHeight() const {
+    return h_;
+  }
+
+ private:
+  int x_;
+  int y_;
+  int w_;
+  int h_;
+};  // class Geometry
+
+class EXPORT_API Style {
+ public:
+  Style(Color color, Padding padding, Geometry geometry);
+  virtual ~Style();
+
+  Padding GetPadding() const;
+  Color GetColor() const;
+  Geometry GetGeometry() const;
+
+ private:
+  Color color_;
+  Padding padding_;
+  Geometry geometry_;
+};  // class Style
+
+class EXPORT_API LEDInfo {
+ public:
+  LEDInfo() {
+    Color(0, 0, 0, 0);
+  }
+  explicit LEDInfo(Color color);
+  virtual ~LEDInfo();
+
+  void SetOffPeriod(int ms);
+  void SetOnPeriod(int ms);
+  Color GetColor() const;
+
+ private:
+  Color color_;
+  int period_ = 0;
+};  // clss LEDInfo
+
+class EXPORT_API AbstractItem {
+ public:
+  enum Type {
+    Text,
+    Image,
+    Icon,
+    Button,
+    ChatMessage,
+    CheckBox,
+    IconText,
+    InputSelector,
+    Group,
+    Effect,
+    Progress,
+    Custom,
+  };
+
+  enum Policy {
+    OnBootClear,
+    SimMode,
+  };
+
+ public:
+  AbstractItem();
+  virtual ~AbstractItem();
+
+  virtual Bundle Serialize() = 0;
+  virtual void Deserialize(Bundle b) = 0;
+  virtual std::shared_ptr<AbstractItem> FindByID(std::string id) = 0;
+  std::string GetId() const;
+  void SetId(std::string id);
+  std::shared_ptr<AbstractAction> GetAction() const;
+  Style GetStyle() const;
+  Type GetType() const;
+  void SetVisible(bool visible);
+  void SetEnable(bool enable);
+  void AddReceiver(std::string receiver_group);
+  void RemoveReceiver(std::string receiver_group);
+  bool CanReceive(std::string id) const;
+  void SetPolicy(Policy policy);
+  int GetVersion() const;
+  void SetVersion(int ver);
+  int GetHideTime() const;
+  int GetDeleteTime() const;
+
+ private:
+  Style style_;
+};  // class AbstractItem
+
+}  // namespace item
+}  // namespace notification
+
+#endif  // NOTIFICATION_EX_ABSTRACT_ITEM_H_
diff --git a/notification-ex/action.cc b/notification-ex/action.cc
new file mode 100644 (file)
index 0000000..f5f337f
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+#include <string>
+#include <memory>
+
+#include "notification-ex/action.h"
+#include "notification-ex/bundle.h"
+#include "notification-ex/exception.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+
+namespace notification {
+namespace item {
+
+AppControlAction::AppControlAction(app_control_h control)
+  : control_(control) {
+}
+
+AppControlAction::~AppControlAction() {
+}
+
+ReplyAction::ReplyAction() {
+}
+
+ReplyAction::~ReplyAction() {
+}
+
+VisibilityAction::VisibilityAction() {
+}
+
+VisibilityAction::~VisibilityAction() {
+}
+
+
+} //namespace item
+}  //namespace notification
diff --git a/notification-ex/action.h b/notification-ex/action.h
new file mode 100644 (file)
index 0000000..247e323
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * 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 NOTIFICATION_EX_ACTION_H_
+#define NOTIFICATION_EX_ACTION_H_
+
+#include <app_control.h>
+
+#include <memory>
+#include <string>
+
+#include "notification-ex/abstract_action.h"
+#include "notification-ex/bundle.h"
+
+namespace notification {
+namespace item {
+
+class EXPORT_API AppControlAction  : public AbstractAction {
+ public:
+  explicit AppControlAction(app_control_h control);
+  virtual ~AppControlAction();
+
+  bool IsLocal() const override;
+  void Execute(std::shared_ptr<AbstractItem> item) override;
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  void SetAppControl(app_control_h control);
+  app_control_h GetAppControl() const;
+
+ private:
+  app_control_h control_ = nullptr;
+};
+
+class EXPORT_API ReplyAction  : public AbstractAction {
+ public:
+  ReplyAction();
+  virtual ~ReplyAction();
+
+  bool IsLocal() const override;
+  void Execute(std::shared_ptr<AbstractItem> item) override;
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+};
+
+class EXPORT_API VisibilityAction  : public AbstractAction {
+ public:
+  VisibilityAction();
+  virtual ~VisibilityAction();
+
+  bool IsLocal() const override;
+  void Execute(std::shared_ptr<AbstractItem> item) override;
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  void SetVisibility(std::string id, bool visible);
+
+ private:
+  std::string id_ = NULL;
+  bool visible_ = false;
+};
+
+}  // namespace item
+}  // namespace notification
+
+#endif  // NOTIFICATION_EX_ACTION_H_
diff --git a/notification-ex/bundle.cc b/notification-ex/bundle.cc
new file mode 100644 (file)
index 0000000..4ff78e9
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+#include "notification-ex/bundle.h"
+#include "notification-ex/exception.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+
+namespace notification {
+namespace item {
+
+Bundle::Bundle() {
+       raw_ = bundle_create();
+}
+
+const char* Bundle::ToString() {
+  int str_len = 0;
+  bundle_raw* temp;
+
+  if (str_raw_ != NULL)
+    return str_raw_;
+
+  bundle_encode(raw_, &temp, &str_len);
+
+  str_raw_ = reinterpret_cast<char*>(temp);
+  return str_raw_;
+}
+
+Bundle::~Bundle() {
+  if (raw_) {
+    bundle_free(raw_);
+    raw_ = NULL;
+  }
+  if (str_raw_) {
+    free(str_raw_);
+    str_raw_ = NULL;
+  }
+}
+
+} //namespace item
+} //namespace notification
diff --git a/notification-ex/bundle.h b/notification-ex/bundle.h
new file mode 100644 (file)
index 0000000..3246789
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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 NOTIFICATION_EX_BUNDLE_H_
+#define NOTIFICATION_EX_BUNDLE_H_
+
+#include <bundle.h>
+
+#include <string>
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace notification {
+namespace item {
+
+class EXPORT_API Bundle {
+ public:
+  Bundle();
+  ~Bundle();
+  const char* ToString();
+
+ private:
+  bundle* raw_ = NULL;
+  char* str_raw_ = NULL;
+};
+
+}  // namespace item
+}  // namespace notification
+
+#endif  // NOTIFICATION_EX_BUNDLE_H_
diff --git a/notification-ex/common.h b/notification-ex/common.h
new file mode 100644 (file)
index 0000000..8a0a67d
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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 NOTIFICATION_EX_COMMON_H_
+#define NOTIFICATION_EX_COMMON_H_
+
+namespace notification {
+
+typedef enum _notification_error {
+ NOTIFICATION_ERROR_NONE = TIZEN_ERROR_NONE, /**< Success */
+ NOTIFICATION_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ NOTIFICATION_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ NOTIFICATION_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
+ NOTIFICATION_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ NOTIFICATION_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Function not implemented (@b Since: @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif) */
+ NOTIFICATION_ERROR_FROM_DB = TIZEN_ERROR_NOTIFICATION | 0x01, /**< Error from DB query */
+ NOTIFICATION_ERROR_ALREADY_EXIST_ID = TIZEN_ERROR_NOTIFICATION | 0x02, /**< Already exist private ID */
+ NOTIFICATION_ERROR_FROM_DBUS = TIZEN_ERROR_NOTIFICATION | 0x03, /**< Error from DBus */
+ NOTIFICATION_ERROR_NOT_EXIST_ID = TIZEN_ERROR_NOTIFICATION | 0x04, /**< Not exist private ID */
+ NOTIFICATION_ERROR_SERVICE_NOT_READY = TIZEN_ERROR_NOTIFICATION | 0x05, /**< No response from notification service */
+ NOTIFICATION_ERROR_MAX_EXCEEDED = TIZEN_ERROR_NOTIFICATION | 0x06, /**< Max notification count exceeded (@b Since: 3.0) */
+} notification_error_e;
+
+}  // namespace notification
+
+#endif  // NOTIFICATION_EX_COMMON_H_
+
diff --git a/notification-ex/dbus_listener.h b/notification-ex/dbus_listener.h
new file mode 100644 (file)
index 0000000..e0ad60a
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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 NOTIFICATION_EX_DBUS_LISTENER_H_
+#define NOTIFICATION_EX_DBUS_LISTENER_H_
+
+#include "notification-ex/observer_interface.h"
+
+namespace notification {
+
+class EXPORT_API DBusEventsListener : public IEventListener {
+ public:
+  DBusEventsListener();
+  ~DBusEventsListener();
+
+  void RegisterObserver(IEventObserver observer) override;
+  void UnRegisterObserver(IEventObserver observer) override;
+  void NotifyAll() override;
+};
+
+}  // namespace notification
+
+#endif  // NOTIFICATION_EX_DBUS_LISTENER_H_
diff --git a/notification-ex/dbus_manager.h b/notification-ex/dbus_manager.h
new file mode 100644 (file)
index 0000000..8c1943d
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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 NOTIFICATION_EX_DBUS_MANAGER_H_
+#define NOTIFICATION_EX_DBUS_MANAGER_H_
+
+#include <string>
+
+namespace notification {
+
+class DBusConnectionManager {
+ public:
+  static DBusConnectionManager& GetInst();
+  GDbusConnection& GetConnection();
+
+ private:
+  DBusConnectionManager();
+  ~DBusConnectionManager();
+  GDbusConnection connection_;
+};
+
+}  // namespace notification
+
+#endif  // NOTIFICATION_EX_DBUS_MANAGER_H_
diff --git a/notification-ex/dbus_sender.h b/notification-ex/dbus_sender.h
new file mode 100644 (file)
index 0000000..5fd1bed
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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 NOTIFICATION_EX_DBUS_SENDER_H_
+#define NOTIFICATION_EX_DBUS_SENDER_H_
+
+#include "notification-ex/bundle.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace notification {
+
+class EXPORT_API DBusSender : public IEventsSender {
+ public:
+  DBusSender();
+  virtual ~DBusSender();
+
+  void Notify(Bundle serialized) override;
+};
+
+}  // namespace notification
+
+#endif  // NOTIFICATION_EX_DBUS_SENDER_H_
diff --git a/notification-ex/event_info.h b/notification-ex/event_info.h
new file mode 100644 (file)
index 0000000..55b31b8
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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 NOTIFICATION_EX_EVENT_INFO_H_
+#define NOTIFICATION_EX_EVENT_INFO_H_
+
+#include <string>
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace notification {
+
+class EXPORT_API EventInfo {
+ public:
+  EventInfo();
+  ~EventInfo();
+
+  int GetEventType() const;
+  std::string GetOwner() const;
+  int GetChannel();
+
+ private:
+  int type_;
+  std::string owner_;
+  int channel_;
+};
+
+}  // namespace notification
+
+#endif  // NOTIFICATION_EX_EVENT_INFO_H_
diff --git a/notification-ex/event_listener_interface.h b/notification-ex/event_listener_interface.h
new file mode 100644 (file)
index 0000000..3990271
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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 NOTIFICATION_EX_EVENT_LISTENER_INTERFACE_H_
+#define NOTIFICATION_EX_EVENT_LISTENER_INTERFACE_H_
+
+#include "notification-ex/observer_interface.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace notification {
+
+class EXPORT_API IEventsListener {
+ public:
+  virtual ~IEventsListener() = 0;
+
+  virtual void RegisterObserver(IEventObserver observer) = 0;
+  virtual void UnRegisterObserver(IEventObserver observer) = 0;
+  virtual void NotifyAll() = 0;
+};
+
+}  // namespace notification
+
+#endif  // NOTIFICATION_EX_EVENT_LISTENER_INTERFACE_H_
diff --git a/notification-ex/event_sender_interface.h b/notification-ex/event_sender_interface.h
new file mode 100644 (file)
index 0000000..3c42a4e
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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 NOTIFICATION_EX_EVENT_SENDER_INTERFACE_H_
+#define NOTIFICATION_EX_EVENT_SENDER_INTERFACE_H_
+
+#include "notification-ex/bundle.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace notification {
+
+class EXPORT_API IEventsSender {
+ public:
+  virtual ~IEventsSender() = 0;
+
+  virtual void Notify(Bundle serialized) = 0;
+};
+
+}  // namespace notification
+
+#endif  // NOTIFICATION_EX_EVENT_SENDER_INTERFACE_H_
diff --git a/notification-ex/exception.h b/notification-ex/exception.h
new file mode 100644 (file)
index 0000000..9e87cb7
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * 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 NOTIFICATION_EX_EXCEPTION_H_
+#define NOTIFICATION_EX_EXCEPTION_H_
+
+#include <string>
+#include <exception>
+
+#include "notification-ex/common.h"
+
+#define THROW(error_code) throw Exception(error_code, __FILE__, __LINE__)
+
+namespace notification {
+
+class Exception : public std::exception {
+ public:
+  explicit Exception(int error_code, std::string file = __FILE__,
+      int line = __LINE__ ) {
+    error_code_ = error_code;
+    message_ = file.substr(file.find_last_of("/") + 1) + ":"
+        + std::to_string(line) + GetErrorString(error_code);
+  }
+  virtual ~Exception() {}
+  virtual const char *what(void) const noexcept {
+    return message_.c_str();
+  }
+  int GetErrorCode() {
+    return error_code_;
+  }
+
+ private:
+  int error_code_;
+  std::string message_;
+  std::string GetErrorString(int error_code) {
+    switch (error_code) {
+    case NOTIFICATION_ERROR_INVALID_PARAMETER:
+      return ": INVALID_PARAMETER";
+    case NOTIFICATION_ERROR_OUT_OF_MEMORY:
+      return ": OUT_OF_MEMORY";
+    case NOTIFICATION_ERROR_IO_ERROR:
+      return ": IO_ERROR";
+    case NOTIFICATION_ERROR_PERMISSION_DENIED:
+      return ": PERMISSION_DENIED";
+    case NOTIFICATION_ERROR_INVALID_OPERATION:
+      return ": INVALID_OPERATION";
+    case NOTIFICATION_ERROR_FROM_DB:
+      return ": ERROR_FROM_DB";
+    case NOTIFICATION_ERROR_ALREADY_EXIST_ID:
+      return ": ALREADY_EXIST_ID";
+    case NOTIFICATION_ERROR_FROM_DBUS:
+      return ": ERROR_FROM_DBUS";
+    case NOTIFICATION_ERROR_NOT_EXIST_ID:
+      return ": NOT_EXIST_ID";
+    case NOTIFICATION_ERROR_SERVICE_NOT_READY:
+      return ": SERVICE_NOT_READY";
+    case NOTIFICATION_ERROR_MAX_EXCEEDED:
+      return ": MAX_EXCEEDED";
+    default:
+      return "";
+    }
+  }
+};  // class Exception
+
+}  // namespace notification
+
+#endif  // NOTIFICATION_EX_EXCEPTION_H_
diff --git a/notification-ex/item.cc b/notification-ex/item.cc
new file mode 100644 (file)
index 0000000..95fa057
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * 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.
+ */
+#include <dlog.h>
+#include <glib.h>
+#include <unistd.h>
+#include <stdexcept>
+
+#include "notification-ex/item.h"
+#include "notification-ex/bundle.h"
+#include "notification-ex/exception.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+
+namespace notification {
+namespace item {
+
+GroupItem::GroupItem() {
+}
+
+GroupItem:: ~GroupItem() {
+}
+
+TextItem::TextItem(std::string text) {
+}
+
+TextItem::~TextItem() {
+}
+
+IconItem::IconItem(std::string iconpath) {
+}
+
+IconItem::~IconItem() {
+}
+
+IconTextItem::IconTextItem(std::string iconpath, std::string text) {
+}
+
+IconTextItem::~IconTextItem() {
+}
+
+ImageItem::ImageItem(std::string imagePath) {
+}
+
+ImageItem::~ImageItem() {
+}
+
+ButtonItem::ButtonItem(std::string title) {
+}
+
+ButtonItem::~ButtonItem() {
+}
+
+ProgressItem::ProgressItem(float min, float max, float current) {
+}
+
+ProgressItem::~ProgressItem() {
+}
+
+CheckBoxItem::CheckBoxItem(bool checked) {
+}
+
+CheckBoxItem::~CheckBoxItem() {
+}
+
+ChatMessageItem::ChatMessageItem() {
+}
+
+ChatMessageItem::~ChatMessageItem() {
+}
+
+InputSelectorItem::InputSelectorItem() {
+}
+
+InputSelectorItem::~InputSelectorItem() {
+}
+
+EntryItem::EntryItem() {
+}
+
+EntryItem::~EntryItem() {
+}
+
+EffectItem::EffectItem() {
+}
+
+EffectItem::~EffectItem() {
+}
+
+CustomItem::CustomItem() {
+}
+
+CustomItem::~CustomItem() {
+}
+
+} //namespace item
+} //namespace notification_ex
diff --git a/notification-ex/item.h b/notification-ex/item.h
new file mode 100644 (file)
index 0000000..c231ab1
--- /dev/null
@@ -0,0 +1,249 @@
+/*
+ * 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 NOTIFICATION_EX_ITEM_H_
+#define NOTIFICATION_EX_ITEM_H_
+
+#include <time.h>
+
+#include <memory>
+#include <string>
+#include <list>
+
+#include "notification-ex/abstract_item.h"
+#include "notification-ex/bundle.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace notification {
+namespace item {
+
+class EXPORT_API GroupItem : public AbstractItem {
+ public:
+  GroupItem();
+  virtual ~GroupItem();
+
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  std::shared_ptr<AbstractItem> FindByID(std::string id) override;
+  void AddChild(std::shared_ptr<AbstractItem> child);
+  void Remove(std::string itemId);
+  std::list<std::shared_ptr<AbstractItem>> GetChildren() const;
+  int GetChannel() const;
+  void SetChannel(int channel);
+  void SetDirection(bool vertical);
+  bool IsVertical() const;
+  std::string GetAppLabel() const;
+
+
+ private:
+  bool Vertical_ = true;
+  std::string channel_ = nullptr;
+  std::string id_ = nullptr;
+  LEDInfo led_;
+  std::string itemId_ = nullptr;
+};  // class GroupItem
+
+class EXPORT_API TextItem : public AbstractItem {
+ public:
+  TextItem(std::string text);
+  virtual ~TextItem();
+
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  std::shared_ptr<AbstractItem> FindByID(std::string id) override;
+  void SetContents(std::string contents);
+  std::string GetContents() const;
+  std::string GetHyperLink() const;
+
+ private:
+  std::string text_ = nullptr;
+};  // class TextItem
+
+class EXPORT_API IconItem : public AbstractItem {
+ public:
+  IconItem(std::string iconpath);
+  virtual ~IconItem();
+
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  std::shared_ptr<AbstractItem> FindByID(std::string id) override;
+
+ private:
+  std::string iconPath_ = nullptr;
+};  // class IconItem
+
+class EXPORT_API IconTextItem : public AbstractItem {
+ public:
+  IconTextItem(std::string iconpath, std::string text);
+  virtual ~IconTextItem();
+
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  std::shared_ptr<AbstractItem> FindByID(std::string id) override;
+  IconItem GetIconItem() const;
+  IconItem GetTextItem() const;
+
+ private:
+  std::string iconPath_ = nullptr;
+  std::string text_ = nullptr;
+};  // class IconTextItem
+
+class EXPORT_API ImageItem : public AbstractItem {
+ public:
+  ImageItem(std::string imagePath);
+  virtual ~ImageItem();
+
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  std::shared_ptr<AbstractItem> FindByID(std::string id) override;
+  std::string GetImagePath() const;
+
+ private:
+  std::string imagePath_ = nullptr;
+};  // class ImageItem
+
+class EXPORT_API ButtonItem : public AbstractItem {
+ public:
+  ButtonItem(std::string title);
+  virtual ~ButtonItem();
+
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  std::shared_ptr<AbstractItem> FindByID(std::string id) override;
+  std::string GetTitle() const;
+
+ private:
+  std::string title_ = nullptr;
+};  // class ButtonItem
+
+class EXPORT_API ProgressItem : public AbstractItem {
+ public:
+  ProgressItem(float min, float max, float current);
+  virtual ~ProgressItem();
+
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  std::shared_ptr<AbstractItem> FindByID(std::string id) override;
+  float GetCurrent() const;
+  void SetCurrent(float current);
+  float GetMin() const;
+  float GetMax() const;
+
+ private:
+  float min_ = 0.0;
+  float max_ = 0.0;
+  float current_ = 0.0;
+};  // class ProgressItem
+
+class EXPORT_API CheckBoxItem : public AbstractItem {
+ public:
+  CheckBoxItem(bool checked);
+  virtual ~CheckBoxItem();
+
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  std::shared_ptr<AbstractItem> FindByID(std::string id) override;
+  bool IsChecked() const;
+
+private:
+  bool checked_ = false;
+};  // class CheckBoxItem
+
+class EXPORT_API ChatMessageItem : public AbstractItem {
+ public:
+  enum Type {
+    user,
+    sender,
+  };
+
+ public:
+  ChatMessageItem();
+  virtual ~ChatMessageItem();
+
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  std::shared_ptr<AbstractItem> FindByID(std::string id) override;
+  TextItem GetTextItem() const;
+  TextItem GetDataItem() const;
+  time_t GetTimeItem() const;
+  Type GetType() const;
+};  // class ChatMessageItem
+
+class EXPORT_API InputSelectorItem : public AbstractItem {
+ public:
+  InputSelectorItem();
+  virtual ~InputSelectorItem();
+
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  std::shared_ptr<AbstractItem> FindByID(std::string id) override;
+  std::list<std::string> GetContents() const;
+  void SetContents(std::list<std::string> contents);
+
+ private:
+  std::list<std::string> contents_;
+};  // class InputSelectorItem
+
+class EXPORT_API EntryItem : public AbstractItem {
+ public:
+  EntryItem();
+  virtual ~EntryItem();
+
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  std::shared_ptr<AbstractItem> FindByID(std::string id) override;
+  std::string GetText() const;
+  void SetText(std::string text);
+  void SetTextLimit(int size);
+  int GetTextLimit() const;
+
+ private:
+  std::string text_ = nullptr;
+  int limit_ = 160;
+};  // class EntryItem
+
+class EXPORT_API EffectItem : public AbstractItem {
+ public:
+  EffectItem();
+  virtual ~EffectItem();
+
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  std::shared_ptr<AbstractItem> FindByID(std::string id) override;
+  std::string GetSoundPath() const;
+  std::string GetVibrationPath() const;
+
+ private:
+  std::string soundPath_ = nullptr;
+  std::string vibrationPath_ = nullptr;
+};  // class EffectItem
+
+class EXPORT_API CustomItem : public AbstractItem {
+ public:
+  CustomItem();
+  virtual ~CustomItem();
+
+  Bundle Serialize() override;
+  void Deserialize(Bundle b) override;
+  std::shared_ptr<AbstractItem> FindByID(std::string id) override;
+};  // class CustomItem
+
+}  // namespace item
+}  // nampace notification
+#endif  // NOTIFICATION_EX_ITEM_H_
diff --git a/notification-ex/manager.h b/notification-ex/manager.h
new file mode 100644 (file)
index 0000000..8942ba1
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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 NOTIFICATION_EX_MANAGER_H_
+#define NOTIFICATION_EX_MANAGER_H_
+
+#include <string>
+#include <list>
+
+#include "notification-ex/abstract_item.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace notification {
+
+class EXPORT_API Manager : public IEventObserver {
+ public:
+  Manager(IEventsSender* sender, IEventsListener* listener);
+  virtual ~Manager();
+
+  void Update(std::shared_ptr<item::AbstractItem> noti);
+  void Remove(std::shared_ptr<item::AbstractItem> noti);
+  void Hide(std::shared_ptr<item::AbstractItem> noti);
+  std::shared_ptr<item::AbstractItem> FindByRootID(std::string id);
+  void SendEvent(EventInfo info, std::shared_ptr<item::AbstractItem> noti);
+  void OnEvent(EventInfo info, std::shared_ptr<AbstractItem> notiList) override;
+
+ protected:
+  virtual void OnAdd(std::list<std::shared_ptr<item::AbstractItem>> addedItem);
+  virtual void OnUpdate(shared_ptr<item::AbstractItem> updatedItem);
+  virtual void OnDelete(shared_ptr<item::AbstractItem> deletedItem);
+
+ private:
+  IEventsSender* sender_;
+  IEventsListener* receiver_;
+};
+
+}  // namespace notification
+
+#endif  // NOTIFICATION_EX_MANAGER_H_
diff --git a/notification-ex/mock_listener.h b/notification-ex/mock_listener.h
new file mode 100644 (file)
index 0000000..1df439b
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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 NOTIFICATION_EX_MOCK_LISTENER_H_
+#define NOTIFICATION_EX_MOCK_LISTENER_H_
+
+#include "notification-ex/observer_interface.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace notification {
+
+class EXPORT_API MockEventsListener : public IEventListener {
+ public:
+  MockEventsListener();
+  virtual ~MockEventsListener();
+
+  void RegisterObserver(IEventObserver observer) override;
+  void UnRegisterObserver(IEventObserver observer) override;
+  void NotifyAll() override;
+};
+
+}  // namespace notification
+
+#endif  // NOTIFICATION_EX_MOCK_LISTENER_H_
diff --git a/notification-ex/mock_sender.h b/notification-ex/mock_sender.h
new file mode 100644 (file)
index 0000000..c4dea88
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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 NOTIFICATION_EX_MOCK_SENDER_H_
+#define NOTIFICATION_EX_MOCK_SENDER_H_
+
+#include "notification-ex/bundle.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace notification {
+
+class EXPORT_API MockSender : public IEventsSender {
+ public:
+  MockSender();
+  virtual ~MockSender();
+
+  void Notify(Bundle serialized) override;
+};
+
+}  // namespace notification
+
+#endif  // NOTIFICATION_EX_MOCK_SENDER_H_
diff --git a/notification-ex/notification-ex.pc.in b/notification-ex/notification-ex.pc.in
new file mode 100644 (file)
index 0000000..a4fdc5e
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: notification-ex
+Description: Support development of the notification
+Version: @VERSION@
+Libs: -L${libdir}
+Cflags: -I${includedir}
+cppflags: -I${includedir}
\ No newline at end of file
diff --git a/notification-ex/observer_interface.h b/notification-ex/observer_interface.h
new file mode 100644 (file)
index 0000000..9c1e5d2
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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 NOTIFICATION_EX_OBSERVER_INTERFACE_H_
+#define NOTIFICATION_EX_OBSERVER_INTERFACE_H_
+
+#include "notification-ex/bundle.h"
+#include "notification-ex/event_info.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace notification {
+
+class EXPORT_API IEventObserver {
+ public:
+  virtual ~IEventObserver() = 0;
+
+  virtual void OnEvent(EventInfo info, std::shared_ptr<AbstractItem> noti) = 0;
+};
+
+}  // namespace notification
+
+#endif
\ No newline at end of file
diff --git a/notification-ex/repoter.h b/notification-ex/repoter.h
new file mode 100644 (file)
index 0000000..90cbf6f
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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 NOTIFICATION_EX_REPOTER_H_
+#define NOTIFICATION_EX_REPOTER_H_
+
+#include <string>
+#include <list>
+
+#include "notification-ex/abstract_item.h"
+#include "notification-ex/event_info.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace notification {
+
+class EXPORT_API Repoter : public IEventObserver {
+ public:
+  Repoter(IEventsSender* sender, IEventsListener* listener);
+  virtual ~Repoter();
+
+  void Post(std::shared_ptr<item::AbstractItem> noti);
+  void Post(std::list<std::shared_ptr<AbstractItem>> notiList);
+  void Update(std::shared_ptr<AbstractItem> noti);
+  void Remove(std::shared_ptr<AbstractItem> noti);
+  std::shared_ptr<AbstractItem> FindByRootID(std::string id);
+  void OnEvent(EventInfo info, std::shared_ptr<AbstractItem> notiList) override;
+
+ private:
+  IEventsSender* sender_;
+  IEventsListener* receiver_;
+};
+
+}  // namespace notification
+
+#endif  // NOTIFICATION_EX_REPOTER_H_
diff --git a/notification/CMakeLists.txt b/notification/CMakeLists.txt
new file mode 100644 (file)
index 0000000..24fb7d5
--- /dev/null
@@ -0,0 +1,68 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(notification C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR ${LIB_INSTALL_DIR})
+SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}")
+
+#ADD_SUBDIRECTORY(test-app)
+
+SET(INIT-SRCS
+       ./src/notification_init.c
+)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SRCS)
+LIST(REMOVE_ITEM SRCS ${INIT-SRCS})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+       sqlite3
+       vconf
+       bundle
+       dlog
+       aul
+       dbus-1
+       capi-appfw-app-control
+       capi-appfw-package-manager
+       pkgmgr-info
+       libtzplatform-config
+       glib-2.0
+       gio-2.0
+       gio-unix-2.0
+       iniparser
+       security-manager
+       libsmack
+)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -g -Wall")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
+
+SET(CMAKE_SKIP_BUILD_RPATH TRUE)
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${MAJORVER})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${FULLVER})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+
+ADD_EXECUTABLE(notification_init ${INIT-SRCS})
+TARGET_LINK_LIBRARIES(notification_init ${pkgs_LDFLAGS} notification "-pie")
+
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
+        DESTINATION include/notification
+        FILES_MATCHING
+               PATTERN "*_private.h" EXCLUDE
+               PATTERN "*_group.h" EXCLUDE
+               PATTERN "*_debug.h" EXCLUDE
+        PATTERN "*.h")
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/11_notification-add.post DESTINATION ${SYSCONF_INSTALL_DIR}/gumd/useradd.d/)
+INSTALL(TARGETS notification_init DESTINATION bin)
similarity index 99%
rename from test-app/main.c
rename to notification/test-app/main.c
index ac288f3..c6034ef 100644 (file)
@@ -356,7 +356,8 @@ static int testapp_test_delete_all_notifications()
 {
        int noti_err = NOTIFICATION_ERROR_NONE;
 
-       noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
+       //noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
+       noti_err = notification_delete_by_display_applist(NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY);
 
        testapp_print("notification_delete_all returns[%d]", noti_err);
 
index 95e0604..cf8fc5a 100644 (file)
@@ -16,12 +16,11 @@ BuildRequires: pkgconfig(capi-appfw-app-control)
 BuildRequires: pkgconfig(capi-appfw-package-manager)
 BuildRequires: pkgconfig(pkgmgr-info)
 BuildRequires: pkgconfig(libtzplatform-config)
-BuildRequires: pkgconfig(gio-2.0)
-BuildRequires: pkgconfig(gio-unix-2.0)
 BuildRequires: pkgconfig(glib-2.0)
 BuildRequires: pkgconfig(iniparser)
 BuildRequires: pkgconfig(security-manager)
 BuildRequires: pkgconfig(libsmack)
+BuildRequires: pkgconfig(gmock)
 
 BuildRequires: cmake
 Requires(post): /sbin/ldconfig
@@ -106,3 +105,53 @@ fi
 %{_includedir}/notification/notification_type_internal.h
 %{_libdir}/pkgconfig/notification.pc
 %{_libdir}/libnotification.so
+
+
+
+#################################################
+# notification-ex
+#################################################
+%package -n %{name}-ex
+Summary: Library for developing the notification
+Group: Applications/Application Utility
+License: Apache-2.0
+
+%description -n %{name}-ex
+Provide APIs to develop the notification.
+
+%package -n %{name}-ex-devel
+Summary: Notification development library (dev)
+Group: Development/Libraries
+Requires: %{name}-ex
+
+%description -n %{name}-ex-devel
+Header & package configuration files to support development of the notification.
+
+%post -n %{name}-ex
+/sbin/ldconfig
+
+%postun -n %{name}-ex -p /sbin/ldconfig
+
+%files -n %{name}-ex
+%manifest %{name}-ex.manifest
+%attr(0644,root,root) %{_libdir}/libnotification-ex.so.*
+%license LICENSE
+
+%files -n %{name}-ex-devel
+%{_includedir}/notification-ex/*.h
+%{_libdir}/pkgconfig/notification-ex.pc
+%attr(0644,root,root) %{_libdir}/libnotification-ex.so
+
+
+#################################################
+# notification_ex_unittests
+#################################################
+%package -n notification_ex_unittests
+Summary:    GTest for notification_ex
+Group:      Development/Libraries
+
+%description -n notification_ex_unittests
+GTest for notification_ex
+
+%files -n notification_ex_unittests
+%{_bindir}/notification_ex_unittests
diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt
new file mode 100644 (file)
index 0000000..129c1ef
--- /dev/null
@@ -0,0 +1,30 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(notification_ex_unittests CXX)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(notification_ex_unittests REQUIRED
+    dlog
+    gmock
+)
+
+FOREACH(flag ${notification_ex_unittests_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++11")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
+
+AUX_SOURCE_DIRECTORY(src SOURCES)
+ADD_EXECUTABLE(${PROJECT_NAME}
+    ${SOURCES}
+)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${watchface-complication_unittests_LDFLAGS}
+    ${pkgs_LDFLAGS}
+    ${pkgs_LIBRARIES}
+    gmock
+)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)
diff --git a/unittest/src/test_main.cc b/unittest/src/test_main.cc
new file mode 100644 (file)
index 0000000..4be05dc
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+int main(int argc, char** argv){
+  int ret = -1;
+  setenv("GCOV_PREFIX", "/tmp/", 1);
+  try {
+    testing::InitGoogleTest(&argc, argv);
+  } catch(...) {
+    std::cout << "Exception occurred" << std::endl;
+  }
+
+  try {
+    ret = RUN_ALL_TESTS();
+  } catch (const ::testing::internal::GoogleTestFailureException& e) {
+    ret = -1;
+    std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl;
+  }
+
+  return ret;
+}