• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-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 GROUP_OPERATION_H
17 #define GROUP_OPERATION_H
18 
19 #include "device_auth.h"
20 #include "base_group_manager_task.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 typedef struct {
27     const char* deviceId;
28     bool isUdid;
29 } DeviceQueryParams;
30 
31 typedef struct {
32     int32_t (*createGroup)(int32_t osAccountId, int64_t requestId, const char *appId, const char *createParams);
33     int32_t (*deleteGroup)(int32_t osAccountId, int64_t requestId, const char *appId, const char *disbandParams);
34     int32_t (*addMemberToGroup)(int32_t osAccountId, int64_t requestId, const char *appId, const char *addParams);
35     int32_t (*processBindData)(int64_t requestId, const uint8_t *data, uint32_t dataLen);
36     int32_t (*deleteMember)(int32_t osAccountId, int64_t requestId, const char *appId, const char *deleteParams);
37     int32_t (*addMultiMembers)(int32_t osAccountId, const char *appId, const char *addParams);
38     int32_t (*delMultiMembers)(int32_t osAccountId, const char *appId, const char *deleteParams);
39     int32_t (*regCallback)(const char *appId, const DeviceAuthCallback *callback);
40     int32_t (*unRegCallback)(const char *appId);
41     int32_t (*regListener)(const char *appId, const DataChangeListener *listener);
42     int32_t (*unRegListener)(const char *appId);
43     int32_t (*getRegisterInfo)(const char *reqJsonStr, char **returnRegisterInfo);
44     int32_t (*checkAccessToGroup)(int32_t osAccountId, const char *appId, const char *groupId);
45     int32_t (*getAccessibleGroupInfoById)(int32_t osAccountId, const char *appId, const char *groupId,
46         char **returnGroupInfo);
47     int32_t (*getAccessibleGroupInfo)(int32_t osAccountId, const char *appId, const char *queryParams,
48         char **returnGroupVec, uint32_t *groupNum);
49     int32_t (*getAccessibleJoinedGroups)(int32_t osAccountId, const char *appId, int groupType,
50         char **returnGroupVec, uint32_t *groupNum);
51     int32_t (*getAccessibleRelatedGroups)(int32_t osAccountId, const char *appId, const char *peerDeviceId,
52         char **returnGroupVec, uint32_t *groupNum);
53     int32_t (*getAccessibleDeviceInfoById)(int32_t osAccountId, const char *appId,
54         const DeviceQueryParams *devQueryParams, const char *groupId, char **returnDeviceInfo);
55     int32_t (*getAccessibleTrustedDevices)(int32_t osAccountId, const char *appId, const char *groupId,
56         char **returnDevInfoVec, uint32_t *deviceNum);
57     bool (*isDeviceInAccessibleGroup)(int32_t osAccountId, const char *appId, const char *groupId,
58         const char *deviceId, bool isUdid);
59     int32_t (*getPkInfoList)(int32_t osAccountId, const char *appId, const char *queryParams, char **returnInfoList,
60         uint32_t *returnInfoNum);
61     void (*destroyInfo)(char **returnInfo);
62 } GroupImpl;
63 
64 int32_t InitGroupRelatedModule(void);
65 void DestroyGroupRelatedModule(void);
66 const GroupImpl *GetGroupImplInstance(void);
67 bool IsGroupSupport(void);
68 
69 typedef void (*TaskFunc)(HcTaskBase *task);
70 
71 void DestroyGroupManagerTask(HcTaskBase *task);
72 
73 int32_t BindCallbackToTask(GroupManagerTask *task, const CJson *jsonParams);
74 int32_t AddReqInfoToJson(int64_t requestId, const char *appId, CJson *jsonParams);
75 int32_t AddBindParamsToJson(int operationCode, int64_t requestId, const char *appId, CJson *jsonParams);
76 int32_t InitAndPushGMTask(int32_t osAccountId, int32_t opCode, int64_t reqId, CJson *params, TaskFunc func);
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 #endif
82