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/text_item.h"
22 #include "notification-ex/text_item_implementation.h"
23 #include "notification-ex/factory_manager.h"
29 #define LOG_TAG "NOTIFICATION_EX"
30 #define TEXT_CONTENTS_KEY "__TEXT_CONTENTS_KEY__"
31 #define TEXT_HYPERLINK_KEY "__TEXT_HYPERLINK_KEY__"
33 using namespace tizen_base;
35 namespace notification {
37 TextItem::TextItem(std::string id, std::string text, std::string hyperlink,
38 std::shared_ptr<AbstractAction> action)
39 : AbstractItem(id, action), impl_(new Impl(this, text, hyperlink)) {
42 TextItem::Impl::Impl(TextItem* parent, std::string text, std::string hyperlink)
43 : parent_(parent), text_(text), hyperlink_(hyperlink) {
44 LOGI("TextItem created");
47 TextItem::~TextItem() = default;
48 TextItem::Impl::~Impl() = default;
50 int TextItem::GetType() const {
51 return AbstractItem::Text;
54 Bundle TextItem::Serialize() const {
56 b = AbstractItem::Serialize();
58 if (!impl_->text_.empty())
59 b.Add(TEXT_CONTENTS_KEY, impl_->text_);
61 if (!impl_->hyperlink_.empty())
62 b.Add(TEXT_HYPERLINK_KEY, impl_->hyperlink_);
67 void TextItem::Deserialize(Bundle b) {
68 AbstractItem::Deserialize(b);
69 impl_->text_ = b.GetString(TEXT_CONTENTS_KEY);
70 impl_->hyperlink_ = b.GetString(TEXT_HYPERLINK_KEY);
73 AbstractItem& TextItem::FindByID(std::string id) {
76 return FactoryManager::GetInst().GetNullItem();
79 void TextItem::SetContents(std::string contents) {
80 impl_->text_ = contents;
83 std::string TextItem::GetContents() const {
87 std::string TextItem::GetHyperLink() const {
88 return impl_->hyperlink_;
92 } // namespace notification