emergency commit, computer acting up bad!

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5565 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2012-09-17 22:08:23 +00:00
parent 4f470090b2
commit eaa7342165
39 changed files with 1835 additions and 2080 deletions

View file

@ -193,8 +193,8 @@ freebsd-* {
# ###########################################
bitdht {
LIBS += ../../libbitdht/src/lib/libbitdht.a
PRE_TARGETDEPS *= ../../libbitdht/src/lib/libbitdht.a
LIBS += C:\Development\Rs\v0.5-gxs-b1\libbitdht\libbitdht-build-desktop\lib\libbitdht.a
PRE_TARGETDEPS *= C:\Development\Rs\v0.5-gxs-b1\libbitdht\libbitdht-build-desktop\lib\libbitdht.a
# Chris version.
#LIBS += ../../libbitdht/libbitdht-build-desktop/lib/libbitdht.a
@ -416,7 +416,8 @@ HEADERS += rshare.h \
gui/groups/CreateGroup.h \
gui/dht/DhtWindow.h \
gui/bwctrl/BwCtrlWindow.h \
gui/GetStartedDialog.h
gui/GetStartedDialog.h \
gui/PhotoShare/PhotoCommentItem.h
@ -520,7 +521,7 @@ FORMS += gui/StartDialog.ui \
gui/dht/DhtWindow.ui \
gui/bwctrl/BwCtrlWindow.ui \
gui/GetStartedDialog.ui \
gui/PhotoShare/PhotoCommentItem.ui
SOURCES += main.cpp \
rshare.cpp \
gui/notifyqt.cpp \
@ -699,7 +700,8 @@ SOURCES += main.cpp \
gui/groups/CreateGroup.cpp \
gui/dht/DhtWindow.cpp \
gui/bwctrl/BwCtrlWindow.cpp \
gui/GetStartedDialog.cpp
gui/GetStartedDialog.cpp \
gui/PhotoShare/PhotoCommentItem.cpp
RESOURCES += gui/images.qrc lang/lang.qrc gui/help/content/content.qrc
@ -862,7 +864,6 @@ SOURCES += gui/unfinished/ApplicationWindow.cpp \
photoshare {
HEADERS += \
gui/PhotoShare/PhotoDialog.h \
gui/PhotoShare/PhotoDrop.h \
gui/PhotoShare/AlbumItem.h \
gui/PhotoShare/AlbumDialog.h \
@ -872,6 +873,7 @@ photoshare {
gui/PhotoShare/PhotoShareItemHolder.h \
gui/PhotoShare/PhotoShare.h \
gui/PhotoShare/PhotoSlideShow.h \
gui/PhotoShare/PhotoDialog.h
FORMS += \
gui/PhotoShare/PhotoItem.ui \
@ -880,7 +882,7 @@ photoshare {
gui/PhotoShare/AlbumDialog.ui \
gui/PhotoShare/AlbumCreateDialog.ui \
gui/PhotoShare/PhotoShare.ui \
gui/PhotoShare/PhotoSlideShow.ui \
gui/PhotoShare/PhotoSlideShow.ui
SOURCES += \
gui/PhotoShare/PhotoItem.cpp \
@ -892,7 +894,7 @@ photoshare {
util/TokenQueueV2.cpp \
gui/PhotoShare/PhotoShareItemHolder.cpp \
gui/PhotoShare/PhotoShare.cpp \
gui/PhotoShare/PhotoSlideShow.cpp \
gui/PhotoShare/PhotoSlideShow.cpp
}

View file

@ -55,7 +55,7 @@ void AlbumItem::setSelected(bool on)
update();
}
RsPhotoAlbum AlbumItem::getAlbum()
const RsPhotoAlbum& AlbumItem::getAlbum()
{
return mAlbum;
}

View file

@ -16,9 +16,9 @@ class AlbumItem : public QWidget, public PhotoShareItem
public:
explicit AlbumItem(const RsPhotoAlbum& album, PhotoShareItemHolder* albumHolder, QWidget *parent = 0);
~AlbumItem();
virtual ~AlbumItem();
RsPhotoAlbum getAlbum();
const RsPhotoAlbum& getAlbum();
bool isSelected() { return mSelected ;}
void setSelected(bool selected);

View file

@ -0,0 +1,14 @@
#include "PhotoCommentItem.h"
#include "ui_PhotoCommentItem.h"
PhotoCommentItem::PhotoCommentItem(QWidget *parent) :
QWidget(parent),
ui(new Ui::PhotoCommentItem)
{
ui->setupUi(this);
}
PhotoCommentItem::~PhotoCommentItem()
{
delete ui;
}

View file

@ -0,0 +1,22 @@
#ifndef PHOTOCOMMENTITEM_H
#define PHOTOCOMMENTITEM_H
#include <QWidget>
namespace Ui {
class PhotoCommentItem;
}
class PhotoCommentItem : public QWidget
{
Q_OBJECT
public:
explicit PhotoCommentItem(QWidget *parent = 0);
~PhotoCommentItem();
private:
Ui::PhotoCommentItem *ui;
};
#endif // PHOTOCOMMENTITEM_H

View file

@ -0,0 +1,21 @@
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>PhotoCommentItem</class>
<widget class="QWidget" name="PhotoCommentItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<pixmapfunction/>
<connections/>
</ui>

View file

@ -1,648 +1,33 @@
/*
* Retroshare Photo Plugin.
*
* Copyright 2012-2012 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "PhotoDialog.h"
#include <retroshare/rspeers.h>
#include <retroshare/rsphotoV2.h>
#include <gxs/rsgxsflags.h>
#include <iostream>
#include <sstream>
#include <QTimer>
#include <QMessageBox>
#include "AlbumCreateDialog.h"
#include "AlbumItem.h"
#include "PhotoItem.h"
/******
* #define PHOTO_DEBUG 1
*****/
/****************************************************************
* New Photo Display Widget.
*
* This has two 'lists'.
* Top list shows Albums.
* Lower list is photos from the selected Album.
*
* Notes:
* Each Item will be an AlbumItem, which contains a thumbnail & random details.
* We will limit Items to < 100. With a 'Filter to see more message.
*
* Thumbnails will come from Service.
* Option to Share albums / pictures onward (if permissions allow).
* Option to Download the albums to a specified directory. (is this required if sharing an album?)
*
* Will introduce a FullScreen SlideShow later... first get basics happening.
*/
#define IS_ALBUM_ADMIN(subscribeFlags) (subscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN)
#define IS_ALBUM_SUBSCRIBED(subscribeFlags) (subscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED)
/** Constructor */
PhotoDialog::PhotoDialog(QWidget *parent)
: MainPage(parent)
{
ui.setupUi(this);
mAlbumSelected = NULL;
mPhotoSelected = NULL;
mSlideShow = NULL;
mAlbumDialog = NULL;
connect( ui.toolButton_NewAlbum, SIGNAL(clicked()), this, SLOT(createAlbum()));
connect( ui.toolButton_ViewAlbum, SIGNAL(clicked()), this, SLOT(OpenAlbumDialog()));
connect( ui.toolButton_SlideShow, SIGNAL(clicked()), this, SLOT(OpenSlideShow()));
connect( ui.pushButton_YourAlbums, SIGNAL(clicked()), this, SLOT(updateAlbums()));
connect( ui.pushButton_SharedAlbums, SIGNAL(clicked()), this, SLOT(updateAlbums()));
connect( ui.pushButton_SubscribedAlbums, SIGNAL(clicked()), this, SLOT(updateAlbums()));
ui.pushButton_YourAlbums->setChecked(true); // default to your albums view
QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
timer->start(1000);
/* setup TokenQueue */
mPhotoQueue = new TokenQueueV2(rsPhotoV2->getTokenService(), this);
requestAlbumData();
updateAlbums();
}
void PhotoDialog::notifySelection(PhotoShareItem *selection)
{
AlbumItem* aItem;
PhotoItem* pItem;
if((aItem = dynamic_cast<AlbumItem*>(selection)) != NULL)
{
if(mPhotoSelected)
mPhotoSelected->setSelected(false);
clearPhotos();
if(mAlbumSelected == aItem)
{
mAlbumSelected->setSelected(true);
}
else
{
if(mAlbumSelected == NULL)
{
mAlbumSelected = aItem;
}
else
{
mAlbumSelected->setSelected(false);
mAlbumSelected = aItem;
}
mAlbumSelected->setSelected(true);
}
updatePhotos();
}
else if((pItem = dynamic_cast<PhotoItem*>(selection)) != NULL)
{
if(mPhotoSelected == pItem)
{
mPhotoSelected->setSelected(true);
}
else
{
if(mPhotoSelected == NULL)
{
mPhotoSelected = pItem;
}
else
{
mPhotoSelected->setSelected(false);
mPhotoSelected = pItem;
}
mPhotoSelected->setSelected(true);
}
}
else
{
}
}
void PhotoDialog::checkUpdate()
{
/* update */
if (!rsPhotoV2)
return;
if (rsPhotoV2->updated())
{
//insertAlbums();
std::list<std::string> grpIds;
rsPhotoV2->groupsChanged(grpIds);
if(!grpIds.empty())
requestAlbumList(grpIds);
GxsMsgIdResult res;
rsPhotoV2->msgsChanged(res);
if(!res.empty())
requestPhotoList(res);
}
return;
}
/*************** New Photo Dialog ***************/
void PhotoDialog::OpenSlideShow()
{
// TODO.
if (!mAlbumSelected)
{
// ALERT.
int ret = QMessageBox::information(this, tr("PhotoShare"),
tr("Please select an album before\n"
"requesting to edit it!"),
QMessageBox::Ok);
return;
}
std::string albumId = mAlbumSelected->getAlbum().mMeta.mGroupId;
if (mSlideShow)
{
mSlideShow->show();
}
else
{
mSlideShow = new PhotoSlideShow(NULL);
mSlideShow->show();
}
mSlideShow->loadAlbum(albumId);
}
/*************** New Photo Dialog ***************/
void PhotoDialog::createAlbum()
{
AlbumCreateDialog albumCreate(mPhotoQueue, rsPhotoV2, this);
albumCreate.exec();
}
void PhotoDialog::OpenAlbumDialog()
{
if(mAlbumSelected){
if(mAlbumDialog == NULL)
{
mAlbumDialog = new AlbumDialog(mAlbumSelected->getAlbum(), mPhotoQueue, rsPhotoV2);
connect(mAlbumDialog, SIGNAL(destroyed()), this, SLOT(SetDialogClosed()));
mAlbumDialog->show();
}else{
// bring dialog to front
mAlbumDialog->raise();
}
}
return;
}
void PhotoDialog::SetDialogClosed()
{
mAlbumDialog = NULL;
}
/*************** Edit Photo Dialog ***************/
void PhotoDialog::clearAlbums()
{
std::cerr << "PhotoDialog::clearAlbums()" << std::endl;
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
QSetIterator<AlbumItem*> sit(mAlbumItems);
while(sit.hasNext())
{
AlbumItem* item = sit.next();
alayout->removeWidget(item);
item->setParent(NULL);
}
clearPhotos();
}
void PhotoDialog::clearPhotos()
{
std::cerr << "PhotoDialog::clearPhotos()" << std::endl;
mPhotoSelected = NULL;
QLayout *layout = ui.scrollAreaWidgetContents_2->layout();
if(mAlbumSelected)
{
const RsGxsGroupId& id = mAlbumSelected->getAlbum().mMeta.mGroupId;
QSetIterator<PhotoItem*> sit(mPhotoItems[id]);
while(sit.hasNext())
{
PhotoItem* item = sit.next();
layout->removeWidget(item);
item->setParent(NULL);
}
}
}
void PhotoDialog::updateAlbums()
{
clearAlbums();
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
QSetIterator<AlbumItem*> sit(mAlbumItems);
if(ui.pushButton_YourAlbums->isChecked())
{
ui.toolButton_subscribe->setEnabled(false);
ui.toolButton_NewAlbum->setEnabled(true);
ui.toolButton_SlideShow->setEnabled(true);
while(sit.hasNext()){
AlbumItem* item = sit.next();
uint32_t flags = item->getAlbum().mMeta.mSubscribeFlags;
if(IS_ALBUM_ADMIN(flags))
alayout->addWidget(item);
}
}else if(ui.pushButton_SubscribedAlbums->isChecked())
{
ui.toolButton_subscribe->setEnabled(false);
ui.toolButton_NewAlbum->setEnabled(false);
ui.toolButton_SlideShow->setEnabled(true);
while(sit.hasNext()){
AlbumItem* item = sit.next();
uint32_t flags = item->getAlbum().mMeta.mSubscribeFlags;
if(IS_ALBUM_SUBSCRIBED(flags))
alayout->addWidget(item);
}
}else if(ui.pushButton_SharedAlbums->isChecked())
{
ui.toolButton_subscribe->setEnabled(true);
ui.toolButton_NewAlbum->setEnabled(false);
ui.toolButton_SlideShow->setEnabled(false);
while(sit.hasNext()){
AlbumItem* item = sit.next();
uint32_t flags = item->getAlbum().mMeta.mSubscribeFlags;
if(flags == 0)
alayout->addWidget(item);
}
}
}
void PhotoDialog::addAlbum(const RsPhotoAlbum &album)
{
std::cerr << " PhotoDialog::addAlbum() AlbumId: " << album.mMeta.mGroupId << std::endl;
AlbumItem *item = new AlbumItem(album, this, this);
mAlbumItems.insert(item);
clearAlbums();
updateAlbums();
}
void PhotoDialog::addPhoto(const RsPhotoPhoto &photo)
{
std::cerr << "PhotoDialog::addPhoto() AlbumId: " << photo.mMeta.mGroupId;
std::cerr << " PhotoId: " << photo.mMeta.mMsgId;
std::cerr << std::endl;
PhotoItem* item = new PhotoItem(this, photo, this);
const RsGxsGroupId id = photo.mMeta.mGroupId;
mPhotoItems[id].insert(item);
}
void PhotoDialog::subscribeToAlbum()
{
if(mAlbumSelected){
RsGxsGroupId id = mAlbumSelected->getAlbum().mMeta.mGroupId;
uint32_t token;
rsPhotoV2->subscribeToAlbum(token, id);
mPhotoQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
}
}
void PhotoDialog::updatePhotos()
{
clearPhotos();
if(mAlbumSelected)
{
const RsGxsGroupId& grpId = mAlbumSelected->getAlbum().mMeta.mGroupId;
QSetIterator<PhotoItem*> sit(mPhotoItems[grpId]);
while(sit.hasNext())
{
QLayout *layout = ui.scrollAreaWidgetContents_2->layout();
layout->addWidget(sit.next());
}
}
}
/**************************** Request / Response Filling of Data ************************/
void PhotoDialog::requestAlbumList(std::list<std::string>& ids)
{
RsTokReqOptionsV2 opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_IDS;
uint32_t token;
mPhotoQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, ids, 0);
}
void PhotoDialog::requestPhotoList(GxsMsgReq& req)
{
RsTokReqOptionsV2 opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_IDS;
uint32_t token;
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, req, 0);
return;
}
void PhotoDialog::loadAlbumList(const uint32_t &token)
{
std::cerr << "PhotoDialog::loadAlbumList()";
std::cerr << std::endl;
std::list<std::string> albumIds;
rsPhotoV2->getGroupList(token, albumIds);
requestAlbumData(albumIds);
clearPhotos();
std::list<std::string>::iterator it;
for(it = albumIds.begin(); it != albumIds.end(); it++)
{
requestPhotoList(*it);
}
}
void PhotoDialog::requestAlbumData(std::list<RsGxsGroupId> &ids)
{
RsTokReqOptionsV2 opts;
uint32_t token;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
mPhotoQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, ids, 0);
}
void PhotoDialog::requestAlbumData()
{
RsTokReqOptionsV2 opts;
uint32_t token;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
mPhotoQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, 0);
}
bool PhotoDialog::loadAlbumData(const uint32_t &token)
{
std::cerr << "PhotoDialog::loadAlbumData()";
std::cerr << std::endl;
std::vector<RsPhotoAlbum> albums;
rsPhotoV2->getAlbum(token, albums);
std::vector<RsPhotoAlbum>::iterator vit = albums.begin();
for(; vit != albums.end(); vit++)
{
RsPhotoAlbum& album = *vit;
std::cerr << " PhotoDialog::addAlbum() AlbumId: " << album.mMeta.mGroupId << std::endl;
addAlbum(album);
}
updateAlbums();
return true;
}
void PhotoDialog::requestPhotoList(const std::string &albumId)
{
std::list<RsGxsGroupId> grpIds;
grpIds.push_back(albumId);
RsTokReqOptionsV2 opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_IDS;
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
uint32_t token;
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, grpIds, 0);
}
void PhotoDialog::acknowledgeGroup(const uint32_t &token)
{
RsGxsGroupId grpId;
rsPhotoV2->acknowledgeGrp(token, grpId);
if(!grpId.empty())
{
std::list<RsGxsGroupId> grpIds;
grpIds.push_back(grpId);
RsTokReqOptionsV2 opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
uint32_t reqToken;
mPhotoQueue->requestGroupInfo(reqToken, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, 0);
}
}
void PhotoDialog::acknowledgeMessage(const uint32_t &token)
{
std::pair<RsGxsGroupId, RsGxsMessageId> p;
rsPhotoV2->acknowledgeMsg(token, p);
if(!p.first.empty())
{
GxsMsgReq req;
std::vector<RsGxsMessageId> v;
v.push_back(p.second);
req[p.first] = v;
RsTokReqOptionsV2 opts;
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
uint32_t reqToken;
mPhotoQueue->requestMsgInfo(reqToken, RS_TOKREQ_ANSTYPE_DATA, opts, req, 0);
}
}
void PhotoDialog::loadPhotoList(const uint32_t &token)
{
std::cerr << "PhotoDialog::loadPhotoList()";
std::cerr << std::endl;
GxsMsgIdResult res;
rsPhotoV2->getMsgList(token, res);
requestPhotoData(res);
}
void PhotoDialog::requestPhotoData(GxsMsgReq &photoIds)
{
RsTokReqOptionsV2 opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
uint32_t token;
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, photoIds, 0);
}
void PhotoDialog::loadPhotoData(const uint32_t &token)
{
std::cerr << "PhotoDialog::loadPhotoData()";
std::cerr << std::endl;
PhotoResult res;
rsPhotoV2->getPhoto(token, res);
PhotoResult::iterator mit = res.begin();
for(; mit != res.end(); mit++)
{
std::vector<RsPhotoPhoto>& photoV = mit->second;
std::vector<RsPhotoPhoto>::iterator vit = photoV.begin();
for(; vit != photoV.end(); vit++)
{
RsPhotoPhoto& photo = *vit;
addPhoto(photo);
std::cerr << "PhotoDialog::loadPhotoData() AlbumId: " << photo.mMeta.mGroupId;
std::cerr << " PhotoId: " << photo.mMeta.mMsgId;
std::cerr << std::endl;
}
}
updatePhotos();
}
/**************************** Request / Response Filling of Data ************************/
void PhotoDialog::loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &req)
{
std::cerr << "PhotoDialog::loadRequest()";
std::cerr << std::endl;
if (queue == mPhotoQueue)
{
/* now switch on req */
switch(req.mType)
{
case TOKENREQ_GROUPINFO:
switch(req.mAnsType)
{
case RS_TOKREQ_ANSTYPE_LIST:
loadAlbumList(req.mToken);
break;
case RS_TOKREQ_ANSTYPE_DATA:
loadAlbumData(req.mToken);
break;
case RS_TOKREQ_ANSTYPE_ACK:
acknowledgeGroup(req.mToken);
break;
default:
std::cerr << "PhotoDialog::loadRequest() ERROR: GROUP: INVALID ANS TYPE";
std::cerr << std::endl;
break;
}
break;
case TOKENREQ_MSGINFO:
switch(req.mAnsType)
{
case RS_TOKREQ_ANSTYPE_LIST:
loadPhotoList(req.mToken);
break;
case RS_TOKREQ_ANSTYPE_ACK:
acknowledgeMessage(req.mToken);
break;
case RS_TOKREQ_ANSTYPE_DATA:
loadPhotoData(req.mToken);
break;
default:
std::cerr << "PhotoDialog::loadRequest() ERROR: MSG: INVALID ANS TYPE";
std::cerr << std::endl;
break;
}
break;
case TOKENREQ_MSGRELATEDINFO:
switch(req.mAnsType)
{
case RS_TOKREQ_ANSTYPE_DATA:
loadPhotoData(req.mToken);
break;
default:
std::cerr << "PhotoDialog::loadRequest() ERROR: MSG: INVALID ANS TYPE";
std::cerr << std::endl;
break;
}
break;
default:
std::cerr << "PhotoDialog::loadRequest() ERROR: INVALID TYPE";
std::cerr << std::endl;
break;
}
}
}
/**************************** Request / Response Filling of Data ************************/
#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)
{
ui->setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true );
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));
}
void PhotoDialog::loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &req)
{
}

