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 #ifndef OHOS_DISTRIBUTED_DATA_SERVICE_KVDB_SERVICE_STUB_H 17 #define OHOS_DISTRIBUTED_DATA_SERVICE_KVDB_SERVICE_STUB_H 18 #include "checker/checker_manager.h" 19 #include "distributeddata_kvdb_ipc_interface_code.h" 20 #include "iremote_stub.h" 21 #include "kvdb_service.h" 22 #include "feature/feature_system.h" 23 namespace OHOS::DistributedKv { 24 class KVDBServiceStub : public KVDBService, public DistributedData::FeatureSystem::Feature { 25 public: 26 int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply) override; 27 28 private: 29 using StoreInfo = DistributedData::CheckerManager::StoreInfo; 30 using Handler = int32_t (KVDBServiceStub::*)( 31 const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 32 int32_t OnGetStoreIds(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 33 int32_t OnBeforeCreate(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 34 int32_t OnAfterCreate(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 35 int32_t OnDelete(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 36 int32_t OnClose(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 37 int32_t OnSync(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 38 int32_t OnCloudSync(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 39 int32_t OnRegServiceNotifier( 40 const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 41 int32_t OnUnregServiceNotifier( 42 const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 43 int32_t OnSetSyncParam(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 44 int32_t OnGetSyncParam(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 45 int32_t OnEnableCap(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 46 int32_t OnDisableCap(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 47 int32_t OnSetCapability(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 48 int32_t OnAddSubInfo(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 49 int32_t OnRmvSubInfo(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 50 int32_t OnSubscribe(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 51 int32_t OnUnsubscribe(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 52 int32_t OnGetBackupPassword(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 53 int32_t OnNotifyDataChange(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 54 int32_t OnPutSwitch(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 55 int32_t OnGetSwitch(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 56 int32_t OnSubscribeSwitchData(const AppId &appId, const StoreId &storeId, MessageParcel &data, 57 MessageParcel &reply); 58 int32_t OnUnsubscribeSwitchData(const AppId &appId, const StoreId &storeId, MessageParcel &data, 59 MessageParcel &reply); 60 int32_t OnSetConfig(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 61 int32_t OnRemoveDeviceData(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); 62 static const Handler HANDLERS[static_cast<uint32_t>(KVDBServiceInterfaceCode::TRANS_BUTT)]; 63 64 bool CheckPermission(uint32_t code, const StoreInfo &storeInfo); 65 std::pair<int32_t, StoreInfo> GetStoreInfo(uint32_t code, MessageParcel &data); 66 }; 67 } // namespace OHOS::DistributedKv 68 #endif // OHOS_DISTRIBUTED_DATA_SERVICE_KVDB_SERVICE_STUB_H 69