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 #include "disc_client_stub.h"
17
18 #include "client_disc_manager.h"
19 #include "ipc_skeleton.h"
20 #include "softbus_errcode.h"
21 #include "softbus_log.h"
22
ClientOnDiscoverySuccess(IpcIo * data,IpcIo * reply)23 int32_t ClientOnDiscoverySuccess(IpcIo *data, IpcIo *reply)
24 {
25 if (data == NULL) {
26 SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "%s:invalid param.", __func__);
27 return SOFTBUS_INVALID_PARAM;
28 }
29
30 int32_t subscribeId = 0;
31 ReadInt32(data, &subscribeId);
32 DiscClientOnDiscoverySuccess(subscribeId);
33 return SOFTBUS_OK;
34 }
35
ClientOnDiscoverFailed(IpcIo * data,IpcIo * reply)36 int32_t ClientOnDiscoverFailed(IpcIo *data, IpcIo *reply)
37 {
38 if (data == NULL) {
39 SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "%s:invalid param.", __func__);
40 return SOFTBUS_INVALID_PARAM;
41 }
42
43 int32_t subscribeId = 0;
44 int32_t failReason = 0;
45 ReadInt32(data, &subscribeId);
46 ReadInt32(data, &failReason);
47 DiscClientOnDiscoverFailed(subscribeId, failReason);
48 return SOFTBUS_OK;
49 }
50
ClientOnDeviceFound(IpcIo * data,IpcIo * reply)51 int32_t ClientOnDeviceFound(IpcIo *data, IpcIo *reply)
52 {
53 if (data == NULL) {
54 SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "%s:invalid param.", __func__);
55 return SOFTBUS_INVALID_PARAM;
56 }
57
58 const DeviceInfo *deviceInfo = (const DeviceInfo*)ReadRawData(reply, sizeof(DeviceInfo));
59 if (deviceInfo == NULL) {
60 return SOFTBUS_ERR;
61 }
62 DiscClientOnDeviceFound(deviceInfo);
63 return SOFTBUS_OK;
64 }
65
ClientOnPublishSuccess(IpcIo * data,IpcIo * reply)66 int32_t ClientOnPublishSuccess(IpcIo *data, IpcIo *reply)
67 {
68 if (data == NULL) {
69 SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "%s:invalid param.", __func__);
70 return SOFTBUS_INVALID_PARAM;
71 }
72
73 int32_t publishId = 0;
74 ReadInt32(data, &publishId);
75 DiscClientOnPublishSuccess(publishId);
76 return SOFTBUS_OK;
77 }
78
ClientOnPublishFail(IpcIo * data,IpcIo * reply)79 int32_t ClientOnPublishFail(IpcIo *data, IpcIo *reply)
80 {
81 if (data == NULL) {
82 SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "%s:invalid param.", __func__);
83 return SOFTBUS_INVALID_PARAM;
84 }
85
86 int32_t publishId = 0;
87 int32_t failReason = 0;
88 ReadInt32(data, &publishId);
89 ReadInt32(data, &failReason);
90 DiscClientOnPublishFail(publishId, failReason);
91 return SOFTBUS_OK;
92 }
93