View file

@ -1,113 +1,37 @@
/*
* Retroshare Photo Plugin.
*
* Copyright 2012-2012 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef MRK_PHOTO_DIALOG_H
#define MRK_PHOTO_DIALOG_H
#include "retroshare-gui/mainpage.h"
#include "ui_PhotoDialog.h"
#include "AlbumCreateDialog.h"
#include "AlbumDialog.h"
#include "AlbumItem.h"
#include "PhotoItem.h"
#include "PhotoSlideShow.h"
#include <retroshare/rsphotoV2.h>
#include <map>
#include "util/TokenQueueV2.h"
#include "PhotoShareItemHolder.h"
class PhotoDialog : public MainPage, public TokenResponseV2, public PhotoShareItemHolder
{
Q_OBJECT
public:
PhotoDialog(QWidget *parent = 0);
void notifySelection(PhotoShareItem* selection);
private slots:
void checkUpdate();
void createAlbum();
void OpenAlbumDialog();
void OpenSlideShow();
void SetDialogClosed();
void updateAlbums();
void subscribeToAlbum();
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 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 TokenQueueV2 *queue, const TokenRequestV2 &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 updatePhotos();
private:
AlbumItem* mAlbumSelected;
PhotoItem* mPhotoSelected;
PhotoSlideShow* mSlideShow;
AlbumDialog* mAlbumDialog;
TokenQueueV2 *mPhotoQueue;
/* UI - from Designer */
Ui::PhotoDialog ui;
QSet<AlbumItem*> mAlbumItems;
QMap<RsGxsGroupId, QSet<PhotoItem*> > mPhotoItems;
};
#endif
#ifndef PHOTODIALOG_H
#define PHOTODIALOG_H
#include <QDialog>
#include "retroshare/rsphotoV2.h"
#include "util/TokenQueueV2.h"
namespace Ui {
class PhotoDialog;
}
class PhotoDialog : public QDialog, public TokenResponseV2
{
Q_OBJECT
public:
explicit PhotoDialog(RsPhotoV2* rs_photo, const RsPhotoPhoto& photo, QWidget *parent = 0);
~PhotoDialog();
private slots:
void addComment();
public:
void loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &req);
private:
void setUp();
private:
Ui::PhotoDialog *ui;
RsPhotoV2* mRsPhoto;
TokenQueueV2* mPhotoQueue;
RsPhotoPhoto mPhotoDetails;
};
#endif // PHOTODIALOG_H

