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 {
42 * @brief The class for ReceiverGroup.
43 * @details The class to define receiver group of notification.
46 class EXPORT_API ReceiverGroup {
48 static const std::string Panel;
49 static const std::string Ticker;
50 static const std::string LockScreen;
51 static const std::string Indicator;
52 static const std::string Popup;
56 * @brief The class for color data.
57 * @details The color consists A,R,G,B values.
60 class EXPORT_API Color {
68 Color(unsigned char a, unsigned char r, unsigned char g, unsigned char b)
69 : a_(a), r_(r), g_(g), b_(b) {
71 virtual ~Color() = default;
74 * @brief Copy-constructor.
76 * @param[in] c The object to copy
78 Color(const Color& c) {
88 * @param[in] c The object to copy
90 Color& operator = (const Color& c) {
101 * @brief Move-constructor.
103 * @param[in] c The object to move
105 Color(Color&& c) noexcept {
122 * @param[in] c The object to move
124 Color& operator = (Color&& c) noexcept {
142 * @brief Gets alpha value of color.
144 * @return The alpha value of color
146 unsigned char GetAVal() const {
151 * @brief Gets red value of color.
153 * @return The red value of color
155 unsigned char GetRVal() const {
160 * @brief Gets green value of color.
162 * @return The green value of color
164 unsigned char GetGVal() const {
169 * @brief Gets blue value of color.
171 * @return The blue value of color
173 unsigned char GetBVal() const {
185 * @brief The class for padding data.
186 * @details There are left, top, right, bottom padding value.
189 class EXPORT_API Padding {
197 Padding(int left, int top, int right, int bottom)
198 : left_(left), top_(top), right_(right), bottom_(bottom) {
200 virtual ~Padding() = default;
203 * @brief Copy-constructor.
205 * @param[in] c The object to copy
207 Padding(const Padding& c) {
217 * @param[in] c The object to copy
219 Padding& operator = (const Padding& c) {
230 * @brief Move-constructor.
232 * @param[in] c The object to move
234 Padding(Padding&& c) noexcept {
251 * @param[in] c The object to move
253 Padding& operator = (Padding&& c) noexcept {
271 * @brief Gets left value of padding.
273 * @return The left value of padding
275 int GetLeft() const {
280 * @brief Gets top value of padding.
282 * @return The top value of padding
289 * @brief Gets right value of padding.
291 * @return the right value of padding
293 int GetRight() const {
298 * @brief Gets bottom value of padding.
300 * @return The bottom value of padding.
302 int GetBottom() const {
314 * @brief The class for geometry data.
315 * @details There are x, y, width, height value.
318 class EXPORT_API Geometry {
326 Geometry(int x, int y, int w, int h) : x_(x), y_(y), w_(w), h_(h) {
328 virtual ~Geometry() = default;
331 * @brief Copy-constructor.
333 * @param[in] c The object to copy
335 Geometry(const Geometry& c) {
345 * @param[in] c The object to copy
347 Geometry& operator = (const Geometry& c) {
358 * @brief Move-constructor.
360 * @param[in] c The object to move
362 Geometry(Geometry&& c) noexcept {
379 * @param[in] c The object to move
381 Geometry& operator = (Geometry&& c) noexcept {
399 * @brief Gets x value of geometry.
401 * @return The x value of geometry.
408 * @brief Gets y value of geometry.
410 * @return The y value of geometry.
417 * @brief Gets width value of geometry.
419 * @return The width value of geometry.
421 int GetWidth() const {
426 * @brief Gets height value of geometry.
428 * @return The height value of geometry.
430 int GetHeight() const {
442 * @brief The class for style data
443 * @details The style data consists color, padding, geometry data.
446 class EXPORT_API Style {
451 Style(std::shared_ptr<Color> color, std::shared_ptr<Padding> padding,
452 std::shared_ptr<Geometry> geometry)
453 : color_(color), padding_(padding), geometry_(geometry) {
456 Style(std::shared_ptr<Color> color, std::shared_ptr<Padding> padding,
457 std::shared_ptr<Geometry> geometry,
458 std::shared_ptr<Color> background_color, std::string background_image)
459 : color_(color), padding_(padding), geometry_(geometry),
460 background_color_(background_color),
461 background_image_path_(background_image) {
464 virtual ~Style() = default;
467 * @brief Copy-constructor.
469 * @param[in] c The object to copy
471 Style(const Style& c) {
473 padding_ = c.padding_;
474 geometry_ = c.geometry_;
475 background_color_ = c.background_color_;
476 background_image_path_ = c.background_image_path_;
482 * @param[in] c The object to copy
484 Style& operator = (const Style& c) {
487 padding_ = c.padding_;
488 geometry_ = c.geometry_;
489 background_color_ = c.background_color_;
490 background_image_path_ = c.background_image_path_;
496 * @brief Move-constructor.
498 * @param[in] c The object to move
500 Style(Style&& c) noexcept {
504 padding_ = c.padding_;
505 c.padding_ = nullptr;
507 geometry_ = c.geometry_;
508 c.geometry_ = nullptr;
510 background_color_ = c.background_color_;
511 c.background_color_ = nullptr;
513 background_image_path_ = c.background_image_path_;
514 c.background_image_path_ = "";
520 * @param[in] c The object to move
522 Style& operator = (Style&& c) noexcept {
527 padding_ = c.padding_;
528 c.padding_ = nullptr;
530 geometry_ = c.geometry_;
531 c.geometry_ = nullptr;
533 background_color_ = c.background_color_;
534 c.background_color_ = nullptr;
536 background_image_path_ = c.background_image_path_;
537 c.background_image_path_ = "";
543 * @brief Gets padding data
545 * @return The padding data
547 std::shared_ptr<Padding> GetPadding() const {
552 * @brief Sets padding data
554 * @param[in] padding The padding data
556 void SetPadding(std::shared_ptr<Padding> padding) {
557 padding_ = std::move(padding);
561 * @brief Gets color data
563 * @return The color data
565 std::shared_ptr<Color> GetColor() const {
570 * @brief Sets color data
572 * @param[in] color The color data
574 void SetColor(std::shared_ptr<Color> color) {
575 color_ = std::move(color);
579 * @brief Gets geometry data
581 * @return The geometry data
583 std::shared_ptr<Geometry> GetGeometry() const {
588 * @brief Sets geometry data
590 * @param[in] geometry The geometry data
592 void SetGeometry(std::shared_ptr<Geometry> geometry) {
593 geometry_ = std::move(geometry);
597 * @brief Gets background image path
599 * @param[in] image_path The background image path
601 void SetBackgroundImage(std::string image_path) {
602 background_image_path_ = std::move(image_path);
606 * @brief Gets background image path
608 * @return The background image path
610 std::string GetBackgroundImage() const {
611 return background_image_path_;
615 * @brief Sets background color
618 void SetBackgroundColor(std::shared_ptr<Color> color) {
619 background_color_ = std::move(color);
623 * @brief Gets background color
625 * @return The background color
627 std::shared_ptr<Color> GetBackgroundColor() const {
628 return background_color_;
632 std::shared_ptr<Color> color_;
633 std::shared_ptr<Padding> padding_;
634 std::shared_ptr<Geometry> geometry_;
635 std::shared_ptr<Color> background_color_;
636 std::string background_image_path_;
640 * @brief The class for LED data.
641 * @details The LED data consists color data and period time.
644 class EXPORT_API LEDInfo {
648 explicit LEDInfo(std::shared_ptr<Color> color)
651 virtual ~LEDInfo() = default;
654 * @brief Sets the time period for turning on the LED
656 * @param[in] ms period time
658 void SetOnPeriod(int ms) {
663 * @brief Gets the time period for turning on the LED
665 * @return The time for turning on the LED
667 int GetOnPeriod() const {
672 * @brief Sets the time period for turning off the LED
674 * @param[in] ms period time
676 void SetOffPeriod(int ms) {
681 * @brief Gets the time period for turning off the LED
683 * @return The time for turning off the LED
685 int GetOffPeriod() const {
690 * @brief Gets the color of LED
694 std::shared_ptr<Color> GetColor() const {
698 void SetColor(std::shared_ptr<Color> color) {
699 color_ = std::move(color);
703 std::shared_ptr<Color> color_;
709 * @brief The base class for the notification item classes.
710 * @details The AbstractItem is abstract class.
711 * The AbstractItem has basic APIs for notification items.
712 * The notification item class have to be a derived class of this class.
715 class EXPORT_API AbstractItem {
736 OnBootClear = 1 << 0,
752 * @param[in] action The AbstractAction for notification item
755 std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
760 * @param[in] id The notification id
761 * @param[in] action The AbstractAction for notification item
763 AbstractItem(std::string id,
764 std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
770 virtual ~AbstractItem() = 0;
773 * @brief Serialize the data of AbstractItem.
775 * @return Bundle type data
777 virtual tizen_base::Bundle Serialize() const = 0;
780 * @brief Deserialize the serialized data.
782 * @param[in] b The serialized Bundle data
784 virtual void Deserialize(tizen_base::Bundle b) = 0;
787 * @brief Finds the AbstractItem using by notification item id.
789 * @param[in] id notification item id
790 * @return AbstractItem object
792 virtual AbstractItem& FindByID(std::string id);
795 * @brief Finds the AbstractItem using by main type.
797 * @param[in] type The main type
798 * @return AbstractItem object
800 virtual AbstractItem& FindByMainType(MainType type);
803 * @brief Checks the item type exist in this notification.
805 * @param[in] type notification item type
806 * @return true if the item type exists
808 virtual bool IsItemTypeExist(int type) = 0;
811 * @brief Gets the type of notification item.
813 * @return The type of notification item
815 virtual int GetType() const = 0;
818 * @brief Gets the type of notification item from Bundle data.
820 * @return The type of notification item
822 static int GetType(tizen_base::Bundle b);
825 * @brief Gets the path of shared file location.
827 * @return The list of shared path.
829 virtual std::list<std::string> GetSharedPath() const;
832 * @brief Sets the shared file path to original file path.
834 virtual void SetSharedPath();
841 virtual std::list<std::map<std::string, std::string>> GetPathMapList() const;
844 * @brief Gets the notification item id.
846 * @return The notification item id.
848 std::string GetId() const;
851 * @brief Sets the notification item id.
853 * @param[in] id notification item id
855 void SetId(std::string id);
857 std::vector<std::shared_ptr<MultiLanguage>> GetMultiLanguageArr() const;
858 std::shared_ptr<MultiLanguage> GetMultiLanguage() const;
859 void SetMultiLanguage(std::shared_ptr<MultiLanguage> multi);
860 void SetMultiLanguage(std::vector<std::shared_ptr<MultiLanguage>> multi_arr);
863 * @brief Gets AbstractAction for notification item.
865 * @return AbstractAction instance
867 std::shared_ptr<AbstractAction> GetAction() const;
870 * @brief Sets AbstractAction for notification item.
872 * @param[in] action AbstractAction instance
874 void SetAction(std::shared_ptr<AbstractAction> action);
877 * @brief Sets the style data for notification item.
879 * @return Style instance
881 std::shared_ptr<Style> GetStyle() const;
884 * @brief Sets the style data for notification item.
886 * @param[in] style Style instance
888 void SetStyle(std::shared_ptr<Style> style);
891 * @brief Sets the visibile state of notification item.
893 * @param[in] visibile The visible state
895 void SetVisible(bool visible);
898 * @brief Gets the visibile state of notification item.
900 * @return true if visible, false if not visible.
902 bool GetVisible() const;
905 * @brief Sets the enable state of notification item.
907 * @param[in] enable The enable state
909 void SetEnable(bool enable);
912 * @brief Gets the enable state of notification item.
914 * @return true if enabled, false if not enabled.
916 bool GetEnable() const;
919 * @brief Adds the receiver group for notification item.
921 * @param[in] receiver_group The receiver group for notification item
923 void AddReceiver(std::string receiver_group);
926 * @brief Removes the receiver group from the receiver group list.
928 * @param[in] receiver_group The receiver group
930 void RemoveReceiver(std::string receiver_group);
933 * @brief Gets the receiver group list.
935 * @return The list of receiver group.
937 std::list<std::string> GetReceiverList();
940 * @brief Sets the policy for notification item.
942 * @param[in] policy The policy option
944 void SetPolicy(int policy);
947 * @brief Gets the policy for notification item.
949 * @return The policy for notification item.
951 int GetPolicy() const;
954 * @brief Gets the channel option for notification item.
956 * @return The channel option for notification item.
958 std::string GetChannel() const;
961 * @brief Sets the channel option for notification item.
963 * @param[in] channel The channel option for notification item.
965 void SetChannel(std::string channel);
968 * @brief Sets LED option for notification item.
970 * @param[in] led The LEDInfo instance
972 void SetLEDInfo(std::shared_ptr<LEDInfo> led);
975 * @brief Gets LED option for notification item.
977 * @return The LEDInfo instance
979 std::shared_ptr<LEDInfo> GetLEDInfo() const;
982 * @brief Sets the sound path for notification item.
984 * @param[in] path The sound path
986 void SetSoundPath(std::string path);
989 * @brief Sets the vibration path for notification item.
991 * @param[in] path The vibration path
993 void SetVibrationPath(std::string path);
996 * @brief Gets the sound path for notification item.
998 * @return The sound path
1000 std::string GetSoundPath() const;
1003 * @brief Gets the vibration path for notification item.
1005 * @return The vibration path
1007 std::string GetVibrationPath() const;
1010 * @brief Gets IItemInfo instance to get some information of notification item.
1012 * @return The IItemInfo instance
1014 std::shared_ptr<IItemInfo> GetInfo() const;
1017 * @brief Gets the sender app id of notification item.
1019 * @return The sender app id.
1021 std::string GetSenderAppId() const;
1024 * @brief Sets the sender app id of notification item.
1026 * @param[in] sender_appid The sender app id
1028 void SetSenderAppId(std::string sender_appid);
1031 * @brief Sets the tag of notification item.
1033 * @return The tag of notification item
1035 std::string GetTag() const;
1038 * @brief Sets the tag of notification item.
1040 * @param[in] tag The tag of notification item
1042 void SetTag(std::string tag);
1045 * @brief Sets the ongoing state of notification item.
1047 * @param[in] ongoing The ongoing state of notification item
1049 void SetOnGoingState(bool ongoing);
1052 * @brief Gets the ongoing state of notification item.
1054 * @return The ongoing state of notification item
1056 bool GetOnGoingState() const;
1059 * @brief Sets the main type of notification item.
1061 * @param[in] target_id The ID of notification item to set
1062 * @param[in] type The main type
1063 * @return true if target_id is valid to set
1065 bool SetMainType(std::string target_id, MainType type);
1068 * @brief Gets the main type of notification item.
1070 * @return The main type
1072 MainType GetMainType() const;
1075 * @brief Gets the extension data.
1080 tizen_base::Bundle GetExtensionData(std::string key);
1083 * @brief Sets the extension data.
1085 * @param[in] key key string
1086 * @param[in] value Bundle
1088 void SetExtensionData(std::string key, tizen_base::Bundle value);
1092 std::unique_ptr<Impl> impl_;
1093 void UpdateSoundPrivatePath();
1094 void UpdateVibrationPrivatePath();
1095 }; // class AbstractItem
1096 /* LCOV_EXCL_STOP */
1099 } // namespace notification
1101 #endif // NOTIFICATION_EX_ABSTRACT_ITEM_H_