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 #include "rdb_result_set_impl.h" 24 25 namespace OHOS::DistributedRdb { 26 using RdbServiceCode = OHOS::DistributedRdb::RelationalStore::RdbServiceInterfaceCode; 27 28 class RdbServiceStub : public RdbService, public DistributedData::FeatureSystem::Feature { 29 public: 30 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.DistributedRdb.IRdbService"); 31 int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply) override; 32 33 private: 34 static bool CheckInterfaceToken(MessageParcel& data); 35 36 int32_t OnRemoteObtainDistributedTableName(MessageParcel& data, MessageParcel& reply); 37 38 int32_t OnDelete(MessageParcel& data, MessageParcel& reply); 39 40 int32_t OnRemoteInitNotifier(MessageParcel& data, MessageParcel& reply); 41 42 int32_t OnRemoteSetDistributedTables(MessageParcel& data, MessageParcel& reply); 43 44 int32_t OnRemoteDoSync(MessageParcel& data, MessageParcel& reply); 45 46 int32_t OnRemoteDoAsync(MessageParcel& data, MessageParcel& reply); 47 48 int32_t OnRemoteDoSubscribe(MessageParcel& data, MessageParcel& reply); 49 50 int32_t OnRemoteDoUnSubscribe(MessageParcel& data, MessageParcel& reply); 51 52 int32_t OnRemoteRegisterDetailProgressObserver(MessageParcel& data, MessageParcel& reply); 53 54 int32_t OnRemoteUnregisterDetailProgressObserver(MessageParcel& data, MessageParcel& reply); 55 56 int32_t OnRemoteDoRemoteQuery(MessageParcel& data, MessageParcel& reply); 57 58 int32_t OnRemoteNotifyDataChange(MessageParcel& data, MessageParcel& reply); 59 60 int32_t OnRemoteSetSearchable(MessageParcel& data, MessageParcel& reply); 61 62 int32_t OnRemoteQuerySharingResource(MessageParcel& data, MessageParcel& reply); 63 64 int32_t OnBeforeOpen(MessageParcel& data, MessageParcel& reply); 65 66 int32_t OnAfterOpen(MessageParcel& data, MessageParcel& reply); 67 68 int32_t OnReportStatistic(MessageParcel& data, MessageParcel& reply); 69 70 int32_t OnDisable(MessageParcel& data, MessageParcel& reply); 71 72 int32_t OnEnable(MessageParcel& data, MessageParcel& reply); 73 74 int32_t OnGetPassword(MessageParcel& data, MessageParcel& reply); 75 76 int32_t OnLockCloudContainer(MessageParcel& data, MessageParcel& reply); 77 78 int32_t OnUnlockCloudContainer(MessageParcel& data, MessageParcel& reply); 79 80 int32_t OnGetDebugInfo(MessageParcel& data, MessageParcel& reply); 81 82 int32_t OnGetDfxInfo(MessageParcel& data, MessageParcel& reply); 83 84 int32_t OnVerifyPromiseInfo(MessageParcel& data, MessageParcel& reply); 85 86 using RequestHandle = int (RdbServiceStub::*)(MessageParcel &, MessageParcel &); 87 RDB_UTILS_PUSH_WARNING 88 RDB_UTILS_DISABLE_WARNING("-Wc99-designator") 89 static constexpr RequestHandle HANDLERS[static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_MAX)] = { 90 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_OBTAIN_TABLE)] = 91 &RdbServiceStub::OnRemoteObtainDistributedTableName, 92 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_INIT_NOTIFIER)] = &RdbServiceStub::OnRemoteInitNotifier, 93 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_SET_DIST_TABLE)] = 94 &RdbServiceStub::OnRemoteSetDistributedTables, 95 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_SYNC)] = &RdbServiceStub::OnRemoteDoSync, 96 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_ASYNC)] = &RdbServiceStub::OnRemoteDoAsync, 97 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_SUBSCRIBE)] = &RdbServiceStub::OnRemoteDoSubscribe, 98 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_UNSUBSCRIBE)] = &RdbServiceStub::OnRemoteDoUnSubscribe, 99 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_REMOTE_QUERY)] = &RdbServiceStub::OnRemoteDoRemoteQuery, 100 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_DELETE)] = &RdbServiceStub::OnDelete, 101 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_REGISTER_AUTOSYNC_PROGRESS_OBSERVER)] = 102 &RdbServiceStub::OnRemoteRegisterDetailProgressObserver, 103 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_UNREGISTER_AUTOSYNC_PROGRESS_OBSERVER)] = 104 &RdbServiceStub::OnRemoteUnregisterDetailProgressObserver, 105 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_NOTIFY_DATA_CHANGE)] = 106 &RdbServiceStub::OnRemoteNotifyDataChange, 107 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_SET_SEARCHABLE)] = 108 &RdbServiceStub::OnRemoteSetSearchable, 109 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_QUERY_SHARING_RESOURCE)] = 110 &RdbServiceStub::OnRemoteQuerySharingResource, 111 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_DISABLE)] = &RdbServiceStub::OnDisable, 112 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_ENABLE)] = &RdbServiceStub::OnEnable, 113 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_BEFORE_OPEN)] = &RdbServiceStub::OnBeforeOpen, 114 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_AFTER_OPEN)] = &RdbServiceStub::OnAfterOpen, 115 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_GET_PASSWORD)] = &RdbServiceStub::OnGetPassword, 116 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_LOCK_CLOUD_CONTAINER)] = 117 &RdbServiceStub::OnLockCloudContainer, 118 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_UNLOCK_CLOUD_CONTAINER)] = 119 &RdbServiceStub::OnUnlockCloudContainer, 120 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_GET_DEBUG_INFO)] = &RdbServiceStub::OnGetDebugInfo, 121 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_VERIFY_PROMISE_INFO)] = 122 &RdbServiceStub::OnVerifyPromiseInfo, 123 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_REPORT_STAT)] = 124 &RdbServiceStub::OnReportStatistic, 125 [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_GET_DFX_INFO)] = &RdbServiceStub::OnGetDfxInfo, 126 }; 127 RDB_UTILS_POP_WARNING 128 }; 129 } // namespace OHOS::DistributedRdb 130 #endif 131