Addition of two more Services / Applications.

(1) A PhotoService / Dialog to share slideshows.
(2) A Network View service, derived from p3disc for a graphical view of peers.
Both of these need a little help to get them fully functional.




git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@375 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-03-04 21:31:11 +00:00
parent 3ed1eef186
commit 08860b25e6
28 changed files with 3297 additions and 235 deletions

View File

@ -0,0 +1,48 @@
#ifndef RETROSHARE_DISC_GUI_INTERFACE_H
#define RETROSHARE_DISC_GUI_INTERFACE_H
/*
* libretroshare/src/rsiface: rsdisc.h
*
* RetroShare C++ Interface.
*
* Copyright 2008-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include <inttypes.h>
#include <string>
#include <list>
/* The Main Interface Class - for information about your Peers */
class RsDisc;
extern RsDisc *rsDisc;
class RsDisc
{
public:
RsDisc() { return; }
virtual ~RsDisc() { return; }
virtual bool getDiscFriends(std::string id, std::list<std::string> &friends) = 0;
};
#endif

View File

@ -0,0 +1,122 @@
#ifndef RETROSHARE_PHOTO_GUI_INTERFACE_H
#define RETROSHARE_PHOTO_GUI_INTERFACE_H
/*
* libretroshare/src/rsiface: rsphoto.h
*
* RetroShare C++ Interface.
*
* Copyright 2008-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include <inttypes.h>
#include <string>
#include <list>
/* The Main Interface Class - for information about your Peers */
class RsPhoto;
extern RsPhoto *rsPhoto;
class RsPhotoDetails;
class RsPhotoShowDetails;
class RsPhotoShowInfo
{
public:
std::string photoId;
std::wstring altComment;
uint32_t deltaT; /* in 100ths of sec? */
};
class RsPhotoShowDetails
{
public:
RsPhotoShowDetails();
std::string id;
std::string showid;
std::string name;
std::wstring location;
std::wstring comment;
std::string date;
std::list<RsPhotoShowInfo> photos;
};
/* Details class */
class RsPhotoDetails
{
public:
RsPhotoDetails();
std::string id;
std::string srcid;
std::string hash;
std::string name;
std::wstring location;
std::wstring comment;
std::string date;
uint32_t format;
bool isAvailable;
std::string path;
};
std::ostream &operator<<(std::ostream &out, const RsPhotoShowDetails &detail);
std::ostream &operator<<(std::ostream &out, const RsPhotoDetails &detail);
class RsPhoto
{
public:
RsPhoto() { return; }
virtual ~RsPhoto() { return; }
/* access data */
virtual bool getPhotoList(std::string id, std::list<std::string> hashs) = 0;
virtual bool getShowList(std::string id, std::list<std::string> showIds) = 0;
virtual bool getShowDetails(std::string id, std::string showId, RsPhotoShowDetails &detail) = 0;
virtual bool getPhotoDetails(std::string id, std::string photoId, RsPhotoDetails &detail) = 0;
/* add / delete */
virtual std::string createShow(std::string name) = 0;
virtual bool deleteShow(std::string showId) = 0;
virtual bool addPhotoToShow(std::string showId, std::string photoId, int16_t index) = 0;
virtual bool movePhotoInShow(std::string showId, std::string photoId, int16_t index) = 0;
virtual bool removePhotoFromShow(std::string showId, std::string photoId) = 0;
virtual std::string addPhoto(std::string path) = 0; /* add from file */
virtual bool addPhoto(std::string srcId, std::string photoId) = 0; /* add from peers photos */
virtual bool deletePhoto(std::string photoId) = 0;
/* modify properties (TODO) */
virtual bool modifyShow(std::string showId, std::wstring name, std::wstring comment) = 0;
virtual bool modifyPhoto(std::string photoId, std::wstring name, std::wstring comment) = 0;
virtual bool modifyShowComment(std::string showId, std::string photoId, std::wstring comment) = 0;
};
#endif

View File

@ -9,14 +9,16 @@ include $(RS_TOP_DIR)/scripts/config.mk
RSOBJ = p3peers.o \
p3rank.o \
p3photo.o \
p3msgs.o \
p3discovery.o \
p3face-file.o \
p3face-server.o \
p3face-config.o \
p3face-startup.o \
p3face-msgs.o \
rstypes.o \
rsiface.o \
p3face-msgs.o
rsiface.o
# pqistrings.o \
# p3face-people.o

View File

@ -0,0 +1,40 @@
/*
* libretroshare/src/rsserver: p3discovery.cc
*
* RetroShare C++ Interface.
*
* Copyright 2008-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "rsserver/p3discovery.h"
#include <iostream>
#include <sstream>
RsDisc *rsDisc = NULL;
bool p3Discovery::getDiscFriends(std::string id, std::list<std::string> &friends)
{
if (mDisc)
{
return mDisc->potentialproxies(id, friends);
}
return false;
}

View File

@ -0,0 +1,48 @@
#ifndef RETROSHARE_P3_DISC_INTERFACE_H
#define RETROSHARE_P3_DISC_INTERFACE_H
/*
* libretroshare/src/rsserver: p3discovery.h
*
* RetroShare C++ Interface.
*
* Copyright 2008-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "rsiface/rsdisc.h"
#include "services/p3disc.h"
class p3Discovery: public RsDisc
{
public:
p3Discovery(p3disc *disc)
:mDisc(disc) { return; }
virtual ~p3Discovery() { return; }
virtual bool getDiscFriends(std::string id, std::list<std::string> &friends);
private:
p3disc *mDisc;
};
#endif

View File

@ -47,6 +47,7 @@
#include "services/p3chatservice.h"
#include "services/p3gamelauncher.h"
#include "services/p3ranking.h"
#include "services/p3photoservice.h"
#include <list>
#include <string>
@ -55,10 +56,13 @@
// for blocking signals
#include <signal.h>
/* Implemented Rs Interfaces */
#include "rsserver/p3face.h"
#include "rsserver/p3peers.h"
#include "rsserver/p3rank.h"
#include "rsserver/p3msgs.h"
#include "rsserver/p3discovery.h"
#include "rsserver/p3photo.h"
#include "rsiface/rsgame.h"
/**************** PQI_USE_XPGP ******************/
@ -522,6 +526,13 @@ int RsServer::StartupRetroShare(RsInit *config)
CachePair cp(mRanking, mRanking, CacheId(RS_SERVICE_TYPE_RANK, 0));
mCacheStrapper -> addCachePair(cp);
p3PhotoService *photoService = new p3PhotoService(RS_SERVICE_TYPE_PHOTO,
mCacheStrapper, mCacheTransfer,
localcachedir, remotecachedir);
CachePair cp2(photoService, photoService, CacheId(RS_SERVICE_TYPE_PHOTO, 0));
mCacheStrapper -> addCachePair(cp2);
/**************************************************************************/
mConnMgr->setDhtMgr(mDhtMgr);
@ -661,6 +672,8 @@ int RsServer::StartupRetroShare(RsInit *config)
rsGameLauncher = gameLauncher;
rsRanks = new p3Rank(mRanking);
rsMsgs = new p3Msgs(mAuthMgr, msgSrv, chatSrv);
rsDisc = new p3Discovery(ad);
rsPhoto = new p3Photo(photoService);
/* put a welcome message in! */
if (config->firsttime_run)

View File

@ -0,0 +1,137 @@
/*
* libretroshare/src/rsserver: p3photo.cc
*
* RetroShare C++ Interface.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "rsserver/p3photo.h"
#include "services/p3photoservice.h"
RsPhoto *rsPhoto = NULL;
RsPhotoDetails::RsPhotoDetails()
{
return;
}
RsPhotoShowDetails::RsPhotoShowDetails()
{
return;
}
p3Photo::p3Photo(p3PhotoService *p3ps)
:mPhoto(p3ps)
{
return;
}
p3Photo::~p3Photo()
{
return;
}
/* access data */
bool p3Photo::getPhotoList(std::string id, std::list<std::string> hashs)
{
return mPhoto->getPhotoList(id, hashs);
}
bool p3Photo::getShowList(std::string id, std::list<std::string> showIds)
{
return mPhoto -> getShowList(id, showIds);
}
bool p3Photo::getShowDetails(std::string id, std::string showId, RsPhotoShowDetails &detail)
{
return mPhoto -> getShowDetails(id, showId, detail);
}
bool p3Photo::getPhotoDetails(std::string id, std::string photoId, RsPhotoDetails &detail)
{
return mPhoto -> getPhotoDetails(id, photoId, detail);
}
/* add / delete */
std::string p3Photo::createShow(std::string name)
{
return mPhoto -> createShow(name);
}
bool p3Photo::deleteShow(std::string showId)
{
return mPhoto -> deleteShow(showId);
}
bool p3Photo::addPhotoToShow(std::string showId, std::string photoId, int16_t index)
{
return mPhoto -> addPhotoToShow(showId, photoId, index);
}
bool p3Photo::movePhotoInShow(std::string showId, std::string photoId, int16_t index)
{
return mPhoto -> movePhotoInShow(showId, photoId, index);
}
bool p3Photo::removePhotoFromShow(std::string showId, std::string photoId)
{
return mPhoto -> removePhotoFromShow(showId, photoId);
}
std::string p3Photo::addPhoto(std::string path) /* add from file */
{
return mPhoto -> addPhoto(path); /* add from file */
}
bool p3Photo::addPhoto(std::string srcId, std::string photoId) /* add from peers photos */
{
return mPhoto -> addPhoto(srcId, photoId); /* add from peers photos */
}
bool p3Photo::deletePhoto(std::string photoId)
{
return mPhoto -> deletePhoto(photoId);
}
/* modify properties (TODO) */
bool p3Photo::modifyShow(std::string showId, std::wstring name, std::wstring comment)
{
return mPhoto -> modifyShow(showId, name, comment);
}
bool p3Photo::modifyPhoto(std::string photoId, std::wstring name, std::wstring comment)
{
return mPhoto -> modifyPhoto(photoId, name, comment);
}
bool p3Photo::modifyShowComment(std::string showId, std::string photoId, std::wstring comment)
{
return mPhoto -> modifyShowComment(showId, photoId, comment);
}

View File

