added group icon support

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2904 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2010-05-14 13:00:07 +00:00
parent 47de2af50c
commit 27895d1781
10 changed files with 124 additions and 58 deletions

View File

@ -45,6 +45,9 @@ class BlogInfo
uint32_t blogFlags; uint32_t blogFlags;
uint32_t pop; uint32_t pop;
unsigned char* pngChanImage;
uint32_t pngImageLen;
time_t lastPost; time_t lastPost;
}; };
@ -108,7 +111,8 @@ virtual ~RsBlogs() { return; }
virtual bool blogsChanged(std::list<std::string> &blogIds) = 0; virtual bool blogsChanged(std::list<std::string> &blogIds) = 0;
virtual std::string createBlog(std::wstring blogName, std::wstring blogDesc, uint32_t blogFlags) = 0; virtual std::string createBlog(std::wstring blogName, std::wstring blogDesc, uint32_t blogFlags,
unsigned char* pngImageData, uint32_t imageSize) = 0;
virtual bool getBlogInfo(std::string cId, BlogInfo &ci) = 0; virtual bool getBlogInfo(std::string cId, BlogInfo &ci) = 0;
virtual bool getBlogList(std::list<BlogInfo> &chanList) = 0; virtual bool getBlogList(std::list<BlogInfo> &chanList) = 0;

View File

@ -34,6 +34,10 @@
#include "rsiface/rstypes.h" #include "rsiface/rstypes.h"
#include "rsiface/rsdistrib.h" /* For FLAGS */ #include "rsiface/rsdistrib.h" /* For FLAGS */
//! Stores information for a give channel id
/*!
* Stores all information for a given channel id
*/
class ChannelInfo class ChannelInfo
{ {
public: public:
@ -43,11 +47,16 @@ class ChannelInfo
std::wstring channelDesc; std::wstring channelDesc;
uint32_t channelFlags; uint32_t channelFlags;
uint32_t pop; uint32_t pop; /// popularity
unsigned char* pngChanImage;
uint32_t pngImageLen;
time_t lastPost; time_t lastPost;
}; };
//! Stores information on a message within a channel
class ChannelMsgInfo class ChannelMsgInfo
{ {
public: public:
@ -59,14 +68,14 @@ class ChannelMsgInfo
std::wstring subject; std::wstring subject;
std::wstring msg; std::wstring msg;
time_t ts; time_t ts; /// time stamp
std::list<FileInfo> files; std::list<FileInfo> files;
uint32_t count; uint32_t count; /// file count
uint64_t size; uint64_t size; /// size of all files
}; };
//! gives a more brief account of a channel message than channelMsgInfo
class ChannelMsgSummary class ChannelMsgSummary
{ {
public: public:
@ -78,8 +87,8 @@ class ChannelMsgSummary
std::wstring subject; std::wstring subject;
std::wstring msg; std::wstring msg;
uint32_t count; /* file count */ uint32_t count; /// file count
time_t ts; time_t ts; /// time stamp
}; };
@ -90,6 +99,12 @@ std::ostream &operator<<(std::ostream &out, const ChannelMsgInfo &info);
class RsChannels; class RsChannels;
extern RsChannels *rsChannels; extern RsChannels *rsChannels;
/*!
* retroshare interface to the channels distributed group service
* Channels user to create feeds similar to RSS feed where you can share files
* with other users, when you subscribe to a channel you immediately begin downloading
* the file shared on that channel. Channel feeds are shared anonymously
*/
class RsChannels class RsChannels
{ {
public: public:
@ -99,18 +114,56 @@ virtual ~RsChannels() { return; }
/****************************************/ /****************************************/
/*!
* returns a list of channel id that have changed (i.e. received new message, chan descr update)
* @param chanIds this is populated with channel ids that have changed
*/
virtual bool channelsChanged(std::list<std::string> &chanIds) = 0; virtual bool channelsChanged(std::list<std::string> &chanIds) = 0;
/*!
* @param chanName name of the channel
* @param chanDesc a short description for the created channel
* @param chanFlags admin details on created channel group see rsdistrib.h for flags types
* @param pngImageData point at image data in PNG format
* @param imageSize size of the image data
*/
virtual std::string createChannel(std::wstring chanName, std::wstring chanDesc, uint32_t chanFlags,
unsigned char* pngImageData, uint32_t imageSize) = 0;
virtual std::string createChannel(std::wstring chanName, std::wstring chanDesc, uint32_t chanFlags) = 0; /*!
* retrieve channel information
* @param cId channel id
* @param ci channel info is store here
*/
virtual bool getChannelInfo(std::string cId, ChannelInfo &ci) = 0; virtual bool getChannelInfo(std::string cId, ChannelInfo &ci) = 0;
/*!
* @param chanList populated channelinfo for all channels
*/
virtual bool getChannelList(std::list<ChannelInfo> &chanList) = 0; virtual bool getChannelList(std::list<ChannelInfo> &chanList) = 0;
/*!
* get a message summary list for a given channel id
* @param cId channel id user wants messages for
* @param msgs summary of messages for the given cId
*/
virtual bool getChannelMsgList(std::string cId, std::list<ChannelMsgSummary> &msgs) = 0; virtual bool getChannelMsgList(std::string cId, std::list<ChannelMsgSummary> &msgs) = 0;
/*!
* retrieve more comprehensive message info given channel id and message id
*/
virtual bool getChannelMessage(std::string cId, std::string mId, ChannelMsgInfo &msg) = 0; virtual bool getChannelMessage(std::string cId, std::string mId, ChannelMsgInfo &msg) = 0;
/*!
* send message contain in message info to the id indicated within it (make sure you set the channel id of the message info)
* @param info message to be sent
*/
virtual bool ChannelMessageSend(ChannelMsgInfo &info) = 0; virtual bool ChannelMessageSend(ChannelMsgInfo &info) = 0;
/*!
* @param cId the channel id
* @param subscribe set to true if you want to subscribe and to false to unsubscribe
*/
virtual bool channelSubscribe(std::string cId, bool subscribe) = 0; virtual bool channelSubscribe(std::string cId, bool subscribe) = 0;
/*! /*!
@ -123,8 +176,10 @@ virtual bool channelExtraFileHash(std::string path, std::string chId, FileInfo&
/*! /*!
* This removes hashed extra files, and also removes channels directory copy if it exists * This removes hashed extra files, and also removes channels directory copy if it exists
* @param chId channel id
*/ */
virtual bool channelExtraFileRemove(std::string hash, std::string chId) = 0; virtual bool channelExtraFileRemove(std::string hash, std::string chId) = 0;
/****************************************/ /****************************************/
}; };

