• 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 LNN_DATA_CLOUD_SYNC_H
17 #define LNN_DATA_CLOUD_SYNC_H
18 
19 #include "lnn_node_info.h"
20 #include "softbus_adapter_crypto.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #define CLOUD_SYNC_INFO_SIZE 33
27 
28 typedef struct {
29     char networkId[NETWORK_ID_BUF_LEN];
30     char deviceName[DEVICE_NAME_BUF_LEN];
31     char unifiedName[DEVICE_NAME_BUF_LEN];
32     char unifiedDefaultName[DEVICE_NAME_BUF_LEN];
33     char nickName[DEVICE_NAME_BUF_LEN];
34     char deviceUdid[UDID_BUF_LEN];
35     char uuid[UUID_BUF_LEN];
36     char softBusVersion[VERSION_MAX_LEN];
37     char pkgVersion[VERSION_MAX_LEN];
38     char macAddr[MAC_LEN];
39     unsigned char cipherKey[SESSION_KEY_LENGTH];
40     unsigned char cipherIv[BROADCAST_IV_LEN];
41     unsigned char publicAddress[LFINDER_MAC_ADDR_LEN];
42     char remotePtk[PTK_DEFAULT_LEN];
43     char osVersion[OS_VERSION_BUF_LEN];
44     bool isBleP2p;
45     bool distributedSwitch;
46     uint16_t deviceTypeId;
47     uint32_t authCapacity;
48     uint32_t heartbeatCapacity;
49     int32_t osType;
50     int32_t stateVersion;
51     char *broadcastCipherKey;
52     uint64_t supportedProtocols;
53     int64_t wifiVersion;
54     int64_t bleVersion;
55     int64_t accountId;
56     uint64_t feature;
57     uint64_t connSubFeature;
58     uint64_t timestamp;
59 } CloudSyncInfo;
60 
61 typedef enum {
62     DB_ADD = 0,
63     DB_UPDATE = 1,
64     DB_DELETE = 2,
65     DB_CHANGE_TYPE_MAX,
66 } ChangeType;
67 
68 void LnnInitCloudSyncModule(void);
69 void LnnDeInitCloudSyncModule(void);
70 int32_t LnnLedgerAllDataSyncToDB(NodeInfo *info, bool isAckSeq, char *peerudid);
71 int32_t LnnAsyncCallLedgerAllDataSyncToDB(NodeInfo *info);
72 int32_t LnnLedgerDataChangeSyncToDB(const char *key, const char *value, size_t valueLength);
73 int32_t LnnDeleteSyncToDB(void);
74 int32_t LnnDeleteDevInfoSyncToDB(const char *udid, int64_t accountId);
75 int32_t LnnDBDataChangeSyncToCache(const char *key, const char *value, ChangeType changeType);
76 int32_t LnnDBDataAddChangeSyncToCache(const char **key, const char **value, int32_t keySize);
77 int32_t LnnDBDataChangeSyncToCacheInner(const char *key, const char *value);
78 int32_t LnnSetCloudAbility(const bool isEnableCloud);
79 #ifdef __cplusplus
80 }
81 #endif
82 
83 #endif // LNN_DATA_CLOUD_SYNC_H
84