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>
28 #include "notification-ex/abstract_action.h"
29 #include "notification-ex/multi_language.h"
30 #include "notification-ex/iitem_info.h"
33 #define EXPORT_API __attribute__((visibility("default")))
36 namespace notification {
40 * @brief The class for ReceiverGroup.
41 * @details The class to define receiver group of notification.
44 class EXPORT_API ReceiverGroup {
46 static const std::string Panel;
47 static const std::string Ticker;
48 static const std::string LockScreen;
49 static const std::string Indicator;
50 static const std::string Popup;
54 * @brief The class for color data.
55 * @details The color consists A,R,G,B values.
58 class EXPORT_API Color {
66 Color(unsigned char a, unsigned char r, unsigned char g, unsigned char b)
67 : a_(a), r_(r), g_(g), b_(b) {
69 virtual ~Color() = default;
72 * @brief Copy-constructor.
74 * @param[in] c The object to copy
76 Color(const Color& c) {
86 * @param[in] c The object to copy
88 Color& operator = (const Color& c) {
99 * @brief Move-constructor.
101 * @param[in] c The object to move
103 Color(Color&& c) noexcept {
120 * @param[in] c The object to move
122 Color& operator = (Color&& c) noexcept {
140 * @brief Gets alpha value of color.
142 * @return The alpha value of color
144 unsigned char GetAVal() const {
149 * @brief Gets red value of color.
151 * @return The red value of color
153 unsigned char GetRVal() const {
158 * @brief Gets green value of color.
160 * @return The green value of color
162 unsigned char GetGVal() const {
167 * @brief Gets blue value of color.
169 * @return The blue value of color
171 unsigned char GetBVal() const {
183 * @brief The class for padding data.
184 * @details There are left, top, right, bottom padding value.
187 class EXPORT_API Padding {
195 Padding(int left, int top, int right, int bottom)
196 : left_(left), top_(top), right_(right), bottom_(bottom) {
198 virtual ~Padding() = default;
201 * @brief Copy-constructor.
203 * @param[in] c The object to copy
205 Padding(const Padding& c) {
215 * @param[in] c The object to copy
217 Padding& operator = (const Padding& c) {
228 * @brief Move-constructor.
230 * @param[in] c The object to move
232 Padding(Padding&& c) noexcept {
249 * @param[in] c The object to move
251 Padding& operator = (Padding&& c) noexcept {
269 * @brief Gets left value of padding.
271 * @return The left value of padding
273 int GetLeft() const {
278 * @brief Gets top value of padding.
280 * @return The top value of padding
287 * @brief Gets right value of padding.
289 * @return the right value of padding
291 int GetRight() const {
296 * @brief Gets bottom value of padding.
298 * @return The bottom value of padding.
300 int GetBottom() const {
312 * @brief The class for geometry data.
313 * @details There are x, y, width, height value.
316 class EXPORT_API Geometry {
324 Geometry(int x, int y, int w, int h) : x_(x), y_(y), w_(w), h_(h) {
326 virtual ~Geometry() = default;
329 * @brief Copy-constructor.
331 * @param[in] c The object to copy
333 Geometry(const Geometry& c) {
343 * @param[in] c The object to copy
345 Geometry& operator = (const Geometry& c) {
356 * @brief Move-constructor.
358 * @param[in] c The object to move
360 Geometry(Geometry&& c) noexcept {
377 * @param[in] c The object to move
379 Geometry& operator = (Geometry&& c) noexcept {
397 * @brief Gets x value of geometry.
399 * @return The x value of geometry.
406 * @brief Gets y value of geometry.
408 * @return The y value of geometry.
415 * @brief Gets width value of geometry.
417 * @return The width value of geometry.
419 int GetWidth() const {
424 * @brief Gets height value of geometry.
426 * @return The height value of geometry.
428 int GetHeight() const {
440 * @brief The class for style data
441 * @details The style data consists color, padding, geometry data.
444 class EXPORT_API Style {
449 Style(std::shared_ptr<Color> color, std::shared_ptr<Padding> padding,
450 std::shared_ptr<Geometry> geometry)
451 : color_(color), padding_(padding), geometry_(geometry) {
454 Style(std::shared_ptr<Color> color, std::shared_ptr<Padding> padding,
455 std::shared_ptr<Geometry> geometry,
456 std::shared_ptr<Color> background_color, std::string background_image)
457 : color_(color), padding_(padding), geometry_(geometry),
458 background_color_(background_color),
459 background_image_path_(background_image) {
462 virtual ~Style() = default;
465 * @brief Copy-constructor.
467 * @param[in] c The object to copy
469 Style(const Style& c) {
471 padding_ = c.padding_;
472 geometry_ = c.geometry_;
473 background_color_ = c.background_color_;
474 background_image_path_ = c.background_image_path_;
480 * @param[in] c The object to copy
482 Style& operator = (const Style& c) {
485 padding_ = c.padding_;
486 geometry_ = c.geometry_;
487 background_color_ = c.background_color_;
488 background_image_path_ = c.background_image_path_;
494 * @brief Move-constructor.
496 * @param[in] c The object to move
498 Style(Style&& c) noexcept {
502 padding_ = c.padding_;
503 c.padding_ = nullptr;
505 geometry_ = c.geometry_;
506 c.geometry_ = nullptr;
508 background_color_ = c.background_color_;
509 c.background_color_ = nullptr;
511 background_image_path_ = c.background_image_path_;
512 c.background_image_path_ = "";
518 * @param[in] c The object to move
520 Style& operator = (Style&& c) noexcept {
525 padding_ = c.padding_;
526 c.padding_ = nullptr;
528 geometry_ = c.geometry_;
529 c.geometry_ = nullptr;
531 background_color_ = c.background_color_;
532 c.background_color_ = nullptr;
534 background_image_path_ = c.background_image_path_;
535 c.background_image_path_ = "";
541 * @brief Gets padding data
543 * @return The padding data
545 std::shared_ptr<Padding> GetPadding() const {
550 * @brief Sets padding data
552 * @param[in] padding The padding data
554 void SetPadding(std::shared_ptr<Padding> padding) {
555 padding_ = std::move(padding);
559 * @brief Gets color data
561 * @return The color data
563 std::shared_ptr<Color> GetColor() const {
568 * @brief Sets color data
570 * @param[in] color The color data
572 void SetColor(std::shared_ptr<Color> color) {
573 color_ = std::move(color);
577 * @brief Gets geometry data
579 * @return The geometry data
581 std::shared_ptr<Geometry> GetGeometry() const {
586 * @brief Sets geometry data
588 * @param[in] geometry The geometry data
590 void SetGeometry(std::shared_ptr<Geometry> geometry) {
591 geometry_ = std::move(geometry);
595 * @brief Gets background image path
597 * @param[in] image_path The background image path
599 void SetBackgroundImage(std::string image_path) {
600 background_image_path_ = std::move(image_path);
604 * @brief Gets background image path
606 * @return The background image path
608 std::string GetBackgroundImage() const {
609 return background_image_path_;
613 * @brief Sets background color
616 void SetBackgroundColor(std::shared_ptr<Color> color) {
617 background_color_ = std::move(color);
621 * @brief Gets background color
623 * @return The background color
625 std::shared_ptr<Color> GetBackgroundColor() const {
626 return background_color_;
630 std::shared_ptr<Color> color_;
631 std::shared_ptr<Padding> padding_;
632 std::shared_ptr<Geometry> geometry_;
633 std::shared_ptr<Color> background_color_;
634 std::string background_image_path_;
638 * @brief The class for LED data.
639 * @details The LED data consists color data and period time.
642 class EXPORT_API LEDInfo {
646 explicit LEDInfo(std::shared_ptr<Color> color)
649 virtual ~LEDInfo() = default;
652 * @brief Sets the time period for turning on the LED
654 * @param[in] ms period time
656 void SetOnPeriod(int ms) {
661 * @brief Gets the time period for turning on the LED
663 * @return The time for turning on the LED
665 int GetOnPeriod() const {
670 * @brief Sets the time period for turning off the LED
672 * @param[in] ms period time
674 void SetOffPeriod(int ms) {
679 * @brief Gets the time period for turning off the LED
681 * @return The time for turning off the LED
683 int GetOffPeriod() const {
688 * @brief Gets the color of LED
692 std::shared_ptr<Color> GetColor() const {
697 std::shared_ptr<Color> color_;
703 * @brief The base class for the notification item classes.
704 * @details The AbstractItem is abstract class.
705 * The AbstractItem has basic APIs for notification items.
706 * The notification item class have to be a derived class of this class.
709 class EXPORT_API AbstractItem {
730 OnBootClear = 1 << 0,
746 * @param[in] action The AbstractAction for notification item
749 std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
754 * @param[in] id The notification id
755 * @param[in] action The AbstractAction for notification item
757 AbstractItem(std::string id,
758 std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
764 virtual ~AbstractItem() = 0;
767 * @brief Serialize the data of AbstractItem.
769 * @return Bundle type data
771 virtual tizen_base::Bundle Serialize() const = 0;
774 * @brief Deserialize the serialized data.
776 * @param[in] b The serialized Bundle data
778 virtual void Deserialize(tizen_base::Bundle b) = 0;
781 * @brief Finds the AbstractItem using by notification item id.
783 * @param[in] id notification item id
784 * @return AbstractItem object
786 virtual AbstractItem& FindByID(std::string id);
789 * @brief Finds the AbstractItem using by main type.
791 * @param[in] type The main type
792 * @return AbstractItem object
794 virtual AbstractItem& FindByMainType(MainType type);
797 * @brief Checks the item type exist in this notification.
799 * @param[in] type notification item type
800 * @return true if the item type exists
802 virtual bool IsItemTypeExist(int type) = 0;
805 * @brief Gets the type of notification item.
807 * @return The type of notification item
809 virtual int GetType() const = 0;
812 * @brief Gets the type of notification item from Bundle data.
814 * @return The type of notification item
816 static int GetType(tizen_base::Bundle b);
819 * @brief Gets the path of shared file location.
821 * @return The list of shared path.
823 virtual std::list<std::string> GetSharedPath() const;
826 * @brief Gets the notification item id.
828 * @return The notification item id.
830 std::string GetId() const;
833 * @brief Sets the notification item id.
835 * @param[in] id notification item id
837 void SetId(std::string id);
839 std::vector<std::shared_ptr<MultiLanguage>> GetMultiLanguageArr() const;
840 std::shared_ptr<MultiLanguage> GetMultiLanguage() const;
841 void SetMultiLanguage(std::shared_ptr<MultiLanguage> multi);
842 void SetMultiLanguage(std::vector<std::shared_ptr<MultiLanguage>> multi_arr);
845 * @brief Gets AbstractAction for notification item.
847 * @return AbstractAction instance
849 std::shared_ptr<AbstractAction> GetAction() const;
852 * @brief Sets AbstractAction for notification item.
854 * @param[in] action AbstractAction instance
856 void SetAction(std::shared_ptr<AbstractAction> action);
859 * @brief Sets the style data for notification item.
861 * @return Style instance
863 std::shared_ptr<Style> GetStyle() const;
866 * @brief Sets the style data for notification item.
868 * @param[in] style Style instance
870 void SetStyle(std::shared_ptr<Style> style);
873 * @brief Sets the visibile state of notification item.
875 * @param[in] visibile The visible state
877 void SetVisible(bool visible);
880 * @brief Gets the visibile state of notification item.
882 * @return true if visible, false if not visible.
884 bool GetVisible() const;
887 * @brief Sets the enable state of notification item.
889 * @param[in] enable The enable state
891 void SetEnable(bool enable);
894 * @brief Gets the enable state of notification item.
896 * @return true if enabled, false if not enabled.
898 bool GetEnable() const;
901 * @brief Adds the receiver group for notification item.
903 * @param[in] receiver_group The receiver group for notification item
905 void AddReceiver(std::string receiver_group);
908 * @brief Removes the receiver group from the receiver group list.
910 * @param[in] receiver_group The receiver group
912 void RemoveReceiver(std::string receiver_group);
915 * @brief Gets the receiver group list.
917 * @return The list of receiver group.
919 std::list<std::string> GetReceiverList();
922 * @brief Sets the policy for notification item.
924 * @param[in] policy The policy option
926 void SetPolicy(int policy);
929 * @brief Gets the policy for notification item.
931 * @return The policy for notification item.
933 int GetPolicy() const;
936 * @brief Gets the channel option for notification item.
938 * @return The channel option for notification item.
940 std::string GetChannel() const;
943 * @brief Sets the channel option for notification item.
945 * @param[in] channel The channel option for notification item.
947 void SetChannel(std::string channel);
950 * @brief Sets LED option for notification item.
952 * @param[in] led The LEDInfo instance
954 void SetLEDInfo(std::shared_ptr<LEDInfo> led);
957 * @brief Gets LED option for notification item.
959 * @return The LEDInfo instance
961 std::shared_ptr<LEDInfo> GetLEDInfo() const;
964 * @brief Sets the sound path for notification item.
966 * @param[in] path The sound path
968 void SetSoundPath(std::string path);
971 * @brief Sets the vibration path for notification item.
973 * @param[in] path The vibration path
975 void SetVibrationPath(std::string path);
978 * @brief Gets the sound path for notification item.
980 * @return The sound path
982 std::string GetSoundPath() const;
985 * @brief Gets the vibration path for notification item.
987 * @return The vibration path
989 std::string GetVibrationPath() const;
992 * @brief Gets IItemInfo instance to get some information of notification item.
994 * @return The IItemInfo instance
996 std::shared_ptr<IItemInfo> GetInfo() const;
999 * @brief Gets the sender app id of notification item.
1001 * @return The sender app id.
1003 std::string GetSenderAppId() const;
1006 * @brief Sets the sender app id of notification item.
1008 * @param[in] sender_appid The sender app id
1010 void SetSenderAppId(std::string sender_appid);
1013 * @brief Sets the tag of notification item.
1015 * @return The tag of notification item
1017 std::string GetTag() const;
1020 * @brief Sets the tag of notification item.
1022 * @param[in] tag The tag of notification item
1024 void SetTag(std::string tag);
1027 * @brief Sets the ongoing state of notification item.
1029 * @param[in] ongoing The ongoing state of notification item
1031 void SetOnGoingState(bool ongoing);
1034 * @brief Gets the ongoing state of notification item.
1036 * @return The ongoing state of notification item
1038 bool GetOnGoingState() const;
1041 * @brief Sets the main type of notification item.
1043 * @param[in] target_id The ID of notification item to set
1044 * @param[in] type The main type
1045 * @return true if target_id is valid to set
1047 bool SetMainType(std::string target_id, MainType type);
1050 * @brief Gets the main type of notification item.
1052 * @return The main type
1054 MainType GetMainType() const;
1058 std::unique_ptr<Impl> impl_;
1059 }; // class AbstractItem
1062 } // namespace notification
1064 #endif // NOTIFICATION_EX_ABSTRACT_ITEM_H_