mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-15 02:44:20 -05:00
added edit channel info feature and edit distrib group info
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3060 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
163c0e96a7
commit
458eb34fb6
@ -430,9 +430,9 @@ RsDistribGrp *p3Channels::locked_createPrivateDistribGrp(GroupInfo &info)
|
||||
|
||||
bool p3Channels::channelSubscribe(std::string cId, bool subscribe)
|
||||
{
|
||||
#ifdef CHANNEL_DEBUG
|
||||
#ifdef CHANNEL_DEBUG
|
||||
std::cerr << "p3Channels::channelSubscribe() " << cId << std::endl;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return subscribeToGroup(cId, subscribe);
|
||||
}
|
||||
@ -447,6 +447,33 @@ bool p3Channels::channelShareKeys(std::string chId, std::list<std::string>& peer
|
||||
|
||||
}
|
||||
|
||||
bool p3Channels::channelEditInfo(std::string chId, ChannelInfo& info){
|
||||
|
||||
#ifdef CHANNEL_DEBUG
|
||||
std::cerr << "p3Channels::channelUdateInfo() " << chId << std::endl;
|
||||
#endif
|
||||
|
||||
GroupInfo gi;
|
||||
|
||||
RsStackMutex stack(distribMtx);
|
||||
|
||||
gi.grpName = info.channelName;
|
||||
gi.grpDesc = info.channelDesc;
|
||||
|
||||
|
||||
if((info.pngChanImage != NULL) && (info.pngImageLen != 0)){
|
||||
gi.grpIcon.imageSize = info.pngImageLen;
|
||||
gi.grpIcon.pngImageData = info.pngChanImage;
|
||||
}
|
||||
else{
|
||||
gi.grpIcon.imageSize = 0;
|
||||
gi.grpIcon.pngImageData = NULL;
|
||||
}
|
||||
|
||||
return locked_editGroup(chId, gi);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************************/
|
||||
/****************** Event Feedback (Overloaded form p3distrib) *************************/
|
||||
|
@ -73,6 +73,7 @@ virtual bool channelExtraFileHash(std::string path, std::string chId, FileInfo&
|
||||
virtual bool channelExtraFileRemove(std::string hash, std::string chId);
|
||||
virtual bool channelRestoreKeys(std::string chId);
|
||||
virtual bool channelShareKeys(std::string chId, std::list<std::string>& peers);
|
||||
virtual bool channelEditInfo(std::string chId, ChannelInfo &ci);
|
||||
/***************************************************************************************/
|
||||
/****************** Event Feedback (Overloaded form p3distrib) *************************/
|
||||
/***************************************************************************************/
|
||||
|
@ -2312,6 +2312,76 @@ bool p3GroupDistrib::locked_updateGroupInfo(GroupInfo &info, RsDistribGrp *newG
|
||||
}
|
||||
|
||||
|
||||
bool p3GroupDistrib::locked_editGroup(std::string grpId, GroupInfo& gi){
|
||||
|
||||
#ifdef DISTRIB_DEBUG
|
||||
std::cerr << "p3GroupDistrib::locked_editGroup() " << grpId << std::endl;
|
||||
#endif
|
||||
|
||||
GroupInfo* gi_curr = locked_getGroupInfo(grpId);
|
||||
|
||||
if(gi_curr == NULL){
|
||||
|
||||
std::cerr << "p3GroupDistrib::locked_editGroup() Failed, group does not exist " << grpId
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!(gi_curr->flags & RS_DISTRIB_ADMIN))
|
||||
return false;
|
||||
|
||||
|
||||
gi_curr->grpName = gi.grpName;
|
||||
gi_curr->distribGroup->grpName = gi_curr->grpName;
|
||||
gi_curr->grpDesc = gi.grpDesc;
|
||||
gi_curr->distribGroup->grpDesc = gi_curr->grpDesc;
|
||||
|
||||
if((gi.grpIcon.imageSize != 0) && gi.grpIcon.pngImageData != NULL){
|
||||
|
||||
if((gi_curr->distribGroup->grpPixmap.binData.bin_data != NULL) &&
|
||||
(gi_curr->distribGroup->grpPixmap.binData.bin_len != 0))
|
||||
gi_curr->distribGroup->grpPixmap.binData.TlvClear();
|
||||
|
||||
gi_curr->distribGroup->grpPixmap.binData.bin_data = gi_curr->grpIcon.pngImageData;
|
||||
gi_curr->distribGroup->grpPixmap.binData.bin_len = gi_curr->grpIcon.imageSize;
|
||||
|
||||
gi_curr->grpIcon.imageSize = gi.grpIcon.imageSize;
|
||||
gi_curr->grpIcon.pngImageData = gi.grpIcon.pngImageData;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// create new signature for group
|
||||
|
||||
EVP_PKEY *key_admin = gi_curr->adminKey.key;
|
||||
gi_curr->distribGroup->adminSignature.TlvClear();
|
||||
RsSerialType *serialType = new RsDistribSerialiser();
|
||||
uint32_t size = serialType->size(gi_curr->distribGroup);
|
||||
char* data = new char[size];
|
||||
serialType->serialise(gi_curr->distribGroup, data, &size);
|
||||
|
||||
/* calc and check signature */
|
||||
EVP_MD_CTX *mdctx = EVP_MD_CTX_create();
|
||||
EVP_SignInit(mdctx, EVP_sha1());
|
||||
EVP_SignUpdate(mdctx, data, size);
|
||||
|
||||
unsigned int siglen = EVP_PKEY_size(key_admin);
|
||||
unsigned char sigbuf[siglen];
|
||||
int ans = EVP_SignFinal(mdctx, sigbuf, &siglen, key_admin);
|
||||
|
||||
/* save signature */
|
||||
gi_curr->distribGroup->adminSignature.signData.setBinData(sigbuf, siglen);
|
||||
gi_curr->distribGroup->adminSignature.keyId = grpId;
|
||||
|
||||
mGroupsChanged = true;
|
||||
gi_curr->grpChanged = true;
|
||||
mGroupsRepublish = true;
|
||||
|
||||
delete[] data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3GroupDistrib::locked_checkGroupKeys(GroupInfo &info)
|
||||
{
|
||||
#ifdef DISTRIB_DEBUG
|
||||
@ -2456,6 +2526,7 @@ bool p3GroupDistrib::locked_checkGroupKeys(GroupInfo &info)
|
||||
|
||||
|
||||
|
||||
|
||||
bool p3GroupDistrib::locked_updateGroupAdminKey(GroupInfo &info, RsDistribGrpKey *newKey)
|
||||
{
|
||||
/* so firstly - check that the KeyId matches something in the group */
|
||||
|
@ -386,6 +386,12 @@ virtual void locked_receivePubKeys();
|
||||
*/
|
||||
virtual void locked_loadRecvdPubKeys();
|
||||
|
||||
/**
|
||||
* Allows group admin(s) to change group icon, description and name
|
||||
*
|
||||
*/
|
||||
virtual bool locked_editGroup(std::string grpId, GroupInfo& gi);
|
||||
|
||||
|
||||
/***************************************************************************************/
|
||||
/***************************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user