@ -0,0 +1,66 @@
#ifndef RETROSHARE_P3_PHOTO_INTERFACE_H
#define RETROSHARE_P3_PHOTO_INTERFACE_H
/*
* libretroshare/src/rsserver: p3photo.h
*
* RetroShare C++ Interface.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "rsiface/rsphoto.h"
#include "services/p3photoservice.h"
class p3Photo: public RsPhoto
{
public:
p3Photo(p3PhotoService *p3ps);
virtual ~p3Photo();
/* access data */
virtual bool getPhotoList(std::string id, std::list<std::string> hashs);
virtual bool getShowList(std::string id, std::list<std::string> showIds);
virtual bool getShowDetails(std::string id, std::string showId, RsPhotoShowDetails &detail);
virtual bool getPhotoDetails(std::string id, std::string photoId, RsPhotoDetails &detail);
/* add / delete */
virtual std::string createShow(std::string name);
virtual bool deleteShow(std::string showId);
virtual bool addPhotoToShow(std::string showId, std::string photoId, int16_t index);
virtual bool movePhotoInShow(std::string showId, std::string photoId, int16_t index);
virtual bool removePhotoFromShow(std::string showId, std::string photoId);
virtual std::string addPhoto(std::string path); /* add from file */
virtual bool addPhoto(std::string srcId, std::string photoId); /* add from peers photos */
virtual bool deletePhoto(std::string photoId);
/* modify properties (TODO) */
virtual bool modifyShow(std::string showId, std::wstring name, std::wstring comment);
virtual bool modifyPhoto(std::string photoId, std::wstring name, std::wstring comment);
virtual bool modifyShowComment(std::string showId, std::string photoId, std::wstring comment);
private:
p3PhotoService *mPhoto;
};
#endif

View File

@ -11,6 +11,7 @@ RSOBJ = rsserial.o rsbaseserial.o rstlvbase.o rstlvtypes.o
RSOBJ += rstlvfileitem.o rstlvutil.o # TLV Objs
RSOBJ += rsbaseitems.o rsconfigitems.o rsdiscitems.o # RsItems
RSOBJ += rsmsgitems.o rsrankitems.o # RsItems
RSOBJ += rsphotoitems.o # RsItems
TESTOBJ = tlvbase_test.o tlvbase_test2.o tlvfileitem_test.o
TESTOBJ += tlvitems_test.o tlvstack_test.o tlvconfig_test.o

View File

@ -0,0 +1,290 @@
/*
* libretroshare/src/serialiser: rsphotoitems.cc
*
* RetroShare Serialiser.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "serialiser/rsbaseserial.h"
#include "serialiser/rsphotoitems.h"
#include "serialiser/rstlvbase.h"
#define RSSERIAL_DEBUG 1
#include <iostream>
/*************************************************************************/
void RsPhotoItem::clear()
{
srcId.clear();
photoId.clear();
size = 0;
name.clear();
comment.clear();
location.clear();
date.clear();
/* not serialised */
isAvailable = false;
path.clear();
}
std::ostream &RsPhotoItem::print(std::ostream &out, uint16_t indent)
{
printRsItemBase(out, "RsPhotoItem", indent);
uint16_t int_Indent = indent + 2;
printIndent(out, int_Indent);
out << "srcId: " << srcId << std::endl;
printIndent(out, int_Indent);
out << "photoId: " << photoId << std::endl;
printIndent(out, int_Indent);
out << "size: " << size << std::endl;
printIndent(out, int_Indent);
out << "name: " << name << std::endl;
printIndent(out, int_Indent);
std::string cnv_comment(comment.begin(), comment.end());
out << "msg: " << cnv_comment << std::endl;
printIndent(out, int_Indent);
out << "location: " << location << std::endl;
printIndent(out, int_Indent);
out << "date: " << date << std::endl;
printIndent(out, int_Indent);
out << "(NS) isAvailable: " << isAvailable << std::endl;
printIndent(out, int_Indent);
out << "(NS) path: " << path << std::endl;
printRsItemEnd(out, "RsPhotoItem", indent);
return out;
}
/*************************************************************************/
/*************************************************************************/
void RsPhotoShowItem::clear()
{
showId.clear();
name.clear();
comment.clear();
location.clear();
date.clear();
photos.clear();
}
std::ostream &RsPhotoShowItem::print(std::ostream &out, uint16_t indent)
{
printRsItemBase(out, "RsPhotoShowItem", indent);
uint16_t int_Indent = indent + 2;
uint16_t int_Indent2 = int_Indent + 2;
printIndent(out, int_Indent);
out << "showId: " << showId << std::endl;
printIndent(out, int_Indent);
out << "name: " << name << std::endl;
printIndent(out, int_Indent);
std::string cnv_comment(comment.begin(), comment.end());
out << "msg: " << cnv_comment << std::endl;
printIndent(out, int_Indent);
out << "location: " << location << std::endl;
printIndent(out, int_Indent);
out << "date: " << date << std::endl;
printIndent(out, int_Indent);
out << "Photos in Show: " << photos.size() << std::endl;
std::list<RsPhotoRefItem>::iterator it;
for(it = photos.begin(); it != photos.end(); it++)
{
printIndent(out, int_Indent2);
out << "PhotoId: " << it->photoId << std::endl;
printIndent(out, int_Indent2 + 2);
std::string cnv_comment2(it->altComment.begin(), it->altComment.end());
out << "AltComment: " << cnv_comment2 << std::endl;
printIndent(out, int_Indent2 + 2);
out << "Delta T: " << it->deltaT << std::endl;
}
printRsItemEnd(out, "RsPhotoShowItem", indent);
return out;
}
RsPhotoRefItem::RsPhotoRefItem()
:deltaT(0)
{
return;
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* TODO serialiser */
#if 0
uint32_t RsPhotoSerialiser::sizeLink(RsPhotoLinkMsg *item)
{
uint32_t s = 8; /* header */
s += GetTlvStringSize(item->rid);
s += 4; /* timestamp */
s += GetTlvWideStringSize(item->title);
s += GetTlvWideStringSize(item->comment);
s += 4; /* linktype */
s += GetTlvWideStringSize(item->link);
return s;
}
/* serialise the data to the buffer */
bool RsPhotoSerialiser::serialiseLink(RsPhotoLinkMsg *item, void *data, uint32_t *pktsize)
{
uint32_t tlvsize = sizeLink(item);
uint32_t offset = 0;
if (*pktsize < tlvsize)
return false; /* not enough space */
*pktsize = tlvsize;
bool ok = true;
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
std::cerr << "RsPhotoLinkSerialiser::serialiseLink() Header: " << ok << std::endl;
std::cerr << "RsPhotoLinkSerialiser::serialiseLink() Size: " << tlvsize << std::endl;
/* skip the header */
offset += 8;
/* add mandatory parts first */
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GENID, item->rid);
std::cerr << "RsPhotoLinkSerialiser::serialiseLink() rid: " << ok << std::endl;
ok &= setRawUInt32(data, tlvsize, &offset, item->timestamp);
std::cerr << "RsPhotoLinkSerialiser::serialiseLink() timestamp: " << ok << std::endl;
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_TITLE, item->title);
std::cerr << "RsPhotoLinkSerialiser::serialiseLink() Title: " << ok << std::endl;
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_COMMENT, item->comment);
std::cerr << "RsPhotoLinkSerialiser::serialiseLink() Comment: " << ok << std::endl;
ok &= setRawUInt32(data, tlvsize, &offset, item->linktype);
std::cerr << "RsPhotoLinkSerialiser::serialiseLink() linktype: " << ok << std::endl;
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_LINK, item->link);
std::cerr << "RsPhotoLinkSerialiser::serialiseLink() Link: " << ok << std::endl;
if (offset != tlvsize)
{
ok = false;
std::cerr << "RsPhotoLinkSerialiser::serialiseLink() Size Error! " << std::endl;
}
return ok;
}
RsPhotoLinkMsg *RsPhotoSerialiser::deserialiseLink(void *data, uint32_t *pktsize)
{
/* get the type and size */
uint32_t rstype = getRsItemId(data);
uint32_t rssize = getRsItemSize(data);
uint32_t offset = 0;
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
(RS_SERVICE_TYPE_RANK != getRsItemService(rstype)) ||
(RS_PKT_SUBTYPE_RANK_LINK != getRsItemSubType(rstype)))
{
return NULL; /* wrong type */
}
if (*pktsize < rssize) /* check size */
return NULL; /* not enough data */
/* set the packet length */
*pktsize = rssize;
bool ok = true;
/* ready to load */
RsPhotoLinkMsg *item = new RsPhotoLinkMsg();
item->clear();
/* skip the header */
offset += 8;
/* get mandatory parts first */
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GENID, item->rid);
ok &= getRawUInt32(data, rssize, &offset, &(item->timestamp));
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_TITLE, item->title);
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_COMMENT, item->comment);
ok &= getRawUInt32(data, rssize, &offset, &(item->linktype));
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_LINK, item->link);
if (offset != rssize)
{
/* error */
delete item;
return NULL;
}
if (!ok)
{
delete item;
return NULL;
}
return item;
}
uint32_t RsPhotoSerialiser::size(RsItem *item)
{
return sizeLink((RsPhotoLinkMsg *) item);
}
bool RsPhotoSerialiser::serialise(RsItem *item, void *data, uint32_t *pktsize)
{
return serialiseLink((RsPhotoLinkMsg *) item, data, pktsize);
}
RsItem *RsPhotoSerialiser::deserialise(void *data, uint32_t *pktsize)
{
return deserialiseLink(data, pktsize);
}
#endif
/*************************************************************************/

View File

