replaced string grp and msg ids with typedefs

started implementing gen exchange client calls
finished implementing msgrelated info dataAccess routine
more refinements to various interface - need to think about how meta is passed about the various
layers of gxs and kept consistent with sqldb

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-new_cache_system@5321 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2012-07-22 21:38:15 +00:00
parent 3534aad90d
commit 5fbd591517
16 changed files with 903 additions and 188 deletions

View File

@ -235,7 +235,6 @@ RsGxsGrpMetaData* RsDataService::getGrpMeta(RetroCursor &c)
RsNxsGrp* RsDataService::getGroup(RetroCursor &c) RsNxsGrp* RsDataService::getGroup(RetroCursor &c)
{ {
/*! /*!
* grpId, pub admin and pub publish key * grpId, pub admin and pub publish key
* necessary for successful group * necessary for successful group
@ -590,6 +589,8 @@ int RsDataService::retrieveNxsGrps(std::map<std::string, RsNxsGrp *> &grp, bool
} }
} }
} }
return 1;
} }
void RsDataService::retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps){ void RsDataService::retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps){

View File

@ -54,9 +54,9 @@ class GrpLocMetaData {
}; };
typedef std::map<std::string, std::set<std::string> > GxsMsgReq; // <grpId, msgIds> typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgReq; // <grpId, msgIds>
typedef std::map<std::string, std::vector<RsNxsMsg*> > GxsMsgResult; // <grpId, msgs> typedef std::map<RsGxsGroupId, std::vector<RsNxsMsg*> > GxsMsgResult; // <grpId, msgs>
typedef std::map<std::string, std::vector<RsGxsMsgMetaData*> > GxsMsgMetaResult; // <grpId, msg metadatas> 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 * The main role of GDS is the preparation and handing out of messages requested from
@ -102,14 +102,16 @@ public:
* @param cache whether to store retrieval in mem for faster later retrieval * @param cache whether to store retrieval in mem for faster later retrieval
* @return error code * @return error code
*/ */
virtual int retrieveNxsGrps(std::map<std::string, RsNxsGrp*>& grp, bool cache) = 0; virtual int retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp*>& grp, bool cache) = 0;
/*! /*!
* Retrieves meta data of all groups stored (most current versions only) * Retrieves meta data of all groups stored (most current versions only)
* @param cache whether to store retrieval in mem for faster later retrieval *
* @param grp if null grpIds entries are made, only meta for those grpId are retrieved \n
* , if grpId is failed to be retrieved it will be erased from map
* @return error code * @return error code
*/ */
virtual int retrieveGxsGrpMetaData(std::map<std::string, RsGxsGrpMetaData*>& grp) = 0; virtual int retrieveGxsGrpMetaData(std::map<RsGxsGroupId, RsGxsGrpMetaData*>& grp) = 0;
/*! /*!
* Retrieves meta data of all groups stored (most current versions only) * Retrieves meta data of all groups stored (most current versions only)
@ -125,14 +127,14 @@ public:
* @param msgIds ids of messages to be removed * @param msgIds ids of messages to be removed
* @return error code * @return error code
*/ */
virtual int removeMsgs(const std::string grpId, const std::vector<std::string>& msgIds) = 0; virtual int removeMsgs(const GxsMsgReq& msgIds) = 0;
/*! /*!
* remove groups in data store listed in grpIds param * remove groups in data store listed in grpIds param
* @param grpIds ids of groups to be removed * @param grpIds ids of groups to be removed
* @return error code * @return error code
*/ */
virtual int removeGroups(const std::vector<std::string>& grpIds) = 0; virtual int removeGroups(const std::vector<RsGxsGroupId>& grpIds) = 0;
/*! /*!
* @return the cache size set for this RsGeneralDataService in bytes * @return the cache size set for this RsGeneralDataService in bytes

View File

@ -30,43 +30,154 @@ void RsGenExchange::tick()
} }
bool RsGenExchange::getGroupList(const uint32_t &token, std::list<std::string> &groupIds) bool RsGenExchange::getGroupList(const uint32_t &token, std::list<RsGxsGroupId> &groupIds)
{ {
return mDataAccess->getGroupList(token, groupIds);
return false;
} }
bool RsGenExchange::getMsgList(const uint32_t &token, bool RsGenExchange::getMsgList(const uint32_t &token,
std::map<std::string, std::vector<std::string> > &msgIds) GxsMsgIdResult &msgIds)
{ {
return mDataAccess->getMsgList(token, msgIds);
return false;
} }
bool RsGenExchange::getGroupMeta(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo) bool RsGenExchange::getGroupMeta(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo)
{ {
return false; std::list<RsGxsGrpMetaData*> metaL;
bool ok = mDataAccess->getGroupSummary(token, metaL);
groupInfo = metaL;
std::list<RsGroupMetaData*>::iterator cit = metaL;
for(; cit != metaL.end(); cit++)
delete *cit;
return ok;
} }
bool RsGenExchange::getMsgMeta(const uint32_t &token,
std::map<std::string, std::vector<RsMsgMetaData> > &msgInfo)
{
bool RsGenExchange::getMsgMeta(const uint32_t &token,
GxsMsgMetaMap &msgInfo)
{
std::list<RsGxsMsgMetaData*> metaL;
GxsMsgMetaResult result;
bool ok = mDataAccess->getMsgSummary(token, result);
GxsMsgMetaResult::iterator mit = result.begin();
for(; mit != result.end(); mit++)
{
std::vector<RsGxsMsgMetaData*>& metaV = mit->second;
msgInfo[mit->first] = metaV;
std::vector<RsGxsMsgMetaData*>::iterator vit = metaV.begin();
for(; vit != metaV.end(); vit++)
{
delete *vit;
}
}
return ok;
} }
bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem *> grpItem) bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem *> grpItem)
{ {
return false;
std::list<RsNxsGrp*> nxsGrps;
bool ok = mDataAccess->getGroupData(token, nxsGrps);
std::list<RsNxsGrp*>::iterator lit = nxsGrps.begin();
if(ok)
{
for(; lit != nxsGrps.end(); lit++)
{
RsTlvBinaryData& data = *lit->grp;
RsItem* item = mSerialiser->deserialise(data.bin_data, &data.bin_len);
RsGxsGrpItem* gItem = dynamic_cast<RsGxsGrpItem*>(item);
grpItem.push_back(gItem);
delete *lit;
}
}
return ok;
} }
bool RsGenExchange::getMsgData(const uint32_t &token, bool RsGenExchange::getMsgData(const uint32_t &token,
std::map<std::string, std::vector<RsGxsMsgItem *> > &msgItems) GxsMsgDataMap &msgItems)
{ {
return false; NxsMsgDataResult msgResult;
bool ok = mDataAccess->getMsgData(token, msgResult);
NxsMsgDataResult::iterator mit = msgResult.begin();
if(ok)
{
for(; mit != msgResult.end(); mit++)
{
std::vector<RsGxsMsgItem*> gxsMsgItems;
RsGxsGroupId& grpId = mit->first;
std::vector<RsNxsMsg*>& nxsMsgsV = mit->second;
std::vector<RsNxsMsg*>::iterator vit
= nxsMsgsV.begin();
for(; vit != nxsMsgsV.end(); vit++)
{
RsNxsMsg*& msg = *vit;
RsItem* item = mSerialiser->deserialise(msg->msg.bin_data,
&msg->msg.bin_len);
RsGxsMsgItem* mItem = dynamic_cast<RsGxsMsgItem*>(item);
gxsMsgItems.push_back(mItem);
delete msg;
}
msgItems[grpId] = gxsMsgItems;
}
}
return ok;
} }
void RsGenExchange::operator =(std::list<RsGroupMetaData>& lMeta, std::list<RsGxsGrpMetaData*>& rGxsMeta)
{
std::list<RsGxsGrpMetaData*>::const_iterator cit = rGxsMeta.begin();
for(; cit != rGxsMeta.end(); cit++)
{
const RsGxsGrpMetaData*& gxm = *cit;
RsGroupMetaData gm;
gm.mAuthorId = gxm->mAuthorId;
gm.mGroupFlags = gxm->mGroupFlags;
gm.mGroupId = gxm->mGroupId;
gm.mGroupStatus = gxm->mGroupStatus;
gm.mLastPost = gxm->mLastPost;
gm.mMsgCount = gxm->mMsgCount;
gm.mPop = gxm->mPop;
gm.mPublishTs = gxm->mPublishTs;
gm.mSubscribeFlags = gxm->mSubscribeFlags;
gm.mGroupName = gxm->mGroupName;
lMeta.push_back(gm);
}
}
void RsGenExchange::operator =(std::vector<RsMsgMetaData>& lMeta, std::vector<RsGxsMsgMetaData*>& rGxsMeta)
{
std::vector<RsMsgMetaData*>::const_iterator vit = rGxsMeta.begin();
for(; vit != rGxsMeta.end(); vit++)
{
const RsGxsMsgMetaData*& mxm = *vit;
RsMsgMetaData mm;
mm.mAuthorId = mxm->mAuthorId;
mm.mChildTs = mxm->mChildTs;
mm.mGroupId = mxm->mGroupId;
mm.mMsgFlags = mxm->mMsgFlags;
mm.mMsgId = mxm->mMsgId;
mm.mMsgName = mxm->mMsgName;
mm.mMsgStatus = mxm->mMsgStatus;
mm.mOrigMsgId = mxm->mOrigMsgId;
mm.mParentId = mxm->mParentId;
mm.mPublishTs = mxm->mPublishTs;
mm.mThreadId = mxm->mThreadId;
lMeta.push_back(mm);
}
}
RsTokenService* RsGenExchange::getTokenService() RsTokenService* RsGenExchange::getTokenService()
{ {
@ -94,10 +205,6 @@ void RsGenExchange::notifyNewMessages(std::vector<RsNxsMsg *> messages)
} }
bool RsGenExchange::subscribeToGroup(std::string &grpId, bool subscribe)
{
return false;
}
bool RsGenExchange::publishGroup(RsGxsGrpItem *grpItem) bool RsGenExchange::publishGroup(RsGxsGrpItem *grpItem)
{ {

View File

@ -1,6 +1,31 @@
#ifndef RSGENEXCHANGE_H #ifndef RSGENEXCHANGE_H
#define RSGENEXCHANGE_H #define RSGENEXCHANGE_H
/*
* libretroshare/src/retroshare: rsphoto.h
*
* RetroShare C++ Interface.
*
* Copyright 2012-2012 by Christopher Evi-Parker, 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 <queue> #include <queue>
#include "rsgxs.h" #include "rsgxs.h"
@ -10,6 +35,9 @@
#include "retroshare/rsgxsservice.h" #include "retroshare/rsgxsservice.h"
#include "serialiser/rsnxsitems.h" #include "serialiser/rsnxsitems.h"
typedef std::map<RsGxsGroupId, std::vector<RsGxsMsgItem*> > GxsMsgDataMap;
typedef std::map<RsGxsGroupId, RsGxsGrpItem*> GxsGroupDataMap;
typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > GxsMsgMetaMap;
/*! /*!
@ -76,7 +104,7 @@ public:
*/ */
RsTokenService* getTokenService(); RsTokenService* getTokenService();
public: protected:
/** data access functions **/ /** data access functions **/
@ -86,14 +114,14 @@ public:
* @param groupIds * @param groupIds
* @return false if token cannot be redeemed, if false you may have tried to redeem when not ready * @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); bool getGroupList(const uint32_t &token, std::list<RsGxsGroupId> &groupIds);
/*! /*!
* Retrieve msg list for a given token sectioned by group Ids * Retrieve msg list for a given token sectioned by group Ids
* @param token token to be redeemed * @param token token to be redeemed
* @param msgIds a map of grpId -> msgList (vector) * @param msgIds a map of grpId -> msgList (vector)
*/ */
bool getMsgList(const uint32_t &token, std::map<std::string, std::vector<std::string> > &msgIds); bool getMsgList(const uint32_t &token, GxsMsgIdResult &msgIds);
/*! /*!
@ -108,7 +136,7 @@ public:
* @param token token to be redeemed * @param token token to be redeemed
* @param msgInfo the meta data to be retrieved for token store here * @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); bool getMsgMeta(const uint32_t &token, GxsMsgMetaMap &msgInfo);
/*! /*!
* retrieves group data associated to a request token * retrieves group data associated to a request token
@ -122,9 +150,9 @@ public:
* @param token token to be redeemed for message item retrieval * @param token token to be redeemed for message item retrieval
* @param msgItems * @param msgItems
*/ */
bool getMsgData(const uint32_t &token, std::map<std::string, std::vector<RsGxsMsgItem*> >& msgItems); bool getMsgData(const uint32_t &token, GxsMsgDataMap& msgItems);
public: protected:
/** Modifications **/ /** Modifications **/
@ -147,31 +175,26 @@ public:
bool publishMsg(RsGxsMsgItem* msgItem); bool publishMsg(RsGxsMsgItem* msgItem);
/*!
*
* @param grpId
* @param subscribe
* @return false subscription fails
*/
bool subscribeToGroup(std::string& grpId, bool subscribe);
protected: protected:
/** Notifications **/ /** Notifications **/
/*! /*!
* This confirm this class as an abstract one that \n * This confirms this class as an abstract one that \n
* should not be instantiated \n * should not be instantiated \n
* The deriving class should implement this function \n * The deriving class should implement this function \n
* as its is called by the backend GXS system to \n * as it is called by the backend GXS system to \n
* update client of changes which should \n * update client of changes which should \n
* instigate client to retrieve new content from system * instigate client to retrieve new content from the system
* @param changes the changes that have occured to data held by this service * @param changes the changes that have occured to data held by this service
*/ */
virtual void notifyChanges(std::vector<RsGxsChange*>& changes) = 0; virtual void notifyChanges(std::vector<RsGxsChange*>& changes) = 0;
private: private:
void operator=(std::list<RsGroupMetaData>& lMeta, std::list<RsGxsGrpMetaData*>& rGxsMeta);
void operator=(std::vector<RsMsgMetaData>& lMeta, std::vector<RsGxsMsgMetaData*>& rGxsMeta);
void processRecvdData(); void processRecvdData();
void processRecvdMessages(); void processRecvdMessages();

