Merge branch 'tizen' into tizen_5.5
[platform/core/api/notification.git] / notification-ex / abstract_action.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_ABSTRACT_ACTION_H_
18 #define NOTIFICATION_EX_ABSTRACT_ACTION_H_
19
20 #include <memory>
21 #include <string>
22
23 #include <bundle_cpp.h>
24
25 #ifndef EXPORT_API
26 #define EXPORT_API __attribute__((visibility("default")))
27 #endif
28
29 namespace notification {
30 namespace item {
31
32 class AbstractItem;
33
34 /**
35  * @brief The base class for the notification action classes.
36  * @details The AbstractAction is abstract class.
37  *          The AbstractAction has basic APIs for notification actions.
38  *          The notification action class have to be a derived class of this class.
39  * @since_tizen 5.5
40  */
41 class EXPORT_API AbstractAction {
42  public:
43   enum Type {
44     NullObject,
45     AppControl,
46     Visibility,
47     Custom = 100
48   };
49
50  public:
51   /**
52    * @brief Constructor
53    * @since_tizen 5.5
54    * @param[in] isLoacal
55    */
56   AbstractAction(bool isLocal);
57
58   /**
59    * @brief Constructor
60    * @since_tizen 5.5
61    * @param[in] isLocal
62    * @param[in] extra
63    */
64   AbstractAction(bool isLocal, std::string extra);
65
66   /**
67    * @brief Destructor
68    * @since_tizen 5.5
69    */
70   virtual ~AbstractAction();
71
72   /**
73    * @brief Gets the type of action
74    * @since_tizen 5.5
75    * @return The type of action
76    */
77   virtual int GetType() const = 0;
78
79   /**
80    * @brief Gets the type of action from Bundle data
81    * @since_tizen 5.5
82    * @param[in] b Bundle type data
83    * @return The type of action
84    */
85   static int GetType(tizen_base::Bundle b);
86
87   /**
88    * @brief Serialize the data of AbstractAction.
89    * @since_tizen 5.5
90    * @return Bundle type data
91    */
92   virtual tizen_base::Bundle Serialize() const = 0;
93
94   /**
95    * @brief Deserialize the serialized data.
96    * @since_tizen 5.5
97    * @param[in] b The serialized Bundle data
98    */
99   virtual void Deserialize(tizen_base::Bundle b) = 0;
100
101   /**
102    * @brief Gets whether local or not.
103    * @since_tizen 5.5
104    * @return true if local, or false
105    */
106   virtual bool IsLocal() const = 0;
107
108   /**
109    * @brief Execute the action
110    * @since_tizen 5.5
111    * @param[in] item The AbstractItem
112    */
113   virtual void Execute(std::shared_ptr<AbstractItem> item) = 0;
114
115   /**
116    * @brief Gets the extra data
117    * @since_tizen 5.5
118    * @return The extra data
119    */
120   virtual std::string GetExtra() const = 0;
121
122  private:
123   class Impl;
124   std::unique_ptr<Impl> impl_;
125 };
126
127 }  // namespace item
128 }  // namespace notification
129
130 #endif  // NOTIFICATION_EX_ABSTRACT_ACTION_H_