@ -0,0 +1,138 @@
#ifndef P3_PHOTO_ITEMS_H
#define P3_PHOTO_ITEMS_H
/*
* libretroshare/src/serialiser: rsphotoitems.h
*
* RetroShare Serialiser.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include <map>
#include "serialiser/rsserviceids.h"
#include "serialiser/rsserial.h"
#include "serialiser/rstlvtypes.h"
const uint8_t RS_PKT_SUBTYPE_PHOTO_ITEM = 0x02;
const uint8_t RS_PKT_SUBTYPE_PHOTO_SHOW_ITEM = 0x03;
const uint8_t RS_PKT_SUBTYPE_PHOTO_COMMENT_ITEM = 0x04;
/**************************************************************************/
class RsPhotoItem;
class RsPhotoShowItem;
class RsPhotoCommentItem;
class RsPhotoItem: public RsItem
{
public:
RsPhotoItem()
:RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_PHOTO,
RS_PKT_SUBTYPE_PHOTO_ITEM) { return; }
virtual ~RsPhotoItem() { return; }
virtual void clear();
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
std::string srcId;
std::string photoId; /* same as hash */
uint64_t size; /* file size */
std::string name;
std::wstring comment;
std::string location; /* TODO: change to TLV */
std::string date; /* TODO: change to TLV */
/* not serialised */
bool isAvailable;
std::string path;
};
/* THIS must be turned into a TLV type + set (TOD) */
class RsPhotoRefItem
{
public:
RsPhotoRefItem();
std::string photoId;
std::wstring altComment;
uint32_t deltaT; /* in 100ths of sec? */
};
class RsPhotoShowItem: public RsItem
{
public:
RsPhotoShowItem()
:RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_PHOTO,
RS_PKT_SUBTYPE_PHOTO_SHOW_ITEM) { return; }
virtual ~RsPhotoShowItem() { return; }
virtual void clear();
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
std::string showId;
std::string name;
std::wstring comment;
std::string location; /* TODO -> TLV */
std::string date; /* TODO -> TLV */
std::list<RsPhotoRefItem> photos; /* list as ordered */
};
class RsPhotoSerialiser: public RsSerialType
{
public:
RsPhotoSerialiser()
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_PHOTO)
{ return; }
virtual ~RsPhotoSerialiser()
{ return; }
virtual uint32_t size(RsItem *) { return 0; }
virtual bool serialise (RsItem *item, void *data, uint32_t *size) { return false; }
virtual RsItem * deserialise(void *data, uint32_t *size) { return NULL; }
private:
/* For RS_PKT_SUBTYPE_PHOTO_ITEM */
//virtual uint32_t sizeLink(RsPhotoItem *);
//virtual bool serialiseLink (RsPhotoItem *item, void *data, uint32_t *size);
//virtual RsPhotoItem *deserialiseLink(void *data, uint32_t *size);
/* For RS_PKT_SUBTYPE_PHOTO_SHOW_ITEM */
//virtual uint32_t sizeLink(RsPhotoShowItem *);
//virtual bool serialiseLink (RsPhotoShowItem *item, void *data, uint32_t *size);
//virtual RsPhotoShowItem *deserialiseLink(void *data, uint32_t *size);
/* For RS_PKT_SUBTYPE_PHOTO_COMMENT_ITEM */
//virtual uint32_t sizeLink(RsPhotoCommentItem *);
//virtual bool serialiseLink (RsPhotoCommentItem *item, void *data, uint32_t *size);
//virtual RsPhotoCommentItem *deserialiseLink(void *data, uint32_t *size);
};
/**************************************************************************/
#endif /* RS_PHOTO_ITEMS_H */

View File

@ -40,6 +40,7 @@
/* These are Cache Only */
const uint16_t RS_SERVICE_TYPE_FILE_INDEX = 0x0001;
const uint16_t RS_SERVICE_TYPE_RANK = 0x0002;
const uint16_t RS_SERVICE_TYPE_PHOTO = 0x0003;
/* These are Services only */
const uint16_t RS_SERVICE_TYPE_DISC = 0x0011;

View File

@ -8,7 +8,8 @@ include $(RS_TOP_DIR)/scripts/config.mk
###############################################################
RSOBJ = p3service.o p3chatservice.o p3msgservice.o \
p3gamelauncher.o p3ranking.o p3disc.o
p3gamelauncher.o p3ranking.o p3disc.o \
p3photoservice.o
#TESTOBJ =

View File

