Release version 0.5.85
[platform/core/api/notification.git] / notification-ex / manager.h
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef NOTIFICATION_EX_MANAGER_H_
18 #define NOTIFICATION_EX_MANAGER_H_
19
20 #include <string>
21 #include <list>
22 #include <memory>
23
24 #include "notification-ex/common.h"
25 #include "notification-ex/abstract_item.h"
26 #include "notification-ex/event_observer_interface.h"
27 #include "notification-ex/event_sender_interface.h"
28 #include "notification-ex/event_listener_interface.h"
29
30 #ifndef EXPORT_API
31 #define EXPORT_API __attribute__((visibility("default")))
32 #endif
33
34 namespace notification {
35
36 class EXPORT_API Manager : public IEventObserver {
37  public:
38   Manager(std::unique_ptr<IEventSender> sender,
39       std::unique_ptr<IEventListener> listener, std::string receiver_group = "");
40   virtual ~Manager();
41
42   std::list<std::unique_ptr<item::AbstractItem>> Get(std::string channel = "");
43   int Update(std::shared_ptr<item::AbstractItem> noti, int& request_id);
44   int Delete(std::shared_ptr<item::AbstractItem> noti, int& request_id);
45   int DeleteAll(int& request_id);
46   int DeleteByChannel(std::string channel, int& request_id);
47   int DeleteByAppId(std::string appId, int& request_id);
48   int Hide(std::shared_ptr<item::AbstractItem> noti, int& request_id);
49   std::unique_ptr<item::AbstractItem> FindByRootID(std::string id);
50   int SendEvent(const IEventInfo& info, std::shared_ptr<item::AbstractItem> noti);
51   int SendEvent(const IEventInfo& info, std::list<std::shared_ptr<item::AbstractItem>> notiList);
52   void OnEvent(const IEventInfo& info,
53       std::list<tizen_base::Bundle> serialized) override;
54   std::list<tizen_base::Bundle> OnRequest(const IEventInfo& info) override;
55   int OnRequestNumber(const IEventInfo& info) override;
56   void SendError(const IEventInfo& info, NotificationError error);
57   int GetCount() const;
58   static std::string GetPath();
59
60  protected:
61   virtual void OnAdd(const IEventInfo& info, std::list<std::shared_ptr<item::AbstractItem>> addedList);
62   virtual void OnUpdate(const IEventInfo& info, std::list<std::shared_ptr<item::AbstractItem>> updatedList);
63   virtual void OnDelete(const IEventInfo& info, std::list<std::shared_ptr<item::AbstractItem>> deletedList);
64   virtual void OnError(NotificationError error, int requestId);
65   virtual std::list<std::shared_ptr<item::AbstractItem>> OnRequestEvent(
66       const IEventInfo& info);
67   virtual int OnRequestNumberEvent(const IEventInfo& info);
68
69  private:
70   class Impl;
71   std::unique_ptr<Impl> impl_;
72 };
73
74 }  // namespace notification
75
76 #endif  // NOTIFICATION_EX_MANAGER_H_