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 "rdb_service.h" 21 #include "rdb_notifier.h" 22 #include "feature/feature_system.h" 23 24 namespace OHOS::DistributedRdb { 25 using RdbServiceCode = OHOS::DistributedRdb::RelationalStore::RdbServiceInterfaceCode; 26 27 class RdbServiceStub : public RdbService, public DistributedData::FeatureSystem::Feature { 28 public: 29 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.DistributedRdb.IRdbService"); 30 int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply) override; 31 32 private: 33 static bool CheckInterfaceToken(MessageParcel& data); 34 35 int32_t OnRemoteObtainDistributedTableName(MessageParcel& data, MessageParcel& reply); 36 37 int32_t OnGetSchema(MessageParcel& data, MessageParcel& reply); 38 39 int32_t OnDelete(MessageParcel& data, MessageParcel& reply); 40 41 int32_t OnRemoteInitNotifier(MessageParcel& data, MessageParcel& reply); 42 43 int32_t OnRemoteSetDistributedTables(MessageParcel& data, MessageParcel& reply); 44 45 int32_t OnRemoteDoSync(MessageParcel& data, MessageParcel& reply); 46 47 int32_t OnRemoteDoAsync(MessageParcel& data, MessageParcel& reply); 48 49 int32_t OnRemoteDoSubscribe(MessageParcel& data, MessageParcel& reply); 50 51 int32_t OnRemoteDoUnSubscribe(MessageParcel& data, MessageParcel& reply); 52 53 int32_t OnRemoteRegisterDetailProgressObserver(MessageParcel& data, MessageParcel& reply); 54 55 int32_t OnRemoteUnregisterDetailProgressObserver(MessageParcel& data, MessageParcel& reply); 56 57 int32_t OnRemoteDoRemoteQuery(MessageParcel& data, MessageParcel& reply); 58 59 int32_t OnRemoteNotifyDataChange(MessageParcel& data, MessageParcel& reply); 60 61 int32_t OnRemoteQuerySharingResource(MessageParcel& data, MessageParcel& reply); 62 63 using RequestHandle = int (RdbServiceStub::*)(MessageParcel &, MessageParcel &); 64 static constexpr RequestHandle HANDLERS[static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_MAX)] = { 65 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_OBTAIN_TABLE)] = 66 &RdbServiceStub::OnRemoteObtainDistributedTableName, 67 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_INIT_NOTIFIER)] = &RdbServiceStub::OnRemoteInitNotifier, 68 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_SET_DIST_TABLE)] = 69 &RdbServiceStub::OnRemoteSetDistributedTables, 70 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_SYNC)] = &RdbServiceStub::OnRemoteDoSync, 71 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_ASYNC)] = &RdbServiceStub::OnRemoteDoAsync, 72 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_SUBSCRIBE)] = &RdbServiceStub::OnRemoteDoSubscribe, 73 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_UNSUBSCRIBE)] = &RdbServiceStub::OnRemoteDoUnSubscribe, 74 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_REMOTE_QUERY)] = &RdbServiceStub::OnRemoteDoRemoteQuery, 75 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_GET_SCHEMA)] = &RdbServiceStub::OnGetSchema, 76 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_DELETE)] = &RdbServiceStub::OnDelete, 77 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_REGISTER_AUTOSYNC_PROGRESS_OBSERVER)] = 78 &RdbServiceStub::OnRemoteRegisterDetailProgressObserver, 79 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_UNREGISTER_AUTOSYNC_PROGRESS_OBSERVER)] = 80 &RdbServiceStub::OnRemoteUnregisterDetailProgressObserver, 81 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_NOTIFY_DATA_CHANGE)] = 82 &RdbServiceStub::OnRemoteNotifyDataChange, 83 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_QUERY_SHARING_RESOURCE)] = 84 &RdbServiceStub::OnRemoteQuerySharingResource 85 }; 86 }; 87 } // namespace OHOS::DistributedRdb 88 #endif 89