View File

@ -207,6 +207,8 @@ const uint16_t TLV_TYPE_KEYSIGNATURE = 0x1050;
const uint16_t TLV_TYPE_IMAGE = 0x1060; const uint16_t TLV_TYPE_IMAGE = 0x1060;
const uint32_t RSTLV_IMAGE_TYPE_PNG = 0x0001;
const uint32_t RSTLV_IMAGE_TYPE_JPG = 0x0002;
/**** Basic TLV Functions ****/ /**** Basic TLV Functions ****/
uint32_t GetTlvSize(void *data); uint32_t GetTlvSize(void *data);

View File

@ -124,6 +124,14 @@ bool p3Blogs::getBlogInfo(std::string cId, BlogInfo &ci)
ci.pop = gi->sources.size(); ci.pop = gi->sources.size();
ci.lastPost = gi->lastPost; ci.lastPost = gi->lastPost;
if(gi->grpIcon.image_type == RSTLV_IMAGE_TYPE_PNG){
ci.pngChanImage = (unsigned char*) gi->grpIcon.binData.bin_data;
ci.pngImageLen = gi->grpIcon.binData.bin_len;
}else{
ci.pngChanImage = NULL;
ci.pngImageLen = 0;
}
return true; return true;
} }
@ -269,9 +277,11 @@ bool p3Blogs::isReply(BlogMsgInfo& info){
return !info.msgIdReply.empty(); return !info.msgIdReply.empty();
} }
std::string p3Blogs::createBlog(std::wstring blogName, std::wstring blogDesc, uint32_t blogFlags) std::string p3Blogs::createBlog(std::wstring blogName, std::wstring blogDesc, uint32_t blogFlags,
unsigned char* pngImageData, uint32_t imageSize)
{ {
std::string id = createGroup(blogName, blogDesc, blogFlags);
std::string id = createGroup(blogName, blogDesc, blogFlags, pngImageData, imageSize);
return id; return id;
} }
@ -312,23 +322,6 @@ bool p3Blogs::blogSubscribe(std::string cId, bool subscribe)
} }
bool p3Blogs::deleteBlogMsg(std::string cId, std::string mId){
return false;
}
bool p3Blogs::isBlogDeleted(std::string cId){
return false;
}
bool p3Blogs::isBlogMsgDeleted(std::string cId, std::string mId){
return false;
}
bool p3Blogs::deleteBlog(std::string cId){
return false;
}
/***************************************************************************************/ /***************************************************************************************/
/****************** Event Feedback (Overloaded form p3distrib) *************************/ /****************** Event Feedback (Overloaded form p3distrib) *************************/
/***************************************************************************************/ /***************************************************************************************/

