• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 DISTRIBUTED_INCLUDE_SOFTBUS_DISTRIBUTED_PUBLISH_SERVICE_H
17 #define DISTRIBUTED_INCLUDE_SOFTBUS_DISTRIBUTED_PUBLISH_SERVICE_H
18 
19 #include "tlv_box.h"
20 #include "notification.h"
21 #include "request_box.h"
22 #include "notification_request.h"
23 #include "distributed_device_data.h"
24 #ifdef DISTRIBUTED_FEATURE_MASTER
25 #include "remove_box.h"
26 #include "batch_remove_box.h"
27 #else
28 #endif
29 
30 
31 namespace OHOS {
32 namespace Notification {
33 class DistributedPublishService {
34 public:
35     static DistributedPublishService& GetInstance();
36     void RemoveNotification(const std::shared_ptr<TlvBox>& boxMessage);
37     void RemoveNotifications(const std::shared_ptr<TlvBox>& boxMessage);
38     void BatchRemoveReport(const std::string &slotTypesString, const std::string &deviceId, const int result);
39     int RemoveDistributedNotifications(const std::vector<std::string>& hashcodes);
40     void OnRemoveNotification(const DistributedDeviceInfo& peerDevice,
41         std::string hashCode, int32_t slotTypes);
42     void OnRemoveNotifications(const DistributedDeviceInfo& peerDevice,
43         std::string hashCodes, std::string slotTypes);
44 
45 #ifdef DISTRIBUTED_FEATURE_MASTER
46     void RemoveAllDistributedNotifications(DistributedDeviceInfo& deviceInfo);
47     void SyncLiveViewNotification(const DistributedDeviceInfo peerDevice, bool isForce);
48     void SyncLiveViewList(const DistributedDeviceInfo device, const std::vector<sptr<Notification>>& notifications);
49     void SyncLiveViewContent(const DistributedDeviceInfo device, const std::vector<sptr<Notification>>& notifications);
50     void SendNotifictionRequest(const std::shared_ptr<Notification> request,
51         const DistributedDeviceInfo& peerDevice, bool isSyncNotification = false);
52     bool SetNotificationExtendInfo(const sptr<NotificationRequest> notificationRequest,
53             int32_t deviceType, bool isSyncNotification, std::shared_ptr<NotificationRequestBox>& requestBox);
54 private:
55     void SyncNotifictionList(const DistributedDeviceInfo& peerDevice,
56         const std::vector<std::string>& notificationList);
57     void SetNotificationButtons(const sptr<NotificationRequest> notificationRequest, int32_t deviceType,
58         NotificationConstant::SlotType slotType, std::shared_ptr<NotificationRequestBox>& requestBox);
59     void SetNotificationContent(const std::shared_ptr<NotificationContent> &content,
60         NotificationContent::Type type, std::shared_ptr<NotificationRequestBox>& requestBox);
61     bool ForWardRemove(const std::shared_ptr<BoxBase>& boxMessage, std::string& deviceId);
62     std::shared_ptr<NotificationRemoveBox> MakeRemvoeBox(std::string &hashCode, int32_t &slotTypes);
63     std::shared_ptr<BatchRemoveNotificationBox> MakeBatchRemvoeBox(std::vector<std::string>& hashCodes,
64         std::string &slotTypes);
65     bool FillSyncRequestExtendInfo(const sptr<NotificationRequest> notificationRequest, int32_t deviceTypeId,
66         std::shared_ptr<NotificationRequestBox>& requestBox, AAFwk::WantParams& wantParam);
67     bool FillNotSyncRequestExtendInfo(const sptr<NotificationRequest> notificationRequest, int32_t deviceType,
68         std::shared_ptr<NotificationRequestBox>& requestBox, AAFwk::WantParams& wantParam);
69 #else
70     void PublishNotification(const std::shared_ptr<TlvBox>& boxMessage);
71     void PublishSynchronousLiveView(const std::shared_ptr<TlvBox>& boxMessage);
72     void RemoveAllDistributedNotifications(const std::shared_ptr<TlvBox>& boxMessage);
73 private:
74     void MakeExtendInfo(const NotificationRequestBox& box, sptr<NotificationRequest>& request);
75     void MakeNotificationButtons(const NotificationRequestBox& box,
76         NotificationConstant::SlotType slotType, sptr<NotificationRequest>& request);
77     void MakePadNotificationButtons(const NotificationRequestBox& box, sptr<NotificationRequest>& request);
78     void MakeNotificationContent(const NotificationRequestBox& box, sptr<NotificationRequest>& request,
79         bool isCommonLiveView, int32_t contentType);
80     void MakeNotificationIcon(const NotificationRequestBox& box, sptr<NotificationRequest>& request);
81     void MakeNotificationReminderFlag(const NotificationRequestBox& box,
82         sptr<NotificationRequest>& request);
83     void MakeNotificationBasicContent(const NotificationRequestBox& box, sptr<NotificationRequest>& request,
84         int32_t contentType);
85 #endif
86 };
87 }
88 }
89 #endif
90