• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 DISC_MANAGER_H
17 #define DISC_MANAGER_H
18 
19 #include "disc_interface.h"
20 #include "disc_manager_struct.h"
21 
22 #ifdef __cplusplus
23 #if __cplusplus
24 extern "C" {
25 #endif
26 #endif
27 
28 /**
29  * @brief Publish service to start publishing its own information to other devices.
30  * @see {@link DiscUnPublishService}
31  * @param[in] packageName Indicates the pointer to the package name,
32  * and the name of the relevant package carrying its own capabilities.
33  * @param[in] info ndicates the pointer to the published information,
34  * which is used to publish the information body of its own information. For details, see {@link PublishInfo}.
35  * @return <b>SOFTBUS_INVALID_PARAM</b> if any parameter is null or invalid.
36  * @return <b>SOFTBUS_DISCOVER_MANAGER_INVALID_MEDIUM</b> Error in message medium during message check.
37  * @return <b>SOFTBUS_DISCOVER_MANAGER_NOT_INIT</b> Softbus found that management variables are not initialized.
38  * @return <b>SOFTBUS_DISCOVER_MANAGER_INFO_NOT_CREATE</b> The new publishing node corresponding to the discovery
39  * information has not been created
40  * @return <b>SOFTBUS_LOCK_ERR</b> Failed to lock.
41  * @return <b>SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM</b> The information to be published is already in the list.
42  * @return <b>SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE</b> The new project node corresponding to the discovery
43  * information was not created.
44  * @return <b>SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL</b> Internal function error.
45  * @return <b>SOFTBUS_OK</b> Published self information successfully.
46  */
47 int32_t DiscPublishService(const char *packageName, const PublishInfo *info, int32_t callingPid);
48 
49 /**
50  * @brief If the service is cancelled, the remote device cannot obtain its own information.
51  * @see {@link DiscPublishService}
52  * @param[in] packageName Indicates the pointer to the package name,
53  * and the name of the relevant package carrying its own capabilities.
54  * @param[in] publishId ID of the internal release information to be cancelled this time.
55  * @return <b>SOFTBUS_INVALID_PARAM</b> if any parameter is null or invalid.
56  * @return <b>SOFTBUS_DISCOVER_MANAGER_NOT_INIT</b> Softbus found that management variables are not initialized.
57  * @return <b>SOFTBUS_DISCOVER_MANAGER_INFO_NOT_DELETE</b> Delete the inode corresponding to the publication id
58  * from the list.
59  * @return <b>SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL</b> Internal function error.
60  * @return <b>SOFTBUS_OK</b> Unpublished service succeeded.
61  */
62 int32_t DiscUnPublishService(const char *packageName, int32_t publishId, int32_t callingPid);
63 
64 /**
65  * @brief Start discovery, other devices can be discovered.
66  * @see {@link DiscStopDiscovery}
67  * @param[in] packageName Indicates the pointer to the package name,
68  * and the name of the relevant package carrying its own capabilities.
69  * @param[in] info Indicates a pointer to published information used
70  * to discover the body of information for a specific capability. For more information, see {@link SubscribeInfo}.
71  * @param[in] cb Indicates the pointer to the discovery callback, It is used to inform yourself,
72  * Whether the discovery capability is successfully started after the discovery function is triggered.
73  * For more information, see {@link IServerDiscInnerCallback}.
74  * @return <b>SOFTBUS_INVALID_PARAM</b> if any parameter is null or invalid.
75  * @return <b>SOFTBUS_DISCOVER_MANAGER_INVALID_MEDIUM</b> Error in message medium during message check.
76  * @return <b>SOFTBUS_DISCOVER_MANAGER_NOT_INIT</b> Softbus found that management variables are not initialized.
77  * @return <b>SOFTBUS_DISCOVER_MANAGER_INFO_NOT_CREATE</b> The new publishing node corresponding to the discovery
78  * information has not been created.
79  * @return <b>SOFTBUS_LOCK_ERR</b> Failed to lock.
80  * @return <b>SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM</b> The information to be published is already in the list.
81  * @return <b>SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE</b> The new project node corresponding to the discovery
82  * information was not created.
83  * @return <b>SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL</b> Internal function error.
84  * @return <b>SOFTBUS_OK</b> Passive discovery function successfully started.
85  */
86 int32_t DiscStartDiscovery(const char *packageName, const SubscribeInfo *info, const IServerDiscInnerCallback *cb,
87     int32_t callingPid);
88 
89 /**
90  * @brief Stop discovering, stop discovering other devices.
91  * @see {@link DiscStartDiscovery}
92  * @param[in] packageName Indicates the pointer to the package name,
93  * and the name of the relevant package carrying its own capabilities.
94  * @param[in] subscribeId ID to stop discovery this time.
95  * @return <b>SOFTBUS_INVALID_PARAM</b> if any parameter is null or invalid.
96  * @return <b>SOFTBUS_DISCOVER_MANAGER_NOT_INIT</b> Softbus found that management variables are not initialized.
97  * @return <b>SOFTBUS_DISCOVER_MANAGER_INFO_NOT_DELETE</b> Delete the inode corresponding to the publication id
98  * from the list.
99  * @return <b>SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL</b> Internal function error.
100  * @return <b>SOFTBUS_OK</b> Passive stop discovery function stopped successfully
101  */
102 int32_t DiscStopDiscovery(const char *packageName, int32_t subscribeId, int32_t callingPid);
103 
104 int32_t DiscSetDisplayName(const char *pkgName, const char *nameData, uint32_t len);
105 
106 int32_t DiscGetDisplayName(char *displayName, uint32_t length, uint32_t remainLen);
107 
108 #ifdef __cplusplus
109 #if __cplusplus
110 }
111 #endif /* __cplusplus */
112 #endif /* __cplusplus */
113 
114 #endif /* DISC_MANAGER_H */