mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Added cleanup code for GXS services in rsinit (services now based in GXS_phase1 folder in .retroshare/ folder
disabled msg synchronisation by default through compilation #define (use GXS_ENABLE_MSG_SYNC to enable message sync) Finally removed v2 suffix from all photo components and filenames (please edit your libretroshare.pro file accordingly) git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5883 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
da39d1de77
commit
744a78b140
@ -86,6 +86,8 @@ void RsGxsNetService::syncWithPeers()
|
||||
sendItem(grp);
|
||||
}
|
||||
|
||||
|
||||
#ifdef GXS_ENABLE_SYNC_MSGS
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData* > grpMeta;
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMeta);
|
||||
|
||||
@ -123,6 +125,7 @@ void RsGxsNetService::syncWithPeers()
|
||||
sendItem(msg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool RsGxsNetService::loadList(std::list<RsItem*>& load)
|
||||
|
@ -32,8 +32,8 @@
|
||||
#include "rsgxsservice.h"
|
||||
|
||||
/* The Main Interface Class - for information about your Peers */
|
||||
class RsPhotoV2;
|
||||
extern RsPhotoV2 *rsPhotoV2;
|
||||
class RsPhoto;
|
||||
extern RsPhoto *rsPhoto;
|
||||
|
||||
/******************* NEW STUFF FOR NEW CACHE SYSTEM *********/
|
||||
|
||||
@ -176,7 +176,7 @@ typedef std::map<RsGxsGroupId, std::vector<RsPhotoPhoto> > PhotoResult;
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsPhotoComment> > PhotoCommentResult;
|
||||
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsPhotoComment> > PhotoRelatedCommentResult;
|
||||
|
||||
class RsPhotoV2
|
||||
class RsPhoto
|
||||
{
|
||||
|
||||
public:
|
||||
@ -186,9 +186,9 @@ public:
|
||||
static const uint32_t FLAG_MSG_TYPE_MASK;
|
||||
|
||||
|
||||
RsPhotoV2() { return; }
|
||||
RsPhoto() { return; }
|
||||
|
||||
virtual ~RsPhotoV2() { return; }
|
||||
virtual ~RsPhoto() { return; }
|
||||
|
||||
/*!
|
||||
* Use to enquire if groups or msgs have changed
|
@ -1827,7 +1827,7 @@ RsTurtle *rsTurtle = NULL ;
|
||||
#include "services/p3idservice.h"
|
||||
#include "services/p3wiki.h"
|
||||
#include "services/p3posted.h"
|
||||
#include "services/p3photoserviceV2.h"
|
||||
#include "services/p3photoservice.h"
|
||||
#include "services/p3gxsforums.h"
|
||||
|
||||
// Not too many to convert now!
|
||||
@ -2278,9 +2278,28 @@ int RsServer::StartupRetroShare()
|
||||
mPluginsManager->registerCacheServices() ;
|
||||
|
||||
|
||||
|
||||
#ifdef ENABLE_GXS_SERVICES
|
||||
|
||||
// The idea is that if priorGxsDir is non
|
||||
// empty and matches an exist directory location
|
||||
// the given ssl user id then this directory is cleaned
|
||||
// and deleted
|
||||
std::string priorGxsDir = "./" + mLinkMgr->getOwnId() + "/", currGxsDir = RsInitConfig::configDir + "/GXS_phase1";
|
||||
bool cleanUpGxsDir = false;
|
||||
|
||||
if(!priorGxsDir.empty())
|
||||
cleanUpGxsDir = RsDirUtil::checkDirectory(priorGxsDir);
|
||||
|
||||
std::list<std::string> filesToKeep;
|
||||
bool cleanUpSuccess = RsDirUtil::cleanupDirectory(priorGxsDir, filesToKeep);
|
||||
|
||||
if(!cleanUpSuccess)
|
||||
std::cerr << "RsInit::StartupRetroShare() Clean up of Old Gxs Dir Failed!";
|
||||
else
|
||||
rmdir(priorGxsDir.c_str());
|
||||
|
||||
RsDirUtil::checkCreateDirectory(currGxsDir);
|
||||
|
||||
// Testing New Cache Services.
|
||||
//p3WikiServiceVEG *mWikis = new p3WikiServiceVEG(RS_SERVICE_GXSV1_TYPE_WIKI);
|
||||
//pqih -> addService(mWikis);
|
||||
@ -2295,7 +2314,7 @@ int RsServer::StartupRetroShare()
|
||||
|
||||
|
||||
// TODO: temporary to store GXS service data, remove
|
||||
RsDirUtil::checkCreateDirectory(mLinkMgr->getOwnId());
|
||||
RsDirUtil::checkCreateDirectory(currGxsDir);
|
||||
|
||||
RsNxsNetMgr* nxsMgr = new RsNxsNetMgrImpl(mLinkMgr);
|
||||
|
||||
@ -2303,7 +2322,7 @@ int RsServer::StartupRetroShare()
|
||||
|
||||
p3IdService *mGxsIdService = NULL;
|
||||
|
||||
RsGeneralDataService* gxsid_ds = new RsDataService("./" + mLinkMgr->getOwnId() + "/", "gxsid_db",
|
||||
RsGeneralDataService* gxsid_ds = new RsDataService(currGxsDir + "/", "gxsid_db",
|
||||
RS_SERVICE_GXSV1_TYPE_GXSID, NULL);
|
||||
|
||||
gxsid_ds->resetDataStore();
|
||||
@ -2338,27 +2357,27 @@ int RsServer::StartupRetroShare()
|
||||
RsGenExchange::setAuthenPolicyFlag(flag, photoAuthenPolicy,
|
||||
RsGenExchange::GRP_OPTION_BITS);
|
||||
|
||||
p3PhotoServiceV2 *mPhotoV2 = NULL;
|
||||
p3PhotoService *mPhoto = NULL;
|
||||
|
||||
|
||||
RsGeneralDataService* photo_ds = new RsDataService("./" + mLinkMgr->getOwnId() + "/", "photoV2_db",
|
||||
RsGeneralDataService* photo_ds = new RsDataService(currGxsDir + "/", "photoV2_db",
|
||||
RS_SERVICE_GXSV1_TYPE_PHOTO, NULL);
|
||||
|
||||
photo_ds->resetDataStore(); //TODO: remove, new service data per RS session, for testing
|
||||
|
||||
|
||||
// init gxs services
|
||||
mPhotoV2 = new p3PhotoServiceV2(photo_ds, NULL, mGxsIdService, photoAuthenPolicy);
|
||||
mPhoto = new p3PhotoService(photo_ds, NULL, mGxsIdService, photoAuthenPolicy);
|
||||
|
||||
// create GXS photo service
|
||||
RsGxsNetService* photo_ns = new RsGxsNetService(
|
||||
RS_SERVICE_GXSV1_TYPE_PHOTO, photo_ds, nxsMgr, mPhotoV2);
|
||||
RS_SERVICE_GXSV1_TYPE_PHOTO, photo_ds, nxsMgr, mPhoto);
|
||||
|
||||
/**** Posted GXS service ****/
|
||||
|
||||
p3Posted *mPosted = NULL;
|
||||
|
||||
RsGeneralDataService* posted_ds = new RsDataService("./" + mLinkMgr->getOwnId()+ "/", "posted_db",
|
||||
RsGeneralDataService* posted_ds = new RsDataService(currGxsDir + "/", "posted_db",
|
||||
RS_SERVICE_GXSV1_TYPE_POSTED);
|
||||
|
||||
posted_ds->resetDataStore(); //TODO: remove, new service data per RS session, for testing
|
||||
@ -2374,7 +2393,7 @@ int RsServer::StartupRetroShare()
|
||||
|
||||
p3Wiki *mWiki = NULL;
|
||||
|
||||
RsGeneralDataService* wiki_ds = new RsDataService("./" + mLinkMgr->getOwnId()+ "/", "wiki_db",
|
||||
RsGeneralDataService* wiki_ds = new RsDataService(currGxsDir + "/", "wiki_db",
|
||||
RS_SERVICE_GXSV1_TYPE_WIKI);
|
||||
|
||||
wiki_ds->resetDataStore(); //TODO: remove, new service data per RS session, for testing
|
||||
@ -2389,7 +2408,7 @@ int RsServer::StartupRetroShare()
|
||||
|
||||
p3GxsForums *mGxsForums = NULL;
|
||||
|
||||
RsGeneralDataService* gxsforums_ds = new RsDataService("./" + mLinkMgr->getOwnId()+ "/", "gxsforums_db",
|
||||
RsGeneralDataService* gxsforums_ds = new RsDataService(currGxsDir + "/", "gxsforums_db",
|
||||
RS_SERVICE_GXSV1_TYPE_FORUMS);
|
||||
|
||||
gxsforums_ds->resetDataStore(); //TODO: remove, new service data per RS session, for testing
|
||||
@ -2411,12 +2430,12 @@ int RsServer::StartupRetroShare()
|
||||
//mGxsCore->addService(mGxsIdService);
|
||||
#if ENABLE_OTHER_GXS_SERVICES
|
||||
createThread(*mGxsIdService);
|
||||
createThread(*mPhotoV2);
|
||||
createThread(*mPhoto);
|
||||
createThread(*mPosted);
|
||||
createThread(*mWiki);
|
||||
createThread(*mGxsForums);
|
||||
//
|
||||
// mGxsCore->addService(mPhotoV2);
|
||||
// mGxsCore->addService(mPhoto);
|
||||
// mGxsCore->addService(mPosted);
|
||||
// mGxsCore->addService(mWiki);
|
||||
#endif
|
||||
@ -2707,7 +2726,7 @@ int RsServer::StartupRetroShare()
|
||||
#if ENABLE_OTHER_GXS_SERVICES
|
||||
rsWiki = mWiki;
|
||||
rsPosted = mPosted;
|
||||
rsPhotoV2 = mPhotoV2;
|
||||
rsPhoto = mPhoto;
|
||||
rsGxsForums = mGxsForums;
|
||||
#endif
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "rsphotov2items.h"
|
||||
#include "rsphotoitems.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "serialiser/rstlvtypes.h"
|
||||
|
||||
#include "rsgxsitems.h"
|
||||
#include "retroshare/rsphotoV2.h"
|
||||
#include "retroshare/rsphoto.h"
|
||||
|
||||
const uint8_t RS_PKT_SUBTYPE_PHOTO_ITEM = 0x02;
|
||||
const uint8_t RS_PKT_SUBTYPE_PHOTO_SHOW_ITEM = 0x03;
|
@ -1,388 +1,388 @@
|
||||
#include "p3photoserviceV2.h"
|
||||
#include "serialiser/rsphotov2items.h"
|
||||
#include "gxs/rsgxsflags.h"
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
RsPhotoComment::RsPhotoComment()
|
||||
: mComment(""), mCommentFlag(0) {
|
||||
|
||||
}
|
||||
|
||||
RsPhotoComment::RsPhotoComment(const RsGxsPhotoCommentItem &comment)
|
||||
: mComment(""), mCommentFlag(0) {
|
||||
|
||||
*this = comment.comment;
|
||||
(*this).mMeta = comment.meta;
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
p3PhotoServiceV2::p3PhotoServiceV2(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs,
|
||||
uint32_t authenPolicy)
|
||||
: RsGenExchange(gds, nes, new RsGxsPhotoSerialiser(), RS_SERVICE_GXSV1_TYPE_PHOTO, gixs, authenPolicy),
|
||||
mPhotoMutex(std::string("Photo Mutex"))
|
||||
{
|
||||
|
||||
// create dummy grps
|
||||
|
||||
RsGxsPhotoAlbumItem* item1 = new RsGxsPhotoAlbumItem(), *item2 = new RsGxsPhotoAlbumItem();
|
||||
|
||||
item1->meta.mGroupName = "Dummy Album 1";
|
||||
item1->meta.mGroupFlags = GXS_SERV::FLAG_PRIVACY_RESTRICTED;
|
||||
item1->album.mCaption = "Dummy 1";
|
||||
item2->meta.mGroupName = "Dummy Album 2";
|
||||
item2->meta.mGroupFlags = GXS_SERV::FLAG_PRIVACY_RESTRICTED;
|
||||
item2->album.mCaption = "Dummy 2";
|
||||
|
||||
createDummyGroup(item1);
|
||||
createDummyGroup(item2);
|
||||
}
|
||||
|
||||
bool p3PhotoServiceV2::updated()
|
||||
{
|
||||
RsStackMutex stack(mPhotoMutex);
|
||||
|
||||
bool changed = (!mGroupChange.empty() || !mMsgChange.empty());
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
void p3PhotoServiceV2::service_tick()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void p3PhotoServiceV2::groupsChanged(std::list<RsGxsGroupId>& grpIds)
|
||||
{
|
||||
RsStackMutex stack(mPhotoMutex);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void p3PhotoServiceV2::msgsChanged(
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgs)
|
||||
{
|
||||
RsStackMutex stack(mPhotoMutex);
|
||||
|
||||
while(!mMsgChange.empty())
|
||||
{
|
||||
RsGxsMsgChange* mc = mMsgChange.back();
|
||||
msgs = mc->msgChangeMap;
|
||||
mMsgChange.pop_back();
|
||||
delete mc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RsTokenService* p3PhotoServiceV2::getTokenService() {
|
||||
|
||||
return RsGenExchange::getTokenService();
|
||||
}
|
||||
|
||||
|
||||
bool p3PhotoServiceV2::getGroupList(const uint32_t& token,
|
||||
std::list<RsGxsGroupId>& groupIds)
|
||||
{
|
||||
return RsGenExchange::getGroupList(token, groupIds);
|
||||
}
|
||||
|
||||
|
||||
bool p3PhotoServiceV2::getMsgList(const uint32_t& token,
|
||||
GxsMsgIdResult& msgIds)
|
||||
{
|
||||
|
||||
return RsGenExchange::getMsgList(token, msgIds);
|
||||
}
|
||||
|
||||
|
||||
bool p3PhotoServiceV2::getGroupSummary(const uint32_t& token,
|
||||
std::list<RsGroupMetaData>& groupInfo)
|
||||
{
|
||||
return RsGenExchange::getGroupMeta(token, groupInfo);
|
||||
}
|
||||
|
||||
|
||||
bool p3PhotoServiceV2::getMsgSummary(const uint32_t& token,
|
||||
MsgMetaResult& msgInfo)
|
||||
{
|
||||
return RsGenExchange::getMsgMeta(token, msgInfo);
|
||||
}
|
||||
|
||||
|
||||
bool p3PhotoServiceV2::getAlbum(const uint32_t& token, std::vector<RsPhotoAlbum>& albums)
|
||||
{
|
||||
std::vector<RsGxsGrpItem*> grpData;
|
||||
bool ok = RsGenExchange::getGroupData(token, grpData);
|
||||
|
||||
if(ok)
|
||||
{
|
||||
std::vector<RsGxsGrpItem*>::iterator vit = grpData.begin();
|
||||
|
||||
for(; vit != grpData.end(); vit++)
|
||||
{
|
||||
RsGxsPhotoAlbumItem* item = dynamic_cast<RsGxsPhotoAlbumItem*>(*vit);
|
||||
RsPhotoAlbum album = item->album;
|
||||
item->album.mMeta = item->meta;
|
||||
album.mMeta = item->album.mMeta;
|
||||
delete item;
|
||||
albums.push_back(album);
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool p3PhotoServiceV2::getPhoto(const uint32_t& token, PhotoResult& photos)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
RsGxsPhotoPhotoItem* item = dynamic_cast<RsGxsPhotoPhotoItem*>(*vit);
|
||||
|
||||
if(item)
|
||||
{
|
||||
RsPhotoPhoto photo = item->photo;
|
||||
photo.mMeta = item->meta;
|
||||
photos[grpId].push_back(photo);
|
||||
delete item;
|
||||
}else
|
||||
{
|
||||
std::cerr << "Not a photo Item, deleting!" << std::endl;
|
||||
delete *vit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
RsPhotoComment& RsPhotoComment::operator=(const RsGxsPhotoCommentItem& comment)
|
||||
{
|
||||
*this = comment.comment;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool p3PhotoServiceV2::getPhotoRelatedComment(const uint32_t &token, PhotoRelatedCommentResult &comments)
|
||||
{
|
||||
|
||||
return RsGenExchange::getMsgRelatedDataT<RsGxsPhotoCommentItem, RsPhotoComment>(token, comments);
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void p3PhotoServiceV2::notifyChanges(std::vector<RsGxsNotify*>& changes)
|
||||
{
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool p3PhotoServiceV2::acknowledgeMsg(const uint32_t& token,
|
||||
std::pair<RsGxsGroupId, RsGxsMessageId>& msgId)
|
||||
{
|
||||
return RsGenExchange::acknowledgeTokenMsg(token, msgId);
|
||||
}
|
||||
|
||||
|
||||
bool p3PhotoServiceV2::acknowledgeGrp(const uint32_t& token,
|
||||
RsGxsGroupId& grpId)
|
||||
{
|
||||
return RsGenExchange::acknowledgeTokenGrp(token, grpId);
|
||||
}
|
||||
|
||||
bool p3PhotoServiceV2::subscribeToAlbum(uint32_t &token, const RsGxsGroupId &grpId, bool subscribe)
|
||||
{
|
||||
if(subscribe)
|
||||
RsGenExchange::setGroupSubscribeFlags(token, grpId, GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED, GXS_SERV::GROUP_SUBSCRIBE_MASK);
|
||||
else
|
||||
RsGenExchange::setGroupSubscribeFlags(token, grpId, 0, GXS_SERV::GROUP_SUBSCRIBE_MASK);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#include "p3photoservice.h"
|
||||
#include "serialiser/rsphotoitems.h"
|
||||
#include "gxs/rsgxsflags.h"
|
||||
|
||||
RsPhoto *rsPhoto = NULL;
|
||||
|
||||
|
||||
const uint32_t RsPhoto::FLAG_MSG_TYPE_MASK = 0x000f;
|
||||
const uint32_t RsPhoto::FLAG_MSG_TYPE_PHOTO_POST = 0x0001;
|
||||
const uint32_t RsPhoto::FLAG_MSG_TYPE_PHOTO_COMMENT = 0x0002;
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
RsPhotoComment::RsPhotoComment()
|
||||
: mComment(""), mCommentFlag(0) {
|
||||
|
||||
}
|
||||
|
||||
RsPhotoComment::RsPhotoComment(const RsGxsPhotoCommentItem &comment)
|
||||
: mComment(""), mCommentFlag(0) {
|
||||
|
||||
*this = comment.comment;
|
||||
(*this).mMeta = comment.meta;
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
p3PhotoService::p3PhotoService(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs,
|
||||
uint32_t authenPolicy)
|
||||
: RsGenExchange(gds, nes, new RsGxsPhotoSerialiser(), RS_SERVICE_GXSV1_TYPE_PHOTO, gixs, authenPolicy),
|
||||
mPhotoMutex(std::string("Photo Mutex"))
|
||||
{
|
||||
|
||||
// create dummy grps
|
||||
|
||||
RsGxsPhotoAlbumItem* item1 = new RsGxsPhotoAlbumItem(), *item2 = new RsGxsPhotoAlbumItem();
|
||||
|
||||
item1->meta.mGroupName = "Dummy Album 1";
|
||||
item1->meta.mGroupFlags = GXS_SERV::FLAG_PRIVACY_RESTRICTED;
|
||||
item1->album.mCaption = "Dummy 1";
|
||||
item2->meta.mGroupName = "Dummy Album 2";
|
||||
item2->meta.mGroupFlags = GXS_SERV::FLAG_PRIVACY_RESTRICTED;
|
||||
item2->album.mCaption = "Dummy 2";
|
||||
|
||||
createDummyGroup(item1);
|
||||
createDummyGroup(item2);
|
||||
}
|
||||
|
||||
bool p3PhotoService::updated()
|
||||
{
|
||||
RsStackMutex stack(mPhotoMutex);
|
||||
|
||||
bool changed = (!mGroupChange.empty() || !mMsgChange.empty());
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
void p3PhotoService::service_tick()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void p3PhotoService::groupsChanged(std::list<RsGxsGroupId>& grpIds)
|
||||
{
|
||||
RsStackMutex stack(mPhotoMutex);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void p3PhotoService::msgsChanged(
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgs)
|
||||
{
|
||||
RsStackMutex stack(mPhotoMutex);
|
||||
|
||||
while(!mMsgChange.empty())
|
||||
{
|
||||
RsGxsMsgChange* mc = mMsgChange.back();
|
||||
msgs = mc->msgChangeMap;
|
||||
mMsgChange.pop_back();
|
||||
delete mc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RsTokenService* p3PhotoService::getTokenService() {
|
||||
|
||||
return RsGenExchange::getTokenService();
|
||||
}
|
||||
|
||||
|
||||
bool p3PhotoService::getGroupList(const uint32_t& token,
|
||||
std::list<RsGxsGroupId>& groupIds)
|
||||
{
|
||||
return RsGenExchange::getGroupList(token, groupIds);
|
||||
}
|
||||
|
||||
|
||||
bool p3PhotoService::getMsgList(const uint32_t& token,
|
||||
GxsMsgIdResult& msgIds)
|
||||
{
|
||||
|
||||
return RsGenExchange::getMsgList(token, msgIds);
|
||||
}
|
||||
|
||||
|
||||
bool p3PhotoService::getGroupSummary(const uint32_t& token,
|
||||
std::list<RsGroupMetaData>& groupInfo)
|
||||
{
|
||||
return RsGenExchange::getGroupMeta(token, groupInfo);
|
||||
}
|
||||
|
||||
|
||||
bool p3PhotoService::getMsgSummary(const uint32_t& token,
|
||||
MsgMetaResult& msgInfo)
|
||||
{
|
||||
return RsGenExchange::getMsgMeta(token, msgInfo);
|
||||
}
|
||||
|
||||
|
||||
bool p3PhotoService::getAlbum(const uint32_t& token, std::vector<RsPhotoAlbum>& albums)
|
||||
{
|
||||
std::vector<RsGxsGrpItem*> grpData;
|
||||
bool ok = RsGenExchange::getGroupData(token, grpData);
|
||||
|
||||
if(ok)
|
||||
{
|
||||
std::vector<RsGxsGrpItem*>::iterator vit = grpData.begin();
|
||||
|
||||
for(; vit != grpData.end(); vit++)
|
||||
{
|
||||
RsGxsPhotoAlbumItem* item = dynamic_cast<RsGxsPhotoAlbumItem*>(*vit);
|
||||
RsPhotoAlbum album = item->album;
|
||||
item->album.mMeta = item->meta;
|
||||
album.mMeta = item->album.mMeta;
|
||||
delete item;
|
||||
albums.push_back(album);
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool p3PhotoService::getPhoto(const uint32_t& token, PhotoResult& photos)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
RsGxsPhotoPhotoItem* item = dynamic_cast<RsGxsPhotoPhotoItem*>(*vit);
|
||||
|
||||
if(item)
|
||||
{
|
||||
RsPhotoPhoto photo = item->photo;
|
||||
photo.mMeta = item->meta;
|
||||
photos[grpId].push_back(photo);
|
||||
delete item;
|
||||
}else
|
||||
{
|
||||
std::cerr << "Not a photo Item, deleting!" << std::endl;
|
||||
delete *vit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool p3PhotoService::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;
|
||||
}
|
||||
|
||||
RsPhotoComment& RsPhotoComment::operator=(const RsGxsPhotoCommentItem& comment)
|
||||
{
|
||||
*this = comment.comment;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool p3PhotoService::getPhotoRelatedComment(const uint32_t &token, PhotoRelatedCommentResult &comments)
|
||||
{
|
||||
|
||||
return RsGenExchange::getMsgRelatedDataT<RsGxsPhotoCommentItem, RsPhotoComment>(token, comments);
|
||||
|
||||
}
|
||||
|
||||
bool p3PhotoService::submitAlbumDetails(uint32_t& token, RsPhotoAlbum& album)
|
||||
{
|
||||
RsGxsPhotoAlbumItem* albumItem = new RsGxsPhotoAlbumItem();
|
||||
albumItem->album = album;
|
||||
albumItem->meta = album.mMeta;
|
||||
RsGenExchange::publishGroup(token, albumItem);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void p3PhotoService::notifyChanges(std::vector<RsGxsNotify*>& changes)
|
||||
{
|
||||
|
||||
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 p3PhotoService::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;
|
||||
}
|
||||
|
||||
bool p3PhotoService::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;
|
||||
}
|
||||
|
||||
bool p3PhotoService::acknowledgeMsg(const uint32_t& token,
|
||||
std::pair<RsGxsGroupId, RsGxsMessageId>& msgId)
|
||||
{
|
||||
return RsGenExchange::acknowledgeTokenMsg(token, msgId);
|
||||
}
|
||||
|
||||
|
||||
bool p3PhotoService::acknowledgeGrp(const uint32_t& token,
|
||||
RsGxsGroupId& grpId)
|
||||
{
|
||||
return RsGenExchange::acknowledgeTokenGrp(token, grpId);
|
||||
}
|
||||
|
||||
bool p3PhotoService::subscribeToAlbum(uint32_t &token, const RsGxsGroupId &grpId, bool subscribe)
|
||||
{
|
||||
if(subscribe)
|
||||
RsGenExchange::setGroupSubscribeFlags(token, grpId, GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED, GXS_SERV::GROUP_SUBSCRIBE_MASK);
|
||||
else
|
||||
RsGenExchange::setGroupSubscribeFlags(token, grpId, 0, GXS_SERV::GROUP_SUBSCRIBE_MASK);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,148 +1,148 @@
|
||||
#ifndef P3PHOTOSERVICEV2_H
|
||||
#define P3PHOTOSERVICEV2_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/retroshare: rsphoto.h
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2008-2012 by Robert Fernie, Christopher Evi-Parker
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gxs/rsgenexchange.h"
|
||||
#include "retroshare/rsphotoV2.h"
|
||||
|
||||
class p3PhotoServiceV2 : public RsPhotoV2, public RsGenExchange
|
||||
{
|
||||
public:
|
||||
|
||||
p3PhotoServiceV2(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs,
|
||||
uint32_t authenPolicy);
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
* @return true if a change has occured
|
||||
*/
|
||||
bool updated();
|
||||
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
void service_tick();
|
||||
|
||||
protected:
|
||||
|
||||
void notifyChanges(std::vector<RsGxsNotify*>& changes);
|
||||
public:
|
||||
|
||||
/** Requests **/
|
||||
|
||||
void groupsChanged(std::list<RsGxsGroupId>& grpIds);
|
||||
|
||||
|
||||
void msgsChanged(std::map<RsGxsGroupId,
|
||||
std::vector<RsGxsMessageId> >& msgs);
|
||||
|
||||
RsTokenService* getTokenService();
|
||||
|
||||
bool getGroupList(const uint32_t &token,
|
||||
std::list<RsGxsGroupId> &groupIds);
|
||||
bool getMsgList(const uint32_t &token,
|
||||
GxsMsgIdResult& msgIds);
|
||||
|
||||
/* Generic Summary */
|
||||
bool getGroupSummary(const uint32_t &token,
|
||||
std::list<RsGroupMetaData> &groupInfo);
|
||||
|
||||
bool getMsgSummary(const uint32_t &token,
|
||||
MsgMetaResult &msgInfo);
|
||||
|
||||
/* Specific Service Data */
|
||||
bool getAlbum(const uint32_t &token, std::vector<RsPhotoAlbum> &albums);
|
||||
bool getPhoto(const uint32_t &token, PhotoResult &photos);
|
||||
bool getPhotoComment(const uint32_t &token, PhotoCommentResult &comments);
|
||||
bool getPhotoRelatedComment(const uint32_t &token, PhotoRelatedCommentResult &comments);
|
||||
|
||||
public:
|
||||
|
||||
/** Modifications **/
|
||||
|
||||
/*!
|
||||
* submits album, which returns a token that needs
|
||||
* to be acknowledge to get album grp id
|
||||
* @param token token to redeem for acknowledgement
|
||||
* @param album album to be submitted
|
||||
*/
|
||||
bool submitAlbumDetails(uint32_t& token, RsPhotoAlbum &album);
|
||||
|
||||
/*!
|
||||
* submits photo, which returns a token that needs
|
||||
* to be acknowledge to get photo msg-grp id pair
|
||||
* @param token token to redeem for acknowledgement
|
||||
* @param photo photo to be submitted
|
||||
*/
|
||||
bool submitPhoto(uint32_t& token, RsPhotoPhoto &photo);
|
||||
|
||||
/*!
|
||||
* submits photo comment, which returns a token that needs
|
||||
* to be acknowledged to get photo msg-grp id pair
|
||||
* The mParentId needs to be set to an existing msg for which
|
||||
* commenting is enabled
|
||||
* @param token token to redeem for acknowledgement
|
||||
* @param comment comment to be submitted
|
||||
*/
|
||||
bool submitComment(uint32_t& token, RsPhotoComment &photo);
|
||||
|
||||
/*!
|
||||
* subscribes to group, and returns token which can be used
|
||||
* to be acknowledged to get group Id
|
||||
* @param token token to redeem for acknowledgement
|
||||
* @param grpId the id of the group to subscribe to
|
||||
*/
|
||||
bool subscribeToAlbum(uint32_t& token, const RsGxsGroupId& grpId, bool subscribe);
|
||||
|
||||
/*!
|
||||
* This allows the client service to acknowledge that their msgs has
|
||||
* been created/modified and retrieve the create/modified msg ids
|
||||
* @param token the token related to modification/create request
|
||||
* @param msgIds map of grpid->msgIds of message created/modified
|
||||
* @return true if token exists false otherwise
|
||||
*/
|
||||
bool acknowledgeMsg(const uint32_t& token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId);
|
||||
|
||||
/*!
|
||||
* This allows the client service to acknowledge that their grps has
|
||||
* been created/modified and retrieve the create/modified grp ids
|
||||
* @param token the token related to modification/create request
|
||||
* @param msgIds vector of ids of groups created/modified
|
||||
* @return true if token exists false otherwise
|
||||
*/
|
||||
bool acknowledgeGrp(const uint32_t& token, RsGxsGroupId& grpId);
|
||||
|
||||
private:
|
||||
|
||||
std::vector<RsGxsGroupChange*> mGroupChange;
|
||||
std::vector<RsGxsMsgChange*> mMsgChange;
|
||||
|
||||
RsMutex mPhotoMutex;
|
||||
};
|
||||
|
||||
#endif // P3PHOTOSERVICEV2_H
|
||||
#ifndef P3PHOTOSERVICEV2_H
|
||||
#define P3PHOTOSERVICEV2_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/retroshare: rsphoto.h
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2008-2012 by Robert Fernie, Christopher Evi-Parker
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gxs/rsgenexchange.h"
|
||||
#include "retroshare/rsphoto.h"
|
||||
|
||||
class p3PhotoService : public RsPhoto, public RsGenExchange
|
||||
{
|
||||
public:
|
||||
|
||||
p3PhotoService(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs,
|
||||
uint32_t authenPolicy);
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
* @return true if a change has occured
|
||||
*/
|
||||
bool updated();
|
||||
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
void service_tick();
|
||||
|
||||
protected:
|
||||
|
||||
void notifyChanges(std::vector<RsGxsNotify*>& changes);
|
||||
public:
|
||||
|
||||
/** Requests **/
|
||||
|
||||
void groupsChanged(std::list<RsGxsGroupId>& grpIds);
|
||||
|
||||
|
||||
void msgsChanged(std::map<RsGxsGroupId,
|
||||
std::vector<RsGxsMessageId> >& msgs);
|
||||
|
||||
RsTokenService* getTokenService();
|
||||
|
||||
bool getGroupList(const uint32_t &token,
|
||||
std::list<RsGxsGroupId> &groupIds);
|
||||
bool getMsgList(const uint32_t &token,
|
||||
GxsMsgIdResult& msgIds);
|
||||
|
||||
/* Generic Summary */
|
||||
bool getGroupSummary(const uint32_t &token,
|
||||
std::list<RsGroupMetaData> &groupInfo);
|
||||
|
||||
bool getMsgSummary(const uint32_t &token,
|
||||
MsgMetaResult &msgInfo);
|
||||
|
||||
/* Specific Service Data */
|
||||
bool getAlbum(const uint32_t &token, std::vector<RsPhotoAlbum> &albums);
|
||||
bool getPhoto(const uint32_t &token, PhotoResult &photos);
|
||||
bool getPhotoComment(const uint32_t &token, PhotoCommentResult &comments);
|
||||
bool getPhotoRelatedComment(const uint32_t &token, PhotoRelatedCommentResult &comments);
|
||||
|
||||
public:
|
||||
|
||||
/** Modifications **/
|
||||
|
||||
/*!
|
||||
* submits album, which returns a token that needs
|
||||
* to be acknowledge to get album grp id
|
||||
* @param token token to redeem for acknowledgement
|
||||
* @param album album to be submitted
|
||||
*/
|
||||
bool submitAlbumDetails(uint32_t& token, RsPhotoAlbum &album);
|
||||
|
||||
/*!
|
||||
* submits photo, which returns a token that needs
|
||||
* to be acknowledge to get photo msg-grp id pair
|
||||
* @param token token to redeem for acknowledgement
|
||||
* @param photo photo to be submitted
|
||||
*/
|
||||
bool submitPhoto(uint32_t& token, RsPhotoPhoto &photo);
|
||||
|
||||
/*!
|
||||
* submits photo comment, which returns a token that needs
|
||||
* to be acknowledged to get photo msg-grp id pair
|
||||
* The mParentId needs to be set to an existing msg for which
|
||||
* commenting is enabled
|
||||
* @param token token to redeem for acknowledgement
|
||||
* @param comment comment to be submitted
|
||||
*/
|
||||
bool submitComment(uint32_t& token, RsPhotoComment &photo);
|
||||
|
||||
/*!
|
||||
* subscribes to group, and returns token which can be used
|
||||
* to be acknowledged to get group Id
|
||||
* @param token token to redeem for acknowledgement
|
||||
* @param grpId the id of the group to subscribe to
|
||||
*/
|
||||
bool subscribeToAlbum(uint32_t& token, const RsGxsGroupId& grpId, bool subscribe);
|
||||
|
||||
/*!
|
||||
* This allows the client service to acknowledge that their msgs has
|
||||
* been created/modified and retrieve the create/modified msg ids
|
||||
* @param token the token related to modification/create request
|
||||
* @param msgIds map of grpid->msgIds of message created/modified
|
||||
* @return true if token exists false otherwise
|
||||
*/
|
||||
bool acknowledgeMsg(const uint32_t& token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId);
|
||||
|
||||
/*!
|
||||
* This allows the client service to acknowledge that their grps has
|
||||
* been created/modified and retrieve the create/modified grp ids
|
||||
* @param token the token related to modification/create request
|
||||
* @param msgIds vector of ids of groups created/modified
|
||||
* @return true if token exists false otherwise
|
||||
*/
|
||||
bool acknowledgeGrp(const uint32_t& token, RsGxsGroupId& grpId);
|
||||
|
||||
private:
|
||||
|
||||
std::vector<RsGxsGroupChange*> mGroupChange;
|
||||
std::vector<RsGxsMsgChange*> mMsgChange;
|
||||
|
||||
RsMutex mPhotoMutex;
|
||||
};
|
||||
|
||||
#endif // P3PHOTOSERVICEV2_H
|
@ -1,190 +1,190 @@
|
||||
#include <QBuffer>
|
||||
|
||||
#include "AlbumCreateDialog.h"
|
||||
#include "ui_AlbumCreateDialog.h"
|
||||
|
||||
#include "util/misc.h"
|
||||
#include "gxs/rsgxsflags.h"
|
||||
|
||||
AlbumCreateDialog::AlbumCreateDialog(TokenQueue *photoQueue, RsPhotoV2 *rs_photo, QWidget *parent):
|
||||
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
|
||||
ui(new Ui::AlbumCreateDialog), mPhotoQueue(photoQueue), mRsPhoto(rs_photo), mPhotoSelected(NULL)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->headerFrame->setHeaderImage(QPixmap(":/images/album_create_64.png"));
|
||||
ui->headerFrame->setHeaderText(tr("Create Album"));
|
||||
|
||||
|
||||
#if QT_VERSION >= 0x040700
|
||||
ui->lineEdit_Title_2->setPlaceholderText(tr("Untitle Album"));
|
||||
ui->lineEdit_Caption_2->setPlaceholderText(tr("Say something about this album..."));
|
||||
//ui->textEdit_Description->setPlaceholderText(tr("Say something about this album...")) ;
|
||||
ui->lineEdit_Where->setPlaceholderText(tr("Where were this taken?"));
|
||||
#endif
|
||||
|
||||
ui->backButton->hide();
|
||||
|
||||
connect(ui->publishButton, SIGNAL(clicked()), this, SLOT(publishAlbum()));
|
||||
connect(ui->AlbumThumbNail, SIGNAL(clicked()), this, SLOT(addAlbumThumbnail()));
|
||||
|
||||
connect(ui->addphotosButton, SIGNAL(clicked()),this, SLOT(changePage()));
|
||||
connect(ui->backButton, SIGNAL(clicked()),this, SLOT(backPage()));
|
||||
|
||||
|
||||
mPhotoDrop = ui->scrollAreaWidgetContents;
|
||||
mPhotoDrop->setPhotoItemHolder(this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
AlbumCreateDialog::~AlbumCreateDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
#define PUBLIC_INDEX 0
|
||||
#define RESTRICTED_INDEX 1
|
||||
#define PRIVATE_INDEX 2
|
||||
|
||||
void AlbumCreateDialog::publishAlbum()
|
||||
{
|
||||
// get fields for album to publish, publish and then exit dialog
|
||||
RsPhotoAlbum album;
|
||||
|
||||
album.mCaption = ui->lineEdit_Caption_2->text().toStdString();
|
||||
album.mPhotographer = ui->lineEdit_Photographer->text().toStdString();
|
||||
album.mMeta.mGroupName = ui->lineEdit_Title_2->text().toStdString();
|
||||
album.mDescription = ui->textEdit_Description->toPlainText().toStdString();
|
||||
album.mWhere = ui->lineEdit_Where->text().toStdString();
|
||||
album.mPhotographer = ui->lineEdit_Photographer->text().toStdString();
|
||||
getAlbumThumbnail(album.mThumbnail);
|
||||
|
||||
|
||||
int currIndex = ui->privacyComboBox->currentIndex();
|
||||
|
||||
switch(currIndex)
|
||||
{
|
||||
case PUBLIC_INDEX:
|
||||
album.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_PUBLIC;
|
||||
break;
|
||||
case RESTRICTED_INDEX:
|
||||
album.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_RESTRICTED;
|
||||
break;
|
||||
case PRIVATE_INDEX:
|
||||
album.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_PRIVATE;
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t token;
|
||||
mRsPhoto->submitAlbumDetails(token, album);
|
||||
mPhotoQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
|
||||
|
||||
publishPhotos();
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
void AlbumCreateDialog::publishPhotos()
|
||||
{
|
||||
// get fields for album to publish, publish and then exit dialog
|
||||
RsPhotoAlbum album;
|
||||
|
||||
QSet<PhotoItem*> photos;
|
||||
|
||||
mPhotoDrop->getPhotos(photos);
|
||||
|
||||
QSetIterator<PhotoItem*> sit(photos);
|
||||
|
||||
while(sit.hasNext())
|
||||
{
|
||||
PhotoItem* item = sit.next();
|
||||
uint32_t token;
|
||||
RsPhotoPhoto photo = item->getPhotoDetails();
|
||||
photo.mMeta.mGroupId = album.mMeta.mGroupId;
|
||||
mRsPhoto->submitPhoto(token, photo);
|
||||
mPhotoQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool AlbumCreateDialog::getAlbumThumbnail(RsPhotoThumbnail &nail)
|
||||
{
|
||||
const QPixmap *tmppix = &mThumbNail;
|
||||
|
||||
QByteArray ba;
|
||||
QBuffer buffer(&ba);
|
||||
|
||||
if(!tmppix->isNull())
|
||||
{
|
||||
// send chan image
|
||||
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
tmppix->save(&buffer, "PNG"); // writes image into ba in PNG format
|
||||
|
||||
RsPhotoThumbnail tmpnail;
|
||||
tmpnail.data = (uint8_t *) ba.data();
|
||||
tmpnail.size = ba.size();
|
||||
|
||||
nail.copyFrom(tmpnail);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
nail.data = NULL;
|
||||
nail.size = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
void AlbumCreateDialog::addAlbumThumbnail()
|
||||
{
|
||||
QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load Album Thumbnail"), 128, 128);
|
||||
|
||||
if (img.isNull())
|
||||
return;
|
||||
|
||||
mThumbNail = img;
|
||||
|
||||
// to show the selected
|
||||
ui->AlbumThumbNail->setIcon(mThumbNail);
|
||||
}
|
||||
|
||||
void AlbumCreateDialog::changePage()
|
||||
{
|
||||
int nextPage = ui->stackedWidget->currentIndex() + 1;
|
||||
if (nextPage >= ui->stackedWidget->count())
|
||||
nextPage = 0;
|
||||
ui->stackedWidget->setCurrentIndex(nextPage);
|
||||
|
||||
ui->backButton->show();
|
||||
ui->addphotosButton->hide();
|
||||
}
|
||||
|
||||
void AlbumCreateDialog::backPage()
|
||||
{
|
||||
int nextPage = ui->stackedWidget->currentIndex() - 1;
|
||||
if (nextPage >= ui->stackedWidget->count())
|
||||
nextPage = 0;
|
||||
ui->stackedWidget->setCurrentIndex(nextPage);
|
||||
|
||||
ui->backButton->hide();
|
||||
ui->addphotosButton->show();
|
||||
}
|
||||
|
||||
void AlbumCreateDialog::notifySelection(PhotoShareItem *selection)
|
||||
{
|
||||
|
||||
PhotoItem* pItem = dynamic_cast<PhotoItem*>(selection);
|
||||
|
||||
if(mPhotoSelected == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
mPhotoSelected->setSelected(false);
|
||||
mPhotoSelected = pItem;
|
||||
}
|
||||
|
||||
mPhotoSelected->setSelected(true);
|
||||
}
|
||||
#include <QBuffer>
|
||||
|
||||
#include "AlbumCreateDialog.h"
|
||||
#include "ui_AlbumCreateDialog.h"
|
||||
|
||||
#include "util/misc.h"
|
||||
#include "gxs/rsgxsflags.h"
|
||||
|
||||
AlbumCreateDialog::AlbumCreateDialog(TokenQueue *photoQueue, RsPhoto *rs_photo, QWidget *parent):
|
||||
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
|
||||
ui(new Ui::AlbumCreateDialog), mPhotoQueue(photoQueue), mRsPhoto(rs_photo), mPhotoSelected(NULL)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->headerFrame->setHeaderImage(QPixmap(":/images/album_create_64.png"));
|
||||
ui->headerFrame->setHeaderText(tr("Create Album"));
|
||||
|
||||
|
||||
#if QT_VERSION >= 0x040700
|
||||
ui->lineEdit_Title_2->setPlaceholderText(tr("Untitle Album"));
|
||||
ui->lineEdit_Caption_2->setPlaceholderText(tr("Say something about this album..."));
|
||||
//ui->textEdit_Description->setPlaceholderText(tr("Say something about this album...")) ;
|
||||
ui->lineEdit_Where->setPlaceholderText(tr("Where were this taken?"));
|
||||
#endif
|
||||
|
||||
ui->backButton->hide();
|
||||
|
||||
connect(ui->publishButton, SIGNAL(clicked()), this, SLOT(publishAlbum()));
|
||||
connect(ui->AlbumThumbNail, SIGNAL(clicked()), this, SLOT(addAlbumThumbnail()));
|
||||
|
||||
connect(ui->addphotosButton, SIGNAL(clicked()),this, SLOT(changePage()));
|
||||
connect(ui->backButton, SIGNAL(clicked()),this, SLOT(backPage()));
|
||||
|
||||
|
||||
mPhotoDrop = ui->scrollAreaWidgetContents;
|
||||
mPhotoDrop->setPhotoItemHolder(this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
AlbumCreateDialog::~AlbumCreateDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
#define PUBLIC_INDEX 0
|
||||
#define RESTRICTED_INDEX 1
|
||||
#define PRIVATE_INDEX 2
|
||||
|
||||
void AlbumCreateDialog::publishAlbum()
|
||||
{
|
||||
// get fields for album to publish, publish and then exit dialog
|
||||
RsPhotoAlbum album;
|
||||
|
||||
album.mCaption = ui->lineEdit_Caption_2->text().toStdString();
|
||||
album.mPhotographer = ui->lineEdit_Photographer->text().toStdString();
|
||||
album.mMeta.mGroupName = ui->lineEdit_Title_2->text().toStdString();
|
||||
album.mDescription = ui->textEdit_Description->toPlainText().toStdString();
|
||||
album.mWhere = ui->lineEdit_Where->text().toStdString();
|
||||
album.mPhotographer = ui->lineEdit_Photographer->text().toStdString();
|
||||
getAlbumThumbnail(album.mThumbnail);
|
||||
|
||||
|
||||
int currIndex = ui->privacyComboBox->currentIndex();
|
||||
|
||||
switch(currIndex)
|
||||
{
|
||||
case PUBLIC_INDEX:
|
||||
album.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_PUBLIC;
|
||||
break;
|
||||
case RESTRICTED_INDEX:
|
||||
album.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_RESTRICTED;
|
||||
break;
|
||||
case PRIVATE_INDEX:
|
||||
album.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_PRIVATE;
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t token;
|
||||
mRsPhoto->submitAlbumDetails(token, album);
|
||||
mPhotoQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
|
||||
|
||||
publishPhotos();
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
void AlbumCreateDialog::publishPhotos()
|
||||
{
|
||||
// get fields for album to publish, publish and then exit dialog
|
||||
RsPhotoAlbum album;
|
||||
|
||||
QSet<PhotoItem*> photos;
|
||||
|
||||
mPhotoDrop->getPhotos(photos);
|
||||
|
||||
QSetIterator<PhotoItem*> sit(photos);
|
||||
|
||||
while(sit.hasNext())
|
||||
{
|
||||
PhotoItem* item = sit.next();
|
||||
uint32_t token;
|
||||
RsPhotoPhoto photo = item->getPhotoDetails();
|
||||
photo.mMeta.mGroupId = album.mMeta.mGroupId;
|
||||
mRsPhoto->submitPhoto(token, photo);
|
||||
mPhotoQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool AlbumCreateDialog::getAlbumThumbnail(RsPhotoThumbnail &nail)
|
||||
{
|
||||
const QPixmap *tmppix = &mThumbNail;
|
||||
|
||||
QByteArray ba;
|
||||
QBuffer buffer(&ba);
|
||||
|
||||
if(!tmppix->isNull())
|
||||
{
|
||||
// send chan image
|
||||
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
tmppix->save(&buffer, "PNG"); // writes image into ba in PNG format
|
||||
|
||||
RsPhotoThumbnail tmpnail;
|
||||
tmpnail.data = (uint8_t *) ba.data();
|
||||
tmpnail.size = ba.size();
|
||||
|
||||
nail.copyFrom(tmpnail);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
nail.data = NULL;
|
||||
nail.size = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
void AlbumCreateDialog::addAlbumThumbnail()
|
||||
{
|
||||
QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load Album Thumbnail"), 128, 128);
|
||||
|
||||
if (img.isNull())
|
||||
return;
|
||||
|
||||
mThumbNail = img;
|
||||
|
||||
// to show the selected
|
||||
ui->AlbumThumbNail->setIcon(mThumbNail);
|
||||
}
|
||||
|
||||
void AlbumCreateDialog::changePage()
|
||||
{
|
||||
int nextPage = ui->stackedWidget->currentIndex() + 1;
|
||||
if (nextPage >= ui->stackedWidget->count())
|
||||
nextPage = 0;
|
||||
ui->stackedWidget->setCurrentIndex(nextPage);
|
||||
|
||||
ui->backButton->show();
|
||||
ui->addphotosButton->hide();
|
||||
}
|
||||
|
||||
void AlbumCreateDialog::backPage()
|
||||
{
|
||||
int nextPage = ui->stackedWidget->currentIndex() - 1;
|
||||
if (nextPage >= ui->stackedWidget->count())
|
||||
nextPage = 0;
|
||||
ui->stackedWidget->setCurrentIndex(nextPage);
|
||||
|
||||
ui->backButton->hide();
|
||||
ui->addphotosButton->show();
|
||||
}
|
||||
|
||||
void AlbumCreateDialog::notifySelection(PhotoShareItem *selection)
|
||||
{
|
||||
|
||||
PhotoItem* pItem = dynamic_cast<PhotoItem*>(selection);
|
||||
|
||||
if(mPhotoSelected == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
mPhotoSelected->setSelected(false);
|
||||
mPhotoSelected = pItem;
|
||||
}
|
||||
|
||||
mPhotoSelected->setSelected(true);
|
||||
}
|
||||
|
@ -1,50 +1,51 @@
|
||||
#ifndef ALBUMCREATEDIALOG_H
|
||||
#define ALBUMCREATEDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "util/TokenQueue.h"
|
||||
#include "retroshare/rsphotoV2.h"
|
||||
#include "PhotoShareItemHolder.h"
|
||||
#include "PhotoItem.h"
|
||||
#include "PhotoDrop.h"
|
||||
|
||||
namespace Ui {
|
||||
class AlbumCreateDialog;
|
||||
}
|
||||
|
||||
|
||||
class AlbumCreateDialog : public QDialog, public PhotoShareItemHolder
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AlbumCreateDialog(TokenQueue* photoQueue, RsPhotoV2* rs_photo, QWidget *parent = 0);
|
||||
~AlbumCreateDialog();
|
||||
|
||||
void notifySelection(PhotoShareItem* selection);
|
||||
|
||||
|
||||
private slots:
|
||||
void publishAlbum();
|
||||
void publishPhotos();
|
||||
void addAlbumThumbnail();
|
||||
void changePage();
|
||||
void backPage();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
bool getAlbumThumbnail(RsPhotoThumbnail &nail);
|
||||
private:
|
||||
Ui::AlbumCreateDialog *ui;
|
||||
|
||||
TokenQueue* mPhotoQueue;
|
||||
RsPhotoV2* mRsPhoto;
|
||||
QPixmap mThumbNail;
|
||||
PhotoDrop* mPhotoDrop;
|
||||
PhotoItem* mPhotoSelected;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // ALBUMCREATEDIALOG_H
|
||||
#ifndef ALBUMCREATEDIALOG_H
|
||||
#define ALBUMCREATEDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "util/TokenQueue.h"
|
||||
#include "retroshare/rsphoto.h"
|
||||
#include "retroshare/rsphoto.h"
|
||||
#include "PhotoShareItemHolder.h"
|
||||
#include "PhotoItem.h"
|
||||
#include "PhotoDrop.h"
|
||||
|
||||
namespace Ui {
|
||||
class AlbumCreateDialog;
|
||||
}
|
||||
|
||||
|
||||
class AlbumCreateDialog : public QDialog, public PhotoShareItemHolder
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AlbumCreateDialog(TokenQueue* photoQueue, RsPhoto* rs_photo, QWidget *parent = 0);
|
||||
~AlbumCreateDialog();
|
||||
|
||||
void notifySelection(PhotoShareItem* selection);
|
||||
|
||||
|
||||
private slots:
|
||||
void publishAlbum();
|
||||
void publishPhotos();
|
||||
void addAlbumThumbnail();
|
||||
void changePage();
|
||||
void backPage();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
bool getAlbumThumbnail(RsPhotoThumbnail &nail);
|
||||
private:
|
||||
Ui::AlbumCreateDialog *ui;
|
||||
|
||||
TokenQueue* mPhotoQueue;
|
||||
RsPhoto* mRsPhoto;
|
||||
QPixmap mThumbNail;
|
||||
PhotoDrop* mPhotoDrop;
|
||||
PhotoItem* mPhotoSelected;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // ALBUMCREATEDIALOG_H
|
||||
|
@ -1,112 +1,112 @@
|
||||
#include <QPixmap>
|
||||
|
||||
#include "AlbumDialog.h"
|
||||
#include "ui_AlbumDialog.h"
|
||||
#include "gxs/rsgxsflags.h"
|
||||
|
||||
AlbumDialog::AlbumDialog(const RsPhotoAlbum& album, TokenQueue* photoQueue, RsPhotoV2* rs_Photo, QWidget *parent) :
|
||||
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
|
||||
ui(new Ui::AlbumDialog), mRsPhoto(rs_Photo), mPhotoQueue(photoQueue), mAlbum(album), mPhotoSelected(NULL)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->headerFrame->setHeaderImage(QPixmap(":/images/kview_64.png"));
|
||||
ui->headerFrame->setHeaderText(tr("Album"));
|
||||
|
||||
connect(ui->pushButton_PublishPhotos, SIGNAL(clicked()), this, SLOT(updateAlbumPhotos()));
|
||||
connect(ui->pushButton_DeletePhoto, SIGNAL(clicked()), this, SLOT(deletePhoto()));
|
||||
|
||||
mPhotoDrop = ui->scrollAreaWidgetContents;
|
||||
|
||||
if(!(mAlbum.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN))
|
||||
{
|
||||
ui->scrollAreaPhotos->setEnabled(false);
|
||||
ui->pushButton_DeletePhoto->setEnabled(false);
|
||||
}
|
||||
mPhotoDrop->setPhotoItemHolder(this);
|
||||
|
||||
setUp();
|
||||
}
|
||||
|
||||
|
||||
void AlbumDialog::setUp()
|
||||
{
|
||||
ui->lineEdit_Title->setText(QString::fromStdString(mAlbum.mMeta.mGroupName));
|
||||
ui->lineEdit_Caption->setText(QString::fromStdString(mAlbum.mCaption));
|
||||
ui->lineEdit_Category->setText(QString::fromStdString(mAlbum.mCategory));
|
||||
ui->lineEdit_Identity->setText(QString::fromStdString(mAlbum.mMeta.mAuthorId));
|
||||
ui->lineEdit_Where->setText(QString::fromStdString(mAlbum.mWhere));
|
||||
ui->textEdit_description->setText(QString::fromStdString(mAlbum.mDescription));
|
||||
|
||||
|
||||
QPixmap qtn;
|
||||
qtn.loadFromData(mAlbum.mThumbnail.data, mAlbum.mThumbnail.size, mAlbum.mThumbnail.type.c_str());
|
||||
|
||||
if(mAlbum.mThumbnail.size != 0)
|
||||
{
|
||||
ui->label_thumbNail->setPixmap(qtn);
|
||||
}
|
||||
else
|
||||
{
|
||||
// display a default Album icon when album has no Thumbnail
|
||||
ui->label_thumbNail->setPixmap(QPixmap(":/images/album_default_128.png"));
|
||||
}
|
||||
}
|
||||
|
||||
void AlbumDialog::updateAlbumPhotos(){
|
||||
|
||||
QSet<PhotoItem*> photos;
|
||||
|
||||
mPhotoDrop->getPhotos(photos);
|
||||
|
||||
QSetIterator<PhotoItem*> sit(photos);
|
||||
|
||||
while(sit.hasNext())
|
||||
{
|
||||
PhotoItem* item = sit.next();
|
||||
uint32_t token;
|
||||
RsPhotoPhoto photo = item->getPhotoDetails();
|
||||
photo.mMeta.mGroupId = mAlbum.mMeta.mGroupId;
|
||||
mRsPhoto->submitPhoto(token, photo);
|
||||
mPhotoQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
void AlbumDialog::deletePhoto(){
|
||||
|
||||
if(mPhotoSelected)
|
||||
{
|
||||
mPhotoSelected->setSelected(false);
|
||||
mPhotoDrop->deletePhoto(mPhotoSelected);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AlbumDialog::editPhoto()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AlbumDialog::~AlbumDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void AlbumDialog::notifySelection(PhotoShareItem *selection)
|
||||
{
|
||||
|
||||
PhotoItem* pItem = dynamic_cast<PhotoItem*>(selection);
|
||||
|
||||
if(mPhotoSelected == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
mPhotoSelected->setSelected(false);
|
||||
mPhotoSelected = pItem;
|
||||
}
|
||||
|
||||
mPhotoSelected->setSelected(true);
|
||||
}
|
||||
#include <QPixmap>
|
||||
|
||||
#include "AlbumDialog.h"
|
||||
#include "ui_AlbumDialog.h"
|
||||
#include "gxs/rsgxsflags.h"
|
||||
|
||||
AlbumDialog::AlbumDialog(const RsPhotoAlbum& album, TokenQueue* photoQueue, RsPhoto* rs_Photo, QWidget *parent) :
|
||||
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
|
||||
ui(new Ui::AlbumDialog), mRsPhoto(rs_Photo), mPhotoQueue(photoQueue), mAlbum(album), mPhotoSelected(NULL)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->headerFrame->setHeaderImage(QPixmap(":/images/kview_64.png"));
|
||||
ui->headerFrame->setHeaderText(tr("Album"));
|
||||
|
||||
connect(ui->pushButton_PublishPhotos, SIGNAL(clicked()), this, SLOT(updateAlbumPhotos()));
|
||||
connect(ui->pushButton_DeletePhoto, SIGNAL(clicked()), this, SLOT(deletePhoto()));
|
||||
|
||||
mPhotoDrop = ui->scrollAreaWidgetContents;
|
||||
|
||||
if(!(mAlbum.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN))
|
||||
{
|
||||
ui->scrollAreaPhotos->setEnabled(false);
|
||||
ui->pushButton_DeletePhoto->setEnabled(false);
|
||||
}
|
||||
mPhotoDrop->setPhotoItemHolder(this);
|
||||
|
||||
setUp();
|
||||
}
|
||||
|
||||
|
||||
void AlbumDialog::setUp()
|
||||
{
|
||||
ui->lineEdit_Title->setText(QString::fromStdString(mAlbum.mMeta.mGroupName));
|
||||
ui->lineEdit_Caption->setText(QString::fromStdString(mAlbum.mCaption));
|
||||
ui->lineEdit_Category->setText(QString::fromStdString(mAlbum.mCategory));
|
||||
ui->lineEdit_Identity->setText(QString::fromStdString(mAlbum.mMeta.mAuthorId));
|
||||
ui->lineEdit_Where->setText(QString::fromStdString(mAlbum.mWhere));
|
||||
ui->textEdit_description->setText(QString::fromStdString(mAlbum.mDescription));
|
||||
|
||||
|
||||
QPixmap qtn;
|
||||
qtn.loadFromData(mAlbum.mThumbnail.data, mAlbum.mThumbnail.size, mAlbum.mThumbnail.type.c_str());
|
||||
|
||||
if(mAlbum.mThumbnail.size != 0)
|
||||
{
|
||||
ui->label_thumbNail->setPixmap(qtn);
|
||||
}
|
||||
else
|
||||
{
|
||||
// display a default Album icon when album has no Thumbnail
|
||||
ui->label_thumbNail->setPixmap(QPixmap(":/images/album_default_128.png"));
|
||||
}
|
||||
}
|
||||
|
||||
void AlbumDialog::updateAlbumPhotos(){
|
||||
|
||||
QSet<PhotoItem*> photos;
|
||||
|
||||
mPhotoDrop->getPhotos(photos);
|
||||
|
||||
QSetIterator<PhotoItem*> sit(photos);
|
||||
|
||||
while(sit.hasNext())
|
||||
{
|
||||
PhotoItem* item = sit.next();
|
||||
uint32_t token;
|
||||
RsPhotoPhoto photo = item->getPhotoDetails();
|
||||
photo.mMeta.mGroupId = mAlbum.mMeta.mGroupId;
|
||||
mRsPhoto->submitPhoto(token, photo);
|
||||
mPhotoQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
void AlbumDialog::deletePhoto(){
|
||||
|
||||
if(mPhotoSelected)
|
||||
{
|
||||
mPhotoSelected->setSelected(false);
|
||||
mPhotoDrop->deletePhoto(mPhotoSelected);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AlbumDialog::editPhoto()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AlbumDialog::~AlbumDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void AlbumDialog::notifySelection(PhotoShareItem *selection)
|
||||
{
|
||||
|
||||
PhotoItem* pItem = dynamic_cast<PhotoItem*>(selection);
|
||||
|
||||
if(mPhotoSelected == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
mPhotoSelected->setSelected(false);
|
||||
mPhotoSelected = pItem;
|
||||
}
|
||||
|
||||
mPhotoSelected->setSelected(true);
|
||||
}
|
||||
|
@ -1,43 +1,43 @@
|
||||
#ifndef ALBUMDIALOG_H
|
||||
#define ALBUMDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "retroshare/rsphotoV2.h"
|
||||
#include "util/TokenQueue.h"
|
||||
#include "PhotoShareItemHolder.h"
|
||||
#include "PhotoItem.h"
|
||||
#include "PhotoDrop.h"
|
||||
|
||||
namespace Ui {
|
||||
class AlbumDialog;
|
||||
}
|
||||
|
||||
class AlbumDialog : public QDialog, public PhotoShareItemHolder
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AlbumDialog(const RsPhotoAlbum& album, TokenQueue* photoQueue, RsPhotoV2* rs_Photo, QWidget *parent = 0);
|
||||
~AlbumDialog();
|
||||
|
||||
void notifySelection(PhotoShareItem* selection);
|
||||
|
||||
private:
|
||||
|
||||
void setUp();
|
||||
|
||||
private slots:
|
||||
|
||||
void updateAlbumPhotos();
|
||||
void deletePhoto();
|
||||
void editPhoto();
|
||||
private:
|
||||
Ui::AlbumDialog *ui;
|
||||
RsPhotoV2* mRsPhoto;
|
||||
TokenQueue* mPhotoQueue;
|
||||
RsPhotoAlbum mAlbum;
|
||||
PhotoDrop* mPhotoDrop;
|
||||
PhotoItem* mPhotoSelected;
|
||||
};
|
||||
|
||||
#endif // ALBUMDIALOG_H
|
||||
#ifndef ALBUMDIALOG_H
|
||||
#define ALBUMDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "retroshare/rsphoto.h"
|
||||
#include "util/TokenQueue.h"
|
||||
#include "PhotoShareItemHolder.h"
|
||||
#include "PhotoItem.h"
|
||||
#include "PhotoDrop.h"
|
||||
|
||||
namespace Ui {
|
||||
class AlbumDialog;
|
||||
}
|
||||
|
||||
class AlbumDialog : public QDialog, public PhotoShareItemHolder
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AlbumDialog(const RsPhotoAlbum& album, TokenQueue* photoQueue, RsPhoto* rs_Photo, QWidget *parent = 0);
|
||||
~AlbumDialog();
|
||||
|
||||
void notifySelection(PhotoShareItem* selection);
|
||||
|
||||
private:
|
||||
|
||||
void setUp();
|
||||
|
||||
private slots:
|
||||
|
||||
void updateAlbumPhotos();
|
||||
void deletePhoto();
|
||||
void editPhoto();
|
||||
private:
|
||||
Ui::AlbumDialog *ui;
|
||||
RsPhoto* mRsPhoto;
|
||||
TokenQueue* mPhotoQueue;
|
||||
RsPhotoAlbum mAlbum;
|
||||
PhotoDrop* mPhotoDrop;
|
||||
PhotoItem* mPhotoSelected;
|
||||
};
|
||||
|
||||
#endif // ALBUMDIALOG_H
|
||||
|
@ -1,38 +1,38 @@
|
||||
#ifndef ALBUMITEM_H
|
||||
#define ALBUMITEM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "string.h"
|
||||
#include "retroshare/rsphotoV2.h"
|
||||
#include "PhotoShareItemHolder.h"
|
||||
|
||||
namespace Ui {
|
||||
class AlbumItem;
|
||||
}
|
||||
|
||||
class AlbumItem : public QWidget, public PhotoShareItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AlbumItem(const RsPhotoAlbum& album, PhotoShareItemHolder* albumHolder, QWidget *parent = 0);
|
||||
virtual ~AlbumItem();
|
||||
|
||||
const RsPhotoAlbum& getAlbum();
|
||||
|
||||
bool isSelected() { return mSelected ;}
|
||||
void setSelected(bool selected);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
private:
|
||||
void setUp();
|
||||
private:
|
||||
Ui::AlbumItem *ui;
|
||||
RsPhotoAlbum mAlbum;
|
||||
PhotoShareItemHolder* mAlbumHolder;
|
||||
bool mSelected;
|
||||
};
|
||||
|
||||
#endif // ALBUMITEM_H
|
||||
#ifndef ALBUMITEM_H
|
||||
#define ALBUMITEM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "string.h"
|
||||
#include "retroshare/rsphoto.h"
|
||||
#include "PhotoShareItemHolder.h"
|
||||
|
||||
namespace Ui {
|
||||
class AlbumItem;
|
||||
}
|
||||
|
||||
class AlbumItem : public QWidget, public PhotoShareItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AlbumItem(const RsPhotoAlbum& album, PhotoShareItemHolder* albumHolder, QWidget *parent = 0);
|
||||
virtual ~AlbumItem();
|
||||
|
||||
const RsPhotoAlbum& getAlbum();
|
||||
|
||||
bool isSelected() { return mSelected ;}
|
||||
void setSelected(bool selected);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
private:
|
||||
void setUp();
|
||||
private:
|
||||
Ui::AlbumItem *ui;
|
||||
RsPhotoAlbum mAlbum;
|
||||
PhotoShareItemHolder* mAlbumHolder;
|
||||
bool mSelected;
|
||||
};
|
||||
|
||||
#endif // ALBUMITEM_H
|
||||
|
@ -1,29 +1,29 @@
|
||||
#ifndef PHOTOCOMMENTITEM_H
|
||||
#define PHOTOCOMMENTITEM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "retroshare/rsphotoV2.h"
|
||||
|
||||
namespace Ui {
|
||||
class PhotoCommentItem;
|
||||
}
|
||||
|
||||
class PhotoCommentItem : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PhotoCommentItem(const RsPhotoComment& comment, QWidget *parent = 0);
|
||||
~PhotoCommentItem();
|
||||
|
||||
const RsPhotoComment& getComment();
|
||||
|
||||
private:
|
||||
|
||||
void setUp();
|
||||
private:
|
||||
Ui::PhotoCommentItem *ui;
|
||||
RsPhotoComment mComment;
|
||||
};
|
||||
|
||||
#endif // PHOTOCOMMENTITEM_H
|
||||
#ifndef PHOTOCOMMENTITEM_H
|
||||
#define PHOTOCOMMENTITEM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "retroshare/rsphoto.h"
|
||||
|
||||
namespace Ui {
|
||||
class PhotoCommentItem;
|
||||
}
|
||||
|
||||
class PhotoCommentItem : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PhotoCommentItem(const RsPhotoComment& comment, QWidget *parent = 0);
|
||||
~PhotoCommentItem();
|
||||
|
||||
const RsPhotoComment& getComment();
|
||||
|
||||
private:
|
||||
|
||||
void setUp();
|
||||
private:
|
||||
Ui::PhotoCommentItem *ui;
|
||||
RsPhotoComment mComment;
|
||||
};
|
||||
|
||||
#endif // PHOTOCOMMENTITEM_H
|
||||
|
@ -1,237 +1,237 @@
|
||||
#include <iostream>
|
||||
#include <QVBoxLayout>
|
||||
#include "PhotoDialog.h"
|
||||
#include "ui_PhotoDialog.h"
|
||||
#include "retroshare/rsidentity.h"
|
||||
#include "AddCommentDialog.h"
|
||||
|
||||
PhotoDialog::PhotoDialog(RsPhotoV2 *rs_photo, const RsPhotoPhoto &photo, QWidget *parent) :
|
||||
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
|
||||
ui(new Ui::PhotoDialog), mRsPhoto(rs_photo), mPhotoQueue(new TokenQueue(mRsPhoto->getTokenService(), this)),
|
||||
mPhotoDetails(photo)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||
|
||||
connect(ui->pushButton_AddComment, SIGNAL(clicked()), this, SLOT(createComment()));
|
||||
connect(ui->pushButton_AddCommentDlg, SIGNAL(clicked()), this, SLOT(addComment()));
|
||||
connect(ui->fullscreenButton, SIGNAL(clicked()),this, SLOT(setFullScreen()));
|
||||
|
||||
#if QT_VERSION >= 0x040700
|
||||
ui->lineEdit->setPlaceholderText(tr("Write a comment...")) ;
|
||||
#endif
|
||||
|
||||
setUp();
|
||||
}
|
||||
|
||||
PhotoDialog::~PhotoDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete mPhotoQueue;
|
||||
}
|
||||
|
||||
void PhotoDialog::setUp()
|
||||
{
|
||||
QPixmap qtn;
|
||||
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));
|
||||
|
||||
requestComments();
|
||||
}
|
||||
|
||||
void PhotoDialog::addComment()
|
||||
{
|
||||
AddCommentDialog dlg(this);
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
RsPhotoComment comment;
|
||||
comment.mComment = dlg.getComment().toUtf8().constData();
|
||||
|
||||
uint32_t token;
|
||||
comment.mMeta.mGroupId = mPhotoDetails.mMeta.mGroupId;
|
||||
comment.mMeta.mParentId = mPhotoDetails.mMeta.mOrigMsgId;
|
||||
mRsPhoto->submitComment(token, comment);
|
||||
mPhotoQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void PhotoDialog::clearComments()
|
||||
{
|
||||
//QLayout* l = ui->scrollAreaWidgetContents->layout();
|
||||
QSetIterator<PhotoCommentItem*> sit(mComments);
|
||||
while(sit.hasNext())
|
||||
{
|
||||
PhotoCommentItem* item = sit.next();
|
||||
ui->verticalLayout->removeWidget(item);
|
||||
item->setParent(NULL);
|
||||
delete item;
|
||||
}
|
||||
|
||||
mComments.clear();
|
||||
}
|
||||
|
||||
void PhotoDialog::resetComments()
|
||||
{
|
||||
QSetIterator<PhotoCommentItem*> sit(mComments);
|
||||
//QLayout* l = ui->scrollAreaWidgetContents->layout();
|
||||
while(sit.hasNext())
|
||||
{
|
||||
PhotoCommentItem* item = sit.next();
|
||||
ui->verticalLayout->insertWidget(0,item);
|
||||
}
|
||||
}
|
||||
|
||||
void PhotoDialog::requestComments()
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
opts.mMsgFlagMask = RsPhotoV2::FLAG_MSG_TYPE_MASK;
|
||||
opts.mMsgFlagFilter = RsPhotoV2::FLAG_MSG_TYPE_PHOTO_COMMENT;
|
||||
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_IDS;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
|
||||
opts.mOptions = RS_TOKREQOPT_MSG_PARENT | RS_TOKREQOPT_MSG_LATEST;
|
||||
RsGxsGrpMsgIdPair msgId;
|
||||
uint32_t token;
|
||||
msgId.first = mPhotoDetails.mMeta.mGroupId;
|
||||
msgId.second = mPhotoDetails.mMeta.mMsgId;
|
||||
std::vector<RsGxsGrpMsgIdPair> msgIdV;
|
||||
msgIdV.push_back(msgId);
|
||||
mPhotoQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIdV, 0);
|
||||
}
|
||||
|
||||
void PhotoDialog::createComment()
|
||||
{
|
||||
RsPhotoComment comment;
|
||||
QString commentString = ui->lineEdit->text();
|
||||
|
||||
comment.mComment = commentString.toUtf8().constData();
|
||||
|
||||
uint32_t token;
|
||||
comment.mMeta.mGroupId = mPhotoDetails.mMeta.mGroupId;
|
||||
comment.mMeta.mParentId = mPhotoDetails.mMeta.mOrigMsgId;
|
||||
mRsPhoto->submitComment(token, comment);
|
||||
mPhotoQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
|
||||
|
||||
ui->lineEdit->clear();
|
||||
}
|
||||
|
||||
|
||||
/*************** message loading **********************/
|
||||
|
||||
void PhotoDialog::loadRequest(const TokenQueue *queue, const TokenRequest &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_LIST:
|
||||
loadList(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)
|
||||
{
|
||||
|
||||
clearComments();
|
||||
|
||||
PhotoRelatedCommentResult results;
|
||||
mRsPhoto->getPhotoRelatedComment(token, results);
|
||||
|
||||
PhotoRelatedCommentResult::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::loadList(uint32_t token)
|
||||
{
|
||||
GxsMsgReq msgIds;
|
||||
mRsPhoto->getMsgList(token, msgIds);
|
||||
RsTokReqOptions opts;
|
||||
|
||||
// just use data as no need to worry about getting comments
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
uint32_t reqToken;
|
||||
mPhotoQueue->requestMsgInfo(reqToken, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, 0);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
requestComments();
|
||||
}
|
||||
}
|
||||
|
||||
void PhotoDialog::setFullScreen()
|
||||
{
|
||||
if (!isFullScreen()) {
|
||||
// hide menu & toolbars
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
show();
|
||||
raise();
|
||||
setWindowState( windowState() | Qt::WindowFullScreen );
|
||||
#else
|
||||
setWindowState( windowState() | Qt::WindowFullScreen );
|
||||
show();
|
||||
raise();
|
||||
#endif
|
||||
} else {
|
||||
|
||||
setWindowState( windowState() ^ Qt::WindowFullScreen );
|
||||
show();
|
||||
}
|
||||
}
|
||||
#include <iostream>
|
||||
#include <QVBoxLayout>
|
||||
#include "PhotoDialog.h"
|
||||
#include "ui_PhotoDialog.h"
|
||||
#include "retroshare/rsidentity.h"
|
||||
#include "AddCommentDialog.h"
|
||||
|
||||
PhotoDialog::PhotoDialog(RsPhoto *rs_photo, const RsPhotoPhoto &photo, QWidget *parent) :
|
||||
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
|
||||
ui(new Ui::PhotoDialog), mRsPhoto(rs_photo), mPhotoQueue(new TokenQueue(mRsPhoto->getTokenService(), this)),
|
||||
mPhotoDetails(photo)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||
|
||||
connect(ui->pushButton_AddComment, SIGNAL(clicked()), this, SLOT(createComment()));
|
||||
connect(ui->pushButton_AddCommentDlg, SIGNAL(clicked()), this, SLOT(addComment()));
|
||||
connect(ui->fullscreenButton, SIGNAL(clicked()),this, SLOT(setFullScreen()));
|
||||
|
||||
#if QT_VERSION >= 0x040700
|
||||
ui->lineEdit->setPlaceholderText(tr("Write a comment...")) ;
|
||||
#endif
|
||||
|
||||
setUp();
|
||||
}
|
||||
|
||||
PhotoDialog::~PhotoDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete mPhotoQueue;
|
||||
}
|
||||
|
||||
void PhotoDialog::setUp()
|
||||
{
|
||||
QPixmap qtn;
|
||||
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));
|
||||
|
||||
requestComments();
|
||||
}
|
||||
|
||||
void PhotoDialog::addComment()
|
||||
{
|
||||
AddCommentDialog dlg(this);
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
RsPhotoComment comment;
|
||||
comment.mComment = dlg.getComment().toUtf8().constData();
|
||||
|
||||
uint32_t token;
|
||||
comment.mMeta.mGroupId = mPhotoDetails.mMeta.mGroupId;
|
||||
comment.mMeta.mParentId = mPhotoDetails.mMeta.mOrigMsgId;
|
||||
mRsPhoto->submitComment(token, comment);
|
||||
mPhotoQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void PhotoDialog::clearComments()
|
||||
{
|
||||
//QLayout* l = ui->scrollAreaWidgetContents->layout();
|
||||
QSetIterator<PhotoCommentItem*> sit(mComments);
|
||||
while(sit.hasNext())
|
||||
{
|
||||
PhotoCommentItem* item = sit.next();
|
||||
ui->verticalLayout->removeWidget(item);
|
||||
item->setParent(NULL);
|
||||
delete item;
|
||||
}
|
||||
|
||||
mComments.clear();
|
||||
}
|
||||
|
||||
void PhotoDialog::resetComments()
|
||||
{
|
||||
QSetIterator<PhotoCommentItem*> sit(mComments);
|
||||
//QLayout* l = ui->scrollAreaWidgetContents->layout();
|
||||
while(sit.hasNext())
|
||||
{
|
||||
PhotoCommentItem* item = sit.next();
|
||||
ui->verticalLayout->insertWidget(0,item);
|
||||
}
|
||||
}
|
||||
|
||||
void PhotoDialog::requestComments()
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
opts.mMsgFlagMask = RsPhoto::FLAG_MSG_TYPE_MASK;
|
||||
opts.mMsgFlagFilter = RsPhoto::FLAG_MSG_TYPE_PHOTO_COMMENT;
|
||||
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_IDS;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
|
||||
opts.mOptions = RS_TOKREQOPT_MSG_PARENT | RS_TOKREQOPT_MSG_LATEST;
|
||||
RsGxsGrpMsgIdPair msgId;
|
||||
uint32_t token;
|
||||
msgId.first = mPhotoDetails.mMeta.mGroupId;
|
||||
msgId.second = mPhotoDetails.mMeta.mMsgId;
|
||||
std::vector<RsGxsGrpMsgIdPair> msgIdV;
|
||||
msgIdV.push_back(msgId);
|
||||
mPhotoQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIdV, 0);
|
||||
}
|
||||
|
||||
void PhotoDialog::createComment()
|
||||
{
|
||||
RsPhotoComment comment;
|
||||
QString commentString = ui->lineEdit->text();
|
||||
|
||||
comment.mComment = commentString.toUtf8().constData();
|
||||
|
||||
uint32_t token;
|
||||
comment.mMeta.mGroupId = mPhotoDetails.mMeta.mGroupId;
|
||||
comment.mMeta.mParentId = mPhotoDetails.mMeta.mOrigMsgId;
|
||||
mRsPhoto->submitComment(token, comment);
|
||||
mPhotoQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
|
||||
|
||||
ui->lineEdit->clear();
|
||||
}
|
||||
|
||||
|
||||
/*************** message loading **********************/
|
||||
|
||||
void PhotoDialog::loadRequest(const TokenQueue *queue, const TokenRequest &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_LIST:
|
||||
loadList(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)
|
||||
{
|
||||
|
||||
clearComments();
|
||||
|
||||
PhotoRelatedCommentResult results;
|
||||
mRsPhoto->getPhotoRelatedComment(token, results);
|
||||
|
||||
PhotoRelatedCommentResult::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::loadList(uint32_t token)
|
||||
{
|
||||
GxsMsgReq msgIds;
|
||||
mRsPhoto->getMsgList(token, msgIds);
|
||||
RsTokReqOptions opts;
|
||||
|
||||
// just use data as no need to worry about getting comments
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
uint32_t reqToken;
|
||||
mPhotoQueue->requestMsgInfo(reqToken, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, 0);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
requestComments();
|
||||
}
|
||||
}
|
||||
|
||||
void PhotoDialog::setFullScreen()
|
||||
{
|
||||
if (!isFullScreen()) {
|
||||
// hide menu & toolbars
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
show();
|
||||
raise();
|
||||
setWindowState( windowState() | Qt::WindowFullScreen );
|
||||
#else
|
||||
setWindowState( windowState() | Qt::WindowFullScreen );
|
||||
show();
|
||||
raise();
|
||||
#endif
|
||||
} else {
|
||||
|
||||
setWindowState( windowState() ^ Qt::WindowFullScreen );
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
@ -1,62 +1,62 @@
|
||||
#ifndef PHOTODIALOG_H
|
||||
#define PHOTODIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QSet>
|
||||
#include "retroshare/rsphotoV2.h"
|
||||
#include "util/TokenQueue.h"
|
||||
#include "PhotoCommentItem.h"
|
||||
|
||||
namespace Ui {
|
||||
class PhotoDialog;
|
||||
}
|
||||
|
||||
class PhotoDialog : public QDialog, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PhotoDialog(RsPhotoV2* rs_photo, const RsPhotoPhoto& photo, QWidget *parent = 0);
|
||||
~PhotoDialog();
|
||||
|
||||
private slots:
|
||||
|
||||
void addComment();
|
||||
void createComment();
|
||||
void setFullScreen();
|
||||
|
||||
public:
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
private:
|
||||
void setUp();
|
||||
|
||||
/*!
|
||||
* clears comments
|
||||
* and places them back in dialog
|
||||
*/
|
||||
void resetComments();
|
||||
|
||||
/*!
|
||||
* Request comments
|
||||
*/
|
||||
void requestComments();
|
||||
|
||||
/*!
|
||||
* Simply removes comments but doesn't place them back in dialog
|
||||
*/
|
||||
void clearComments();
|
||||
|
||||
void acknowledgeComment(uint32_t token);
|
||||
void loadComment(uint32_t token);
|
||||
void loadList(uint32_t token);
|
||||
void addComment(const RsPhotoComment& comment);
|
||||
private:
|
||||
Ui::PhotoDialog *ui;
|
||||
|
||||
RsPhotoV2* mRsPhoto;
|
||||
TokenQueue* mPhotoQueue;
|
||||
RsPhotoPhoto mPhotoDetails;
|
||||
QSet<PhotoCommentItem*> mComments;
|
||||
};
|
||||
|
||||
#endif // PHOTODIALOG_H
|
||||
#ifndef PHOTODIALOG_H
|
||||
#define PHOTODIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QSet>
|
||||
#include "retroshare/rsphoto.h"
|
||||
#include "util/TokenQueue.h"
|
||||
#include "PhotoCommentItem.h"
|
||||
|
||||
namespace Ui {
|
||||
class PhotoDialog;
|
||||
}
|
||||
|
||||
class PhotoDialog : public QDialog, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PhotoDialog(RsPhoto* rs_photo, const RsPhotoPhoto& photo, QWidget *parent = 0);
|
||||
~PhotoDialog();
|
||||
|
||||
private slots:
|
||||
|
||||
void addComment();
|
||||
void createComment();
|
||||
void setFullScreen();
|
||||
|
||||
public:
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
private:
|
||||
void setUp();
|
||||
|
||||
/*!
|
||||
* clears comments
|
||||
* and places them back in dialog
|
||||
*/
|
||||
void resetComments();
|
||||
|
||||
/*!
|
||||
* Request comments
|
||||
*/
|
||||
void requestComments();
|
||||
|
||||
/*!
|
||||
* Simply removes comments but doesn't place them back in dialog
|
||||
*/
|
||||
void clearComments();
|
||||
|
||||
void acknowledgeComment(uint32_t token);
|
||||
void loadComment(uint32_t token);
|
||||
void loadList(uint32_t token);
|
||||
void addComment(const RsPhotoComment& comment);
|
||||
private:
|
||||
Ui::PhotoDialog *ui;
|
||||
|
||||
RsPhoto* mRsPhoto;
|
||||
TokenQueue* mPhotoQueue;
|
||||
RsPhotoPhoto mPhotoDetails;
|
||||
QSet<PhotoCommentItem*> mComments;
|
||||
};
|
||||
|
||||
#endif // PHOTODIALOG_H
|
||||
|
@ -1,52 +1,52 @@
|
||||
#ifndef PHOTOITEM_H
|
||||
#define PHOTOITEM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include "PhotoShareItemHolder.h"
|
||||
#include "retroshare/rsphotoV2.h"
|
||||
|
||||
namespace Ui {
|
||||
class PhotoItem;
|
||||
}
|
||||
|
||||
class PhotoItem : public QWidget, public PhotoShareItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
PhotoItem(PhotoShareItemHolder *holder, const RsPhotoPhoto& photo, QWidget* parent = 0);
|
||||
PhotoItem(PhotoShareItemHolder *holder, const QString& path, QWidget* parent = 0); // for new photos.
|
||||
~PhotoItem();
|
||||
void setSelected(bool selected);
|
||||
bool isSelected(){ return mSelected; }
|
||||
const RsPhotoPhoto& getPhotoDetails();
|
||||
bool getPhotoThumbnail(RsPhotoThumbnail &nail);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
private:
|
||||
void updateImage(const RsPhotoThumbnail &thumbnail);
|
||||
void setUp();
|
||||
|
||||
private slots:
|
||||
void setTitle();
|
||||
void setPhotoGrapher();
|
||||
|
||||
private:
|
||||
Ui::PhotoItem *ui;
|
||||
|
||||
QPixmap mThumbNail;
|
||||
|
||||
QPixmap getPixmap() { return mThumbNail; }
|
||||
|
||||
bool mSelected;
|
||||
RsPhotoPhoto mPhotoDetails;
|
||||
PhotoShareItemHolder* mHolder;
|
||||
|
||||
QLabel *mTitleLabel, *mPhotoGrapherLabel;
|
||||
};
|
||||
|
||||
#endif // PHOTOITEM_H
|
||||
#ifndef PHOTOITEM_H
|
||||
#define PHOTOITEM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include "PhotoShareItemHolder.h"
|
||||
#include "retroshare/rsphoto.h"
|
||||
|
||||
namespace Ui {
|
||||
class PhotoItem;
|
||||
}
|
||||
|
||||
class PhotoItem : public QWidget, public PhotoShareItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
PhotoItem(PhotoShareItemHolder *holder, const RsPhotoPhoto& photo, QWidget* parent = 0);
|
||||
PhotoItem(PhotoShareItemHolder *holder, const QString& path, QWidget* parent = 0); // for new photos.
|
||||
~PhotoItem();
|
||||
void setSelected(bool selected);
|
||||
bool isSelected(){ return mSelected; }
|
||||
const RsPhotoPhoto& getPhotoDetails();
|
||||
bool getPhotoThumbnail(RsPhotoThumbnail &nail);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
private:
|
||||
void updateImage(const RsPhotoThumbnail &thumbnail);
|
||||
void setUp();
|
||||
|
||||
private slots:
|
||||
void setTitle();
|
||||
void setPhotoGrapher();
|
||||
|
||||
private:
|
||||
Ui::PhotoItem *ui;
|
||||
|
||||
QPixmap mThumbNail;
|
||||
|
||||
QPixmap getPixmap() { return mThumbNail; }
|
||||
|
||||
bool mSelected;
|
||||
RsPhotoPhoto mPhotoDetails;
|
||||
PhotoShareItemHolder* mHolder;
|
||||
|
||||
QLabel *mTitleLabel, *mPhotoGrapherLabel;
|
||||
};
|
||||
|
||||
#endif // PHOTOITEM_H
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,97 +1,97 @@
|
||||
#ifndef PHOTOSHARE_H
|
||||
#define PHOTOSHARE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <map>
|
||||
#include "ui_PhotoShare.h"
|
||||
|
||||
#include "retroshare/rsphotoV2.h"
|
||||
#include "retroshare-gui/mainpage.h"
|
||||
|
||||
#include "AlbumCreateDialog.h"
|
||||
#include "AlbumDialog.h"
|
||||
#include "PhotoDialog.h"
|
||||
|
||||
#include "AlbumItem.h"
|
||||
#include "PhotoItem.h"
|
||||
#include "PhotoSlideShow.h"
|
||||
|
||||
#include "util/TokenQueue.h"
|
||||
#include "PhotoShareItemHolder.h"
|
||||
|
||||
namespace Ui {
|
||||
class PhotoShare;
|
||||
}
|
||||
|
||||
class PhotoShare : public MainPage, public TokenResponse, public PhotoShareItemHolder
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PhotoShare(QWidget *parent = 0);
|
||||
|
||||
void notifySelection(PhotoShareItem* selection);
|
||||
|
||||
private slots:
|
||||
void checkUpdate();
|
||||
void createAlbum();
|
||||
void OpenAlbumDialog();
|
||||
void OpenPhotoDialog();
|
||||
void OpenSlideShow();
|
||||
void updateAlbums();
|
||||
void subscribeToAlbum();
|
||||
void deleteAlbum(const RsGxsGroupId&);
|
||||
|
||||
private:
|
||||
/* Request Response Functions for loading data */
|
||||
void requestAlbumList(std::list<std::string>& ids);
|
||||
void requestAlbumData(std::list<RsGxsGroupId> &ids);
|
||||
|
||||
/*!
|
||||
* request data for all groups
|
||||
*/
|
||||
void requestAlbumData();
|
||||
void requestPhotoList(GxsMsgReq &albumIds);
|
||||
void requestPhotoList(const std::string &albumId);
|
||||
void requestPhotoData(GxsMsgReq &photoIds);
|
||||
void requestPhotoData(const std::list<RsGxsGroupId> &grpIds);
|
||||
|
||||
void loadAlbumList(const uint32_t &token);
|
||||
bool loadAlbumData(const uint32_t &token);
|
||||
void loadPhotoList(const uint32_t &token);
|
||||
void loadPhotoData(const uint32_t &token);
|
||||
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
void acknowledgeGroup(const uint32_t &token);
|
||||
void acknowledgeMessage(const uint32_t &token);
|
||||
|
||||
/* Grunt work of setting up the GUI */
|
||||
|
||||
void addAlbum(const RsPhotoAlbum &album);
|
||||
void addPhoto(const RsPhotoPhoto &photo);
|
||||
|
||||
void clearAlbums();
|
||||
void clearPhotos();
|
||||
void deleteAlbums();
|
||||
/*!
|
||||
* Fills up photo ui with photos held in mPhotoItems (current groups photos)
|
||||
*/
|
||||
void updatePhotos();
|
||||
|
||||
private:
|
||||
AlbumItem* mAlbumSelected;
|
||||
PhotoItem* mPhotoSelected;
|
||||
|
||||
|
||||
TokenQueue *mPhotoQueue;
|
||||
|
||||
/* UI - from Designer */
|
||||
Ui::PhotoShare ui;
|
||||
|
||||
QSet<AlbumItem*> mAlbumItems;
|
||||
QSet<PhotoItem*> mPhotoItems; // the current album selected
|
||||
|
||||
};
|
||||
|
||||
#endif // PHOTOSHARE_H
|
||||
#ifndef PHOTOSHARE_H
|
||||
#define PHOTOSHARE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <map>
|
||||
#include "ui_PhotoShare.h"
|
||||
|
||||
#include "retroshare/rsphoto.h"
|
||||
#include "retroshare-gui/mainpage.h"
|
||||
|
||||
#include "AlbumCreateDialog.h"
|
||||
#include "AlbumDialog.h"
|
||||
#include "PhotoDialog.h"
|
||||
|
||||
#include "AlbumItem.h"
|
||||
#include "PhotoItem.h"
|
||||
#include "PhotoSlideShow.h"
|
||||
|
||||
#include "util/TokenQueue.h"
|
||||
#include "PhotoShareItemHolder.h"
|
||||
|
||||
namespace Ui {
|
||||
class PhotoShare;
|
||||
}
|
||||
|
||||
class PhotoShare : public MainPage, public TokenResponse, public PhotoShareItemHolder
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PhotoShare(QWidget *parent = 0);
|
||||
|
||||
void notifySelection(PhotoShareItem* selection);
|
||||
|
||||
private slots:
|
||||
void checkUpdate();
|
||||
void createAlbum();
|
||||
void OpenAlbumDialog();
|
||||
void OpenPhotoDialog();
|
||||
void OpenSlideShow();
|
||||
void updateAlbums();
|
||||
void subscribeToAlbum();
|
||||
void deleteAlbum(const RsGxsGroupId&);
|
||||
|
||||
private:
|
||||
/* Request Response Functions for loading data */
|
||||
void requestAlbumList(std::list<std::string>& ids);
|
||||
void requestAlbumData(std::list<RsGxsGroupId> &ids);
|
||||
|
||||
/*!
|
||||
* request data for all groups
|
||||
*/
|
||||
void requestAlbumData();
|
||||
void requestPhotoList(GxsMsgReq &albumIds);
|
||||
void requestPhotoList(const std::string &albumId);
|
||||
void requestPhotoData(GxsMsgReq &photoIds);
|
||||
void requestPhotoData(const std::list<RsGxsGroupId> &grpIds);
|
||||
|
||||
void loadAlbumList(const uint32_t &token);
|
||||
bool loadAlbumData(const uint32_t &token);
|
||||
void loadPhotoList(const uint32_t &token);
|
||||
void loadPhotoData(const uint32_t &token);
|
||||
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
void acknowledgeGroup(const uint32_t &token);
|
||||
void acknowledgeMessage(const uint32_t &token);
|
||||
|
||||
/* Grunt work of setting up the GUI */
|
||||
|
||||
void addAlbum(const RsPhotoAlbum &album);
|
||||
void addPhoto(const RsPhotoPhoto &photo);
|
||||
|
||||
void clearAlbums();
|
||||
void clearPhotos();
|
||||
void deleteAlbums();
|
||||
/*!
|
||||
* Fills up photo ui with photos held in mPhotoItems (current groups photos)
|
||||
*/
|
||||
void updatePhotos();
|
||||
|
||||
private:
|
||||
AlbumItem* mAlbumSelected;
|
||||
PhotoItem* mPhotoSelected;
|
||||
|
||||
|
||||
TokenQueue *mPhotoQueue;
|
||||
|
||||
/* UI - from Designer */
|
||||
Ui::PhotoShare ui;
|
||||
|
||||
QSet<AlbumItem*> mAlbumItems;
|
||||
QSet<PhotoItem*> mPhotoItems; // the current album selected
|
||||
|
||||
};
|
||||
|
||||
#endif // PHOTOSHARE_H
|
||||
|
@ -39,7 +39,7 @@ PhotoSlideShow::PhotoSlideShow(const RsPhotoAlbum& album, QWidget *parent)
|
||||
connect(ui.pushButton_Close, SIGNAL( clicked( void ) ), this, SLOT( closeShow( void ) ) );
|
||||
connect(ui.fullscreenButton, SIGNAL(clicked()),this, SLOT(setFullScreen()));
|
||||
|
||||
mPhotoQueue = new TokenQueue(rsPhotoV2->getTokenService(), this);
|
||||
mPhotoQueue = new TokenQueue(rsPhoto->getTokenService(), this);
|
||||
|
||||
mRunning = true;
|
||||
mShotActive = true;
|
||||
@ -236,7 +236,7 @@ bool PhotoSlideShow::loadPhotoData(const uint32_t &token)
|
||||
std::cerr << std::endl;
|
||||
|
||||
PhotoResult res;
|
||||
rsPhotoV2->getPhoto(token, res);
|
||||
rsPhoto->getPhoto(token, res);
|
||||
PhotoResult::iterator mit = res.begin();
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include "ui_PhotoSlideShow.h"
|
||||
|
||||
#include <retroshare/rsphotoV2.h>
|
||||
#include <retroshare/rsphoto.h>
|
||||
#include "util/TokenQueue.h"
|
||||
#include "AlbumItem.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user