1 /* 2 * Copyright (c) 2022-2024 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_FILEMGMT_BACKUP_SERVICE_REVERSE_H 17 #define OHOS_FILEMGMT_BACKUP_SERVICE_REVERSE_H 18 19 #include "b_session_backup.h" 20 #include "b_session_restore.h" 21 #include "b_incremental_backup_session.h" 22 #include "b_incremental_restore_session.h" 23 #include "service_reverse_stub.h" 24 25 namespace OHOS::FileManagement::Backup { 26 class ServiceReverse final : public ServiceReverseStub { 27 public: 28 void BackupOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) override; 29 void BackupOnBundleStarted(int32_t errCode, std::string bundleName) override; 30 void BackupOnResultReport(std::string result, std::string bundleName) override; 31 void BackupOnBundleFinished(int32_t errCode, std::string bundleName) override; 32 void BackupOnAllBundlesFinished(int32_t errCode) override; 33 void BackupOnProcessInfo(std::string bundleName, std::string processInfo) override; 34 35 void RestoreOnBundleStarted(int32_t errCode, std::string bundleName) override; 36 void RestoreOnBundleFinished(int32_t errCode, std::string bundleName) override; 37 void RestoreOnAllBundlesFinished(int32_t errCode) override; 38 void RestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) override; 39 void RestoreOnResultReport(std::string result, std::string bundleName, 40 ErrCode errCode = 0) override; 41 void RestoreOnProcessInfo(std::string bundleName, std::string processInfo) override; 42 43 void IncrementalBackupOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, 44 int32_t errCode) override; 45 void IncrementalBackupOnBundleStarted(int32_t errCode, std::string bundleName) override; 46 void IncrementalBackupOnResultReport(std::string result, std::string bundleName) override; 47 void IncrementalBackupOnBundleFinished(int32_t errCode, std::string bundleName) override; 48 void IncrementalBackupOnAllBundlesFinished(int32_t errCode) override; 49 void IncrementalBackupOnProcessInfo(std::string bundleName, std::string processInfo) override; 50 51 void IncrementalRestoreOnBundleStarted(int32_t errCode, std::string bundleName) override; 52 void IncrementalRestoreOnBundleFinished(int32_t errCode, std::string bundleName) override; 53 void IncrementalRestoreOnAllBundlesFinished(int32_t errCode) override; 54 void IncrementalRestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd, 55 int32_t errCode) override; 56 void IncrementalRestoreOnResultReport(std::string result, std::string bundleName, 57 ErrCode errCode = 0) override; 58 void IncrementalRestoreOnProcessInfo(std::string bundleName, std::string processInfo) override; 59 60 public: 61 ServiceReverse() = delete; 62 explicit ServiceReverse(BSessionRestore::Callbacks callbacks); 63 explicit ServiceReverse(BSessionBackup::Callbacks callbacks); 64 explicit ServiceReverse(BIncrementalBackupSession::Callbacks callbacks); 65 explicit ServiceReverse(BIncrementalRestoreSession::Callbacks callbacks); 66 ~ServiceReverse() override = default; 67 68 private: 69 Scenario scenario_ {Scenario::UNDEFINED}; 70 BSessionBackup::Callbacks callbacksBackup_; 71 BSessionRestore::Callbacks callbacksRestore_; 72 BIncrementalBackupSession::Callbacks callbacksIncrementalBackup_; 73 BIncrementalRestoreSession::Callbacks callbacksIncrementalRestore_; 74 }; 75 } // namespace OHOS::FileManagement::Backup 76 77 #endif // OHOS_FILEMGMT_BACKUP_SERVICE_REVERSE_H