• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 "cloud_sync_callback_stub.h"
17 #include "dfs_error.h"
18 #include "utils_log.h"
19 
20 namespace OHOS::FileManagement::CloudSync {
21 using namespace std;
22 
CloudSyncCallbackStub()23 CloudSyncCallbackStub::CloudSyncCallbackStub()
24 {
25     opToInterfaceMap_[SERVICE_CMD_ON_SYNC_STATE_CHANGED] = &CloudSyncCallbackStub::HandleOnSyncStateChanged;
26 }
27 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)28 int32_t CloudSyncCallbackStub::OnRemoteRequest(uint32_t code,
29                                                MessageParcel &data,
30                                                MessageParcel &reply,
31                                                MessageOption &option)
32 {
33     if (data.ReadInterfaceToken() != GetDescriptor()) {
34         return E_SERVICE_DESCRIPTOR_IS_EMPTY;
35     }
36     auto interfaceIndex = opToInterfaceMap_.find(code);
37     if (interfaceIndex == opToInterfaceMap_.end() || !interfaceIndex->second) {
38         LOGE("Cannot response request %d: unknown tranction", code);
39         return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
40     }
41     return (this->*(interfaceIndex->second))(data, reply);
42 }
43 
HandleOnSyncStateChanged(MessageParcel & data,MessageParcel & reply)44 int32_t CloudSyncCallbackStub::HandleOnSyncStateChanged(MessageParcel &data, MessageParcel &reply)
45 {
46     CloudSyncState state = CloudSyncState(data.ReadInt32());
47     ErrorType error = ErrorType(data.ReadInt32());
48     OnSyncStateChanged(state, error);
49     LOGI("OnSyncStateChanged, error = %{public}d, state = %{public}d", error, state);
50     return E_OK;
51 }
52 } // namespace OHOS::FileManagement::CloudSync