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.
21 #include "notification-ex/entry_item.h"
22 #include "notification-ex/entry_item_implementation.h"
23 #include "notification-ex/factory_manager.h"
29 #define LOG_TAG "NOTIFICATION_EX"
30 #define ENTRY_TEXT_KEY "__ENTRY_TEXT_KEY__"
31 #define ENTRY_LIMIT_KEY "__ENTRY_LIMIT_KEY__"
33 using namespace tizen_base;
35 namespace notification {
38 EntryItem::EntryItem(std::shared_ptr<AbstractAction> action)
39 : AbstractItem(action), impl_(new Impl(this)) {
42 EntryItem::EntryItem(std::string id, std::shared_ptr<AbstractAction> action)
43 : AbstractItem(id, action), impl_(new Impl(this)) {
46 EntryItem::Impl::Impl(EntryItem* parent)
48 LOGI("EntryItem created");
51 EntryItem::~EntryItem() = default;
52 EntryItem::Impl::~Impl() = default;
54 int EntryItem::GetType() const {
55 return AbstractItem::Entry;
58 Bundle EntryItem::Serialize() const {
60 b = AbstractItem::Serialize();
62 if (!impl_->text_.empty())
63 b.Add(ENTRY_TEXT_KEY, impl_->text_);
65 b.Add(ENTRY_LIMIT_KEY, std::to_string(impl_->limit_));
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));
76 AbstractItem& EntryItem::FindByID(std::string id) {
79 return FactoryManager::GetInst().GetNullItem();
82 bool EntryItem::IsItemTypeExist(int type) {
83 if (GetType() == type)
88 std::string EntryItem::GetText() const {
92 void EntryItem::SetText(std::string text) {
96 int EntryItem::GetTextLimit() const {
101 } // namespace notification