View File

@ -56,7 +56,8 @@ virtual bool blogsChanged(std::list<std::string> &blogIds);
/** /**
* creates a new blog * creates a new blog
*/ */
virtual std::string createBlog(std::wstring blogName, std::wstring blogDesc, uint32_t blogFlags); virtual std::string createBlog(std::wstring blogName, std::wstring blogDesc, uint32_t blogFlags,
unsigned char* pngImageData, uint32_t imageSize);
/** /**
* @param cId the id for the blog * @param cId the id for the blog
@ -98,22 +99,7 @@ virtual bool BlogMessageReply(BlogMsgInfo &info);
*/ */
virtual bool isReply(BlogMsgInfo& info); virtual bool isReply(BlogMsgInfo& info);
/**
* Deletes a blog by group id
*
*/
virtual bool deleteBlog(std::string cId);
/**
* Delete a blog message
* @param cId the group id the blog message belongs to
* @param mId the message id within the group
*/
virtual bool deleteBlogMsg(std::string cId, std::string mId);
virtual bool isBlogDeleted(std::string cId);
virtual bool isBlogMsgDeleted(std::string cId, std::string mId);
/***************************************************************************************/ /***************************************************************************************/
/****************** Event Feedback (Overloaded form p3distrib) *************************/ /****************** Event Feedback (Overloaded form p3distrib) *************************/
/***************************************************************************************/ /***************************************************************************************/

View File

@ -65,7 +65,7 @@ RsChannels *rsChannels = NULL;
* PUBPERIOD * 2^16 = max STORE PERIOD */ * PUBPERIOD * 2^16 = max STORE PERIOD */
#define CHANNEL_STOREPERIOD (30*24*3600) /* 30 * 24 * 3600 - secs in a 30 day month */ #define CHANNEL_STOREPERIOD (30*24*3600) /* 30 * 24 * 3600 - secs in a 30 day month */
#define TEST_CHANNEL_STOREPERIOD (24*3600) /* one day */ #define TEST_CHANNEL_STOREPERIOD (24*3600) /* one day */
#define CHANNEL_PUBPERIOD 6 /* 10 minutes ... (max = 455 days) */ #define CHANNEL_PUBPERIOD 600 /* 10 minutes ... (max = 455 days) */
#define MAX_AUTO_DL 1E9 /* auto download of attachment limit; 1 GIG */ #define MAX_AUTO_DL 1E9 /* auto download of attachment limit; 1 GIG */
p3Channels::p3Channels(uint16_t type, CacheStrapper *cs, p3Channels::p3Channels(uint16_t type, CacheStrapper *cs,
@ -119,6 +119,16 @@ bool p3Channels::getChannelInfo(std::string cId, ChannelInfo &ci)
ci.pop = gi->sources.size(); ci.pop = gi->sources.size();
ci.lastPost = gi->lastPost; ci.lastPost = gi->lastPost;
if(gi->grpIcon.image_type == RSTLV_IMAGE_TYPE_PNG){
ci.pngChanImage = (unsigned char*) gi->grpIcon.binData.bin_data;
ci.pngImageLen = gi->grpIcon.binData.bin_len;
}else{
ci.pngChanImage = NULL;
ci.pngImageLen = 0;
}
return true; return true;
} }
@ -372,9 +382,12 @@ bool p3Channels::channelExtraFileRemove(std::string hash, std::string chId){
} }
std::string p3Channels::createChannel(std::wstring channelName, std::wstring channelDesc, uint32_t channelFlags)
std::string p3Channels::createChannel(std::wstring channelName, std::wstring channelDesc, uint32_t channelFlags,
unsigned char* pngImageData, uint32_t imageSize)
{ {
std::string id = createGroup(channelName, channelDesc, channelFlags);
std::string id = createGroup(channelName, channelDesc, channelFlags, pngImageData, imageSize);
return id; return id;
} }

