From: mk5004.lee Date: Mon, 28 Jan 2019 10:25:41 +0000 (+0900) Subject: Initialize Noti-ex X-Git-Tag: submit/tizen/20190228.000028~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F43%2F198643%2F23;p=platform%2Fcore%2Fapi%2Fnotification.git Initialize Noti-ex Change-Id: I96813e041aee48027806f97fef8a28bdc5d49c27 Signed-off-by: mk5004.lee --- diff --git a/CMakeLists.txt b/CMakeLists.txt index f528db1..e85ca6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 index 0000000..6c61ae0 --- /dev/null +++ b/notification-ex.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/notification-ex/CMakeLists.txt b/notification-ex/CMakeLists.txt new file mode 100644 index 0000000..be66165 --- /dev/null +++ b/notification-ex/CMakeLists.txt @@ -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 index 0000000..a5431b1 --- /dev/null +++ b/notification-ex/abstract_action.h @@ -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 + +#include +#include + +#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 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 index 0000000..9069ee0 --- /dev/null +++ b/notification-ex/abstract_item.h @@ -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 + +#include +#include + +#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 FindByID(std::string id) = 0; + std::string GetId() const; + void SetId(std::string id); + std::shared_ptr 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 index 0000000..f5f337f --- /dev/null +++ b/notification-ex/action.cc @@ -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 +#include + +#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 index 0000000..247e323 --- /dev/null +++ b/notification-ex/action.h @@ -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 + +#include +#include + +#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 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 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 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 index 0000000..4ff78e9 --- /dev/null +++ b/notification-ex/bundle.cc @@ -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(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 index 0000000..3246789 --- /dev/null +++ b/notification-ex/bundle.h @@ -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 + +#include + +#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 index 0000000..8a0a67d --- /dev/null +++ b/notification-ex/common.h @@ -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 index 0000000..e0ad60a --- /dev/null +++ b/notification-ex/dbus_listener.h @@ -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 index 0000000..8c1943d --- /dev/null +++ b/notification-ex/dbus_manager.h @@ -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 + +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 index 0000000..5fd1bed --- /dev/null +++ b/notification-ex/dbus_sender.h @@ -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 index 0000000..55b31b8 --- /dev/null +++ b/notification-ex/event_info.h @@ -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 + +#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 index 0000000..3990271 --- /dev/null +++ b/notification-ex/event_listener_interface.h @@ -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 index 0000000..3c42a4e --- /dev/null +++ b/notification-ex/event_sender_interface.h @@ -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 index 0000000..9e87cb7 --- /dev/null +++ b/notification-ex/exception.h @@ -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 +#include + +#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 index 0000000..95fa057 --- /dev/null +++ b/notification-ex/item.cc @@ -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 +#include +#include +#include + +#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 index 0000000..c231ab1 --- /dev/null +++ b/notification-ex/item.h @@ -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 + +#include +#include +#include + +#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 FindByID(std::string id) override; + void AddChild(std::shared_ptr child); + void Remove(std::string itemId); + std::list> 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 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 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 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 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 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 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 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 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 FindByID(std::string id) override; + std::list GetContents() const; + void SetContents(std::list contents); + + private: + std::list contents_; +}; // class InputSelectorItem + +class EXPORT_API EntryItem : public AbstractItem { + public: + EntryItem(); + virtual ~EntryItem(); + + Bundle Serialize() override; + void Deserialize(Bundle b) override; + std::shared_ptr 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 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 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 index 0000000..8942ba1 --- /dev/null +++ b/notification-ex/manager.h @@ -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 +#include + +#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 noti); + void Remove(std::shared_ptr noti); + void Hide(std::shared_ptr noti); + std::shared_ptr FindByRootID(std::string id); + void SendEvent(EventInfo info, std::shared_ptr noti); + void OnEvent(EventInfo info, std::shared_ptr notiList) override; + + protected: + virtual void OnAdd(std::list> addedItem); + virtual void OnUpdate(shared_ptr updatedItem); + virtual void OnDelete(shared_ptr 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 index 0000000..1df439b --- /dev/null +++ b/notification-ex/mock_listener.h @@ -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 index 0000000..c4dea88 --- /dev/null +++ b/notification-ex/mock_sender.h @@ -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 index 0000000..a4fdc5e --- /dev/null +++ b/notification-ex/notification-ex.pc.in @@ -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 index 0000000..9c1e5d2 --- /dev/null +++ b/notification-ex/observer_interface.h @@ -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 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 index 0000000..90cbf6f --- /dev/null +++ b/notification-ex/repoter.h @@ -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 +#include + +#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 noti); + void Post(std::list> notiList); + void Update(std::shared_ptr noti); + void Remove(std::shared_ptr noti); + std::shared_ptr FindByRootID(std::string id); + void OnEvent(EventInfo info, std::shared_ptr notiList) override; + + private: + IEventsSender* sender_; + IEventsListener* receiver_; +}; + +} // namespace notification + +#endif // NOTIFICATION_EX_REPOTER_H_ diff --git a/11_notification-add.post b/notification/11_notification-add.post similarity index 100% rename from 11_notification-add.post rename to notification/11_notification-add.post diff --git a/notification/CMakeLists.txt b/notification/CMakeLists.txt new file mode 100644 index 0000000..24fb7d5 --- /dev/null +++ b/notification/CMakeLists.txt @@ -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) diff --git a/include/notification.h b/notification/include/notification.h similarity index 100% rename from include/notification.h rename to notification/include/notification.h diff --git a/include/notification_db.h b/notification/include/notification_db.h similarity index 100% rename from include/notification_db.h rename to notification/include/notification_db.h diff --git a/include/notification_debug.h b/notification/include/notification_debug.h similarity index 100% rename from include/notification_debug.h rename to notification/include/notification_debug.h diff --git a/include/notification_error.h b/notification/include/notification_error.h similarity index 100% rename from include/notification_error.h rename to notification/include/notification_error.h diff --git a/include/notification_group.h b/notification/include/notification_group.h similarity index 100% rename from include/notification_group.h rename to notification/include/notification_group.h diff --git a/include/notification_internal.h b/notification/include/notification_internal.h similarity index 100% rename from include/notification_internal.h rename to notification/include/notification_internal.h diff --git a/include/notification_ipc.h b/notification/include/notification_ipc.h similarity index 100% rename from include/notification_ipc.h rename to notification/include/notification_ipc.h diff --git a/include/notification_list.h b/notification/include/notification_list.h similarity index 100% rename from include/notification_list.h rename to notification/include/notification_list.h diff --git a/include/notification_noti.h b/notification/include/notification_noti.h similarity index 100% rename from include/notification_noti.h rename to notification/include/notification_noti.h diff --git a/include/notification_ongoing.h b/notification/include/notification_ongoing.h similarity index 100% rename from include/notification_ongoing.h rename to notification/include/notification_ongoing.h diff --git a/include/notification_ongoing_flag.h b/notification/include/notification_ongoing_flag.h similarity index 100% rename from include/notification_ongoing_flag.h rename to notification/include/notification_ongoing_flag.h diff --git a/include/notification_private.h b/notification/include/notification_private.h similarity index 100% rename from include/notification_private.h rename to notification/include/notification_private.h diff --git a/include/notification_setting.h b/notification/include/notification_setting.h similarity index 100% rename from include/notification_setting.h rename to notification/include/notification_setting.h diff --git a/include/notification_setting_internal.h b/notification/include/notification_setting_internal.h similarity index 100% rename from include/notification_setting_internal.h rename to notification/include/notification_setting_internal.h diff --git a/include/notification_setting_service.h b/notification/include/notification_setting_service.h similarity index 100% rename from include/notification_setting_service.h rename to notification/include/notification_setting_service.h diff --git a/include/notification_shared_file.h b/notification/include/notification_shared_file.h similarity index 100% rename from include/notification_shared_file.h rename to notification/include/notification_shared_file.h diff --git a/include/notification_status.h b/notification/include/notification_status.h similarity index 100% rename from include/notification_status.h rename to notification/include/notification_status.h diff --git a/include/notification_status_internal.h b/notification/include/notification_status_internal.h similarity index 100% rename from include/notification_status_internal.h rename to notification/include/notification_status_internal.h diff --git a/include/notification_text_domain.h b/notification/include/notification_text_domain.h similarity index 100% rename from include/notification_text_domain.h rename to notification/include/notification_text_domain.h diff --git a/include/notification_type.h b/notification/include/notification_type.h similarity index 100% rename from include/notification_type.h rename to notification/include/notification_type.h diff --git a/include/notification_type_internal.h b/notification/include/notification_type_internal.h similarity index 100% rename from include/notification_type_internal.h rename to notification/include/notification_type_internal.h diff --git a/include/notification_viewer.h b/notification/include/notification_viewer.h similarity index 100% rename from include/notification_viewer.h rename to notification/include/notification_viewer.h diff --git a/notification.pc.in b/notification/notification.pc.in similarity index 100% rename from notification.pc.in rename to notification/notification.pc.in diff --git a/src/notification.c b/notification/src/notification.c similarity index 100% rename from src/notification.c rename to notification/src/notification.c diff --git a/src/notification_db.c b/notification/src/notification_db.c similarity index 100% rename from src/notification_db.c rename to notification/src/notification_db.c diff --git a/src/notification_db_query.h b/notification/src/notification_db_query.h similarity index 100% rename from src/notification_db_query.h rename to notification/src/notification_db_query.h diff --git a/src/notification_error.c b/notification/src/notification_error.c similarity index 100% rename from src/notification_error.c rename to notification/src/notification_error.c diff --git a/src/notification_group.c b/notification/src/notification_group.c similarity index 100% rename from src/notification_group.c rename to notification/src/notification_group.c diff --git a/src/notification_init.c b/notification/src/notification_init.c similarity index 100% rename from src/notification_init.c rename to notification/src/notification_init.c diff --git a/src/notification_internal.c b/notification/src/notification_internal.c similarity index 100% rename from src/notification_internal.c rename to notification/src/notification_internal.c diff --git a/src/notification_ipc.c b/notification/src/notification_ipc.c similarity index 100% rename from src/notification_ipc.c rename to notification/src/notification_ipc.c diff --git a/src/notification_ipc_socket.c b/notification/src/notification_ipc_socket.c similarity index 100% rename from src/notification_ipc_socket.c rename to notification/src/notification_ipc_socket.c diff --git a/src/notification_list.c b/notification/src/notification_list.c similarity index 100% rename from src/notification_list.c rename to notification/src/notification_list.c diff --git a/src/notification_noti.c b/notification/src/notification_noti.c similarity index 100% rename from src/notification_noti.c rename to notification/src/notification_noti.c diff --git a/src/notification_ongoing.c b/notification/src/notification_ongoing.c similarity index 100% rename from src/notification_ongoing.c rename to notification/src/notification_ongoing.c diff --git a/src/notification_setting.c b/notification/src/notification_setting.c similarity index 100% rename from src/notification_setting.c rename to notification/src/notification_setting.c diff --git a/src/notification_setting_service.c b/notification/src/notification_setting_service.c similarity index 100% rename from src/notification_setting_service.c rename to notification/src/notification_setting_service.c diff --git a/src/notification_shared_file.c b/notification/src/notification_shared_file.c similarity index 100% rename from src/notification_shared_file.c rename to notification/src/notification_shared_file.c diff --git a/src/notification_status.c b/notification/src/notification_status.c similarity index 100% rename from src/notification_status.c rename to notification/src/notification_status.c diff --git a/src/notification_viewer.c b/notification/src/notification_viewer.c similarity index 100% rename from src/notification_viewer.c rename to notification/src/notification_viewer.c diff --git a/test-app/CMakeLists.txt b/notification/test-app/CMakeLists.txt similarity index 100% rename from test-app/CMakeLists.txt rename to notification/test-app/CMakeLists.txt diff --git a/test-app/main.c b/notification/test-app/main.c similarity index 99% rename from test-app/main.c rename to notification/test-app/main.c index ac288f3..c6034ef 100644 --- a/test-app/main.c +++ b/notification/test-app/main.c @@ -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); diff --git a/packaging/notification.spec b/packaging/notification.spec index 95e0604..cf8fc5a 100644 --- a/packaging/notification.spec +++ b/packaging/notification.spec @@ -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 index 0000000..129c1ef --- /dev/null +++ b/unittest/CMakeLists.txt @@ -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 index 0000000..4be05dc --- /dev/null +++ b/unittest/src/test_main.cc @@ -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 +#include + +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; +}