Fixed compile issues for VEG in librs (rs-gui VEG ui cannot be compiled as was the case prior to issues)

removed VEG photoservice
Enabled group synchronisation between retroshare peers! test synchro between two rs peers worked.
Added crude commenting facility to photoshare, much tuning to be done



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5602 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2012-09-25 21:04:04 +00:00
parent 51362f7bac
commit 0fc3a2704b
29 changed files with 653 additions and 1087 deletions

View File

@ -69,8 +69,13 @@ void RsGenExchange::tick()
processMsgMetaChanges();
notifyChanges(mNotifications);
mNotifications.clear();
processRecvdData();
if(!mNotifications.empty())
{
notifyChanges(mNotifications);
mNotifications.clear();
}
}
@ -493,10 +498,10 @@ void RsGenExchange::processMsgMetaChanges()
if(ok)
{
mDataAccess->updatePublicRequestStatus(token, RsTokenServiceV2::GXS_REQUEST_STATUS_COMPLETE);
mDataAccess->updatePublicRequestStatus(token, RsTokenServiceV2::GXS_REQUEST_V2_STATUS_COMPLETE);
}else
{
mDataAccess->updatePublicRequestStatus(token, RsTokenServiceV2::GXS_REQUEST_STATUS_FAILED);
mDataAccess->updatePublicRequestStatus(token, RsTokenServiceV2::GXS_REQUEST_V2_STATUS_FAILED);
}
mMsgNotify.insert(std::make_pair(token, m.msgId));
}
@ -519,10 +524,10 @@ void RsGenExchange::processGrpMetaChanges()
if(ok)
{
mDataAccess->updatePublicRequestStatus(token, RsTokenServiceV2::GXS_REQUEST_STATUS_COMPLETE);
mDataAccess->updatePublicRequestStatus(token, RsTokenServiceV2::GXS_REQUEST_V2_STATUS_COMPLETE);
}else
{
mDataAccess->updatePublicRequestStatus(token, RsTokenServiceV2::GXS_REQUEST_STATUS_FAILED);
mDataAccess->updatePublicRequestStatus(token, RsTokenServiceV2::GXS_REQUEST_V2_STATUS_FAILED);
}
mGrpNotify.insert(std::make_pair(token, g.grpId));
}
@ -582,7 +587,7 @@ void RsGenExchange::publishMsgs()
// add to published to allow acknowledgement
mMsgNotify.insert(std::make_pair(mit->first, std::make_pair(msg->grpId, msg->msgId)));
mDataAccess->updatePublicRequestStatus(mit->first, RsTokenServiceV2::GXS_REQUEST_STATUS_COMPLETE);
mDataAccess->updatePublicRequestStatus(mit->first, RsTokenServiceV2::GXS_REQUEST_V2_STATUS_COMPLETE);
}
// if addition failed then delete nxs message
@ -628,6 +633,7 @@ void RsGenExchange::publishGrps()
grp->metaData = new RsGxsGrpMetaData();
grpItem->meta.mPublishTs = time(NULL);
*(grp->metaData) = grpItem->meta;
grp->metaData->mSubscribeFlags = GXS_SERV::GROUP_SUBSCRIBE_ADMIN;
createGroup(grp);
size = grp->metaData->serial_size();
char mData[size];
@ -639,7 +645,7 @@ void RsGenExchange::publishGrps()
// add to published to allow acknowledgement
mGrpNotify.insert(std::make_pair(mit->first, grp->grpId));
mDataAccess->updatePublicRequestStatus(mit->first, RsTokenServiceV2::GXS_REQUEST_STATUS_COMPLETE);
mDataAccess->updatePublicRequestStatus(mit->first, RsTokenServiceV2::GXS_REQUEST_V2_STATUS_COMPLETE);
}
if(!ok)
@ -652,7 +658,7 @@ void RsGenExchange::publishGrps()
// add to published to allow acknowledgement, grpid is empty as grp creation failed
mGrpNotify.insert(std::make_pair(mit->first, RsGxsGroupId("")));
mDataAccess->updatePublicRequestStatus(mit->first, RsTokenServiceV2::GXS_REQUEST_STATUS_FAILED);
mDataAccess->updatePublicRequestStatus(mit->first, RsTokenServiceV2::GXS_REQUEST_V2_STATUS_FAILED);
continue;
}
@ -664,9 +670,50 @@ void RsGenExchange::publishGrps()
mGrpsToPublish.clear();
}
void RsGenExchange::createDummyGroup(RsGxsGrpItem *grpItem)
{
RsStackMutex stack(mGenMtx);
RsNxsGrp* grp = new RsNxsGrp(mServType);
uint32_t size = mSerialiser->size(grpItem);
char gData[size];
bool ok = mSerialiser->serialise(grpItem, gData, &size);
grp->grp.setBinData(gData, size);
if(ok)
{
grp->metaData = new RsGxsGrpMetaData();
grpItem->meta.mPublishTs = time(NULL);
*(grp->metaData) = grpItem->meta;
grp->metaData->mSubscribeFlags = ~GXS_SERV::GROUP_SUBSCRIBE_MASK;
createGroup(grp);
size = grp->metaData->serial_size();
char mData[size];
grp->metaData->mGroupId = grp->grpId;
ok = grp->metaData->serialise(mData, size);
grp->meta.setBinData(mData, size);
ok = mDataAccess->addGroupData(grp);
}
if(!ok)
{
#ifdef GEN_EXCH_DEBUG
std::cerr << "RsGenExchange::createDummyGroup(); failed to publish grp " << std::endl;
#endif
delete grp;
}
delete grpItem;
}
void RsGenExchange::processRecvdData()
{
processRecvdGroups();
}
@ -677,5 +724,33 @@ void RsGenExchange::processRecvdMessages()
void RsGenExchange::processRecvdGroups()
{
RsStackMutex stack(mGenMtx);
std::vector<RsNxsGrp*>::iterator vit = mReceivedGrps.begin();
std::map<RsNxsGrp*, RsGxsGrpMetaData*> grps;
std::list<RsGxsGroupId> grpIds;
for(; vit != mReceivedGrps.end(); vit++)
{
RsNxsGrp* grp = *vit;
RsGxsGrpMetaData* meta = new RsGxsGrpMetaData();
meta->deserialise(grp->meta.bin_data, grp->meta.bin_len);
grps.insert(std::make_pair(grp, meta));
grpIds.push_back(grp->grpId);
}
if(!grpIds.empty())
{
RsGxsGroupChange* c = new RsGxsGroupChange();
c->grpIdList = grpIds;
mNotifications.push_back(c);
mDataStore->storeGroup(grps);
}
mReceivedGrps.clear();
}

View File