View File

@ -33,11 +33,11 @@
#include "serialiser/rstlvtypes.h" #include "serialiser/rstlvtypes.h"
#include "serialiser/rschannelitems.h" #include "serialiser/rschannelitems.h"
//! Channels is a distributed 'feed' service //! Channels is a distributed 'feed' service
/*! /*!
* The channels service allows peers to subscirbe to each feeds published by * Implementations of rschannels interface
* their peers. Using the p3groupdistrib class to enable management of * @see rsChannels for definition of implemented interface
* publication and viewing keys
*/ */
class p3Channels: public p3GroupDistrib, public RsChannels class p3Channels: public p3GroupDistrib, public RsChannels
{ {
@ -48,7 +48,7 @@ class p3Channels: public p3GroupDistrib, public RsChannels
virtual ~p3Channels(); virtual ~p3Channels();
/*! /*!
* cleans up local info and dowloaded files older than one month, * cleans up dowloaded files older than one month,
* should be called during shutdown of rs * should be called during shutdown of rs
*/ */
void cleanUpOldFiles(); void cleanUpOldFiles();
@ -58,7 +58,8 @@ void cleanUpOldFiles();
virtual bool channelsChanged(std::list<std::string> &chanIds); virtual bool channelsChanged(std::list<std::string> &chanIds);
virtual std::string createChannel(std::wstring chanName, std::wstring chanDesc, uint32_t chanFlags); virtual std::string createChannel(std::wstring chanName, std::wstring chanDesc, uint32_t chanFlags,
unsigned char* pngImageData, uint32_t size);
virtual bool getChannelInfo(std::string cId, ChannelInfo &ci); virtual bool getChannelInfo(std::string cId, ChannelInfo &ci);
virtual bool getChannelList(std::list<ChannelInfo> &chanList); virtual bool getChannelList(std::list<ChannelInfo> &chanList);

View File

@ -1486,7 +1486,8 @@ RSA *extractPrivateKey(RsTlvSecurityKey &key)
} }
std::string p3GroupDistrib::createGroup(std::wstring name, std::wstring desc, uint32_t flags) std::string p3GroupDistrib::createGroup(std::wstring name, std::wstring desc, uint32_t flags,
unsigned char* pngImageData, uint32_t imageSize)
{ {
#ifdef DISTRIB_DEBUG #ifdef DISTRIB_DEBUG
std::cerr << "p3GroupDistrib::createGroup()" << std::endl; std::cerr << "p3GroupDistrib::createGroup()" << std::endl;
@ -1514,6 +1515,11 @@ std::string p3GroupDistrib::createGroup(std::wstring name, std::wstring desc, ui
newGrp->grpFlags = flags & (RS_DISTRIB_PRIVACY_MASK | RS_DISTRIB_AUTHEN_MASK); newGrp->grpFlags = flags & (RS_DISTRIB_PRIVACY_MASK | RS_DISTRIB_AUTHEN_MASK);
newGrp->grpControlFlags = 0; newGrp->grpControlFlags = 0;
// explicit member wise copy for grp image
newGrp->grpPixmap.binData.bin_data = pngImageData;
newGrp->grpPixmap.binData.bin_len = imageSize;
newGrp->grpPixmap.image_type = RSTLV_IMAGE_TYPE_PNG;
/* set keys */ /* set keys */
setRSAPublicKey(newGrp->adminKey, rsa_admin_pub); setRSAPublicKey(newGrp->adminKey, rsa_admin_pub);
newGrp->adminKey.keyFlags = RSTLV_KEY_TYPE_PUBLIC_ONLY | RSTLV_KEY_DISTRIB_ADMIN; newGrp->adminKey.keyFlags = RSTLV_KEY_TYPE_PUBLIC_ONLY | RSTLV_KEY_DISTRIB_ADMIN;
@ -1904,6 +1910,9 @@ bool p3GroupDistrib::locked_updateGroupInfo(GroupInfo &info, RsDistribGrp *newG
info.grpDesc = newGrp->grpDesc; info.grpDesc = newGrp->grpDesc;
info.grpCategory = newGrp->grpCategory; info.grpCategory = newGrp->grpCategory;
info.grpFlags = newGrp->grpFlags; info.grpFlags = newGrp->grpFlags;
info.grpIcon.binData.bin_data = newGrp->grpPixmap.binData.bin_data;
info.grpIcon.binData.bin_len = newGrp->grpPixmap.binData.bin_len;
info.grpIcon.image_type = newGrp->grpPixmap.image_type;
/* pop already calculated */ /* pop already calculated */
/* last post handled seperately */ /* last post handled seperately */

View File

@ -150,7 +150,7 @@ class GroupInfo
/* NOT USED YET */ /* NOT USED YET */
//PIXMAP *GroupIcon; RsTlvImage grpIcon;
bool publisher, allowAnon, allowUnknown; bool publisher, allowAnon, allowUnknown;
bool subscribed, listener; bool subscribed, listener;
@ -259,7 +259,7 @@ void loadGroupKey(RsDistribGrpKey *newKey);
/* TO FINISH */ /* TO FINISH */
public: public:
std::string createGroup(std::wstring name, std::wstring desc, uint32_t flags); std::string createGroup(std::wstring name, std::wstring desc, uint32_t flags, unsigned char*, uint32_t imageSize);
//std::string modGroupDescription(std::string grpId, std::string discription); //std::string modGroupDescription(std::string grpId, std::string discription);
//std::string modGroupIcon(std::string grpId, PIXMAP *icon); //std::string modGroupIcon(std::string grpId, PIXMAP *icon);
@ -300,7 +300,9 @@ RsDistribMsg *locked_getGroupMsg(std::string grpId, std::string msgId);
/***************************************************************************************/ /***************************************************************************************/
protected: protected:
/* root version of this function must be called */ /*!
* root version (p3Distrib::) of this function must be called
**/
virtual void locked_notifyGroupChanged(GroupInfo &info, uint32_t flags); virtual void locked_notifyGroupChanged(GroupInfo &info, uint32_t flags);
virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, std::string id) = 0; virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, std::string id) = 0;
virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, std::string id) = 0; virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, std::string id) = 0;

View File

@ -265,8 +265,9 @@ bool p3Forums::ForumMessageSend(ForumMsgInfo &info)
std::string p3Forums::createForum(std::wstring forumName, std::wstring forumDesc, uint32_t forumFlags) std::string p3Forums::createForum(std::wstring forumName, std::wstring forumDesc, uint32_t forumFlags)
{ {
std::string id = createGroup(forumName, forumDesc, std::string id = createGroup(forumName, forumDesc,
convertToInternalFlags(forumFlags)); convertToInternalFlags(forumFlags), NULL, 0);
return id; return id;
} }