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 DISTRIBUTED_RDB_SERVICE_STUB_H 17 #define DISTRIBUTED_RDB_SERVICE_STUB_H 18 19 #include <iremote_stub.h> 20 #include "irdb_service.h" 21 #include "rdb_notifier.h" 22 #include "feature/feature_system.h" 23 24 namespace OHOS::DistributedRdb { 25 class RdbServiceStub : public RdbService, public DistributedData::FeatureSystem::Feature { 26 public: 27 int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply) override; 28 Sync(const RdbSyncerParam & param,const SyncOption & option,const RdbPredicates & predicates,const SyncCallback & callback)29 int32_t Sync(const RdbSyncerParam& param, const SyncOption& option, 30 const RdbPredicates& predicates, const SyncCallback& callback) override 31 { 32 return 0; 33 } 34 Subscribe(const RdbSyncerParam & param,const SubscribeOption & option,RdbStoreObserver * observer)35 int32_t Subscribe(const RdbSyncerParam& param, const SubscribeOption& option, 36 RdbStoreObserver *observer) override 37 { 38 return 0; 39 } 40 UnSubscribe(const RdbSyncerParam & param,const SubscribeOption & option,RdbStoreObserver * observer)41 int32_t UnSubscribe(const RdbSyncerParam& param, const SubscribeOption& option, 42 RdbStoreObserver *observer) override 43 { 44 return 0; 45 } 46 47 private: 48 static bool CheckInterfaceToken(MessageParcel& data); 49 50 int32_t OnRemoteObtainDistributedTableName(MessageParcel& data, MessageParcel& reply); 51 52 int32_t OnRemoteInitNotifier(MessageParcel&data, MessageParcel& reply); 53 54 int32_t OnRemoteSetDistributedTables(MessageParcel &data, MessageParcel &reply); 55 56 int32_t OnRemoteDoSync(MessageParcel& data, MessageParcel& reply); 57 58 int32_t OnRemoteDoAsync(MessageParcel& data, MessageParcel& reply); 59 60 int32_t OnRemoteDoSubscribe(MessageParcel& data, MessageParcel& reply); 61 62 int32_t OnRemoteDoUnSubscribe(MessageParcel& data, MessageParcel& reply); 63 64 int32_t OnRemoteDoRemoteQuery(MessageParcel& data, MessageParcel& reply); 65 66 int32_t OnRemoteDoCreateTable(MessageParcel& data, MessageParcel& reply); 67 68 int32_t OnRemoteDoDestroyTable(MessageParcel& data, MessageParcel& reply); 69 70 using RequestHandle = int (RdbServiceStub::*)(MessageParcel &, MessageParcel &); 71 static constexpr RequestHandle HANDLERS[RDB_SERVICE_CMD_MAX] = { 72 [RDB_SERVICE_CMD_OBTAIN_TABLE] = &RdbServiceStub::OnRemoteObtainDistributedTableName, 73 [RDB_SERVICE_CMD_INIT_NOTIFIER] = &RdbServiceStub::OnRemoteInitNotifier, 74 [RDB_SERVICE_CMD_SET_DIST_TABLE] = &RdbServiceStub::OnRemoteSetDistributedTables, 75 [RDB_SERVICE_CMD_SYNC] = &RdbServiceStub::OnRemoteDoSync, 76 [RDB_SERVICE_CMD_ASYNC] = &RdbServiceStub::OnRemoteDoAsync, 77 [RDB_SERVICE_CMD_SUBSCRIBE] = &RdbServiceStub::OnRemoteDoSubscribe, 78 [RDB_SERVICE_CMD_UNSUBSCRIBE] = &RdbServiceStub::OnRemoteDoUnSubscribe, 79 [RDB_SERVICE_CMD_REMOTE_QUERY] = &RdbServiceStub::OnRemoteDoRemoteQuery, 80 [RDB_SERVICE_CREATE_RDB_TABLE] = &RdbServiceStub::OnRemoteDoCreateTable, 81 [RDB_SERVICE_DESTROY_RDB_TABLE] = &RdbServiceStub::OnRemoteDoDestroyTable 82 }; 83 }; 84 } // namespace OHOS::DistributedRdb 85 #endif 86