gxs back end now compilable, need to test

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5346 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2012-07-28 20:01:30 +00:00
parent d5520a1cd8
commit 17da89938f
15 changed files with 71 additions and 91 deletions

View File

@ -8,6 +8,7 @@
#include "gxscoreserver.h"
GxsCoreServer::GxsCoreServer()
: mGxsMutex("GxsCoreServer")
{
}

View File

@ -35,6 +35,7 @@
#include "serialiser/rsgxsitems.h"
#include "serialiser/rsnxsitems.h"
#include "gxs/rsgxsdata.h"
#include "rsgxs.h"
class RsGxsSearchModule {
@ -62,9 +63,9 @@ class GrpLocMetaData {
};
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgReq; // <grpId, msgIds>
typedef std::map<RsGxsGroupId, std::vector<RsNxsMsg*> > GxsMsgResult; // <grpId, msgs>
typedef std::map<RsGxsGroupId, std::vector<RsGxsMsgMetaData*> > GxsMsgMetaResult; // <grpId, msg metadatas>
//typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgReq; // <grpId, msgIds>
//typedef std::map<RsGxsGroupId, std::vector<RsGxsMsgMetaData*> > GxsMsgMetaResult; // <grpId, msg metadatas>
/*!
* The main role of GDS is the preparation and handing out of messages requested from

View File

@ -52,14 +52,16 @@ bool RsGenExchange::getGroupMeta(const uint32_t &token, std::list<RsGroupMetaDat
bool ok = mDataAccess->getGroupSummary(token, metaL);
std::list<RsGxsGrpMetaData*>::iterator lit = metaL.begin();
RsGroupMetaData m;
for(; lit != metaL.end(); lit++)
{
RsGroupMetaData m = *(*lit);
RsGxsGrpMetaData& gMeta = *(*lit);
m = gMeta;
groupInfo.push_back(m);
delete (*lit);
}
std::list<RsGxsGrpMetaData*>::iterator cit = metaL;
std::list<RsGxsGrpMetaData*>::iterator cit = metaL.begin();
for(; cit != metaL.end(); cit++)
delete *cit;
@ -79,7 +81,7 @@ bool RsGenExchange::getMsgMeta(const uint32_t &token,
for(; mit != result.end(); mit++)
{
std::vector<RsGxsMsgMetaData*>& metaV = mit->second;
msgInfo[mit->first] = metaV;
//msgInfo[mit->first] = metaV;
std::vector<RsGxsMsgMetaData*>::iterator vit = metaV.begin();
@ -147,7 +149,7 @@ bool RsGenExchange::getMsgData(const uint32_t &token,
}
RsTokenService* RsGenExchange::getTokenService()
RsTokenServiceV2* RsGenExchange::getTokenService()
{
return mDataAccess;
}
@ -256,7 +258,7 @@ void RsGenExchange::publishGrps()
{
grp->metaData = new RsGxsGrpMetaData();
ok = mDataAccess->addGroupData(grp);
RsGxsGroupChange* gc = RsGxsGroupChange();
RsGxsGroupChange* gc = new RsGxsGroupChange();
mNotifications.push_back(gc);
}

View File

@ -101,7 +101,7 @@ public:
* @return handle to token service handle for making
* request to this gxs service
*/
RsTokenService* getTokenService();
RsTokenServiceV2* getTokenService();
protected:
@ -225,7 +225,7 @@ private:
private:
std::vector<RsGxsChange*> mChanges;
std::vector<RsGxsNotify*> mChanges;
};
#endif // RSGENEXCHANGE_H

View File

