• 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_ANS_STANDARD_FRAMEWORKS_ANS_CORE_COMMON_INCLUDE_DISTRIBUTED_DATA_DEFINE_H
17 #define BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_COMMON_INCLUDE_DISTRIBUTED_DATA_DEFINE_H
18 
19 #include <string>
20 #include <set>
21 #include <mutex>
22 #include <unordered_set>
23 #include "notification_operation_info.h"
24 
25 namespace OHOS {
26 namespace Notification {
27 
28 namespace {
29 constexpr const int32_t MIN_DATA_LENGTH = 4;
30 constexpr char const AnonymousString[] = "******";
31 constexpr int32_t DEFAULT_REPLY_TIMEOUT = 3;
32 }
33 
34 enum BundleListOperationType {
35     ADD_BUNDLES = 0,      // add bundles
36     REMOVE_BUNDLES,   // remove bundle
37     RELEASE_BUNDLES   // release bundles
38 };
39 
40 enum DeviceStatueChangeType {
41     DEVICE_USING_ONLINE = 0,
42     NOTIFICATION_ENABLE_CHANGE = 1,
43     ALL_CONNECT_STATUS_CHANGE = 2,
44     DEVICE_USING_CLOSE = 3,
45 };
46 
47 enum HaOperationType {
48     COLLABORATE_DELETE = 0,
49     COLLABORATE_REPLY = 1,
50     COLLABORATE_JUMP = 2,
51 };
52 
53 struct DistributedHaCallbacks {
54     std::function<void(int32_t, int32_t, std::string)> hiSysEventCallback;
55     std::function<void(int32_t, int32_t, uint32_t, std::string)> haMaintenanceCallback;
56     std::function<void(const std::string&, int32_t, int32_t, std::string)> haOperationCallback;
57 };
58 
59 struct DeviceStatueChangeInfo {
60     int32_t changeType;
61     std::string deviceId;
62     bool enableChange;
63     bool liveViewChange;
64 };
65 
66 struct DistributedDeviceConfig {
67     int32_t maxTitleLength;
68     int32_t maxContentLength;
69     uint32_t startAbilityTimeout;
70     int32_t operationReplyTimeout = DEFAULT_REPLY_TIMEOUT;
71     std::string localType;
72     std::set<std::string> supportPeerDevice;
73     std::unordered_set<std::string> collaborativeDeleteTypes;
74     std::map<std::string, std::map<std::string, std::unordered_set<std::string>>> collaborativeDeleteTypesByDevice;
75 };
76 
StringAnonymous(const std::string & data)77 static std::string StringAnonymous(const std::string& data)
78 {
79     std::string result;
80     if (data.length() <= MIN_DATA_LENGTH) {
81         result = data + AnonymousString + data;
82     } else {
83         result = data.substr(0, MIN_DATA_LENGTH) + AnonymousString +
84             data.substr(data.length() - MIN_DATA_LENGTH, MIN_DATA_LENGTH);
85     }
86     return result;
87 }
88 
89 }  // namespace Notification
90 }  // namespace OHOS
91 
92 #endif  // BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_COMMON_INCLUDE_DISTRIBUTED_DATA_DEFINE_H
93