mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-24 14:23:36 -05:00
refined GDP, GNP, and GSP component further and made classes pure
virtual. - added interface to allow GDP and GNP to work via an observer pattern - added grpId explicitly to GDP, GNP and GSP - shifting from protocol to service semantics git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-new_cache_system@4816 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
6d4fa40416
commit
00c6010543
@ -26,82 +26,164 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "inttypes.h"
|
#include "inttypes.h"
|
||||||
#include "util/rssqlite.h"
|
#include "gxs/rsgxs.h"
|
||||||
|
|
||||||
|
typedef std::map<std::string, std::set<std::string> > MsgGrpId;
|
||||||
|
typedef std::map<std::string, std::set<RsGxsSignedMessage*> > SignedMsgGrp;
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* GDP: Represents the center of gxs. In as far as enabling synchronisation between peers
|
* The main role of GDP is the preparation of messages requested from
|
||||||
|
* GXS instance's storage module (RsGeneralStorageService)
|
||||||
*
|
*
|
||||||
* Responsibilty:
|
* It acts as a layer between RsGeneralStorageService and its parent GXS instance
|
||||||
* GDP has access to concrete RsGxs services internal messages by way of a passed
|
* thus allowing for non-blocking requests, etc.
|
||||||
* RsGss (storage module in read only mode)
|
* It also provides caching ability
|
||||||
* 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
|
|
||||||
* and prepare exchange data for RsGnp.
|
|
||||||
* It is also the curator (write authority) of externally received messages
|
|
||||||
*/
|
*/
|
||||||
class RsGdp
|
class RsGeneralDataService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RsGdp();
|
|
||||||
|
/*!
|
||||||
|
* Retrieves signed message
|
||||||
|
* @param msgGrp this contains grp and the message to retrieve
|
||||||
|
* @return request code to be redeemed later
|
||||||
|
*/
|
||||||
|
virtual int request(const MsgGrpId& msgGrp, SignedMsgGrp& result, bool decrypted) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* allows for more complex queries specific to the service
|
||||||
|
* Service should implement method taking case
|
||||||
|
* @param filter generally stores parameters needed for query
|
||||||
|
* @param cacheRequest set to true to cache the messages requested
|
||||||
|
* @return request code to be redeemed later
|
||||||
|
*/
|
||||||
|
virtual int request(RequestFilter* filter, SignedMsgGrp& msgs, bool cacheRequest) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* stores signed message
|
||||||
|
* @param msgs signed messages to store
|
||||||
|
*/
|
||||||
|
virtual bool store(SignedMsgGrp& msgs) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @param grpIds set with grpIds available from storage
|
||||||
|
* @return request code to be redeemed later
|
||||||
|
*/
|
||||||
|
virtual int getGroups(std::set<std::string>& grpIds) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*
|
||||||
|
* @param msgIds gets message ids in storage
|
||||||
|
* @return request code to be redeemed later
|
||||||
|
*/
|
||||||
|
virtual int getMessageIds(std::set<std::string>& msgIds) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* caches message for faster retrieval later
|
||||||
|
* @return false if caching failed, msg may not exist, false otherwise
|
||||||
|
*/
|
||||||
|
virtual bool cacheMsg(const std::string& grpId, const std::string& msgId) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* caches all messages of this grpId for faster retrieval later
|
||||||
|
* @param grpId all message of this grpId are cached
|
||||||
|
* @return false if caching failed, msg may not exist, false otherwise
|
||||||
|
*/
|
||||||
|
bool cacheGrp(const std::string& grpId) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* checks if msg is cached
|
||||||
|
* @param msgId message to check if cached
|
||||||
|
* @param grpId
|
||||||
|
* @return false if caching failed, msg may not exist, false otherwise
|
||||||
|
*/
|
||||||
|
bool msgCached(const std::string& grpId, const std::string& msgId) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* check if messages of the grpId are cached
|
||||||
|
* @param grpId all message of this grpId are checked
|
||||||
|
* @return false if caching failed, msg may not exist, false otherwise
|
||||||
|
*/
|
||||||
|
bool grpCached(const std::string& grpId) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class RsGxsSignedMessage {
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Might be better off simply sending request codes
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class RequestFilter {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual int code() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* General Storage service
|
*
|
||||||
* This presents an abstract interface used by both concrete Gxs services and the Gdp to store
|
* This is implemented by the concrete GXS class to represent to define how \n
|
||||||
* internally and externally generated messages respectively.
|
* RsGxsSignedMessage is stored and retrieved \n
|
||||||
* This abstraction allows GDP to retrieve entries from an SQL lite db without knowledge of the
|
* More complicated queries are enabled through the use of \n
|
||||||
* service db schema (columns basically).
|
* RequestFilter which through rtti store generic parameter used \n
|
||||||
* Concrete services should implement this service
|
* The main reason for layering RsGeneralDataService between this and service implementer \n
|
||||||
|
* is to avoid the overhead of storage access \n
|
||||||
*/
|
*/
|
||||||
class RsGss {
|
class RsGeneralStorageService {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RsGss(RsSqlite*, uint8_t io_stat);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* stores message in associate RsSqlite db
|
* Retrieves signed messages from storage
|
||||||
* if RsGss is in read only mode this function will always \n
|
* @param msgGrp this contains grp and the message to retrieve
|
||||||
* return false
|
|
||||||
*
|
|
||||||
* @param message the message to store
|
|
||||||
* @return true if message successfully stored
|
|
||||||
*/
|
*/
|
||||||
virtual bool store(const RsGxsSignedMessage* message) = 0;
|
virtual void retrieve(const MsgGrpId& msgGrp, SignedMsgGrp& result, bool decrypted) = 0;
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* retrieve message from associate RsSqlite db \n
|
* allows for more complex queries specific to the service
|
||||||
* @param msgId
|
* Service should implement method taking case
|
||||||
* @param message
|
* @param filter
|
||||||
* @return true if successfully retrieved, false otherwise
|
|
||||||
*/
|
*/
|
||||||
virtual bool retrieve(const std::string msgId, RsGxsSignedMessage* message) = 0;
|
virtual void retrieve(RequestFilter* filter, SignedMsgGrp& msgs) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* stores signed message in internal storage
|
||||||
|
* @param msgs signed messages to store
|
||||||
|
*/
|
||||||
|
virtual void store(SignedMsgGrp& msgs) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* retrieves the group ids from storage
|
||||||
|
* @param grpIds set with grpIds available from storage
|
||||||
|
*/
|
||||||
|
virtual void getGroups(std::set<std::string>& grpIds) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* retrieve message in this stored in this storage
|
||||||
|
* @param msgIds gets message ids in storage
|
||||||
|
*/
|
||||||
|
virtual bool getMessageIds(std::set<std::string>& msgIds) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Use this find out if Rss i/o status
|
* Use this find out if Rss i/o status
|
||||||
* @return the io status
|
* @return the io status
|
||||||
*/
|
*/
|
||||||
uint8_t getIoStat();
|
virtual uint8_t getIoStat() = 0;
|
||||||
|
|
||||||
|
static uint8_t IOSTAT_READ_ONLY;
|
||||||
|
static uint8_t IOSTAT_READ_AND_WRITE;
|
||||||
|
|
||||||
static uint8_t READ_ONLY;
|
|
||||||
static uint8_t READ_AND_WRITE;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RSGDP_H
|
#endif // RSGDP_H
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* General Exchange Protocol interface for RetroShare.
|
* General Exchange Protocol interface for RetroShare.
|
||||||
*
|
*
|
||||||
* Copyright 2011-2011 by Robert Fernie.
|
* Copyright 2011-2011 by Robert Fernie, Christopher Evi-Prker
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GIXP: General Identity Exchange Protocol.
|
* GIXP: General Identity Exchange Protocol.
|
||||||
*
|
*
|
||||||
@ -48,7 +49,6 @@
|
|||||||
* 6) This class will use the generalised packet storage for efficient caching & loading.
|
* 6) This class will use the generalised packet storage for efficient caching & loading.
|
||||||
* 7) Data will be stored encrypted.
|
* 7) Data will be stored encrypted.
|
||||||
*/
|
*/
|
||||||
namespace retroshare_gxs {
|
|
||||||
|
|
||||||
class GixsKey
|
class GixsKey
|
||||||
{
|
{
|
||||||
@ -110,7 +110,7 @@ namespace retroshare_gxs {
|
|||||||
* also provides encyption, decryption, verification,
|
* also provides encyption, decryption, verification,
|
||||||
* and signing functionality using any created identities
|
* and signing functionality using any created identities
|
||||||
*/
|
*/
|
||||||
class RsGixs : RsGxs
|
class RsIdentityExchangeService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RsGixs();
|
RsGixs();
|
||||||
@ -119,28 +119,28 @@ namespace retroshare_gxs {
|
|||||||
* creates gixs profile and shares it
|
* creates gixs profile and shares it
|
||||||
* @param profile
|
* @param profile
|
||||||
*/
|
*/
|
||||||
bool createKey(RsGixsProfile& profile); /* fills in mKeyId, and signature */
|
bool createKey(RsGixsProfile& profile) = 0; /* fills in mKeyId, and signature */
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Use to query a whether given key is available by its key reference
|
* Use to query a whether given key is available by its key reference
|
||||||
* @param keyref the keyref of key that is being checked for
|
* @param keyref the keyref of key that is being checked for
|
||||||
* @return true if available, false otherwise
|
* @return true if available, false otherwise
|
||||||
*/
|
*/
|
||||||
bool haveKey(const KeyRef& keyref);
|
bool haveKey(const KeyRef& keyref) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Use to query whether private key member of the given key reference is available
|
* Use to query whether private key member of the given key reference is available
|
||||||
* @param keyref the KeyRef of the key being checked for
|
* @param keyref the KeyRef of the key being checked for
|
||||||
* @return true if private key is held here, false otherwise
|
* @return true if private key is held here, false otherwise
|
||||||
*/
|
*/
|
||||||
bool havePrivateKey(const KeyRef& keyref);
|
bool havePrivateKey(const KeyRef& keyref) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Use to request a given key reference
|
* Use to request a given key reference
|
||||||
* @param keyref the KeyRef of the key being requested
|
* @param keyref the KeyRef of the key being requested
|
||||||
* @return will
|
* @return will
|
||||||
*/
|
*/
|
||||||
bool requestKey(const KeyRef& keyref);
|
bool requestKey(const KeyRef& keyref) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Retrieves a key identity
|
* Retrieves a key identity
|
||||||
@ -148,7 +148,7 @@ namespace retroshare_gxs {
|
|||||||
* @return a pointer to a valid profile if successful, otherwise NULL
|
* @return a pointer to a valid profile if successful, otherwise NULL
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
RsGixsProfile* getProfile(const KeyRef& keyref);
|
RsGixsProfile* getProfile(const KeyRef& keyref) = 0;
|
||||||
|
|
||||||
|
|
||||||
/*** process data ***/
|
/*** process data ***/
|
||||||
@ -161,7 +161,7 @@ namespace retroshare_gxs {
|
|||||||
* @param signature is set with the signature from signing with keyref
|
* @param signature is set with the signature from signing with keyref
|
||||||
* @return false if signing failed, true otherwise
|
* @return false if signing failed, true otherwise
|
||||||
*/
|
*/
|
||||||
bool sign(const KeyRef& keyref, unsigned char* data, uint32_t dataLen, std::string& signature);
|
bool sign(const KeyRef& keyref, unsigned char* data, uint32_t dataLen, std::string& signature) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Verify that the data is signed by the key owner
|
* Verify that the data is signed by the key owner
|
||||||
@ -171,7 +171,7 @@ namespace retroshare_gxs {
|
|||||||
* @param signature
|
* @param signature
|
||||||
* @return false if verification failed, false otherwise
|
* @return false if verification failed, false otherwise
|
||||||
*/
|
*/
|
||||||
bool verify(const KeyRef& keyref, unsigned char* data, int dataLen, std::string& signature);
|
bool verify(const KeyRef& keyref, unsigned char* data, int dataLen, std::string& signature) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Attempt to decrypt data with a given key
|
* Attempt to decrypt data with a given key
|
||||||
@ -183,7 +183,7 @@ namespace retroshare_gxs {
|
|||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
bool decrypt(const KeyRef& keyref, unsigned char* data, int dataLen,
|
bool decrypt(const KeyRef& keyref, unsigned char* data, int dataLen,
|
||||||
unsigned char*& decryptedData, uint32_t& decyptDataLen);
|
unsigned char*& decryptedData, uint32_t& decyptDataLen) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Attempt to encrypt data with a given key
|
* Attempt to encrypt data with a given key
|
||||||
@ -194,10 +194,9 @@ namespace retroshare_gxs {
|
|||||||
* @param encryptDataLen length of encrypted data
|
* @param encryptDataLen length of encrypted data
|
||||||
*/
|
*/
|
||||||
bool encrypt(const KeyRef& keyref, unsigned char* data, int dataLen,
|
bool encrypt(const KeyRef& keyref, unsigned char* data, int dataLen,
|
||||||
unsigned char*& encryptedData, uint32_t& encryptDataLen);
|
unsigned char*& encryptedData, uint32_t& encryptDataLen) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // RSGIXS_H
|
#endif // RSGIXS_H
|
||||||
|
@ -1,39 +1,115 @@
|
|||||||
#ifndef RSGNP_H
|
#ifndef RSGNP_H
|
||||||
#define RSGNP_H
|
#define RSGNP_H
|
||||||
|
|
||||||
#include <set>
|
/*
|
||||||
#include <time.h>
|
* libretroshare/src/gxs: rsgnp.h
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "services/p3service.h"
|
|
||||||
#include "gxs/rsgdp.h"
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Retroshare general network protocol
|
|
||||||
*
|
*
|
||||||
* This simply deals with the receiving and sending
|
* General Exchange Protocol interface for RetroShare.
|
||||||
* RsGxs data
|
*
|
||||||
|
* Copyright 2011-2011 by Robert Fernie, Christopher Evi-Prker
|
||||||
|
*
|
||||||
|
* 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".
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class RsGnp : p3ThreadedService
|
|
||||||
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
#include <time.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <list>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include "gxs/rsgxs.h"
|
||||||
|
|
||||||
|
typedef std::map<std::string, std::set<std::string> > PeerGrp;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Retroshare General Network Exchange Service: \n
|
||||||
|
* This provides a module to service peers requests for GXS message \n
|
||||||
|
* and also request GXS messages from other peers. \n
|
||||||
|
* Users can make a general request for message under a grp id for a peer, all grp ids held \n
|
||||||
|
* by a set of peers. And can also apply to timerange to them
|
||||||
|
* An interface is provided for the observer pattern is provided to alert clients this class
|
||||||
|
* when requests have been served
|
||||||
|
*/
|
||||||
|
class RsNetworktExchangeService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RsGnp();
|
|
||||||
|
RsNetworkExchangeService();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Queries peers for a set of grp ids
|
||||||
|
* @param pg a map of peer to a set of grp ids to query message from
|
||||||
|
* @param from start range of time
|
||||||
|
* @param to end range of time
|
||||||
|
* @return a request code to be kept to redeem query later
|
||||||
|
*/
|
||||||
|
virtual int requestAvailableMsgs(PeerGrp& pg, time_t from, time_t to) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Queries peer for msgs of peer grp id pairs
|
||||||
|
* @param pg peer, grp id peers
|
||||||
|
* @param from start range of time
|
||||||
|
* @param to end range of time
|
||||||
|
* @return a request code to be kept to redeem query later
|
||||||
|
*/
|
||||||
|
virtual int requestMsgs(PeerGrp& pg, time_t from, time_t to) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Queries peers in list for groups avaialble
|
||||||
|
*
|
||||||
|
* @param peers the peers to query
|
||||||
|
* @param from start range of time
|
||||||
|
* @param to end range of time
|
||||||
|
* @return a request code to be kept to redeem query later
|
||||||
|
*/
|
||||||
|
int requestAvailableGrps(const std::set<std::string>& peers, time_t from, time_t to) = 0;
|
||||||
|
|
||||||
|
|
||||||
/*** gdp::iterface *****/
|
/*!
|
||||||
int requestMsgs(std::set<std::string> msgId, double &delay);
|
* When messages are received this function should be call containing the messages
|
||||||
void addGdp(RsGdp* gdp) = 0;
|
* @param msgs the messages received from peers
|
||||||
void removeGdp(RsGdp* gdp) = 0;
|
*/
|
||||||
|
void messageFromPeers(std::list<RsGxsSignedMessage*>& msgs) = 0;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/*** 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, time_t from, time_t to); /* send to peers */
|
* attempt to retrieve requested messages
|
||||||
|
* @param requestCode
|
||||||
|
* @param msgs
|
||||||
|
* @return false if not received, true is requestCode has been redeemed
|
||||||
|
* @see RsGeneralNetExchangeService::requestAvailableGrps()
|
||||||
|
*/
|
||||||
|
bool getRequested(uint32_t requestCode, std::list<RsGxsSignedMessage*>& msgs) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Allows observer pattern for checking if a request has been satisfied
|
||||||
|
*
|
||||||
|
* @param requestCode the code returned msg request functions
|
||||||
|
* @return false if not ready, true otherwise
|
||||||
|
* @see RsGeneralNetExchangeService::requestAvailableGrps()
|
||||||
|
* @see RsGeneralNetExchangeService::requestAvailableMsgs()
|
||||||
|
*/
|
||||||
|
bool requestCodeReady(uint32_t reuqestCode);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
* libretroshare/src/gxs : rsgxs.h
|
* libretroshare/src/gxs : rsgxs.h
|
||||||
*
|
*
|
||||||
* GXS interface for RetroShare.
|
* GXS interface for RetroShare.
|
||||||
|
* Convenience header
|
||||||
*
|
*
|
||||||
* Copyright 2011 Christopher Evi-Parker
|
* Copyright 2011 Christopher Evi-Parker
|
||||||
*
|
*
|
||||||
@ -30,74 +31,23 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "rsgdp.h"
|
#include <string>
|
||||||
#include "util/rsthreads.h"
|
#include <inttypes.h>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Retroshare general exchange service
|
* This is universal format for messages that is transported throughout
|
||||||
* This forms the basic interface that classes need to inherit
|
* the general exchange service chain. From concrete service to
|
||||||
* in order to use the general exchange service
|
|
||||||
* Generally GNP drives the service.
|
|
||||||
* GDP deals with exporting and importing msgs to and from the concrete service
|
|
||||||
* data from the derived class
|
|
||||||
* GXIP is used to maintain
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* The maiin transport mechanism
|
|
||||||
*/
|
*/
|
||||||
class RsGxs : public RsThread
|
class RsGxsSignedMessage {
|
||||||
{
|
|
||||||
public:
|
|
||||||
RsGxs(const std::string& serviceName);
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* @param msgIds the ids of the new msgs received
|
|
||||||
*/
|
|
||||||
virtual void receiveMessage(std::set<std::string>& msgIds) = 0;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Push a set of messages which have been written to your service
|
|
||||||
* database
|
|
||||||
* @param msgIds
|
|
||||||
*/
|
|
||||||
void push(std::set<std::string>& msgIds) = 0;
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* allows for non blocking pushes, receives, and configuration changes.
|
|
||||||
*/
|
|
||||||
void run();
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* cache a message
|
|
||||||
* @param msg message to cache
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void cache(RsGxsSignedMessage* msg);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Queries if message with message id is cached
|
|
||||||
* @param msgId the id of the message to query
|
|
||||||
*/
|
|
||||||
bool cached(std::string& msgId);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Use to retrieve cached msgs
|
|
||||||
* If message id of messages not cached are requested, it is simply ignored
|
|
||||||
* @param requestIds The ids of messages to retrieve
|
|
||||||
* @param msgs the retrieved cached messages
|
|
||||||
*/
|
|
||||||
void retrieveCache(std::set<std::string>& requestIds, std::set<RsGxsSignedMessage*>& msgs);
|
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t timestamp;
|
||||||
|
void* signature;
|
||||||
|
void* data;
|
||||||
|
uint32_t msg_flags; /* encrypted */
|
||||||
|
std::string msgId; /* hash of all message data */
|
||||||
|
std::string grpId;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // RSGXS_H
|
#endif // RSGXS_H
|
||||||
|
Loading…
Reference in New Issue
Block a user