@ -49,12 +49,12 @@
#define RS_TOKREQ_ANSTYPE_SUMMARY 0x0002
#define RS_TOKREQ_ANSTYPE_DATA 0x0003
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.
const uint8_t RsTokenServiceV2::GXS_REQUEST_V2_STATUS_FAILED = 0;
const uint8_t RsTokenServiceV2::GXS_REQUEST_V2_STATUS_PENDING = 1;
const uint8_t RsTokenServiceV2::GXS_REQUEST_V2_STATUS_PARTIAL = 2;
const uint8_t RsTokenServiceV2::GXS_REQUEST_V2_STATUS_FINISHED_INCOMPLETE = 3;
const uint8_t RsTokenServiceV2::GXS_REQUEST_V2_STATUS_COMPLETE = 4;
const uint8_t RsTokenServiceV2::GXS_REQUEST_V2_STATUS_DONE = 5; // ONCE ALL DATA RETRIEVED.
RsGxsDataAccess::RsGxsDataAccess(RsGeneralDataService* ds)
: mDataStore(ds), mDataMutex("RsGxsDataAccess"), mNextToken(0)
@ -183,19 +183,19 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
for(; vit != toRemove.end(); vit++)
filteredMsgIds.erase(*vit);
if(reqType & GXS_REQUEST_TYPE_MSG_META)
if(reqType & GXS_REQUEST_TYPE_MSG_META)
{
MsgMetaReq* mmr = new MsgMetaReq();
mmr->mMsgIds = filteredMsgIds;
req = mmr;
}else if(reqType & GXS_REQUEST_TYPE_MSG_DATA)
}else if(reqType & GXS_REQUEST_TYPE_MSG_DATA)
{
MsgDataReq* mdr = new MsgDataReq();
mdr->mMsgIds = filteredMsgIds;
req = mdr;
}else if(reqType & GXS_REQUEST_TYPE_MSG_IDS)
}else if(reqType & GXS_REQUEST_TYPE_MSG_IDS)
{
MsgIdReq* mir = new MsgIdReq();
mir->mMsgIds = filteredMsgIds;
@ -296,7 +296,7 @@ void RsGxsDataAccess::storeRequest(GxsRequest* req)
{
RsStackMutex stack(mDataMutex); /****** LOCKED *****/
req->status = GXS_REQUEST_STATUS_PENDING;
req->status = GXS_REQUEST_V2_STATUS_PENDING;
mRequests[req->token] = req;
return;
@ -359,14 +359,14 @@ bool RsGxsDataAccess::getGroupSummary(const uint32_t& token, std::list<RsGxsGrpM
std::cerr << "RsGxsDataAccess::getGroupSummary() Unable to retrieve group summary" << std::endl;
return false;
}else if(req->status == GXS_REQUEST_STATUS_COMPLETE){
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){
GroupMetaReq* gmreq = dynamic_cast<GroupMetaReq*>(req);
if(gmreq)
{
groupInfo = gmreq->mGroupMetaData;
locked_updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
}else{
std::cerr << "RsGxsDataAccess::getGroupSummary() Req found, failed caste" << std::endl;
return false;
@ -389,14 +389,14 @@ bool RsGxsDataAccess::getGroupData(const uint32_t& token, std::list<RsNxsGrp*>&
std::cerr << "RsGxsDataAccess::getGroupData() Unable to retrieve group data" << std::endl;
return false;
}else if(req->status == GXS_REQUEST_STATUS_COMPLETE){
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){
GroupDataReq* gmreq = dynamic_cast<GroupDataReq*>(req);
if(gmreq)
{
grpData = gmreq->mGroupData;
locked_updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
}else{
std::cerr << "RsGxsDataAccess::getGroupData() Req found, failed caste" << std::endl;
return false;
@ -420,14 +420,14 @@ bool RsGxsDataAccess::getMsgData(const uint32_t& token, NxsMsgDataResult& msgDat
std::cerr << "RsGxsDataAccess::getMsgData() Unable to retrieve group data" << std::endl;
return false;
}else if(req->status == GXS_REQUEST_STATUS_COMPLETE){
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){
MsgDataReq* mdreq = dynamic_cast<MsgDataReq*>(req);
if(mdreq)
{
msgData = mdreq->mMsgData;
locked_updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
}else{
std::cerr << "RsGxsDataAccess::getMsgData() Req found, failed caste" << std::endl;
return false;
@ -451,14 +451,14 @@ bool RsGxsDataAccess::getMsgSummary(const uint32_t& token, GxsMsgMetaResult& msg
std::cerr << "RsGxsDataAccess::getMsgSummary() Unable to retrieve group data" << std::endl;
return false;
}else if(req->status == GXS_REQUEST_STATUS_COMPLETE){
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){
MsgMetaReq* mmreq = dynamic_cast<MsgMetaReq*>(req);
if(mmreq)
{
msgInfo = mmreq->mMsgMetaData;
locked_updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
}else{
std::cerr << "RsGxsDataAccess::getMsgSummary() Req found, failed caste" << std::endl;
@ -482,7 +482,7 @@ bool RsGxsDataAccess::getMsgList(const uint32_t& token, GxsMsgIdResult& msgIds)
std::cerr << "RsGxsDataAccess::getMsgList() Unable to retrieve group data" << std::endl;
return false;
}else if(req->status == GXS_REQUEST_STATUS_COMPLETE){
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){
MsgIdReq* mireq = dynamic_cast<MsgIdReq*>(req);
MsgRelatedInfoReq* mrireq = dynamic_cast<MsgRelatedInfoReq*>(req);
@ -490,12 +490,12 @@ bool RsGxsDataAccess::getMsgList(const uint32_t& token, GxsMsgIdResult& msgIds)
if(mireq)
{
msgIds = mireq->mMsgIdResult;
locked_updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
}
else if(mrireq)
{
msgIds = mrireq->mMsgIdResult;
locked_updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
}
else{
std::cerr << "RsGxsDataAccess::getMsgList() Req found, failed caste" << std::endl;
@ -520,14 +520,14 @@ bool RsGxsDataAccess::getGroupList(const uint32_t& token, std::list<RsGxsGroupId
std::cerr << "RsGxsDataAccess::getGroupList() Unable to retrieve group data,"
"\nRequest does not exist" << std::endl;
return false;
}else if(req->status == GXS_REQUEST_STATUS_COMPLETE){
}else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE){
GroupIdReq* gireq = dynamic_cast<GroupIdReq*>(req);
if(gireq)
{
groupIds = gireq->mGroupIdResult;
locked_updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
}else{
std::cerr << "RsGxsDataAccess::getGroupList() Req found, failed caste" << std::endl;
@ -579,13 +579,13 @@ void RsGxsDataAccess::processRequests()
{
GxsRequest* req = it->second;
if (req->status == GXS_REQUEST_STATUS_PENDING)
if (req->status == GXS_REQUEST_V2_STATUS_PENDING)
{
std::cerr << "RsGxsDataAccess::processRequests() Processing Token: " << req->token << " Status: "
<< req->status << " ReqType: " << req->reqType << " Age: "
<< now - req->reqTime << std::endl;
req->status = GXS_REQUEST_STATUS_PARTIAL;
req->status = GXS_REQUEST_V2_STATUS_PARTIAL;
/* PROCESS REQUEST! */
@ -624,14 +624,14 @@ void RsGxsDataAccess::processRequests()
<< req->token << std::endl;
#endif
req->status = GXS_REQUEST_STATUS_FAILED;
req->status = GXS_REQUEST_V2_STATUS_FAILED;
}
}
else if (req->status == GXS_REQUEST_STATUS_PARTIAL)
else if (req->status == GXS_REQUEST_V2_STATUS_PARTIAL)
{
req->status = GXS_REQUEST_STATUS_COMPLETE;
req->status = GXS_REQUEST_V2_STATUS_COMPLETE;
}
else if (req->status == GXS_REQUEST_STATUS_DONE)
else if (req->status == GXS_REQUEST_V2_STATUS_DONE)
{
std::cerr << "RsGxsDataAccess::processrequests() Clearing Done Request Token: "
<< req->token;
@ -1331,7 +1331,7 @@ uint32_t RsGxsDataAccess::generatePublicToken()
{
RsStackMutex stack(mDataMutex);
mPublicToken[token] = RsTokenServiceV2::GXS_REQUEST_STATUS_PENDING;
mPublicToken[token] = RsTokenServiceV2::GXS_REQUEST_V2_STATUS_PENDING;
}
return token;

View File

@ -98,7 +98,7 @@ void RsGxsNetService::syncWithPeers()
{
RsGxsGrpMetaData* meta = mit->second;
if(meta->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_MASK)
if(meta->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED)
grpIds.push_back(mit->first);
}
@ -655,8 +655,6 @@ void RsGxsNetService::locked_processCompletedIncomingTrans(NxsTransaction* tr)
}
}
int nitems = msgs.size();
// notify listener of msgs
mObserver->notifyNewMessages(msgs);
@ -761,6 +759,8 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
}
}
if(msgItemL.empty())
return;
// get grp id for this transaction
RsNxsSyncMsgItem* item = msgItemL.front();
@ -1258,3 +1258,36 @@ NxsTransaction::~NxsTransaction(){
delete mTransaction;
mTransaction = NULL;
}
/* Net Manager */
RsNxsNetMgrImpl::RsNxsNetMgrImpl(p3LinkMgr *lMgr)
: mLinkMgr(lMgr)
{
}
std::string RsNxsNetMgrImpl::getOwnId()
{
return mLinkMgr->getOwnId();
}
void RsNxsNetMgrImpl::getOnlineList(std::set<std::string> &ssl_peers)
{
ssl_peers.clear();
std::list<std::string> pList;
mLinkMgr->getOnlineList(pList);
std::list<std::string>::const_iterator lit = pList.begin();
for(; lit != pList.end(); lit++)
ssl_peers.insert(*lit);
}

View File

@ -90,17 +90,21 @@ public:
};
//class RsNxsNetMgrImpl : public RsNxsNetMgrImpl
//{
class RsNxsNetMgrImpl : public RsNxsNetMgr
{
//public:
public:
// RsNxsNetMgrImpl(p3LinkMgr* lMgr);
RsNxsNetMgrImpl(p3LinkMgr* lMgr);
// std::string getOwnId();
// void getOnlineList(std::set<std::string>& ssl_peers);
std::string getOwnId();
void getOnlineList(std::set<std::string>& ssl_peers);
//};
private:
p3LinkMgr* mLinkMgr;
};
/// keep track of transaction number

View File

@ -107,12 +107,12 @@ class RsTokenServiceV2
public:
static const uint8_t GXS_REQUEST_STATUS_FAILED;
static const uint8_t GXS_REQUEST_STATUS_PENDING;
static const uint8_t GXS_REQUEST_STATUS_PARTIAL;
static const uint8_t GXS_REQUEST_STATUS_FINISHED_INCOMPLETE;
static const uint8_t GXS_REQUEST_STATUS_COMPLETE;
static const uint8_t GXS_REQUEST_STATUS_DONE; // ONCE ALL DATA RETRIEVED.
static const uint8_t GXS_REQUEST_V2_STATUS_FAILED;
static const uint8_t GXS_REQUEST_V2_STATUS_PENDING;
static const uint8_t GXS_REQUEST_V2_STATUS_PARTIAL;
static const uint8_t GXS_REQUEST_V2_STATUS_FINISHED_INCOMPLETE;
static const uint8_t GXS_REQUEST_V2_STATUS_COMPLETE;
static const uint8_t GXS_REQUEST_V2_STATUS_DONE; // ONCE ALL DATA RETRIEVED.
public:

View File

@ -62,6 +62,7 @@
#define RS_TOKREQ_ANSTYPE_LIST 0x0001
#define RS_TOKREQ_ANSTYPE_SUMMARY 0x0002
#define RS_TOKREQ_ANSTYPE_DATA 0x0003
@ -358,8 +359,8 @@ virtual bool groupShareKeys(const std::string &groupId, std::list<std::string>&
/* The Main Interface Class - for information about your Peers */
class RsIdentity;
extern RsIdentity *rsIdentity;
class RsIdentityVEG;
extern RsIdentityVEG *rsIdentityVEG;
#define RSID_TYPE_MASK 0xff00
#define RSID_RELATION_MASK 0x00ff

View File

@ -168,6 +168,7 @@ std::ostream &operator<<(std::ostream &out, const RsPhotoPhoto &photo);
std::ostream &operator<<(std::ostream &out, const RsPhotoAlbum &album);
typedef std::map<RsGxsGroupId, std::vector<RsPhotoPhoto> > PhotoResult;
typedef std::map<RsGxsGroupId, std::vector<RsPhotoComment> > PhotoCommentResult;
typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > MsgMetaResult;
class RsPhotoV2
@ -266,6 +267,14 @@ public:
/* details are updated in album - to choose Album ID, and storage path */
/*!
* @param token token to be redeemed for photo request
* @param photo the photo returned for given request token
* @return false if request token is invalid, check token status for error report
*/
virtual bool getPhotoComment(const uint32_t &token,
PhotoCommentResult& comments) = 0;
/*!
* submits album, which returns a token that needs
* to be acknowledge to get album grp id

View File

@ -1,85 +0,0 @@
#ifndef RETROSHARE_PHOTO_GUI_INTERFACE_H
#define RETROSHARE_PHOTO_GUI_INTERFACE_H
/*
* libretroshare/src/retroshare: rsphoto.h
*
* RetroShare C++ Interface.
*
* Copyright 2008-2012 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include <inttypes.h>
#include <string>
#include <list>
#include <retroshare/rsidentityVEG.h>
#include "rsphotoV2.h"
/* The Main Interface Class - for information about your Peers */
class RsPhotoVEG;
extern RsPhotoVEG *rsPhotoVEG;
/******************* NEW STUFF FOR NEW CACHE SYSTEM *********/
#define RSPHOTO_MODE_NEW 1
#define RSPHOTO_MODE_OWN 2
#define RSPHOTO_MODE_REMOTE 3
/* If these flags are no set - the Photo inherits values from the Album
*/
#define RSPHOTO_FLAGS_ATTRIB_TITLE 0x0001
#define RSPHOTO_FLAGS_ATTRIB_CAPTION 0x0002
#define RSPHOTO_FLAGS_ATTRIB_DESC 0x0004
#define RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER 0x0008
#define RSPHOTO_FLAGS_ATTRIB_WHERE 0x0010
#define RSPHOTO_FLAGS_ATTRIB_WHEN 0x0020
#define RSPHOTO_FLAGS_ATTRIB_OTHER 0x0040
#define RSPHOTO_FLAGS_ATTRIB_CATEGORY 0x0080
#define RSPHOTO_FLAGS_ATTRIB_HASHTAGS 0x0100
#define RSPHOTO_FLAGS_ATTRIB_ORDER 0x0200
#define RSPHOTO_FLAGS_ATTRIB_THUMBNAIL 0x0400
#define RSPHOTO_FLAGS_ATTRIB_MODE 0x0800
#define RSPHOTO_FLAGS_ATTRIB_AUTHOR 0x1000 // PUSH UP ORDER
#define RSPHOTO_FLAGS_ATTRIB_PHOTO 0x2000 // PUSH UP ORDER.
std::ostream &operator<<(std::ostream &out, const RsPhotoPhoto &photo);
std::ostream &operator<<(std::ostream &out, const RsPhotoAlbum &album);
class RsPhotoVEG: public RsTokenServiceVEG
{
public:
RsPhotoVEG() { return; }
virtual ~RsPhotoVEG() { return; }
/* Specific Service Data */
virtual bool getAlbum(const uint32_t &token, RsPhotoAlbum &album) = 0;
virtual bool getPhoto(const uint32_t &token, RsPhotoPhoto &photo) = 0;
virtual bool submitAlbumDetails(uint32_t &token, RsPhotoAlbum &album, bool isNew) = 0;
virtual bool submitPhoto(uint32_t &token, RsPhotoPhoto &photo, bool isNew) = 0;
};
#endif

View File

@ -1806,7 +1806,7 @@ RsTurtle *rsTurtle = NULL ;
#include "services/p3blogs.h"
#include "turtle/p3turtle.h"
//#define ENABLE_GXS_SERVICES 1
#define ENABLE_GXS_SERVICES 1
#define ENABLE_GXS_CORE 1
#ifdef ENABLE_GXS_CORE
@ -1817,12 +1817,11 @@ RsTurtle *rsTurtle = NULL ;
#endif
#ifdef ENABLE_GXS_SERVICES
#include "services/p3photoservice.h"
#include "services/p3wikiservice.h"
#include "services/p3wire.h"
#include "services/p3idservice.h"
#include "services/p3forumsv2.h"
#include "services/p3posted.h"
#include "services/p3wikiserviceVEG.h"
#include "services/p3wireVEG.h"
#include "services/p3idserviceVEG.h".h"
#include "services/p3forumsVEG.h"
#include "services/p3postedVEG.h"
#endif
#ifndef PQI_DISABLE_TUNNEL
@ -2271,55 +2270,56 @@ int RsServer::StartupRetroShare()
// first prep the core
RsGeneralDataService* photo_ds = new RsDataService("./", "photoV2_db",
RsDirUtil::checkCreateDirectory(mLinkMgr->getOwnId());
RsGeneralDataService* photo_ds = new RsDataService("./" + mLinkMgr->getOwnId() + "/", "photoV2_db",
RS_SERVICE_GXSV1_TYPE_PHOTO, NULL);
photo_ds->resetDataStore();
// init gxs services
mPhotoV2 = new p3PhotoServiceV2(photo_ds, NULL);
// TODO need net manager
//RsGxsNetService* photo_ns = new RsGxsNetService(
// RS_SERVICE_TYPE_PHOTO, photo_ds, NULL, mPhotoV2);
RsGxsNetService* photo_ns = new RsGxsNetService(
RS_SERVICE_GXSV1_TYPE_PHOTO, photo_ds, new RsNxsNetMgrImpl(mLinkMgr), mPhotoV2);
// init gxs services
mPhotoV2 = new p3PhotoServiceV2(photo_ds, NULL);
GxsCoreServer* mGxsCore = new GxsCoreServer();
mGxsCore->addService(mPhotoV2);
// cores read start up servers !
// start nxs core core server
//createThread(*photo_ns);
createThread(*photo_ns);
// start up gxs core server
createThread(*mGxsCore);
pqih->addService(photo_ns);
#endif
#ifdef ENABLE_GXS_SERVICES
// Testing New Cache Services.
p3PhotoService *mPhotos = new p3PhotoService(RS_SERVICE_TYPE_PHOTO);
pqih -> addService(mPhotos);
// Testing New Cache Services.
p3WikiService *mWikis = new p3WikiService(RS_SERVICE_TYPE_WIKI);
p3WikiServiceVEG *mWikis = new p3WikiServiceVEG(RS_SERVICE_GXSV1_TYPE_WIKI);
pqih -> addService(mWikis);
// Testing New Cache Services.
p3Wire *mWire = new p3Wire(RS_SERVICE_TYPE_WIRE);
p3WireVEG *mWire = new p3WireVEG(RS_SERVICE_GXSV1_TYPE_WIRE);
pqih -> addService(mWire);
// Testing New Cache Services.
p3IdService *mIdentity = new p3IdService(RS_SERVICE_TYPE_IDENTITY);
p3IdServiceVEG *mIdentity = new p3IdServiceVEG(RS_SERVICE_GXSV1_TYPE_IDENTITY);
pqih -> addService(mIdentity);
// Testing New Cache Services.
p3ForumsV2 *mForumsV2 = new p3ForumsV2(RS_SERVICE_TYPE_FORUMSV2);
p3ForumsVEG *mForumsV2 = new p3ForumsVEG(RS_SERVICE_GXSV1_TYPE_FORUMS);
pqih -> addService(mForumsV2);
// Testing New Cache Services.
p3PostedService *mPosted = new p3PostedService(RS_SERVICE_TYPE_POSTED);
p3PostedServiceVEG *mPosted = new p3PostedServiceVEG(RS_SERVICE_GXSV1_TYPE_POSTED);
pqih -> addService(mPosted);
#endif // ENABLE_GXS_SERVICES
@ -2583,12 +2583,11 @@ int RsServer::StartupRetroShare()
rsPhotoV2 = mPhotoV2;
#ifdef ENABLE_GXS_SERVICES
// Testing of new cache system interfaces.
rsIdentity = mIdentity;
rsPhoto = mPhotos;
rsWiki = mWikis;
rsWire = mWire;
rsForumsV2 = mForumsV2;
rsPosted = mPosted;
rsIdentityVEG = mIdentity;
rsWikiVEG = mWikis;
rsWireVEG = mWire;
rsForumsVEG = mForumsV2;
rsPostedVEG = mPosted;
#endif // ENABLE_GXS_SERVICES

View File

@ -562,7 +562,7 @@ RsGxsPhotoCommentItem * RsGxsPhotoSerialiser::deserialiseGxsPhotoCommentItem(
/* skip the header */
offset += 8;
ok &= GetTlvString(data, rssize, &offset, 1, item->comment.mComment);
ok &= GetTlvString(data, rssize, &offset, 0, item->comment.mComment);
ok &= getRawUInt32(data, rssize, &offset, &(item->comment.mCommentFlag));
if (offset != rssize)

View File

@ -5,6 +5,11 @@
RsPhotoV2 *rsPhotoV2 = NULL;
const uint32_t RsPhotoV2::FLAG_MSG_TYPE_MASK = 0x000f;
const uint32_t RsPhotoV2::FLAG_MSG_TYPE_PHOTO_POST = 0x0001;
const uint32_t RsPhotoV2::FLAG_MSG_TYPE_PHOTO_COMMENT = 0x0002;
bool RsPhotoThumbnail::copyFrom(const RsPhotoThumbnail &nail)
@ -75,33 +80,46 @@ std::ostream &operator<<(std::ostream &out, const RsPhotoAlbum &album)
}
p3PhotoServiceV2::p3PhotoServiceV2(RsGeneralDataService* gds, RsNetworkExchangeService* nes)
: RsGenExchange(gds, nes, new RsGxsPhotoSerialiser(), RS_SERVICE_GXSV1_TYPE_PHOTO)
: RsGenExchange(gds, nes, new RsGxsPhotoSerialiser(), RS_SERVICE_GXSV1_TYPE_PHOTO), mPhotoMutex(std::string("Photo Mutex"))
{
// create dummy grps
RsGxsPhotoAlbumItem* item1 = new RsGxsPhotoAlbumItem(), *item2 = new RsGxsPhotoAlbumItem();
item1->meta.mGroupName = "Dummy Album 1";
item2->meta.mGroupName = "Dummy Album 2";
createDummyGroup(item1);
createDummyGroup(item2);
}
bool p3PhotoServiceV2::updated()
{
bool changed = (!mGroupChange.empty() || !mMsgChange.empty());
RsStackMutex stack(mPhotoMutex);
return changed;
bool changed = (!mGroupChange.empty() || !mMsgChange.empty());
return changed;
}
void p3PhotoServiceV2::groupsChanged(std::list<RsGxsGroupId>& grpIds)
{
while(!mGroupChange.empty())
{
RsGxsGroupChange* gc = mGroupChange.back();
std::list<RsGxsGroupId>& gList = gc->grpIdList;
std::list<RsGxsGroupId>::iterator lit = gList.begin();
for(; lit != gList.end(); lit++)
grpIds.push_back(*lit);
RsStackMutex stack(mPhotoMutex);
mGroupChange.pop_back();
delete gc;
}
while(!mGroupChange.empty())
{
RsGxsGroupChange* gc = mGroupChange.back();
std::list<RsGxsGroupId>& gList = gc->grpIdList;
std::list<RsGxsGroupId>::iterator lit = gList.begin();
for(; lit != gList.end(); lit++)
grpIds.push_back(*lit);
mGroupChange.pop_back();
delete gc;
}
}
@ -192,13 +210,14 @@ bool p3PhotoServiceV2::getPhoto(const uint32_t& token, PhotoResult& photos)
if(item)
{
RsPhotoPhoto photo = item->photo;
RsPhotoPhoto photo = item->photo;
photo.mMeta = item->meta;
photos[grpId].push_back(photo);
delete item;
}else
{
delete *vit;
std::cerr << "Not a photo Item, deleting!" << std::endl;
delete *vit;
}
}
}
@ -207,40 +226,79 @@ bool p3PhotoServiceV2::getPhoto(const uint32_t& token, PhotoResult& photos)
return ok;
}
bool p3PhotoServiceV2::getPhotoComment(const uint32_t &token, PhotoCommentResult &comments)
{
GxsMsgDataMap msgData;
bool ok = RsGenExchange::getMsgData(token, msgData);
if(ok)
{
GxsMsgDataMap::iterator mit = msgData.begin();
for(; mit != msgData.end(); mit++)
{
RsGxsGroupId grpId = mit->first;
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
for(; vit != msgItems.end(); vit++)
{
RsGxsPhotoCommentItem* item = dynamic_cast<RsGxsPhotoCommentItem*>(*vit);
if(item)
{
RsPhotoComment comment = item->comment;
comment.mMeta = item->meta;
comments[grpId].push_back(comment);
delete item;
}else
{
std::cerr << "Not a comment Item, deleting!" << std::endl;
delete *vit;
}
}
}
}
return ok;
}
bool p3PhotoServiceV2::submitAlbumDetails(uint32_t& token, RsPhotoAlbum& album)
{
RsGxsPhotoAlbumItem* albumItem = new RsGxsPhotoAlbumItem();
albumItem->album = album;
albumItem->meta = album.mMeta;
RsGenExchange::publishGroup(token, albumItem);
return true;
RsGxsPhotoAlbumItem* albumItem = new RsGxsPhotoAlbumItem();
albumItem->album = album;
albumItem->meta = album.mMeta;
RsGenExchange::publishGroup(token, albumItem);
return true;
}
void p3PhotoServiceV2::notifyChanges(std::vector<RsGxsNotify*>& changes)
{
std::vector<RsGxsNotify*>::iterator vit = changes.begin();
for(; vit != changes.end(); vit++)
{
RsGxsNotify* n = *vit;
RsGxsGroupChange* gc;
RsGxsMsgChange* mc;
if((mc = dynamic_cast<RsGxsMsgChange*>(n)) != NULL)
{
mMsgChange.push_back(mc);
}
else if((gc = dynamic_cast<RsGxsGroupChange*>(n)) != NULL)
{
mGroupChange.push_back(gc);
}
else
{
delete n;
}
}
RsStackMutex stack(mPhotoMutex);
std::vector<RsGxsNotify*>::iterator vit = changes.begin();
for(; vit != changes.end(); vit++)
{
RsGxsNotify* n = *vit;
RsGxsGroupChange* gc;
RsGxsMsgChange* mc;
if((mc = dynamic_cast<RsGxsMsgChange*>(n)) != NULL)
{
mMsgChange.push_back(mc);
}
else if((gc = dynamic_cast<RsGxsGroupChange*>(n)) != NULL)
{
mGroupChange.push_back(gc);
}
else
{
delete n;
}
}
}
bool p3PhotoServiceV2::submitPhoto(uint32_t& token, RsPhotoPhoto& photo)
@ -248,6 +306,7 @@ bool p3PhotoServiceV2::submitPhoto(uint32_t& token, RsPhotoPhoto& photo)
RsGxsPhotoPhotoItem* photoItem = new RsGxsPhotoPhotoItem();
photoItem->photo = photo;
photoItem->meta = photo.mMeta;
photoItem->meta.mMsgFlags = FLAG_MSG_TYPE_PHOTO_POST;
RsGenExchange::publishMsg(token, photoItem);
return true;
@ -258,6 +317,7 @@ bool p3PhotoServiceV2::submitComment(uint32_t &token, RsPhotoComment &comment)
RsGxsPhotoCommentItem* commentItem = new RsGxsPhotoCommentItem();
commentItem->comment = comment;
commentItem->meta = comment.mMeta;
commentItem->meta.mMsgFlags = FLAG_MSG_TYPE_PHOTO_COMMENT;
RsGenExchange::publishMsg(token, commentItem);
return true;

View File

@ -73,6 +73,7 @@ public:
/* Specific Service Data */
bool getAlbum(const uint32_t &token, std::vector<RsPhotoAlbum> &albums);
bool getPhoto(const uint32_t &token, PhotoResult &photos);
bool getPhotoComment(const uint32_t &token, PhotoCommentResult &comments);
public:
@ -134,6 +135,8 @@ private:
std::vector<RsGxsGroupChange*> mGroupChange;
std::vector<RsGxsMsgChange*> mMsgChange;
RsMutex mPhotoMutex;
};
#endif // P3PHOTOSERVICEV2_H

View File

@ -1,680 +0,0 @@
/*
* libretroshare/src/services p3photoservice.cc
*
* Photo Service for RetroShare.
*
* 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 "services/p3photoserviceVEG.h"
#include "util/rsrandom.h"
/****
* #define PHOTO_DEBUG 1
****/
RsPhotoVEG *rsPhotoVEG = NULL;
/********************************************************************************/
/******************* Startup / Tick ******************************************/
/********************************************************************************/
p3PhotoServiceVEG::p3PhotoServiceVEG(uint16_t type)
:p3GxsDataServiceVEG(type, new PhotoDataProxy()), mPhotoMtx("p3PhotoService"), mUpdated(true)
{
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
mPhotoProxy = (PhotoDataProxy *) mProxy;
return;
}
int p3PhotoServiceVEG::tick()
{
//std::cerr << "p3PhotoServiceVEG::tick()";
//std::cerr << std::endl;
fakeprocessrequests();
return 0;
}
bool p3PhotoServiceVEG::updated()
{
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
if (mUpdated)
{
mUpdated = false;
return true;
}
return false;
}
/* Data Requests */
bool p3PhotoServiceVEG::requestGroupInfo( uint32_t &token, uint32_t ansType, const RsTokReqOptionsVEG &opts, const std::list<std::string> &groupIds)
{
generateToken(token);
std::cerr << "p3PhotoServiceVEG::requestGroupInfo() gets Token: " << token << std::endl;
storeRequest(token, ansType, opts, GXS_REQUEST_TYPE_GROUPS, groupIds);
return true;
}
bool p3PhotoServiceVEG::requestMsgInfo( uint32_t &token, uint32_t ansType, const RsTokReqOptionsVEG &opts, const std::list<std::string> &groupIds)
{
generateToken(token);
std::cerr << "p3PhotoServiceVEG::requestMsgInfo() gets Token: " << token << std::endl;
storeRequest(token, ansType, opts, GXS_REQUEST_TYPE_MSGS, groupIds);
return true;
}
bool p3PhotoServiceVEG::requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsVEG &opts, const std::list<std::string> &msgIds)
{
generateToken(token);
std::cerr << "p3PhotoServiceVEG::requestMsgRelatedInfo() gets Token: " << token << std::endl;
storeRequest(token, ansType, opts, GXS_REQUEST_TYPE_MSGRELATED, msgIds);
return true;
}
/* Generic Lists */
bool p3PhotoServiceVEG::getGroupList( const uint32_t &token, std::list<std::string> &groupIds)
{
uint32_t status;
uint32_t reqtype;
uint32_t anstype;
time_t ts;
checkRequestStatus(token, status, reqtype, anstype, ts);
if (anstype != RS_TOKREQ_ANSTYPE_LIST)
{
std::cerr << "p3PhotoServiceVEG::getGroupList() ERROR AnsType Wrong" << std::endl;
return false;
}
if (reqtype != GXS_REQUEST_TYPE_GROUPS)
{
std::cerr << "p3PhotoServiceVEG::getGroupList() ERROR ReqType Wrong" << std::endl;
return false;
}
if (status != GXS_REQUEST_STATUS_COMPLETE)
{
std::cerr << "p3PhotoServiceVEG::getGroupList() ERROR Status Incomplete" << std::endl;
return false;
}
bool ans = loadRequestOutList(token, groupIds);
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
return ans;
}
bool p3PhotoServiceVEG::getMsgList( const uint32_t &token, std::list<std::string> &msgIds)
{
uint32_t status;
uint32_t reqtype;
uint32_t anstype;
time_t ts;
checkRequestStatus(token, status, reqtype, anstype, ts);
if (anstype != RS_TOKREQ_ANSTYPE_LIST)
{
std::cerr << "p3PhotoServiceVEG::getMsgList() ERROR AnsType Wrong" << std::endl;
return false;
}
if ((reqtype != GXS_REQUEST_TYPE_MSGS) && (reqtype != GXS_REQUEST_TYPE_MSGRELATED))
{
std::cerr << "p3PhotoServiceVEG::getMsgList() ERROR ReqType Wrong" << std::endl;
return false;
}
if (status != GXS_REQUEST_STATUS_COMPLETE)
{
std::cerr << "p3PhotoServiceVEG::getMsgList() ERROR Status Incomplete" << std::endl;
return false;
}
bool ans = loadRequestOutList(token, msgIds);
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
return ans;
}
/* Generic Summary */
bool p3PhotoServiceVEG::getGroupSummary( const uint32_t &token, std::list<RsGroupMetaData> &groupInfo)
{
uint32_t status;
uint32_t reqtype;
uint32_t anstype;
time_t ts;
checkRequestStatus(token, status, reqtype, anstype, ts);
if (anstype != RS_TOKREQ_ANSTYPE_SUMMARY)
{
std::cerr << "p3PhotoServiceVEG::getGroupSummary() ERROR AnsType Wrong" << std::endl;
return false;
}
if (reqtype != GXS_REQUEST_TYPE_GROUPS)
{
std::cerr << "p3PhotoServiceVEG::getGroupSummary() ERROR ReqType Wrong" << std::endl;
return false;
}
if (status != GXS_REQUEST_STATUS_COMPLETE)
{
std::cerr << "p3PhotoServiceVEG::getGroupSummary() ERROR Status Incomplete" << std::endl;
return false;
}
std::list<std::string> groupIds;
bool ans = loadRequestOutList(token, groupIds);
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
/* convert to RsGroupMetaData */
mProxy->getGroupSummary(groupIds, groupInfo);
return ans;
}
bool p3PhotoServiceVEG::getMsgSummary( const uint32_t &token, std::list<RsMsgMetaData> &msgInfo)
{
uint32_t status;
uint32_t reqtype;
uint32_t anstype;
time_t ts;
checkRequestStatus(token, status, reqtype, anstype, ts);
if (anstype != RS_TOKREQ_ANSTYPE_SUMMARY)
{
std::cerr << "p3PhotoServiceVEG::getMsgSummary() ERROR AnsType Wrong" << std::endl;
return false;
}
if ((reqtype != GXS_REQUEST_TYPE_MSGS) && (reqtype != GXS_REQUEST_TYPE_MSGRELATED))
{
std::cerr << "p3PhotoServiceVEG::getMsgSummary() ERROR ReqType Wrong" << std::endl;
return false;
}
if (status != GXS_REQUEST_STATUS_COMPLETE)
{
std::cerr << "p3PhotoServiceVEG::getMsgSummary() ERROR Status Incomplete" << std::endl;
return false;
}
std::list<std::string> msgIds;
bool ans = loadRequestOutList(token, msgIds);
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
/* convert to RsMsgMetaData */
mProxy->getMsgSummary(msgIds, msgInfo);
return ans;
}
/* Specific Service Data */
bool p3PhotoServiceVEG::getAlbum(const uint32_t &token, RsPhotoAlbum &album)
{
std::cerr << "p3PhotoServiceVEG::getAlbum() Token: " << token;
std::cerr << std::endl;
uint32_t status;
uint32_t reqtype;
uint32_t anstype;
time_t ts;
checkRequestStatus(token, status, reqtype, anstype, ts);
if (anstype != RS_TOKREQ_ANSTYPE_DATA)
{
std::cerr << "p3PhotoServiceVEG::getAlbum() ERROR AnsType Wrong" << std::endl;
return false;
}
if (reqtype != GXS_REQUEST_TYPE_GROUPS)
{
std::cerr << "p3PhotoServiceVEG::getAlbum() ERROR ReqType Wrong" << std::endl;
return false;
}
if (status != GXS_REQUEST_STATUS_COMPLETE)
{
std::cerr << "p3PhotoServiceVEG::getAlbum() ERROR Status Incomplete" << std::endl;
return false;
}
std::string id;
if (!popRequestOutList(token, id))
{
/* finished */
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
return false;
}
/* convert to RsPhotoAlbum */
bool ans = mPhotoProxy->getAlbum(id, album);
return ans;
}
bool p3PhotoServiceVEG::getPhoto(const uint32_t &token, RsPhotoPhoto &photo)
{
std::cerr << "p3PhotoServiceVEG::getPhoto() Token: " << token;
std::cerr << std::endl;
uint32_t status;
uint32_t reqtype;
uint32_t anstype;
time_t ts;
checkRequestStatus(token, status, reqtype, anstype, ts);
if (anstype != RS_TOKREQ_ANSTYPE_DATA)
{
std::cerr << "p3PhotoServiceVEG::getPhoto() ERROR AnsType Wrong" << std::endl;
return false;
}
if ((reqtype != GXS_REQUEST_TYPE_MSGS) && (reqtype != GXS_REQUEST_TYPE_MSGRELATED))
{
std::cerr << "p3PhotoServiceVEG::getPhoto() ERROR ReqType Wrong" << std::endl;
return false;
}
if (status != GXS_REQUEST_STATUS_COMPLETE)
{
std::cerr << "p3PhotoServiceVEG::getPhoto() ERROR Status Incomplete" << std::endl;
return false;
}
std::string id;
if (!popRequestOutList(token, id))
{
/* finished */
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
return false;
}
/* convert to RsPhotoAlbum */
bool ans = mPhotoProxy->getPhoto(id, photo);
return ans;
}
/* Poll */
uint32_t p3PhotoServiceVEG::requestStatus(const uint32_t token)
{
uint32_t status;
uint32_t reqtype;
uint32_t anstype;
time_t ts;
checkRequestStatus(token, status, reqtype, anstype, ts);
return status;
}
/* Cancel Request */
bool p3PhotoServiceVEG::cancelRequest(const uint32_t &token)
{
return clearRequest(token);
}
bool p3PhotoServiceVEG::setMessageStatus(const std::string &msgId, const uint32_t status, const uint32_t statusMask)
{
return mPhotoProxy->setMessageStatus(msgId, status, statusMask);
}
bool p3PhotoServiceVEG::setGroupStatus(const std::string &groupId, const uint32_t status, const uint32_t statusMask)
{
return mPhotoProxy->setGroupStatus(groupId, status, statusMask);
}
bool p3PhotoServiceVEG::setGroupSubscribeFlags(const std::string &groupId, uint32_t subscribeFlags, uint32_t subscribeMask)
{
return mPhotoProxy->setGroupSubscribeFlags(groupId, subscribeFlags, subscribeMask);
}
bool p3PhotoServiceVEG::setMessageServiceString(const std::string &msgId, const std::string &str)
{
return mPhotoProxy->setMessageServiceString(msgId, str);
}
bool p3PhotoServiceVEG::setGroupServiceString(const std::string &grpId, const std::string &str)
{
return mPhotoProxy->setGroupServiceString(grpId, str);
}
bool p3PhotoServiceVEG::groupRestoreKeys(const std::string &groupId)
{
return false;
}
bool p3PhotoServiceVEG::groupShareKeys(const std::string &groupId, std::list<std::string>& peers)
{
return false;
}
/* details are updated in album - to choose Album ID, and storage path */
bool p3PhotoServiceVEG::submitAlbumDetails(uint32_t &token, RsPhotoAlbum &album, bool isNew)
{
/* check if its a modification or a new album */
/* add to database */
/* check if its a mod or new photo */
if (album.mMeta.mGroupId.empty())
{
/* new photo */
/* generate a temp id */
album.mMeta.mGroupId = genRandomId();
// TODO.
//album.mMeta.mPublishTs = time(NULL);
std::cerr << "p3PhotoServiceVEG::submitAlbumDetails() Generated New GroupID: " << album.mMeta.mGroupId;
std::cerr << std::endl;
}
album.mModFlags = 0; // These are always cleared.
{
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
mUpdated = true;
/* add / modify */
mPhotoProxy->addAlbum(album);
}
// Fake a request to return the GroupMetaData.
generateToken(token);
uint32_t ansType = RS_TOKREQ_ANSTYPE_SUMMARY;
RsTokReqOptionsVEG opts; // NULL is good.
std::list<std::string> groupIds;
groupIds.push_back(album.mMeta.mGroupId); // It will just return this one.
std::cerr << "p3PhotoServiceVEG::submitAlbumDetails() Generating Request Token: " << token << std::endl;
storeRequest(token, ansType, opts, GXS_REQUEST_TYPE_GROUPS, groupIds);
return true;
}
bool p3PhotoServiceVEG::submitPhoto(uint32_t &token, RsPhotoPhoto &photo, bool isNew)
{
if (photo.mMeta.mGroupId.empty())
{
/* new photo */
std::cerr << "p3PhotoServiceVEG::submitPhoto() Missing GroupID: ERROR";
std::cerr << std::endl;
return false;
}
/* generate a new id */
photo.mMeta.mMsgId = genRandomId();
photo.mMeta.mPublishTs = time(NULL);
if (isNew)
{
/* new (Original Msg) photo */
photo.mMeta.mOrigMsgId = photo.mMeta.mMsgId;
std::cerr << "p3PhotoServiceVEG::submitPhoto() New Msg";
std::cerr << std::endl;
}
else
{
std::cerr << "p3PhotoServiceVEG::submitPhoto() Updated Msg";
std::cerr << std::endl;
}
photo.mModFlags = 0; // These are always cleared.
std::cerr << "p3PhotoServiceVEG::submitPhoto() OrigMsgId: " << photo.mMeta.mOrigMsgId;
std::cerr << " MsgId: " << photo.mMeta.mMsgId;
std::cerr << std::endl;
{
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
mUpdated = true;
mPhotoProxy->addPhoto(photo);
}
// Fake a request to return the MsgMetaData.
generateToken(token);
uint32_t ansType = RS_TOKREQ_ANSTYPE_SUMMARY;
RsTokReqOptionsVEG opts; // NULL is good.
std::list<std::string> msgIds;
msgIds.push_back(photo.mMeta.mMsgId); // It will just return this one.
std::cerr << "p3PhotoServiceVEG::submitPhoto() Generating Request Token: " << token << std::endl;
storeRequest(token, ansType, opts, GXS_REQUEST_TYPE_MSGRELATED, msgIds);
return true;
}
/********************************************************************************************/
bool PhotoDataProxy::getAlbum(const std::string &id, RsPhotoAlbum &album)
{
void *groupData = NULL;
RsGroupMetaData meta;
if (getGroupData(id, groupData) && getGroupSummary(id, meta))
{
RsPhotoAlbum *pA = (RsPhotoAlbum *) groupData;
// Shallow copy of thumbnail.
album = *pA;
// update definitive version of the metadata.
album.mMeta = meta;
std::cerr << "PhotoDataProxy::getAlbum() Id: " << id;
std::cerr << " MetaData: " << meta << " DataPointer: " << groupData;
std::cerr << std::endl;
return true;
}
std::cerr << "PhotoDataProxy::getAlbum() FAILED Id: " << id;
std::cerr << std::endl;
return false;
}
bool PhotoDataProxy::getPhoto(const std::string &id, RsPhotoPhoto &photo)
{
void *msgData = NULL;
RsMsgMetaData meta;
if (getMsgData(id, msgData) && getMsgSummary(id, meta))
{
RsPhotoPhoto *pP = (RsPhotoPhoto *) msgData;
// Shallow copy of thumbnail.
photo = *pP;
// update definitive version of the metadata.
photo.mMeta = meta;
std::cerr << "PhotoDataProxy::getPhoto() Id: " << id;
std::cerr << " MetaData: " << meta << " DataPointer: " << msgData;
std::cerr << std::endl;
return true;
}
std::cerr << "PhotoDataProxy::getPhoto() FAILED Id: " << id;
std::cerr << std::endl;
return false;
}
bool PhotoDataProxy::addAlbum(const RsPhotoAlbum &album)
{
// Make duplicate.
RsPhotoAlbum *pA = new RsPhotoAlbum();
*pA = album;
std::cerr << "PhotoDataProxy::addAlbum()";
std::cerr << " MetaData: " << pA->mMeta << " DataPointer: " << pA;
std::cerr << std::endl;
// deep copy thumbnail.
pA->mThumbnail.data = NULL;
pA->mThumbnail.copyFrom(album.mThumbnail);
return createGroup(pA);
}
bool PhotoDataProxy::addPhoto(const RsPhotoPhoto &photo)
{
// Make duplicate.
RsPhotoPhoto *pP = new RsPhotoPhoto();
*pP = photo;
std::cerr << "PhotoDataProxy::addPhoto()";
std::cerr << " MetaData: " << pP->mMeta << " DataPointer: " << pP;
std::cerr << std::endl;
// deep copy thumbnail.
pP->mThumbnail.data = NULL;
pP->mThumbnail.copyFrom(photo.mThumbnail);
return createMsg(pP);
}
/* These Functions must be overloaded to complete the service */
bool PhotoDataProxy::convertGroupToMetaData(void *groupData, RsGroupMetaData &meta)
{
RsPhotoAlbum *album = (RsPhotoAlbum *) groupData;
meta = album->mMeta;
return true;
}
bool PhotoDataProxy::convertMsgToMetaData(void *msgData, RsMsgMetaData &meta)
{
RsPhotoPhoto *photo = (RsPhotoPhoto *) msgData;
meta = photo->mMeta;
return true;
}
/********************************************************************************************/
std::string p3PhotoServiceVEG::genRandomId()
{
std::string randomId;
for(int i = 0; i < 20; i++)
{
randomId += (char) ('a' + (RSRandom::random_u32() % 26));
}
return randomId;
}
bool RsPhotoThumbnail::copyFrom(const RsPhotoThumbnail &nail)
{
if (data)
{
deleteImage();
}
if ((!nail.data) || (nail.size == 0))
{
return false;
}
size = nail.size;
type = nail.type;
data = (uint8_t *) malloc(size);
memcpy(data, nail.data, size);
return true;
}
bool RsPhotoThumbnail::deleteImage()
{
if (data)
{
free(data);
data = NULL;
size = 0;
type.clear();
}
return true;
}
/********************************************************************************************/
RsPhotoPhoto::RsPhotoPhoto()
:mSetFlags(0), mOrder(0), mMode(0), mModFlags(0)
{
return;
}
RsPhotoAlbum::RsPhotoAlbum()
:mMode(0), mSetFlags(0), mModFlags(0)
{
return;
}
std::ostream &operator<<(std::ostream &out, const RsPhotoPhoto &photo)
{
out << "RsPhotoPhoto [ ";
out << "Title: " << photo.mMeta.mMsgName;
out << "]";
return out;
}
std::ostream &operator<<(std::ostream &out, const RsPhotoAlbum &album)
{
out << "RsPhotoAlbum [ ";
out << "Title: " << album.mMeta.mGroupName;
out << "]";
return out;
}

View File

@ -1,138 +0,0 @@
/*
* libretroshare/src/services: p3photoservice.h
*
* 3P/PQI network interface for RetroShare.
*
* 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 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 P3_PHOTO_SERVICE_VEG_HEADER
#define P3_PHOTO_SERVICE_VEG_HEADER
#include "services/p3gxsserviceVEG.h"
#include "retroshare/rsphotoVEG.h"
#include <map>
#include <string>
/*
* Photo Service
*
* This is an example service for the new cache system.
* For the moment, it will only hold data passed to it from the GUI.
* and spew that back when asked....
*
* We are doing it like this - so we can check the required interface functionality.
*
* Expect it won't take long before it'll be properly linked into the backend!
*
* This will be transformed into a Plugin Service, once the basics have been worked out.
*
*/
class PhotoDataProxy: public GxsDataProxyVEG
{
public:
bool addAlbum(const RsPhotoAlbum &album);
bool addPhoto(const RsPhotoPhoto &photo);
bool getAlbum(const std::string &id, RsPhotoAlbum &album);
bool getPhoto(const std::string &id, RsPhotoPhoto &photo);
/* These Functions must be overloaded to complete the service */
virtual bool convertGroupToMetaData(void *groupData, RsGroupMetaData &meta);
virtual bool convertMsgToMetaData(void *groupData, RsMsgMetaData &meta);
};
class p3PhotoServiceVEG: public p3GxsDataServiceVEG, public RsPhotoVEG
{
public:
p3PhotoServiceVEG(uint16_t type);
virtual int tick();
public:
// NEW INTERFACE.
/************* Extern Interface *******/
/* changed? */
virtual bool updated();
/* Data Requests */
virtual bool requestGroupInfo( uint32_t &token, uint32_t ansType, const RsTokReqOptionsVEG &opts, const std::list<std::string> &groupIds);
virtual bool requestMsgInfo( uint32_t &token, uint32_t ansType, const RsTokReqOptionsVEG &opts, const std::list<std::string> &groupIds);
virtual bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsVEG &opts, const std::list<std::string> &msgIds);
/* Generic Lists */
virtual bool getGroupList( const uint32_t &token, std::list<std::string> &groupIds);
virtual bool getMsgList( const uint32_t &token, std::list<std::string> &msgIds);
/* Generic Summary */
virtual bool getGroupSummary( const uint32_t &token, std::list<RsGroupMetaData> &groupInfo);
virtual bool getMsgSummary( const uint32_t &token, std::list<RsMsgMetaData> &msgInfo);
/* Actual Data -> specific to Interface */
/* Specific Service Data */
virtual bool getAlbum(const uint32_t &token, RsPhotoAlbum &album);
virtual bool getPhoto(const uint32_t &token, RsPhotoPhoto &photo);
/* Poll */
virtual uint32_t requestStatus(const uint32_t token);
/* Cancel Request */
virtual bool cancelRequest(const uint32_t &token);
//////////////////////////////////////////////////////////////////////////////
virtual bool setMessageStatus(const std::string &msgId, const uint32_t status, const uint32_t statusMask);
virtual bool setGroupStatus(const std::string &groupId, const uint32_t status, const uint32_t statusMask);
virtual bool setGroupSubscribeFlags(const std::string &groupId, uint32_t subscribeFlags, uint32_t subscribeMask);
virtual bool setMessageServiceString(const std::string &msgId, const std::string &str);
virtual bool setGroupServiceString(const std::string &grpId, const std::string &str);
virtual bool groupRestoreKeys(const std::string &groupId);
virtual bool groupShareKeys(const std::string &groupId, std::list<std::string>& peers);
/* details are updated in album - to choose Album ID, and storage path */
virtual bool submitAlbumDetails(uint32_t &token, RsPhotoAlbum &album, bool isNew);
virtual bool submitPhoto(uint32_t &token, RsPhotoPhoto &photo, bool isNew);
private:
std::string genRandomId();
PhotoDataProxy *mPhotoProxy;
RsMutex mPhotoMtx;
bool mUpdated;
};
#endif

View File

@ -417,7 +417,7 @@ HEADERS += rshare.h \
gui/dht/DhtWindow.h \
gui/bwctrl/BwCtrlWindow.h \
gui/GetStartedDialog.h \
gui/PhotoShare/PhotoCommentItem.h
@ -520,8 +520,7 @@ FORMS += gui/StartDialog.ui \
gui/style/StyleDialog.ui \
gui/dht/DhtWindow.ui \
gui/bwctrl/BwCtrlWindow.ui \
gui/GetStartedDialog.ui \
gui/PhotoShare/PhotoCommentItem.ui
gui/GetStartedDialog.ui
SOURCES += main.cpp \
rshare.cpp \
gui/notifyqt.cpp \
@ -700,8 +699,8 @@ SOURCES += main.cpp \
gui/groups/CreateGroup.cpp \
gui/dht/DhtWindow.cpp \
gui/bwctrl/BwCtrlWindow.cpp \
gui/GetStartedDialog.cpp \
gui/PhotoShare/PhotoCommentItem.cpp
gui/GetStartedDialog.cpp
RESOURCES += gui/images.qrc lang/lang.qrc gui/help/content/content.qrc
@ -873,7 +872,9 @@ photoshare {
gui/PhotoShare/PhotoShareItemHolder.h \
gui/PhotoShare/PhotoShare.h \
gui/PhotoShare/PhotoSlideShow.h \
gui/PhotoShare/PhotoDialog.h
gui/PhotoShare/PhotoDialog.h \
gui/PhotoShare/PhotoCommentItem.h \
gui/PhotoShare/AddCommentDialog.h
FORMS += \
gui/PhotoShare/PhotoItem.ui \
@ -882,7 +883,9 @@ photoshare {
gui/PhotoShare/AlbumDialog.ui \
gui/PhotoShare/AlbumCreateDialog.ui \
gui/PhotoShare/PhotoShare.ui \
gui/PhotoShare/PhotoSlideShow.ui
gui/PhotoShare/PhotoSlideShow.ui \
gui/PhotoShare/PhotoCommentItem.ui \
gui/PhotoShare/AddCommentDialog.ui
SOURCES += \
gui/PhotoShare/PhotoItem.cpp \
@ -894,7 +897,9 @@ photoshare {
util/TokenQueueV2.cpp \
gui/PhotoShare/PhotoShareItemHolder.cpp \
gui/PhotoShare/PhotoShare.cpp \
gui/PhotoShare/PhotoSlideShow.cpp
gui/PhotoShare/PhotoSlideShow.cpp \
gui/PhotoShare/PhotoCommentItem.cpp \
gui/PhotoShare/AddCommentDialog.cpp
}

View File

@ -0,0 +1,19 @@
#include "AddCommentDialog.h"
#include "ui_AddCommentDialog.h"
AddCommentDialog::AddCommentDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AddCommentDialog)
{
ui->setupUi(this);
}
AddCommentDialog::~AddCommentDialog()
{
delete ui;
}
QString AddCommentDialog::getComment() const
{
return ui->textEditAddComment->document()->toPlainText();
}

View File

@ -0,0 +1,23 @@
#ifndef ADDCOMMENTDIALOG_H
#define ADDCOMMENTDIALOG_H
#include <QDialog>
namespace Ui {
class AddCommentDialog;
}
class AddCommentDialog : public QDialog
{
Q_OBJECT
public:
explicit AddCommentDialog(QWidget *parent = 0);
~AddCommentDialog();
QString getComment() const;
private:
Ui::AddCommentDialog *ui;
};
#endif // ADDCOMMENTDIALOG_H

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AddCommentDialog</class>
<widget class="QDialog" name="AddCommentDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>370</width>
<height>118</height>
</rect>
</property>
<property name="windowTitle">
<string>Add Comment</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTextEdit" name="textEditAddComment"/>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AddCommentDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AddCommentDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -69,7 +69,7 @@ bool AlbumCreateDialog::getAlbumThumbnail(RsPhotoThumbnail &nail)
void AlbumCreateDialog::addAlbumThumbnail()
{
QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load Album Thumbnail"), 64, 64);
QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load Album Thumbnail"), 128, 128);
if (img.isNull())
return;

View File

@ -1,14 +1,25 @@
#include "PhotoCommentItem.h"
#include "ui_PhotoCommentItem.h"
PhotoCommentItem::PhotoCommentItem(QWidget *parent) :
PhotoCommentItem::PhotoCommentItem(const RsPhotoComment& comment, QWidget *parent):
QWidget(parent),
ui(new Ui::PhotoCommentItem)
ui(new Ui::PhotoCommentItem), mComment(comment)
{
ui->setupUi(this);
setUp();
}
PhotoCommentItem::~PhotoCommentItem()
{
delete ui;
}
const RsPhotoComment& PhotoCommentItem::getComment()
{
return mComment;
}
void PhotoCommentItem::setUp()
{
ui->labelComment->setText(QString::fromStdString(mComment.mComment));
}

View File

@ -2,6 +2,7 @@
#define PHOTOCOMMENTITEM_H
#include <QWidget>
#include "retroshare/rsphotoV2.h"
namespace Ui {
class PhotoCommentItem;
@ -12,11 +13,17 @@ class PhotoCommentItem : public QWidget
Q_OBJECT
public:
explicit PhotoCommentItem(QWidget *parent = 0);
explicit PhotoCommentItem(const RsPhotoComment& comment, QWidget *parent = 0);
~PhotoCommentItem();
const RsPhotoComment& getComment();
private:
void setUp();
private:
Ui::PhotoCommentItem *ui;
RsPhotoComment mComment;
};
#endif // PHOTOCOMMENTITEM_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>484</width>
<height>110</height>
<width>479</width>
<height>89</height>
</rect>
</property>
<property name="windowTitle">
@ -30,7 +30,7 @@ border-radius: 10px;}</string>
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QWidget" name="msgWidget" native="true">
<widget class="QWidget" name="commentWidget" native="true">
<property name="styleSheet">
<string notr="true">QWidget#msgWidget{border: 2px solid #238;
border-radius: 10px;}</string>
@ -40,7 +40,7 @@ border-radius: 10px;}</string>
<number>5</number>
</property>
<item>
<widget class="QLabel" name="msgLabel">
<widget class="QLabel" name="labelComment">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>

View File

@ -1,15 +1,22 @@
#include <iostream>
#include <QVBoxLayout>
#include "PhotoDialog.h"
#include "ui_PhotoDialog.h"
PhotoDialog::PhotoDialog(RsPhotoV2 *rs_photo, const RsPhotoPhoto &photo, QWidget *parent) :
QDialog(parent),
ui(new Ui::PhotoDialog), mRsPhoto(rs_photo), mPhotoQueue(new TokenQueueV2(mRsPhoto->getTokenService(), this)),
mPhotoDetails(photo)
mPhotoDetails(photo), mCommentDialog(NULL)
{
ui->setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true );
setUp();
connect(ui->toolButton_AddComment, SIGNAL(clicked()), this, SLOT(addComment()));
}
PhotoDialog::~PhotoDialog()
@ -24,15 +31,155 @@ void PhotoDialog::setUp()
qtn.loadFromData(mPhotoDetails.mThumbnail.data, mPhotoDetails.mThumbnail.size, mPhotoDetails.mThumbnail.type.c_str());
ui->label_Photo->setPixmap(qtn);
ui->lineEdit_Title->setText(QString::fromStdString(mPhotoDetails.mMeta.mMsgName));
ui->scrollAreaWidgetContents->setLayout(new QVBoxLayout());
}
void PhotoDialog::loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &req)
{
}
void PhotoDialog::addComment()
{
mCommentDialog = new AddCommentDialog(this);
connect(mCommentDialog, SIGNAL(accepted()), this, SLOT(createComment()));
connect(mCommentDialog, SIGNAL(rejected()), mCommentDialog, SLOT(deleteLater()));
mCommentDialog->exec();
}
void PhotoDialog::clearComments()
{
QLayout* l = ui->scrollAreaWidgetContents->layout();
QSetIterator<PhotoCommentItem*> sit(mComments);
while(sit.hasNext())
{
PhotoCommentItem* item = sit.next();
l->removeWidget(item);
item->setParent(NULL);
}
}
void PhotoDialog::resetComments()
{
clearComments();
QSetIterator<PhotoCommentItem*> sit(mComments);
QLayout* l = ui->scrollAreaWidgetContents->layout();
while(sit.hasNext())
{
PhotoCommentItem* item = sit.next();
l->addWidget(item);
}
}
void PhotoDialog::createComment()
{
if(mCommentDialog)
{
RsPhotoComment comment;
QString commentString = mCommentDialog->getComment();
comment.mComment = commentString.toStdString();
uint32_t token;
comment.mMeta.mGroupId = mPhotoDetails.mMeta.mGroupId;
mRsPhoto->submitComment(token, comment);
mPhotoQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
mCommentDialog->close();
delete mCommentDialog;
mCommentDialog = NULL;
}
}
/*************** message loading **********************/
void PhotoDialog::loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &req)
{
std::cerr << "PhotoShare::loadRequest()";
std::cerr << std::endl;
if (queue == mPhotoQueue)
{
/* now switch on req */
switch(req.mType)
{
case TOKENREQ_MSGINFO:
{
switch(req.mAnsType)
{
case RS_TOKREQ_ANSTYPE_DATA:
loadComment(req.mToken);
break;
case RS_TOKREQ_ANSTYPE_ACK:
acknowledgeComment(req.mToken);
break;
default:
std::cerr << "PhotoShare::loadRequest() ERROR: MSG INVALID TYPE";
std::cerr << std::endl;
break;
}
break;
}
default:
{
std::cerr << "PhotoShare::loadRequest() ERROR: INVALID TYPE";
std::cerr << std::endl;
break;
}
}
}
}
void PhotoDialog::loadComment(uint32_t token)
{
PhotoCommentResult results;
mRsPhoto->getPhotoComment(token, results);
PhotoCommentResult::iterator mit = results.begin();
for(; mit != results.end(); mit++)
{
const std::vector<RsPhotoComment>& commentV = mit->second;
std::vector<RsPhotoComment>::const_iterator vit = commentV.begin();
for(; vit != commentV.end(); vit++)
{
addComment(*vit);
}
}
resetComments();
}
void PhotoDialog::addComment(const RsPhotoComment &comment)
{
PhotoCommentItem* item = new PhotoCommentItem(comment);
mComments.insert(item);
}
void PhotoDialog::acknowledgeComment(uint32_t token)
{
RsGxsGrpMsgIdPair msgId;
mRsPhoto->acknowledgeMsg(token, msgId);
if(msgId.first.empty() || msgId.second.empty()){
}else
{
uint32_t reqToken;
RsTokReqOptionsV2 opts;
opts.mMsgFlagMask = RsPhotoV2::FLAG_MSG_TYPE_MASK;
opts.mMsgFlagFilter = RsPhotoV2::FLAG_MSG_TYPE_PHOTO_COMMENT;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
GxsMsgReq req;
std::vector<RsGxsMessageId> msgIdsV;
msgIdsV.push_back(msgId.second);
req.insert(std::make_pair(msgId.first, msgIdsV));
mPhotoQueue->requestMsgInfo(reqToken, RS_TOKREQ_ANSTYPE_DATA, opts, req, 0);
}
}

