mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-06 21:58:57 -04:00
Message Synchronisation now supported by photoshare (photo and comments sync)
Photoshare UI now functional - subscribing to an album enables message sync - TokenQueue now operate with FIFO stack to prevent overlap in request completion - photos are now load on demand as with comments - fixed some noddy bugs (subscribe flag initialises incorrectly) git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5624 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
bdd6c6041b
commit
b06214b779
12 changed files with 240 additions and 102 deletions
|
@ -558,11 +558,6 @@ void RsGenExchange::publishMsgs()
|
||||||
msg->metaData = new RsGxsMsgMetaData();
|
msg->metaData = new RsGxsMsgMetaData();
|
||||||
msg->msg.setBinData(mData, size);
|
msg->msg.setBinData(mData, size);
|
||||||
*(msg->metaData) = msgItem->meta;
|
*(msg->metaData) = msgItem->meta;
|
||||||
size = msg->metaData->serial_size();
|
|
||||||
char metaDataBuff[size];
|
|
||||||
|
|
||||||
msg->metaData->serialise(metaDataBuff, &size);
|
|
||||||
msg->meta.setBinData(metaDataBuff, size);
|
|
||||||
|
|
||||||
ok = createMessage(msg);
|
ok = createMessage(msg);
|
||||||
RsGxsMessageId msgId;
|
RsGxsMessageId msgId;
|
||||||
|
@ -582,6 +577,14 @@ void RsGenExchange::publishMsgs()
|
||||||
{
|
{
|
||||||
msg->metaData->mOrigMsgId = msg->metaData->mMsgId;
|
msg->metaData->mOrigMsgId = msg->metaData->mMsgId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// now serialise meta data
|
||||||
|
size = msg->metaData->serial_size();
|
||||||
|
char metaDataBuff[size];
|
||||||
|
msg->metaData->serialise(metaDataBuff, &size);
|
||||||
|
msg->meta.setBinData(metaDataBuff, size);
|
||||||
|
|
||||||
|
|
||||||
msgId = msg->msgId;
|
msgId = msg->msgId;
|
||||||
grpId = msg->grpId;
|
grpId = msg->grpId;
|
||||||
ok = mDataAccess->addMsgData(msg);
|
ok = mDataAccess->addMsgData(msg);
|
||||||
|
@ -716,11 +719,50 @@ void RsGenExchange::createDummyGroup(RsGxsGrpItem *grpItem)
|
||||||
void RsGenExchange::processRecvdData()
|
void RsGenExchange::processRecvdData()
|
||||||
{
|
{
|
||||||
processRecvdGroups();
|
processRecvdGroups();
|
||||||
|
|
||||||
|
processRecvdMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RsGenExchange::processRecvdMessages()
|
void RsGenExchange::processRecvdMessages()
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(mGenMtx);
|
||||||
|
|
||||||
|
std::vector<RsNxsMsg*>::iterator vit = mReceivedMsgs.begin();
|
||||||
|
GxsMsgReq msgIds;
|
||||||
|
std::map<RsNxsMsg*, RsGxsMsgMetaData*> msgs;
|
||||||
|
|
||||||
|
for(; vit != mReceivedMsgs.end(); vit++)
|
||||||
|
{
|
||||||
|
RsNxsMsg* msg = *vit;
|
||||||
|
RsGxsMsgMetaData* meta = new RsGxsMsgMetaData();
|
||||||
|
bool ok = meta->deserialise(msg->meta.bin_data, &(msg->meta.bin_len));
|
||||||
|
|
||||||
|
if(ok)
|
||||||
|
{
|
||||||
|
msgs.insert(std::make_pair(msg, meta));
|
||||||
|
msgIds[msg->grpId].push_back(msg->msgId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifdef GXS_GENX_DEBUG
|
||||||
|
std::cerr << "failed to deserialise incoming meta, grpId: "
|
||||||
|
<< msg->grpId << ", msgId: " << msg->msgId << std::endl;
|
||||||
|
#endif
|
||||||
|
delete msg;
|
||||||
|
delete meta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!msgIds.empty())
|
||||||
|
{
|
||||||
|
mDataStore->storeMessage(msgs);
|
||||||
|
RsGxsMsgChange* c = new RsGxsMsgChange();
|
||||||
|
c->msgChangeMap = msgIds;
|
||||||
|
mNotifications.push_back(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
mReceivedMsgs.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -737,11 +779,22 @@ void RsGenExchange::processRecvdGroups()
|
||||||
{
|
{
|
||||||
RsNxsGrp* grp = *vit;
|
RsNxsGrp* grp = *vit;
|
||||||
RsGxsGrpMetaData* meta = new RsGxsGrpMetaData();
|
RsGxsGrpMetaData* meta = new RsGxsGrpMetaData();
|
||||||
meta->deserialise(grp->meta.bin_data, grp->meta.bin_len);
|
bool ok = meta->deserialise(grp->meta.bin_data, grp->meta.bin_len);
|
||||||
grps.insert(std::make_pair(grp, meta));
|
|
||||||
|
|
||||||
grpIds.push_back(grp->grpId);
|
|
||||||
|
|
||||||
|
if(ok)
|
||||||
|
{
|
||||||
|
grps.insert(std::make_pair(grp, meta));
|
||||||
|
grpIds.push_back(grp->grpId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifdef GXS_GENX_DEBUG
|
||||||
|
std::cerr << "failed to deserialise incoming meta, grpId: "
|
||||||
|
<< grp->grpId << std::endl;
|
||||||
|
#endif
|
||||||
|
delete grp;
|
||||||
|
delete meta;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!grpIds.empty())
|
if(!grpIds.empty())
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
RsGxsGrpMetaData::RsGxsGrpMetaData()
|
RsGxsGrpMetaData::RsGxsGrpMetaData()
|
||||||
{
|
{
|
||||||
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t RsGxsGrpMetaData::serial_size()
|
uint32_t RsGxsGrpMetaData::serial_size()
|
||||||
|
|
|
@ -98,7 +98,8 @@ void RsGxsNetService::syncWithPeers()
|
||||||
{
|
{
|
||||||
RsGxsGrpMetaData* meta = mit->second;
|
RsGxsGrpMetaData* meta = mit->second;
|
||||||
|
|
||||||
if(meta->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED)
|
if(meta->mSubscribeFlags & (GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED |
|
||||||
|
GXS_SERV::GROUP_SUBSCRIBE_ADMIN) )
|
||||||
grpIds.push_back(mit->first);
|
grpIds.push_back(mit->first);
|
||||||
|
|
||||||
delete meta;
|
delete meta;
|
||||||
|
@ -106,21 +107,21 @@ void RsGxsNetService::syncWithPeers()
|
||||||
|
|
||||||
sit = peers.begin();
|
sit = peers.begin();
|
||||||
|
|
||||||
// TODO msgs
|
// synchronise group msg for groups which we're subscribed to
|
||||||
for(; sit != peers.end(); sit++)
|
for(; sit != peers.end(); sit++)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mNxsMutex);
|
RsStackMutex stack(mNxsMutex);
|
||||||
|
|
||||||
std::vector<RsGxsGroupId>::iterator vit = grpIds.begin();
|
std::vector<RsGxsGroupId>::iterator vit = grpIds.begin();
|
||||||
|
|
||||||
for(; vit != grpIds.end(); vit++)
|
for(; vit != grpIds.end(); vit++)
|
||||||
{
|
{
|
||||||
RsNxsSyncMsg* msg = new RsNxsSyncMsg(mServType);
|
RsNxsSyncMsg* msg = new RsNxsSyncMsg(mServType);
|
||||||
msg->clear();
|
msg->clear();
|
||||||
msg->PeerId(*sit);
|
msg->PeerId(*sit);
|
||||||
msg->grpId = *vit;
|
msg->grpId = *vit;
|
||||||
sendItem(msg);
|
sendItem(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,15 @@ void p3PhotoServiceV2::groupsChanged(std::list<RsGxsGroupId>& grpIds)
|
||||||
void p3PhotoServiceV2::msgsChanged(
|
void p3PhotoServiceV2::msgsChanged(
|
||||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgs)
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>479</width>
|
<width>411</width>
|
||||||
<height>89</height>
|
<height>84</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -16,6 +16,18 @@
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="expandFrame">
|
<widget class="QFrame" name="expandFrame">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>400</width>
|
||||||
|
<height>71</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">QFrame#expandFrame{border: 2px solid #D3D3D3;
|
<string notr="true">QFrame#expandFrame{border: 2px solid #D3D3D3;
|
||||||
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
|
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
|
||||||
|
|
|
@ -13,9 +13,8 @@ PhotoDialog::PhotoDialog(RsPhotoV2 *rs_photo, const RsPhotoPhoto &photo, QWidget
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setAttribute ( Qt::WA_DeleteOnClose, true );
|
setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||||
setUp();
|
|
||||||
connect(ui->toolButton_AddComment, SIGNAL(clicked()), this, SLOT(addComment()));
|
connect(ui->toolButton_AddComment, SIGNAL(clicked()), this, SLOT(addComment()));
|
||||||
|
setUp();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +32,8 @@ void PhotoDialog::setUp()
|
||||||
ui->lineEdit_Title->setText(QString::fromStdString(mPhotoDetails.mMeta.mMsgName));
|
ui->lineEdit_Title->setText(QString::fromStdString(mPhotoDetails.mMeta.mMsgName));
|
||||||
|
|
||||||
ui->scrollAreaWidgetContents->setLayout(new QVBoxLayout());
|
ui->scrollAreaWidgetContents->setLayout(new QVBoxLayout());
|
||||||
|
|
||||||
|
requestComments();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,13 +56,14 @@ void PhotoDialog::clearComments()
|
||||||
PhotoCommentItem* item = sit.next();
|
PhotoCommentItem* item = sit.next();
|
||||||
l->removeWidget(item);
|
l->removeWidget(item);
|
||||||
item->setParent(NULL);
|
item->setParent(NULL);
|
||||||
|
delete item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mComments.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhotoDialog::resetComments()
|
void PhotoDialog::resetComments()
|
||||||
{
|
{
|
||||||
clearComments();
|
|
||||||
|
|
||||||
QSetIterator<PhotoCommentItem*> sit(mComments);
|
QSetIterator<PhotoCommentItem*> sit(mComments);
|
||||||
QLayout* l = ui->scrollAreaWidgetContents->layout();
|
QLayout* l = ui->scrollAreaWidgetContents->layout();
|
||||||
while(sit.hasNext())
|
while(sit.hasNext())
|
||||||
|
@ -71,6 +73,21 @@ void PhotoDialog::resetComments()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PhotoDialog::requestComments()
|
||||||
|
{
|
||||||
|
RsTokReqOptionsV2 opts;
|
||||||
|
opts.mMsgFlagMask = RsPhotoV2::FLAG_MSG_TYPE_MASK;
|
||||||
|
opts.mMsgFlagFilter = RsPhotoV2::FLAG_MSG_TYPE_PHOTO_COMMENT;
|
||||||
|
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_IDS;
|
||||||
|
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;
|
||||||
|
mPhotoQueue->requestMsgRelatedInfo(token, opts, msgId, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void PhotoDialog::createComment()
|
void PhotoDialog::createComment()
|
||||||
{
|
{
|
||||||
if(mCommentDialog)
|
if(mCommentDialog)
|
||||||
|
@ -82,6 +99,7 @@ void PhotoDialog::createComment()
|
||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
comment.mMeta.mGroupId = mPhotoDetails.mMeta.mGroupId;
|
comment.mMeta.mGroupId = mPhotoDetails.mMeta.mGroupId;
|
||||||
|
comment.mMeta.mParentId = mPhotoDetails.mMeta.mOrigMsgId;
|
||||||
mRsPhoto->submitComment(token, comment);
|
mRsPhoto->submitComment(token, comment);
|
||||||
mPhotoQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
|
mPhotoQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
|
||||||
|
|
||||||
|
@ -111,6 +129,9 @@ void PhotoDialog::loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &r
|
||||||
case RS_TOKREQ_ANSTYPE_DATA:
|
case RS_TOKREQ_ANSTYPE_DATA:
|
||||||
loadComment(req.mToken);
|
loadComment(req.mToken);
|
||||||
break;
|
break;
|
||||||
|
case RS_TOKREQ_ANSTYPE_LIST:
|
||||||
|
loadList(req.mToken);
|
||||||
|
break;
|
||||||
case RS_TOKREQ_ANSTYPE_ACK:
|
case RS_TOKREQ_ANSTYPE_ACK:
|
||||||
acknowledgeComment(req.mToken);
|
acknowledgeComment(req.mToken);
|
||||||
break;
|
break;
|
||||||
|
@ -136,6 +157,8 @@ void PhotoDialog::loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &r
|
||||||
void PhotoDialog::loadComment(uint32_t token)
|
void PhotoDialog::loadComment(uint32_t token)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
clearComments();
|
||||||
|
|
||||||
PhotoCommentResult results;
|
PhotoCommentResult results;
|
||||||
mRsPhoto->getPhotoComment(token, results);
|
mRsPhoto->getPhotoComment(token, results);
|
||||||
|
|
||||||
|
@ -155,6 +178,18 @@ void PhotoDialog::loadComment(uint32_t token)
|
||||||
resetComments();
|
resetComments();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PhotoDialog::loadList(uint32_t token)
|
||||||
|
{
|
||||||
|
GxsMsgReq msgIds;
|
||||||
|
mRsPhoto->getMsgList(token, msgIds);
|
||||||
|
RsTokReqOptionsV2 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)
|
void PhotoDialog::addComment(const RsPhotoComment &comment)
|
||||||
{
|
{
|
||||||
PhotoCommentItem* item = new PhotoCommentItem(comment);
|
PhotoCommentItem* item = new PhotoCommentItem(comment);
|
||||||
|
@ -170,16 +205,7 @@ void PhotoDialog::acknowledgeComment(uint32_t token)
|
||||||
|
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
uint32_t reqToken;
|
requestComments();
|
||||||
RsTokReqOptionsV2 opts;
|
|
||||||
opts.mMsgFlagMask = RsPhotoV2::FLAG_MSG_TYPE_MASK;
|
|
||||||
opts.mMsgFlagFilter = RsPhotoV2::FLAG_MSG_TYPE_PHOTO_COMMENT;
|
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
|
||||||
GxsMsgReq req;
|
|
||||||
std::vector<RsGxsMessageId> msgIdsV;
|
|
||||||
msgIdsV.push_back(msgId.second);
|
|
||||||
req.insert(std::make_pair(msgId.first, msgIdsV));
|
|
||||||
mPhotoQueue->requestMsgInfo(reqToken, RS_TOKREQ_ANSTYPE_DATA, opts, req, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,11 @@ private:
|
||||||
*/
|
*/
|
||||||
void resetComments();
|
void resetComments();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Request comments
|
||||||
|
*/
|
||||||
|
void requestComments();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Simply removes comments but doesn't place them back in dialog
|
* Simply removes comments but doesn't place them back in dialog
|
||||||
*/
|
*/
|
||||||
|
@ -43,6 +48,7 @@ private:
|
||||||
|
|
||||||
void acknowledgeComment(uint32_t token);
|
void acknowledgeComment(uint32_t token);
|
||||||
void loadComment(uint32_t token);
|
void loadComment(uint32_t token);
|
||||||
|
void loadList(uint32_t token);
|
||||||
void addComment(const RsPhotoComment& comment);
|
void addComment(const RsPhotoComment& comment);
|
||||||
private:
|
private:
|
||||||
Ui::PhotoDialog *ui;
|
Ui::PhotoDialog *ui;
|
||||||
|
|
|
@ -32,12 +32,12 @@ PhotoItem::PhotoItem(PhotoShareItemHolder *holder, const QString& path, QWidget
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
int width = 120;
|
int width = 250;
|
||||||
int height = 120;
|
int height = 250;
|
||||||
|
|
||||||
QPixmap qtn = QPixmap(path).scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
QPixmap qtn = QPixmap(path).scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
ui->label_Thumbnail->setPixmap(qtn);
|
|
||||||
mThumbNail = qtn;
|
mThumbNail = qtn;
|
||||||
|
ui->label_Thumbnail->setPixmap(mThumbNail.scaled(120, 120, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||||
setSelected(false);
|
setSelected(false);
|
||||||
|
|
||||||
getPhotoThumbnail(mPhotoDetails.mThumbnail);
|
getPhotoThumbnail(mPhotoDetails.mThumbnail);
|
||||||
|
|
|
@ -98,7 +98,6 @@ PhotoShare::PhotoShare(QWidget *parent)
|
||||||
/* setup TokenQueue */
|
/* setup TokenQueue */
|
||||||
mPhotoQueue = new TokenQueueV2(rsPhotoV2->getTokenService(), this);
|
mPhotoQueue = new TokenQueueV2(rsPhotoV2->getTokenService(), this);
|
||||||
requestAlbumData();
|
requestAlbumData();
|
||||||
updateAlbums();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhotoShare::notifySelection(PhotoShareItem *selection)
|
void PhotoShare::notifySelection(PhotoShareItem *selection)
|
||||||
|
@ -113,8 +112,6 @@ void PhotoShare::notifySelection(PhotoShareItem *selection)
|
||||||
if(mPhotoSelected)
|
if(mPhotoSelected)
|
||||||
mPhotoSelected->setSelected(false);
|
mPhotoSelected->setSelected(false);
|
||||||
|
|
||||||
clearPhotos();
|
|
||||||
|
|
||||||
if(mAlbumSelected == aItem)
|
if(mAlbumSelected == aItem)
|
||||||
{
|
{
|
||||||
mAlbumSelected->setSelected(true);
|
mAlbumSelected->setSelected(true);
|
||||||
|
@ -133,9 +130,11 @@ void PhotoShare::notifySelection(PhotoShareItem *selection)
|
||||||
|
|
||||||
mAlbumSelected->setSelected(true);
|
mAlbumSelected->setSelected(true);
|
||||||
|
|
||||||
|
// get photo data
|
||||||
|
std::list<RsGxsGroupId> grpIds;
|
||||||
|
grpIds.push_back(mAlbumSelected->getAlbum().mMeta.mGroupId);
|
||||||
|
requestPhotoData(grpIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePhotos();
|
|
||||||
}
|
}
|
||||||
else if((pItem = dynamic_cast<PhotoItem*>(selection)) != NULL)
|
else if((pItem = dynamic_cast<PhotoItem*>(selection)) != NULL)
|
||||||
{
|
{
|
||||||
|
@ -283,6 +282,8 @@ void PhotoShare::SetPhotoDialogClosed()
|
||||||
|
|
||||||
void PhotoShare::clearAlbums()
|
void PhotoShare::clearAlbums()
|
||||||
{
|
{
|
||||||
|
clearPhotos();
|
||||||
|
|
||||||
std::cerr << "PhotoShare::clearAlbums()" << std::endl;
|
std::cerr << "PhotoShare::clearAlbums()" << std::endl;
|
||||||
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
|
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
|
||||||
|
|
||||||
|
@ -295,8 +296,6 @@ void PhotoShare::clearAlbums()
|
||||||
item->setParent(NULL);
|
item->setParent(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearPhotos();
|
|
||||||
|
|
||||||
// set no albums to be selected
|
// set no albums to be selected
|
||||||
if(mAlbumSelected)
|
if(mAlbumSelected)
|
||||||
{
|
{
|
||||||
|
@ -328,23 +327,23 @@ void PhotoShare::deleteAlbums()
|
||||||
void PhotoShare::clearPhotos()
|
void PhotoShare::clearPhotos()
|
||||||
{
|
{
|
||||||
std::cerr << "PhotoShare::clearPhotos()" << std::endl;
|
std::cerr << "PhotoShare::clearPhotos()" << std::endl;
|
||||||
mPhotoSelected = NULL;
|
|
||||||
|
|
||||||
QLayout *layout = ui.scrollAreaWidgetContents_2->layout();
|
QLayout *layout = ui.scrollAreaWidgetContents_2->layout();
|
||||||
|
|
||||||
if(mAlbumSelected)
|
if(mAlbumSelected)
|
||||||
{
|
{
|
||||||
const RsGxsGroupId& id = mAlbumSelected->getAlbum().mMeta.mGroupId;
|
QSetIterator<PhotoItem*> sit(mPhotoItems);
|
||||||
|
|
||||||
QSetIterator<PhotoItem*> sit(mPhotoItems[id]);
|
|
||||||
|
|
||||||
while(sit.hasNext())
|
while(sit.hasNext())
|
||||||
{
|
{
|
||||||
PhotoItem* item = sit.next();
|
PhotoItem* item = sit.next();
|
||||||
layout->removeWidget(item);
|
layout->removeWidget(item);
|
||||||
item->setParent(NULL);
|
item->setParent(NULL);
|
||||||
|
delete item; // remove item
|
||||||
}
|
}
|
||||||
|
mPhotoItems.clear();
|
||||||
}
|
}
|
||||||
|
mPhotoSelected = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhotoShare::updateAlbums()
|
void PhotoShare::updateAlbums()
|
||||||
|
@ -407,10 +406,38 @@ void PhotoShare::updateAlbums()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PhotoShare::deleteAlbum(const RsGxsGroupId &grpId)
|
||||||
|
{
|
||||||
|
|
||||||
|
QSetIterator<AlbumItem*> sit(mAlbumItems);
|
||||||
|
|
||||||
|
while(sit.hasNext())
|
||||||
|
{
|
||||||
|
AlbumItem* item = sit.next();
|
||||||
|
|
||||||
|
if(item->getAlbum().mMeta.mGroupId == grpId){
|
||||||
|
|
||||||
|
if(mAlbumSelected == item)
|
||||||
|
{
|
||||||
|
item->setSelected(false);
|
||||||
|
mAlbumSelected = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
|
||||||
|
alayout->removeWidget(item);
|
||||||
|
mAlbumItems.remove(item);
|
||||||
|
item->setParent(NULL);
|
||||||
|
delete item;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PhotoShare::addAlbum(const RsPhotoAlbum &album)
|
void PhotoShare::addAlbum(const RsPhotoAlbum &album)
|
||||||
{
|
{
|
||||||
std::cerr << " PhotoShare::addAlbum() AlbumId: " << album.mMeta.mGroupId << std::endl;
|
std::cerr << " PhotoShare::addAlbum() AlbumId: " << album.mMeta.mGroupId << std::endl;
|
||||||
|
|
||||||
|
deleteAlbum(album.mMeta.mGroupId); // remove from ui
|
||||||
AlbumItem *item = new AlbumItem(album, this, this);
|
AlbumItem *item = new AlbumItem(album, this, this);
|
||||||
mAlbumItems.insert(item);
|
mAlbumItems.insert(item);
|
||||||
}
|
}
|
||||||
|
@ -423,9 +450,7 @@ void PhotoShare::addPhoto(const RsPhotoPhoto &photo)
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
PhotoItem* item = new PhotoItem(this, photo, this);
|
PhotoItem* item = new PhotoItem(this, photo, this);
|
||||||
const RsGxsGroupId id = photo.mMeta.mGroupId;
|
mPhotoItems.insert(item);
|
||||||
|
|
||||||
mPhotoItems[id].insert(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhotoShare::subscribeToAlbum()
|
void PhotoShare::subscribeToAlbum()
|
||||||
|
@ -450,13 +475,10 @@ void PhotoShare::subscribeToAlbum()
|
||||||
|
|
||||||
void PhotoShare::updatePhotos()
|
void PhotoShare::updatePhotos()
|
||||||
{
|
{
|
||||||
clearPhotos();
|
|
||||||
|
|
||||||
if(mAlbumSelected)
|
if(mAlbumSelected)
|
||||||
{
|
{
|
||||||
const RsGxsGroupId& grpId = mAlbumSelected->getAlbum().mMeta.mGroupId;
|
QSetIterator<PhotoItem*> sit(mPhotoItems);
|
||||||
|
|
||||||
QSetIterator<PhotoItem*> sit(mPhotoItems[grpId]);
|
|
||||||
|
|
||||||
while(sit.hasNext())
|
while(sit.hasNext())
|
||||||
{
|
{
|
||||||
|
@ -497,8 +519,6 @@ void PhotoShare::loadAlbumList(const uint32_t &token)
|
||||||
|
|
||||||
requestAlbumData(albumIds);
|
requestAlbumData(albumIds);
|
||||||
|
|
||||||
clearPhotos();
|
|
||||||
|
|
||||||
std::list<std::string>::iterator it;
|
std::list<std::string>::iterator it;
|
||||||
for(it = albumIds.begin(); it != albumIds.end(); it++)
|
for(it = albumIds.begin(); it != albumIds.end(); it++)
|
||||||
{
|
{
|
||||||
|
@ -525,9 +545,6 @@ void PhotoShare::requestAlbumData()
|
||||||
|
|
||||||
bool PhotoShare::loadAlbumData(const uint32_t &token)
|
bool PhotoShare::loadAlbumData(const uint32_t &token)
|
||||||
{
|
{
|
||||||
|
|
||||||
deleteAlbums();
|
|
||||||
|
|
||||||
std::cerr << "PhotoShare::loadAlbumData()";
|
std::cerr << "PhotoShare::loadAlbumData()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
@ -544,6 +561,7 @@ bool PhotoShare::loadAlbumData(const uint32_t &token)
|
||||||
|
|
||||||
addAlbum(album);
|
addAlbum(album);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAlbums();
|
updateAlbums();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -575,7 +593,7 @@ void PhotoShare::acknowledgeGroup(const uint32_t &token)
|
||||||
RsTokReqOptionsV2 opts;
|
RsTokReqOptionsV2 opts;
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||||
uint32_t reqToken;
|
uint32_t reqToken;
|
||||||
mPhotoQueue->requestGroupInfo(reqToken, RS_TOKREQ_ANSTYPE_DATA, opts, 0);
|
mPhotoQueue->requestGroupInfo(reqToken, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -584,18 +602,21 @@ void PhotoShare::acknowledgeMessage(const uint32_t &token)
|
||||||
std::pair<RsGxsGroupId, RsGxsMessageId> p;
|
std::pair<RsGxsGroupId, RsGxsMessageId> p;
|
||||||
rsPhotoV2->acknowledgeMsg(token, p);
|
rsPhotoV2->acknowledgeMsg(token, p);
|
||||||
|
|
||||||
if(!p.first.empty())
|
// just acknowledge don't load it
|
||||||
{
|
// loading is only instigated by clicking an album (i.e. requesting photo data)
|
||||||
GxsMsgReq req;
|
// but load it if the album is selected
|
||||||
std::vector<RsGxsMessageId> v;
|
// if(!p.first.empty())
|
||||||
v.push_back(p.second);
|
// {
|
||||||
req[p.first] = v;
|
// if(mAlbumSelected)
|
||||||
RsTokReqOptionsV2 opts;
|
// {
|
||||||
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
|
// if(mAlbumSelected->getAlbum().mMeta.mGroupId == p.first)
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
// {
|
||||||
uint32_t reqToken;
|
// std::list<RsGxsGroupId> grpIds;
|
||||||
mPhotoQueue->requestMsgInfo(reqToken, RS_TOKREQ_ANSTYPE_DATA, opts, req, 0);
|
// grpIds.push_back(p.first);
|
||||||
}
|
// requestPhotoData(grpIds);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhotoShare::loadPhotoList(const uint32_t &token)
|
void PhotoShare::loadPhotoList(const uint32_t &token)
|
||||||
|
@ -618,12 +639,22 @@ void PhotoShare::requestPhotoData(GxsMsgReq &photoIds)
|
||||||
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, photoIds, 0);
|
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, photoIds, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PhotoShare::requestPhotoData(const std::list<RsGxsGroupId>& grpIds)
|
||||||
|
{
|
||||||
|
RsTokReqOptionsV2 opts;
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||||
|
uint32_t token;
|
||||||
|
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PhotoShare::loadPhotoData(const uint32_t &token)
|
void PhotoShare::loadPhotoData(const uint32_t &token)
|
||||||
{
|
{
|
||||||
std::cerr << "PhotoShare::loadPhotoData()";
|
std::cerr << "PhotoShare::loadPhotoData()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
clearPhotos();
|
||||||
|
|
||||||
PhotoResult res;
|
PhotoResult res;
|
||||||
rsPhotoV2->getPhoto(token, res);
|
rsPhotoV2->getPhoto(token, res);
|
||||||
PhotoResult::iterator mit = res.begin();
|
PhotoResult::iterator mit = res.begin();
|
||||||
|
|
|
@ -43,6 +43,7 @@ private slots:
|
||||||
void SetPhotoDialogClosed();
|
void SetPhotoDialogClosed();
|
||||||
void updateAlbums();
|
void updateAlbums();
|
||||||
void subscribeToAlbum();
|
void subscribeToAlbum();
|
||||||
|
void deleteAlbum(const RsGxsGroupId&);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/* Request Response Functions for loading data */
|
/* Request Response Functions for loading data */
|
||||||
|
@ -56,6 +57,7 @@ private:
|
||||||
void requestPhotoList(GxsMsgReq &albumIds);
|
void requestPhotoList(GxsMsgReq &albumIds);
|
||||||
void requestPhotoList(const std::string &albumId);
|
void requestPhotoList(const std::string &albumId);
|
||||||
void requestPhotoData(GxsMsgReq &photoIds);
|
void requestPhotoData(GxsMsgReq &photoIds);
|
||||||
|
void requestPhotoData(const std::list<RsGxsGroupId> &grpIds);
|
||||||
|
|
||||||
void loadAlbumList(const uint32_t &token);
|
void loadAlbumList(const uint32_t &token);
|
||||||
bool loadAlbumData(const uint32_t &token);
|
bool loadAlbumData(const uint32_t &token);
|
||||||
|
@ -75,6 +77,9 @@ private:
|
||||||
void clearAlbums();
|
void clearAlbums();
|
||||||
void clearPhotos();
|
void clearPhotos();
|
||||||
void deleteAlbums();
|
void deleteAlbums();
|
||||||
|
/*!
|
||||||
|
* Fills up photo ui with photos held in mPhotoItems (current groups photos)
|
||||||
|
*/
|
||||||
void updatePhotos();
|
void updatePhotos();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -92,7 +97,7 @@ private:
|
||||||
Ui::PhotoShare ui;
|
Ui::PhotoShare ui;
|
||||||
|
|
||||||
QSet<AlbumItem*> mAlbumItems;
|
QSet<AlbumItem*> mAlbumItems;
|
||||||
QMap<RsGxsGroupId, QSet<PhotoItem*> > mPhotoItems;
|
QSet<PhotoItem*> mPhotoItems; // the current album selected
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ void TokenQueueV2::queueRequest(uint32_t token, uint32_t basictype, uint32_t ans
|
||||||
gettimeofday(&req.mRequestTs, NULL);
|
gettimeofday(&req.mRequestTs, NULL);
|
||||||
req.mPollTs = req.mRequestTs;
|
req.mPollTs = req.mRequestTs;
|
||||||
|
|
||||||
mRequests.push_back(req);
|
mRequests.push_back(req);
|
||||||
|
|
||||||
if (mRequests.size() == 1)
|
if (mRequests.size() == 1)
|
||||||
{
|
{
|
||||||
|
@ -123,26 +123,23 @@ void TokenQueueV2::doPoll(float dt)
|
||||||
|
|
||||||
void TokenQueueV2::pollRequests()
|
void TokenQueueV2::pollRequests()
|
||||||
{
|
{
|
||||||
std::list<TokenRequestV2>::iterator it;
|
|
||||||
|
|
||||||
double pollPeriod = 1.0; // max poll period.
|
double pollPeriod = 1.0; // max poll period.
|
||||||
for(it = mRequests.begin(); it != mRequests.end();)
|
|
||||||
{
|
|
||||||
if (checkForRequest(it->mToken))
|
|
||||||
{
|
|
||||||
/* clean it up and handle */
|
|
||||||
loadRequest(*it);
|
|
||||||
it = mRequests.erase(it);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* calculate desired poll period */
|
|
||||||
|
|
||||||
/* if less then current poll period, adjust */
|
TokenRequestV2 req;
|
||||||
|
|
||||||
it++;
|
if(mRequests.size() > 0){
|
||||||
}
|
req = mRequests.front();
|
||||||
}
|
}else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkForRequest(req.mToken))
|
||||||
|
{
|
||||||
|
/* clean it up and handle */
|
||||||
|
loadRequest(req);
|
||||||
|
mRequests.pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
if (mRequests.size() > 0)
|
if (mRequests.size() > 0)
|
||||||
{
|
{
|
||||||
|
@ -178,7 +175,7 @@ bool TokenQueueV2::cancelRequest(const uint32_t token)
|
||||||
/* cancel at lower level first */
|
/* cancel at lower level first */
|
||||||
mService->cancelRequest(token);
|
mService->cancelRequest(token);
|
||||||
|
|
||||||
std::list<TokenRequestV2>::iterator it;
|
std::list<TokenRequestV2>::iterator it;
|
||||||
|
|
||||||
for(it = mRequests.begin(); it != mRequests.end(); it++)
|
for(it = mRequests.begin(); it != mRequests.end(); it++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -64,9 +64,8 @@ class TokenResponseV2
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
*
|
* An important thing to note is that all requests are stacked (so FIFO)
|
||||||
*
|
* This is to prevent overlapped loads on GXS UIs
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class TokenQueueV2: public QWidget
|
class TokenQueueV2: public QWidget
|
||||||
{
|
{
|
||||||
|
@ -110,7 +109,7 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* Info for Data Requests */
|
/* Info for Data Requests */
|
||||||
std::list<TokenRequestV2> mRequests;
|
std::list<TokenRequestV2> mRequests;
|
||||||
|
|
||||||
RsTokenServiceV2 *mService;
|
RsTokenServiceV2 *mService;
|
||||||
TokenResponseV2 *mResponder;
|
TokenResponseV2 *mResponder;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue