• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_SUBSCRIBER_STUB_H
17 #define BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_SUBSCRIBER_STUB_H
18 
19 #include "ans_subscriber_interface.h"
20 #include "iremote_stub.h"
21 
22 namespace OHOS {
23 namespace Notification {
24 class AnsSubscriberStub : public IRemoteStub<AnsSubscriberInterface> {
25 public:
26     AnsSubscriberStub();
27     ~AnsSubscriberStub() override;
28     DISALLOW_COPY_AND_MOVE(AnsSubscriberStub);
29 
30     /**
31      * @brief Handle remote request.
32      *
33      * @param data Indicates the input parcel.
34      * @param reply Indicates the output parcel.
35      * @param option Indicates the message option.
36      * @return Returns ERR_OK on success, others on failure.
37      */
38     virtual int32_t OnRemoteRequest(
39         uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
40 
41     /**
42      * @brief The callback function for the subscriber to establish a connection.
43      */
44     void OnConnected() override;
45 
46     /**
47      * @brief The callback function for subscriber disconnected.
48      */
49     void OnDisconnected() override;
50 
51     /**
52      * @brief The callback function on a notification published.
53      *
54      * @param notification Indicates the consumed notification.
55      */
56     void OnConsumed(const sptr<Notification> &notification) override;
57 
58     /**
59      * @brief The callback function on a notification published.
60      *
61      * @param notification Indicates the consumed notification.
62      * @param notificationMap Indicates the NotificationSortingMap object.
63      */
64     void OnConsumed(
65         const sptr<Notification> &notification, const sptr<NotificationSortingMap> &notificationMap) override;
66 
67     /**
68      * @brief The callback function on a notification canceled.
69      *
70      * @param notification Indicates the canceled notification.
71      * @param notificationMap Indicates the NotificationSortingMap object.
72      * @param deleteReason Indicates the delete reason.
73      */
74     void OnCanceled(const sptr<Notification> &notification, const sptr<NotificationSortingMap> &notificationMap,
75         int32_t deleteReason) override;
76 
77     /**
78      * @brief The callback function on the notifications updated.
79      *
80      * @param notificationMap Indicates the NotificationSortingMap object.
81      */
82     void OnUpdated(const sptr<NotificationSortingMap> &notificationMap) override;
83 
84     /**
85      * @brief The callback function on the do not disturb date changed.
86      *
87      * @param date Indicates the NotificationDoNotDisturbDate object.
88      */
89     void OnDoNotDisturbDateChange(const sptr<NotificationDoNotDisturbDate> &date) override;
90 
91     /**
92      * @brief The callback function on the notification enabled flag changed.
93      *
94      * @param callbackData Indicates the EnabledNotificationCallbackData object.
95      */
96     void OnEnabledNotificationChanged(const sptr<EnabledNotificationCallbackData> &callbackData) override;
97 
98 private:
99     std::map<uint32_t, std::function<ErrCode(MessageParcel &, MessageParcel &)>> interfaces_;
100 
101     ErrCode HandleOnConnected(MessageParcel &data, MessageParcel &reply);
102     ErrCode HandleOnDisconnected(MessageParcel &data, MessageParcel &reply);
103     ErrCode HandleOnConsumed(MessageParcel &data, MessageParcel &reply);
104     ErrCode HandleOnConsumedMap(MessageParcel &data, MessageParcel &reply);
105     ErrCode HandleOnCanceledMap(MessageParcel &data, MessageParcel &reply);
106     ErrCode HandleOnUpdated(MessageParcel &data, MessageParcel &reply);
107     ErrCode HandleOnDoNotDisturbDateChange(MessageParcel &data, MessageParcel &reply);
108     ErrCode HandleOnEnabledNotificationChanged(MessageParcel &data, MessageParcel &reply);
109 };
110 }  // namespace Notification
111 }  // namespace OHOS
112 
113 #endif  // BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_SUBSCRIBER_STUB_H
114