View File

@ -2,8 +2,11 @@
#define PHOTODIALOG_H
#include <QDialog>
#include <QSet>
#include "retroshare/rsphotoV2.h"
#include "util/TokenQueueV2.h"
#include "PhotoCommentItem.h"
#include "AddCommentDialog.h"
namespace Ui {
class PhotoDialog;
@ -20,17 +23,35 @@ public:
private slots:
void addComment();
void createComment();
public:
void loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &req);
private:
void setUp();
/*!
* clears comments
* and places them back in dialog
*/
void resetComments();
/*!
* Simply removes comments but doesn't place them back in dialog
*/
void clearComments();
void acknowledgeComment(uint32_t token);
void loadComment(uint32_t token);
void addComment(const RsPhotoComment& comment);
private:
Ui::PhotoDialog *ui;
RsPhotoV2* mRsPhoto;
TokenQueueV2* mPhotoQueue;
RsPhotoPhoto mPhotoDetails;
QSet<PhotoCommentItem*> mComments;
AddCommentDialog* mCommentDialog;
};

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>516</width>
<height>449</height>
<height>460</height>
</rect>
</property>
<property name="windowTitle">
@ -173,7 +173,7 @@
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<widget class="QToolButton" name="toolButton_AddComment">
<property name="text">
<string>Add Comment</string>
</property>
@ -195,14 +195,11 @@
</layout>
</item>
<item>
<widget class="QScrollArea" name="scrollArea_2">
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_2">
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
@ -211,24 +208,6 @@
<height>69</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>