@ -656,7 +656,7 @@ int p3disc::addDiscoveryData(std::string fromId, std::string aboutId,
/* Extracting Network Graph Details */
/*************************************************************************************/
bool p3disc::potentialproxies(std::string id, std::list<std::string> proxyIds)
bool p3disc::potentialproxies(std::string id, std::list<std::string> &proxyIds)
{
/* find id -> and extract the neighbour_of ids */

View File

@ -88,6 +88,9 @@ virtual void statusChange(const std::list<pqipeer> &plist);
int tick();
/* GUI requires access */
bool potentialproxies(std::string id, std::list<std::string> &proxyIds);
private:
@ -107,7 +110,6 @@ int addDiscoveryData(std::string fromId, std::string aboutId,
struct sockaddr_in laddr, struct sockaddr_in raddr,
uint32_t flags, time_t ts);
bool potentialproxies(std::string id, std::list<std::string> proxyIds);
int idServers();

View File

@ -0,0 +1,818 @@
/*
* libretroshare/src/services p3ranking.cc
*
* 3P/PQI network interface for RetroShare.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "services/p3photoservice.h"
#include "pqi/pqibin.h"
#include "pqi/p3authmgr.h"
std::string generateRandomShowId();
#define PHOTO_DEBUG 1
PhotoSet::PhotoSet()
{
return;
}
/********************************************************************************/
/******************* Startup / Tick ******************************************/
/********************************************************************************/
p3PhotoService::p3PhotoService(uint16_t type, CacheStrapper *cs, CacheTransfer *cft,
std::string sourcedir, std::string storedir)
:CacheSource(type, true, cs, sourcedir),
CacheStore(type, true, cs, cft, storedir)
{
{ RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
mOwnId = getAuthMgr()->OwnId();
}
// createDummyData();
return;
}
void p3PhotoService::tick()
{
bool repub = false;
{
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
repub = mRepublish;
}
if (repub)
{
//publishPhotos();
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
mRepublish = false;
}
}
/********************************************************************************/
/******************* Cache Interaction ******************************************/
/********************************************************************************/
bool p3PhotoService::loadLocalCache(const CacheData &data)
{
std::string filename = data.path + '/' + data.name;
std::string hash = data.hash;
//uint64_t size = data.size;
std::string source = data.pid;
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::loadLocalCache()";
std::cerr << std::endl;
std::cerr << "\tSource: " << source;
std::cerr << std::endl;
std::cerr << "\tFilename: " << filename;
std::cerr << std::endl;
std::cerr << "\tHash: " << hash;
std::cerr << std::endl;
std::cerr << "\tSize: " << data.size;
std::cerr << std::endl;
#endif
if (data.cid.subid == 0)
{
loadPhotoIndex(filename, hash, source);
}
else
{
availablePhoto(filename, hash, source);
}
{
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
mRepublish = false;
}
if (data.size > 0) /* don't refresh zero sized caches */
{
refreshCache(data);
}
return true;
}
int p3PhotoService::loadCache(const CacheData &data)
{
std::string filename = data.path + '/' + data.name;
std::string hash = data.hash;
//uint64_t size = data.size;
std::string source = data.pid;
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::loadCache()";
std::cerr << std::endl;
std::cerr << "\tSource: " << source;
std::cerr << std::endl;
std::cerr << "\tFilename: " << filename;
std::cerr << std::endl;
std::cerr << "\tHash: " << hash;
std::cerr << std::endl;
std::cerr << "\tSize: " << data.size;
std::cerr << std::endl;
#endif
if (data.cid.subid == 0)
{
loadPhotoIndex(filename, hash, source);
}
else
{
availablePhoto(filename, hash, source);
}
CacheStore::lockData(); /***** LOCK ****/
locked_storeCacheEntry(data);
CacheStore::unlockData(); /***** UNLOCK ****/
return 1;
}
void p3PhotoService::loadPhotoIndex(std::string filename, std::string hash, std::string src)
{
/* create the serialiser to load info */
RsSerialiser *rsSerialiser = new RsSerialiser();
rsSerialiser->addSerialType(new RsPhotoSerialiser());
uint32_t bioflags = BIN_FLAGS_HASH_DATA | BIN_FLAGS_READABLE;
BinInterface *bio = new BinFileInterface(filename.c_str(), bioflags);
pqistreamer *stream = new pqistreamer(rsSerialiser, src, bio, 0);
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::loadPhotoIndex()";
std::cerr << std::endl;
std::cerr << "\tSource: " << src;
std::cerr << std::endl;
std::cerr << "\tHash: " << hash;
std::cerr << std::endl;
std::cerr << "\tFilename: " << filename;
std::cerr << std::endl;
#endif
RsItem *item;
RsPhotoItem *pitem;
RsPhotoShowItem *sitem;
stream->tick(); /* Tick to read! */
while(NULL != (item = stream->GetItem()))
{
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::loadPhotoIndex() Got Item:";
std::cerr << std::endl;
item->print(std::cerr, 10);
std::cerr << std::endl;
#endif
pitem = dynamic_cast<RsPhotoItem *>(item);
sitem = dynamic_cast<RsPhotoShowItem *>(item);
if (pitem)
{
/* photo item */
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::loadPhotoIndex() Loading Photo Item";
std::cerr << std::endl;
#endif
loadPhotoItem(pitem);
}
else if (sitem)
{
/* show item */
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::loadPhotoIndex() Loading Show Item";
std::cerr << std::endl;
#endif
loadPhotoShowItem(sitem);
}
else
{
/* unknown */
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::loadRankFile() Unknown Item (deleting):";
std::cerr << std::endl;
#endif
}
delete item;
stream->tick(); /* Tick to read! */
}
delete stream;
}
bool p3PhotoService::loadPhotoItem(RsPhotoItem *item)
{
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::loadPhotoItem()";
std::cerr << std::endl;
item->print(std::cerr);
std::cerr << std::endl;
#endif
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
PhotoSet &pset = locked_getPhotoSet(item->PeerId());
pset.photos[item->photoId] = item;
return true;
}
bool p3PhotoService::loadPhotoShowItem(RsPhotoShowItem *item)
{
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::loadPhotoShowItem()";
std::cerr << std::endl;
item->print(std::cerr);
std::cerr << std::endl;
#endif
/* add to set */
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
PhotoSet &pset = locked_getPhotoSet(item->PeerId());
pset.shows[item->showId] = item;
//mRepublish = true;
return true;
}
void p3PhotoService::availablePhoto(std::string filename, std::string hash, std::string src)
{
/* TODO */
return;
}
void p3PhotoService::publishPhotos()
{
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::publishPhotos()";
std::cerr << std::endl;
#endif
/* determine filename */
std::string path = CacheSource::getCacheDir();
std::ostringstream out;
out << "photo-index-" << time(NULL) << ".pdx";
std::string tmpname = out.str();
std::string fname = path + "/" + tmpname;
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::publishPhotos() Storing to: " << fname;
std::cerr << std::endl;
#endif
RsSerialiser *rsSerialiser = new RsSerialiser();
rsSerialiser->addSerialType(new RsPhotoSerialiser());
uint32_t bioflags = BIN_FLAGS_HASH_DATA | BIN_FLAGS_WRITEABLE;
BinInterface *bio = new BinFileInterface(fname.c_str(), bioflags);
pqistreamer *stream = new pqistreamer(rsSerialiser, mOwnId, bio,
BIN_FLAGS_NO_DELETE);
{ RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
PhotoSet &pset = locked_getPhotoSet(mOwnId);
std::map<std::string, RsPhotoItem *>::iterator pit;
for(pit = pset.photos.begin(); pit != pset.photos.end(); pit++)
{
RsPhotoItem *pitem = pit->second;
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::publishPhotos() Storing Photo Item:";
std::cerr << std::endl;
pitem->print(std::cerr, 10);
std::cerr << std::endl;
#endif
stream->SendItem(pitem);
stream->tick(); /* Tick to write! */
}
std::map<std::string, RsPhotoShowItem *>::iterator sit;
for(sit = pset.shows.begin(); sit != pset.shows.end(); sit++)
{
RsPhotoShowItem *sitem = sit->second;
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::publishPhotos() Storing PhotoShow Item:";
std::cerr << std::endl;
sitem->print(std::cerr, 10);
std::cerr << std::endl;
#endif
stream->SendItem(sitem);
stream->tick(); /* Tick to write! */
}
} /********** STACK LOCKED MTX ******/
stream->tick(); /* Tick for final write! */
/* flag as new info */
CacheData data;
{ RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
data.pid = mOwnId;
} /********** STACK LOCKED MTX ******/
data.cid = CacheId(CacheSource::getCacheType(), 1);
data.path = path;
data.name = tmpname;
data.hash = bio->gethash();
data.size = bio->bytecount();
data.recvd = time(NULL);
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::publishPhotos() refreshing Cache";
std::cerr << std::endl;
std::cerr << "\tCache Path: " << data.path;
std::cerr << std::endl;
std::cerr << "\tCache Name: " << data.name;
std::cerr << std::endl;
std::cerr << "\tCache Hash: " << data.hash;
std::cerr << std::endl;
std::cerr << "\tCache Size: " << data.size;
std::cerr << std::endl;
#endif
if (data.size > 0) /* don't refresh zero sized caches */
{
refreshCache(data);
}
delete stream;
/* TO HERE
* update Cache (new Photos (all Photos?))
* */
}
/********************************************************************************/
/******************* External Interface *****************************************/
/********************************************************************************/
bool p3PhotoService::getPhotoList(std::string id, std::list<std::string> photoIds)
{
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::getPhotoList() pid: " << id;
std::cerr << std::endl;
#endif
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
PhotoSet &pset = locked_getPhotoSet(id);
/* get the list of photoids */
std::map<std::string, RsPhotoItem *>::iterator pit;
for(pit = pset.photos.begin(); pit != pset.photos.end(); pit++)
{
photoIds.push_back(pit->first);
}
return true;
}
bool p3PhotoService::getShowList(std::string id, std::list<std::string> showIds)
{
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::getShowList() pid: " << id;
std::cerr << std::endl;
#endif
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
PhotoSet &pset = locked_getPhotoSet(id);
/* get the list of showIds */
std::map<std::string, RsPhotoShowItem *>::iterator sit;
for(sit = pset.shows.begin(); sit != pset.shows.end(); sit++)
{
showIds.push_back(sit->first);
}
return true;
}
bool p3PhotoService::getShowDetails(std::string id, std::string showId, RsPhotoShowDetails &detail)
{
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::getShowDetails() pid: " << id;
std::cerr << "showId: " << showId;
std::cerr << std::endl;
#endif
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
RsPhotoShowItem *item = locked_getShow(id, showId);
if (!item)
{
return false;
}
/* extract Show details */
return true;
}
bool p3PhotoService::getPhotoDetails(std::string id, std::string photoId, RsPhotoDetails &detail)
{
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::getPhotoDetails() pid: " << id;
std::cerr << " photoId: " << photoId;
std::cerr << std::endl;
#endif
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
RsPhotoItem *item = locked_getPhoto(id, photoId);
if (!item)
{
return false;
}
/* extract Photo details */
return true;
}
/* add / delete */
std::string p3PhotoService::createShow(std::string name)
{
std::string showId = generateRandomShowId();
RsPhotoShowItem *newShow = new RsPhotoShowItem();
newShow->showId = showId;
newShow->name = name;
/* add to set */
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
PhotoSet &pset = locked_getPhotoSet(mOwnId);
pset.shows[showId] = newShow;
mRepublish = true;
return showId;
}
bool p3PhotoService::deleteShow(std::string showId)
{
/* add to set */
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
PhotoSet &pset = locked_getPhotoSet(mOwnId);
std::map<std::string, RsPhotoShowItem *>::iterator sit;
sit = pset.shows.find(showId);
if (sit == pset.shows.end())
{
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::deleteShow() no existant";
std::cerr << std::endl;
#endif
return false;
}
RsPhotoShowItem *oldShow = sit->second;
pset.shows.erase(sit);
delete oldShow;
mRepublish = true;
return true;
}
bool p3PhotoService::addPhotoToShow(std::string showId, std::string photoId, int16_t index)
{
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::addPhotoToShow() showId: " << showId;
std::cerr << " photoId: " << photoId;
std::cerr << std::endl;
#endif
/* add to set */
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
RsPhotoItem *photo = locked_getPhoto(mOwnId, photoId);
RsPhotoShowItem *show = locked_getShow(mOwnId, showId);
if ((!photo) || (!show))
{
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::addPhotoToShow() NULL data";
std::cerr << std::endl;
#endif
return false;
}
/* can have duplicates so just add it in */
RsPhotoRefItem ref;
ref.photoId = photoId;
/* add in at correct location! */
//uint32_t i = 0;
//for(it = show.photos.begin();
// (i < index) && (it != show.photos.end()); it++, i++);
show->photos.push_back(ref);
mRepublish = true;
return true;
}
bool p3PhotoService::movePhotoInShow(std::string showId, std::string photoId, int16_t index)
{
return false;
}
bool p3PhotoService::removePhotoFromShow(std::string showId, std::string photoId)
{
return false;
}
std::string p3PhotoService::addPhoto(std::string path) /* add from file */
{
/* check file exists */
/* copy to outgoing directory */
/* hash it */
std::string hash = "PHOTO HASH";
/* create item */
RsPhotoItem *item = new RsPhotoItem();
{
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
item->PeerId(mOwnId);
}
item->srcId = item->PeerId();
item->photoId = hash;
item->name = hash;
item->path = path;
/* add in */
loadPhotoItem(item);
/* flag for republish */
{
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
mRepublish = true;
}
return hash;
}
bool p3PhotoService::addPhoto(std::string srcId, std::string photoId) /* add from peers photos */
{
return false;
}
bool p3PhotoService::deletePhoto(std::string photoId)
{
return false;
}
/* modify properties (TODO) */
bool p3PhotoService::modifyShow(std::string showId, std::wstring name, std::wstring comment)
{
return false;
}
bool p3PhotoService::modifyPhoto(std::string photoId, std::wstring name, std::wstring comment)
{
return false;
}
bool p3PhotoService::modifyShowComment(std::string showId, std::string photoId, std::wstring comment)
{
return false;
}
/********************************************************************************/
/******************* Utility Functions ******************************************/
/********************************************************************************/
PhotoSet &p3PhotoService::locked_getPhotoSet(std::string id)
{
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::locked_getPhotoSet() pid: " << id;
std::cerr << std::endl;
#endif
std::map<std::string, PhotoSet>::iterator it;
it = mPhotos.find(id);
if (it == mPhotos.end())
{
/* missing group -> add it in */
PhotoSet pset;
pset.pid = id;
mPhotos[id] = pset;
it = mPhotos.find(id);
}
return (it->second);
}
RsPhotoItem *p3PhotoService::locked_getPhoto(std::string id, std::string photoId)
{
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::locked_getPhoto() pid: " << id;
std::cerr << " photoId: " << photoId;
std::cerr << std::endl;
#endif
PhotoSet &pset = locked_getPhotoSet(id);
std::map<std::string, RsPhotoItem *>::iterator pit;
pit = pset.photos.find(photoId);
if (pit == pset.photos.end())
{
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::getPhotoDetails() Failed - noPhoto";
std::cerr << std::endl;
#endif
return NULL;
}
return pit->second;
}
RsPhotoShowItem *p3PhotoService::locked_getShow(std::string id, std::string showId)
{
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::locked_getShow() pid: " << id;
std::cerr << " showId: " << showId;
std::cerr << std::endl;
#endif
PhotoSet &pset = locked_getPhotoSet(id);
std::map<std::string, RsPhotoShowItem *>::iterator sit;
sit = pset.shows.find(showId);
if (sit == pset.shows.end())
{
#ifdef PHOTO_DEBUG
std::cerr << "p3PhotoService::locked_getShow() Failed - no Show";
std::cerr << std::endl;
#endif
return NULL;
}
return sit->second;
}
std::string generateRandomShowId()
{
std::ostringstream out;
out << std::hex;
/* 4 bytes per random number: 4 x 4 = 16 bytes */
for(int i = 0; i < 4; i++)
{
uint32_t rint = random();
out << rint;
}
return out.str();
}
void p3PhotoService::createDummyData()
{
#if 0
RsRankLinkMsg *msg = new RsRankLinkMsg();
time_t now = time(NULL);
msg->PeerId(mOwnId);
msg->rid = "0001";
msg->title = L"Original Awesome Site!";
msg->timestamp = now - 60 * 60 * 24 * 15;
msg->link = L"http://www.retroshare.org";
msg->comment = L"Retroshares Website";
addRankMsg(msg);
msg = new RsRankLinkMsg();
msg->PeerId(mOwnId);
msg->rid = "0002";
msg->title = L"Awesome Site!";
msg->timestamp = now - 123;
msg->link = L"http://www.lunamutt.org";
msg->comment = L"Lunamutt's Website";
addRankMsg(msg);
msg = new RsRankLinkMsg();
msg->PeerId("ALTID");
msg->rid = "0002";
msg->title = L"Awesome Site!";
msg->timestamp = now - 60 * 60 * 24 * 29;
msg->link = L"http://www.lunamutt.org";
msg->comment = L"Lunamutt's Website (TWO) How Long can this comment be!\n";
msg->comment += L"What happens to the second line?\n";
msg->comment += L"And a 3rd!";
addRankMsg(msg);
msg = new RsRankLinkMsg();
msg->PeerId("ALTID2");
msg->rid = "0002";
msg->title = L"Awesome Site!";
msg->timestamp = now - 60 * 60 * 7;
msg->link = L"http://www.lunamutt.org";
msg->comment += L"A Short Comment";
addRankMsg(msg);
/***** Third one ****/
msg = new RsRankLinkMsg();
msg->PeerId(mOwnId);
msg->rid = "0003";
msg->title = L"Weird Site!";
msg->timestamp = now - 60 * 60;
msg->link = L"http://www.lunamutt.com";
msg->comment = L"";
addRankMsg(msg);
msg = new RsRankLinkMsg();
msg->PeerId("ALTID");
msg->rid = "0003";
msg->title = L"Weird Site!";
msg->timestamp = now - 60 * 60 * 24 * 2;
msg->link = L"http://www.lunamutt.com";
msg->comment = L"";
addRankMsg(msg);
#endif
}

View File

@ -0,0 +1,137 @@
/*
* libretroshare/src/services: p3photoservice.h
*
* 3P/PQI network interface for RetroShare.
*
* Copyright 2008-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef P3_PHOTO_SERVICE_HEADER
#define P3_PHOTO_SERVICE_HEADER
#include "dbase/cachestrapper.h"
#include "pqi/pqiservice.h"
#include "pqi/pqistreamer.h"
#include "serialiser/rsserial.h"
#include "serialiser/rsphotoitems.h"
#include "rsiface/rsphoto.h"
/*
* Photo Service
*/
class PhotoSet
{
public:
PhotoSet();
std::string pid;
std::map<std::string, RsPhotoItem *> photos;
std::map<std::string, RsPhotoShowItem *> shows;
};
class p3PhotoService: public CacheSource, public CacheStore
{
public:
p3PhotoService(uint16_t type, CacheStrapper *cs, CacheTransfer *cft,
std::string sourcedir, std::string storedir);
void tick();
/******************************* CACHE SOURCE / STORE Interface *********************/
/* overloaded functions from Cache Source */
virtual bool loadLocalCache(const CacheData &data);
/* overloaded functions from Cache Store */
virtual int loadCache(const CacheData &data);
/******************************* CACHE SOURCE / STORE Interface *********************/
public:
/************* Extern Interface *******/
/* access data */
bool getPhotoList(std::string id, std::list<std::string> hashs);
bool getShowList(std::string id, std::list<std::string> showIds);
bool getShowDetails(std::string id, std::string showId, RsPhotoShowDetails &detail);
bool getPhotoDetails(std::string id, std::string photoId, RsPhotoDetails &detail);
/* add / delete */
std::string createShow(std::string name);
bool deleteShow(std::string showId);
bool addPhotoToShow(std::string showId, std::string photoId, int16_t index);
bool movePhotoInShow(std::string showId, std::string photoId, int16_t index);
bool removePhotoFromShow(std::string showId, std::string photoId);
std::string addPhoto(std::string path); /* add from file */
bool addPhoto(std::string srcId, std::string photoId); /* add from peers photos */
bool deletePhoto(std::string photoId);
/* modify properties (TODO) */
bool modifyShow(std::string showId, std::wstring name, std::wstring comment);
bool modifyPhoto(std::string photoId, std::wstring name, std::wstring comment);
bool modifyShowComment(std::string showId, std::string photoId, std::wstring comment);
private:
/* cache processing */
void loadPhotoIndex(std::string filename, std::string hash, std::string src);
void availablePhoto(std::string filename, std::string hash, std::string src);
bool loadPhotoItem(RsPhotoItem *item);
bool loadPhotoShowItem(RsPhotoShowItem *item);
void publishPhotos();
/* locate info */
PhotoSet &locked_getPhotoSet(std::string id);
RsPhotoItem *locked_getPhoto(std::string id, std::string photoId);
RsPhotoShowItem *locked_getShow(std::string id, std::string showId);
/* test functions */
void createDummyData();
RsMutex mPhotoMtx;
/***** below here is locked *****/
bool mRepublish;
std::string mOwnId;
std::map<std::string, PhotoSet> mPhotos;
};
#endif

View File

@ -62,6 +62,7 @@ HEADERS += rshare.h \
gui/GamesDialog.h \
gui/PhotoDialog.h \
gui/LinksDialog.h \
gui/NetworkView.h \
gui/MessengerWindow.h \
gui/PeersDialog.h \
gui/SearchDialog.h \
@ -150,6 +151,7 @@ FORMS += gui/ChatDialog.ui \
gui/GamesDialog.ui \
gui/PhotoDialog.ui \
gui/LinksDialog.ui \
gui/NetworkView.ui \
gui/MessengerWindow.ui \
gui/PeersDialog.ui \
gui/SearchDialog.ui \
@ -212,6 +214,7 @@ SOURCES += main.cpp \
gui/GamesDialog.cpp \
gui/PhotoDialog.cpp \
gui/LinksDialog.cpp \
gui/NetworkView.cpp \
gui/MessengerWindow.cpp \
gui/PeersDialog.cpp \
gui/SearchDialog.cpp \

View File

@ -42,6 +42,7 @@
#include "LinksDialog.h"
#include "GamesDialog.h"
#include "NetworkView.h"
#include "PhotoDialog.h"
#include "channels/channelsDialog.h"
@ -103,7 +104,21 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
ui.stackPages->add(gamesDialog = new GamesDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_MESSAGES), tr("Games Launcher"), grp));
NetworkView *networkView = NULL;
ui.stackPages->add(networkView = new NetworkView(ui.stackPages),
createPageAction(QIcon(IMAGE_NETWORK), tr("Network View"), grp));
PhotoDialog *photoDialog = NULL;
ui.stackPages->add(photoDialog = new PhotoDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_CHANNELS), tr("Photo View"), grp));
//ui.stackPages->add(groupsDialog = new GroupsDialog(ui.stackPages),
// createPageAction(QIcon(), tr("Groups"), grp));
//ui.stackPages->add(new StatisticDialog(ui.stackPages),
// createPageAction(QIcon(IMAGE_STATISTIC), tr("Statistics"), grp));
/* Create the toolbar */
ui.toolBar->addActions(grp->actions());
ui.toolBar->addSeparator();

