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 #include "file_dfs_listener_proxy.h"
17 #include "dfs_error.h"
18 #include "iservice_registry.h"
19 #include "ipc_types.h"
20 #include "system_ability_definition.h"
21 #include "utils_log.h"
22 #include "file_dfs_listener_interface_code.h"
23 
24 namespace OHOS {
25 namespace Storage {
26 namespace DistributedFile {
27 using namespace std;
28 using namespace OHOS::Storage;
29 using namespace OHOS::FileManagement;
30 
OnStatus(const std::string & networkId,int32_t status)31 void FileDfsListenerProxy::OnStatus(const std::string &networkId, int32_t status)
32 {
33     MessageParcel data;
34     MessageParcel reply;
35     MessageOption option;
36     if (!data.WriteInterfaceToken(GetDescriptor())) {
37         LOGE("Failed to write interface token");
38         return;
39     }
40     if (!data.WriteString(networkId)) {
41         LOGE("Failed to send networkId");
42         return;
43     }
44     if (!data.WriteInt32(status)) {
45         LOGE("Failed to send status");
46         return;
47     }
48     auto remote = Remote();
49     if (remote == nullptr) {
50         LOGE("remote is nullptr");
51         return;
52     }
53     int32_t ret = remote->SendRequest(
54         static_cast<uint32_t>(FileDfsListenerInterfaceCode::FILE_DFS_LISTENER_ON_STATUS), data, reply, option);
55     if (ret != E_OK) {
56         LOGE("Failed to send out the request, errno:%{public}d", errno);
57         return;
58     }
59     return;
60 }
61 
62 } // namespace DistributedFile
63 } // namespace Storage
64 } // namespace OHOS