View file

@ -1,195 +1,234 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PhotoDialog</class>
<widget class="QWidget" name="PhotoDialog">
<widget class="QDialog" name="PhotoDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>774</width>
<height>608</height>
<width>516</width>
<height>449</height>
</rect>
</property>
<property name="windowTitle">
<string>Photo Share</string>
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QGroupBox" name="sortGroup">
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="pushButton_YourAlbums">
<property name="text">
<string>Your Albums</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_SubscribedAlbums">
<property name="text">
<string>Subscribed Albums</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_SharedAlbums">
<property name="text">
<string>Shared Albums</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QGroupBox" name="albumGroup">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Photo</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_Photo">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>300</height>
</size>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>200</height>
</size>
</property>
<property name="title">
<string>Summary</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_Title">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Caption</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_Caption">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Where:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_Where">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_When">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Photo Title:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>When</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="toolButton_SlideShow">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<property name="text">
<string>Slide Show</string>
<string>Add Comment</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_ViewAlbum">
<property name="text">
<string>View Album / Add Photos</string>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_subscribe">
<property name="text">
<string>Subscribe To Album</string>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_NewAlbum">
<property name="text">
<string>Create Album</string>
</property>
</widget>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
<widget class="QScrollArea" name="scrollArea_2">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>496</width>
<height>69</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
<property name="styleSheet">
<string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>754</width>
<height>261</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>139</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
<widget class="QScrollArea" name="scrollArea_2">
<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">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>754</width>
<height>260</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>426</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<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

