2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "notification-ex/abstract_action.h"
20 #include "notification-ex/abstract_action_implementation.h"
26 #define LOG_TAG "NOTIFICATION_EX"
27 #define ABSTRACT_ACTION_TYPE_KEY "__ABSTRACT_ACTION_TYPE_KEY__"
28 #define ABSTRACT_ACTION_IS_LOCAL_KEY "__ABSTRACT_ACTION_IS_LOCAL_KEY__"
29 #define ABSTRACT_ACTION_EXTRA_KEY "__ABSTRACT_ACTION_EXTRA_KEY__"
31 using namespace tizen_base;
33 namespace notification {
35 AbstractAction::AbstractAction(bool isLocal)
36 : impl_(new Impl(this, isLocal)) {
39 AbstractAction::AbstractAction(bool isLocal, std::string extra)
40 : impl_(new Impl(this, isLocal, extra)) {
43 AbstractAction::Impl::Impl(AbstractAction* parent, bool isLocal)
44 : parent_(parent) , isLocal_(isLocal) {
45 LOGI("Action created");
48 AbstractAction::Impl::Impl(AbstractAction* parent, bool isLocal,
49 std::string extra) : parent_(parent) , isLocal_(isLocal), extra_(extra) {
50 LOGI("Action created");
53 AbstractAction::~AbstractAction() = default;
54 AbstractAction::Impl::~Impl() = default;
56 int AbstractAction::GetType(Bundle b) {
57 return std::stoi(b.GetString(ABSTRACT_ACTION_TYPE_KEY));
60 Bundle AbstractAction::Serialize() const {
63 b.Add(ABSTRACT_ACTION_TYPE_KEY, std::to_string(GetType()));
64 b.Add(ABSTRACT_ACTION_IS_LOCAL_KEY, std::to_string(impl_->isLocal_));
65 if (!impl_->extra_.empty())
66 b.Add(ABSTRACT_ACTION_EXTRA_KEY, impl_->extra_);
70 void AbstractAction::Deserialize(Bundle b) {
71 impl_->isLocal_ = std::stoi(b.GetString(ABSTRACT_ACTION_IS_LOCAL_KEY));
72 impl_->extra_ = b.GetString(ABSTRACT_ACTION_EXTRA_KEY);
75 bool AbstractAction::IsLocal() const {
76 return impl_->isLocal_;
79 void AbstractAction::Execute(std::shared_ptr<AbstractItem> item) {
82 std::string AbstractAction::GetExtra() const {
87 } // namespace notification