Initialize Noti-ex
[platform/core/api/notification.git] / notification-ex / abstract_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_ABSTRACT_ITEM_H_
18 #define NOTIFICATION_EX_ABSTRACT_ITEM_H_
19
20 #include <time.h>
21
22 #include <memory>
23 #include <string>
24
25 #include "notification-ex/abstract_action.h"
26 #include "notification-ex/bundle.h"
27
28 #ifndef EXPORT_API
29 #define EXPORT_API __attribute__((visibility("default")))
30 #endif
31
32 namespace notification {
33 namespace item {
34
35 class EXPORT_API Color {
36  public:
37   Color() {
38     a_ = 0;
39     r_ = 0;
40     g_ = 0;
41     b_ = 0;
42   }
43   Color(unsigned char a, unsigned char r, unsigned char g, unsigned char b)
44     : a_(a), r_(r), g_(g), b_(b) {
45   }
46   virtual ~Color();
47
48   unsigned char GetAVal() const {
49     return a_;
50   }
51   unsigned char GetRVal() const {
52     return r_;
53   }
54   unsigned char GetGVal() const {
55     return g_;
56   }
57   unsigned char GetBVal() const {
58     return b_;
59   }
60
61  private:
62   unsigned char a_;
63   unsigned char r_;
64   unsigned char g_;
65   unsigned char b_;
66 };  // class Color
67
68 class EXPORT_API Padding {
69  public:
70   Padding() {
71     left_ = 0;
72     top_ = 0;
73     right_ = 0;
74     bottom_ = 0;
75   }
76   Padding(int left, int top, int right, int bottom)
77     : left_(left), top_(top), right_(right), bottom_(bottom) {
78   }
79   virtual ~Padding();
80
81   int GeLeft() const {
82     return left_;
83   }
84   int GetTop() const {
85     return top_;
86   }
87   int GetRight() const {
88     return right_;
89   }
90   int GetBottom() const {
91     return bottom_;
92   }
93
94  private:
95   int left_;
96   int top_;
97   int right_;
98   int bottom_;
99 };  // class  Padding
100
101 class EXPORT_API Geometry {
102  public:
103   Geometry() {
104     x_ = 0;
105     y_ = 0;
106     w_ = 0;
107     h_ = 0;
108   }
109   Geometry(int x, int y, int w, int h) : x_(x), y_(y), w_(w), h_(h) {
110   }
111   virtual ~Geometry();
112
113   int GetX() const {
114     return x_;
115   }
116   int GetY() const {
117     return y_;
118   }
119   int GetWidth() const {
120     return w_;
121   }
122   int GetHeight() const {
123     return h_;
124   }
125
126  private:
127   int x_;
128   int y_;
129   int w_;
130   int h_;
131 };  // class Geometry
132
133 class EXPORT_API Style {
134  public:
135   Style(Color color, Padding padding, Geometry geometry);
136   virtual ~Style();
137
138   Padding GetPadding() const;
139   Color GetColor() const;
140   Geometry GetGeometry() const;
141
142  private:
143   Color color_;
144   Padding padding_;
145   Geometry geometry_;
146 };  // class Style
147
148 class EXPORT_API LEDInfo {
149  public:
150   LEDInfo() {
151     Color(0, 0, 0, 0);
152   }
153   explicit LEDInfo(Color color);
154   virtual ~LEDInfo();
155
156   void SetOffPeriod(int ms);
157   void SetOnPeriod(int ms);
158   Color GetColor() const;
159
160  private:
161   Color color_;
162   int period_ = 0;
163 };  // clss LEDInfo
164
165 class EXPORT_API AbstractItem {
166  public:
167   enum Type {
168     Text,
169     Image,
170     Icon,
171     Button,
172     ChatMessage,
173     CheckBox,
174     IconText,
175     InputSelector,
176     Group,
177     Effect,
178     Progress,
179     Custom,
180   };
181
182   enum Policy {
183     OnBootClear,
184     SimMode,
185   };
186
187  public:
188   AbstractItem();
189   virtual ~AbstractItem();
190
191   virtual Bundle Serialize() = 0;
192   virtual void Deserialize(Bundle b) = 0;
193   virtual std::shared_ptr<AbstractItem> FindByID(std::string id) = 0;
194   std::string GetId() const;
195   void SetId(std::string id);
196   std::shared_ptr<AbstractAction> GetAction() const;
197   Style GetStyle() const;
198   Type GetType() const;
199   void SetVisible(bool visible);
200   void SetEnable(bool enable);
201   void AddReceiver(std::string receiver_group);
202   void RemoveReceiver(std::string receiver_group);
203   bool CanReceive(std::string id) const;
204   void SetPolicy(Policy policy);
205   int GetVersion() const;
206   void SetVersion(int ver);
207   int GetHideTime() const;
208   int GetDeleteTime() const;
209
210  private:
211   Style style_;
212 };  // class AbstractItem
213
214 }  // namespace item
215 }  // namespace notification
216
217 #endif  // NOTIFICATION_EX_ABSTRACT_ITEM_H_