1 /*
2  * Copyright (c) 2021 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 LOCAL_DATABASE_OPER_H
17 #define LOCAL_DATABASE_OPER_H
18 
19 #ifndef OMIT_MULTI_VER
20 #include "database_oper.h"
21 #include "sqlite_local_kvdb.h"
22 
23 namespace DistributedDB {
24 class LocalDatabaseOper : public DatabaseOper {
25 public:
26     LocalDatabaseOper(SQLiteLocalKvDB *localKvDb, SQLiteStorageEngine *storageEngine);
~LocalDatabaseOper()27     ~LocalDatabaseOper() override {};
28 
29     int Rekey(const CipherPassword &passwd) override;
30 
31     int Import(const std::string &filePath, const CipherPassword &passwd) override;
32 
33     int Export(const std::string &filePath, const CipherPassword &passwd) const override;
34 
35 protected:
36     bool RekeyPreHandle(const CipherPassword &passwd, int &errCode) override;
37 
38     int BackupDb(const CipherPassword &passwd) const override;
39 
40     int CloseStorages() override;
41 
42     int RekeyPostHandle(const CipherPassword &passwd) override;
43 
44     int ExportAllDatabases(const std::string &currentDir, const CipherPassword &passwd,
45         const std::string &dbDir) const override;
46 
47     int BackupCurrentDatabase(const ImportFileInfo &info) const override;
48 
49     int ImportUnpackedDatabase(const ImportFileInfo &info, const CipherPassword &srcPasswd) const override;
50 
51     int ImportPostHandle() const override;
52 
53 private:
54     SQLiteLocalKvDB *localKvDb_;
55     SQLiteStorageEngine *storageEngine_;
56 };
57 } // namespace DistributedDB
58 #endif // OMIT_MULTI_VER
59 #endif // LOCAL_DATABASE_OPER_H