@ -1,14 +1,716 @@
/*
* Retroshare Photo Plugin.
*
* Copyright 2012-2012 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "PhotoShare.h"
#include "ui_PhotoShare.h"
PhotoShare::PhotoShare(QWidget *parent) :
QWidget(parent),
ui(new Ui::PhotoShare)
#include <retroshare/rspeers.h>
#include <retroshare/rsphotoV2.h>
#include <gxs/rsgxsflags.h>
#include <iostream>
#include <sstream>
#include <QTimer>
#include <QMessageBox>
#include "AlbumCreateDialog.h"
#include "AlbumItem.h"
#include "PhotoItem.h"
/******
* #define PHOTO_DEBUG 1
*****/
/****************************************************************
* New Photo Display Widget.
*
* This has two 'lists'.
* Top list shows Albums.
* Lower list is photos from the selected Album.
*
* Notes:
* Each Item will be an AlbumItem, which contains a thumbnail & random details.
* We will limit Items to < 100. With a 'Filter to see more message.
*
* Thumbnails will come from Service.
* Option to Share albums / pictures onward (if permissions allow).
* Option to Download the albums to a specified directory. (is this required if sharing an album?)
*
* Will introduce a FullScreen SlideShow later... first get basics happening.
*/
#define IS_ALBUM_ADMIN(subscribeFlags) (subscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN)
#define IS_ALBUM_SUBSCRIBED(subscribeFlags) (subscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED)
#define IS_ALBUM_N_SUBSCR_OR_ADMIN(subscribeFlags) ((subscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_MASK) == 0)
/** Constructor */
PhotoShare::PhotoShare(QWidget *parent)
: MainPage(parent)
{
ui->setupUi(this);
ui.setupUi(this);
mAlbumSelected = NULL;
mPhotoSelected = NULL;
mSlideShow = NULL;
mAlbumDialog = NULL;
mPhotoDialog = NULL;
connect( ui.toolButton_NewAlbum, SIGNAL(clicked()), this, SLOT(createAlbum()));
connect( ui.toolButton_ViewAlbum, SIGNAL(clicked()), this, SLOT(OpenAlbumDialog()));
connect( ui.toolButton_SlideShow, SIGNAL(clicked()), this, SLOT(OpenSlideShow()));
connect( ui.toolButton_subscribe, SIGNAL(clicked()), this, SLOT(subscribeToAlbum()));
connect(ui.toolButton_ViewPhoto, SIGNAL(clicked()), this, SLOT(OpenPhotoDialog()));
connect( ui.pushButton_YourAlbums, SIGNAL(clicked()), this, SLOT(updateAlbums()));
connect( ui.pushButton_SharedAlbums, SIGNAL(clicked()), this, SLOT(updateAlbums()));
connect( ui.pushButton_SubscribedAlbums, SIGNAL(clicked()), this, SLOT(updateAlbums()));
ui.pushButton_YourAlbums->setChecked(true); // default to your albums view
QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
timer->start(1000);
/* setup TokenQueue */
mPhotoQueue = new TokenQueueV2(rsPhotoV2->getTokenService(), this);
requestAlbumData();
updateAlbums();
}
PhotoShare::~PhotoShare()
void PhotoShare::notifySelection(PhotoShareItem *selection)
{
delete ui;
AlbumItem* aItem;
PhotoItem* pItem;
if((aItem = dynamic_cast<AlbumItem*>(selection)) != NULL)
{
if(mPhotoSelected)
mPhotoSelected->setSelected(false);
clearPhotos();
if(mAlbumSelected == aItem)
{
mAlbumSelected->setSelected(true);
}
else
{
if(mAlbumSelected == NULL)
{
mAlbumSelected = aItem;
}
else
{
mAlbumSelected->setSelected(false);
mAlbumSelected = aItem;
}
mAlbumSelected->setSelected(true);
}
updatePhotos();
}
else if((pItem = dynamic_cast<PhotoItem*>(selection)) != NULL)
{
if(mPhotoSelected == pItem)
{
mPhotoSelected->setSelected(true);
}
else
{
if(mPhotoSelected == NULL)
{
mPhotoSelected = pItem;
}
else
{
mPhotoSelected->setSelected(false);
mPhotoSelected = pItem;
}
mPhotoSelected->setSelected(true);
}
}
else
{
}
}
void PhotoShare::checkUpdate()
{
/* update */
if (!rsPhotoV2)
return;
if (rsPhotoV2->updated())
{
//insertAlbums();
std::list<std::string> grpIds;
rsPhotoV2->groupsChanged(grpIds);
if(!grpIds.empty())
requestAlbumList(grpIds);
GxsMsgIdResult res;
rsPhotoV2->msgsChanged(res);
if(!res.empty())
requestPhotoList(res);
}
return;
}
/*************** New Photo Dialog ***************/
void PhotoShare::OpenSlideShow()
{
// TODO.
if (!mAlbumSelected)
{
// ALERT.
int ret = QMessageBox::information(this, tr("PhotoShare"),
tr("Please select an album before\n"
"requesting to edit it!"),
QMessageBox::Ok);
return;
}
std::string albumId = mAlbumSelected->getAlbum().mMeta.mGroupId;
if (mSlideShow)
{
mSlideShow->show();
}
else
{
mSlideShow = new PhotoSlideShow(NULL);
mSlideShow->show();
}
mSlideShow->loadAlbum(albumId);
}
/*************** New Photo Dialog ***************/
void PhotoShare::createAlbum()
{
AlbumCreateDialog albumCreate(mPhotoQueue, rsPhotoV2, this);
albumCreate.exec();
}
void PhotoShare::OpenAlbumDialog()
{
if(mAlbumSelected){
if(mAlbumDialog == NULL)
{
mAlbumDialog = new AlbumDialog(mAlbumSelected->getAlbum(), mPhotoQueue, rsPhotoV2);
connect(mAlbumDialog, SIGNAL(destroyed()), this, SLOT(SetAlbumDialogClosed()));
mAlbumDialog->show();
}else{
// bring dialog to front
mAlbumDialog->raise();
}
}
return;
}
void PhotoShare::OpenPhotoDialog()
{
if(mPhotoSelected)
{
if(mPhotoDialog == NULL)
{
mPhotoDialog = new PhotoDialog(rsPhotoV2, mPhotoSelected->getPhotoDetails());
connect(mPhotoDialog, SIGNAL(destroyed()), this, SLOT(SetPhotoDialogClosed()));
mPhotoDialog->show();
}
else
{
mPhotoDialog->raise();
}
}
}
void PhotoShare::SetAlbumDialogClosed()
{
mAlbumDialog = NULL;
}
void PhotoShare::SetPhotoDialogClosed()
{
mPhotoDialog = NULL;
}
/*************** Edit Photo Dialog ***************/
void PhotoShare::clearAlbums()
{
std::cerr << "PhotoShare::clearAlbums()" << std::endl;
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
QSetIterator<AlbumItem*> sit(mAlbumItems);
while(sit.hasNext())
{
AlbumItem* item = sit.next();
alayout->removeWidget(item);
item->setParent(NULL);
}
clearPhotos();
// set no albums to be selected
if(mAlbumSelected)
{
mAlbumSelected->setSelected(false);
mAlbumSelected = NULL;
}
}
void PhotoShare::deleteAlbums()
{
std::cerr << "PhotoShare::clearAlbums()" << std::endl;
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
QSetIterator<AlbumItem*> sit(mAlbumItems);
while(sit.hasNext())
{
AlbumItem* item = sit.next();
alayout->removeWidget(item);
delete item;
}
mAlbumItems.clear();
mAlbumSelected = NULL;
}
void PhotoShare::clearPhotos()
{
std::cerr << "PhotoShare::clearPhotos()" << std::endl;
mPhotoSelected = NULL;
QLayout *layout = ui.scrollAreaWidgetContents_2->layout();
if(mAlbumSelected)
{
const RsGxsGroupId& id = mAlbumSelected->getAlbum().mMeta.mGroupId;
QSetIterator<PhotoItem*> sit(mPhotoItems[id]);
while(sit.hasNext())
{
PhotoItem* item = sit.next();
layout->removeWidget(item);
item->setParent(NULL);
}
}
}
void PhotoShare::updateAlbums()
{
clearAlbums();
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
QSetIterator<AlbumItem*> sit(mAlbumItems);
if(ui.pushButton_YourAlbums->isChecked())
{
ui.toolButton_subscribe->setEnabled(false);
ui.toolButton_NewAlbum->setEnabled(true);
ui.toolButton_SlideShow->setEnabled(true);
while(sit.hasNext()){
AlbumItem* item = sit.next();
uint32_t flags = item->getAlbum().mMeta.mSubscribeFlags;
if(IS_ALBUM_ADMIN(flags))
alayout->addWidget(item);
}
}else if(ui.pushButton_SubscribedAlbums->isChecked())
{
ui.toolButton_subscribe->setEnabled(true);
ui.toolButton_subscribe->setText("Unsubscribe From Album");
ui.toolButton_NewAlbum->setEnabled(false);
ui.toolButton_SlideShow->setEnabled(true);
while(sit.hasNext()){
AlbumItem* item = sit.next();
uint32_t flags = item->getAlbum().mMeta.mSubscribeFlags;
if(IS_ALBUM_SUBSCRIBED(flags))
alayout->addWidget(item);
}
}else if(ui.pushButton_SharedAlbums->isChecked())
{
ui.toolButton_subscribe->setEnabled(true);
ui.toolButton_subscribe->setText("Subscribe To Album");
ui.toolButton_NewAlbum->setEnabled(false);
ui.toolButton_SlideShow->setEnabled(false);
while(sit.hasNext()){
AlbumItem* item = sit.next();
uint32_t flags = item->getAlbum().mMeta.mSubscribeFlags;
if(IS_ALBUM_N_SUBSCR_OR_ADMIN(flags))
alayout->addWidget(item);
}
}
}
void PhotoShare::addAlbum(const RsPhotoAlbum &album)
{
std::cerr << " PhotoShare::addAlbum() AlbumId: " << album.mMeta.mGroupId << std::endl;
AlbumItem *item = new AlbumItem(album, this, this);
mAlbumItems.insert(item);
}
void PhotoShare::addPhoto(const RsPhotoPhoto &photo)
{
std::cerr << "PhotoShare::addPhoto() AlbumId: " << photo.mMeta.mGroupId;
std::cerr << " PhotoId: " << photo.mMeta.mMsgId;
std::cerr << std::endl;
PhotoItem* item = new PhotoItem(this, photo, this);
const RsGxsGroupId id = photo.mMeta.mGroupId;
mPhotoItems[id].insert(item);
}
void PhotoShare::subscribeToAlbum()
{
if(mAlbumSelected){
RsGxsGroupId id = mAlbumSelected->getAlbum().mMeta.mGroupId;
uint32_t token;
if(IS_ALBUM_SUBSCRIBED(mAlbumSelected->getAlbum().mMeta.mSubscribeFlags))
rsPhotoV2->subscribeToAlbum(token, id, false);
else if(IS_ALBUM_ADMIN(mAlbumSelected->getAlbum().mMeta.mSubscribeFlags))
return;
else if(IS_ALBUM_N_SUBSCR_OR_ADMIN(
mAlbumSelected->getAlbum().mMeta.mSubscribeFlags))
rsPhotoV2->subscribeToAlbum(token, id, true);
else
return;
mPhotoQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
}
}
void PhotoShare::updatePhotos()
{
clearPhotos();
if(mAlbumSelected)
{
const RsGxsGroupId& grpId = mAlbumSelected->getAlbum().mMeta.mGroupId;
QSetIterator<PhotoItem*> sit(mPhotoItems[grpId]);
while(sit.hasNext())
{
QLayout *layout = ui.scrollAreaWidgetContents_2->layout();
layout->addWidget(sit.next());
}
}
}
/**************************** Request / Response Filling of Data ************************/
void PhotoShare::requestAlbumList(std::list<std::string>& ids)
{
RsTokReqOptionsV2 opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_IDS;
uint32_t token;
mPhotoQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, ids, 0);
}
void PhotoShare::requestPhotoList(GxsMsgReq& req)
{
RsTokReqOptionsV2 opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_IDS;
uint32_t token;
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, req, 0);
return;
}
void PhotoShare::loadAlbumList(const uint32_t &token)
{
std::cerr << "PhotoShare::loadAlbumList()";
std::cerr << std::endl;
std::list<std::string> albumIds;
rsPhotoV2->getGroupList(token, albumIds);
requestAlbumData(albumIds);
clearPhotos();
std::list<std::string>::iterator it;
for(it = albumIds.begin(); it != albumIds.end(); it++)
{
requestPhotoList(*it);
}
}
void PhotoShare::requestAlbumData(std::list<RsGxsGroupId> &ids)
{
RsTokReqOptionsV2 opts;
uint32_t token;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
mPhotoQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, ids, 0);
}
void PhotoShare::requestAlbumData()
{
RsTokReqOptionsV2 opts;
uint32_t token;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
mPhotoQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, 0);
}
bool PhotoShare::loadAlbumData(const uint32_t &token)
{
deleteAlbums();
std::cerr << "PhotoShare::loadAlbumData()";
std::cerr << std::endl;
std::vector<RsPhotoAlbum> albums;
rsPhotoV2->getAlbum(token, albums);
std::vector<RsPhotoAlbum>::iterator vit = albums.begin();
for(; vit != albums.end(); vit++)
{
RsPhotoAlbum& album = *vit;
std::cerr << " PhotoShare::addAlbum() AlbumId: " << album.mMeta.mGroupId << std::endl;
addAlbum(album);
}
updateAlbums();
return true;
}
void PhotoShare::requestPhotoList(const std::string &albumId)
{
std::list<RsGxsGroupId> grpIds;
grpIds.push_back(albumId);
RsTokReqOptionsV2 opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_IDS;
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
uint32_t token;
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, grpIds, 0);
}
void PhotoShare::acknowledgeGroup(const uint32_t &token)
{
RsGxsGroupId grpId;
rsPhotoV2->acknowledgeGrp(token, grpId);
if(!grpId.empty())
{
std::list<RsGxsGroupId> grpIds;
grpIds.push_back(grpId);
RsTokReqOptionsV2 opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
uint32_t reqToken;
mPhotoQueue->requestGroupInfo(reqToken, RS_TOKREQ_ANSTYPE_DATA, opts, 0);
}
}
void PhotoShare::acknowledgeMessage(const uint32_t &token)
{
std::pair<RsGxsGroupId, RsGxsMessageId> p;
rsPhotoV2->acknowledgeMsg(token, p);
if(!p.first.empty())
{
GxsMsgReq req;
std::vector<RsGxsMessageId> v;
v.push_back(p.second);
req[p.first] = v;
RsTokReqOptionsV2 opts;
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
uint32_t reqToken;
mPhotoQueue->requestMsgInfo(reqToken, RS_TOKREQ_ANSTYPE_DATA, opts, req, 0);
}
}
void PhotoShare::loadPhotoList(const uint32_t &token)
{
std::cerr << "PhotoShare::loadPhotoList()";
std::cerr << std::endl;
GxsMsgIdResult res;
rsPhotoV2->getMsgList(token, res);
requestPhotoData(res);
}
void PhotoShare::requestPhotoData(GxsMsgReq &photoIds)
{
RsTokReqOptionsV2 opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
uint32_t token;
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, photoIds, 0);
}
void PhotoShare::loadPhotoData(const uint32_t &token)
{
std::cerr << "PhotoShare::loadPhotoData()";
std::cerr << std::endl;
PhotoResult res;
rsPhotoV2->getPhoto(token, res);
PhotoResult::iterator mit = res.begin();
for(; mit != res.end(); mit++)
{
std::vector<RsPhotoPhoto>& photoV = mit->second;
std::vector<RsPhotoPhoto>::iterator vit = photoV.begin();
for(; vit != photoV.end(); vit++)
{
RsPhotoPhoto& photo = *vit;
addPhoto(photo);
std::cerr << "PhotoShare::loadPhotoData() AlbumId: " << photo.mMeta.mGroupId;
std::cerr << " PhotoId: " << photo.mMeta.mMsgId;
std::cerr << std::endl;
}
}
updatePhotos();
}
/**************************** Request / Response Filling of Data ************************/
void PhotoShare::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_GROUPINFO:
switch(req.mAnsType)
{
case RS_TOKREQ_ANSTYPE_LIST:
loadAlbumList(req.mToken);
break;
case RS_TOKREQ_ANSTYPE_DATA:
loadAlbumData(req.mToken);
break;
case RS_TOKREQ_ANSTYPE_ACK:
acknowledgeGroup(req.mToken);
break;
default:
std::cerr << "PhotoShare::loadRequest() ERROR: GROUP: INVALID ANS TYPE";
std::cerr << std::endl;
break;
}
break;
case TOKENREQ_MSGINFO:
switch(req.mAnsType)
{
case RS_TOKREQ_ANSTYPE_LIST:
loadPhotoList(req.mToken);
break;
case RS_TOKREQ_ANSTYPE_ACK:
acknowledgeMessage(req.mToken);
break;
case RS_TOKREQ_ANSTYPE_DATA:
loadPhotoData(req.mToken);
break;
default:
std::cerr << "PhotoShare::loadRequest() ERROR: MSG: INVALID ANS TYPE";
std::cerr << std::endl;
break;
}
break;
case TOKENREQ_MSGRELATEDINFO:
switch(req.mAnsType)
{
case RS_TOKREQ_ANSTYPE_DATA:
loadPhotoData(req.mToken);
break;
default:
std::cerr << "PhotoShare::loadRequest() ERROR: MSG: INVALID ANS TYPE";
std::cerr << std::endl;
break;
}
break;
default:
std::cerr << "PhotoShare::loadRequest() ERROR: INVALID TYPE";
std::cerr << std::endl;
break;
}
}
}
/**************************** Request / Response Filling of Data ************************/