View File

@ -8,6 +8,11 @@
#include "serialiser/rstlvtypes.h" #include "serialiser/rstlvtypes.h"
#include "serialiser/rstlvkeys.h" #include "serialiser/rstlvkeys.h"
typedef std::string RsGxsGroupId;
typedef std::string RsGxsMessageId;
typedef std::pair<RsGxsGroupId, RsGxsMessageId> RsGxsGrpMsgIdPair;
class RsGxsGrpMetaData class RsGxsGrpMetaData
{ {
public: public:
@ -19,8 +24,8 @@ public:
void clear(); void clear();
std::string mGroupId; RsGxsGroupId mGroupId;
std::string mOrigGrpId; RsGxsGroupId mOrigGrpId;
std::string mGroupName; std::string mGroupName;
uint32_t mGroupFlags; uint32_t mGroupFlags;
uint32_t mPublishTs; uint32_t mPublishTs;
@ -58,12 +63,12 @@ public:
uint32_t serial_size(); uint32_t serial_size();
void clear(); void clear();
std::string mGroupId; RsGxsGroupId mGroupId;
std::string mMsgId; RsGxsMessageId mMsgId;
std::string mThreadId; RsGxsMessageId mThreadId;
std::string mParentId; RsGxsMessageId mParentId;
std::string mOrigMsgId; RsGxsMessageId mOrigMsgId;
std::string mAuthorId; std::string mAuthorId;
RsTlvKeySignature pubSign; RsTlvKeySignature pubSign;

View File

@ -148,22 +148,60 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
return true; return true;
} }
bool RsGxsDataAccess::requestGroupSubscribe(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::string &grpId) bool RsGxsDataAccess::requestSetGroupSubscribeFlags(uint32_t& token, const RsGxsGroupId &grpId, uint32_t subscribeFlags,
uint32_t subscribeMask)
{ {
generateToken(token); generateToken(token);
GroupMetaReq* req = new GroupDataReq(); GroupSetFlagReq* req = new GroupSetFlagReq();
req->mGroupIds.push_back(grpId);
std::cerr << "RsGxsDataAccess::requestGroupSubscribe() gets Token: " << token << std::endl; req->flag = subscribeFlags;
req->flagMask = subscribeMask;
req->grpId = grpId;
setReq(req, token, ansType, opts); std::cerr << "RsGxsDataAccess::requestSetGroupSubscribeFlags() gets Token: " << token << std::endl;
storeRequest(req); storeRequest(req);
return false; return false;
} }
bool RsGxsDataAccess::requestSetGroupStatus(uint32_t& token, const RsGxsGroupId& grpId, uint32_t status, uint32_t statusMask)
{
generateToken(token);
GroupSetFlagReq* req = new GroupSetFlagReq();
req->flag = status;
req->flagMask = statusMask;
req->grpId = grpId;
std::cerr << "RsGxsDataAccess::requestSetGroupStatus() gets Token: " << token << std::endl;
storeRequest(req);
return true;
}
bool RsGxsDataAccess::requestSetMessageStatus(uint32_t& token, const RsGxsGrpMsgIdPair &msgId, uint32_t status,
uint32_t statusMask)
{
generateToken(token);
MessageSetFlagReq* req = new MessageSetFlagReq();
req->flag = status;
req->flagMask = statusMask;
req->msgId = msgId;
std::cerr << "RsGxsDataAccess::requestSetGroupStatus() gets Token: " << token << std::endl;
storeRequest(req);
return true;
}
void RsGxsDataAccess::setReq(GxsRequest* req, const uint32_t& token, const uint32_t& ansType, const RsTokReqOptions& opts) const void RsGxsDataAccess::setReq(GxsRequest* req, const uint32_t& token, const uint32_t& ansType, const RsTokReqOptions& opts) const
{ {
req->token = token; req->token = token;
@ -266,7 +304,7 @@ bool RsGxsDataAccess::getGroupData(const uint32_t& token, std::list<RsNxsGrp*>&
return true; return true;
} }
bool RsGxsDataAccess::getMsgData(const uint32_t& token, GxsMsgDataResult& msgData) bool RsGxsDataAccess::getMsgData(const uint32_t& token, NxsMsgDataResult& msgData)
{ {
GxsRequest* req = retrieveRequest(token); GxsRequest* req = retrieveRequest(token);
@ -340,7 +378,7 @@ bool RsGxsDataAccess::getMsgList(const uint32_t& token, GxsMsgIdResult& msgIds)
return true; return true;
} }
bool RsGxsDataAccess::getGroupList(const uint32_t& token, std::list<std::string>& groupIds) bool RsGxsDataAccess::getGroupList(const uint32_t& token, std::list<RsGxsGroupId>& groupIds)
{ {
GxsRequest* req = retrieveRequest(token); GxsRequest* req = retrieveRequest(token);
@ -481,10 +519,10 @@ void RsGxsDataAccess::processRequests()
bool RsGxsDataAccess::getGroupData(GroupDataReq* req) bool RsGxsDataAccess::getGroupData(GroupDataReq* req)
{ {
std::map<std::string, RsNxsGrp*> grpData; std::map<RsGxsGroupId, RsNxsGrp*> grpData;
mDataStore->retrieveNxsGrps(grpData, true); mDataStore->retrieveNxsGrps(grpData, true);
std::map<std::string, RsNxsGrp*>::iterator mit = grpData.begin(); std::map<RsGxsGroupId, RsNxsGrp*>::iterator mit = grpData.begin();
for(; mit != grpData.end(); mit++) for(; mit != grpData.end(); mit++)
req->mGroupData.push_back(mit->second); req->mGroupData.push_back(mit->second);
@ -494,16 +532,16 @@ bool RsGxsDataAccess::getGroupData(GroupDataReq* req)
bool RsGxsDataAccess::getGroupSummary(GroupMetaReq* req) bool RsGxsDataAccess::getGroupSummary(GroupMetaReq* req)
{ {
std::map<std::string, RsGxsGrpMetaData*> grpMeta; std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMeta;
std::list<std::string>::const_iterator lit = req->mGroupIds.begin(); std::list<RsGxsGroupId>::const_iterator lit = req->mGroupIds.begin();
for(; lit != req->mGroupIds.end(); lit++) for(; lit != req->mGroupIds.end(); lit++)
grpMeta[*lit] = NULL; grpMeta[*lit] = NULL;
mDataStore->retrieveGxsGrpMetaData(grpMeta); mDataStore->retrieveGxsGrpMetaData(grpMeta);
std::map<std::string, RsGxsGrpMetaData*>::iterator mit = grpMeta.begin(); std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit = grpMeta.begin();
for(; mit != grpMeta.end(); mit++) for(; mit != grpMeta.end(); mit++)
req->mGroupMetaData.push_back(mit->second); req->mGroupMetaData.push_back(mit->second);
@ -513,9 +551,9 @@ bool RsGxsDataAccess::getGroupSummary(GroupMetaReq* req)
bool RsGxsDataAccess::getGroupList(GroupIdReq* req) bool RsGxsDataAccess::getGroupList(GroupIdReq* req)
{ {
std::map<std::string, RsGxsGrpMetaData*> grpMeta; std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMeta;
std::list<std::string>::const_iterator lit = req->mGroupIds.begin(); std::list<RsGxsGroupId>::const_iterator lit = req->mGroupIds.begin();
for(; lit != req->mGroupIds.end(); lit++) for(; lit != req->mGroupIds.end(); lit++)
grpMeta[*lit] = NULL; grpMeta[*lit] = NULL;
@ -549,7 +587,7 @@ bool RsGxsDataAccess::getMsgData(MsgDataReq* req)
bool RsGxsDataAccess::getMsgSummary(MsgMetaReq* req) bool RsGxsDataAccess::getMsgSummary(MsgMetaReq* req)
{ {
GxsMsgMetaResult result; GxsMsgMetaResult result;
std::vector<std::string> groupIds; std::vector<RsGxsGroupId> groupIds;
GxsMsgReq::iterator mit = req->mMsgIds.begin(); GxsMsgReq::iterator mit = req->mMsgIds.begin();
for(; mit != req->mMsgIds.end(); mit++) for(; mit != req->mMsgIds.end(); mit++)
groupIds.push_back(mit->first); groupIds.push_back(mit->first);
@ -564,31 +602,236 @@ bool RsGxsDataAccess::getMsgSummary(MsgMetaReq* req)
bool RsGxsDataAccess::getMsgList(MsgIdReq* req) bool RsGxsDataAccess::getMsgList(MsgIdReq* req)
{ {
GxsMsgMetaResult result; GxsMsgMetaResult result;
std::vector<std::string> groupIds; std::vector<RsGxsGroupId> groupIds;
GxsMsgReq::iterator mit = req->mMsgIds.begin(); GxsMsgReq::iterator mit = req->mMsgIds.begin();
const RsTokReqOptions& opts = req->Options;
for(; mit != req->mMsgIds.end(); mit++) for(; mit != req->mMsgIds.end(); mit++)
groupIds.push_back(mit->first); groupIds.push_back(mit->first);
{
RsStackMutex stack(mDataMutex);
mDataStore->retrieveGxsMsgMetaData(groupIds, result); mDataStore->retrieveGxsMsgMetaData(groupIds, result);
GxsMsgMetaResult::iterator mit2 = result.begin();
for(; mit2 != result.end(); mit2++)
{
std::vector<RsGxsMsgMetaData*>& msgIdV = mit2->second;
std::vector<RsGxsMsgMetaData*>::iterator vit = mit2->second.begin();
std::vector<std::string> msgIds;
for(; vit != mit2->second.end(); vit++)
{
msgIds.push_back((*vit)->mMsgId);
delete *vit;
} }
req->mMsgIdResult.insert(std::pair<std::string,
std::vector<std::string> >(mit2->first, msgIds)); /* CASEs this handles.
* Input is groupList + Flags.
* 1) No Flags => All Messages in those Groups.
*
*/
std::cerr << "RsGxsDataAccess::getMsgList()";
std::cerr << std::endl;
bool onlyOrigMsgs = false;
bool onlyLatestMsgs = false;
bool onlyThreadHeadMsgs = false;
// Can only choose one of these two.
if (opts.mOptions & RS_TOKREQOPT_MSG_ORIGMSG)
{
std::cerr << "RsGxsDataAccess::getMsgList() MSG_ORIGMSG";
std::cerr << std::endl;
onlyOrigMsgs = true;
}
else if (opts.mOptions & RS_TOKREQOPT_MSG_LATEST)
{
std::cerr << "RsGxsDataAccess::getMsgList() MSG_LATEST";
std::cerr << std::endl;
onlyLatestMsgs = true;
}
if (opts.mOptions & RS_TOKREQOPT_MSG_THREAD)
{
std::cerr << "RsGxsDataAccess::getMsgList() MSG_THREAD";
std::cerr << std::endl;
onlyThreadHeadMsgs = true;
}
GxsMsgMetaResult::iterator meta_it;
MsgMetaFilter metaFilter;
for(meta_it = result.begin(); meta_it != result.end(); meta_it++)
{
const RsGxsGroupId& grpId = meta_it->first;
metaFilter[grpId] = std::map<RsGxsMessageId, RsGxsMsgMetaData*>();
const std::vector<RsMsgMetaData*>& metaV = meta_it->second;
if (onlyLatestMsgs) // THIS ONE IS HARD -> LOTS OF COMP.
{
std::vector<RsMsgMetaData*>::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;
for(; vit != metaV.end(); vit++)
{
RsMsgMetaData* msgMeta = *vit;
/* if we are grabbing thread Head... then parentId == empty. */
if (onlyThreadHeadMsgs)
{
if (!(msgMeta->mParentId.empty()))
{
continue;
}
}
oit = origMsgTs.find(msgMeta->mOrigMsgId);
bool addMsg = false;
if (oit == origMsgTs.end())
{
std::cerr << "RsGxsDataAccess::getMsgList() Found New OrigMsgId: ";
std::cerr << msgMeta->mOrigMsgId;
std::cerr << " MsgId: " << msgMeta->mMsgId;
std::cerr << " TS: " << msgMeta->mPublishTs;
std::cerr << std::endl;
addMsg = true;
}
// check timestamps.
else if (oit->second.second < msgMeta->mPublishTs)
{
std::cerr << "RsGxsDataAccess::getMsgList() Found Later Msg. OrigMsgId: ";
std::cerr << msgMeta->mOrigMsgId;
std::cerr << " MsgId: " << msgMeta->mMsgId;
std::cerr << " TS: " << msgMeta->mPublishTs;
addMsg = true;
}
if (addMsg)
{
// add as latest. (overwriting if necessary)
origMsgTs[msgMeta->mOrigMsgId] = std::make_pair(msgMeta->mMsgId, msgMeta->mPublishTs);
metaFilter[grpId].insert(std::make_pair(msgMeta->mMsgId, msgMeta));
}
}
// Add the discovered Latest Msgs.
for(oit = origMsgTs.begin(); oit != origMsgTs.end(); oit++)
{
req->mMsgIds.insert(std::make_pair(grpId, oit->second.first));
} }
}
else // ALL OTHER CASES.
{
std::vector<RsMsgMetaData*>::const_iterator vit = metaV.begin();
for(; vit != metaV.end(); vit++)
{
RsMsgMetaData* msgMeta = *vit;
bool add = false;
/* if we are grabbing thread Head... then parentId == empty. */
if (onlyThreadHeadMsgs)
{
if (!(msgMeta->mParentId.empty()))
{
continue;
}
}
if (onlyOrigMsgs)
{
if (msgMeta->mMsgId == msgMeta->mOrigMsgId)
{
add = true;
}
}
else
{
add = true;
}
if (add)
{
req->mMsgIdResult.insert(grpId,msgMeta->mMsgId);
}
}
}
}
filterMsgList(req->mMsgIdResult, opts, metaFilter);
return true; return true;
} }
void RsGxsDataAccess::filterMsgList(GxsMsgIdResult& msgIds, const RsTokReqOptions& opts,
const MsgMetaFilter& msgMetas) const
{
GxsMsgIdResult::iterator mit = msgIds.begin();
for(;mit != msgIds.end(); mit++)
{
MsgMetaFilter::const_iterator cit = msgMetas.find(mit->first);
if(cit == msgMetas.end())
continue;
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;
for(; vit != msgs.end();)
{
bool keep = false;
if( (cit2 = meta.find(*vit)) != meta.end() )
{
keep = checkMsgFilter(opts, cit2->second);
}
if(keep)
{
vit++;
}else
{
vit = msgs.erase(vit);
}
}
}
}
bool RsGxsDataAccess::checkMsgFilter(const RsTokReqOptions& opts, const RsGxsMsgMetaData* meta) const
{
bool statusMatch = false;
if (opts.mStatusMask)
{
// Exact Flags match required.
if ((opts.mStatusMask & opts.mStatusFilter) == (opts.mStatusMask & meta->mMsgStatus))
{
std::cerr << "checkMsgFilter() Accepting Msg as StatusMatches: ";
std::cerr << " Mask: " << opts.mStatusMask << " StatusFilter: " << opts.mStatusFilter;
std::cerr << " MsgStatus: " << meta->mMsgStatus << " MsgId: " << meta->mMsgId;
std::cerr << std::endl;
statusMatch = true;
}
else
{
std::cerr << "checkMsgFilter() Dropping Msg due to !StatusMatch ";
std::cerr << " Mask: " << opts.mStatusMask << " StatusFilter: " << opts.mStatusFilter;
std::cerr << " MsgStatus: " << meta->mMsgStatus << " MsgId: " << meta->mMsgId;
std::cerr << std::endl;
}
}
else
{
// no status comparision,
statusMatch = true;
}
return statusMatch;
}

View File

@ -1,76 +1,37 @@
#ifndef RSGXSDATAACCESS_H #ifndef RSGXSDATAACCESS_H
#define RSGXSDATAACCESS_H #define RSGXSDATAACCESS_H
/*
* libretroshare/src/retroshare: rsgxsdataaccess.cc
*
* 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 "rstokenservice.h" #include "rstokenservice.h"
#include "rsgxsrequesttypes.h"
#include "rsgds.h" #include "rsgds.h"
class GxsRequest typedef std::map< RsGxsGroupId, std::map<RsGxsMessageId, RsGxsMsgMetaData> > MsgMetaFilter;
{
public:
uint32_t token;
uint32_t reqTime;
uint32_t ansType;
uint32_t reqType;
RsTokReqOptions Options;
uint32_t status;
};
class GroupMetaReq : public GxsRequest
{
public:
std::list<std::string> mGroupIds;
std::list<RsGxsGrpMetaData*> mGroupMetaData;
};
class GroupIdReq : public GxsRequest
{
public:
std::list<std::string> mGroupIds;
std::list<std::string> mGroupIdResult;
};
class GroupDataReq : public GxsRequest
{
public:
std::list<std::string> mGroupIds;
std::list<RsNxsGrp*> mGroupData;
};
class MsgIdReq : public GxsRequest
{
public:
GxsMsgReq mMsgIds;
GxsMsgIdResult mMsgIdResult;
};
class MsgMetaReq : public GxsRequest
{
public:
GxsMsgReq mMsgIds;
GxsMsgMetaResult mMsgMetaData;
};
class MsgDataReq : public GxsRequest
{
public:
GxsMsgReq mMsgIds;
GxsMsgDataResult mMsgData;
};
class RsGxsDataAccess : public RsTokenService class RsGxsDataAccess : public RsTokenService
{ {
@ -90,7 +51,7 @@ public:
* @param groupIds * @param groupIds
* @return * @return
*/ */
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &groupIds); bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId> &groupIds);
/*! /*!
* For requesting info on all messages of one or more groups * For requesting info on all messages of one or more groups
@ -103,17 +64,36 @@ public:
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const GxsMsgReq&); bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const GxsMsgReq&);
/*! /*!
* More involved for request of particular information for msg * This sets the status of the message
* @param token set to value if , should be discarded if routine returns false * @param msgId the message id to set status for
* @param ansType * @param status status
* @param opts * @param statusMask the mask for the settings targetted
* @param msgIds * @return true if request made successfully, false otherwise
* @return true if successful in placing request, false otherwise
*/ */
bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, bool requestSetMessageStatus(uint32_t &token, const RsGxsGrpMsgIdPair &msgId,
const GxsMsgReq &msgIds); const uint32_t status, const uint32_t statusMask);
/*!
*
* @param token
* @param grpId
* @param status
* @param statusMask
* @return true if request made successfully, false otherwise
*/
bool requestSetGroupStatus(uint32_t &token, const RsGxsGroupId &grpId, const uint32_t status,
const uint32_t statusMask);
/*!
* Use request status to find out if successfully set
* @param groupId
* @param subscribeFlags
* @param subscribeMask
* @return true if request made successfully, false otherwise
*/
bool requestSetGroupSubscribeFlags(uint32_t& token, const RsGxsGroupId &groupId, uint32_t subscribeFlags,
uint32_t subscribeMask);
bool requestGroupSubscribe(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::string &grpId);
/* Poll */ /* Poll */
uint32_t requestStatus(const uint32_t token); uint32_t requestStatus(const uint32_t token);
@ -123,8 +103,17 @@ public:
/** E: RsTokenService **/ /** E: RsTokenService **/
public: public:
bool addGroupData(RsNxsGrp* grp);
bool addMsgData(RsNxsMsg* msg);
public:
/*!
* This must be called periodically to progress requests
*/
void processRequests(); void processRequests();
/*! /*!
@ -170,7 +159,7 @@ public:
* @param msgData * @param msgData
* @return false if data cannot be found for token * @return false if data cannot be found for token
*/ */
bool getMsgData(const uint32_t &token, GxsMsgDataResult& msgData); bool getMsgData(const uint32_t &token, NxsMsgDataResult& msgData);
private: private:
@ -181,6 +170,12 @@ private:
* @param token is assigned a unique token value * @param token is assigned a unique token value
*/ */
void generateToken(uint32_t &token); void generateToken(uint32_t &token);
/*!
*
* @param token the value of the token for the request object handle wanted
* @return the request associated to this token
*/
GxsRequest* retrieveRequest(const uint32_t& token); GxsRequest* retrieveRequest(const uint32_t& token);
/*! /*!
@ -206,12 +201,31 @@ private:
*/ */
bool clearRequest(const uint32_t &token); bool clearRequest(const uint32_t &token);
/*!
*
* @param token
* @param status
* @return
*/
bool updateRequestStatus(const uint32_t &token, const uint32_t &status); bool updateRequestStatus(const uint32_t &token, const uint32_t &status);
/*!
*
* @param token
* @param status
* @param reqtype
* @param anstype
* @param ts
* @return
*/
bool checkRequestStatus(const uint32_t &token, uint32_t &status, uint32_t &reqtype, uint32_t &anstype, time_t &ts); 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) // special ones for testing (not in final design)
/*!
*
* @param tokens
* @return
*/
bool tokenList(std::list<uint32_t> &tokens); bool tokenList(std::list<uint32_t> &tokens);
bool popRequestInList(const uint32_t &token, std::string &id); bool popRequestInList(const uint32_t &token, std::string &id);
bool popRequestOutList(const uint32_t &token, std::string &id); bool popRequestOutList(const uint32_t &token, std::string &id);
@ -229,6 +243,8 @@ private:
private: private:
/* These perform the actual blocking retrieval of data */
/*! /*!
* Attempts to retrieve group id list from data store * Attempts to retrieve group id list from data store
* @param req * @param req
@ -238,6 +254,7 @@ private:
/*! /*!
* Attempts to retrieve msg id list from data store * Attempts to retrieve msg id list from data store
* Computationally/CPU-Bandwidth expensive
* @param req * @param req
* @return false if unsuccessful, true otherwise * @return false if unsuccessful, true otherwise
*/ */
@ -272,6 +289,24 @@ private:
*/ */
bool getMsgData(MsgDataReq* req); bool getMsgData(MsgDataReq* req);
/*!
* This filter msgs based of options supplied (at the moment just status masks)
* @param msgIds The msgsIds to filter
* @param opts the request options set by user
* @param meta The accompanying meta information for msg, ids
*/
void filterMsgList(GxsMsgIdResult& msgIds, const RsTokReqOptions& opts, const MsgMetaFilter& meta) const;
/*!
* This applies the options to the meta to find out if the message satisfies
* them
* @param opts options containing filters to check
* @param meta meta containing currently defined options for msg
* @return true if msg meta passed all options
*/
bool checkMsgFilter(const RsTokReqOptions& opts, const RsGxsMsgMetaData* meta) const;
private: private:
RsGeneralDataService* mDataStore; RsGeneralDataService* mDataStore;

View File

@ -0,0 +1,104 @@
/*
* rsgxsrequesttypes.h
*
* Created on: 21 Jul 2012
* Author: crispy
*/
#ifndef RSGXSREQUESTTYPES_H_
#define RSGXSREQUESTTYPES_H_
class GxsRequest
{
public:
uint32_t token;
uint32_t reqTime;
uint32_t ansType;
uint32_t reqType;
RsTokReqOptions Options;
uint32_t status;
};
class GroupMetaReq : public GxsRequest
{
public:
std::list<std::string> mGroupIds;
std::list<RsGxsGrpMetaData*> mGroupMetaData;
};
class GroupIdReq : public GxsRequest
{
public:
std::list<std::string> mGroupIds;
std::list<std::string> mGroupIdResult;
};
class GroupDataReq : public GxsRequest
{
public:
std::list<std::string> mGroupIds;
std::list<RsNxsGrp*> mGroupData;
};
class MsgIdReq : public GxsRequest
{
public:
GxsMsgReq mMsgIds;
GxsMsgIdResult mMsgIdResult;
};
class MsgMetaReq : public GxsRequest
{
public:
GxsMsgReq mMsgIds;
GxsMsgMetaResult mMsgMetaData;
};
class MsgDataReq : public GxsRequest
{
public:
GxsMsgReq mMsgIds;
NxsMsgDataResult mMsgData;
};
class GroupSetFlagReq : public GxsRequest
{
public:
const static uint32_t FLAG_SUBSCRIBE;
const static uint32_t FLAG_STATUS;
uint8_t type;
uint32_t flag;
uint32_t flagMask;
RsGxsGroupId grpId;
};
class MessageSetFlagReq : public GxsRequest
{
public:
const static uint32_t FLAG_STATUS;
uint8_t type;
uint32_t flag;
uint32_t flagMask;
RsGxsGrpMsgIdPair msgId;
};
#endif /* RSGXSREQUESTTYPES_H_ */

View File

@ -32,10 +32,10 @@
#include "serialiser/rsgxsitems.h" #include "serialiser/rsgxsitems.h"
typedef std::map<std::string, std::vector<std::string> > GxsMsgReq; typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgReq;
typedef std::map<std::string, std::vector<std::string> > GxsMsgIdResult; typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgIdResult;
typedef std::map<std::string, std::vector<RsGxsMsgMetaData*> > GxsMsgMetaResult; typedef std::map<RsGxsGroupId, std::vector<RsGxsMsgMetaData*> > GxsMsgMetaResult;
typedef std::map<std::string, std::vector<RsNxsMsg*> > GxsMsgDataResult; typedef std::map<RsGxsGroupId, std::vector<RsNxsMsg*> > NxsMsgDataResult;
#define GXS_REQUEST_STATUS_FAILED 0 #define GXS_REQUEST_STATUS_FAILED 0
#define GXS_REQUEST_STATUS_PENDING 1 #define GXS_REQUEST_STATUS_PENDING 1
@ -58,12 +58,27 @@ typedef std::map<std::string, std::vector<RsNxsMsg*> > GxsMsgDataResult;
class RsTokReqOptions class RsTokReqOptions
{ {
public: public:
RsTokReqOptions() { mOptions = 0; mBefore = 0; mAfter = 0; } RsTokReqOptions()
{
mOptions = 0;
mStatusFilter = 0; mStatusMask = 0; mSubscribeFilter = 0;
mBefore = 0; mAfter = 0; mReqType = 0;
}
uint32_t mOptions; uint32_t mOptions;
uint32_t mReqType;
time_t mBefore; // Request specific matches with Group / Message Status.
time_t mAfter; // Should be usable with any Options... applied afterwards.
uint32_t mStatusFilter;
uint32_t mStatusMask;
uint32_t mReqType;
uint32_t mSubscribeFilter; // Only for Groups.
// Time range... again applied after Options.
time_t mBefore;
time_t mAfter;
}; };
@ -89,7 +104,7 @@ public:
* @param groupIds group id to request info for. Leave empty to get info on all groups, * @param groupIds group id to request info for. Leave empty to get info on all groups,
* @return * @return
*/ */
virtual bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &groupIds) = 0; virtual bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId> &groupIds) = 0;
/*! /*!
* *
@ -99,33 +114,60 @@ public:
* @param groupIds * @param groupIds
* @return * @return
*/ */
virtual bool requestMsgInfo(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 GxsMsgReq& msgIds) = 0;
/*!
* This sets the status of the message
* @param msgId the message id to set status for
* @param status status
* @param statusMask the mask for the settings targetted
* @return true if request made successfully, false otherwise
*/
virtual bool requestSetMessageStatus(uint32_t &token, const RsGxsGrpMsgIdPair &msgId,
const uint32_t status, const uint32_t statusMask) = 0;
/*! /*!
* *
* @param token * @param token
* @param ansType
* @param opts
* @param grpId * @param grpId
* @return * @param status
* @param statusMask
* @return true if request made successfully, false otherwise
*/ */
virtual bool requestGroupSubscribe(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::string &grpId) = 0; virtual bool requestSetGroupStatus(uint32_t &token, const RsGxsGroupId &grpId, const uint32_t status,
const uint32_t statusMask) = 0;
/*!
* Use request status to find out if successfully set
* @param groupId
* @param subscribeFlags
* @param subscribeMask
* @return true if request made successfully, false otherwise
*/
virtual bool requestSetGroupSubscribeFlags(uint32_t& token, const RsGxsGroupId &groupId, uint32_t subscribeFlags, uint32_t subscribeMask) = 0;
// (FUTURE WORK).
//virtual bool groupRestoreKeys(const std::string &groupId) = 0;
//virtual bool groupShareKeys(const std::string &groupId, std::list<std::string>& peers) = 0;
/* Poll */ /* Poll */
/*! /*!
* * Request the status of ongoing request. This is a blocking operation!
* @param token * @param token value of token to check status for
* @return * @return the current status of request
*/ */
virtual uint32_t requestStatus(const uint32_t token) = 0; virtual uint32_t requestStatus(const uint32_t token) = 0;
/* Cancel Request */ /* Cancel Request */
/*! /*!
* * If this function returns false, it may be that the request has completed
* already. Useful for very expensive request. This is a blocking operation
* @param token * @param token
* @return * @return false if unusuccessful, true if successful
*/ */
virtual bool cancelRequest(const uint32_t &token) = 0; virtual bool cancelRequest(const uint32_t &token) = 0;

View File

@ -27,7 +27,7 @@ public:
class RsGxsGroupChange : RsGxsChange class RsGxsGroupChange : RsGxsChange
{ {
public: public:
std::list<std::string> grpIdList; std::list<RsGxsGroupId> grpIdList;
}; };
/*! /*!
@ -37,7 +37,7 @@ public:
class RsGxsMsgChange : RsGxsChange class RsGxsMsgChange : RsGxsChange
{ {
public: public:
std::map<std::string, std::vector<std::string> > msgChangeMap; std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgChangeMap;
}; };

View File

@ -6,7 +6,7 @@
* *
* RetroShare C++ Interface. * RetroShare C++ Interface.
* *
* Copyright 2008-2012 by Robert Fernie. * Copyright 2008-2012 by Robert Fernie, Christopher Evi-Parker
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public

View File

@ -198,6 +198,8 @@ public:
*/ */
RsTlvBinaryData meta; RsTlvBinaryData meta;
// deserialised metaData, this is not serialised
RsGxsMsgMetaData* metaData;
}; };
/*! /*!

View File

@ -0,0 +1,45 @@
/*
* rsphotov2items.cc
*
* Created on: 22 Jul 2012
* Author: crispy
*/
#include "rsphotov2items.h"
uint32_t RsGxsPhotoSerialiser::size(RsItem* item) {
}
bool RsGxsPhotoSerialiser::serialise(RsItem* item, void* data, uint32_t* size) {
}
RsItem* RsGxsPhotoSerialiser::deserialise(void* data, uint32_t* size) {
}
uint32_t RsGxsPhotoSerialiser::sizeGxsPhotoAlbumItem(RsGxsPhotoAlbumItem* item) {
}
bool RsGxsPhotoSerialiser::serialiseGxsPhotoAlbumItem(RsGxsPhotoAlbumItem* item, void* data,
uint32_t* size) {
}
RsGxsPhotoAlbumItem* RsGxsPhotoSerialiser::deserialiseGxsPhotoAlbumItem(void* data,
uint32_t* size) {
}
uint32_t RsGxsPhotoSerialiser::sizeGxsPhotoPhotoItem(RsGxsPhotoPhotoItem* item) {
}
bool RsGxsPhotoSerialiser::serialiseGxsPhotoPhotoItem(RsGxsPhotoPhotoItem* item, void* data,
uint32_t* size) {
}
RsGxsPhotoPhotoItem* RsGxsPhotoSerialiser::deserialiseGxsPhotoPhotoItem(void* data,
uint32_t* size) {
}

View File

@ -0,0 +1,78 @@
/*
* libretroshare/src/retroshare: rsphoto.h
*
* RetroShare C++ Interface.
*
* Copyright 2012-2012 by Christopher Evi-Parker, 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".
*
*/
#ifndef RSPHOTOV2ITEMS_H_
#define RSPHOTOV2ITEMS_H_
#include <map>
#include "serialiser/rsserviceids.h"
#include "serialiser/rsserial.h"
#include "serialiser/rstlvtypes.h"
#include "rsgxsitems.h"
#include "retroshare/rsphotoV2.h"
class RsGxsPhotoAlbumItem : public RsGxsGrpItem
{
RsGxsPhotoAlbumItem() {}
RsPhotoAlbum album;
};
class RsGxsPhotoPhotoItem : public RsGxsMsgItem
{
RsGxsPhotoPhotoItem() {}
RsPhotoPhoto photo;
};
class RsGxsPhotoSerialiser : public RsSerialType
{
RsGxsPhotoSerialiser()
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_PHOTO)
{ return; }
virtual ~RsGxsPhotoSerialiser() { return; }
uint32_t size(RsItem *item);
bool serialise (RsItem *item, void *data, uint32_t *size);
RsItem * deserialise(void *data, uint32_t *size);
private:
uint32_t sizeGxsPhotoAlbumItem(RsGxsPhotoAlbumItem *item);
bool serialiseGxsPhotoAlbumItem (RsGxsPhotoAlbumItem *item, void *data, uint32_t *size);
RsGxsPhotoAlbumItem * deserialiseGxsPhotoAlbumItem(void *data, uint32_t *size);
uint32_t sizeGxsPhotoPhotoItem(RsGxsPhotoPhotoItem *item);
bool serialiseGxsPhotoPhotoItem (RsGxsPhotoPhotoItem *item, void *data, uint32_t *size);
RsGxsPhotoPhotoItem * deserialiseGxsPhotoPhotoItem(void *data, uint32_t *size);
};
#endif /* RSPHOTOV2ITEMS_H_ */

View File

@ -1,5 +1,8 @@
#include "p3photoserviceV2.h" #include "p3photoserviceV2.h"
#include "serialiser/rsphotov2items.h"
p3PhotoServiceV2::p3PhotoServiceV2() p3PhotoServiceV2::p3PhotoServiceV2(RsGeneralDataService* gds, RsNetworkExchangeService* nes)
: RsGenExchange(gds, nes, new RsGxsPhotoSerialiser())
{ {
} }

View File

@ -1,15 +1,40 @@
#ifndef P3PHOTOSERVICEV2_H #ifndef P3PHOTOSERVICEV2_H
#define P3PHOTOSERVICEV2_H #define P3PHOTOSERVICEV2_H
/*
* libretroshare/src/retroshare: rsphoto.h
*
* RetroShare C++ Interface.
*
* Copyright 2008-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 "gxs/rsgenexchange.h" #include "gxs/rsgenexchange.h"
#include "retroshare/rsphotoV2.h" #include "retroshare/rsphotoV2.h"
#include "gxs/rstokenservice.h"
class p3PhotoServiceV2 : public RsPhotoV2, public RsGenExchange class p3PhotoServiceV2 : public RsPhotoV2, public RsGenExchange
{ {
public: public:
p3PhotoServiceV2(); p3PhotoServiceV2(RsGeneralDataService* gds, RsNetworkExchangeService* nes);
public: public: