mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-04 17:15:31 -05:00
fresh recompile needed!
TokenQueueV2 added, first change to photoshare to deal with gxs backend needed to redirect meta types to mine in order to get compilation working and definition fixes to rsgenexchange. Next step is to get GxsRunner going git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5377 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
09b5d7a8c6
commit
d220e14c4a
@ -32,6 +32,7 @@
|
|||||||
#include "rsgds.h"
|
#include "rsgds.h"
|
||||||
#include "rsnxs.h"
|
#include "rsnxs.h"
|
||||||
#include "rsgxsdataaccess.h"
|
#include "rsgxsdataaccess.h"
|
||||||
|
#include "rsnxsobserver.h"
|
||||||
#include "retroshare/rsgxsservice.h"
|
#include "retroshare/rsgxsservice.h"
|
||||||
#include "serialiser/rsnxsitems.h"
|
#include "serialiser/rsnxsitems.h"
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > GxsMsgMetaMap;
|
|||||||
* Also notifications are made here on receipt of new data from
|
* Also notifications are made here on receipt of new data from
|
||||||
* connected peers
|
* connected peers
|
||||||
*/
|
*/
|
||||||
class RsGenExchange : public RsGxsService
|
class RsGenExchange : public RsGxsService, public RsNxsObserver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "serialiser/rsnxsitems.h"
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -38,7 +39,6 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "rsnxsobserver.h"
|
|
||||||
|
|
||||||
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgReq;
|
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgReq;
|
||||||
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgIdResult;
|
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgIdResult;
|
||||||
@ -46,13 +46,13 @@ typedef std::map<RsGxsGroupId, std::vector<RsGxsMsgMetaData*> > GxsMsgMetaResult
|
|||||||
typedef std::map<RsGxsGroupId, std::vector<RsNxsMsg*> > NxsMsgDataResult;
|
typedef std::map<RsGxsGroupId, std::vector<RsNxsMsg*> > NxsMsgDataResult;
|
||||||
typedef std::map<RsGxsGroupId, std::vector<RsNxsMsg*> > GxsMsgResult; // <grpId, msgs>
|
typedef std::map<RsGxsGroupId, std::vector<RsNxsMsg*> > GxsMsgResult; // <grpId, msgs>
|
||||||
|
|
||||||
class RsGxsService : public RsNxsObserver
|
class RsGxsService
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RsGxsService();
|
RsGxsService(){}
|
||||||
virtual ~RsGxsService();
|
virtual ~RsGxsService(){}
|
||||||
|
|
||||||
virtual void tick() = 0;
|
virtual void tick() = 0;
|
||||||
|
|
||||||
|
@ -891,6 +891,21 @@ void RsGxsDataAccess::tokenList(std::list<uint32_t>& tokens) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RsGxsDataAccess::updateRequestStatus(const uint32_t& token,
|
||||||
|
const uint32_t& status) {
|
||||||
|
|
||||||
|
RsStackMutex stack(mDataMutex);
|
||||||
|
|
||||||
|
GxsRequest* req = retrieveRequest(token);
|
||||||
|
|
||||||
|
if(req)
|
||||||
|
req->status = status;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool RsGxsDataAccess::checkMsgFilter(const RsTokReqOptions& opts, const RsGxsMsgMetaData* meta) const
|
bool RsGxsDataAccess::checkMsgFilter(const RsTokReqOptions& opts, const RsGxsMsgMetaData* meta) const
|
||||||
{
|
{
|
||||||
bool statusMatch = false;
|
bool statusMatch = false;
|
||||||
|
@ -40,6 +40,28 @@
|
|||||||
#define GXS_REQUEST_TYPE_MSG_META 0x00100000
|
#define GXS_REQUEST_TYPE_MSG_META 0x00100000
|
||||||
#define GXS_REQUEST_TYPE_MSG_IDS 0x00200000
|
#define GXS_REQUEST_TYPE_MSG_IDS 0x00200000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
#define RS_TOKREQOPT_MSG_LATEST 0x0004 // MSGLIST: All Latest MsgIds in Group. MSGRELATED: Latest MsgIds for Input Msgs.
|
||||||
|
|
||||||
|
#define RS_TOKREQOPT_MSG_THREAD 0x0010 // MSGRELATED: All Msgs in Thread. MSGLIST: All Unique Thread Ids in Group.
|
||||||
|
#define RS_TOKREQOPT_MSG_PARENT 0x0020 // MSGRELATED: All Children Msgs.
|
||||||
|
|
||||||
|
#define RS_TOKREQOPT_MSG_AUTHOR 0x0040 // MSGLIST: Messages from this AuthorId
|
||||||
|
|
||||||
|
// Read Status.
|
||||||
|
#define RS_TOKREQOPT_READ 0x0001
|
||||||
|
#define RS_TOKREQOPT_UNREAD 0x0002
|
||||||
|
|
||||||
|
#define RS_TOKREQ_ANSTYPE_LIST 0x0001
|
||||||
|
#define RS_TOKREQ_ANSTYPE_SUMMARY 0x0002
|
||||||
|
#define RS_TOKREQ_ANSTYPE_DATA 0x0003
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This class provides useful generic support for GXS style services.
|
* This class provides useful generic support for GXS style services.
|
||||||
* I expect much of this will be incorporated into the base GXS.
|
* I expect much of this will be incorporated into the base GXS.
|
||||||
|
@ -673,6 +673,7 @@ HEADERS += serialiser/rsnxsitems.h \
|
|||||||
gxs/rsgxsdataaccess.h \
|
gxs/rsgxsdataaccess.h \
|
||||||
retroshare/rsgxsservice.h \
|
retroshare/rsgxsservice.h \
|
||||||
serialiser/rsgxsitems.h \
|
serialiser/rsgxsitems.h \
|
||||||
|
serialiser/rsphotov2items.h \
|
||||||
util/retrodb.h
|
util/retrodb.h
|
||||||
|
|
||||||
SOURCES += serialiser/rsnxsitems.cc \
|
SOURCES += serialiser/rsnxsitems.cc \
|
||||||
@ -680,8 +681,10 @@ SOURCES += serialiser/rsnxsitems.cc \
|
|||||||
gxs/rsgenexchange.cc \
|
gxs/rsgenexchange.cc \
|
||||||
gxs/rsgxsnetservice.cc \
|
gxs/rsgxsnetservice.cc \
|
||||||
gxs/rsgxsdata.cc \
|
gxs/rsgxsdata.cc \
|
||||||
|
serialiser/rsgxsitems.cc \
|
||||||
services/p3photoserviceV2.cc \
|
services/p3photoserviceV2.cc \
|
||||||
gxs/rsgxsdataaccess.cc \
|
gxs/rsgxsdataaccess.cc \
|
||||||
|
serialiser/rsphotov2items.cc \
|
||||||
util/retrodb.cc
|
util/retrodb.cc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,83 +215,84 @@ class RsTokReqOptions
|
|||||||
|
|
||||||
#define RSGXS_MAX_SERVICE_STRING 200 // Sensible limit for dbase usage.
|
#define RSGXS_MAX_SERVICE_STRING 200 // Sensible limit for dbase usage.
|
||||||
|
|
||||||
|
#include "serialiser/rsgxsitems.h"
|
||||||
|
|
||||||
class RsGroupMetaData
|
//class RsGroupMetaData
|
||||||
{
|
//{
|
||||||
public:
|
// public:
|
||||||
|
//
|
||||||
RsGroupMetaData()
|
// RsGroupMetaData()
|
||||||
{
|
// {
|
||||||
mGroupFlags = 0;
|
// mGroupFlags = 0;
|
||||||
mSignFlags = 0;
|
// mSignFlags = 0;
|
||||||
mSubscribeFlags = 0;
|
// mSubscribeFlags = 0;
|
||||||
|
//
|
||||||
mPop = 0;
|
// mPop = 0;
|
||||||
mMsgCount = 0;
|
// mMsgCount = 0;
|
||||||
mLastPost = 0;
|
// mLastPost = 0;
|
||||||
mGroupStatus = 0;
|
// mGroupStatus = 0;
|
||||||
|
//
|
||||||
//mPublishTs = 0;
|
// //mPublishTs = 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
std::string mGroupId;
|
// std::string mGroupId;
|
||||||
std::string mGroupName;
|
// std::string mGroupName;
|
||||||
uint32_t mGroupFlags; // Service Specific Options ????
|
// uint32_t mGroupFlags; // Service Specific Options ????
|
||||||
uint32_t mSignFlags; // Combination of RSGXS_GROUP_SIGN_PUBLISH_MASK & RSGXS_GROUP_SIGN_AUTHOR_MASK.
|
// uint32_t mSignFlags; // Combination of RSGXS_GROUP_SIGN_PUBLISH_MASK & RSGXS_GROUP_SIGN_AUTHOR_MASK.
|
||||||
|
//
|
||||||
time_t mPublishTs; // Mandatory.
|
// time_t mPublishTs; // Mandatory.
|
||||||
std::string mAuthorId; // Optional.
|
// std::string mAuthorId; // Optional.
|
||||||
|
//
|
||||||
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
|
// // BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
|
||||||
|
//
|
||||||
uint32_t mSubscribeFlags;
|
// uint32_t mSubscribeFlags;
|
||||||
|
//
|
||||||
uint32_t mPop; // HOW DO WE DO THIS NOW.
|
// uint32_t mPop; // HOW DO WE DO THIS NOW.
|
||||||
uint32_t mMsgCount; // ???
|
// uint32_t mMsgCount; // ???
|
||||||
time_t mLastPost; // ???
|
// time_t mLastPost; // ???
|
||||||
|
//
|
||||||
uint32_t mGroupStatus;
|
// uint32_t mGroupStatus;
|
||||||
|
//
|
||||||
std::string mServiceString; // Service Specific Free-Form extra storage.
|
// std::string mServiceString; // Service Specific Free-Form extra storage.
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
class RsMsgMetaData
|
//class RsMsgMetaData
|
||||||
{
|
//{
|
||||||
public:
|
// public:
|
||||||
|
//
|
||||||
RsMsgMetaData()
|
// RsMsgMetaData()
|
||||||
{
|
// {
|
||||||
mPublishTs = 0;
|
// mPublishTs = 0;
|
||||||
mMsgFlags = 0;
|
// mMsgFlags = 0;
|
||||||
mMsgStatus = 0;
|
// mMsgStatus = 0;
|
||||||
mChildTs = 0;
|
// mChildTs = 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
std::string mGroupId;
|
// std::string mGroupId;
|
||||||
std::string mMsgId;
|
// std::string mMsgId;
|
||||||
|
//
|
||||||
std::string mThreadId;
|
// std::string mThreadId;
|
||||||
std::string mParentId;
|
// std::string mParentId;
|
||||||
std::string mOrigMsgId;
|
// std::string mOrigMsgId;
|
||||||
|
//
|
||||||
std::string mAuthorId;
|
// std::string mAuthorId;
|
||||||
|
//
|
||||||
std::string mMsgName;
|
// std::string mMsgName;
|
||||||
time_t mPublishTs;
|
// time_t mPublishTs;
|
||||||
|
//
|
||||||
uint32_t mMsgFlags; // Whats this for? (Optional Service Specific - e.g. flag MsgType)
|
// uint32_t mMsgFlags; // Whats this for? (Optional Service Specific - e.g. flag MsgType)
|
||||||
|
//
|
||||||
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
|
// // BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
|
||||||
// normally READ / UNREAD flags. LOCAL Data.
|
// // normally READ / UNREAD flags. LOCAL Data.
|
||||||
uint32_t mMsgStatus;
|
// uint32_t mMsgStatus;
|
||||||
time_t mChildTs;
|
// time_t mChildTs;
|
||||||
|
//
|
||||||
std::string mServiceString; // Service Specific Free-Form extra storage.
|
// std::string mServiceString; // Service Specific Free-Form extra storage.
|
||||||
|
//
|
||||||
};
|
//};
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const RsGroupMetaData &meta);
|
std::ostream &operator<<(std::ostream &out, const RsGroupMetaData &meta);
|
||||||
std::ostream &operator<<(std::ostream &out, const RsMsgMetaData &meta);
|
std::ostream &operator<<(std::ostream &out, const RsMsgMetaData &meta);
|
||||||
|
@ -32,8 +32,8 @@
|
|||||||
#include "rsgxsservice.h"
|
#include "rsgxsservice.h"
|
||||||
|
|
||||||
/* The Main Interface Class - for information about your Peers */
|
/* The Main Interface Class - for information about your Peers */
|
||||||
class RsPhoto;
|
class RsPhotoV2;
|
||||||
extern RsPhoto *rsPhoto;
|
extern RsPhotoV2 *rsPhotoV2;
|
||||||
|
|
||||||
/******************* NEW STUFF FOR NEW CACHE SYSTEM *********/
|
/******************* NEW STUFF FOR NEW CACHE SYSTEM *********/
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@ class RsGroupMetaData
|
|||||||
std::string mGroupId;
|
std::string mGroupId;
|
||||||
std::string mGroupName;
|
std::string mGroupName;
|
||||||
uint32_t mGroupFlags;
|
uint32_t mGroupFlags;
|
||||||
|
uint32_t mSignFlags; // Combination of RSGXS_GROUP_SIGN_PUBLISH_MASK & RSGXS_GROUP_SIGN_AUTHOR_MASK.
|
||||||
|
|
||||||
time_t mPublishTs; // Mandatory.
|
time_t mPublishTs; // Mandatory.
|
||||||
std::string mAuthorId; // Optional.
|
std::string mAuthorId; // Optional.
|
||||||
@ -70,6 +71,7 @@ class RsGroupMetaData
|
|||||||
time_t mLastPost; // ???
|
time_t mLastPost; // ???
|
||||||
|
|
||||||
uint32_t mGroupStatus;
|
uint32_t mGroupStatus;
|
||||||
|
std::string mServiceString; // Service Specific Free-Form extra storage.
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -109,6 +111,7 @@ class RsMsgMetaData
|
|||||||
// normally READ / UNREAD flags. LOCAL Data.
|
// normally READ / UNREAD flags. LOCAL Data.
|
||||||
uint32_t mMsgStatus;
|
uint32_t mMsgStatus;
|
||||||
time_t mChildTs;
|
time_t mChildTs;
|
||||||
|
std::string mServiceString; // Service Specific Free-Form extra storage.
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include "p3photoserviceV2.h"
|
#include "p3photoserviceV2.h"
|
||||||
#include "serialiser/rsphotov2items.h"
|
#include "serialiser/rsphotov2items.h"
|
||||||
|
|
||||||
|
RsPhotoV2 *rsPhotoV2 = NULL;
|
||||||
|
|
||||||
p3PhotoServiceV2::p3PhotoServiceV2(RsGeneralDataService* gds, RsNetworkExchangeService* nes)
|
p3PhotoServiceV2::p3PhotoServiceV2(RsGeneralDataService* gds, RsNetworkExchangeService* nes)
|
||||||
: RsGenExchange(gds, nes, new RsGxsPhotoSerialiser(), RS_SERVICE_TYPE_PHOTO)
|
: RsGenExchange(gds, nes, new RsGxsPhotoSerialiser(), RS_SERVICE_TYPE_PHOTO)
|
||||||
{
|
{
|
||||||
|
@ -45,12 +45,11 @@ PhotoAddDialog::PhotoAddDialog(QWidget *parent)
|
|||||||
|
|
||||||
mPhotoDetails = NULL;
|
mPhotoDetails = NULL;
|
||||||
|
|
||||||
mPhotoQueue = new TokenQueue(rsPhoto, this);
|
mPhotoQueue = new TokenQueueV2(rsPhotoV2->getTokenService(), this);
|
||||||
|
|
||||||
ui.AlbumDrop->setSingleImage();
|
ui.AlbumDrop->setSingleImage();
|
||||||
connect(ui.AlbumDrop, SIGNAL( photosChanged( void ) ), this, SLOT( albumImageChanged( void ) ) );
|
connect(ui.AlbumDrop, SIGNAL( photosChanged( void ) ), this, SLOT( albumImageChanged( void ) ) );
|
||||||
connect(ui.scrollAreaWidgetContents, SIGNAL( photosChanged( void ) ), this, SLOT( photoImageChanged( void ) ) );
|
connect(ui.scrollAreaWidgetContents, SIGNAL( photosChanged( void ) ), this, SLOT( photoImageChanged( void ) ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -333,7 +332,7 @@ void PhotoAddDialog::publishAlbum()
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
rsPhoto->submitAlbumDetails(token, album, true);
|
rsPhotoV2->submitAlbumDetails(album);
|
||||||
|
|
||||||
// tell tokenQueue to expect results from submission.
|
// tell tokenQueue to expect results from submission.
|
||||||
mPhotoQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_SUMMARY, 0);
|
mPhotoQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_SUMMARY, 0);
|
||||||
@ -413,12 +412,12 @@ void PhotoAddDialog::publishPhotos(std::string albumId)
|
|||||||
if (isNewPhoto)
|
if (isNewPhoto)
|
||||||
{
|
{
|
||||||
std::cerr << "Is a New Photo";
|
std::cerr << "Is a New Photo";
|
||||||
rsPhoto->submitPhoto(token, photo, true);
|
rsPhotoV2->submitPhoto(photo);
|
||||||
}
|
}
|
||||||
else if (isModifiedPhoto)
|
else if (isModifiedPhoto)
|
||||||
{
|
{
|
||||||
std::cerr << "Is Updated";
|
std::cerr << "Is Updated";
|
||||||
rsPhoto->submitPhoto(token, photo, false);
|
rsPhotoV2->submitPhoto(photo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -479,7 +478,7 @@ void PhotoAddDialog::loadAlbum(const std::string &albumId)
|
|||||||
|
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
std::list<std::string> albumIds;
|
std::list<RsGxsGroupId> albumIds;
|
||||||
albumIds.push_back(albumId);
|
albumIds.push_back(albumId);
|
||||||
|
|
||||||
// We need both Album and Photo Data.
|
// We need both Album and Photo Data.
|
||||||
@ -497,9 +496,10 @@ bool PhotoAddDialog::loadPhotoData(const uint32_t &token)
|
|||||||
bool moreData = true;
|
bool moreData = true;
|
||||||
while(moreData)
|
while(moreData)
|
||||||
{
|
{
|
||||||
|
PhotoResult res;
|
||||||
RsPhotoPhoto photo;
|
RsPhotoPhoto photo;
|
||||||
|
|
||||||
if (rsPhoto->getPhoto(token, photo))
|
if (rsPhotoV2->getPhoto(token, res))
|
||||||
{
|
{
|
||||||
std::cerr << "PhotoDialog::addAddPhoto() AlbumId: " << photo.mMeta.mGroupId;
|
std::cerr << "PhotoDialog::addAddPhoto() AlbumId: " << photo.mMeta.mGroupId;
|
||||||
std::cerr << " PhotoId: " << photo.mMeta.mMsgId;
|
std::cerr << " PhotoId: " << photo.mMeta.mMsgId;
|
||||||
@ -525,8 +525,9 @@ bool PhotoAddDialog::loadAlbumData(const uint32_t &token)
|
|||||||
bool moreData = true;
|
bool moreData = true;
|
||||||
while(moreData)
|
while(moreData)
|
||||||
{
|
{
|
||||||
|
std::vector<RsPhotoAlbum> albums;
|
||||||
RsPhotoAlbum album;
|
RsPhotoAlbum album;
|
||||||
if (rsPhoto->getAlbum(token, album))
|
if (rsPhotoV2->getAlbum(token, albums))
|
||||||
{
|
{
|
||||||
std::cerr << " PhotoAddDialog::loadAlbumData() AlbumId: " << album.mMeta.mGroupId << std::endl;
|
std::cerr << " PhotoAddDialog::loadAlbumData() AlbumId: " << album.mMeta.mGroupId << std::endl;
|
||||||
updateAlbumDetails(album);
|
updateAlbumDetails(album);
|
||||||
@ -536,7 +537,9 @@ bool PhotoAddDialog::loadAlbumData(const uint32_t &token)
|
|||||||
uint32_t token;
|
uint32_t token;
|
||||||
std::list<std::string> albumIds;
|
std::list<std::string> albumIds;
|
||||||
albumIds.push_back(album.mMeta.mGroupId);
|
albumIds.push_back(album.mMeta.mGroupId);
|
||||||
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, albumIds, 0);
|
GxsMsgReq req;
|
||||||
|
req[album.mMeta.mGroupId] = std::vector<RsGxsMessageId>();
|
||||||
|
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, req, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -552,7 +555,7 @@ bool PhotoAddDialog::loadCreatedAlbum(const uint32_t &token)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
std::list<RsGroupMetaData> groupInfo;
|
std::list<RsGroupMetaData> groupInfo;
|
||||||
if (!rsPhoto->getGroupSummary(token, groupInfo))
|
if (!rsPhotoV2->getGroupSummary(token, groupInfo))
|
||||||
{
|
{
|
||||||
std::cerr << "PhotoAddDialog::loadCreatedAlbum() ERROR Getting MetaData";
|
std::cerr << "PhotoAddDialog::loadCreatedAlbum() ERROR Getting MetaData";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -575,7 +578,7 @@ bool PhotoAddDialog::loadCreatedAlbum(const uint32_t &token)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PhotoAddDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
void PhotoAddDialog::loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &req)
|
||||||
{
|
{
|
||||||
std::cerr << "PhotoDialog::loadRequest()";
|
std::cerr << "PhotoDialog::loadRequest()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
@ -26,12 +26,12 @@
|
|||||||
|
|
||||||
#include "ui_PhotoAddDialog.h"
|
#include "ui_PhotoAddDialog.h"
|
||||||
|
|
||||||
#include <retroshare/rsphoto.h>
|
#include <retroshare/rsphotoV2.h>
|
||||||
#include "util/TokenQueue.h"
|
#include "util/TokenQueueV2.h"
|
||||||
|
|
||||||
class PhotoDetailsDialog;
|
class PhotoDetailsDialog;
|
||||||
|
|
||||||
class PhotoAddDialog : public QWidget, public TokenResponse
|
class PhotoAddDialog : public QWidget, public TokenResponseV2
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public:
|
|||||||
PhotoAddDialog(QWidget *parent = 0);
|
PhotoAddDialog(QWidget *parent = 0);
|
||||||
|
|
||||||
void loadAlbum(const std::string &albumId);
|
void loadAlbum(const std::string &albumId);
|
||||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
virtual void loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &req);
|
||||||
|
|
||||||
void clearDialog();
|
void clearDialog();
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ private:
|
|||||||
bool loadAlbumData(const uint32_t &token);
|
bool loadAlbumData(const uint32_t &token);
|
||||||
bool loadCreatedAlbum(const uint32_t &token);
|
bool loadCreatedAlbum(const uint32_t &token);
|
||||||
|
|
||||||
TokenQueue *mPhotoQueue;
|
TokenQueueV2 *mPhotoQueue;
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool mAlbumEdit; // Editing or New.
|
bool mAlbumEdit; // Editing or New.
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "PhotoDialog.h"
|
#include "PhotoDialog.h"
|
||||||
|
|
||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
#include <retroshare/rsphoto.h>
|
#include <retroshare/rsphotoV2.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -79,7 +79,7 @@ PhotoDialog::PhotoDialog(QWidget *parent)
|
|||||||
|
|
||||||
|
|
||||||
/* setup TokenQueue */
|
/* setup TokenQueue */
|
||||||
mPhotoQueue = new TokenQueue(rsPhoto, this);
|
mPhotoQueue = new TokenQueueV2(rsPhotoV2->getTokenService(), this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,10 +139,10 @@ void PhotoDialog::notifyPhotoSelection(PhotoItem *item)
|
|||||||
void PhotoDialog::checkUpdate()
|
void PhotoDialog::checkUpdate()
|
||||||
{
|
{
|
||||||
/* update */
|
/* update */
|
||||||
if (!rsPhoto)
|
if (!rsPhotoV2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (rsPhoto->updated())
|
if (rsPhotoV2->updated())
|
||||||
{
|
{
|
||||||
//insertAlbums();
|
//insertAlbums();
|
||||||
requestAlbumList();
|
requestAlbumList();
|
||||||
@ -443,7 +443,7 @@ void PhotoDialog::loadAlbumList(const uint32_t &token)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
std::list<std::string> albumIds;
|
std::list<std::string> albumIds;
|
||||||
rsPhoto->getGroupList(token, albumIds);
|
rsPhotoV2->getGroupList(token, albumIds);
|
||||||
|
|
||||||
requestAlbumData(albumIds);
|
requestAlbumData(albumIds);
|
||||||
|
|
||||||
@ -458,11 +458,11 @@ void PhotoDialog::loadAlbumList(const uint32_t &token)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PhotoDialog::requestAlbumData(const std::list<std::string> &ids)
|
void PhotoDialog::requestAlbumData(std::list<std::string> &ids)
|
||||||
{
|
{
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
mPhotoQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, ids, 0);
|
mPhotoQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, ids, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -477,7 +477,8 @@ bool PhotoDialog::loadAlbumData(const uint32_t &token)
|
|||||||
while(moreData)
|
while(moreData)
|
||||||
{
|
{
|
||||||
RsPhotoAlbum album;
|
RsPhotoAlbum album;
|
||||||
if (rsPhoto->getAlbum(token, album))
|
std::vector<RsPhotoAlbum> albums;
|
||||||
|
if (rsPhotoV2->getAlbum(token, albums))
|
||||||
{
|
{
|
||||||
std::cerr << " PhotoDialog::addAlbum() AlbumId: " << album.mMeta.mGroupId << std::endl;
|
std::cerr << " PhotoDialog::addAlbum() AlbumId: " << album.mMeta.mGroupId << std::endl;
|
||||||
|
|
||||||
@ -499,11 +500,12 @@ void PhotoDialog::requestPhotoList(const std::string &albumId)
|
|||||||
{
|
{
|
||||||
|
|
||||||
std::list<std::string> ids;
|
std::list<std::string> ids;
|
||||||
ids.push_back(albumId);
|
GxsMsgReq req;
|
||||||
|
req[albumId] = std::vector<RsGxsMessageId>();
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
|
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, ids, 0);
|
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, req, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -515,18 +517,19 @@ void PhotoDialog::loadPhotoList(const uint32_t &token)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
|
||||||
std::list<std::string> photoIds;
|
GxsMsgIdResult res;
|
||||||
|
GxsMsgReq req;
|
||||||
|
|
||||||
rsPhoto->getMsgList(token, photoIds);
|
rsPhotoV2->getMsgList(token, res);
|
||||||
requestPhotoData(photoIds);
|
requestPhotoData(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PhotoDialog::requestPhotoData(const std::list<std::string> &photoIds)
|
void PhotoDialog::requestPhotoData(GxsMsgReq &photoIds)
|
||||||
{
|
{
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
mPhotoQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, photoIds, 0);
|
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, photoIds, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -539,8 +542,8 @@ void PhotoDialog::loadPhotoData(const uint32_t &token)
|
|||||||
while(moreData)
|
while(moreData)
|
||||||
{
|
{
|
||||||
RsPhotoPhoto photo;
|
RsPhotoPhoto photo;
|
||||||
|
PhotoResult res;
|
||||||
if (rsPhoto->getPhoto(token, photo))
|
if (rsPhotoV2->getPhoto(token, res))
|
||||||
{
|
{
|
||||||
|
|
||||||
std::cerr << "PhotoDialog::loadPhotoData() AlbumId: " << photo.mMeta.mGroupId;
|
std::cerr << "PhotoDialog::loadPhotoData() AlbumId: " << photo.mMeta.mGroupId;
|
||||||
@ -559,7 +562,7 @@ void PhotoDialog::loadPhotoData(const uint32_t &token)
|
|||||||
|
|
||||||
/********************************/
|
/********************************/
|
||||||
|
|
||||||
void PhotoDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
void PhotoDialog::loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &req)
|
||||||
{
|
{
|
||||||
std::cerr << "PhotoDialog::loadRequest()";
|
std::cerr << "PhotoDialog::loadRequest()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -640,7 +643,7 @@ void PhotoDialog::insertAlbums()
|
|||||||
std::list<std::string> filteredAlbumIds;
|
std::list<std::string> filteredAlbumIds;
|
||||||
std::list<std::string>::iterator it;
|
std::list<std::string>::iterator it;
|
||||||
|
|
||||||
rsPhoto->getAlbumList(albumIds);
|
rsPhotoV2->getGroupList(token, al);
|
||||||
|
|
||||||
/* Filter Albums */ /* Sort Albums */
|
/* Filter Albums */ /* Sort Albums */
|
||||||
#define MAX_ALBUMS 50
|
#define MAX_ALBUMS 50
|
||||||
|
@ -27,16 +27,16 @@
|
|||||||
#include "retroshare-gui/mainpage.h"
|
#include "retroshare-gui/mainpage.h"
|
||||||
#include "ui_PhotoDialog.h"
|
#include "ui_PhotoDialog.h"
|
||||||
|
|
||||||
#include <retroshare/rsphoto.h>
|
#include <retroshare/rsphotoV2.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "gui/PhotoShare/PhotoItem.h"
|
#include "gui/PhotoShare/PhotoItem.h"
|
||||||
#include "gui/PhotoShare/PhotoAddDialog.h"
|
#include "gui/PhotoShare/PhotoAddDialog.h"
|
||||||
#include "gui/PhotoShare/PhotoSlideShow.h"
|
#include "gui/PhotoShare/PhotoSlideShow.h"
|
||||||
#include "util/TokenQueue.h"
|
#include "util/TokenQueueV2.h"
|
||||||
|
|
||||||
class PhotoDialog : public MainPage, public PhotoHolder, public TokenResponse
|
class PhotoDialog : public MainPage, public PhotoHolder, public TokenResponseV2
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -59,16 +59,16 @@ private:
|
|||||||
|
|
||||||
/* Request Response Functions for loading data */
|
/* Request Response Functions for loading data */
|
||||||
void requestAlbumList();
|
void requestAlbumList();
|
||||||
void requestAlbumData(const std::list<std::string> &ids);
|
void requestAlbumData(std::list<std::string> &ids);
|
||||||
void requestPhotoList(const std::string &albumId);
|
void requestPhotoList(const std::string &albumId);
|
||||||
void requestPhotoData(const std::list<std::string> &photoIds);
|
void requestPhotoData(GxsMsgReq &photoIds);
|
||||||
|
|
||||||
void loadAlbumList(const uint32_t &token);
|
void loadAlbumList(const uint32_t &token);
|
||||||
bool loadAlbumData(const uint32_t &token);
|
bool loadAlbumData(const uint32_t &token);
|
||||||
void loadPhotoList(const uint32_t &token);
|
void loadPhotoList(const uint32_t &token);
|
||||||
void loadPhotoData(const uint32_t &token);
|
void loadPhotoData(const uint32_t &token);
|
||||||
|
|
||||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
void loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &req);
|
||||||
|
|
||||||
|
|
||||||
/* TODO: These functions must be filled in for proper filtering to work
|
/* TODO: These functions must be filled in for proper filtering to work
|
||||||
@ -101,7 +101,7 @@ private:
|
|||||||
PhotoItem *mAlbumSelected;
|
PhotoItem *mAlbumSelected;
|
||||||
PhotoItem *mPhotoSelected;
|
PhotoItem *mPhotoSelected;
|
||||||
|
|
||||||
TokenQueue *mPhotoQueue;
|
TokenQueueV2 *mPhotoQueue;
|
||||||
|
|
||||||
/* UI - from Designer */
|
/* UI - from Designer */
|
||||||
Ui::PhotoDialog ui;
|
Ui::PhotoDialog ui;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include "PhotoItem.h"
|
#include "PhotoItem.h"
|
||||||
|
|
||||||
#include <retroshare/rsphoto.h>
|
#include <retroshare/rsphotoV2.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include "ui_PhotoItem.h"
|
#include "ui_PhotoItem.h"
|
||||||
|
|
||||||
#include <retroshare/rsphoto.h>
|
#include <retroshare/rsphotoV2.h>
|
||||||
|
|
||||||
class PhotoItem;
|
class PhotoItem;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ PhotoSlideShow::PhotoSlideShow(QWidget *parent)
|
|||||||
connect(ui.pushButton_StartStop, SIGNAL( clicked( void ) ), this, SLOT( StartStop( void ) ) );
|
connect(ui.pushButton_StartStop, SIGNAL( clicked( void ) ), this, SLOT( StartStop( void ) ) );
|
||||||
connect(ui.pushButton_Close, SIGNAL( clicked( void ) ), this, SLOT( closeShow( void ) ) );
|
connect(ui.pushButton_Close, SIGNAL( clicked( void ) ), this, SLOT( closeShow( void ) ) );
|
||||||
|
|
||||||
mPhotoQueue = new TokenQueue(rsPhoto, this);
|
mPhotoQueue = new TokenQueueV2(rsPhotoV2->getTokenService(), this);
|
||||||
|
|
||||||
mRunning = true;
|
mRunning = true;
|
||||||
mShotActive = true;
|
mShotActive = true;
|
||||||
@ -49,6 +49,9 @@ PhotoSlideShow::PhotoSlideShow(QWidget *parent)
|
|||||||
//QTimer::singleShot(5000, this, SLOT(timerEvent()));
|
//QTimer::singleShot(5000, this, SLOT(timerEvent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PhotoSlideShow::~PhotoSlideShow(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void PhotoSlideShow::showPhotoDetails()
|
void PhotoSlideShow::showPhotoDetails()
|
||||||
{
|
{
|
||||||
@ -262,8 +265,9 @@ bool PhotoSlideShow::loadPhotoData(const uint32_t &token)
|
|||||||
while(moreData)
|
while(moreData)
|
||||||
{
|
{
|
||||||
RsPhotoPhoto photo;
|
RsPhotoPhoto photo;
|
||||||
|
PhotoResult res;
|
||||||
|
|
||||||
if (rsPhoto->getPhoto(token, photo))
|
if (rsPhotoV2->getPhoto(token, res))
|
||||||
{
|
{
|
||||||
RsPhotoPhoto *ptr = new RsPhotoPhoto;
|
RsPhotoPhoto *ptr = new RsPhotoPhoto;
|
||||||
*ptr = photo;
|
*ptr = photo;
|
||||||
@ -299,7 +303,8 @@ bool PhotoSlideShow::loadAlbumData(const uint32_t &token)
|
|||||||
while(moreData)
|
while(moreData)
|
||||||
{
|
{
|
||||||
RsPhotoAlbum album;
|
RsPhotoAlbum album;
|
||||||
if (rsPhoto->getAlbum(token, album))
|
std::vector<RsPhotoAlbum> res;
|
||||||
|
if (rsPhotoV2->getAlbum(token, res))
|
||||||
{
|
{
|
||||||
std::cerr << " PhotoSlideShow::loadAlbumData() AlbumId: " << album.mMeta.mGroupId << std::endl;
|
std::cerr << " PhotoSlideShow::loadAlbumData() AlbumId: " << album.mMeta.mGroupId << std::endl;
|
||||||
//updateAlbumDetails(album);
|
//updateAlbumDetails(album);
|
||||||
@ -309,7 +314,9 @@ bool PhotoSlideShow::loadAlbumData(const uint32_t &token)
|
|||||||
uint32_t token;
|
uint32_t token;
|
||||||
std::list<std::string> albumIds;
|
std::list<std::string> albumIds;
|
||||||
albumIds.push_back(album.mMeta.mGroupId);
|
albumIds.push_back(album.mMeta.mGroupId);
|
||||||
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, albumIds, 0);
|
GxsMsgReq req;
|
||||||
|
req[album.mMeta.mGroupId] = std::vector<RsGxsMessageId>();
|
||||||
|
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, req, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -319,8 +326,7 @@ bool PhotoSlideShow::loadAlbumData(const uint32_t &token)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PhotoSlideShow::loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &req)
|
||||||
void PhotoSlideShow::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
|
||||||
{
|
{
|
||||||
std::cerr << "PhotoSlideShow::loadRequest()";
|
std::cerr << "PhotoSlideShow::loadRequest()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
@ -26,18 +26,19 @@
|
|||||||
|
|
||||||
#include "ui_PhotoSlideShow.h"
|
#include "ui_PhotoSlideShow.h"
|
||||||
|
|
||||||
#include <retroshare/rsphoto.h>
|
#include <retroshare/rsphotoV2.h>
|
||||||
#include "util/TokenQueue.h"
|
#include "util/TokenQueueV2.h"
|
||||||
|
|
||||||
class PhotoSlideShow : public QWidget, public TokenResponse
|
class PhotoSlideShow : public QWidget, public TokenResponseV2
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PhotoSlideShow(QWidget *parent = 0);
|
PhotoSlideShow(QWidget *parent = 0);
|
||||||
|
virtual ~PhotoSlideShow();
|
||||||
|
|
||||||
void loadAlbum(const std::string &albumId);
|
void loadAlbum(const std::string &albumId);
|
||||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
virtual void loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &req);
|
||||||
|
|
||||||
void clearDialog();
|
void clearDialog();
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ private:
|
|||||||
int mImageIdx;
|
int mImageIdx;
|
||||||
bool mShotActive;
|
bool mShotActive;
|
||||||
|
|
||||||
TokenQueue *mPhotoQueue;
|
TokenQueueV2 *mPhotoQueue;
|
||||||
|
|
||||||
Ui::PhotoSlideShow ui;
|
Ui::PhotoSlideShow ui;
|
||||||
};
|
};
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include <retroshare/rsiface.h>
|
#include <retroshare/rsiface.h>
|
||||||
|
|
||||||
#include "gui/PhotoShare/PhotoDialog.h"
|
//#include "gui/PhotoShare/PhotoDialog.h"
|
||||||
#include "gui/WikiPoos/WikiDialog.h"
|
#include "gui/WikiPoos/WikiDialog.h"
|
||||||
#include "gui/TheWire/WireDialog.h"
|
#include "gui/TheWire/WireDialog.h"
|
||||||
#include "gui/Identity/IdDialog.h"
|
#include "gui/Identity/IdDialog.h"
|
||||||
@ -97,9 +97,9 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
|
|||||||
ui.stackPages->add(idDialog = new IdDialog(ui.stackPages),
|
ui.stackPages->add(idDialog = new IdDialog(ui.stackPages),
|
||||||
createPageAction(QIcon(IMAGE_LIBRARY), tr("Identities"), grp));
|
createPageAction(QIcon(IMAGE_LIBRARY), tr("Identities"), grp));
|
||||||
|
|
||||||
PhotoDialog *photoDialog = NULL;
|
//PhotoDialog *photoDialog = NULL;
|
||||||
ui.stackPages->add(photoDialog = new PhotoDialog(ui.stackPages),
|
//ui.stackPages->add(photoDialog = new PhotoDialog(ui.stackPages),
|
||||||
createPageAction(QIcon(IMAGE_PHOTO), tr("Photo View"), grp));
|
// createPageAction(QIcon(IMAGE_PHOTO), tr("Photo View"), grp));
|
||||||
|
|
||||||
WikiDialog *wikiDialog = NULL;
|
WikiDialog *wikiDialog = NULL;
|
||||||
ui.stackPages->add(wikiDialog = new WikiDialog(ui.stackPages),
|
ui.stackPages->add(wikiDialog = new WikiDialog(ui.stackPages),
|
||||||
|
@ -29,10 +29,9 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <retroshare/rsidentity.h>
|
#include <retroshare/rsidentity.h>
|
||||||
|
|
||||||
|
|
||||||
#define COMPLETED_REQUEST 4
|
#define COMPLETED_REQUEST 4
|
||||||
|
|
||||||
#define TOKENREQ_GROUPINFO 1
|
#define TOKENREQ_GROUPINFO 1
|
||||||
|
173
retroshare-gui/src/util/TokenQueueV2.cpp
Normal file
173
retroshare-gui/src/util/TokenQueueV2.cpp
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
/*
|
||||||
|
* Token Queue.
|
||||||
|
*
|
||||||
|
* Copyright 2012-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.1 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 "util/TokenQueueV2.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
|
||||||
|
/******
|
||||||
|
* #define ID_DEBUG 1
|
||||||
|
*****/
|
||||||
|
|
||||||
|
/** Constructor */
|
||||||
|
TokenQueueV2::TokenQueueV2(RsTokenServiceV2 *service, TokenResponseV2 *resp)
|
||||||
|
:QWidget(NULL), mService(service), mResponder(resp)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TokenQueueV2::requestGroupInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptions &opts, std::list<RsGxsGroupId>& ids, uint32_t usertype)
|
||||||
|
{
|
||||||
|
uint32_t basictype = TOKENREQ_GROUPINFO;
|
||||||
|
mService->requestGroupInfo(token, anstype, opts, ids);
|
||||||
|
queueRequest(token, basictype, anstype, usertype);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool TokenQueueV2::requestMsgInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptions &opts, const GxsMsgReq& ids, uint32_t usertype)
|
||||||
|
{
|
||||||
|
uint32_t basictype = TOKENREQ_MSGINFO;
|
||||||
|
mService->requestMsgInfo(token, anstype, opts, ids);
|
||||||
|
queueRequest(token, basictype, anstype, usertype);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TokenQueueV2::queueRequest(uint32_t token, uint32_t basictype, uint32_t anstype, uint32_t usertype)
|
||||||
|
{
|
||||||
|
std::cerr << "TokenQueueV2::queueRequest() Token: " << token << " Type: " << basictype;
|
||||||
|
std::cerr << " AnsType: " << anstype << " UserType: " << usertype;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
TokenRequestV2 req;
|
||||||
|
req.mToken = token;
|
||||||
|
req.mType = basictype;
|
||||||
|
req.mAnsType = anstype;
|
||||||
|
req.mUserType = usertype;
|
||||||
|
|
||||||
|
gettimeofday(&req.mRequestTs, NULL);
|
||||||
|
req.mPollTs = req.mRequestTs;
|
||||||
|
|
||||||
|
mRequests.push_back(req);
|
||||||
|
|
||||||
|
if (mRequests.size() == 1)
|
||||||
|
{
|
||||||
|
/* start the timer */
|
||||||
|
doPoll(0.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TokenQueueV2::doPoll(float dt)
|
||||||
|
{
|
||||||
|
/* single shot poll */
|
||||||
|
//mTrigger->singlesshot(dt * 1000);
|
||||||
|
QTimer::singleShot((int) (dt * 1000.0), this, SLOT(pollRequests()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TokenQueueV2::pollRequests()
|
||||||
|
{
|
||||||
|
std::list<TokenRequestV2>::iterator it;
|
||||||
|
|
||||||
|
double pollPeriod = 1.0; // max poll period.
|
||||||
|
for(it = mRequests.begin(); it != mRequests.end();)
|
||||||
|
{
|
||||||
|
if (checkForRequest(it->mToken))
|
||||||
|
{
|
||||||
|
/* clean it up and handle */
|
||||||
|
loadRequest(*it);
|
||||||
|
it = mRequests.erase(it);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* calculate desired poll period */
|
||||||
|
|
||||||
|
/* if less then current poll period, adjust */
|
||||||
|
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mRequests.size() > 0)
|
||||||
|
{
|
||||||
|
doPoll(pollPeriod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool TokenQueueV2::checkForRequest(uint32_t token)
|
||||||
|
{
|
||||||
|
/* check token */
|
||||||
|
return (COMPLETED_REQUEST == mService->requestStatus(token));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TokenQueueV2::loadRequest(const TokenRequestV2 &req)
|
||||||
|
{
|
||||||
|
std::cerr << "TokenQueueV2::loadRequest(): ";
|
||||||
|
std::cerr << "Token: " << req.mToken << " Type: " << req.mType;
|
||||||
|
std::cerr << " AnsType: " << req.mAnsType << " UserType: " << req.mUserType;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
mResponder->loadRequest(this, req);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool TokenQueueV2::cancelRequest(const uint32_t token)
|
||||||
|
{
|
||||||
|
/* cancel at lower level first */
|
||||||
|
mService->cancelRequest(token);
|
||||||
|
|
||||||
|
std::list<TokenRequestV2>::iterator it;
|
||||||
|
|
||||||
|
for(it = mRequests.begin(); it != mRequests.end(); it++)
|
||||||
|
{
|
||||||
|
if (it->mToken == token)
|
||||||
|
{
|
||||||
|
mRequests.erase(it);
|
||||||
|
|
||||||
|
std::cerr << "TokenQueueV2::cancelRequest() Cleared Request: " << token;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cerr << "TokenQueueV2::cancelRequest() Failed to Find Request: " << token;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
102
retroshare-gui/src/util/TokenQueueV2.h
Normal file
102
retroshare-gui/src/util/TokenQueueV2.h
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
* Token Queue.
|
||||||
|
*
|
||||||
|
* 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.1 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 MRK_TOKEN_QUEUE_H
|
||||||
|
#define MRK_TOKEN_QUEUE_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <list>
|
||||||
|
#include <string>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include <gxs/rstokenservice.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define COMPLETED_REQUEST 4
|
||||||
|
|
||||||
|
#define TOKENREQ_GROUPINFO 1
|
||||||
|
#define TOKENREQ_MSGINFO 2
|
||||||
|
#define TOKENREQ_MSGRELATEDINFO 3
|
||||||
|
|
||||||
|
class TokenQueueV2;
|
||||||
|
|
||||||
|
class TokenRequestV2
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint32_t mToken;
|
||||||
|
uint32_t mType;
|
||||||
|
uint32_t mAnsType;
|
||||||
|
uint32_t mUserType;
|
||||||
|
struct timeval mRequestTs;
|
||||||
|
struct timeval mPollTs;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TokenResponseV2
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//virtual ~TokenResponse() { return; }
|
||||||
|
// These Functions are overloaded to get results out.
|
||||||
|
virtual void loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &req) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class TokenQueueV2: public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
TokenQueueV2(RsTokenServiceV2 *service, TokenResponseV2 *resp);
|
||||||
|
|
||||||
|
/* generic handling of token / response update behaviour */
|
||||||
|
bool requestGroupInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptions &opts,
|
||||||
|
std::list<RsGxsGroupId>& ids, uint32_t usertype);
|
||||||
|
bool requestMsgInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptions &opts,
|
||||||
|
const GxsMsgReq& ids, uint32_t usertype);
|
||||||
|
|
||||||
|
bool cancelRequest(const uint32_t token);
|
||||||
|
|
||||||
|
void queueRequest(uint32_t token, uint32_t basictype, uint32_t anstype, uint32_t usertype);
|
||||||
|
bool checkForRequest(uint32_t token);
|
||||||
|
void loadRequest(const TokenRequestV2 &req);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void doPoll(float dt);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void pollRequests();
|
||||||
|
|
||||||
|
private:
|
||||||
|
/* Info for Data Requests */
|
||||||
|
std::list<TokenRequestV2> mRequests;
|
||||||
|
|
||||||
|
RsTokenServiceV2 *mService;
|
||||||
|
TokenResponseV2 *mResponder;
|
||||||
|
|
||||||
|
QTimer *mTrigger;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user