View File

@ -178,7 +178,12 @@ void PhotoShare::checkUpdate()
std::list<std::string> grpIds;
rsPhotoV2->groupsChanged(grpIds);
if(!grpIds.empty())
requestAlbumList(grpIds);
{
RsTokReqOptionsV2 opts;
uint32_t token;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
mPhotoQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, 0);
}
GxsMsgIdResult res;
rsPhotoV2->msgsChanged(res);

View File

@ -66,11 +66,12 @@ bool TokenQueueV2::requestMsgInfo(uint32_t &token, uint32_t anstype, const RsTok
return true;
}
bool TokenQueueV2::requestMsgRelatedInfo(uint32_t &token, const RsTokReqOptionsV2 &opts, const GxsMsgReq& msgIds, uint32_t usertype)
bool TokenQueueV2::requestMsgRelatedInfo(uint32_t &token, const RsTokReqOptionsV2 &opts, const RsGxsGrpMsgIdPair &msgId, uint32_t usertype)
{
uint32_t basictype = TOKENREQ_MSGINFO;
uint32_t anstype = RS_TOKREQ_ANSTYPE_LIST; // always a list answer
mService->requestMsgRelatedInfo(token, anstype, opts, msgIds);
mService->requestMsgRelatedInfo(token, anstype, opts, msgId);
queueRequest(token, basictype, anstype, usertype);
return true;
@ -154,8 +155,8 @@ bool TokenQueueV2::checkForRequest(uint32_t token)
{
/* check token */
uint32_t status = mService->requestStatus(token);
return ( (RsTokenServiceV2::GXS_REQUEST_STATUS_FAILED == status) ||
(RsTokenServiceV2::GXS_REQUEST_STATUS_COMPLETE == status) );
return ( (RsTokenServiceV2::GXS_REQUEST_V2_STATUS_FAILED == status) ||
(RsTokenServiceV2::GXS_REQUEST_V2_STATUS_COMPLETE == status) );
}

View File

@ -94,7 +94,7 @@ public:
bool requestMsgInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptionsV2 &opts,
const GxsMsgReq& grpIds, uint32_t usertype);
bool requestMsgRelatedInfo(uint32_t &token, const RsTokReqOptionsV2 &opts, const GxsMsgReq& msgIds, uint32_t usertype);
bool requestMsgRelatedInfo(uint32_t &token, const RsTokReqOptionsV2 &opts, const RsGxsGrpMsgIdPair& msgId, uint32_t usertype);
bool cancelRequest(const uint32_t token);

View File

@ -56,7 +56,7 @@ class TokenResponseVEG
public:
//virtual ~TokenResponse() { return; }
// These Functions are overloaded to get results out.
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req) = 0;
virtual void loadRequest(const TokenQueueVEG *queue, const TokenRequestVEG &req) = 0;
};