Add implementation of some classes
[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
23 #ifdef LOG_TAG
24 #undef LOG_TAG
25 #endif
26
27 #define LOG_TAG "NOTIFICATION_EX"
28 #define BUTTON_TITLE_KEY "__BUTTON_TITLE_KEY__"
29
30 namespace notification {
31 namespace item {
32
33 ButtonItem::ButtonItem(string title,
34       std::shared_ptr<AbstractAction> action)
35   : AbstractItem(AbstractItem::Button, action), title_(title) {
36 }
37
38 ButtonItem::ButtonItem(string id, string title,
39       std::shared_ptr<AbstractAction> action)
40   : AbstractItem(id, AbstractItem::Button, action), title_(title) {
41 }
42 ButtonItem::~ButtonItem() = default;
43
44 Bundle ButtonItem::Serialize() {
45   Bundle b;
46   b = AbstractItem::Serialize();
47   b.Add(BUTTON_TITLE_KEY, title_);
48   return b;
49 }
50
51 void ButtonItem::Deserialize(Bundle b) {
52   AbstractItem::Deserialize(b);
53   title_ = b.GetString(BUTTON_TITLE_KEY);
54 }
55
56 shared_ptr<AbstractItem> ButtonItem::FindByID(std::string id) {
57   if (GetId() == id)
58     return shared_ptr<AbstractItem>(this);
59   return nullptr;
60 }
61
62 std::string ButtonItem::GetTitle() const {
63   return title_;
64 }
65
66 }  // namespace item
67 }  // namespace notification