View file

@ -2,21 +2,98 @@
#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/TokenQueueV2.h"
#include "PhotoShareItemHolder.h"
namespace Ui {
class PhotoShare;
}
class PhotoShare : public QWidget
class PhotoShare : public MainPage, public TokenResponseV2, public PhotoShareItemHolder
{
Q_OBJECT
Q_OBJECT
public:
explicit PhotoShare(QWidget *parent = 0);
~PhotoShare();
PhotoShare(QWidget *parent = 0);
void notifySelection(PhotoShareItem* selection);
private slots:
void checkUpdate();
void createAlbum();
void OpenAlbumDialog();
void OpenPhotoDialog();
void OpenSlideShow();
void SetAlbumDialogClosed();
void SetPhotoDialogClosed();
void updateAlbums();
void subscribeToAlbum();
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 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 TokenQueueV2 *queue, const TokenRequestV2 &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();
void updatePhotos();
private:
Ui::PhotoShare *ui;
AlbumItem* mAlbumSelected;
PhotoItem* mPhotoSelected;
PhotoSlideShow* mSlideShow;
AlbumDialog* mAlbumDialog;
PhotoDialog* mPhotoDialog;
TokenQueueV2 *mPhotoQueue;
/* UI - from Designer */
Ui::PhotoShare ui;
QSet<AlbumItem*> mAlbumItems;
QMap<RsGxsGroupId, QSet<PhotoItem*> > mPhotoItems;
};
#endif // PHOTOSHARE_H

