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

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



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

View file

@ -2,12 +2,12 @@ CONFIG += qt gui uic qrc resources uitools idle bitdht
# Below is for GXS services.
CONFIG += photoshare
#CONFIG += wikipoos
#CONFIG += thewire
#CONFIG += wikipoos
#CONFIG += thewire
#CONFIG += identities
#CONFIG += forumsv2
#CONFIG += posted
CONFIG += unfinished
#CONFIG += forumsv2
#CONFIG += posted
CONFIG += unfinished
#CONFIG += gxsgui
#CONFIG += pluginmgr
@ -417,7 +417,7 @@ HEADERS += rshare.h \
gui/dht/DhtWindow.h \
gui/bwctrl/BwCtrlWindow.h \
gui/GetStartedDialog.h \
gui/PhotoShare/PhotoCommentItem.h
@ -520,8 +520,7 @@ FORMS += gui/StartDialog.ui \
gui/style/StyleDialog.ui \
gui/dht/DhtWindow.ui \
gui/bwctrl/BwCtrlWindow.ui \
gui/GetStartedDialog.ui \
gui/PhotoShare/PhotoCommentItem.ui
gui/GetStartedDialog.ui
SOURCES += main.cpp \
rshare.cpp \
gui/notifyqt.cpp \
@ -700,8 +699,8 @@ SOURCES += main.cpp \
gui/groups/CreateGroup.cpp \
gui/dht/DhtWindow.cpp \
gui/bwctrl/BwCtrlWindow.cpp \
gui/GetStartedDialog.cpp \
gui/PhotoShare/PhotoCommentItem.cpp
gui/GetStartedDialog.cpp
RESOURCES += gui/images.qrc lang/lang.qrc gui/help/content/content.qrc
@ -873,7 +872,9 @@ photoshare {
gui/PhotoShare/PhotoShareItemHolder.h \
gui/PhotoShare/PhotoShare.h \
gui/PhotoShare/PhotoSlideShow.h \
gui/PhotoShare/PhotoDialog.h
gui/PhotoShare/PhotoDialog.h \
gui/PhotoShare/PhotoCommentItem.h \
gui/PhotoShare/AddCommentDialog.h
FORMS += \
gui/PhotoShare/PhotoItem.ui \
@ -882,7 +883,9 @@ photoshare {
gui/PhotoShare/AlbumDialog.ui \
gui/PhotoShare/AlbumCreateDialog.ui \
gui/PhotoShare/PhotoShare.ui \
gui/PhotoShare/PhotoSlideShow.ui
gui/PhotoShare/PhotoSlideShow.ui \
gui/PhotoShare/PhotoCommentItem.ui \
gui/PhotoShare/AddCommentDialog.ui
SOURCES += \
gui/PhotoShare/PhotoItem.cpp \
@ -894,7 +897,9 @@ photoshare {
util/TokenQueueV2.cpp \
gui/PhotoShare/PhotoShareItemHolder.cpp \
gui/PhotoShare/PhotoShare.cpp \
gui/PhotoShare/PhotoSlideShow.cpp
gui/PhotoShare/PhotoSlideShow.cpp \
gui/PhotoShare/PhotoCommentItem.cpp \
gui/PhotoShare/AddCommentDialog.cpp
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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