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 {
697 void SetColor(std::shared_ptr<Color> color) {
698 color_ = std::move(color);
702 std::shared_ptr<Color> color_;
708 * @brief The base class for the notification item classes.
709 * @details The AbstractItem is abstract class.
710 * The AbstractItem has basic APIs for notification items.
711 * The notification item class have to be a derived class of this class.
714 class EXPORT_API AbstractItem {
735 OnBootClear = 1 << 0,
751 * @param[in] action The AbstractAction for notification item
754 std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
759 * @param[in] id The notification id
760 * @param[in] action The AbstractAction for notification item
762 AbstractItem(std::string id,
763 std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
769 virtual ~AbstractItem() = 0;
772 * @brief Serialize the data of AbstractItem.
774 * @return Bundle type data
776 virtual tizen_base::Bundle Serialize() const = 0;
779 * @brief Deserialize the serialized data.
781 * @param[in] b The serialized Bundle data
783 virtual void Deserialize(tizen_base::Bundle b) = 0;
786 * @brief Finds the AbstractItem using by notification item id.
788 * @param[in] id notification item id
789 * @return AbstractItem object
791 virtual AbstractItem& FindByID(std::string id);
794 * @brief Finds the AbstractItem using by main type.
796 * @param[in] type The main type
797 * @return AbstractItem object
799 virtual AbstractItem& FindByMainType(MainType type);
802 * @brief Checks the item type exist in this notification.
804 * @param[in] type notification item type
805 * @return true if the item type exists
807 virtual bool IsItemTypeExist(int type) = 0;
810 * @brief Gets the type of notification item.
812 * @return The type of notification item
814 virtual int GetType() const = 0;
817 * @brief Gets the type of notification item from Bundle data.
819 * @return The type of notification item
821 static int GetType(tizen_base::Bundle b);
824 * @brief Gets the path of shared file location.
826 * @return The list of shared path.
828 virtual std::list<std::string> GetSharedPath() const;
831 * @brief Sets the shared file path to original file path.
833 virtual void SetSharedPath();
840 virtual std::list<std::map<std::string, std::string>> GetPathMapList() const;
843 * @brief Gets the notification item id.
845 * @return The notification item id.
847 std::string GetId() const;
850 * @brief Sets the notification item id.
852 * @param[in] id notification item id
854 void SetId(std::string id);
856 std::vector<std::shared_ptr<MultiLanguage>> GetMultiLanguageArr() const;
857 std::shared_ptr<MultiLanguage> GetMultiLanguage() const;
858 void SetMultiLanguage(std::shared_ptr<MultiLanguage> multi);
859 void SetMultiLanguage(std::vector<std::shared_ptr<MultiLanguage>> multi_arr);
862 * @brief Gets AbstractAction for notification item.
864 * @return AbstractAction instance
866 std::shared_ptr<AbstractAction> GetAction() const;
869 * @brief Sets AbstractAction for notification item.
871 * @param[in] action AbstractAction instance
873 void SetAction(std::shared_ptr<AbstractAction> action);
876 * @brief Sets the style data for notification item.
878 * @return Style instance
880 std::shared_ptr<Style> GetStyle() const;
883 * @brief Sets the style data for notification item.
885 * @param[in] style Style instance
887 void SetStyle(std::shared_ptr<Style> style);
890 * @brief Sets the visibile state of notification item.
892 * @param[in] visibile The visible state
894 void SetVisible(bool visible);
897 * @brief Gets the visibile state of notification item.
899 * @return true if visible, false if not visible.
901 bool GetVisible() const;
904 * @brief Sets the enable state of notification item.
906 * @param[in] enable The enable state
908 void SetEnable(bool enable);
911 * @brief Gets the enable state of notification item.
913 * @return true if enabled, false if not enabled.
915 bool GetEnable() const;
918 * @brief Adds the receiver group for notification item.
920 * @param[in] receiver_group The receiver group for notification item
922 void AddReceiver(std::string receiver_group);
925 * @brief Removes the receiver group from the receiver group list.
927 * @param[in] receiver_group The receiver group
929 void RemoveReceiver(std::string receiver_group);
932 * @brief Gets the receiver group list.
934 * @return The list of receiver group.
936 std::list<std::string> GetReceiverList();
939 * @brief Sets the policy for notification item.
941 * @param[in] policy The policy option
943 void SetPolicy(int policy);
946 * @brief Gets the policy for notification item.
948 * @return The policy for notification item.
950 int GetPolicy() const;
953 * @brief Gets the channel option for notification item.
955 * @return The channel option for notification item.
957 std::string GetChannel() const;
960 * @brief Sets the channel option for notification item.
962 * @param[in] channel The channel option for notification item.
964 void SetChannel(std::string channel);
967 * @brief Sets LED option for notification item.
969 * @param[in] led The LEDInfo instance
971 void SetLEDInfo(std::shared_ptr<LEDInfo> led);
974 * @brief Gets LED option for notification item.
976 * @return The LEDInfo instance
978 std::shared_ptr<LEDInfo> GetLEDInfo() const;
981 * @brief Sets the sound path for notification item.
983 * @param[in] path The sound path
985 void SetSoundPath(std::string path);
988 * @brief Sets the vibration path for notification item.
990 * @param[in] path The vibration path
992 void SetVibrationPath(std::string path);
995 * @brief Gets the sound path for notification item.
997 * @return The sound path
999 std::string GetSoundPath() const;
1002 * @brief Gets the vibration path for notification item.
1004 * @return The vibration path
1006 std::string GetVibrationPath() const;
1009 * @brief Gets IItemInfo instance to get some information of notification item.
1011 * @return The IItemInfo instance
1013 std::shared_ptr<IItemInfo> GetInfo() const;
1016 * @brief Gets the sender app id of notification item.
1018 * @return The sender app id.
1020 std::string GetSenderAppId() const;
1023 * @brief Sets the sender app id of notification item.
1025 * @param[in] sender_appid The sender app id
1027 void SetSenderAppId(std::string sender_appid);
1030 * @brief Sets the tag of notification item.
1032 * @return The tag of notification item
1034 std::string GetTag() const;
1037 * @brief Sets the tag of notification item.
1039 * @param[in] tag The tag of notification item
1041 void SetTag(std::string tag);
1044 * @brief Sets the ongoing state of notification item.
1046 * @param[in] ongoing The ongoing state of notification item
1048 void SetOnGoingState(bool ongoing);
1051 * @brief Gets the ongoing state of notification item.
1053 * @return The ongoing state of notification item
1055 bool GetOnGoingState() const;
1058 * @brief Sets the main type of notification item.
1060 * @param[in] target_id The ID of notification item to set
1061 * @param[in] type The main type
1062 * @return true if target_id is valid to set
1064 bool SetMainType(std::string target_id, MainType type);
1067 * @brief Gets the main type of notification item.
1069 * @return The main type
1071 MainType GetMainType() const;
1075 std::unique_ptr<Impl> impl_;
1076 void UpdateSoundPrivatePath();
1077 void UpdateVibrationPrivatePath();
1078 }; // class AbstractItem
1081 } // namespace notification
1083 #endif // NOTIFICATION_EX_ABSTRACT_ITEM_H_