mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-30 09:07:32 -04:00
merging gxs_phase2 branch
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6401 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
1150366913
commit
325fa4f222
116 changed files with 6050 additions and 3596 deletions
|
@ -29,7 +29,6 @@
|
|||
#include <inttypes.h>
|
||||
|
||||
#include "retrodb.h"
|
||||
#include "radix64.h"
|
||||
#include "rsdbbind.h"
|
||||
|
||||
//#define RETRODB_DEBUG
|
||||
|
@ -39,7 +38,7 @@ const int RetroDb::OPEN_READONLY = SQLITE_OPEN_READONLY;
|
|||
const int RetroDb::OPEN_READWRITE = SQLITE_OPEN_READWRITE;
|
||||
const int RetroDb::OPEN_READWRITE_CREATE = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
|
||||
|
||||
RetroDb::RetroDb(const std::string &dbPath, int flags) : mDb(NULL) {
|
||||
RetroDb::RetroDb(const std::string &dbPath, int flags, const std::string& key) : mDb(NULL), mKey(key) {
|
||||
|
||||
int rc = sqlite3_open_v2(dbPath.c_str(), &mDb, flags, NULL);
|
||||
|
||||
|
@ -48,6 +47,17 @@ RetroDb::RetroDb(const std::string &dbPath, int flags) : mDb(NULL) {
|
|||
<< std::endl;
|
||||
sqlite3_close(mDb);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_ENCRYPTED_DB
|
||||
rc = sqlite3_key(mDb, mKey.c_str(), mKey.size());
|
||||
#endif
|
||||
|
||||
if(rc){
|
||||
std::cerr << "Can't key database: " << sqlite3_errmsg(mDb)
|
||||
<< std::endl;
|
||||
|
||||
sqlite3_close(mDb);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -229,6 +239,11 @@ bool RetroDb::sqlInsert(const std::string &table, const std::string& /* nullColu
|
|||
return true;
|
||||
}
|
||||
|
||||
std::string RetroDb::getKey() const
|
||||
{
|
||||
return mKey;
|
||||
}
|
||||
|
||||
bool RetroDb::execSQL_bind(const std::string &query, std::list<RetroBind*> ¶mBindings){
|
||||
|
||||
// prepare statement
|
||||
|
|
|
@ -52,13 +52,18 @@ public:
|
|||
* @param dbPath path to data base file
|
||||
* @param flags determine where to open read only or read/write
|
||||
*/
|
||||
RetroDb(const std::string& dbPath, int flags);
|
||||
RetroDb(const std::string& dbPath, int flags, const std::string& key = "");
|
||||
|
||||
/*!
|
||||
* closes db if it is not already closed
|
||||
*/
|
||||
~RetroDb();
|
||||
|
||||
/*!
|
||||
* @return key used to encrypt database
|
||||
*/
|
||||
std::string getKey() const;
|
||||
|
||||
/*!
|
||||
* opens sqlite data base
|
||||
* @param dbPath
|
||||
|
@ -173,7 +178,7 @@ private:
|
|||
private:
|
||||
|
||||
sqlite3* mDb;
|
||||
|
||||
const std::string mKey;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue