mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 07:29:33 -05: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
@ -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
|
@ -158,8 +158,8 @@ PUBLIC_HEADERS = retroshare/rsblogs.h \
|
||||
|
||||
HEADERS += plugins/pluginmanager.h \
|
||||
plugins/dlfcn_win32.h \
|
||||
serialiser/rspluginitems.h \
|
||||
gxs/rsgxsdata.h
|
||||
serialiser/rspluginitems.h
|
||||
|
||||
|
||||
|
||||
HEADERS += $$PUBLIC_HEADERS
|
||||
@ -668,13 +668,14 @@ HEADERS += serialiser/rsnxsitems.h \
|
||||
gxs/rsgxsnetservice.h \
|
||||
gxs/rsgxsflags.h \
|
||||
gxs/rsgenexchange.h \
|
||||
gxs/rsgenexchange.h \
|
||||
gxs/rsnxsobserver.h
|
||||
gxs/rsnxsobserver.h \
|
||||
gxs/rsgxsdata.h \
|
||||
|
||||
SOURCES += serialiser/rsnxsitems.cc \
|
||||
gxs/rsdataservice.cc \
|
||||
gxs/rsgenexchange.cc \
|
||||
gxs/rsgxsnetservice.cc
|
||||
gxs/rsgxsnetservice.cc \
|
||||
gxs/rsgxsdata.cc
|
||||
}
|
||||
|
||||
|
||||
@ -708,9 +709,23 @@ SOURCES += services/p3photoservice.cc \
|
||||
# rsserver/p3photo.cc \
|
||||
}
|
||||
|
||||
SOURCES += \
|
||||
# very temporary will restore back
|
||||
even_newer_cache_modules {
|
||||
|
||||
HEADERS += \
|
||||
serialiser/rsgxsitems.h \
|
||||
services/p3photoserviceV2.h \
|
||||
retroshare/rsphotoV2.h \
|
||||
gxs/rstokenservice.h \
|
||||
gxs/rsgxsdataaccess.h \
|
||||
retroshare/rsgxsservice.h
|
||||
|
||||
|
||||
SOURCES +=
|
||||
|
||||
SOURCES += \
|
||||
gxs/rsgxsdata.cc
|
||||
services/p3photoserviceV2.cc
|
||||
|
||||
SOURCES += \
|
||||
gxs/rsgxsdataaccess.cpp
|
||||
|
||||
}
|
||||
|
45
libretroshare/src/retroshare/rsgxsservice.h
Normal file
45
libretroshare/src/retroshare/rsgxsservice.h
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef RSGXSSERVICE_H
|
||||
#define RSGXSSERVICE_H
|
||||
|
||||
|
||||
#include "gxs/rstokenservice.h"
|
||||
|
||||
|
||||
/*!
|
||||
* The aim of this class is to abstract
|
||||
* how changes are represented so
|
||||
* they can be determined outside the
|
||||
* client API without explcitly
|
||||
* enumerating all possible changes
|
||||
* at the interface
|
||||
*/
|
||||
class RsGxsChange
|
||||
{
|
||||
public:
|
||||
RsGxsChange(){ return; }
|
||||
|
||||
};
|
||||
|
||||
/*!
|
||||
* Relevant to group changes
|
||||
* TODO: extent to indicate whether a meta change or actual data
|
||||
*/
|
||||
class RsGxsGroupChange : RsGxsChange
|
||||
{
|
||||
public:
|
||||
std::list<std::string> grpIdList;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Relevant to message changes
|
||||
* TODO: extent to indicate whether a meta change or actual data
|
||||
*/
|
||||
class RsGxsMsgChange : RsGxsChange
|
||||
{
|
||||
public:
|
||||
std::map<std::string, std::vector<std::string> > msgChangeMap;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // RSGXSSERVICE_H
|
276
libretroshare/src/retroshare/rsphotoV2.h
Normal file
276
libretroshare/src/retroshare/rsphotoV2.h
Normal file
@ -0,0 +1,276 @@
|
||||
#ifndef RSPHOTOV2_H
|
||||
#define RSPHOTOV2_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/retroshare: rsphoto.h
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2008-2012 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 <inttypes.h>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include "rsgxsservice.h"
|
||||
|
||||
/* The Main Interface Class - for information about your Peers */
|
||||
class RsPhoto;
|
||||
extern RsPhoto *rsPhoto;
|
||||
|
||||
/******************* NEW STUFF FOR NEW CACHE SYSTEM *********/
|
||||
|
||||
#define RSPHOTO_MODE_NEW 1
|
||||
#define RSPHOTO_MODE_OWN 2
|
||||
#define RSPHOTO_MODE_REMOTE 3
|
||||
|
||||
class RsPhotoThumbnail
|
||||
{
|
||||
public:
|
||||
RsPhotoThumbnail()
|
||||
:data(NULL), size(0), type("N/A") { return; }
|
||||
|
||||
bool deleteImage();
|
||||
bool copyFrom(const RsPhotoThumbnail &nail);
|
||||
|
||||
// Holds Thumbnail image.
|
||||
uint8_t *data;
|
||||
int size;
|
||||
std::string type;
|
||||
};
|
||||
|
||||
|
||||
/* If these flags are no set - the Photo inherits values from the Album
|
||||
*/
|
||||
|
||||
#define RSPHOTO_FLAGS_ATTRIB_TITLE 0x0001
|
||||
#define RSPHOTO_FLAGS_ATTRIB_CAPTION 0x0002
|
||||
#define RSPHOTO_FLAGS_ATTRIB_DESC 0x0004
|
||||
#define RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER 0x0008
|
||||
#define RSPHOTO_FLAGS_ATTRIB_WHERE 0x0010
|
||||
#define RSPHOTO_FLAGS_ATTRIB_WHEN 0x0020
|
||||
#define RSPHOTO_FLAGS_ATTRIB_OTHER 0x0040
|
||||
#define RSPHOTO_FLAGS_ATTRIB_CATEGORY 0x0080
|
||||
#define RSPHOTO_FLAGS_ATTRIB_HASHTAGS 0x0100
|
||||
#define RSPHOTO_FLAGS_ATTRIB_ORDER 0x0200
|
||||
#define RSPHOTO_FLAGS_ATTRIB_THUMBNAIL 0x0400
|
||||
#define RSPHOTO_FLAGS_ATTRIB_MODE 0x0800
|
||||
#define RSPHOTO_FLAGS_ATTRIB_AUTHOR 0x1000 // PUSH UP ORDER
|
||||
#define RSPHOTO_FLAGS_ATTRIB_PHOTO 0x2000 // PUSH UP ORDER.
|
||||
|
||||
|
||||
class RsPhotoPhoto
|
||||
{
|
||||
public:
|
||||
|
||||
RsMsgMetaData mMeta;
|
||||
|
||||
RsPhotoPhoto();
|
||||
|
||||
// THESE ARE IN THE META DATA.
|
||||
//std::string mAlbumId;
|
||||
//std::string mId;
|
||||
//std::string mTitle; // only used by Album.
|
||||
std::string mCaption;
|
||||
std::string mDescription;
|
||||
std::string mPhotographer;
|
||||
std::string mWhere;
|
||||
std::string mWhen;
|
||||
std::string mOther;
|
||||
std::string mCategory;
|
||||
|
||||
std::string mHashTags;
|
||||
|
||||
uint32_t mSetFlags;
|
||||
|
||||
int mOrder;
|
||||
|
||||
RsPhotoThumbnail mThumbnail;
|
||||
|
||||
int mMode;
|
||||
|
||||
// These are not saved.
|
||||
std::string path; // if in Mode NEW.
|
||||
uint32_t mModFlags;
|
||||
};
|
||||
|
||||
class RsPhotoAlbumShare
|
||||
{
|
||||
public:
|
||||
|
||||
uint32_t mShareType;
|
||||
std::string mShareGroupId;
|
||||
std::string mPublishKey;
|
||||
uint32_t mCommentMode;
|
||||
uint32_t mResizeMode;
|
||||
};
|
||||
|
||||
class RsPhotoAlbum
|
||||
{
|
||||
public:
|
||||
RsPhotoAlbum();
|
||||
|
||||
RsGroupMetaData mMeta;
|
||||
|
||||
// THESE ARE IN THE META DATA.
|
||||
//std::string mAlbumId;
|
||||
//std::string mTitle; // only used by Album.
|
||||
|
||||
std::string mCaption;
|
||||
std::string mDescription;
|
||||
std::string mPhotographer;
|
||||
std::string mWhere;
|
||||
std::string mWhen;
|
||||
std::string mOther;
|
||||
std::string mCategory;
|
||||
|
||||
std::string mHashTags;
|
||||
|
||||
RsPhotoThumbnail mThumbnail;
|
||||
|
||||
int mMode;
|
||||
|
||||
std::string mPhotoPath;
|
||||
RsPhotoAlbumShare mShareOptions;
|
||||
|
||||
// These aren't saved.
|
||||
uint32_t mSetFlags;
|
||||
uint32_t mModFlags;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsPhotoPhoto &photo);
|
||||
std::ostream &operator<<(std::ostream &out, const RsPhotoAlbum &album);
|
||||
|
||||
typedef std::map<std::string, std::vector<RsPhotoPhoto> > PhotoResult;
|
||||
typedef std::map<std::string, std::vector<RsMsgMetaData> > MsgMetaResult;
|
||||
|
||||
class RsPhotoV2
|
||||
{
|
||||
public:
|
||||
|
||||
RsPhotoV2() { return; }
|
||||
virtual ~RsPhotoV2() { return; }
|
||||
|
||||
/*!
|
||||
* Use to enquire if groups or msgs have changed
|
||||
* @return true if msgs or groups have changed
|
||||
*/
|
||||
virtual bool updated() = 0;
|
||||
|
||||
/*!
|
||||
*
|
||||
* @param grpIds
|
||||
*/
|
||||
virtual void groupsChanged(std::list<std::string>& grpIds) = 0;
|
||||
|
||||
/*!
|
||||
*
|
||||
* @param msgs
|
||||
*/
|
||||
virtual void msgsChanged(std::map<std::string,
|
||||
std::vector<std::string> >& msgs) = 0;
|
||||
|
||||
/*!
|
||||
* To acquire a handle to token service handler
|
||||
* needed to make requests to the service
|
||||
* @return handle to token service for this gxs service
|
||||
*/
|
||||
virtual RsTokenService* getTokenService() = 0;
|
||||
|
||||
/* Generic Lists */
|
||||
|
||||
/*!
|
||||
*
|
||||
* @param token token to be redeemed for this request
|
||||
* @param groupIds the ids return for given request token
|
||||
* @return false if request token is invalid, check token status for error report
|
||||
*/
|
||||
virtual bool getGroupList(const uint32_t &token,
|
||||
std::list<std::string> &groupIds) = 0;
|
||||
|
||||
/*!
|
||||
* @param token token to be redeemed for this request
|
||||
* @param msgIds the ids return for given request token
|
||||
* @return false if request token is invalid, check token status for error report
|
||||
*/
|
||||
virtual bool getMsgList(const uint32_t &token,
|
||||
std::map<std::string, std::vector<std::string> > &msgIds) = 0;
|
||||
|
||||
/* Generic Summary */
|
||||
|
||||
/*!
|
||||
* @param token token to be redeemed for this request
|
||||
* @param groupInfo the ids returned for given request token
|
||||
* @return false if request token is invalid, check token status for error report
|
||||
*/
|
||||
virtual bool getGroupSummary(const uint32_t &token,
|
||||
std::list<RsGroupMetaData> &groupInfo) = 0;
|
||||
|
||||
/*!
|
||||
* @param token token to be redeemed for this request
|
||||
* @param msgInfo the message metadata returned for given request token
|
||||
* @return false if request token is invalid, check token status for error report
|
||||
*/
|
||||
virtual bool getMsgSummary(const uint32_t &token,
|
||||
MsgMetaResult &msgInfo) = 0;
|
||||
|
||||
/* Specific Service Data */
|
||||
|
||||
/*!
|
||||
* @param token token to be redeemed for this request
|
||||
* @param album the album returned for given request token
|
||||
* @return false if request token is invalid, check token status for error report
|
||||
*/
|
||||
virtual bool getAlbum(const uint32_t &token, RsPhotoAlbum &album) = 0;
|
||||
|
||||
/*!
|
||||
* @param token token to be redeemed for this request
|
||||
* @param photo the photo returned for given request token
|
||||
* @return false if request token is invalid, check token status for error report
|
||||
*/
|
||||
virtual bool getPhoto(const uint32_t &token,
|
||||
PhotoResult &photo) = 0;
|
||||
|
||||
/* details are updated in album - to choose Album ID, and storage path */
|
||||
|
||||
/*!
|
||||
* @param album
|
||||
* @param isNew
|
||||
* @return false if submission failed
|
||||
*/
|
||||
virtual bool submitAlbumDetails(RsPhotoAlbum &album, bool isNew) = 0;
|
||||
|
||||
/*!
|
||||
* @param photo photo to submit
|
||||
* @param isNew whether photo is new
|
||||
* @param
|
||||
*/
|
||||
virtual bool submitPhoto(RsPhotoPhoto &photo, bool isNew) = 0;
|
||||
|
||||
/*!
|
||||
* @param grpId the id of the group to subscribe to
|
||||
* @param subsribe set to true to subscribe
|
||||
*/
|
||||
virtual bool subscribeToAlbum(const std::string grpId, bool subscribe) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // RSPHOTOV2_H
|
27
libretroshare/src/serialiser/rsgxsitem.h
Normal file
27
libretroshare/src/serialiser/rsgxsitem.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef RSGXSITEM_H
|
||||
#define RSGXSITEM_H
|
||||
|
||||
#include "serialiser/rsserviceids.h"
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include "serialiser/rstlvtypes.h"
|
||||
#include "serialiser/rstlvkeys.h"
|
||||
|
||||
|
||||
class RsGxsGrpItem : RsItem
|
||||
{
|
||||
|
||||
RsGxsItem() : RsItem(0) { return; }
|
||||
virtual ~RsGxsItem();
|
||||
|
||||
};
|
||||
|
||||
class RsGxsMsgItem : RsItem
|
||||
{
|
||||
|
||||
RsGxsItem() : RsItem(0) { return; }
|
||||
virtual ~RsGxsItem();
|
||||
|
||||
};
|
||||
|
||||
#endif // RSGXSITEM_H
|
@ -26,98 +26,114 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "serialiser/rsserviceids.h"
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include "serialiser/rstlvtypes.h"
|
||||
#include "serialiser/rstlvkeys.h"
|
||||
#include "gxs/rsgxsdata.h"
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* Base class used by client API
|
||||
* for messages.
|
||||
* Main purpose is for msg flows
|
||||
* between GDS and GXS API clients
|
||||
*/
|
||||
class RsGxsMsg : public RsItem
|
||||
class RsGxsGrpItem : public RsItem
|
||||
{
|
||||
public:
|
||||
|
||||
RsGxsMsg() : RsItem(0) {}
|
||||
virtual ~RsGxsMsg(){ return; }
|
||||
|
||||
};
|
||||
|
||||
/*!
|
||||
* Base class used by client API
|
||||
* for groups.
|
||||
* Main purpose is for msg flows
|
||||
* between GDS and GXS API clients
|
||||
*/
|
||||
class RsGxsGroup : public RsItem
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/*** type of msgs ***/
|
||||
|
||||
RsGxsGroup(uint16_t servtype, uint8_t subtype)
|
||||
: RsItem(servtype) { return; }
|
||||
|
||||
virtual ~RsGxsGroup() { return; }
|
||||
|
||||
/*!
|
||||
* Three thing flag represents:
|
||||
* Is it signed by identity?
|
||||
* Group type (private, public, restricted)
|
||||
* msgs allowed (signed and anon)
|
||||
*/
|
||||
uint32_t grpFlag;
|
||||
|
||||
/***** *****/
|
||||
RsGxsGrpItem() : RsItem(0) { return; }
|
||||
virtual ~RsGxsGrpItem(){}
|
||||
|
||||
// must be serialised
|
||||
std::string mAuthorId;
|
||||
std::string mGrpId;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class RsGxsSearch : public RsItem {
|
||||
|
||||
RsGxsSearch(uint32_t servtype) : RsItem(servtype) { return ; }
|
||||
virtual ~RsGxsSearch() { return;}
|
||||
|
||||
};
|
||||
|
||||
class RsGxsSrchResMsgCtx : public RsItem {
|
||||
|
||||
RsGxsSrchResMsgCtx(uint32_t servtype) : RsItem(servtype) { return; }
|
||||
virtual ~RsGxsSrchResMsgCtx() {return; }
|
||||
std::string msgId;
|
||||
RsTlvKeySignature sign;
|
||||
|
||||
};
|
||||
|
||||
class RsGxsSrchResGrpCtx : public RsItem {
|
||||
|
||||
RsGxsSrchResGrpCtx(uint32_t servtype) : RsItem(servtype) { return; }
|
||||
virtual ~RsGxsSrchResGrpCtx() {return; }
|
||||
std::string msgId;
|
||||
RsTlvKeySignature sign;
|
||||
|
||||
};
|
||||
|
||||
class RsGxsSerialiser : public RsSerialType
|
||||
class RsGxsMsgItem : public RsItem
|
||||
{
|
||||
public:
|
||||
|
||||
RsGxsSerialiser(uint32_t servtype) : RsSerialType(servtype) { return; }
|
||||
virtual ~RsGxsSerialiser() { return; }
|
||||
public:
|
||||
RsGxsMsgItem() : RsItem(0) { return; }
|
||||
virtual ~RsGxsMsgItem(){}
|
||||
|
||||
// must be serialised
|
||||
std::string mAuthorId;
|
||||
std::string mMsgId;
|
||||
std::string mGrpId;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class RsGroupMetaData
|
||||
{
|
||||
public:
|
||||
|
||||
RsGroupMetaData()
|
||||
{
|
||||
mGroupFlags = 0;
|
||||
mSubscribeFlags = 0;
|
||||
|
||||
mPop = 0;
|
||||
mMsgCount = 0;
|
||||
mLastPost = 0;
|
||||
mGroupStatus = 0;
|
||||
|
||||
//mPublishTs = 0;
|
||||
}
|
||||
|
||||
std::string mGroupId;
|
||||
std::string mGroupName;
|
||||
uint32_t mGroupFlags;
|
||||
|
||||
time_t mPublishTs; // Mandatory.
|
||||
std::string mAuthorId; // Optional.
|
||||
|
||||
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
|
||||
|
||||
uint32_t mSubscribeFlags;
|
||||
|
||||
uint32_t mPop; // HOW DO WE DO THIS NOW.
|
||||
uint32_t mMsgCount; // ???
|
||||
time_t mLastPost; // ???
|
||||
|
||||
uint32_t mGroupStatus;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class RsMsgMetaData
|
||||
{
|
||||
public:
|
||||
|
||||
RsMsgMetaData()
|
||||
{
|
||||
mPublishTs = 0;
|
||||
mMsgFlags = 0;
|
||||
mMsgStatus = 0;
|
||||
mChildTs = 0;
|
||||
}
|
||||
|
||||
std::string mGroupId;
|
||||
std::string mMsgId;
|
||||
|
||||
std::string mThreadId;
|
||||
std::string mParentId;
|
||||
std::string mOrigMsgId;
|
||||
|
||||
std::string mAuthorId;
|
||||
|
||||
std::string mMsgName;
|
||||
time_t mPublishTs;
|
||||
|
||||
uint32_t mMsgFlags; // Whats this for?
|
||||
|
||||
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
|
||||
// normally READ / UNREAD flags. LOCAL Data.
|
||||
uint32_t mMsgStatus;
|
||||
time_t mChildTs;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // RSGXSITEMS_H
|
||||
|
5
libretroshare/src/services/p3photoserviceV2.cc
Normal file
5
libretroshare/src/services/p3photoserviceV2.cc
Normal file
@ -0,0 +1,5 @@
|
||||
#include "p3photoserviceV2.h"
|
||||
|
||||
p3PhotoServiceV2::p3PhotoServiceV2()
|
||||
{
|
||||
}
|
57
libretroshare/src/services/p3photoserviceV2.h
Normal file
57
libretroshare/src/services/p3photoserviceV2.h
Normal file
@ -0,0 +1,57 @@
|
||||
#ifndef P3PHOTOSERVICEV2_H
|
||||
#define P3PHOTOSERVICEV2_H
|
||||
|
||||
#include "gxs/rsgenexchange.h"
|
||||
#include "retroshare/rsphotoV2.h"
|
||||
#include "gxs/rstokenservice.h"
|
||||
|
||||
class p3PhotoServiceV2 : public RsPhotoV2, public RsGenExchange
|
||||
{
|
||||
public:
|
||||
|
||||
p3PhotoServiceV2();
|
||||
|
||||
public:
|
||||
|
||||
bool updated();
|
||||
|
||||
public:
|
||||
|
||||
/** Requests **/
|
||||
|
||||
void groupsChanged(std::list<std::string>& grpIds);
|
||||
|
||||
|
||||
void msgsChanged(std::map<std::string,
|
||||
std::vector<std::string> >& msgs);
|
||||
|
||||
RsTokenService* getTokenService();
|
||||
|
||||
bool getGroupList(const uint32_t &token,
|
||||
std::list<std::string> &groupIds);
|
||||
bool getMsgList(const uint32_t &token,
|
||||
std::list<std::string> &msgIds);
|
||||
|
||||
/* Generic Summary */
|
||||
bool getGroupSummary(const uint32_t &token,
|
||||
std::list<RsGroupMetaData> &groupInfo);
|
||||
|
||||
bool getMsgSummary(const uint32_t &token,
|
||||
MsgMetaResult &msgInfo);
|
||||
|
||||
/* Specific Service Data */
|
||||
bool getAlbum(const uint32_t &token, RsPhotoAlbum &album);
|
||||
bool getPhoto(const uint32_t &token, PhotoResult &photo);
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/** Modifications **/
|
||||
|
||||
bool submitAlbumDetails(RsPhotoAlbum &album, bool isNew);
|
||||
bool submitPhoto(RsPhotoPhoto &photo, bool isNew);
|
||||
bool subscribeToAlbum(const std::string& grpId, bool subscribe);
|
||||
};
|
||||
|
||||
#endif // P3PHOTOSERVICEV2_H
|
@ -69,7 +69,11 @@ void init_item(RsGxsGrpMetaData* metaGrp)
|
||||
metaGrp->mPublishTs = rand()%3452;
|
||||
metaGrp->mGroupFlags = rand()%43;
|
||||
|
||||
|
||||
metaGrp->mGroupStatus = rand()%313;
|
||||
metaGrp->mSubscribeFlags = rand()%2251;
|
||||
metaGrp->mMsgCount = rand()%2421;
|
||||
metaGrp->mLastPost = rand()%2211;
|
||||
metaGrp->mPop = rand()%5262;
|
||||
}
|
||||
|
||||
void init_item(RsGxsMsgMetaData* metaMsg)
|
||||
|
5
libretroshare/src/tests/gxs/nxstesthub.cc
Normal file
5
libretroshare/src/tests/gxs/nxstesthub.cc
Normal file
@ -0,0 +1,5 @@
|
||||
#include "nxstesthub.h"
|
||||
|
||||
NxsTestHub::NxsTestHub()
|
||||
{
|
||||
}
|
45
libretroshare/src/tests/gxs/nxstesthub.h
Normal file
45
libretroshare/src/tests/gxs/nxstesthub.h
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef NXSTESTHUB_H
|
||||
#define NXSTESTHUB_H
|
||||
|
||||
#include "util/rsthreads.h"
|
||||
#include "gxs/rsgxsnetservice.h"
|
||||
|
||||
/*!
|
||||
* This scenario module allows you to model
|
||||
* simply back and forth conversation between nxs and a virtual peer
|
||||
* (this module being the virtual peer)
|
||||
*/
|
||||
class NxsScenario
|
||||
{
|
||||
|
||||
static int SCENARIO_OUTGOING;
|
||||
static int SCENARIO_INCOMING;
|
||||
|
||||
public:
|
||||
|
||||
virtual int scenarioType() = 0;
|
||||
|
||||
virtual void receive(RsNxsItem* ) = 0;
|
||||
virtual RsNxsItem* send() = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class NxsTestHub : public RsThread
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
NxsTestHub(NxsScenario* , std::pair<RsGxsNetService*, RsGxsNetService*> servicePair);
|
||||
|
||||
/*!
|
||||
* To be called only after this thread has
|
||||
* been shutdown
|
||||
*/
|
||||
bool testsPassed();
|
||||
|
||||
void run();
|
||||
};
|
||||
|
||||
#endif // NXSTESTHUB_H
|
73
libretroshare/src/tests/gxs/rs_test.pro
Normal file
73
libretroshare/src/tests/gxs/rs_test.pro
Normal file
@ -0,0 +1,73 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2012-05-06T09:19:26
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core network
|
||||
|
||||
QT -= gui
|
||||
|
||||
TARGET = rs_test
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
win32 {
|
||||
# Switch on extra warnings
|
||||
QMAKE_CFLAGS += -Wextra
|
||||
QMAKE_CXXFLAGS += -Wextra
|
||||
|
||||
# Switch off optimization for release version
|
||||
QMAKE_CXXFLAGS_RELEASE -= -O2
|
||||
QMAKE_CXXFLAGS_RELEASE += -O0
|
||||
QMAKE_CFLAGS_RELEASE -= -O2
|
||||
QMAKE_CFLAGS_RELEASE += -O0
|
||||
|
||||
# Switch on optimization for debug version
|
||||
#QMAKE_CXXFLAGS_DEBUG += -O2
|
||||
#QMAKE_CFLAGS_DEBUG += -O2
|
||||
DEFINES *= WINDOWS_SYS
|
||||
PRE_TARGETDEPS += C:\Development\Rs\v0.5-new_cache_system\libretroshare\libretroshare-build-desktop\lib\libretroshare.a
|
||||
LIBS += C:\Development\Rs\v0.5-new_cache_system\libretroshare\libretroshare-build-desktop\lib\libretroshare.a
|
||||
LIBS += -L"../lib"
|
||||
LIBS += -lssl -lcrypto -lgpgme -lpthreadGC2d -lminiupnpc -lz
|
||||
# added after bitdht
|
||||
# LIBS += -lws2_32
|
||||
LIBS += -luuid -lole32 -liphlpapi -lcrypt32-cygwin -lgdi32
|
||||
LIBS += -lole32 -lwinmm
|
||||
|
||||
# export symbols for the plugins
|
||||
#LIBS += -Wl,--export-all-symbols,--out-implib,lib/libretroshare-gui.a
|
||||
|
||||
GPG_ERROR_DIR = ../../../../libgpg-error-1.7
|
||||
GPGME_DIR = ../../../../gpgme-1.1.8
|
||||
GPG_ERROR_DIR = ../../../../lib/libgpg-error-1.7
|
||||
GPGME_DIR = ../../../../lib/gpgme-1.1.8
|
||||
INCLUDEPATH += . $${GPGME_DIR}/src $${GPG_ERROR_DIR}/src ../../Libraries/sqlite/sqlite-autoconf-3070900
|
||||
LIBS += C:\Development\Libraries\sqlite\sqlite-autoconf-3070900\.libs\libsqlite3.a
|
||||
}
|
||||
|
||||
win32 {
|
||||
# must be added after bitdht
|
||||
LIBS += -lws2_32
|
||||
}
|
||||
|
||||
SOURCES += \
|
||||
support.cc \
|
||||
#rsnxsitems_test.cc
|
||||
rsdataservice_test.cc \
|
||||
data_support.cc
|
||||
#rsnxsservice_test.cc \
|
||||
#nxstesthub.cc
|
||||
#rsgxsdata_test.cc
|
||||
|
||||
HEADERS += support.h \
|
||||
#rsnxsitems_test.h
|
||||
rsdataservice_test.h \
|
||||
data_support.h
|
||||
#rsnxsservice_test.h \
|
||||
#nxstesthub.h
|
||||
|
||||
INCLUDEPATH += C:\Development\Rs\v0.5-new_cache_system\libretroshare\src
|
@ -18,8 +18,7 @@ int main()
|
||||
std::cerr << "RsDataService Tests" << std::endl;
|
||||
|
||||
test_groupStoreAndRetrieve(); REPORT("test_groupStoreAndRetrieve");
|
||||
|
||||
//test_messageStoresAndRetrieve(); REPORT("test_messageStoresAndRetrieve");
|
||||
test_messageStoresAndRetrieve(); REPORT("test_messageStoresAndRetrieve");
|
||||
|
||||
FINALREPORT("RsDataService Tests");
|
||||
|
||||
@ -29,7 +28,10 @@ int main()
|
||||
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* All memory is disposed off, good for looking
|
||||
* for memory leaks
|
||||
*/
|
||||
void test_groupStoreAndRetrieve(){
|
||||
|
||||
setUp();
|
||||
@ -46,7 +48,11 @@ void test_groupStoreAndRetrieve(){
|
||||
p.second = grpMeta;
|
||||
init_item(*grp);
|
||||
init_item(grpMeta);
|
||||
grpMeta->mGroupId = grp->grpId;
|
||||
grps.insert(p);
|
||||
|
||||
grpMeta = NULL;
|
||||
grp = NULL;
|
||||
}
|
||||
|
||||
dStore->storeGroup(grps);
|
||||
@ -56,6 +62,230 @@ void test_groupStoreAndRetrieve(){
|
||||
dStore->retrieveNxsGrps(gR, false);
|
||||
dStore->retrieveGxsGrpMetaData(grpMetaR);
|
||||
|
||||
std::map<RsNxsGrp*, RsGxsGrpMetaData*>::iterator mit = grps.begin();
|
||||
|
||||
bool grpMatch = true, grpMetaMatch = true;
|
||||
|
||||
for(; mit != grps.end(); mit++)
|
||||
{
|
||||
const std::string grpId = mit->first->grpId;
|
||||
|
||||
// check if it exists
|
||||
if(gR.find(grpId) == gR.end()) {
|
||||
grpMatch = false;
|
||||
break;
|
||||
}
|
||||
|
||||
RsNxsGrp *l = mit->first,
|
||||
*r = gR[grpId];
|
||||
|
||||
// assign transaction number
|
||||
// to right to as tn is not stored
|
||||
// in db
|
||||
r->transactionNumber = l->transactionNumber;
|
||||
|
||||
// then do a comparison
|
||||
if(!( *l == *r)) {
|
||||
grpMatch = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// now do a comparison of grp meta types
|
||||
|
||||
if(grpMetaR.find(grpId) == grpMetaR.end())
|
||||
{
|
||||
grpMetaMatch = false;
|
||||
break;
|
||||
}
|
||||
|
||||
RsGxsGrpMetaData *l_Meta = mit->second,
|
||||
*r_Meta = grpMetaR[grpId];
|
||||
|
||||
if(!(*l_Meta == *r_Meta))
|
||||
{
|
||||
grpMetaMatch = false;
|
||||
break;
|
||||
}
|
||||
|
||||
/* release resources */
|
||||
delete l_Meta;
|
||||
delete r_Meta;
|
||||
delete l;
|
||||
delete r;
|
||||
|
||||
remove(grpId.c_str());
|
||||
}
|
||||
|
||||
grpMetaR.clear();
|
||||
|
||||
CHECK(grpMatch);
|
||||
tearDown();
|
||||
}
|
||||
|
||||
/*!
|
||||
* Test for both selective and
|
||||
* bulk msg retrieval
|
||||
*/
|
||||
void test_messageStoresAndRetrieve()
|
||||
{
|
||||
setUp();
|
||||
|
||||
// first create a grpId
|
||||
std::string grpId0, grpId1;
|
||||
|
||||
randString(SHORT_STR, grpId0);
|
||||
randString(SHORT_STR, grpId1);
|
||||
std::vector<std::string> grpV; // stores grpIds of all msgs stored and retrieved
|
||||
grpV.push_back(grpId0);
|
||||
grpV.push_back(grpId1);
|
||||
|
||||
std::map<RsNxsMsg*, RsGxsMsgMetaData*> msgs;
|
||||
RsNxsMsg* msg = NULL;
|
||||
RsGxsMsgMetaData* msgMeta = NULL;
|
||||
int nMsgs = rand()%120;
|
||||
GxsMsgReq req;
|
||||
|
||||
std::map<std::string, RsNxsMsg*> VergrpId0, VergrpId1;
|
||||
std::map<std::string, RsGxsMsgMetaData*> VerMetagrpId0, VerMetagrpId1;
|
||||
|
||||
for(int i=0; i<nMsgs; i++)
|
||||
{
|
||||
msg = new RsNxsMsg(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
msgMeta = new RsGxsMsgMetaData();
|
||||
init_item(*msg);
|
||||
init_item(msgMeta);
|
||||
std::pair<RsNxsMsg*, RsGxsMsgMetaData*> p(msg, msgMeta);
|
||||
int chosen = 0;
|
||||
if(rand()%50 > 24){
|
||||
chosen = 1;
|
||||
|
||||
}
|
||||
|
||||
const std::string& grpId = grpV[chosen];
|
||||
|
||||
if(chosen)
|
||||
req[grpId].insert(msg->msgId);
|
||||
|
||||
msgMeta->mMsgId = msg->msgId;
|
||||
msgMeta->mGroupId = msg->grpId = grpId;
|
||||
|
||||
// store msgs in map to use for verification
|
||||
std::pair<std::string, RsNxsMsg*> vP(msg->msgId, msg);
|
||||
std::pair<std::string, RsGxsMsgMetaData*> vPmeta(msg->msgId, msgMeta);
|
||||
|
||||
if(!chosen)
|
||||
{
|
||||
VergrpId0.insert(vP);
|
||||
VerMetagrpId0.insert(vPmeta);
|
||||
}
|
||||
else
|
||||
{
|
||||
VergrpId1.insert(vP);
|
||||
VerMetagrpId0.insert(vPmeta);
|
||||
}
|
||||
msg = NULL;
|
||||
msgMeta = NULL;
|
||||
|
||||
msgs.insert(p);
|
||||
}
|
||||
|
||||
req[grpV[0]] = std::set<std::string>(); // assign empty list for other
|
||||
|
||||
dStore->storeMessage(msgs);
|
||||
|
||||
// now retrieve msgs for comparison
|
||||
// first selective retrieval
|
||||
|
||||
GxsMsgResult msgResult;
|
||||
GxsMsgMetaResult msgMetaResult;
|
||||
dStore->retrieveNxsMsgs(req, msgResult, false);
|
||||
dStore->retrieveGxsMsgMetaData(grpV, msgMetaResult);
|
||||
|
||||
// now look at result for grpId 1
|
||||
std::vector<RsNxsMsg*>& result0 = msgResult[grpId0];
|
||||
std::vector<RsNxsMsg*>& result1 = msgResult[grpId1];
|
||||
std::vector<RsGxsMsgMetaData*>& resultMeta0 = msgMetaResult[grpId0];
|
||||
std::vector<RsGxsMsgMetaData*>& resultMeta1 = msgMetaResult[grpId1];
|
||||
|
||||
|
||||
|
||||
bool msgGrpId0_Match = true, msgGrpId1_Match = true;
|
||||
bool msgMetaGrpId0_Match = true, msgMetaGrpId1_Match = true;
|
||||
|
||||
// MSG test, selective retrieval
|
||||
for(std::vector<RsNxsMsg*>::size_type i = 0; i < result0.size(); i++)
|
||||
{
|
||||
RsNxsMsg* l = result0[i] ;
|
||||
|
||||
if(VergrpId0.find(l->msgId) == VergrpId0.end())
|
||||
{
|
||||
msgGrpId0_Match = false;
|
||||
break;
|
||||
}
|
||||
|
||||
RsNxsMsg* r = VergrpId0[l->msgId];
|
||||
r->transactionNumber = l->transactionNumber;
|
||||
|
||||
if(!(*l == *r))
|
||||
{
|
||||
msgGrpId0_Match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CHECK(msgGrpId0_Match);
|
||||
|
||||
// META test
|
||||
for(std::vector<RsGxsMsgMetaData*>::size_type i = 0; i < resultMeta0.size(); i++)
|
||||
{
|
||||
RsGxsMsgMetaData* l = resultMeta0[i] ;
|
||||
|
||||
if(VerMetagrpId0.find(l->mMsgId) == VerMetagrpId0.end())
|
||||
{
|
||||
msgMetaGrpId0_Match = false;
|
||||
break;
|
||||
}
|
||||
|
||||
RsGxsMsgMetaData* r = VerMetagrpId0[l->mMsgId];
|
||||
|
||||
if(!(*l == *r))
|
||||
{
|
||||
msgMetaGrpId0_Match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CHECK(msgMetaGrpId0_Match);
|
||||
|
||||
// MSG test, bulk retrieval
|
||||
for(std::vector<RsNxsMsg*>::size_type i = 0; i < result1.size(); i++)
|
||||
{
|
||||
RsNxsMsg* l = result1[i] ;
|
||||
|
||||
if(VergrpId1.find(l->msgId) == VergrpId1.end())
|
||||
{
|
||||
msgGrpId1_Match = false;
|
||||
break;
|
||||
}
|
||||
|
||||
RsNxsMsg* r = VergrpId1[l->msgId];
|
||||
|
||||
r->transactionNumber = l->transactionNumber;
|
||||
|
||||
if(!(*l == *r))
|
||||
{
|
||||
msgGrpId1_Match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CHECK(msgGrpId1_Match);
|
||||
|
||||
//dStore->retrieveGxsMsgMetaData();
|
||||
std::string msgFile = grpId0 + "-msgs";
|
||||
remove(msgFile.c_str());
|
||||
msgFile = grpId1 + "-msgs";
|
||||
remove(msgFile.c_str());
|
||||
tearDown();
|
||||
}
|
||||
|
||||
@ -80,5 +310,42 @@ void tearDown(){
|
||||
perror("Error: ");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool operator ==(const RsGxsGrpMetaData& l, const RsGxsGrpMetaData& r)
|
||||
{
|
||||
if(!(l.adminSign == r.adminSign)) return false;
|
||||
if(!(l.idSign == r.idSign)) return false;
|
||||
if(!(l.keys == r.keys)) return false;
|
||||
if(l.mGroupFlags != r.mGroupFlags) return false;
|
||||
if(l.mPublishTs != r.mPublishTs) return false;
|
||||
if(l.mAuthorId != r.mAuthorId) return false;
|
||||
if(l.mGroupName != r.mGroupName) return false;
|
||||
if(l.mGroupId != r.mGroupId) return false;
|
||||
if(l.mGroupStatus != r.mGroupStatus) return false;
|
||||
if(l.mPop != r.mPop) return false;
|
||||
if(l.mMsgCount != r.mMsgCount) return false;
|
||||
if(l.mSubscribeFlags != r.mSubscribeFlags) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator ==(const RsGxsMsgMetaData& l, const RsGxsMsgMetaData& r)
|
||||
{
|
||||
|
||||
if(!(l.idSign == r.idSign)) return false;
|
||||
if(!(l.pubSign == r.pubSign)) return false;
|
||||
if(l.mGroupId != r.mGroupId) return false;
|
||||
if(l.mAuthorId != r.mAuthorId) return false;
|
||||
if(l.mParentId != r.mParentId) return false;
|
||||
if(l.mOrigMsgId != r.mOrigMsgId) return false;
|
||||
if(l.mThreadId != r.mThreadId) return false;
|
||||
if(l.mMsgId != r.mMsgId) return false;
|
||||
if(l.mMsgName != r.mMsgName) return false;
|
||||
if(l.mPublishTs != r.mPublishTs) return false;
|
||||
if(l.mMsgFlags != r.mMsgFlags) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -15,6 +15,9 @@ void test_storeAndDeleteMessage();
|
||||
void test_searchMsg();
|
||||
void test_searchGrp();
|
||||
|
||||
bool operator ==(const RsGxsGrpMetaData& l, const RsGxsGrpMetaData& r);
|
||||
bool operator ==(const RsGxsMsgMetaData& l, const RsGxsMsgMetaData& r);
|
||||
|
||||
void test_multiThreaded();
|
||||
|
||||
class DataReadWrite : RsThread
|
||||
|
@ -36,6 +36,8 @@ void free_blob(void* dat){
|
||||
|
||||
char* c = (char*) dat;
|
||||
delete[] c;
|
||||
dat = NULL;
|
||||
|
||||
}
|
||||
|
||||
const uint8_t ContentValue::BOOL_TYPE = 1;
|
||||
@ -337,7 +339,7 @@ bool RetroDb::execSQL_bind_blobs(const std::string &query, std::list<RetroDbBlob
|
||||
|
||||
for(; lit != blobs.end(); lit++){
|
||||
const RetroDbBlob& b = *lit;
|
||||
sqlite3_bind_blob(stm, b.index, b.data, b.length, free_blob);
|
||||
sqlite3_bind_blob(stm, b.index, b.data, b.length, NULL);
|
||||
}
|
||||
|
||||
uint32_t delta = 3;
|
||||
|
Loading…
Reference in New Issue
Block a user