• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 "ipc/cloud_sync_callback_proxy.h"
17 
18 #include <sstream>
19 
20 #include "dfs_error.h"
21 #include "utils_log.h"
22 
23 namespace OHOS::FileManagement::CloudSync {
24 using namespace std;
25 
OnSyncStateChanged(CloudSyncState state,ErrorType error)26 void CloudSyncCallbackProxy::OnSyncStateChanged(CloudSyncState state, ErrorType error)
27 {
28     LOGI("Start");
29     MessageParcel data;
30     MessageParcel reply;
31     MessageOption option;
32 
33     if (!data.WriteInterfaceToken(GetDescriptor())) {
34         LOGE("Failed to write interface token");
35         return;
36     }
37 
38     if (!data.WriteInt32(static_cast<int32_t>(state))) {
39         LOGE("Failed to send the type");
40         return;
41     }
42 
43     if (!data.WriteInt32(static_cast<int32_t>(error))) {
44         LOGE("Failed to send the state");
45         return;
46     }
47 
48     auto remote = Remote();
49     if (!remote) {
50         LOGE("remote is nullptr");
51         return;
52     }
53     int32_t ret = remote->SendRequest(ICloudSyncCallback::SERVICE_CMD_ON_SYNC_STATE_CHANGED, data, reply, option);
54     if (ret != E_OK) {
55         stringstream ss;
56         ss << "Failed to send out the requeset, errno:" << ret;
57         LOGE("%{public}s", ss.str().c_str());
58         return;
59     }
60     LOGI("End");
61     return;
62 }
63 
64 } // namespace OHOS::FileManagement::CloudSync