1 /*
2  * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_CORE_NOTIFICATION_SUBSCRIBER_LISTENER_H
17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_CORE_NOTIFICATION_SUBSCRIBER_LISTENER_H
18 
19 #include "ans_manager_interface.h"
20 #include "ans_subscriber_stub.h"
21 #include "notification_request.h"
22 #include "notification_sorting.h"
23 #include "notification_sorting_map.h"
24 #include "notification_subscriber.h"
25 
26 namespace OHOS {
27 namespace Notification {
28 class SubscriberListener final : public AnsSubscriberStub {
29 public:
30     SubscriberListener(const std::shared_ptr<NotificationSubscriber> &subscriber);
31     ~SubscriberListener();
32 
33     void OnConnected() override;
34 
35     void OnDisconnected() override;
36 
37     void OnConsumed(
38         const sptr<Notification> &notification, const sptr<NotificationSortingMap> &notificationMap) override;
39 
40     void OnConsumedList(const std::vector<sptr<Notification>> &notifications,
41         const sptr<NotificationSortingMap> &notificationMap) override;
42 
43     void OnCanceled(const sptr<Notification> &notification, const sptr<NotificationSortingMap> &notificationMap,
44         int32_t deleteReason) override;
45 
46     void OnCanceledList(const std::vector<sptr<Notification>> &notifications,
47         const sptr<NotificationSortingMap> &notificationMap, int32_t deleteReason) override;
48 
49     void OnBatchCanceled(const std::vector<sptr<Notification>> &notifications,
50         const sptr<NotificationSortingMap> &notificationMap, int32_t deleteReason);
51 
52     void OnUpdated(const sptr<NotificationSortingMap> &notificationMap) override;
53 
54     void OnDoNotDisturbDateChange(const sptr<NotificationDoNotDisturbDate> &date) override;
55 
56     void OnEnabledNotificationChanged(const sptr<EnabledNotificationCallbackData> &callbackData) override;
57 
58     void OnBadgeChanged(const sptr<BadgeNumberCallbackData> &badgeData) override;
59 
60     void OnBadgeEnabledChanged(const sptr<EnabledNotificationCallbackData> &callbackData) override;
61 
62 public:
63     std::weak_ptr<NotificationSubscriber> subscriber_;
64 };
65 }  // namespace Notification
66 }  // namespace OHOS
67 
68 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_CORE_NOTIFICATION_SUBSCRIBER_LISTENER_H