View file

@ -1,21 +1,211 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>PhotoShare</class>
<widget class="QWidget" name="PhotoShare">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>824</width>
<height>569</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="sortGroup">
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="pushButton_YourAlbums">
<property name="text">
<string>Your Albums</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_SubscribedAlbums">
<property name="text">
<string>Subscribed Albums</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_SharedAlbums">
<property name="text">
<string>Shared Albums</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QToolButton" name="toolButton_SlideShow">
<property name="text">
<string>Slide Show</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_ViewAlbum">
<property name="text">
<string>View Album / Add Photos</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_subscribe">
<property name="text">
<string>Subscribe To Album</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_NewAlbum">
<property name="text">
<string>Create Album</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<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">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>804</width>
<height>228</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>139</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
<widget class="QScrollArea" name="scrollArea_2">
<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">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>804</width>
<height>227</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>426</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QToolButton" name="toolButton_ViewPhoto">
<property name="text">
<string>View Photo</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<pixmapfunction/>
<resources/>
<connections/>
</ui>

View file

@ -32,7 +32,7 @@
#include <retroshare/rsiface.h>
#include "gui/PhotoShare/PhotoDialog.h"
#include "gui/PhotoShare/PhotoShare.h"
// THESE HAVE TO BE CONVERTED TO VEG FORMAT
#if USE_VEG_SERVICE
@ -104,9 +104,9 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
createPageAction(QIcon(IMAGE_LIBRARY), tr("Identities"), grp));
#endif
PhotoDialog *photoDialog = NULL;
ui.stackPages->add(photoDialog = new PhotoDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_PHOTO), tr("Photo View"), grp));
PhotoShare *photoShare = NULL;
ui.stackPages->add(photoShare = new PhotoShare(ui.stackPages),
createPageAction(QIcon(IMAGE_PHOTO), tr("Photo Share"), grp));
// THESE HAVE TO BE CONVERTED TO VEG FORMAT
#if USE_VEG_SERVICE

