mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-08 22:52:54 -04:00
Mods:
Updated dataservice tests and fixed subsequent bugs added bug fixes for RetroDb and fixed postability issue (removed map.at use) Added: Data access module used as token service gxs service backend (RsGenExchange) RsPhotoV2 which is a modification to deal with different interface provided by RsGenExchange also added subsequent p3photoserviceV2 NxsTestHub to help with testing nxsnetservice (RsGxsNetService is not yet working) git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-new_cache_system@5274 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f05d2f9b09
commit
081b59ee1a
27 changed files with 1529 additions and 395 deletions
|
@ -12,6 +12,7 @@
|
|||
#define KEY_NXS_FILE_LEN std::string("nxsFileLen")
|
||||
#define KEY_NXS_IDENTITY std::string("identity")
|
||||
#define KEY_GRP_ID std::string("grpId")
|
||||
#define KEY_ORIG_GRP_ID std::string("origGrpId")
|
||||
#define KEY_IDENTITY_SIGN std::string("idSign")
|
||||
#define KEY_TIME_STAMP std::string("timeStamp")
|
||||
#define KEY_NXS_FLAGS std::string("flags")
|
||||
|
@ -65,9 +66,10 @@
|
|||
#define COL_GRP_SUBCR_FLAG 7
|
||||
#define COL_GRP_POP 8
|
||||
#define COL_MSG_COUNT 9
|
||||
#define COL_GRP_STATUS 11
|
||||
#define COL_GRP_NAME 12
|
||||
#define COL_GRP_LAST_POST 13
|
||||
#define COL_GRP_STATUS 10
|
||||
#define COL_GRP_NAME 11
|
||||
#define COL_GRP_LAST_POST 12
|
||||
#define COL_ORIG_GRP_ID 13
|
||||
|
||||
// msg col numbers
|
||||
#define COL_PUBLISH_SIGN 5
|
||||
|
@ -110,7 +112,7 @@ RsDataService::RsDataService(const std::string &serviceDir, const std::string &d
|
|||
grpMetaColumns.push_back(KEY_IDENTITY_SIGN); grpMetaColumns.push_back(KEY_NXS_IDENTITY); grpMetaColumns.push_back(KEY_ADMIN_SIGN);
|
||||
grpMetaColumns.push_back(KEY_KEY_SET); grpMetaColumns.push_back(KEY_GRP_SUBCR_FLAG); grpMetaColumns.push_back(KEY_GRP_POP);
|
||||
grpMetaColumns.push_back(KEY_MSG_COUNT); grpMetaColumns.push_back(KEY_GRP_STATUS); grpMetaColumns.push_back(KEY_GRP_NAME);
|
||||
grpMetaColumns.push_back(KEY_GRP_LAST_POST);
|
||||
grpMetaColumns.push_back(KEY_GRP_LAST_POST); grpMetaColumns.push_back(KEY_ORIG_GRP_ID);
|
||||
|
||||
// for retrieving actual grp data
|
||||
grpColumns.push_back(KEY_GRP_ID); grpColumns.push_back(KEY_NXS_FILE); grpColumns.push_back(KEY_NXS_FILE_OFFSET);
|
||||
|
@ -128,23 +130,45 @@ void RsDataService::initialise(){
|
|||
mDb = new RetroDb(mDbName, RetroDb::OPEN_READWRITE_CREATE);
|
||||
|
||||
// create table for msg data
|
||||
mDb->execSQL("CREATE TABLE " + MSG_TABLE_NAME + "(" + KEY_MSG_ID
|
||||
+ " TEXT," + KEY_GRP_ID + " TEXT," + KEY_NXS_FLAGS + " INT," + KEY_ORIG_MSG_ID + " TEXT,"
|
||||
+ KEY_TIME_STAMP + " INT," + KEY_PUBLISH_SIGN + " BLOB," + KEY_NXS_IDENTITY + " TEXT,"
|
||||
+ KEY_IDENTITY_SIGN + " BLOB," + KEY_NXS_FILE + " TEXT,"+ KEY_NXS_FILE_OFFSET + " INT,"
|
||||
+ KEY_MSG_STATUS + " INT," + KEY_CHILD_TS + " INT,"+ KEY_NXS_META + " BLOB,"
|
||||
+ KEY_MSG_THREAD_ID + " TEXT," + KEY_MSG_PARENT_ID + " TEXT,"+ KEY_MSG_NAME + " TEXT,"
|
||||
+ KEY_NXS_FILE_LEN+ " INT);");
|
||||
mDb->execSQL("CREATE TABLE " + MSG_TABLE_NAME + "(" +
|
||||
KEY_MSG_ID + " TEXT," +
|
||||
KEY_GRP_ID + " TEXT," +
|
||||
KEY_NXS_FLAGS + " INT," +
|
||||
KEY_ORIG_MSG_ID + " TEXT," +
|
||||
KEY_TIME_STAMP + " INT," +
|
||||
KEY_PUBLISH_SIGN + " BLOB," +
|
||||
KEY_NXS_IDENTITY + " TEXT," +
|
||||
KEY_IDENTITY_SIGN + " BLOB," +
|
||||
KEY_NXS_FILE + " TEXT,"+
|
||||
KEY_NXS_FILE_OFFSET + " INT," +
|
||||
KEY_MSG_STATUS + " INT," +
|
||||
KEY_CHILD_TS + " INT," +
|
||||
KEY_NXS_META + " BLOB," +
|
||||
KEY_MSG_THREAD_ID + " TEXT," +
|
||||
KEY_MSG_PARENT_ID + " TEXT,"+
|
||||
KEY_MSG_NAME + " TEXT," +
|
||||
KEY_NXS_FILE_LEN + " INT);");
|
||||
|
||||
// create table for grp data
|
||||
mDb->execSQL("CREATE TABLE " + GRP_TABLE_NAME + "(" + KEY_GRP_ID +
|
||||
" TEXT," + KEY_TIME_STAMP + " INT," +
|
||||
KEY_ADMIN_SIGN + " BLOB," + " BLOB," + KEY_NXS_FILE +
|
||||
" TEXT," + KEY_NXS_FILE_OFFSET + " INT," + KEY_KEY_SET + " BLOB," + KEY_NXS_FILE_LEN + " INT,"
|
||||
+ KEY_NXS_META + " BLOB," + KEY_GRP_NAME + " TEXT," + KEY_GRP_LAST_POST + " INT,"
|
||||
+ KEY_GRP_LAST_POST + " INT," + KEY_GRP_POP + " INT," + KEY_MSG_COUNT + " INT,"
|
||||
+ KEY_GRP_SUBCR_FLAG + " INT," + KEY_GRP_STATUS + " INT,"
|
||||
+ KEY_NXS_IDENTITY + " TEXT," + KEY_NXS_FLAGS + " INT," + KEY_IDENTITY_SIGN + " BLOB);");
|
||||
mDb->execSQL("CREATE TABLE " + GRP_TABLE_NAME + "(" +
|
||||
KEY_GRP_ID + " TEXT," +
|
||||
KEY_TIME_STAMP + " INT," +
|
||||
KEY_ADMIN_SIGN + " BLOB," + " BLOB," +
|
||||
KEY_NXS_FILE + " TEXT," +
|
||||
KEY_NXS_FILE_OFFSET + " INT," +
|
||||
KEY_KEY_SET + " BLOB," +
|
||||
KEY_NXS_FILE_LEN + " INT," +
|
||||
KEY_NXS_META + " BLOB," +
|
||||
KEY_GRP_NAME + " TEXT," +
|
||||
KEY_GRP_LAST_POST + " INT," +
|
||||
KEY_GRP_POP + " INT," +
|
||||
KEY_MSG_COUNT + " INT," +
|
||||
KEY_GRP_SUBCR_FLAG + " INT," +
|
||||
KEY_GRP_STATUS + " INT," +
|
||||
KEY_NXS_IDENTITY + " TEXT," +
|
||||
KEY_ORIG_GRP_ID + " TEXT," +
|
||||
KEY_NXS_FLAGS + " INT," +
|
||||
KEY_IDENTITY_SIGN + " BLOB);");
|
||||
|
||||
}
|
||||
|
||||
|
@ -154,7 +178,7 @@ RsGxsGrpMetaData* RsDataService::getGrpMeta(RetroCursor &c)
|
|||
|
||||
bool ok = true;
|
||||
|
||||
// for manipulating raw data
|
||||
// for extracting raw data
|
||||
uint32_t offset = 0;
|
||||
char* data = NULL;
|
||||
uint32_t data_len = 0;
|
||||
|
@ -165,14 +189,15 @@ RsGxsGrpMetaData* RsDataService::getGrpMeta(RetroCursor &c)
|
|||
// required definition of a group
|
||||
ok &= !grpMeta->mGroupId.empty();
|
||||
|
||||
// identity if any
|
||||
|
||||
c.getString(COL_IDENTITY, grpMeta->mAuthorId);
|
||||
c.getString(COL_GRP_NAME, grpMeta->mGroupName);
|
||||
c.getString(COL_ORIG_GRP_ID, grpMeta->mOrigGrpId);
|
||||
|
||||
grpMeta->mPublishTs = c.getInt32(COL_TIME_STAMP);
|
||||
grpMeta->mGroupFlags = c.getInt32(COL_NXS_FLAGS);
|
||||
|
||||
|
||||
// identity if any
|
||||
if(!grpMeta->mAuthorId.empty() && ok){
|
||||
offset = 0;
|
||||
data = (char*)c.getData(COL_IDENTITY_SIGN, data_len);
|
||||
|
@ -215,7 +240,6 @@ RsNxsGrp* RsDataService::getGroup(RetroCursor &c)
|
|||
* grpId, pub admin and pub publish key
|
||||
* necessary for successful group
|
||||
*/
|
||||
|
||||
RsNxsGrp* grp = new RsNxsGrp(mServType);
|
||||
bool ok = true;
|
||||
|
||||
|
@ -295,6 +319,7 @@ RsGxsMsgMetaData* RsDataService::getMsgMeta(RetroCursor &c)
|
|||
msgMeta->mPublishTs = c.getInt32(COL_TIME_STAMP);
|
||||
|
||||
offset = 0; data_len = 0;
|
||||
|
||||
if(ok){
|
||||
|
||||
data = (char*)c.getData(COL_PUBLISH_SIGN, data_len);
|
||||
|
@ -419,6 +444,7 @@ int RsDataService::storeMessage(std::map<RsNxsMsg *, RsGxsMsgMetaData *> &msg)
|
|||
|
||||
cv.put(KEY_MSG_PARENT_ID, msgMetaPtr->mParentId);
|
||||
cv.put(KEY_MSG_THREAD_ID, msgMetaPtr->mThreadId);
|
||||
cv.put(KEY_ORIG_MSG_ID, msgMetaPtr->mOrigMsgId);
|
||||
cv.put(KEY_MSG_NAME, msgMetaPtr->mMsgName);
|
||||
|
||||
// now local meta
|
||||
|
@ -466,7 +492,9 @@ int RsDataService::storeGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
|
|||
cv.put(KEY_NXS_FILE_OFFSET, (int32_t)offset);
|
||||
cv.put(KEY_NXS_FILE_LEN, (int32_t)grpPtr->grp.TlvSize());
|
||||
cv.put(KEY_NXS_FILE, grpFile);
|
||||
cv.put(KEY_GRP_ID, grpMetaPtr->mGroupId);
|
||||
cv.put(KEY_GRP_ID, grpPtr->grpId);
|
||||
cv.put(KEY_GRP_NAME, grpMetaPtr->mGroupName);
|
||||
cv.put(KEY_ORIG_GRP_ID, grpMetaPtr->mOrigGrpId);
|
||||
cv.put(KEY_NXS_FLAGS, (int32_t)grpMetaPtr->mGroupFlags);
|
||||
cv.put(KEY_TIME_STAMP, (int32_t)grpMetaPtr->mPublishTs);
|
||||
|
||||
|
@ -560,6 +588,8 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
|
|||
|
||||
if(c)
|
||||
retrieveMessages(c, msgSet);
|
||||
|
||||
delete c;
|
||||
}else{
|
||||
|
||||
// request each grp
|
||||
|
@ -567,12 +597,18 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
|
|||
|
||||
for(; sit!=msgIdSet.end();sit++){
|
||||
const std::string& msgId = *sit;
|
||||
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, msgColumns, KEY_GRP_ID+ "='" + grpId + "','" + msgId + "'", "");
|
||||
retrieveMessages(c, msgSet);
|
||||
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, msgColumns, KEY_GRP_ID+ "='" + grpId
|
||||
+ "' AND " + KEY_MSG_ID + "='" + msgId + "'", "");
|
||||
|
||||
if(c)
|
||||
retrieveMessages(c, msgSet);
|
||||
|
||||
delete c;
|
||||
}
|
||||
}
|
||||
|
||||
msg[grpId] = msgSet;
|
||||
msgSet.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -621,6 +657,7 @@ int RsDataService::retrieveGxsMsgMetaData(const std::vector<std::string> &grpIds
|
|||
|
||||
msgMeta[grpId] = meta;
|
||||
}
|
||||
delete c;
|
||||
|
||||
}
|
||||
return 1;
|
||||
|
@ -645,6 +682,7 @@ int RsDataService::retrieveGxsGrpMetaData(std::map<std::string, RsGxsGrpMetaData
|
|||
valid = c->moveToNext();
|
||||
}
|
||||
}
|
||||
delete c;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -43,8 +43,6 @@ public:
|
|||
|
||||
virtual ~RsGxsSearchModule();
|
||||
|
||||
virtual bool searchMsg(const RsGxsSearch&, RsGxsMsg* msg) = 0;
|
||||
virtual bool searchGroup(const RsGxsSearch&, RsGxsGroup* grp) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,110 @@
|
|||
#include "rsgenexchange.h"
|
||||
|
||||
RsGenExchange::RsGenExchange()
|
||||
RsGenExchange::RsGenExchange(RsGeneralDataService *gds,
|
||||
RsNetworkExchangeService *ns, RsSerialType *serviceSerialiser)
|
||||
: mReqMtx("GenExchange"), mDataStore(gds), mNetService(ns), mSerialiser(serviceSerialiser)
|
||||
{
|
||||
|
||||
mDataAccess = new RsGxsDataAccess(gds, mSerialiser);
|
||||
|
||||
}
|
||||
|
||||
RsGenExchange::~RsGenExchange()
|
||||
{
|
||||
|
||||
// need to destruct in a certain order
|
||||
delete mNetService;
|
||||
|
||||
delete mDataAccess;
|
||||
mDataAccess = NULL;
|
||||
|
||||
delete mDataStore;
|
||||
mDataStore = NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void RsGenExchange::tick()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool RsGenExchange::getGroupList(const uint32_t &token, std::list<std::string> &groupIds)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RsGenExchange::getMsgList(const uint32_t &token,
|
||||
std::map<std::string, std::vector<std::string> > &msgIds)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RsGenExchange::getGroupMeta(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RsGenExchange::getMsgMeta(const uint32_t &token,
|
||||
std::map<std::string, std::vector<RsMsgMetaData> > &msgInfo)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem *> grpItem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RsGenExchange::getMsgData(const uint32_t &token,
|
||||
std::map<std::string, std::vector<RsGxsMsgItem *> > &msgItems)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RsTokenService* RsGenExchange::getTokenService()
|
||||
{
|
||||
return mDataAccess;
|
||||
}
|
||||
|
||||
|
||||
void RsGenExchange::notifyNewGroups(std::vector<RsNxsGrp *> &groups)
|
||||
{
|
||||
std::vector<RsNxsGrp*>::iterator vit = groups.begin();
|
||||
|
||||
// store these for tick() to pick them up
|
||||
for(; vit != groups.end(); vit++)
|
||||
mReceivedGrps.push_back(*vit);
|
||||
|
||||
}
|
||||
|
||||
void RsGenExchange::notifyNewMessages(std::vector<RsNxsMsg *> messages)
|
||||
{
|
||||
std::vector<RsNxsMsg*>::iterator vit = messages.begin();
|
||||
|
||||
// store these for tick() to pick them up
|
||||
for(; vit != messages.end(); vit++)
|
||||
mReceivedMsgs.push_back(*vit);
|
||||
|
||||
}
|
||||
|
||||
bool RsGenExchange::subscribeToGroup(std::string &grpId, bool subscribe)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RsGenExchange::publishGroup(RsGxsGrpItem *grpItem)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RsGenExchange::publishMsg(RsGxsMsgItem *msgItem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -4,17 +4,200 @@
|
|||
#include <queue>
|
||||
|
||||
#include "rsgxs.h"
|
||||
#include "rsgds.h"
|
||||
#include "rsnxs.h"
|
||||
#include "rsgxsdataaccess.h"
|
||||
#include "retroshare/rsgxsservice.h"
|
||||
#include "serialiser/rsnxsitems.h"
|
||||
|
||||
class gxsRequest
|
||||
{
|
||||
public:
|
||||
uint32_t token;
|
||||
uint32_t reqTime;
|
||||
|
||||
uint32_t ansType;
|
||||
uint32_t reqType;
|
||||
RsTokReqOptions Options;
|
||||
|
||||
uint32_t status;
|
||||
|
||||
class RsGenExchange // : public RsGxsService
|
||||
std::list<std::string> inList;
|
||||
std::list<std::string> outList;
|
||||
//std::map<std::string, void *> readyData;
|
||||
};
|
||||
|
||||
/*!
|
||||
* This should form the parent class to \n
|
||||
* all gxs services. This provides access to service's msg/grp data \n
|
||||
* management/publishing/sync features
|
||||
*
|
||||
* Features: \n
|
||||
* a. Data Access:
|
||||
* Provided by handle to RsTokenService. This ensure consistency
|
||||
* of requests and hiearchy of groups -> then messages which are
|
||||
* sectioned by group ids.
|
||||
* The one caveat is that redemption of tokens are done through
|
||||
* the backend of this class
|
||||
* b. Publishing:
|
||||
* Methods are provided to publish msg and group items and also make
|
||||
* changes to meta information of both item types
|
||||
* c. Sync/Notification:
|
||||
* Also notifications are made here on receipt of new data from
|
||||
* connected peers
|
||||
*/
|
||||
class RsGenExchange : public RsGxsService
|
||||
{
|
||||
public:
|
||||
RsGenExchange();
|
||||
|
||||
/*!
|
||||
* Constructs a RsGenExchange object, the owner ship of gds, ns, and serviceserialiser passes
|
||||
* onto the constructed object
|
||||
* @param gds Data service needed to act as store of message
|
||||
* @param ns Network service needed to synchronise data with rs peers
|
||||
* @param serviceSerialiser The users service needs this \n
|
||||
* in order for gen exchange to deal with its data types
|
||||
*/
|
||||
RsGenExchange(RsGeneralDataService* gds, RsNetworkExchangeService* ns, RsSerialType* serviceSerialiser);
|
||||
|
||||
virtual ~RsGenExchange();
|
||||
|
||||
|
||||
/*!
|
||||
* @param messages messages are deleted after function returns
|
||||
*/
|
||||
void notifyNewMessages(std::vector<RsNxsMsg*> messages);
|
||||
|
||||
/*!
|
||||
* @param messages messages are deleted after function returns
|
||||
*/
|
||||
void notifyNewGroups(std::vector<RsNxsGrp*>& groups);
|
||||
|
||||
|
||||
/*!
|
||||
* This is called by Gxs service runner
|
||||
* periodically, use to implement non
|
||||
* blocking calls
|
||||
*/
|
||||
void tick();
|
||||
|
||||
/*!
|
||||
*
|
||||
* @return handle to token service handle for making
|
||||
* request to this gxs service
|
||||
*/
|
||||
RsTokenService* getTokenService();
|
||||
|
||||
public:
|
||||
|
||||
/** data access functions **/
|
||||
|
||||
/*!
|
||||
* Retrieve group list for a given token
|
||||
* @param token
|
||||
* @param groupIds
|
||||
* @return false if token cannot be redeemed, if false you may have tried to redeem when not ready
|
||||
*/
|
||||
bool getGroupList(const uint32_t &token, std::list<std::string> &groupIds);
|
||||
|
||||
/*!
|
||||
* Retrieve msg list for a given token sectioned by group Ids
|
||||
* @param token token to be redeemed
|
||||
* @param msgIds a map of grpId -> msgList (vector)
|
||||
*/
|
||||
bool getMsgList(const uint32_t &token, std::map<std::string, std::vector<std::string> > &msgIds);
|
||||
|
||||
|
||||
/*!
|
||||
* retrieve group meta data associated to a request token
|
||||
* @param token
|
||||
* @param groupInfo
|
||||
*/
|
||||
bool getGroupMeta(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo);
|
||||
|
||||
/*!
|
||||
* retrieves message meta data associated to a request token
|
||||
* @param token token to be redeemed
|
||||
* @param msgInfo the meta data to be retrieved for token store here
|
||||
*/
|
||||
bool getMsgMeta(const uint32_t &token, std::map<std::string, std::vector<RsMsgMetaData> > &msgInfo);
|
||||
|
||||
/*!
|
||||
* retrieves group data associated to a request token
|
||||
* @param token token to be redeemed for grpitem retrieval
|
||||
* @param grpItem the items to be retrieved for token are stored here
|
||||
*/
|
||||
bool getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem*> grpItem);
|
||||
|
||||
/*!
|
||||
* retrieves message data associated to a request token
|
||||
* @param token token to be redeemed for message item retrieval
|
||||
* @param msgItems
|
||||
*/
|
||||
bool getMsgData(const uint32_t &token, std::map<std::string, std::vector<RsGxsMsgItem*> >& msgItems);
|
||||
|
||||
public:
|
||||
|
||||
/** Modifications **/
|
||||
|
||||
/*!
|
||||
* Enables publication of a group item
|
||||
* If the item exists already this is simply versioned
|
||||
* This will induce a related change message
|
||||
* @param grpItem
|
||||
* @param
|
||||
*/
|
||||
bool publishGroup(RsGxsGrpItem* grpItem);
|
||||
|
||||
/*!
|
||||
* Enables publication of a message item
|
||||
* If the item exists already this is simply versioned
|
||||
* This will induce a related a change message
|
||||
* @param msgItem
|
||||
* @return false if msg creation failed.
|
||||
*/
|
||||
bool publishMsg(RsGxsMsgItem* msgItem);
|
||||
|
||||
|
||||
/*!
|
||||
*
|
||||
* @param grpId
|
||||
* @param subscribe
|
||||
* @return false subscription fails
|
||||
*/
|
||||
bool subscribeToGroup(std::string& grpId, bool subscribe);
|
||||
|
||||
protected:
|
||||
|
||||
/** Notifications **/
|
||||
|
||||
/*!
|
||||
* This confirm this class as an abstract one that \n
|
||||
* should not be instantiated \n
|
||||
* The deriving class should implement this function \n
|
||||
* as its is called by the backend GXS system to \n
|
||||
* update client of changes which should \n
|
||||
* instigate client to retrieve new content from system
|
||||
* @param changes the changes that have occured to data held by this service
|
||||
*/
|
||||
virtual void notifyChanges(std::vector<RsGxsChange*>& changes) = 0;
|
||||
|
||||
private:
|
||||
|
||||
RsMutex mReqMtx;
|
||||
std::map<uint32_t, gxsRequest> mRequests;
|
||||
RsGxsDataAccess* mDataAccess;
|
||||
RsGeneralDataService* mDataStore;
|
||||
RsNetworkExchangeService *mNetService;
|
||||
RsSerialType *mSerialiser;
|
||||
|
||||
std::vector<RsNxsMsg*> mReceivedMsgs;
|
||||
std::vector<RsNxsGrp*> mReceivedGrps;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
std::vector<RsGxsChange*> mChanges;
|
||||
};
|
||||
|
||||
#endif // RSGENEXCHANGE_H
|
||||
|
|
|
@ -38,252 +38,20 @@
|
|||
#include <set>
|
||||
#include <map>
|
||||
|
||||
#include "serialiser/rsgxsitems.h"
|
||||
#include "rsnxsobserver.h"
|
||||
#include "rsnxs.h"
|
||||
#include "rsgds.h"
|
||||
|
||||
#define GXS_STATUS_GRP_NOT_FOUND 1 /* request resulted in grp not found error */
|
||||
#define GXS_STATUS_MSG_NOT_FOUND 2 /* request resulted in msg not found */
|
||||
#define GXS_STATUS_ERROR 3 /* request is in error */
|
||||
#define GXS_STATUS_OK 4 /* request was successful */
|
||||
|
||||
typedef uint64_t RsGroupId ;
|
||||
|
||||
class RsTokReqOptions
|
||||
{
|
||||
public:
|
||||
RsTokReqOptions() { mOptions = 0; mBefore = 0; mAfter = 0; }
|
||||
|
||||
uint32_t mOptions;
|
||||
time_t mBefore;
|
||||
time_t mAfter;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* The whole idea is to provide a broad enough base class from which
|
||||
* all the services listed in gxs/db_apps.h can be implemented
|
||||
* The exchange service features a token redemption request/receive
|
||||
* design in which services make as request to the underlying base
|
||||
* class which returns a token which the service should redeem later
|
||||
* when the request's corresponding receive is called later
|
||||
* Main functionality: \n
|
||||
*
|
||||
* Compared to previous cache-system, some improvements are: \n
|
||||
*
|
||||
* On-demand: There is granularity both in time and hiearchy on whats \n
|
||||
* locally resident, all this is controlled by service \n
|
||||
* * hiearchy - only grps are completely sync'd, have to request msgs \n
|
||||
* * time - grps and hence messages to sync if in time range, grps locally resident but outside range are kept \n
|
||||
*
|
||||
* Search: \n
|
||||
* User can provide search terms (RsGxsSearchItem) that each service can use to retrieve \n
|
||||
* information on items and groups available in their exchange network \n
|
||||
*
|
||||
*
|
||||
* Actual data exchanging: \n
|
||||
* Currently naming convention is a bit confused between 'items' or 'messages' \n
|
||||
* - consider item and msgs to be the same for now, RsGxsId, gives easy means of associate msgs to grps \n
|
||||
* - all data is received via call back \n
|
||||
* - therefore interface to UI should not be based on being alerted to msg availability \n
|
||||
*/
|
||||
class RsGxsService : public RsNxsObserver
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
RsGxsService(RsGeneralDataService* gds, RsNetworkExchangeService* ns);
|
||||
RsGxsService();
|
||||
virtual ~RsGxsService();
|
||||
|
||||
/***************** Group request receive API ********************/
|
||||
virtual void tick() = 0;
|
||||
|
||||
/*!
|
||||
* It is critical this service implements
|
||||
* this function and returns a valid service id
|
||||
* @return the service type of the Gxs Service
|
||||
*/
|
||||
virtual uint16_t getServiceType() const = 0;
|
||||
|
||||
/*!
|
||||
* Request group information
|
||||
* @param token this initialised with a token that can be redeemed for this request
|
||||
* @param ansType type of group result wanted, summary
|
||||
* @param opts token options
|
||||
* @param groupIds list of group ids wanted, leaving this empty will result in a request for only list of group ids for the service
|
||||
* @return false if request failed, true otherwise
|
||||
* @see receiveGrp()
|
||||
*/
|
||||
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &groupIds);
|
||||
|
||||
/*!
|
||||
* Request message information for a list of groups
|
||||
* @param token this initialised with a token that can be redeemed for this request
|
||||
* @param ansType type of msg info result
|
||||
* @param opts token options
|
||||
* @param groupIds groups ids for which message info will be requested
|
||||
* @return false if request failed, true otherwise
|
||||
* @see receiveGrp()
|
||||
*/
|
||||
virtual bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &groupIds);
|
||||
|
||||
/*!
|
||||
* Request message information for a list of groups
|
||||
* @param token this initialised with a token that can be redeemed for this request
|
||||
* @param ansType type of msg info result
|
||||
* @param opts token options
|
||||
* @param groupIds groups ids for which message info will be requested
|
||||
* @return false if request failed, true otherwise
|
||||
* @see receiveGrp()
|
||||
*/
|
||||
bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &msgIds);
|
||||
|
||||
/*********** Start: publication *****************/
|
||||
|
||||
/*!
|
||||
* Pushes a RsGxsItem for publication
|
||||
* @param msg set of messages to push onto service for publication
|
||||
*/
|
||||
int pushMsg(std::set<RsGxsMsg*>& msg);
|
||||
|
||||
/*!
|
||||
* Updates an already published message
|
||||
* on your network with this one
|
||||
* Message must be associated to an identity on
|
||||
* publication for this to work
|
||||
* @param msg the message to update
|
||||
* @return
|
||||
*/
|
||||
int updateMsg(std::set<RsGxsMsg*>& msg);
|
||||
|
||||
|
||||
/*!
|
||||
* Pushes a RsGxsGroup on RsGxsNetwork and associates it with a \n
|
||||
* given RsGixs profile
|
||||
* @param grp group to push onto network
|
||||
|
||||
* @return error code
|
||||
*/
|
||||
int pushGrp(const RsGxsGroup& grp);
|
||||
|
||||
/*!
|
||||
* Update an already published group with
|
||||
* new information
|
||||
* This increments the version number
|
||||
* @param grp grp to update
|
||||
* @return token to be redeemed
|
||||
*/
|
||||
int updateGrp(const RsGxsGroup& grp);
|
||||
|
||||
|
||||
/*********** End: publication *****************/
|
||||
|
||||
/****************************************************************************************************/
|
||||
// Interface for Message Read Status
|
||||
// At the moment this is overloaded to handle autodownload flags too.
|
||||
// This is a configuration thing.
|
||||
/****************************************************************************************************/
|
||||
|
||||
/*********** Start: Update of groups/messages locally *****************/
|
||||
|
||||
/*!
|
||||
* flags latest message in store as read or not read
|
||||
* @param GrpMsgMap flags this msg,version pair as read
|
||||
* @param read set to true for read and false for unread
|
||||
*/
|
||||
int flagMsgRead(const std::string& msgId, bool read) ;
|
||||
|
||||
|
||||
/*!
|
||||
* To flag group as read or not read
|
||||
* @param grpId the
|
||||
* @param
|
||||
*/
|
||||
int flagGroupRead(const std::string grpId, bool read);
|
||||
|
||||
/*!
|
||||
* This marks a local message created by yourself to
|
||||
* no longer distributed and removed
|
||||
* Entry in db is discarded after expiration date has passed
|
||||
* TODO: this may send a standard marker to user that message
|
||||
* should be removed
|
||||
* @param msgId
|
||||
*/
|
||||
int requestDeleteMsg(const RsGxsMsg& msg);
|
||||
|
||||
/*!
|
||||
* This is grpId is marked in database to be removed
|
||||
* and not circulated. Entry will later be removed
|
||||
* once discard age is reached
|
||||
*/
|
||||
bool requestDeleteGrp(uint32_t& token, const RsGxsGroup& grp);
|
||||
|
||||
|
||||
/*!
|
||||
* Use to subscribe or unsubscribe to group
|
||||
* @param grpId the id of the group to scubscribe to
|
||||
* @param subscribe set to false to unsubscribe and true otherwise
|
||||
* @return token to redeem
|
||||
*/
|
||||
bool requestSubscribeToGrp(uint32_t token, const std::string& grpId, bool subscribe);
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
* This called by event runner on status of subscription
|
||||
* @param token the token to be redeemed
|
||||
* @param errCode error code, can be exchanged for error string
|
||||
* @param gxsStatus the status of subscription request
|
||||
*/
|
||||
virtual void receiveSubscribeToGrp(int token, int errCode);
|
||||
|
||||
/*!
|
||||
*
|
||||
* @param error_code
|
||||
* @param errorMsg
|
||||
*/
|
||||
virtual void statusMsg(int error_code, const std::string& errorMsg);
|
||||
|
||||
/******************* End: Configuration *************************/
|
||||
|
||||
/****************** Start: Notifications from event runner ***************/
|
||||
|
||||
/*!
|
||||
* This is called by event runner when a group or groups \n
|
||||
* have been updated or newly arrived
|
||||
* @param grpId ids of groups that have changed or newly arrived
|
||||
*/
|
||||
virtual void notifyGroupChanged(std::list<std::string> grpIds);
|
||||
|
||||
|
||||
/*!
|
||||
* This is called by event runner when a msg or msg \n
|
||||
* have been updated or newly arrived
|
||||
* @param msgId ids of msgs that have changed or newly arrived
|
||||
*/
|
||||
virtual void notifyMsgChanged(std::list<std::string> msgId);
|
||||
|
||||
|
||||
/****************** End: Notifications from event runner ***************/
|
||||
|
||||
// Users can either search groups or messages
|
||||
|
||||
|
||||
/* Generic Lists */
|
||||
bool getGroupList(const uint32_t &token, std::list<std::string> &groupIds);
|
||||
bool getMsgList(const uint32_t &token, std::list<std::string> &msgIds);
|
||||
|
||||
|
||||
|
||||
/* Poll */
|
||||
uint32_t requestStatus(const uint32_t token);
|
||||
|
||||
/* Cancel Request */
|
||||
bool cancelRequest(const uint32_t &token);
|
||||
|
||||
bool groupShareKeys(const std::string &groupId, std::list<std::string>& peers);
|
||||
};
|
||||
|
||||
#endif // RSGXS_H
|
||||
|
|
|
@ -83,5 +83,4 @@ public:
|
|||
|
||||
|
||||
|
||||
|
||||
#endif // RSGXSMETA_H
|
||||
|
|
5
libretroshare/src/gxs/rsgxsdataaccess.cpp
Normal file
5
libretroshare/src/gxs/rsgxsdataaccess.cpp
Normal file
|
@ -0,0 +1,5 @@
|
|||
#include "rsgxsdataaccess.h"
|
||||
|
||||
RsGxsDataAccess::RsGxsDataAccess()
|
||||
{
|
||||
}
|
114
libretroshare/src/gxs/rsgxsdataaccess.h
Normal file
114
libretroshare/src/gxs/rsgxsdataaccess.h
Normal file
|
@ -0,0 +1,114 @@
|
|||
#ifndef RSGXSDATAACCESS_H
|
||||
#define RSGXSDATAACCESS_H
|
||||
|
||||
#include "rstokenservice.h"
|
||||
#include "rsgds.h"
|
||||
|
||||
class RsGxsDataAccess : public RsTokenService
|
||||
{
|
||||
public:
|
||||
RsGxsDataAccess(RsGeneralDataService* ds, RsSerialType* serviceSerialiser);
|
||||
virtual ~RsGxsDataAccess() { return ;}
|
||||
|
||||
public:
|
||||
|
||||
/** start: From RsTokenService **/
|
||||
|
||||
bool requestGroupInfo( uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &groupIds);
|
||||
bool requestMsgInfo( uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &groupIds);
|
||||
bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &msgIds);
|
||||
bool requestGroupSubscribe(uint32_t &token, const std::string &groupId, bool subscribe);
|
||||
|
||||
/* Poll */
|
||||
uint32_t requestStatus(const uint32_t token);
|
||||
|
||||
/* Cancel Request */
|
||||
bool cancelRequest(const uint32_t &token);
|
||||
|
||||
/** end : From RsTokenService **/
|
||||
|
||||
public:
|
||||
|
||||
void processRequests();
|
||||
|
||||
/*!
|
||||
* Retrieve group list for a given token
|
||||
* @param token request token to be redeemed
|
||||
* @param groupIds
|
||||
* @param msgIds
|
||||
* @return false if token cannot be redeemed, if false you may have tried to redeem when not ready
|
||||
*/
|
||||
bool getGroupList(const uint32_t &token, std::list<std::string> &groupIds);
|
||||
|
||||
/*!
|
||||
*
|
||||
* @param token request token to be redeemed
|
||||
* @param msgIds
|
||||
*/
|
||||
bool getMsgList(const uint32_t &token, std::list<std::string> &msgIds);
|
||||
|
||||
|
||||
/*!
|
||||
* @param token request token to be redeemed
|
||||
* @param groupInfo
|
||||
*/
|
||||
bool getGroupSummary(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo);
|
||||
|
||||
/*!
|
||||
*
|
||||
* @param token request token to be redeemed
|
||||
* @param msgInfo
|
||||
*/
|
||||
bool getMsgSummary(const uint32_t &token, std::list<RsMsgMetaData> &msgInfo);
|
||||
|
||||
/*!
|
||||
*
|
||||
* @param token request token to be redeemed
|
||||
* @param grpItem
|
||||
*/
|
||||
bool getGroupData(const uint32_t &token, RsGxsGrpItem* grpItem);
|
||||
|
||||
/*!
|
||||
*
|
||||
* @param token request token to be redeemed
|
||||
* @param msgItems
|
||||
* @return false if
|
||||
*/
|
||||
bool getMsgData(const uint32_t &token, std::vector<RsGxsMsgItem*> msgItems);
|
||||
|
||||
private:
|
||||
|
||||
/** helper functions to implement token service **/
|
||||
|
||||
bool generateToken(uint32_t &token);
|
||||
bool storeRequest(const uint32_t &token, const uint32_t &ansType, const RsTokReqOptions &opts,
|
||||
const uint32_t &type, const std::list<std::string> &ids);
|
||||
bool clearRequest(const uint32_t &token);
|
||||
|
||||
bool updateRequestStatus(const uint32_t &token, const uint32_t &status);
|
||||
bool updateRequestInList(const uint32_t &token, std::list<std::string> ids);
|
||||
bool updateRequestOutList(const uint32_t &token, std::list<std::string> ids);
|
||||
bool checkRequestStatus(const uint32_t &token, uint32_t &status, uint32_t &reqtype, uint32_t &anstype, time_t &ts);
|
||||
|
||||
// special ones for testing (not in final design)
|
||||
bool tokenList(std::list<uint32_t> &tokens);
|
||||
bool popRequestInList(const uint32_t &token, std::string &id);
|
||||
bool popRequestOutList(const uint32_t &token, std::string &id);
|
||||
|
||||
|
||||
virtual bool getGroupList(uint32_t &token, const RsTokReqOptions &opts,
|
||||
const std::list<std::string> &groupIds, std::list<std::string> &outGroupIds);
|
||||
|
||||
virtual bool getMsgList(uint32_t &token, const RsTokReqOptions &opts,
|
||||
const std::list<std::string> &groupIds, std::list<std::string> &outMsgIds);
|
||||
|
||||
virtual bool getMsgRelatedList(uint32_t &token, const RsTokReqOptions &opts,
|
||||
const std::list<std::string> &msgIds, std::list<std::string> &outMsgIds);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // RSGXSDATAACCESS_H
|
|
@ -1,9 +1,9 @@
|
|||
#include "rsgxsnetservice.h"
|
||||
|
||||
RsGxsNetService::RsGxsNetService(uint16_t servType,
|
||||
RsGeneralDataService *gds, RsNxsObserver *nxsObs)
|
||||
: p3Config(servType), mServType(servType), mDataStore(gds),
|
||||
mObserver(nxsObs), mNxsMutex("RsGxsNetService")
|
||||
RsGxsNetService::RsGxsNetService(uint16_t servType, RsGeneralDataService *gds,
|
||||
RsNxsNetMgr *netMgr, RsNxsObserver *nxsObs)
|
||||
: p3Config(servType), p3ThreadedService(servType), mServType(servType), mDataStore(gds),
|
||||
mObserver(nxsObs), mNxsMutex("RsGxsNetService"), mNetMgr(netMgr)
|
||||
|
||||
{
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "rsnxs.h"
|
||||
#include "rsgds.h"
|
||||
#include "rsnxsobserver.h"
|
||||
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "serialiser/rsnxsitems.h"
|
||||
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
|
@ -24,7 +24,7 @@ class NxsTransaction
|
|||
|
||||
public:
|
||||
|
||||
static const uint8_t FLAG_STATE_STARTING; // when
|
||||
static const uint8_t FLAG_STATE_STARTING; // when
|
||||
static const uint8_t FLAG_STATE_RECEIVING; // begin receiving items for incoming trans
|
||||
static const uint8_t FLAG_STATE_SENDING; // begin sending items for outgoing trans
|
||||
static const uint8_t FLAG_STATE_COMPLETED;
|
||||
|
@ -50,18 +50,29 @@ public:
|
|||
std::list<RsNxsItem*> mItems; // items received or sent
|
||||
};
|
||||
|
||||
class NxsGrpSyncTrans : public NxsTransaction {
|
||||
|
||||
class RsNxsNetMgr
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
virtual std::string getOwnId() = 0;
|
||||
virtual void getOnlineList(std::set<std::string>& ssl_peers) = 0;
|
||||
|
||||
};
|
||||
|
||||
class NxsMsgSyncTrans : public NxsTransaction {
|
||||
//class RsNxsNetMgrImpl : public RsNxsNetMgrImpl
|
||||
//{
|
||||
|
||||
public:
|
||||
std::string mGrpId;
|
||||
};
|
||||
//public:
|
||||
|
||||
// RsNxsNetMgrImpl(p3LinkMgr* lMgr);
|
||||
|
||||
// std::string getOwnId();
|
||||
// void getOnlineList(std::set<std::string>& ssl_peers);
|
||||
|
||||
//};
|
||||
|
||||
|
||||
/// keep track of transaction number
|
||||
|
@ -72,10 +83,9 @@ typedef std::map<std::string, TransactionIdMap > TransactionsPeerMap;
|
|||
|
||||
|
||||
/*!
|
||||
* Resource use,
|
||||
*
|
||||
* Resource use
|
||||
*/
|
||||
class RsGxsNetService : public RsNetworkExchangeService, public RsThread,
|
||||
class RsGxsNetService : public RsNetworkExchangeService, public p3ThreadedService,
|
||||
public p3Config
|
||||
{
|
||||
public:
|
||||
|
@ -87,7 +97,7 @@ public:
|
|||
* @param nxsObs observer will be notified whenever new messages/grps
|
||||
* arrive
|
||||
*/
|
||||
RsGxsNetService(uint16_t servType, RsGeneralDataService* gds, RsNxsObserver* nxsObs = NULL);
|
||||
RsGxsNetService(uint16_t servType, RsGeneralDataService* gds, RsNxsNetMgr* netMgr, RsNxsObserver* nxsObs = NULL);
|
||||
|
||||
public:
|
||||
|
||||
|
@ -113,25 +123,6 @@ public:
|
|||
*/
|
||||
void requestMessagesOfPeer(const std::string& peerId, const std::string& grpId){ return; }
|
||||
|
||||
/*!
|
||||
* Initiates a search through the network
|
||||
* This returns messages which contains the search terms set in RsGxsSearch
|
||||
* @param search contains search terms of requested from service
|
||||
* @param hops how far into friend tree for search
|
||||
* @return search token that can be redeemed later, implementation should indicate how this should be used
|
||||
*/
|
||||
int searchMsgs(RsGxsSearch* search, uint8_t hops = 1, bool retrieve = 0){ return 0;}
|
||||
|
||||
/*!
|
||||
* Initiates a search of groups through the network which goes
|
||||
* a given number of hosp deep into your friend's network
|
||||
* @param search contains search term requested from service
|
||||
* @param hops number of hops deep into peer network
|
||||
* @return search token that can be redeemed later
|
||||
*/
|
||||
int searchGrps(RsGxsSearch* search, uint8_t hops = 1, bool retrieve = 0){ return 0;}
|
||||
|
||||
|
||||
/*!
|
||||
* pauses synchronisation of subscribed groups and request for group id
|
||||
* from peers
|
||||
|
@ -311,7 +302,9 @@ private:
|
|||
uint32_t mTransactionTimeOut;
|
||||
|
||||
std::string mOwnId;
|
||||
;
|
||||
|
||||
RsNxsNetMgr* mNetMgr;
|
||||
|
||||
/// for other members save transactions
|
||||
RsMutex mNxsMutex;
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
* 2 transfers only between group
|
||||
* - the also group matrix settings which is by default everyone can transfer to each other
|
||||
*/
|
||||
class RsNetworkExchangeService : public p3Service
|
||||
class RsNetworkExchangeService
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -90,7 +90,7 @@ public:
|
|||
* @param hops how far into friend tree for search
|
||||
* @return search token that can be redeemed later, implementation should indicate how this should be used
|
||||
*/
|
||||
virtual int searchMsgs(RsGxsSearch* search, uint8_t hops = 1, bool retrieve = 0) = 0;
|
||||
//virtual int searchMsgs(RsGxsSearch* search, uint8_t hops = 1, bool retrieve = 0) = 0;
|
||||
|
||||
/*!
|
||||
* Initiates a search of groups through the network which goes
|
||||
|
@ -99,7 +99,7 @@ public:
|
|||
* @param hops number of hops deep into peer network
|
||||
* @return search token that can be redeemed later
|
||||
*/
|
||||
virtual int searchGrps(RsGxsSearch* search, uint8_t hops = 1, bool retrieve = 0) = 0;
|
||||
//virtual int searchGrps(RsGxsSearch* search, uint8_t hops = 1, bool retrieve = 0) = 0;
|
||||
|
||||
|
||||
/*!
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
* Observer, interface for RetroShare.
|
||||
*
|
||||
* Copyright 2011-2011 by Robert Fernie, Evi-Parker Christopher
|
||||
* Copyright 2011-2012 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
|
||||
|
@ -42,12 +42,12 @@ public:
|
|||
/*!
|
||||
* @param messages messages are deleted after function returns
|
||||
*/
|
||||
virtual void notifyNewMessages(std::set<RsNxsMsg*> messages);
|
||||
virtual void notifyNewMessages(std::vector<RsNxsMsg*> messages) = 0;
|
||||
|
||||
/*!
|
||||
* @param messages messages are deleted after function returns
|
||||
*/
|
||||
virtual void notifyNewGroups(std::set<RsNxsGrp*>& groups);
|
||||
virtual void notifyNewGroups(std::vector<RsNxsGrp*>& groups) = 0;
|
||||
|
||||
|
||||
|
||||
|
|
91
libretroshare/src/gxs/rstokenservice.h
Normal file
91
libretroshare/src/gxs/rstokenservice.h
Normal file
|
@ -0,0 +1,91 @@
|
|||
#ifndef RSTOKENSERVICE_H
|
||||
#define RSTOKENSERVICE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/retroshare: rsidentity.h
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2012-2012 by Robert Fernie, Christopher Evi-Parker
|
||||
*
|
||||
* 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 <inttypes.h>
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#include "serialiser/rsgxsitems.h"
|
||||
|
||||
|
||||
#define GXS_REQUEST_STATUS_FAILED 0
|
||||
#define GXS_REQUEST_STATUS_PENDING 1
|
||||
#define GXS_REQUEST_STATUS_PARTIAL 2
|
||||
#define GXS_REQUEST_STATUS_FINISHED_INCOMPLETE 3
|
||||
#define GXS_REQUEST_STATUS_COMPLETE 4
|
||||
#define GXS_REQUEST_STATUS_DONE 5 // ONCE ALL DATA RETRIEVED.
|
||||
|
||||
#define GXS_REQUEST_TYPE_GROUPS 0x00010000
|
||||
#define GXS_REQUEST_TYPE_MSGS 0x00020000
|
||||
#define GXS_REQUEST_TYPE_MSGRELATED 0x00040000
|
||||
|
||||
/*!
|
||||
* This class provides useful generic support for GXS style services.
|
||||
* I expect much of this will be incorporated into the base GXS.
|
||||
*
|
||||
*/
|
||||
class RsTokReqOptions
|
||||
{
|
||||
public:
|
||||
RsTokReqOptions() { mOptions = 0; mBefore = 0; mAfter = 0; }
|
||||
|
||||
uint32_t mOptions;
|
||||
time_t mBefore;
|
||||
time_t mAfter;
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
* A proxy class for requesting generic service data for GXS
|
||||
* This seperates the request mechanism from the actual retrieval of data
|
||||
*/
|
||||
class RsTokenService
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
RsTokenService() { return; }
|
||||
virtual ~RsTokenService() { return; }
|
||||
|
||||
/* Data Requests */
|
||||
virtual bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &groupIds) = 0;
|
||||
virtual bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &groupIds) = 0;
|
||||
virtual bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &msgIds) = 0;
|
||||
virtual bool requestGroupSubscribe(uint32_t &token, const std::string &groupId, bool subscribe) = 0;
|
||||
|
||||
/* Poll */
|
||||
virtual uint32_t requestStatus(const uint32_t token) = 0;
|
||||
|
||||
/* Cancel Request */
|
||||
virtual bool cancelRequest(const uint32_t &token) = 0;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // RSTOKENSERVICE_H
|
Loading…
Add table
Add a link
Reference in a new issue