• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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_SUBSCRIBER_H
17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SUBSCRIBER_H
18 
19 #include "notification_subscriber.h"
20 
21 #include "device_manager.h"
22 #include "distributed_device_data.h"
23 #include "notification_operation_info.h"
24 
25 namespace OHOS {
26 namespace Notification {
27 class DistribuedSubscriber : public NotificationSubscriber {
28 public:
29     ~DistribuedSubscriber() override;
30     void OnDied() override;
31     void OnConnected() override;
32     void OnDisconnected() override;
33     void OnCanceled(const std::shared_ptr<Notification> &request,
34         const std::shared_ptr<NotificationSortingMap> &sortingMap, int32_t deleteReason) override;
35     void OnConsumed(const std::shared_ptr<Notification> &request,
36         const std::shared_ptr<NotificationSortingMap> &sortingMap) override;
37     void OnUpdate(const std::shared_ptr<NotificationSortingMap> &sortingMap) override;
38     void OnDoNotDisturbDateChange(const std::shared_ptr<NotificationDoNotDisturbDate> &date) override;
39     void OnEnabledNotificationChanged(const std::shared_ptr<EnabledNotificationCallbackData> &callbackData) override;
40     void OnBadgeChanged(const std::shared_ptr<BadgeNumberCallbackData> &badgeData) override;
41     void OnBadgeEnabledChanged(const sptr<EnabledNotificationCallbackData> &callbackData) override;
42     void OnBatchCanceled(const std::vector<std::shared_ptr<Notification>> &requestList,
43         const std::shared_ptr<NotificationSortingMap> &sortingMap, int32_t deleteReason) override;
44     void OnApplicationInfoNeedChanged(const std::string& bundleName) override;
45     ErrCode OnOperationResponse(const std::shared_ptr<NotificationOperationInfo> &operationInfo) override;
46     void SetLocalDevice(DistributedDeviceInfo localDevice);
47     void SetPeerDevice(DistributedDeviceInfo localDevice);
48     bool CheckNeedCollaboration(const std::shared_ptr<Notification> &notification);
49     bool CheckCollaborativeRemoveType(const NotificationConstant::SlotType& slotType);
50     bool CheckTypeByCcmRule(const std::string& slotType,
51         const std::string& localDeviceType, const std::string& peerDeviceType);
52     std::string SlotEnumToSring(const NotificationConstant::SlotType& slotType);
HasOnBatchCancelCallback()53     bool HasOnBatchCancelCallback() override
54     {
55         return true;
56     }
57 
58 private:
59     DistributedDeviceInfo localDevice_;
60     DistributedDeviceInfo peerDevice_;
61 };
62 }
63 }
64 
65 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SUBSCRIBER_H
66