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

@ -124,6 +124,14 @@ bool p3Blogs::getBlogInfo(std::string cId, BlogInfo &ci)
ci.pop = gi->sources.size();
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;
}
@ -269,9 +277,11 @@ bool p3Blogs::isReply(BlogMsgInfo& info){
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;
}
@ -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) *************************/
/***************************************************************************************/

View file

@ -56,7 +56,8 @@ virtual bool blogsChanged(std::list<std::string> &blogIds);
/**
* 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
@ -98,22 +99,7 @@ virtual bool BlogMessageReply(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) *************************/
/***************************************************************************************/

View file

@ -65,7 +65,7 @@ RsChannels *rsChannels = NULL;
* PUBPERIOD * 2^16 = max STORE PERIOD */
#define CHANNEL_STOREPERIOD (30*24*3600) /* 30 * 24 * 3600 - secs in a 30 day month */
#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 */
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.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;
}
@ -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;
}

View file

@ -33,11 +33,11 @@
#include "serialiser/rstlvtypes.h"
#include "serialiser/rschannelitems.h"
//! Channels is a distributed 'feed' service
/*!
* The channels service allows peers to subscirbe to each feeds published by
* their peers. Using the p3groupdistrib class to enable management of
* publication and viewing keys
* Implementations of rschannels interface
* @see rsChannels for definition of implemented interface
*/
class p3Channels: public p3GroupDistrib, public RsChannels
{
@ -48,7 +48,7 @@ class p3Channels: public p3GroupDistrib, public RsChannels
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
*/
void cleanUpOldFiles();
@ -58,7 +58,8 @@ void cleanUpOldFiles();
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 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
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->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 */
setRSAPublicKey(newGrp->adminKey, rsa_admin_pub);
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.grpCategory = newGrp->grpCategory;
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 */
/* last post handled seperately */

View file

@ -150,7 +150,7 @@ class GroupInfo
/* NOT USED YET */
//PIXMAP *GroupIcon;
RsTlvImage grpIcon;
bool publisher, allowAnon, allowUnknown;
bool subscribed, listener;
@ -259,7 +259,7 @@ void loadGroupKey(RsDistribGrpKey *newKey);
/* TO FINISH */
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 modGroupIcon(std::string grpId, PIXMAP *icon);
@ -300,7 +300,9 @@ RsDistribMsg *locked_getGroupMsg(std::string grpId, std::string msgId);
/***************************************************************************************/
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 bool locked_eventDuplicateMsg(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 id = createGroup(forumName, forumDesc,
convertToInternalFlags(forumFlags));
convertToInternalFlags(forumFlags), NULL, 0);
return id;
}