View file

@ -66,6 +66,16 @@ bool TokenQueueV2::requestMsgInfo(uint32_t &token, uint32_t anstype, const RsTok
return true;
}
bool TokenQueueV2::requestMsgRelatedInfo(uint32_t &token, const RsTokReqOptionsV2 &opts, const std::list<RsGxsGroupId> &grpIds, uint32_t usertype)
{
uint32_t basictype = TOKENREQ_MSGINFO;
uint32_t anstype = RS_TOKREQ_ANSTYPE_LIST; // always a list answer
mService->requestMsgRelatedInfo(token, anstype, opts, ids);
queueRequest(token, basictype, anstype, usertype);
return true;
}
bool TokenQueueV2::requestMsgInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptionsV2 &opts,
const std::list<RsGxsGroupId> &grpIds, uint32_t usertype)
@ -143,7 +153,9 @@ void TokenQueueV2::pollRequests()
bool TokenQueueV2::checkForRequest(uint32_t token)
{
/* check token */
return (RsTokenServiceV2::GXS_REQUEST_STATUS_COMPLETE == mService->requestStatus(token));
uint32_t status = mService->requestStatus(token);
return ( (RsTokenServiceV2::GXS_REQUEST_STATUS_FAILED == status) ||
(RsTokenServiceV2::GXS_REQUEST_STATUS_COMPLETE == status) );
}

View file

@ -93,6 +93,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 std::list<RsGxsGroupId>& grpIds, uint32_t usertype);
bool cancelRequest(const uint32_t token);