View File

@ -0,0 +1,326 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2008 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "NetworkView.h"
#include "rsiface/rspeers.h"
#include "rsiface/rsdisc.h"
#include <QMenu>
#include <QMouseEvent>
#include <QGraphicsItem>
#include <iostream>
/** Constructor */
NetworkView::NetworkView(QWidget *parent)
: MainPage(parent)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
mScene = new QGraphicsScene();
ui.graphicsView->setScene(mScene);
//connect( ui.linkTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( linkTreeWidgetCostumPopupMenu( QPoint ) ) );
/* link combos */
// connect( ui.rankComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changedSortRank( int ) ) );
// connect( ui.periodComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changedSortPeriod( int ) ) );
// connect( ui.fromComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changedSortFrom( int ) ) );
// connect( ui.topComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changedSortTop( int ) ) );
/* add button */
connect( ui.refreshButton, SIGNAL( clicked( void ) ), this, SLOT( insertPeers( void ) ) );
connect( mScene, SIGNAL( changed ( const QList<QRectF> & ) ), this, SLOT ( changedScene( void ) ) );
/* hide the Tree +/- */
// ui.linkTreeWidget -> setRootIsDecorated( false );
/* Set header resize modes and initial section sizes */
// QHeaderView * _header = ui.linkTreeWidget->header () ;
// _header->setResizeMode (0, QHeaderView::Interactive);
// _header->setResizeMode (1, QHeaderView::Interactive);
// _header->setResizeMode (2, QHeaderView::Interactive);
//
// _header->resizeSection ( 0, 400 );
// _header->resizeSection ( 1, 50 );
// _header->resizeSection ( 2, 150 );
}
void NetworkView::peerCustomPopupMenu( QPoint point )
{
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
//QAction * voteupAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Vote Link Up" ), this );
//connect( voteupAct , SIGNAL( triggered() ), this, SLOT( voteup() ) );
contextMnu.clear();
//contextMnu.addAction(voteupAct);
contextMnu.exec( mevent->globalPos() );
}
void NetworkView::changedFoFCheckBox( )
{
insertPeers();
}
void NetworkView::changedDrawSignatures( )
{
insertPeers();
}
void NetworkView::changedDrawFriends( )
{
insertPeers();
}
void NetworkView::clearPeerItems()
{
std::map<std::string, QGraphicsItem *>::iterator pit;
for(pit = mPeerItems.begin(); pit != mPeerItems.end(); pit++)
{
//mScene->removeItem(pit->second);
mScene->destroyItemGroup((QGraphicsItemGroup *) pit->second);
//delete (pit->second);
}
mPeerItems.clear();
}
void NetworkView::clearOtherItems()
{
std::list<QGraphicsItem *>::iterator oit;
for(oit = mOtherItems.begin(); oit != mOtherItems.end(); oit++)
{
mScene->removeItem(*oit);
delete (*oit);
}
mOtherItems.clear();
}
void NetworkView::clearLineItems()
{
std::list<QGraphicsItem *>::iterator oit;
for(oit = mLineItems.begin(); oit != mLineItems.end(); oit++)
{
mScene->removeItem(*oit);
delete (*oit);
}
mLineItems.clear();
}
void NetworkView::insertPeers()
{
/* clear graphics scene */
clearPeerItems();
clearOtherItems();
/* add all friends */
std::list<std::string> ids;
std::list<std::string>::iterator it;
rsPeers->getOthersList(ids);
ids.push_back(rsPeers->getOwnId()); /* add yourself too */
std::cerr << "NetworkView::insertPeers()" << std::endl;
int i = 0;
for(it = ids.begin(); it != ids.end(); it++, i++)
{
/* *** */
QString name = QString::fromStdString(rsPeers->getPeerName(*it));
QGraphicsTextItem *gti = new QGraphicsTextItem(name);
mScene->addItem(gti);
//QPointF textPoint( i * 10, i * 20);
//gti->setPos(textPoint);
gti->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
gti->setZValue(20);
QRectF textBound = gti->boundingRect();
/* work out bounds for circle */
qreal diameter = textBound.width() + 10;
if (diameter < 40)
diameter = 40;
qreal x = textBound.left() + (textBound.width() / 2.0) - (diameter/ 2.0);
qreal y = textBound.top() + (textBound.height() / 2.0) - (diameter/ 2.0);
QGraphicsEllipseItem *gei = new QGraphicsEllipseItem(x, y, diameter, diameter);
mScene->addItem(gei);
gei->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
gei->setZValue(10);
/* colour depends on Friend... */
if (*it == rsPeers->getOwnId())
{
gei->setBrush(QBrush(Qt::green));
}
else if (rsPeers->isFriend(*it))
{
gei->setBrush(QBrush(Qt::blue));
}
else
{
gei->setBrush(QBrush(Qt::red));
}
QGraphicsItemGroup *gig = new QGraphicsItemGroup();
mScene->addItem(gig);
gig->addToGroup(gei);
gig->addToGroup(gti);
gig->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
//, const QPen & pen = QPen(), const QBrush & brush = QBrush() )
mPeerItems[*it] = gig;
mOtherItems.push_back(gti);
mOtherItems.push_back(gei);
std::cerr << "NetworkView::insertPeers() Added Friend: " << *it << std::endl;
std::cerr << "\t At: " << i*5 << "," << i*10 << std::endl;
}
insertConnections();
}
void NetworkView::insertConnections()
{
clearLineItems();
/* iterate through all peerItems .... and find any proxies */
std::map<std::string, QGraphicsItem *>::const_iterator pit, pit2;
int i = 0;
for(pit = mPeerItems.begin(); pit != mPeerItems.end(); pit++, i++)
{
std::list<std::string> friendList;
std::list<std::string>::iterator it;
rsDisc->getDiscFriends(pit->first, friendList);
int j = 0;
for(it = friendList.begin(); it != friendList.end(); it++)
{
//pit2 = std::find(pit, mPeerItems.end(), *it);
pit2 = mPeerItems.find(*it);
if (pit2 == mPeerItems.end())
{
std::cerr << " Failed to Find: " << *it;
std::cerr << std::endl;
continue; /* missing */
}
if (pit == pit2)
continue; /* skip same one */
std::cerr << " Connecting: " << pit->first << " to " << pit2->first;
std::cerr << std::endl;
QPointF pos1 = (pit->second)->pos();
QRectF bound1 = (pit->second)->boundingRect();
QPointF pos2 = (pit2->second)->pos();
QRectF bound2 = (pit2->second)->boundingRect();
pos1 += QPointF(bound1.width() / 2.0, bound1.height() / 2.0);
pos2 += QPointF(bound2.width() / 2.0, bound2.height() / 2.0);
QLineF line(pos1, pos2);
QGraphicsLineItem *gli = mScene->addLine(line);
mLineItems.push_back(gli);
}
}
/* debugging all lines */
#if 0
/* iterate through all peerItems .... and find any proxies */
std::map<std::string, QGraphicsItem *>::const_iterator pit, pit2;
int i = 0;
for(pit = mPeerItems.begin(); pit != mPeerItems.end(); pit++, i++)
{
int j = 0;
for(pit2 = mPeerItems.begin(); (pit2 != mPeerItems.end()) && (j < i); pit2++, j++)
{
if (pit == pit2)
continue; /* skip same one */
std::cerr << " Connecting: " << pit->first << " to " << pit2->first;
std::cerr << std::endl;
QPointF pos1 = (pit->second)->pos();
QPointF pos2 = (pit2->second)->pos();
QLineF line(pos1, pos2);
QGraphicsLineItem *gli = mScene->addLine(line);
mLineItems.push_back(gli);
}
}
#endif
mLineChanged = true;
}
void NetworkView::changedScene()
{
std::cerr << "NetworkView::changedScene()" << std::endl;
QList<QGraphicsItem *> items = mScene->selectedItems();
std::cerr << "NetworkView::changedScene() Items selected: " << items.size() << std::endl;
/* if an item was selected and moved - then redraw lines */
if (mLineChanged)
{
mLineChanged = false;
return;
}
if (items.size() > 0)
{
mScene->clearSelection();
insertConnections();
}
}

