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_
21 #include <bundle_cpp.h>
29 #include "notification-ex/abstract_action.h"
30 #include "notification-ex/multi_language.h"
31 #include "notification-ex/iitem_info.h"
34 #define EXPORT_API __attribute__((visibility("default")))
37 namespace notification {
41 * @brief The class for ReceiverGroup.
42 * @details The class to define receiver group of notification.
45 class EXPORT_API ReceiverGroup {
47 static const std::string Panel;
48 static const std::string Ticker;
49 static const std::string LockScreen;
50 static const std::string Indicator;
51 static const std::string Popup;
55 * @brief The class for color data.
56 * @details The color consists A,R,G,B values.
59 class EXPORT_API Color {
67 Color(unsigned char a, unsigned char r, unsigned char g, unsigned char b)
68 : a_(a), r_(r), g_(g), b_(b) {
70 virtual ~Color() = default;
73 * @brief Copy-constructor.
75 * @param[in] c The object to copy
77 Color(const Color& c) {
87 * @param[in] c The object to copy
89 Color& operator = (const Color& c) {
100 * @brief Move-constructor.
102 * @param[in] c The object to move
104 Color(Color&& c) noexcept {
121 * @param[in] c The object to move
123 Color& operator = (Color&& c) noexcept {
141 * @brief Gets alpha value of color.
143 * @return The alpha value of color
145 unsigned char GetAVal() const {
150 * @brief Gets red value of color.
152 * @return The red value of color
154 unsigned char GetRVal() const {
159 * @brief Gets green value of color.
161 * @return The green value of color
163 unsigned char GetGVal() const {
168 * @brief Gets blue value of color.
170 * @return The blue value of color
172 unsigned char GetBVal() const {
184 * @brief The class for padding data.
185 * @details There are left, top, right, bottom padding value.
188 class EXPORT_API Padding {
196 Padding(int left, int top, int right, int bottom)
197 : left_(left), top_(top), right_(right), bottom_(bottom) {
199 virtual ~Padding() = default;
202 * @brief Copy-constructor.
204 * @param[in] c The object to copy
206 Padding(const Padding& c) {
216 * @param[in] c The object to copy
218 Padding& operator = (const Padding& c) {
229 * @brief Move-constructor.
231 * @param[in] c The object to move
233 Padding(Padding&& c) noexcept {
250 * @param[in] c The object to move
252 Padding& operator = (Padding&& c) noexcept {
270 * @brief Gets left value of padding.
272 * @return The left value of padding
274 int GetLeft() const {
279 * @brief Gets top value of padding.
281 * @return The top value of padding
288 * @brief Gets right value of padding.
290 * @return the right value of padding
292 int GetRight() const {
297 * @brief Gets bottom value of padding.
299 * @return The bottom value of padding.
301 int GetBottom() const {
313 * @brief The class for geometry data.
314 * @details There are x, y, width, height value.
317 class EXPORT_API Geometry {
325 Geometry(int x, int y, int w, int h) : x_(x), y_(y), w_(w), h_(h) {
327 virtual ~Geometry() = default;
330 * @brief Copy-constructor.
332 * @param[in] c The object to copy
334 Geometry(const Geometry& c) {
344 * @param[in] c The object to copy
346 Geometry& operator = (const Geometry& c) {
357 * @brief Move-constructor.
359 * @param[in] c The object to move
361 Geometry(Geometry&& c) noexcept {
378 * @param[in] c The object to move
380 Geometry& operator = (Geometry&& c) noexcept {
398 * @brief Gets x value of geometry.
400 * @return The x value of geometry.
407 * @brief Gets y value of geometry.
409 * @return The y value of geometry.
416 * @brief Gets width value of geometry.
418 * @return The width value of geometry.
420 int GetWidth() const {
425 * @brief Gets height value of geometry.
427 * @return The height value of geometry.
429 int GetHeight() const {
441 * @brief The class for style data
442 * @details The style data consists color, padding, geometry data.
445 class EXPORT_API Style {
450 Style(std::shared_ptr<Color> color, std::shared_ptr<Padding> padding,
451 std::shared_ptr<Geometry> geometry)
452 : color_(color), padding_(padding), geometry_(geometry) {
455 Style(std::shared_ptr<Color> color, std::shared_ptr<Padding> padding,
456 std::shared_ptr<Geometry> geometry,
457 std::shared_ptr<Color> background_color, std::string background_image)
458 : color_(color), padding_(padding), geometry_(geometry),
459 background_color_(background_color),
460 background_image_path_(background_image) {
463 virtual ~Style() = default;
466 * @brief Copy-constructor.
468 * @param[in] c The object to copy
470 Style(const Style& c) {
472 padding_ = c.padding_;
473 geometry_ = c.geometry_;
474 background_color_ = c.background_color_;
475 background_image_path_ = c.background_image_path_;
481 * @param[in] c The object to copy
483 Style& operator = (const Style& c) {
486 padding_ = c.padding_;
487 geometry_ = c.geometry_;
488 background_color_ = c.background_color_;
489 background_image_path_ = c.background_image_path_;
495 * @brief Move-constructor.
497 * @param[in] c The object to move
499 Style(Style&& c) noexcept {
503 padding_ = c.padding_;
504 c.padding_ = nullptr;
506 geometry_ = c.geometry_;
507 c.geometry_ = nullptr;
509 background_color_ = c.background_color_;
510 c.background_color_ = nullptr;
512 background_image_path_ = c.background_image_path_;
513 c.background_image_path_ = "";
519 * @param[in] c The object to move
521 Style& operator = (Style&& c) noexcept {
526 padding_ = c.padding_;
527 c.padding_ = nullptr;
529 geometry_ = c.geometry_;
530 c.geometry_ = nullptr;
532 background_color_ = c.background_color_;
533 c.background_color_ = nullptr;
535 background_image_path_ = c.background_image_path_;
536 c.background_image_path_ = "";
542 * @brief Gets padding data
544 * @return The padding data
546 std::shared_ptr<Padding> GetPadding() const {
551 * @brief Sets padding data
553 * @param[in] padding The padding data
555 void SetPadding(std::shared_ptr<Padding> padding) {
556 padding_ = std::move(padding);
560 * @brief Gets color data
562 * @return The color data
564 std::shared_ptr<Color> GetColor() const {
569 * @brief Sets color data
571 * @param[in] color The color data
573 void SetColor(std::shared_ptr<Color> color) {
574 color_ = std::move(color);
578 * @brief Gets geometry data
580 * @return The geometry data
582 std::shared_ptr<Geometry> GetGeometry() const {
587 * @brief Sets geometry data
589 * @param[in] geometry The geometry data
591 void SetGeometry(std::shared_ptr<Geometry> geometry) {
592 geometry_ = std::move(geometry);
596 * @brief Gets background image path
598 * @param[in] image_path The background image path
600 void SetBackgroundImage(std::string image_path) {
601 background_image_path_ = std::move(image_path);
605 * @brief Gets background image path
607 * @return The background image path
609 std::string GetBackgroundImage() const {
610 return background_image_path_;
614 * @brief Sets background color
617 void SetBackgroundColor(std::shared_ptr<Color> color) {
618 background_color_ = std::move(color);
622 * @brief Gets background color
624 * @return The background color
626 std::shared_ptr<Color> GetBackgroundColor() const {
627 return background_color_;
631 std::shared_ptr<Color> color_;
632 std::shared_ptr<Padding> padding_;
633 std::shared_ptr<Geometry> geometry_;
634 std::shared_ptr<Color> background_color_;
635 std::string background_image_path_;
639 * @brief The class for LED data.
640 * @details The LED data consists color data and period time.
643 class EXPORT_API LEDInfo {
647 explicit LEDInfo(std::shared_ptr<Color> color)
650 virtual ~LEDInfo() = default;
653 * @brief Sets the time period for turning on the LED
655 * @param[in] ms period time
657 void SetOnPeriod(int ms) {
662 * @brief Gets the time period for turning on the LED
664 * @return The time for turning on the LED
666 int GetOnPeriod() const {
671 * @brief Sets the time period for turning off the LED
673 * @param[in] ms period time
675 void SetOffPeriod(int ms) {
680 * @brief Gets the time period for turning off the LED
682 * @return The time for turning off the LED
684 int GetOffPeriod() const {
689 * @brief Gets the color of LED
693 std::shared_ptr<Color> GetColor() const {
698 std::shared_ptr<Color> color_;
704 * @brief The base class for the notification item classes.
705 * @details The AbstractItem is abstract class.
706 * The AbstractItem has basic APIs for notification items.
707 * The notification item class have to be a derived class of this class.
710 class EXPORT_API AbstractItem {
731 OnBootClear = 1 << 0,
747 * @param[in] action The AbstractAction for notification item
750 std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
755 * @param[in] id The notification id
756 * @param[in] action The AbstractAction for notification item
758 AbstractItem(std::string id,
759 std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
765 virtual ~AbstractItem() = 0;
768 * @brief Serialize the data of AbstractItem.
770 * @return Bundle type data
772 virtual tizen_base::Bundle Serialize() const = 0;
775 * @brief Deserialize the serialized data.
777 * @param[in] b The serialized Bundle data
779 virtual void Deserialize(tizen_base::Bundle b) = 0;
782 * @brief Finds the AbstractItem using by notification item id.
784 * @param[in] id notification item id
785 * @return AbstractItem object
787 virtual AbstractItem& FindByID(std::string id);
790 * @brief Finds the AbstractItem using by main type.
792 * @param[in] type The main type
793 * @return AbstractItem object
795 virtual AbstractItem& FindByMainType(MainType type);
798 * @brief Checks the item type exist in this notification.
800 * @param[in] type notification item type
801 * @return true if the item type exists
803 virtual bool IsItemTypeExist(int type) = 0;
806 * @brief Gets the type of notification item.
808 * @return The type of notification item
810 virtual int GetType() const = 0;
813 * @brief Gets the type of notification item from Bundle data.
815 * @return The type of notification item
817 static int GetType(tizen_base::Bundle b);
820 * @brief Gets the path of shared file location.
822 * @return The list of shared path.
824 virtual std::list<std::string> GetSharedPath() const;
827 * @brief Sets the shared file path to original file path.
829 virtual void SetSharedPath();
836 virtual std::list<std::map<std::string, std::string>> GetPathMapList() const;
839 * @brief Gets the notification item id.
841 * @return The notification item id.
843 std::string GetId() const;
846 * @brief Sets the notification item id.
848 * @param[in] id notification item id
850 void SetId(std::string id);
852 std::vector<std::shared_ptr<MultiLanguage>> GetMultiLanguageArr() const;
853 std::shared_ptr<MultiLanguage> GetMultiLanguage() const;
854 void SetMultiLanguage(std::shared_ptr<MultiLanguage> multi);
855 void SetMultiLanguage(std::vector<std::shared_ptr<MultiLanguage>> multi_arr);
858 * @brief Gets AbstractAction for notification item.
860 * @return AbstractAction instance
862 std::shared_ptr<AbstractAction> GetAction() const;
865 * @brief Sets AbstractAction for notification item.
867 * @param[in] action AbstractAction instance
869 void SetAction(std::shared_ptr<AbstractAction> action);
872 * @brief Sets the style data for notification item.
874 * @return Style instance
876 std::shared_ptr<Style> GetStyle() const;
879 * @brief Sets the style data for notification item.
881 * @param[in] style Style instance
883 void SetStyle(std::shared_ptr<Style> style);
886 * @brief Sets the visibile state of notification item.
888 * @param[in] visibile The visible state
890 void SetVisible(bool visible);
893 * @brief Gets the visibile state of notification item.
895 * @return true if visible, false if not visible.
897 bool GetVisible() const;
900 * @brief Sets the enable state of notification item.
902 * @param[in] enable The enable state
904 void SetEnable(bool enable);
907 * @brief Gets the enable state of notification item.
909 * @return true if enabled, false if not enabled.
911 bool GetEnable() const;
914 * @brief Adds the receiver group for notification item.
916 * @param[in] receiver_group The receiver group for notification item
918 void AddReceiver(std::string receiver_group);
921 * @brief Removes the receiver group from the receiver group list.
923 * @param[in] receiver_group The receiver group
925 void RemoveReceiver(std::string receiver_group);
928 * @brief Gets the receiver group list.
930 * @return The list of receiver group.
932 std::list<std::string> GetReceiverList();
935 * @brief Sets the policy for notification item.
937 * @param[in] policy The policy option
939 void SetPolicy(int policy);
942 * @brief Gets the policy for notification item.
944 * @return The policy for notification item.
946 int GetPolicy() const;
949 * @brief Gets the channel option for notification item.
951 * @return The channel option for notification item.
953 std::string GetChannel() const;
956 * @brief Sets the channel option for notification item.
958 * @param[in] channel The channel option for notification item.
960 void SetChannel(std::string channel);
963 * @brief Sets LED option for notification item.
965 * @param[in] led The LEDInfo instance
967 void SetLEDInfo(std::shared_ptr<LEDInfo> led);
970 * @brief Gets LED option for notification item.
972 * @return The LEDInfo instance
974 std::shared_ptr<LEDInfo> GetLEDInfo() const;
977 * @brief Sets the sound path for notification item.
979 * @param[in] path The sound path
981 void SetSoundPath(std::string path);
984 * @brief Sets the vibration path for notification item.
986 * @param[in] path The vibration path
988 void SetVibrationPath(std::string path);
991 * @brief Gets the sound path for notification item.
993 * @return The sound path
995 std::string GetSoundPath() const;
998 * @brief Gets the vibration path for notification item.
1000 * @return The vibration path
1002 std::string GetVibrationPath() const;
1005 * @brief Gets IItemInfo instance to get some information of notification item.
1007 * @return The IItemInfo instance
1009 std::shared_ptr<IItemInfo> GetInfo() const;
1012 * @brief Gets the sender app id of notification item.
1014 * @return The sender app id.
1016 std::string GetSenderAppId() const;
1019 * @brief Sets the sender app id of notification item.
1021 * @param[in] sender_appid The sender app id
1023 void SetSenderAppId(std::string sender_appid);
1026 * @brief Sets the tag of notification item.
1028 * @return The tag of notification item
1030 std::string GetTag() const;
1033 * @brief Sets the tag of notification item.
1035 * @param[in] tag The tag of notification item
1037 void SetTag(std::string tag);
1040 * @brief Sets the ongoing state of notification item.
1042 * @param[in] ongoing The ongoing state of notification item
1044 void SetOnGoingState(bool ongoing);
1047 * @brief Gets the ongoing state of notification item.
1049 * @return The ongoing state of notification item
1051 bool GetOnGoingState() const;
1054 * @brief Sets the main type of notification item.
1056 * @param[in] target_id The ID of notification item to set
1057 * @param[in] type The main type
1058 * @return true if target_id is valid to set
1060 bool SetMainType(std::string target_id, MainType type);
1063 * @brief Gets the main type of notification item.
1065 * @return The main type
1067 MainType GetMainType() const;
1071 std::unique_ptr<Impl> impl_;
1072 }; // class AbstractItem
1075 } // namespace notification
1077 #endif // NOTIFICATION_EX_ABSTRACT_ITEM_H_