2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef NOTIFICATION_EX_ABSTRACT_ITEM_H_
18 #define NOTIFICATION_EX_ABSTRACT_ITEM_H_
26 #include "notification-ex/abstract_action.h"
27 #include "notification-ex/ex_bundle.h"
28 #include "notification-ex/iitem_info.h"
31 #define EXPORT_API __attribute__((visibility("default")))
34 namespace notification {
37 class EXPORT_API Color {
45 Color(unsigned char a, unsigned char r, unsigned char g, unsigned char b)
46 : a_(a), r_(r), g_(g), b_(b) {
48 virtual ~Color() = default;
50 unsigned char GetAVal() const {
53 unsigned char GetRVal() const {
56 unsigned char GetGVal() const {
59 unsigned char GetBVal() const {
70 class EXPORT_API Padding {
78 Padding(int left, int top, int right, int bottom)
79 : left_(left), top_(top), right_(right), bottom_(bottom) {
81 virtual ~Padding() = default;
89 int GetRight() const {
92 int GetBottom() const {
103 class EXPORT_API Geometry {
111 Geometry(int x, int y, int w, int h) : x_(x), y_(y), w_(w), h_(h) {
113 virtual ~Geometry() = default;
121 int GetWidth() const {
124 int GetHeight() const {
135 class EXPORT_API Style {
139 Style(Color color, Padding padding, Geometry geometry)
140 : color_(color), padding_(padding), geometry_(geometry) {
142 virtual ~Style() = default;
144 Padding GetPadding() const {
147 Color GetColor() const {
150 Geometry GetGeometry() const {
160 class EXPORT_API LEDInfo {
165 explicit LEDInfo(Color color)
168 virtual ~LEDInfo() = default;
170 void SetOnPeriod(int ms) {
173 int GetOnPeriod() const {
176 void SetOffPeriod(int ms) {
179 int GetOffPeriod() const {
183 Color GetColor() const {
193 class EXPORT_API AbstractItem {
214 OnBootClear = 1 << 0,
220 std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
221 AbstractItem(std::string id,
222 std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
223 virtual ~AbstractItem() = 0;
224 virtual Bundle Serialize() const = 0;
225 virtual void Deserialize(Bundle b) = 0;
226 virtual AbstractItem& FindByID(std::string id) = 0;
227 virtual int GetType() const = 0;
228 static int GetType(Bundle b);
229 virtual std::list<std::string> GetSharedPath() const;
230 std::string GetId() const;
231 void SetId(std::string id);
232 std::shared_ptr<AbstractAction> GetAction() const;
233 void SetAction(std::shared_ptr<AbstractAction> action);
234 std::shared_ptr<Style> GetStyle() const;
235 void SetStyle(std::shared_ptr<Style> style);
236 void SetVisible(bool visible);
237 bool GetVisible() const;
238 void SetEnable(bool enable);
239 bool GetEnable() const;
240 void AddReceiver(std::string receiver_group);
241 void RemoveReceiver(std::string receiver_group);
242 std::list<std::string> GetReceiverList();
243 bool CanReceive(std::string receiver_group) const;
244 void SetPolicy(int policy);
245 int GetPolicy() const;
246 std::string GetChannel() const;
247 void SetChannel(std::string channel);
248 void SetLEDInfo(std::shared_ptr<LEDInfo> led);
249 std::shared_ptr<LEDInfo> GetLEDInfo() const;
250 void SetSoundPath(std::string path);
251 void SetVibrationPath(std::string path);
252 std::string GetSoundPath() const;
253 std::string GetVibrationPath() const;
254 std::shared_ptr<IItemInfo> GetInfo() const;
255 std::string GetSenderAppId() const;
256 void SetSenderAppId(std::string sender_appid);
257 std::string GetTag();
262 std::unique_ptr<Impl> impl_;
263 }; // class AbstractItem
266 } // namespace notification
268 #endif // NOTIFICATION_EX_ABSTRACT_ITEM_H_