From: hyunho Date: Tue, 19 Feb 2019 07:19:45 +0000 (+0900) Subject: Add implementation of some classes X-Git-Tag: submit/tizen/20190228.000028~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1ec2c765ad03e04f7dca3e35814f21b026162e1a;p=platform%2Fcore%2Fapi%2Fnotification.git Add implementation of some classes - ItemFactory - ItemInflator - AbstractItem - GroupItem - ButtonItem Change-Id: I3e27193e8d9dd2e280fc1f894a1a4f12be03f3d3 Signed-off-by: hyunho --- diff --git a/CMakeLists.txt b/CMakeLists.txt index e85ca6cd..90ed25c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,11 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +ENABLE_TESTING() +SET(NOTIFICATION_UNIT_TESTS notification-ex_unittests) +ADD_TEST(NAME ${NOTIFICATION_UNIT_TESTS} COMMAND ${NOTIFICATION_UNIT_TESTS}) ADD_SUBDIRECTORY(notification) ADD_SUBDIRECTORY(notification-ex) ADD_SUBDIRECTORY(unittest) + +ADD_DEPENDENCIES(notification-ex_unittests notification-ex) diff --git a/notification-ex/CMakeLists.txt b/notification-ex/CMakeLists.txt index ccfaaa87..cebea323 100644 --- a/notification-ex/CMakeLists.txt +++ b/notification-ex/CMakeLists.txt @@ -15,6 +15,7 @@ pkg_check_modules(notification-ex REQUIRED bundle dlog capi-appfw-app-control + capi-appfw-app-common ) FOREACH(flag ${notification-ex_CFLAGS}) diff --git a/notification-ex/abstract_action.h b/notification-ex/abstract_action.h index 347c6596..b9ea3120 100644 --- a/notification-ex/abstract_action.h +++ b/notification-ex/abstract_action.h @@ -32,12 +32,8 @@ 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; diff --git a/notification-ex/abstract_item.cc b/notification-ex/abstract_item.cc new file mode 100644 index 00000000..2503d888 --- /dev/null +++ b/notification-ex/abstract_item.cc @@ -0,0 +1,180 @@ +/* + * 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 "notification-ex/exception.h" +#include "notification-ex/abstract_item.h" +#include "notification-ex/abstract_item_implementation.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "NOTIFICATION_EX" + +#define ABSTRACT_ITEM_TYPE_KEY "__ABSTRACT_ITEM_TYPE_KEY__" +#define ABSTRACT_ITEM_ID_KEY "__ABSTRACT_ITEM_ID_KEY__" + +using namespace std; +namespace notification { +namespace item { + +AbstractItem::AbstractItem() + : impl_(new Impl(this)) { +} + +AbstractItem::AbstractItem(AbstractItem::Type type, + std::shared_ptr action) + : impl_(new Impl(this, type, action)) { +} + +AbstractItem::AbstractItem(std::string id, AbstractItem::Type type, + std::shared_ptr action) + : impl_(new Impl(this, id, type, action)) { +} + +AbstractItem::Impl::Impl(AbstractItem* parent, string id, + AbstractItem::Type type, std::shared_ptr action) + : id_(id), type_(type), action_(action), parent_(parent) { + LOGI("GroupItem created"); +} + +AbstractItem::Impl::Impl(AbstractItem* parent, + AbstractItem::Type type, std::shared_ptr action) + : type_(type), action_(action), parent_(parent) { + LOGI("GroupItem created"); +} + +AbstractItem::Impl::Impl(AbstractItem* parent) + : parent_(parent) { + LOGI("GroupItem created"); +} + +AbstractItem::~AbstractItem() = default; + +Bundle AbstractItem::Serialize() { + Bundle b; + b.Add(ABSTRACT_ITEM_TYPE_KEY, to_string((int)impl_->type_)); + b.Add(ABSTRACT_ITEM_ID_KEY, impl_->id_); + return b; +} + +void AbstractItem::Deserialize(Bundle b) { + string type_str = b.GetString(ABSTRACT_ITEM_TYPE_KEY); + if (type_str.empty()) + THROW(NOTIFICATION_ERROR_IO_ERROR); + + string id_str = b.GetString(ABSTRACT_ITEM_ID_KEY); + impl_->id_ = id_str; + impl_->type_ = static_cast(strtol(type_str.c_str(), NULL, 10)); +} + +string AbstractItem::GetId() const { + return impl_->id_; +} + +shared_ptr AbstractItem::GetAction() const { + return impl_->action_; +} + +shared_ptr