View File

@ -0,0 +1,73 @@
/****************************************************************
* RetroShare GUI is distributed under the following license:
*
* Copyright (C) 2008 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _NETWORK_VIEW_H
#define _NETWORK_VIEW_H
#include <QGraphicsScene>
#include "mainpage.h"
#include "ui_NetworkView.h"
class NetworkView : public MainPage
{
Q_OBJECT
public:
NetworkView(QWidget *parent = 0);
private slots:
/** Create the context popup menu and it's submenus */
void peerCustomPopupMenu( QPoint point );
void insertPeers();
void insertConnections();
void changedScene();
void changedFoFCheckBox( );
void changedDrawSignatures( );
void changedDrawFriends( );
private:
void clearPeerItems();
void clearOtherItems();
void clearLineItems();
QGraphicsScene *mScene;
std::map<std::string, QGraphicsItem *> mPeerItems;
std::list<QGraphicsItem *> mOtherItems;
std::list<QGraphicsItem *> mLineItems;
bool mLineChanged;
/** Qt Designer generated object */
Ui::NetworkView ui;
};
#endif

View File

@ -0,0 +1,76 @@
<ui version="4.0" >
<class>NetworkView</class>
<widget class="QWidget" name="NetworkView" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>479</width>
<height>467</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<layout class="QVBoxLayout" >
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="refreshButton" >
<property name="text" >
<string>Refresh</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>411</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" >
<item>
<widget class="QCheckBox" name="fofCheckBox" >
<property name="text" >
<string>Show Friends of Friends</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox" >
<property name="text" >
<string>Connect Signature</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_2" >
<property name="text" >
<string>Draw Friend Connections</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QGraphicsView" name="graphicsView" />
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -17,15 +17,15 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
****************************************************************/
#include <QFile>
#include <QFile>
#include <QFileInfo>
#include "common/vmessagebox.h"
#include "rshare.h"
#include "PhotoDialog.h"
#include "rsiface/rsiface.h"
#include "common/vmessagebox.h"
#include "PhotoDialog.h"
#include "rsiface/rspeers.h"
#include "rsiface/rsphoto.h"
#include <iostream>
#include <sstream>
@ -40,25 +40,53 @@
#include <QHeaderView>
/* Images for context menu icons */
/* Images for context menu icons */
#define IMAGE_REMOVEFRIEND ":/images/removefriend16.png"
#define IMAGE_EXPIORTFRIEND ":/images/exportpeers_16x16.png"
#define IMAGE_CHAT ":/images/chat.png"
/* Images for Status icons */
#define IMAGE_ONLINE ":/images/donline.png"
#define IMAGE_OFFLINE ":/images/dhidden.png"
/** Constructor */
PhotoDialog::PhotoDialog(QWidget *parent)
#define IMAGE_OFFLINE ":/images/dhidden.png"
#define PHOTO_ICON_SIZE 90
#define PHOTO_PEER_COL_NAME 0
#define PHOTO_PEER_COL_SHOW 1
#define PHOTO_PEER_COL_PHOTO 2
#define PHOTO_PEER_COL_PID 3
#define PHOTO_PEER_COL_SID 4
#define PHOTO_PEER_COL_PHOTOID 5
#define PHOTO_LIST_COL_PHOTO 0
#define PHOTO_LIST_COL_COMMENT 1
#define PHOTO_LIST_COL_PHOTOID 2
/** Constructor */
PhotoDialog::PhotoDialog(QWidget *parent)
: MainPage(parent)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
connect( ui.photoTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( photoTreeWidgetCostumPopupMenu( QPoint ) ) );
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
connect( ui.peerTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( peerTreeWidgetCustomPopupMenu( QPoint ) ) );
connect( ui.photoTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( photoTreeWidgetCustomPopupMenu( QPoint ) ) );
connect( ui.peerTreeWidget, SIGNAL( currentItemChanged ( QTreeWidgetItem * , QTreeWidgetItem * ) ), this, SLOT( updatePhotoList( ) ) );
//connect( ui.photoTreeWidget, SIGNAL( currentItemChanged ( QTreeWidgetItem * , QTreeWidgetItem * ) ), this, SLOT( displayPhoto( ) ) );
//connect( ui.addPhotoButton, SIGNAL( clicked( ) ), this, SLOT( addPhotos( ) ) );
/* hide the Tree +/- */
ui.photoTreeWidget -> setRootIsDecorated( false );
QSize iconSize(PHOTO_ICON_SIZE,PHOTO_ICON_SIZE);
ui.photoTreeWidget->setIconSize(iconSize);
/* Set header resize modes and initial section sizes */
// QHeaderView * _header = ui.peertreeWidget->header () ;
@ -86,31 +114,204 @@ PhotoDialog::PhotoDialog(QWidget *parent)
// _header->resizeSection ( 8, 100 );
// _header->resizeSection ( 9, 100 );
// _header->resizeSection ( 10, 100 );
/* Hide platform specific features */
#ifdef Q_WS_WIN
#endif
}
void PhotoDialog::peertreeWidgetCostumPopupMenu( QPoint point )
{
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
voteupAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Vote Up" ), this );
connect( voteupAct , SIGNAL( triggered() ), this, SLOT( voteup() ) );
votedownAct = new QAction(QIcon(IMAGE_REMOVEFRIEND), tr( "Vote Down" ), this );
connect( votedownAct , SIGNAL( triggered() ), this, SLOT( votedown() ) );
contextMnu.clear();
contextMnu.addAction(voteupAct);
/* Hide platform specific features */
#ifdef Q_WS_WIN
#endif
}
void PhotoDialog::peerTreeWidgetCustomPopupMenu( QPoint point )
{
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
QAction *ins = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Insert Show Lists" ), this );
connect( ins , SIGNAL( triggered() ), this, SLOT( insertShowLists() ) );
contextMnu.clear();
contextMnu.addAction(ins);
contextMnu.exec( mevent->globalPos() );
}
void PhotoDialog::photoTreeWidgetCustomPopupMenu( QPoint point )
{
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
QAction *rm = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Remove" ), this );
connect( rm , SIGNAL( triggered() ), this, SLOT( removePhoto() ) );
contextMnu.clear();
contextMnu.addAction(rm);
contextMnu.addSeparator();
contextMnu.addAction(votedownAct);
contextMnu.exec( mevent->globalPos() );
contextMnu.exec( mevent->globalPos() );
}
void PhotoDialog::insertShowLists()
{
/* clear it all */
ui.peerTreeWidget->clear();
/* iterate through peers */
addShows(rsPeers->getOwnId());
std::list<std::string> ids;
std::list<std::string>::iterator it;
rsPeers->getFriendList(ids);
for(it = ids.begin(); it != ids.end(); it++)
{
addShows(*it);
}
}
void PhotoDialog::addShows(std::string id)
{
std::list<std::string> allPhotos;
std::list<std::string> showIds;
std::list<std::string>::iterator it;
QTreeWidgetItem *peerItem = new QTreeWidgetItem((QTreeWidget*)0);
peerItem->setText(PHOTO_PEER_COL_NAME, QString::fromStdString(rsPeers->getPeerName(id)));
peerItem->setText(PHOTO_PEER_COL_PID, QString::fromStdString(id));
peerItem->setText(PHOTO_PEER_COL_SID, "");
peerItem->setText(PHOTO_PEER_COL_PHOTOID, "");
ui.peerTreeWidget->insertTopLevelItem(0, peerItem);
QTreeWidgetItem *allItem = new QTreeWidgetItem((QTreeWidget*)0);
allItem->setText(PHOTO_PEER_COL_SHOW, "All Photos");
allItem->setText(PHOTO_PEER_COL_PID, QString::fromStdString(id));
allItem->setText(PHOTO_PEER_COL_SID, "");
allItem->setText(PHOTO_PEER_COL_PHOTOID, "");
peerItem->addChild(allItem);
rsPhoto->getPhotoList(id, allPhotos);
rsPhoto->getShowList(id, showIds);
for(it = allPhotos.begin(); it != allPhotos.end(); it++)
{
QTreeWidgetItem *photoItem = new QTreeWidgetItem((QTreeWidget*)0);
photoItem->setText(PHOTO_PEER_COL_PHOTO, QString::fromStdString(*it));
photoItem->setText(PHOTO_PEER_COL_PID, QString::fromStdString(id));
photoItem->setText(PHOTO_PEER_COL_SID, "");
photoItem->setText(PHOTO_PEER_COL_PHOTOID, QString::fromStdString(*it));
allItem->addChild(photoItem);
}
for(it = showIds.begin(); it != showIds.end(); it++)
{
/* get details */
RsPhotoShowDetails detail;
rsPhoto->getShowDetails(id, *it, detail);
QTreeWidgetItem *showItem = new QTreeWidgetItem((QTreeWidget*)0);
showItem->setText(PHOTO_PEER_COL_SHOW, QString::fromStdString(*it));
showItem->setText(PHOTO_PEER_COL_PID, QString::fromStdString(id));
showItem->setText(PHOTO_PEER_COL_SID, QString::fromStdString(*it));
showItem->setText(PHOTO_PEER_COL_PHOTOID, "");
peerItem->addChild(showItem);
std::list<RsPhotoShowInfo>::iterator sit;
for(sit = detail.photos.begin(); sit != detail.photos.end(); sit++)
{
QTreeWidgetItem *photoItem = new QTreeWidgetItem((QTreeWidget*)0);
photoItem->setText(PHOTO_PEER_COL_PHOTO, QString::fromStdString(sit->photoId));
photoItem->setText(PHOTO_PEER_COL_PID, QString::fromStdString(id));
photoItem->setText(PHOTO_PEER_COL_SID, QString::fromStdString(*it));
photoItem->setText(PHOTO_PEER_COL_PHOTOID, QString::fromStdString(sit->photoId));
showItem->addChild(photoItem);
}
}
}
void PhotoDialog::updatePhotoList()
{
/* get current item */
QTreeWidgetItem *item = ui.peerTreeWidget->currentItem();
if (!item)
{
/* leave current list */
return;
}
/* check if it has changed */
std::string pid = item->text(PHOTO_PEER_COL_PID).toStdString();
std::string sid = item->text(PHOTO_PEER_COL_SID).toStdString();
if ((mCurrentPID == pid) && (mCurrentSID == sid))
{
/* still good */
return;
}
/* get the list of photos */
ui.photoTreeWidget->clear();
QList<QTreeWidgetItem *> items;
if (sid != "")
{
/* load up show list */
RsPhotoShowDetails detail;
rsPhoto->getShowDetails(pid, sid, detail);
std::list<RsPhotoShowInfo>::iterator sit;
for(sit = detail.photos.begin(); sit != detail.photos.end(); sit++)
{
RsPhotoDetails photoDetail;
if (!rsPhoto->getPhotoDetails(pid, sit->photoId, photoDetail))
{
continue;
}
QTreeWidgetItem *photoItem = new QTreeWidgetItem((QTreeWidget*)0);
if (photoDetail.isAvailable)
{
QPixmap qpp(QString::fromStdString(photoDetail.path));
photoItem->setIcon(PHOTO_LIST_COL_PHOTO,
QIcon(qpp.scaledToHeight(PHOTO_ICON_SIZE)));
QSize iconSize(PHOTO_ICON_SIZE + 10,PHOTO_ICON_SIZE + 10);
photoItem->setSizeHint(PHOTO_LIST_COL_PHOTO, iconSize);
}
else
{
photoItem->setText(PHOTO_LIST_COL_PHOTO, "Photo Not Available");
}
photoItem->setText(PHOTO_LIST_COL_COMMENT,
QString::fromStdWString(photoDetail.comment));
photoItem->setText(PHOTO_LIST_COL_PHOTOID,
QString::fromStdString(photoDetail.hash));
items.append(photoItem);
}
}
else
{
}
/* add the items in! */
ui.photoTreeWidget->insertTopLevelItems(0, items);
ui.photoTreeWidget->update();
}
@ -119,114 +320,6 @@ void PhotoDialog::peertreeWidgetCostumPopupMenu( QPoint point )
void PhotoDialog::insertExample()
{
#if 0
rsiface->lockData(); /* Lock Interface */
std::map<RsCertId,NeighbourInfo>::const_iterator it;
const std::map<RsCertId,NeighbourInfo> &friends =
rsiface->getFriendMap();
/* get a link to the table */
QTreeWidget *peerWidget = ui.photoTreeWidget;
/* remove old items ??? */
peerWidget->clear();
peerWidget->setColumnCount(12);
QList<QTreeWidgetItem *> items;
for(it = friends.begin(); it != friends.end(); it++)
{
/* make a widget per friend */
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
/* add all the labels */
/* First 5 (1-5) Key Items */
/* () Status Icon */
item -> setText(0, "");
/* (0) Status */
item -> setText(1, QString::fromStdString(
it->second.statusString));
/* (1) Person */
item -> setText(2, QString::fromStdString(it->second.name));
/* (2) Auto Connect */
item -> setText(3, QString::fromStdString(
it->second.connectString));
/* (3) Trust Level */
item -> setText(4, QString::fromStdString(it->second.trustString));
/* (4) Peer Address */
item -> setText(5, QString::fromStdString(it->second.peerAddress));
/* less important ones */
/* () Last Contact */
item -> setText(6, QString::fromStdString(it->second.lastConnect));
/* () Org */
item -> setText(7, QString::fromStdString(it->second.org));
/* () Location */
item -> setText(8, QString::fromStdString(it->second.loc));
/* () Country */
item -> setText(9, QString::fromStdString(it->second.country));
/* Hidden ones: */
/* () RsCertId */
{
std::ostringstream out;
out << it -> second.id;
item -> setText(10, QString::fromStdString(out.str()));
}
/* () AuthCode */
item -> setText(11, QString::fromStdString(it->second.authCode));
/* change background */
int i;
if (it->second.statusString == "Online")
{
/* bright green */
for(i = 1; i < 12; i++)
{
item -> setBackground(i,QBrush(Qt::green));
item -> setIcon(0,(QIcon(IMAGE_ONLINE)));
}
}
else
{
if (it->second.lastConnect != "Never")
{
for(i = 1; i < 12; i++)
{
item -> setBackground(i,QBrush(Qt::lightGray));
item -> setIcon(0,(QIcon(IMAGE_OFFLINE)));
}
}
else
{
for(i = 1; i < 12; i++)
{
item -> setBackground(i,QBrush(Qt::gray));
item -> setIcon(0,(QIcon(IMAGE_OFFLINE)));
}
}
}
/* add to the list */
items.append(item);
}
/* add the items in! */
peerWidget->insertTopLevelItems(0, items);
rsiface->unlockData(); /* UnLock Interface */
peerWidget->update(); /* update display */
#endif
}
QTreeWidgetItem *PhotoDialog::getCurrentLine()
@ -255,24 +348,97 @@ QTreeWidgetItem *PhotoDialog::getCurrentLine()
return item;
}
void PhotoDialog::voteup()
void PhotoDialog::removePhoto()
{
QTreeWidgetItem *c = getCurrentLine();
std::cerr << "PhotoDialog::voteup()" << std::endl;
std::cerr << "PhotoDialog::removePhoto()" << std::endl;
}
void PhotoDialog::votedown()
{
QTreeWidgetItem *c = getCurrentLine();
std::cerr << "PhotoDialog::votedown()" << std::endl;
/* need to get the input address / port */
/*
std::string addr;
unsigned short port;
rsServer->FriendSetAddress(getPeerRsCertId(c), addr, port);
*/
void PhotoDialog::addPhotos()
{
/* get file dialog */
QStringList files = QFileDialog::getOpenFileNames(this,
"Select one or more Photos to add",
"/home", "Images (*.png *.xpm *.jpg *.gif)");
/* add photo to list */
QStringList::iterator it;
for(it = files.begin(); it != files.end(); it++)
{
addPhoto(*it);
}
}
void PhotoDialog::addPhoto(QString filename)
{
/* load pixmap */
/* add QTreeWidgetItem */
QPixmap *qpp = new QPixmap(filename);
/* store in map */
photoMap[filename] = qpp;
/* add treeitem */
QTreeWidgetItem *item = new QTreeWidgetItem(NULL);
/* */
item->setText(0, "Yourself");
item->setText(2, filename);
item->setIcon(1, QIcon(qpp->scaledToHeight(PHOTO_ICON_SIZE)));
QSize iconSize(PHOTO_ICON_SIZE + 10,PHOTO_ICON_SIZE + 10);
item->setSizeHint(1, iconSize);
//item->setIcon(1, QIcon(*qpp));
ui.photoTreeWidget->insertTopLevelItem (0, item);
showPhoto(filename);
}
void PhotoDialog::updatePhoto()
{
/* load pixmap */
QTreeWidgetItem *item = ui.photoTreeWidget->currentItem();
if (!item)
{
showPhoto("");
}
showPhoto(item->text(2));
}
void PhotoDialog::showPhoto(QString filename)
{
#if 0
/* find in map */
std::map<QString, QPixmap *>::iterator it;
it = photoMap.find(filename);
if (it == photoMap.end())
{
ui.photoPixLabel->clear();
ui.photoPixLabel->setText("No Photo Selected");
ui.photoNameLabel->setText("No Photo File Selected");
return;
}
QSize diaSize = ui.photoTreeWidget->size();
int width = diaSize.width();
ui.photoPixLabel->setPixmap((it->second)->scaledToWidth(width));
ui.photoNameLabel->setText(filename);
#endif
return;
}

View File

@ -24,29 +24,42 @@
#include <QFileDialog>
#include "mainpage.h"
#include "ui_PhotoDialog.h"
#include "mainpage.h"
#include "ui_PhotoDialog.h"
class PhotoDialog : public MainPage
{
Q_OBJECT
public:
#include <map>
class PhotoDialog : public MainPage
{
Q_OBJECT
public:
/** Default Constructor */
PhotoDialog(QWidget *parent = 0);
/** Default Destructor */
void insertExample();
void insertShowLists();
private slots:
/** Create the context popup menu and it's submenus */
void peertreeWidgetCostumPopupMenu( QPoint point );
void photoTreeWidgetCustomPopupMenu( QPoint point );
void peerTreeWidgetCustomPopupMenu( QPoint point );
void voteup();
void votedown();
private:
void updatePhotoList();
void removePhoto();
void updatePhoto();
void addPhotos();
private:
void addShows(std::string peerid);
void addPhoto(QString filename);
void showPhoto(QString filename);
/* Worker Functions */
/* (1) Update Display */
@ -54,11 +67,13 @@ private:
/* (2) Utility Fns */
QTreeWidgetItem *getCurrentLine();
std::map<QString, QPixmap *> photoMap;
std::string mCurrentPID;
std::string mCurrentSID;
/** Define the popup menus for the Context menu */
QMenu* contextMnu;
/** Defines the actions for the context menu */
QAction* voteupAct;
QAction* votedownAct;
QTreeWidget *exampletreeWidget;

View File

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>598</width>
<height>510</height>
<width>561</width>
<height>489</height>
</rect>
</property>
<property name="windowTitle" >
@ -14,60 +14,178 @@
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QTreeWidget" name="photoTreeWidget" >
<property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum>
<widget class="QSplitter" name="splitter_2" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<column>
<property name="text" >
<string>Friend / Set</string>
</property>
</column>
<column>
<property name="text" >
<string>Thumb Image</string>
</property>
</column>
<column>
<property name="text" >
<string>Image Name</string>
</property>
</column>
<column>
<property name="text" >
<string>Date</string>
</property>
</column>
<column>
<property name="text" >
<string>Location</string>
</property>
</column>
<column>
<property name="text" >
<string>Comment</string>
</property>
</column>
<item>
<property name="text" >
<string>QtChess</string>
</property>
<property name="text" >
<string>DrBob</string>
</property>
<property name="text" >
<string>2</string>
</property>
<property name="text" >
<string>Invites</string>
</property>
<property name="text" >
<string/>
</property>
<property name="text" >
<string/>
</property>
</item>
<widget class="QWidget" name="" >
<layout class="QVBoxLayout" >
<item>
<widget class="QSplitter" name="splitter" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<widget class="QTreeWidget" name="peerTreeWidget" >
<property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum>
</property>
<column>
<property name="text" >
<string>Peer</string>
</property>
</column>
<column>
<property name="text" >
<string>Slideshow</string>
</property>
</column>
<column>
<property name="text" >
<string>Photo</string>
</property>
</column>
</widget>
<widget class="QTreeWidget" name="photoTreeWidget" >
<property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum>
</property>
<column>
<property name="text" >
<string>Friend / Set</string>
</property>
</column>
<column>
<property name="text" >
<string>Thumb Image</string>
</property>
</column>
<column>
<property name="text" >
<string>Image Name</string>
</property>
</column>
<column>
<property name="text" >
<string>Date</string>
</property>
</column>
<column>
<property name="text" >
<string>Location</string>
</property>
</column>
<column>
<property name="text" >
<string>Comment</string>
</property>
</column>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="expandButton" >
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/add_24x24.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addButton" >
<property name="text" >
<string>Add Photo(s)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addShowButton" >
<property name="text" >
<string>Add Photo SlideShow</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="updateButton" >
<property name="text" >
<string>Update Details</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="" >
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Photo </string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="photoNameEdit" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Date</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="photoDateEdit" />
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Location</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="photoLocEdit" />
</item>
<item row="3" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Description</string>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLineEdit" name="photoDescEdit" />
</item>
<item row="4" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Comment</string>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QTextEdit" name="photoCommentEdit" />
</item>
</layout>
</widget>
</widget>
</item>
</layout>

View File

@ -0,0 +1,236 @@
<ui version="4.0" >
<class>PhotoShow</class>
<widget class="QWidget" name="PhotoShow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>591</width>
<height>421</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<layout class="QVBoxLayout" >
<item>
<layout class="QHBoxLayout" >
<item>
<layout class="QVBoxLayout" >
<item>
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Date:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Location:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Comment:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" >
<item>
<widget class="QLineEdit" name="lineEdit_2" />
</item>
<item>
<widget class="QLineEdit" name="lineEdit" />
</item>
<item>
<widget class="QLineEdit" name="lineEdit_3" />
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Display Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_2" >
<item>
<property name="text" >
<string>320 x 320</string>
</property>
</item>
<item>
<property name="text" >
<string>640 x 640</string>
</property>
</item>
<item>
<property name="text" >
<string>Full Size</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6" >
<property name="text" >
<string>Play Rate:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox" >
<item>
<property name="text" >
<string>1 Sec</string>
</property>
</item>
<item>
<property name="text" >
<string>2 Sec</string>
</property>
</item>
<item>
<property name="text" >
<string>5 Sec</string>
</property>
</item>
<item>
<property name="text" >
<string>10 Sec</string>
</property>
</item>
<item>
<property name="text" >
<string>20 Sec</string>
</property>
</item>
<item>
<property name="text" >
<string>1 Min</string>
</property>
</item>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_4" >
<property name="text" >
<string>Edit Photo Details</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_3" >
<property name="text" >
<string>Save Photo</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>No Photo Selected</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_5" >
<property name="text" >
<string>Start</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_6" >
<property name="text" >
<string>Back</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton" >
<property name="text" >
<string>Play </string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_2" >
<property name="text" >
<string>Pause</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_7" >
<property name="text" >
<string>Forward</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,48 @@
#ifndef RETROSHARE_DISC_GUI_INTERFACE_H
#define RETROSHARE_DISC_GUI_INTERFACE_H
/*
* libretroshare/src/rsiface: rsdisc.h
*
* RetroShare C++ Interface.
*
* Copyright 2008-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include <inttypes.h>
#include <string>
#include <list>
/* The Main Interface Class - for information about your Peers */
class RsDisc;
extern RsDisc *rsDisc;
class RsDisc
{
public:
RsDisc() { return; }
virtual ~RsDisc() { return; }
virtual bool getDiscFriends(std::string id, std::list<std::string> &friends) = 0;
};
#endif

View File

@ -0,0 +1,122 @@
#ifndef RETROSHARE_PHOTO_GUI_INTERFACE_H
#define RETROSHARE_PHOTO_GUI_INTERFACE_H
/*
* libretroshare/src/rsiface: rsphoto.h
*
* RetroShare C++ Interface.
*
* Copyright 2008-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include <inttypes.h>
#include <string>
#include <list>
/* The Main Interface Class - for information about your Peers */
class RsPhoto;
extern RsPhoto *rsPhoto;
class RsPhotoDetails;
class RsPhotoShowDetails;
class RsPhotoShowInfo
{
public:
std::string photoId;
std::wstring altComment;
uint32_t deltaT; /* in 100ths of sec? */
};
class RsPhotoShowDetails
{
public:
RsPhotoShowDetails();
std::string id;
std::string showid;
std::string name;
std::wstring location;
std::wstring comment;
std::string date;
std::list<RsPhotoShowInfo> photos;
};
/* Details class */
class RsPhotoDetails
{
public:
RsPhotoDetails();
std::string id;
std::string srcid;
std::string hash;
std::string name;
std::wstring location;
std::wstring comment;
std::string date;
uint32_t format;
bool isAvailable;
std::string path;
};
std::ostream &operator<<(std::ostream &out, const RsPhotoShowDetails &detail);
std::ostream &operator<<(std::ostream &out, const RsPhotoDetails &detail);
class RsPhoto
{
public:
RsPhoto() { return; }
virtual ~RsPhoto() { return; }
/* access data */
virtual bool getPhotoList(std::string id, std::list<std::string> hashs) = 0;
virtual bool getShowList(std::string id, std::list<std::string> showIds) = 0;
virtual bool getShowDetails(std::string id, std::string showId, RsPhotoShowDetails &detail) = 0;
virtual bool getPhotoDetails(std::string id, std::string photoId, RsPhotoDetails &detail) = 0;
/* add / delete */
virtual std::string createShow(std::string name) = 0;
virtual bool deleteShow(std::string showId) = 0;
virtual bool addPhotoToShow(std::string showId, std::string photoId, int16_t index) = 0;
virtual bool movePhotoInShow(std::string showId, std::string photoId, int16_t index) = 0;
virtual bool removePhotoFromShow(std::string showId, std::string photoId) = 0;
virtual std::string addPhoto(std::string path) = 0; /* add from file */
virtual bool addPhoto(std::string srcId, std::string photoId) = 0; /* add from peers photos */
virtual bool deletePhoto(std::string photoId) = 0;
/* modify properties (TODO) */
virtual bool modifyShow(std::string showId, std::wstring name, std::wstring comment) = 0;
virtual bool modifyPhoto(std::string photoId, std::wstring name, std::wstring comment) = 0;
virtual bool modifyShowComment(std::string showId, std::string photoId, std::wstring comment) = 0;
};
#endif