@ -40,7 +40,11 @@
#include "rsnxsobserver.h"
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgReq;
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgIdResult;
typedef std::map<RsGxsGroupId, std::vector<RsGxsMsgMetaData*> > GxsMsgMetaResult;
typedef std::map<RsGxsGroupId, std::vector<RsNxsMsg*> > NxsMsgDataResult;
typedef std::map<RsGxsGroupId, std::vector<RsNxsMsg*> > GxsMsgResult; // <grpId, msgs>
class RsGxsService : public RsNxsObserver
{

View File

@ -1,5 +1,3 @@
#include "rsgxsdataaccess.h"
/*
* libretroshare/src/retroshare: rsgxsdataaccess.cc
*
@ -25,6 +23,8 @@
*
*/
#include "rsgxsdataaccess.h"
// This bit will be filled out over time.
#define RS_TOKREQOPT_MSG_VERSIONS 0x0001 // MSGRELATED: Returns All MsgIds with OrigMsgId = MsgId.
#define RS_TOKREQOPT_MSG_ORIGMSG 0x0002 // MSGLIST: All Unique OrigMsgIds in a Group.
@ -51,15 +51,15 @@
#define RS_TOKREQ_ANSTYPE_SUMMARY 0x0002
#define RS_TOKREQ_ANSTYPE_DATA 0x0003
const uint8_t RsGxsDataAccess::GXS_REQUEST_STATUS_FAILED = 0;
const uint8_t RsGxsDataAccess::GXS_REQUEST_STATUS_PENDING = 1;
const uint8_t RsGxsDataAccess::GXS_REQUEST_STATUS_PARTIAL = 2;
const uint8_t RsGxsDataAccess::GXS_REQUEST_STATUS_FINISHED_INCOMPLETE = 3;
const uint8_t RsGxsDataAccess::GXS_REQUEST_STATUS_COMPLETE = 4;
const uint8_t RsGxsDataAccess::GXS_REQUEST_STATUS_DONE = 5; // ONCE ALL DATA RETRIEVED.
const uint8_t RsTokenServiceV2::GXS_REQUEST_STATUS_FAILED = 0;
const uint8_t RsTokenServiceV2::GXS_REQUEST_STATUS_PENDING = 1;
const uint8_t RsTokenServiceV2::GXS_REQUEST_STATUS_PARTIAL = 2;
const uint8_t RsTokenServiceV2::GXS_REQUEST_STATUS_FINISHED_INCOMPLETE = 3;
const uint8_t RsTokenServiceV2::GXS_REQUEST_STATUS_COMPLETE = 4;
const uint8_t RsTokenServiceV2::GXS_REQUEST_STATUS_DONE = 5; // ONCE ALL DATA RETRIEVED.
RsGxsDataAccess::RsGxsDataAccess(RsGeneralDataService* ds)
: mDataStore(ds)
: mDataStore(ds), mDataMutex("RsGxsDataAccess")
{
}
@ -302,7 +302,7 @@ bool RsGxsDataAccess::getGroupData(const uint32_t& token, std::list<RsNxsGrp*>&
return false;
}else if(req->token == GXS_REQUEST_STATUS_COMPLETE){
GroupDataReq* gmreq = dynamic_cast<GroupMetaReq*>(req);
GroupDataReq* gmreq = dynamic_cast<GroupDataReq*>(req);
if(gmreq)
{
@ -330,7 +330,7 @@ bool RsGxsDataAccess::getMsgData(const uint32_t& token, NxsMsgDataResult& msgDat
return false;
}else if(req->token == GXS_REQUEST_STATUS_COMPLETE){
MsgDataReq* mdreq = dynamic_cast<GroupMetaReq*>(req);
MsgDataReq* mdreq = dynamic_cast<MsgDataReq*>(req);
if(mdreq)
{
@ -358,7 +358,7 @@ bool RsGxsDataAccess::getMsgSummary(const uint32_t& token, GxsMsgMetaResult& msg
return false;
}else if(req->token == GXS_REQUEST_STATUS_COMPLETE){
MsgMetaReq* mmreq = dynamic_cast<GroupMetaReq*>(req);
MsgMetaReq* mmreq = dynamic_cast<MsgMetaReq*>(req);
if(mmreq)
{
@ -387,7 +387,7 @@ bool RsGxsDataAccess::getMsgList(const uint32_t& token, GxsMsgIdResult& msgIds)
return false;
}else if(req->token == GXS_REQUEST_STATUS_COMPLETE){
MsgIdReq* mireq = dynamic_cast<GroupMetaReq*>(req);
MsgIdReq* mireq = dynamic_cast<MsgIdReq*>(req);
if(mireq)
{
@ -417,7 +417,7 @@ bool RsGxsDataAccess::getGroupList(const uint32_t& token, std::list<RsGxsGroupId
return false;
}else if(req->token == GXS_REQUEST_STATUS_COMPLETE){
GroupIdReq* gireq = dynamic_cast<GroupMetaReq*>(req);
GroupIdReq* gireq = dynamic_cast<GroupIdReq*>(req);
if(gireq)
{
@ -444,7 +444,7 @@ GxsRequest* RsGxsDataAccess::retrieveRequest(const uint32_t& token)
if(mRequests.find(token) == mRequests.end()) return NULL;
GxsRequest* req = mRequests;
GxsRequest* req = mRequests[token];
return req;
}
@ -692,19 +692,19 @@ bool RsGxsDataAccess::getMsgList(MsgIdReq* req)
metaFilter[grpId] = std::map<RsGxsMessageId, RsGxsMsgMetaData*>();
const std::vector<RsMsgMetaData*>& metaV = meta_it->second;
const std::vector<RsGxsMsgMetaData*>& metaV = meta_it->second;
if (onlyLatestMsgs) // THIS ONE IS HARD -> LOTS OF COMP.
{
std::vector<RsMsgMetaData*>::const_iterator vit = metaV.begin();
std::vector<RsGxsMsgMetaData*>::const_iterator vit = metaV.begin();
// RUN THROUGH ALL MSGS... in map origId -> TS.
std::map<std::string, std::pair<std::string, time_t> > origMsgTs;
std::map<std::string, std::pair<std::string, time_t> >::iterator oit;
std::map<RsGxsGroupId, std::pair<RsGxsMessageId, time_t> > origMsgTs;
std::map<RsGxsGroupId, std::pair<RsGxsMessageId, time_t> >::iterator oit;
for(; vit != metaV.end(); vit++)
{
RsMsgMetaData* msgMeta = *vit;
RsGxsMsgMetaData* msgMeta = *vit;
/* if we are grabbing thread Head... then parentId == empty. */
if (onlyThreadHeadMsgs)
@ -750,18 +750,18 @@ bool RsGxsDataAccess::getMsgList(MsgIdReq* req)
// Add the discovered Latest Msgs.
for(oit = origMsgTs.begin(); oit != origMsgTs.end(); oit++)
{
req->mMsgIds.insert(std::make_pair(grpId, oit->second.first));
req->mMsgIds[grpId].push_back(oit->second.first);
}
}
else // ALL OTHER CASES.
{
std::vector<RsMsgMetaData*>::const_iterator vit = metaV.begin();
std::vector<RsGxsMsgMetaData*>::const_iterator vit = metaV.begin();
for(; vit != metaV.end(); vit++)
{
RsMsgMetaData* msgMeta = *vit;
RsGxsMsgMetaData* msgMeta = *vit;
bool add = false;
/* if we are grabbing thread Head... then parentId == empty. */
@ -788,7 +788,7 @@ bool RsGxsDataAccess::getMsgList(MsgIdReq* req)
if (add)
{
req->mMsgIdResult.insert(grpId,msgMeta->mMsgId);
req->mMsgIdResult[grpId].push_back(msgMeta->mMsgId);
}
}
@ -815,7 +815,7 @@ void RsGxsDataAccess::filterMsgList(GxsMsgIdResult& msgIds, const RsTokReqOption
std::vector<RsGxsMessageId>& msgs = mit->second;
std::vector<RsGxsMessageId>::iterator vit = msgs.begin();
const std::map<RsGxsMessageId, RsGxsMsgMetaData*>& meta = cit->second;
const std::map<RsGxsMessageId, RsGxsMsgMetaData*>::const_iterator cit2;
std::map<RsGxsMessageId, RsGxsMsgMetaData*>::const_iterator cit2;
for(; vit != msgs.end();)
{

View File

@ -31,9 +31,9 @@
#include "rsgds.h"
typedef std::map< RsGxsGroupId, std::map<RsGxsMessageId, RsGxsMsgMetaData> > MsgMetaFilter;
typedef std::map< RsGxsGroupId, std::map<RsGxsMessageId, RsGxsMsgMetaData*> > MsgMetaFilter;
class RsGxsDataAccess : public RsTokenService
class RsGxsDataAccess : public RsTokenServiceV2
{
public:
RsGxsDataAccess(RsGeneralDataService* ds);

View File

@ -13,6 +13,9 @@ class GxsRequest
{
public:
virtual ~GxsRequest() { return; }
uint32_t token;
uint32_t reqTime;
@ -69,7 +72,6 @@ class MsgDataReq : public GxsRequest
{
public:
GxsMsgReq mMsgIds;
NxsMsgDataResult mMsgData;
};

View File

@ -31,11 +31,7 @@
#include <list>
#include "serialiser/rsgxsitems.h"
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgReq;
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgIdResult;
typedef std::map<RsGxsGroupId, std::vector<RsGxsMsgMetaData*> > GxsMsgMetaResult;
typedef std::map<RsGxsGroupId, std::vector<RsNxsMsg*> > NxsMsgDataResult;
#include "gxs/rsgxs.h"
#define GXS_REQUEST_TYPE_GROUP_DATA 0x00010000
#define GXS_REQUEST_TYPE_GROUP_META 0x00020000
@ -79,7 +75,7 @@ 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
class RsTokenServiceV2
{
public:
@ -93,8 +89,8 @@ public:
public:
RsTokenService() { return; }
virtual ~RsTokenService() { return; }
RsTokenServiceV2() { return; }
virtual ~RsTokenServiceV2() { return; }
/* Data Requests */

View File

@ -13,10 +13,10 @@
* enumerating all possible changes
* at the interface
*/
class RsGxsChange
class RsGxsNotify
{
public:
RsGxsChange(){ return; }
RsGxsNotify(){ return; }
};
@ -24,7 +24,7 @@ public:
* Relevant to group changes
* TODO: extent to indicate whether a meta change or actual data
*/
class RsGxsGroupChange : RsGxsChange
class RsGxsGroupChange : public RsGxsNotify
{
public:
std::list<RsGxsGroupId> grpIdList;
@ -34,7 +34,7 @@ public:
* Relevant to message changes
* TODO: extent to indicate whether a meta change or actual data
*/
class RsGxsMsgChange : RsGxsChange
class RsGxsMsgChange : public RsGxsNotify
{
public:
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgChangeMap;

View File

@ -182,7 +182,7 @@ public:
*
* @param grpIds
*/
virtual void groupsChanged(std::list<RsGroupId>& grpIds) = 0;
virtual void groupsChanged(std::list<RsGxsGroupId>& grpIds) = 0;
/*!
*
@ -195,7 +195,7 @@ public:
* needed to make requests to the service
* @return handle to token service for this gxs service
*/
virtual RsTokenService* getTokenService() = 0;
virtual RsTokenServiceV2* getTokenService() = 0;
/* Generic Lists */
@ -206,7 +206,7 @@ public:
* @return false if request token is invalid, check token status for error report
*/
virtual bool getGroupList(const uint32_t &token,
std::list<RsGroupId> &groupIds) = 0;
std::list<RsGxsGroupId> &groupIds) = 0;
/*!
* @param token token to be redeemed for this request

View File

@ -53,18 +53,6 @@ class RsGroupMetaData
}
void operator =(const RsGxsGrpMetaData& rGxsMeta);
// {
// this->mAuthorId = rGxsMeta.mAuthorId;
// this->mGroupFlags = rGxsMeta.mGroupFlags;
// this->mGroupId = rGxsMeta.mGroupId;
// this->mGroupStatus = rGxsMeta.mGroupStatus;
// this->mLastPost = rGxsMeta.mLastPost;
// this->mMsgCount = rGxsMeta.mMsgCount;
// this->mPop = rGxsMeta.mPop;
// this->mPublishTs = rGxsMeta.mPublishTs;
// this->mSubscribeFlags = rGxsMeta.mSubscribeFlags;
// this->mGroupName = rGxsMeta.mGroupName;
// }
std::string mGroupId;
std::string mGroupName;

View File

@ -55,6 +55,8 @@ public:
class RsGxsPhotoSerialiser : public RsSerialType
{
public:
RsGxsPhotoSerialiser()
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_PHOTO)
{ return; }

View File

@ -24,7 +24,7 @@ void p3PhotoServiceV2::msgsChanged(
}
RsTokenService* p3PhotoServiceV2::getTokenService() {
RsTokenServiceV2* p3PhotoServiceV2::getTokenService() {
return RsGenExchange::getTokenService();
}
@ -70,8 +70,9 @@ bool p3PhotoServiceV2::getAlbum(const uint32_t& token, std::vector<RsPhotoAlbum>
for(; vit != grpData.end(); vit++)
{
RsGxsGrpItem* item = *vit;
RsPhotoAlbum album = *item;
RsGxsPhotoAlbumItem* item = dynamic_cast<RsGxsPhotoAlbumItem*>(*vit);
RsPhotoAlbum album = item->album;
delete item;
albums.push_back(album);
}
}
@ -80,7 +81,7 @@ bool p3PhotoServiceV2::getAlbum(const uint32_t& token, std::vector<RsPhotoAlbum>
}
bool p3PhotoServiceV2::getPhoto(const uint32_t& token, PhotoResult& photo)
bool p3PhotoServiceV2::getPhoto(const uint32_t& token, PhotoResult& photos)
{
GxsMsgDataMap msgData;
bool ok = RsGenExchange::getMsgData(token, msgData);
@ -101,8 +102,8 @@ bool p3PhotoServiceV2::getPhoto(const uint32_t& token, PhotoResult& photo)
if(item)
{
RsPhotoPhoto photo = *item;
photo[grpId] = photo;
RsPhotoPhoto photo = item->photo;
photos[grpId].push_back(photo);
delete item;
}else
{
@ -121,20 +122,8 @@ bool p3PhotoServiceV2::submitAlbumDetails(RsPhotoAlbum& album)
return false;
}
void p3PhotoServiceV2::operator =(RsPhoto& lPhotos,
const RsGxsPhotoPhotoItem& rPhoto)
{
lPhotos = rPhoto.photo;
}
void p3PhotoServiceV2::operator =(RsPhotoAlbum& lAlbum,
const RsGxsPhotoAlbumItem& rAlbum)
{
lAlbum = rAlbum.album;
}
bool p3PhotoServiceV2::submitPhoto(RsPhotoPhoto& photo)
{
return false;

View File

@ -53,7 +53,7 @@ public:
void msgsChanged(std::map<std::string,
std::vector<std::string> >& msgs);
RsTokenService* getTokenService();
RsTokenServiceV2* getTokenService();
bool getGroupList(const uint32_t &token,
std::list<std::string> &groupIds);
@ -71,11 +71,6 @@ public:
bool getAlbum(const uint32_t &token, std::vector<RsPhotoAlbum> &albums);
bool getPhoto(const uint32_t &token, PhotoResult &photos);
private:
void operator=(RsPhoto& lPhotos, const RsGxsPhotoPhotoItem& rPhoto);
void operator=(RsPhotoAlbum& lAlbum, const RsGxsPhotoAlbumItem& rAlbum);
public:
/** Modifications **/