Merge branch 'tizen' into tizen_5.5
[platform/core/api/notification.git] / notification-ex / chat_message_item.h
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 #ifndef NOTIFICATION_EX_CHAT_MESSAGE_ITEM_H_
18 #define NOTIFICATION_EX_CHAT_MESSAGE_ITEM_H_
19
20 #include <time.h>
21
22 #include <string>
23 #include <memory>
24 #include <list>
25
26 #include "notification-ex/abstract_item.h"
27 #include "notification-ex/text_item.h"
28 #include "notification-ex/image_item.h"
29 #include "notification-ex/time_item.h"
30
31 namespace notification {
32 namespace item {
33
34 /**
35  * @brief The class for ChatMessageItem type notification.
36  * @details The class to make the chat message type notification.
37  * @since_tizen 5.5
38  */
39 class EXPORT_API ChatMessageItem : public AbstractItem {
40  public:
41   enum Type {
42     user,
43     sender,
44   };
45
46  public:
47   /**
48    * @brief Constructor
49    * @since_tizen 5.5
50    * @param[in] id The ChatMessageItem id
51    * @param[in] name The name of chat message
52    * @param[in] text The text of chat message
53    * @param[in] image The image of chat message
54    * @param[in] time The time of chat message
55    * @param[in] type The type of chat message
56    * @param[in] action The action for ChatMessageItem
57    */
58   ChatMessageItem(std::string id, std::shared_ptr<TextItem> name,
59     std::shared_ptr<TextItem> text, std::shared_ptr<ImageItem> image,
60     std::shared_ptr<TimeItem> time, Type type,
61     std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
62
63   /**
64    * @brief Destructor
65    * @since_tizen 5.5
66    */
67   virtual ~ChatMessageItem();
68
69   /**
70    * @brief Gets the type of ChatMessageItem.
71    * @since_tizen 5.5
72    * @return AbstractItem::Type::ChatMessage
73    */
74   int GetType() const override;
75
76   /**
77    * @brief Serialize the data of ChatMessageItem.
78    * @since_tizen 5.5
79    * @return Bundle type data
80    */
81   tizen_base::Bundle Serialize() const override;
82
83   /**
84    * @brief Deserialize the serialized data.
85    * @since_tizen 5.5
86    * @param[in] b The serialized Bundle data
87    */
88   void Deserialize(tizen_base::Bundle b) override;
89
90   /**
91    * @brief Finds the AbstractItem using by notification item id.
92    * @since_tizen 5.5
93    * @param[in] id notification item id
94    * @return AbstractItem object
95    */
96   AbstractItem& FindByID(std::string id) override;
97
98   /**
99    * @brief Finds the AbstractItem using by main type.
100    * @since_tizen 5.5
101    * @param[in] type The main type
102    * @return AbstractItem object
103    */
104   AbstractItem& FindByMainType(MainType type) override;
105
106   /**
107    * @brief Checks the item type exist in this notification.
108    * @since_tizen 5.5
109    * @param[in] type notification item type
110    * @return true if the item type exists
111    */
112   bool IsItemTypeExist(int type) override;
113
114   /**
115    * @brief Gets the path of shared file location.
116    * @since_tizen 5.5
117    * @return The list of shared path.
118    */
119   std::list<std::string> GetSharedPath() const override;
120
121   /**
122    * @brief Gets the name data of ChatMessageItem.
123    * @since_tizen 5.5
124    * @return The TextItem type name data
125    */
126   TextItem& GetNameItem() const;
127
128   /**
129    * @brief Gets the text data of ChatMessageItem.
130    * @since_tizen 5.5
131    * @return The TextItem type text data
132    */
133   TextItem& GetTextItem() const;
134
135   /**
136    * @brief Gets the image data of ChatMessageItem.
137    * @since_tizen 5.5
138    * @return The ImageItem type image data
139    */
140   ImageItem& GetImageItem() const;
141
142   /**
143    * @brief Gets the time data of ChantMessageItem.
144    * @since_tizen 5.5
145    * @return The TimeItem type time data
146    */
147   TimeItem& GetTimeItem() const;
148
149   /**
150    * @brief Gets the type of message.
151    * @since_tizen 5.5
152    * @return ChatMessageItem::Type::sender or ChatMessageItem::Type::user
153    */
154   Type GetMessageType() const;
155
156  private:
157   class Impl;
158   std::unique_ptr<Impl> impl_;
159 };  // class ChatMessageItem
160
161 }  // namespace item
162 }  // namespace notification
163 #endif  // NOTIFICATION_EX_CHAT_MESSAGE_ITEM_H_