mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-12 16:09:37 -05:00
added more interface declarations and comments clarifying
resposibility git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-new_cache_system@4803 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3f0c811917
commit
2504c0fd9a
@ -28,7 +28,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
|
@ -1,13 +1,53 @@
|
|||||||
#ifndef RSGDP_H
|
#ifndef RSGDP_H
|
||||||
#define RSGDP_H
|
#define RSGDP_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* libretroshare/src/gxp: gxp.h
|
||||||
|
*
|
||||||
|
* General Data service, interface for RetroShare.
|
||||||
|
*
|
||||||
|
* Copyright 2011-2011 by Robert Fernie, Evi-Parker Christopher
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License Version 2 as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "inttypes.h"
|
#include "inttypes.h"
|
||||||
#include "util/rssqlite.h"
|
#include "util/rssqlite.h"
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
* GDP: Represents the center of gxs. In as far as enabling synchronisation between peers
|
||||||
*
|
*
|
||||||
|
* Responsibilty:
|
||||||
|
* GDP has access to concrete RsGxs services internal messages by way of a passed
|
||||||
|
* RsGss (storage module in read only mode)
|
||||||
|
* It also receives messages from GNP which it stores in its external db which
|
||||||
|
* it passed as a handle to the concrete RsGxs service (read only for service)
|
||||||
|
*
|
||||||
|
* An important responsibility is the preparation of data for GNP as such
|
||||||
|
* permissions of messages are enforced here
|
||||||
|
*
|
||||||
|
*****/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
* The main role of GDP is to receive and start sync requests
|
* The main role of GDP is to receive and start sync requests
|
||||||
* and prepare exchange data for RsGnp.
|
* and prepare exchange data for RsGnp.
|
||||||
* It is also the curator (write authority) of externally received messages
|
* It is also the curator (write authority) of externally received messages
|
||||||
@ -18,13 +58,17 @@ public:
|
|||||||
RsGdp();
|
RsGdp();
|
||||||
};
|
};
|
||||||
|
|
||||||
class RsGxsMessage {
|
class RsGxsSignedMessage {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
*
|
* General Storage service
|
||||||
*
|
* This presents an abstract interface used by both concrete Gxs services and the Gdp to store
|
||||||
|
* internally and externally generated messages respectively.
|
||||||
|
* This abstraction allows GDP to retrieve entries from an SQL lite db without knowledge of the
|
||||||
|
* service db schema (columns basically).
|
||||||
|
* Concrete services should implement this service
|
||||||
*/
|
*/
|
||||||
class RsGss {
|
class RsGss {
|
||||||
|
|
||||||
@ -39,15 +83,20 @@ public:
|
|||||||
* @param message the message to store
|
* @param message the message to store
|
||||||
* @return true if message successfully stored
|
* @return true if message successfully stored
|
||||||
*/
|
*/
|
||||||
virtual bool store(const RsGxsMessage& message) = 0;
|
virtual bool store(const RsGxsSignedMessage* message) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* retrieve message from associate RsSqlite db \n
|
* retrieve message from associate RsSqlite db \n
|
||||||
*
|
* @param msgId
|
||||||
|
* @param message
|
||||||
* @return true if successfully retrieved, false otherwise
|
* @return true if successfully retrieved, false otherwise
|
||||||
*/
|
*/
|
||||||
virtual bool retrieve(const std::string msgId, RsGxsMessage&) = 0;
|
virtual bool retrieve(const std::string msgId, RsGxsSignedMessage* message) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Use this find out if Rss i/o status
|
||||||
|
* @return the io status
|
||||||
|
*/
|
||||||
uint8_t getIoStat();
|
uint8_t getIoStat();
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,19 +1,203 @@
|
|||||||
#ifndef RSGIXS_H
|
#ifndef RSGIXS_H
|
||||||
#define RSGIXS_H
|
#define RSGIXS_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* libretroshare/src/gxs: gxs.h
|
||||||
|
*
|
||||||
|
* General Exchange Protocol interface for RetroShare.
|
||||||
|
*
|
||||||
|
* Copyright 2011-2011 by Robert Fernie.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License Version 2 as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include "gxs/rsgxs.h"
|
#include "gxs/rsgxs.h"
|
||||||
|
|
||||||
/*!
|
#include <openssl/ssl.h>
|
||||||
* Retroshare general identity exchange service
|
#include <set>
|
||||||
* provides a means to distribute identities among peers
|
/*
|
||||||
* also provides encyption, decryption, verification,
|
* GIXP: General Identity Exchange Protocol.
|
||||||
* and signing functionality using any created identities
|
*
|
||||||
|
* As we're always running into troubles with GPG signatures... we are going to
|
||||||
|
* create a layer of RSA Keys for the following properties:
|
||||||
|
*
|
||||||
|
* 1) RSA Keys can be Anonymous, Self-Signed with Pseudonym, Signed by GPG Key.
|
||||||
|
* - Anonymous & Pseudonym Keys will be shared network-wide (Hop by Hop).
|
||||||
|
- GPG signed Keys will only be shared if we can validate the signature
|
||||||
|
(providing similar behaviour to existing GPG Keys).
|
||||||
|
- GPG signed Keys can optionally be marked for Network-wide sharing.
|
||||||
|
* 2) These keys can be used anywhere, specifically in the protocols described below.
|
||||||
|
* 3) These keys can be used to sign, encrypt, verify & decrypt
|
||||||
|
* 4) Keys will never need to be directly accessed - stored in this class.
|
||||||
|
* 5) They will be cached locally and exchanged p2p, by pull request.
|
||||||
|
* 6) This class will use the generalised packet storage for efficient caching & loading.
|
||||||
|
* 7) Data will be stored encrypted.
|
||||||
*/
|
*/
|
||||||
class RsGixs : RsGxs
|
namespace retroshare_gxs {
|
||||||
{
|
|
||||||
public:
|
|
||||||
RsGixs();
|
|
||||||
|
|
||||||
};
|
class GixsKey
|
||||||
|
{
|
||||||
|
KeyRef mKeyId;
|
||||||
|
|
||||||
|
/// public key
|
||||||
|
EVP_PKEY *mPubKey;
|
||||||
|
|
||||||
|
/// NULL if non-existant */
|
||||||
|
EVP_PKEY *mPrivKey;
|
||||||
|
};
|
||||||
|
|
||||||
|
class KeyRef {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class KeyRefSet {
|
||||||
|
std::set<KeyRef> mKeyRefSet;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SignatureSet {
|
||||||
|
std::set<Signature> mSignatureSet;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Signature {
|
||||||
|
|
||||||
|
KeyRef mKeyRef;
|
||||||
|
Signature mSignature;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class RsGixsProfile {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
KeyRef mKeyRef;
|
||||||
|
std::string mPseudonym;
|
||||||
|
|
||||||
|
/// may be superseded by newer timestamps
|
||||||
|
time_t mTimeStamp;
|
||||||
|
uint32_t mProfileType;
|
||||||
|
|
||||||
|
// TODO: add permissions members
|
||||||
|
|
||||||
|
Signature mSignature;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Retroshare general identity exchange service
|
||||||
|
* provides a means to distribute identities among peers
|
||||||
|
* also provides encyption, decryption, verification,
|
||||||
|
* and signing functionality using any created identities
|
||||||
|
*/
|
||||||
|
class RsGixs : RsGxs
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RsGixs();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* creates gixs profile and shares it
|
||||||
|
* @param profile
|
||||||
|
*/
|
||||||
|
bool createKey(RsGixsProfile& profile); /* fills in mKeyId, and signature */
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Use to query a whether given key is available by its key reference
|
||||||
|
* @param keyref the keyref of key that is being checked for
|
||||||
|
* @return true if available, false otherwise
|
||||||
|
*/
|
||||||
|
bool haveKey(const KeyRef& keyref);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Use to query whether private key member of the given key reference is available
|
||||||
|
* @param keyref the KeyRef of the key being checked for
|
||||||
|
* @return true if private key is held here, false otherwise
|
||||||
|
*/
|
||||||
|
bool havePrivateKey(const KeyRef& keyref);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Use to request a given key reference
|
||||||
|
* @param keyref the KeyRef of the key being requested
|
||||||
|
* @return will
|
||||||
|
*/
|
||||||
|
bool requestKey(const KeyRef& keyref);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Retrieves a key identity
|
||||||
|
* @param keyref
|
||||||
|
* @return a pointer to a valid profile if successful, otherwise NULL
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
RsGixsProfile* getProfile(const KeyRef& keyref);
|
||||||
|
|
||||||
|
|
||||||
|
/*** process data ***/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Use to sign data with a given key
|
||||||
|
* @param keyref the key to sign the data with
|
||||||
|
* @param data the data to be signed
|
||||||
|
* @param dataLen the length of the data
|
||||||
|
* @param signature is set with the signature from signing with keyref
|
||||||
|
* @return false if signing failed, true otherwise
|
||||||
|
*/
|
||||||
|
bool sign(const KeyRef& keyref, unsigned char* data, uint32_t dataLen, std::string& signature);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Verify that the data is signed by the key owner
|
||||||
|
* @param keyref
|
||||||
|
* @param data
|
||||||
|
* @param dataLen
|
||||||
|
* @param signature
|
||||||
|
* @return false if verification failed, false otherwise
|
||||||
|
*/
|
||||||
|
bool verify(const KeyRef& keyref, unsigned char* data, int dataLen, std::string& signature);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Attempt to decrypt data with a given key
|
||||||
|
* @param keyref
|
||||||
|
* @param data data to be decrypted
|
||||||
|
* @param dataLen length of data
|
||||||
|
* @param decryptedData decrypted data
|
||||||
|
* @param decryptDataLen length of decrypted data
|
||||||
|
* @return false
|
||||||
|
*/
|
||||||
|
bool decrypt(const KeyRef& keyref, unsigned char* data, int dataLen,
|
||||||
|
unsigned char*& decryptedData, uint32_t& decyptDataLen);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Attempt to encrypt data with a given key
|
||||||
|
* @param keyref
|
||||||
|
* @param data data to be encrypted
|
||||||
|
* @param dataLen length of data
|
||||||
|
* @param encryptedData encrypted data
|
||||||
|
* @param encryptDataLen length of encrypted data
|
||||||
|
*/
|
||||||
|
bool encrypt(const KeyRef& keyref, unsigned char* data, int dataLen,
|
||||||
|
unsigned char*& encryptedData, uint32_t& encryptDataLen);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // RSGIXS_H
|
#endif // RSGIXS_H
|
||||||
|
@ -1,20 +1,42 @@
|
|||||||
#ifndef RSGNP_H
|
#ifndef RSGNP_H
|
||||||
#define RSGNP_H
|
#define RSGNP_H
|
||||||
|
|
||||||
#include "pqi/pqiservice.h"
|
#include <set>
|
||||||
|
|
||||||
|
#include "services/p3service.h"
|
||||||
|
#include "gxs/rsgdp.h"
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Retroshare general network protocol
|
* Retroshare general network protocol
|
||||||
*
|
*
|
||||||
* This deals with the receiving and sending
|
* This simply deals with the receiving and sending
|
||||||
* RsGxs data
|
* RsGxs data
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class RsGnp
|
class RsGnp : p3ThreadedService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RsGnp();
|
RsGnp();
|
||||||
|
|
||||||
|
|
||||||
|
/*** gdp::iterface *****/
|
||||||
|
int requestMsgs(std::set<std::string> msgId, double &delay);
|
||||||
|
void addGdp(RsGdp* gdp);
|
||||||
|
void removeGdp(RsGdp* gdp);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/*** IMPLEMENTATION DETAILS ****/
|
||||||
|
|
||||||
|
/* Get/Send Messages */
|
||||||
|
void getAvailableMsgs(std::string peerId, time_t from, time_t to); /* request over the network */
|
||||||
|
void sendAvailableMsgs(std::string peerId, gdp::id grpId, time_t from, time_t to); /* send to peers */
|
||||||
|
|
||||||
|
requestMessages(std::string peerId, gdp::id grpId, std::list<gdp::id> msgIds);
|
||||||
|
sendMessages(std::string peerId, gdp::id grpId, std::list<gdp::id> msgIds); /* send to peer, obviously permissions have been checked first */
|
||||||
|
|
||||||
|
/* Search the network */
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RSGNP_H
|
#endif // RSGNP_H
|
||||||
|
@ -36,8 +36,8 @@
|
|||||||
* Retroshare general exchange service
|
* Retroshare general exchange service
|
||||||
* This forms the basic interface that classes need to inherit
|
* This forms the basic interface that classes need to inherit
|
||||||
* in order to use the general exchange service
|
* in order to use the general exchange service
|
||||||
* General GNP drives the service.
|
* Generally GNP drives the service.
|
||||||
* GDP deals with exporting and importing
|
* GDP deals with exporting and importing msgs to and from the concrete service
|
||||||
* data from the derived class
|
* data from the derived class
|
||||||
* GXIP is used to maintain
|
* GXIP is used to maintain
|
||||||
*/
|
*/
|
||||||
@ -48,13 +48,36 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void receiveMessage(RsGxsMessage*) = 0;
|
/*!
|
||||||
void sendMessage(RsGxsMessage*) = 0;
|
* These are messages, that have been pushed to you
|
||||||
|
* This will be called by RsGdp whenever a new msg(s) has arrived
|
||||||
|
* the list contains ids which may be queried from the external db
|
||||||
|
*/
|
||||||
|
virtual void receiveMessage(std::set<std::string> msgIds) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Push a set of messages which have been written to your service
|
||||||
|
* database
|
||||||
|
*/
|
||||||
|
void push(std::set<std::string>& msgIds) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* drives synchronisation between peers
|
* drives synchronisation between peers
|
||||||
*/
|
*/
|
||||||
void tick();
|
void tick();
|
||||||
|
|
||||||
|
void cache(RsGxsSignedMessage*);
|
||||||
|
bool cached(std::string& msgId);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Use to retrieve cached msgs
|
||||||
|
*
|
||||||
|
* @param msgs the cached msgs
|
||||||
|
*/
|
||||||
|
void retrieveCache(std::set<std::string>& requestIds, std::set<RsGxsSignedMessage*>& msgs);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RSGXS_H
|
#endif // RSGXS_H
|
||||||
|
@ -10,6 +10,7 @@ CONFIG += test_voip
|
|||||||
# Beware: All data of the stripped services are lost
|
# Beware: All data of the stripped services are lost
|
||||||
#CONFIG += minimal
|
#CONFIG += minimal
|
||||||
DEFINES *= PQI_DISABLE_TUNNEL
|
DEFINES *= PQI_DISABLE_TUNNEL
|
||||||
|
INCLUDEPATH += C:/Development/Rs/OpenSSL/include
|
||||||
#ENABLE_CACHE_OPT
|
#ENABLE_CACHE_OPT
|
||||||
|
|
||||||
minimal {
|
minimal {
|
||||||
@ -286,13 +287,13 @@ win32 {
|
|||||||
SOURCES += upnp/upnputil.c
|
SOURCES += upnp/upnputil.c
|
||||||
|
|
||||||
|
|
||||||
UPNPC_DIR = ../../../../miniupnpc-1.3
|
UPNPC_DIR = ../../../lib/miniupnpc-1.3
|
||||||
GPG_ERROR_DIR = ../../../../libgpg-error-1.7
|
GPG_ERROR_DIR = ../../../lib/libgpg-error-1.7
|
||||||
GPGME_DIR = ../../../../gpgme-1.1.8
|
GPGME_DIR = ../../../lib/gpgme-1.1.8
|
||||||
|
|
||||||
PTHREADS_DIR = ../../../../pthreads-w32-2-8-0-release
|
PTHREADS_DIR = ../../../lib/pthreads-w32-2-8-0-release
|
||||||
ZLIB_DIR = ../../../../zlib-1.2.3
|
ZLIB_DIR = ../../../lib/zlib-1.2.3
|
||||||
SSL_DIR = ../../../../OpenSSL
|
SSL_DIR = ../../../OpenSSL
|
||||||
|
|
||||||
|
|
||||||
INCLUDEPATH += . $${SSL_DIR}/include $${UPNPC_DIR} $${PTHREADS_DIR} $${ZLIB_DIR} $${GPGME_DIR}/src $${GPG_ERROR_DIR}/src
|
INCLUDEPATH += . $${SSL_DIR}/include $${UPNPC_DIR} $${PTHREADS_DIR} $${ZLIB_DIR} $${GPGME_DIR}/src $${GPG_ERROR_DIR}/src
|
||||||
|
@ -1,10 +1,150 @@
|
|||||||
#ifndef RSSQLITE_H
|
#ifndef RSSQLITE_H
|
||||||
#define RSSQLITE_H
|
#define RSSQLITE_H
|
||||||
|
|
||||||
class RsSqlite
|
#include "sqlite3.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* The idea of RsDb is to provide a means for Retroshare core and its services itself to maintain
|
||||||
|
* easy to use random access files via a database
|
||||||
|
* Especially for messages, rather than all data to memory
|
||||||
|
* It models itself after android's sqlite functionality
|
||||||
|
*/
|
||||||
|
class RetroDb
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RsSqlite();
|
|
||||||
|
/*!
|
||||||
|
* @param dbPath path to data base file
|
||||||
|
*/
|
||||||
|
RetroDb(const std::string dbPath);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* closes db if it is not already closed
|
||||||
|
*/
|
||||||
|
~RetroDb();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* opens an sqlite data base
|
||||||
|
*/
|
||||||
|
bool openDb(const std::string dbPath);
|
||||||
|
void closeDb();
|
||||||
|
|
||||||
|
/* modifying db */
|
||||||
|
public:
|
||||||
|
|
||||||
|
void execSQL(const std::string&);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* insert a row in a database table
|
||||||
|
* @return true if insertion successful, false otherwise
|
||||||
|
*/
|
||||||
|
bool sqlInsert(std::string& table, const ContentValue&);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* update row in a database table
|
||||||
|
* @return true if update was successful, false otherwise
|
||||||
|
*/
|
||||||
|
bool sqlUpdate(const std::string& tableName, const std::set<std::string>& columns, const std::string& query);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Query the given table, returning a Cursor over the result set
|
||||||
|
* @param tableName
|
||||||
|
* @param columns
|
||||||
|
* @param query
|
||||||
|
* @return cursor over result set
|
||||||
|
*/
|
||||||
|
RetroCursor* sqlQuery(const std::string& tableName, const std::set<std::string>& columns, const std::string& query);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* delete row in an sql table
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
bool sqlDelete(const std::string& tableName, const std::string& query);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* defragment database, should be done on databases if many modifications have occured
|
||||||
|
*/
|
||||||
|
void vacuum();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
sqlite3* mDb;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Exposes results from retrodb query
|
||||||
|
*/
|
||||||
|
class RetroCursor {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
RetroCursor();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* move to first row of result,
|
||||||
|
* @return false if no result
|
||||||
|
*/
|
||||||
|
bool moveToFirst();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* move to
|
||||||
|
* @return false if no row to move next to
|
||||||
|
*/
|
||||||
|
bool moveToNext();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* move to last row of result
|
||||||
|
* @return false if no result
|
||||||
|
*/
|
||||||
|
bool moveToLast();
|
||||||
|
|
||||||
|
/* data retrieval */
|
||||||
|
public:
|
||||||
|
|
||||||
|
int32_t getInt32(const std::string& );
|
||||||
|
uint32_t getUint32(const std::string& );
|
||||||
|
int64_t getInt64(const std::string& );
|
||||||
|
uint64_t getUint64(const std::string& );
|
||||||
|
bool getBool(const std::string& );
|
||||||
|
std::string getString(const std::string& );
|
||||||
|
void* getData(const std::string&, uint32_t& );
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Convenience class for making additions to databases
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class ContentValue {
|
||||||
|
|
||||||
|
public:
|
||||||
|
ContentValue();
|
||||||
|
|
||||||
|
void put(const std::string&, uint32_t );
|
||||||
|
void put(const std::string &, uint64_t);
|
||||||
|
void put(const std::string& , const std::string& );
|
||||||
|
void put(const std::string& , bool);
|
||||||
|
void put(const std::string& , int64_t);
|
||||||
|
void put(const std::string &, int32_t);
|
||||||
|
void put(const std::string&, uint32_t len, void* data);
|
||||||
|
void put(const std::string&, int64_t );
|
||||||
|
|
||||||
|
|
||||||
|
int32_t getAsInt32(const std::string& );
|
||||||
|
uint32_t getAsUint32(const std::string& );
|
||||||
|
int64_t getAsInt64(const std::string& );
|
||||||
|
uint64_t getAsUint64(const std::string& );
|
||||||
|
bool getAsBool(const std::string& );
|
||||||
|
std::string getAsString(const std::string& );
|
||||||
|
void* getAsData(const std::string&, uint32_t& );
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // RSSQLITE_H
|
#endif // RSSQLITE_H
|
||||||
|
Loading…
Reference in New Issue
Block a user