Merge "Fix build warning based on GCC-9" into tizen
[platform/core/api/notification.git] / notification-ex / button_item.cc
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <dlog.h>
18
19 #include <memory>
20
21 #include "notification-ex/button_item.h"
22 #include "notification-ex/button_item_implementation.h"
23 #include "notification-ex/factory_manager.h"
24
25 #ifdef LOG_TAG
26 #undef LOG_TAG
27 #endif
28
29 #define LOG_TAG "NOTIFICATION_EX"
30 #define BUTTON_TITLE_KEY "__BUTTON_TITLE_KEY__"
31
32 using namespace std;
33 using namespace tizen_base;
34
35 namespace notification {
36 namespace item {
37
38 ButtonItem::ButtonItem(string title, std::shared_ptr<AbstractAction> action)
39     : AbstractItem(action), impl_(new Impl(this, title)) {
40 }
41
42 ButtonItem::ButtonItem(string id, string title,
43     std::shared_ptr<AbstractAction> action)
44     : AbstractItem(id, action), impl_(new Impl(this, title)) {
45 }
46
47 ButtonItem::~ButtonItem() = default;
48 ButtonItem::Impl::~Impl() = default;
49
50 ButtonItem::Impl::Impl(ButtonItem* parent, string title)
51     : title_(title), parent_(parent) {
52   LOGI("ButtonItem impl created");
53 }
54
55 int ButtonItem::GetType() const {
56   return AbstractItem::Button;
57 }
58
59 Bundle ButtonItem::Serialize() const {
60   Bundle b;
61   b = AbstractItem::Serialize();
62   b.Add(BUTTON_TITLE_KEY, impl_->title_);
63   return b;
64 }
65
66 void ButtonItem::Deserialize(Bundle b) {
67   AbstractItem::Deserialize(b);
68   impl_->title_ = b.GetString(BUTTON_TITLE_KEY);
69 }
70
71 bool ButtonItem::IsItemTypeExist(int type) {
72   if (GetType() == type)
73     return true;
74   return false;
75 }
76
77 std::string ButtonItem::GetTitle() const {
78   return impl_->title_;
79 }
80
81 }  // namespace item
82 }  // namespace notification