Fix group name for noti_ex
[platform/core/api/notification.git] / notification-ex / image_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 "notification-ex/image_item.h"
20 #include "notification-ex/image_item_implementation.h"
21 #include "notification-ex/factory_manager.h"
22 #include "notification-ex/exception.h"
23
24 #ifdef LOG_TAG
25 #undef LOG_TAG
26 #endif
27
28 #define LOG_TAG "NOTIFICATION_EX"
29 #define IMAGE_PATH_KEY "__IMAGE_PATH_KEY__"
30
31 using namespace tizen_base;
32
33 namespace notification {
34 namespace item {
35
36 ImageItem::ImageItem(std::string image_path,
37     std::shared_ptr<AbstractAction> action)
38     : AbstractItem(action), impl_(new Impl(this, image_path)) {
39 }
40
41 ImageItem::ImageItem(std::string id, std::string image_path,
42     std::shared_ptr<AbstractAction> action)
43     : AbstractItem(id, action), impl_(new Impl(this, image_path)) {
44 }
45
46 ImageItem::Impl::Impl(ImageItem* parent, std::string image_path)
47     : parent_(parent), image_path_(image_path) {
48   LOGI("ImageItem impl created");
49 }
50
51 int ImageItem::GetType() const {
52   return AbstractItem::Image;
53 }
54
55 Bundle ImageItem::Serialize() const {
56   Bundle b;
57   b = AbstractItem::Serialize();
58   b.Add(IMAGE_PATH_KEY, impl_->image_path_);
59
60   return b;
61 }
62
63 void ImageItem::Deserialize(Bundle b) {
64   AbstractItem::Deserialize(b);
65   impl_->image_path_ = b.GetString(IMAGE_PATH_KEY);
66 }
67
68 bool ImageItem::IsItemTypeExist(int type) {
69   if (GetType() == type)
70     return true;
71   return false;
72 }
73
74 std::string ImageItem::GetImagePath() const {
75   return impl_->image_path_;
76 }
77
78 ImageItem::~ImageItem() = default;
79 ImageItem::Impl::~Impl() = default;
80
81 }  // namespace item
82 }  // namespace notification