Change default sound, vibration name
[platform/core/api/notification.git] / notification-ex / entry_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/entry_item.h"
22 #include "notification-ex/entry_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 ENTRY_TEXT_KEY "__ENTRY_TEXT_KEY__"
31 #define ENTRY_LIMIT_KEY "__ENTRY_LIMIT_KEY__"
32
33 using namespace tizen_base;
34
35 namespace notification {
36 namespace item {
37
38 EntryItem::EntryItem(std::shared_ptr<AbstractAction> action)
39     : AbstractItem(action), impl_(new Impl(this)) {
40 }
41
42 EntryItem::EntryItem(std::string id, std::shared_ptr<AbstractAction> action)
43     : AbstractItem(id, action), impl_(new Impl(this)) {
44 }
45
46 EntryItem::Impl::Impl(EntryItem* parent)
47     : parent_(parent) {
48   LOGI("EntryItem created");
49 }
50
51 EntryItem::~EntryItem() = default;
52 EntryItem::Impl::~Impl() = default;
53
54 int EntryItem::GetType() const {
55   return AbstractItem::Entry;
56 }
57
58 Bundle EntryItem::Serialize() const {
59   Bundle b;
60   b = AbstractItem::Serialize();
61
62   if (!impl_->text_.empty())
63     b.Add(ENTRY_TEXT_KEY, impl_->text_);
64
65   b.Add(ENTRY_LIMIT_KEY, std::to_string(impl_->limit_));
66
67   return b;
68 }
69
70 void EntryItem::Deserialize(Bundle b) {
71   AbstractItem::Deserialize(b);
72   impl_->text_ = b.GetString(ENTRY_TEXT_KEY);
73   impl_->limit_ = std::stoi(b.GetString(ENTRY_LIMIT_KEY));
74 }
75
76 bool EntryItem::IsItemTypeExist(int type) {
77   if (GetType() == type)
78     return true;
79   return false;
80 }
81
82 std::string EntryItem::GetText() const {
83   return impl_->text_;
84 }
85
86 void EntryItem::SetText(std::string text) {
87   impl_->text_ = text;
88 }
89
90 int EntryItem::GetTextLimit() const {
91   return impl_->limit_;
92 }
93
94 }  // namespace item
95 }  // namespace notification