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