• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     void BackupOnScanningInfo(std::string scannedInfo) override;
35 
36     void RestoreOnBundleStarted(int32_t errCode, std::string bundleName) override;
37     void RestoreOnBundleFinished(int32_t errCode, std::string bundleName) override;
38     void RestoreOnAllBundlesFinished(int32_t errCode) override;
39     void RestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int32_t errCode) override;
40     void RestoreOnResultReport(std::string result, std::string bundleName,
41         ErrCode errCode = 0) override;
42     void RestoreOnProcessInfo(std::string bundleName, std::string processInfo) override;
43 
44     void IncrementalBackupOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd,
45         int32_t errCode) override;
46     void IncrementalBackupOnBundleStarted(int32_t errCode, std::string bundleName) override;
47     void IncrementalBackupOnResultReport(std::string result, std::string bundleName) override;
48     void IncrementalBackupOnBundleFinished(int32_t errCode, std::string bundleName) override;
49     void IncrementalBackupOnAllBundlesFinished(int32_t errCode) override;
50     void IncrementalBackupOnProcessInfo(std::string bundleName, std::string processInfo) override;
51     void IncrementalBackupOnScanningInfo(std::string scannedInfo) override;
52 
53     void IncrementalRestoreOnBundleStarted(int32_t errCode, std::string bundleName) override;
54     void IncrementalRestoreOnBundleFinished(int32_t errCode, std::string bundleName) override;
55     void IncrementalRestoreOnAllBundlesFinished(int32_t errCode) override;
56     void IncrementalRestoreOnFileReady(std::string bundleName, std::string fileName, int fd, int manifestFd,
57         int32_t errCode) override;
58     void IncrementalRestoreOnResultReport(std::string result, std::string bundleName,
59         ErrCode errCode = 0) override;
60     void IncrementalRestoreOnProcessInfo(std::string bundleName, std::string processInfo) override;
61 
62 public:
63     ServiceReverse() = delete;
64     explicit ServiceReverse(BSessionRestore::Callbacks callbacks);
65     explicit ServiceReverse(BSessionBackup::Callbacks callbacks);
66     explicit ServiceReverse(BIncrementalBackupSession::Callbacks callbacks);
67     explicit ServiceReverse(BIncrementalRestoreSession::Callbacks callbacks);
68     ~ServiceReverse() override = default;
69 
70 private:
71     Scenario scenario_ {Scenario::UNDEFINED};
72     BSessionBackup::Callbacks callbacksBackup_;
73     BSessionRestore::Callbacks callbacksRestore_;
74     BIncrementalBackupSession::Callbacks callbacksIncrementalBackup_;
75     BIncrementalRestoreSession::Callbacks callbacksIncrementalRestore_;
76 };
77 } // namespace OHOS::FileManagement::Backup
78 
79 #endif // OHOS_FILEMGMT_BACKUP_SERVICE_REVERSE_H