diff options
author | mk5004.lee <mk5004.lee@samsung.com> | 2019-02-21 18:13:19 +0900 |
---|---|---|
committer | mk5004.lee <mk5004.lee@samsung.com> | 2019-02-28 11:28:50 +0900 |
commit | bc323136ed8e6aab7bdfa589a6455412cb213be4 (patch) | |
tree | 6e13e61de75a27965a53c28967e669e0fe9dbd70 /notification-ex/icon_text_item.cc | |
parent | 7ce27d9bda8cd08f1cb24606f8350ab0af4e93fd (diff) | |
download | notification-bc323136ed8e6aab7bdfa589a6455412cb213be4.tar.gz notification-bc323136ed8e6aab7bdfa589a6455412cb213be4.tar.bz2 notification-bc323136ed8e6aab7bdfa589a6455412cb213be4.zip |
Update some items
- image, icon, icontext, checkbox, time, chatmessage
Change-Id: I74f8b7192037da6ae8f608ea08d542e4fa803716
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
Diffstat (limited to 'notification-ex/icon_text_item.cc')
-rw-r--r-- | notification-ex/icon_text_item.cc | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/notification-ex/icon_text_item.cc b/notification-ex/icon_text_item.cc new file mode 100644 index 0000000..9ba8833 --- /dev/null +++ b/notification-ex/icon_text_item.cc @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <dlog.h> + +#include "notification-ex/icon_text_item.h" +#include "notification-ex/icon_text_item_implementation.h" +#include "notification-ex/item_factory.h" +#include "notification-ex/exception.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "NOTIFICATION_EX" +#define ICONTEXT_PATH_KEY "__ICONTEXT_PATH_KEY__" +#define ICONTEXT_TITLE_KEY "__ICONTEXT_TITLE_KEY__" + +namespace notification { +namespace item { + +IconTextItem::IconTextItem(std::string id, std::shared_ptr<IconItem> icon, + std::shared_ptr<TextItem> text, std::shared_ptr<AbstractAction> action) + : AbstractItem(AbstractItem::IconText, action), + impl_(new Impl(this, icon, text)) { +} + +IconTextItem::Impl::Impl(IconTextItem* parent, std::shared_ptr<IconItem> icon, + std::shared_ptr<TextItem> text) + : parent_(parent), icon_(icon), text_(text) { + LOGI("IconTextItem impl created"); +} + +Bundle IconTextItem::Serialize() { + Bundle b; + b = AbstractItem::Serialize(); + + b.Add(ICONTEXT_PATH_KEY, + reinterpret_cast<char*>(impl_->icon_->Serialize().ToRaw().first.get())); + b.Add(ICONTEXT_TITLE_KEY, + reinterpret_cast<char*>(impl_->text_->Serialize().ToRaw().first.get())); + return b; +} + +void IconTextItem::Deserialize(Bundle b) { + ItemFactory factory; + + AbstractItem::Deserialize(b); + + std::shared_ptr<AbstractItem> icon = factory.CreateItem(AbstractItem::Icon); + icon.get()->Deserialize(Bundle(b.GetString(ICONTEXT_PATH_KEY))); + impl_->icon_ = std::static_pointer_cast<IconItem>(icon); + + std::shared_ptr<AbstractItem> text = factory.CreateItem(AbstractItem::Text); + text.get()->Deserialize(Bundle(b.GetString(ICONTEXT_TITLE_KEY))); + impl_->text_ = std::static_pointer_cast<TextItem>(text); +} + +AbstractItem& IconTextItem::FindByID(std::string id) { + if (GetId() == id) + return *this; + + return ItemFactory::GetNullItem(); +} + +IconItem& IconTextItem::GetIconItem() const { + return *(impl_->icon_); +} + +TextItem& IconTextItem::GetTextItem() const { + return *(impl_->text_); +} + +IconTextItem::~IconTextItem() = default; +IconTextItem::Impl::~Impl() = default; + +} // namespace item +} // namespace notification_ex |