Merge pull request #434 from csoler/v0.6-LocalCircles

V0.6 local circles
This commit is contained in:
Cyril Soler 2016-07-12 22:49:21 -04:00 committed by GitHub
commit 8ccfee20bb
47 changed files with 2158 additions and 1869 deletions

3
.gitignore vendored
View File

@ -1,5 +1,8 @@
/RetroShare.pro.user /RetroShare.pro.user
*.o *.o
*.sw?
*.so
*.so.*
moc_*.cpp moc_*.cpp
qrc_*.cpp qrc_*.cpp
ui_*.h ui_*.h

View File

@ -431,7 +431,7 @@ int FileIndexMonitor::filterResults(std::list<FileEntry*>& firesults,std::list<D
return !results.empty() ; return !results.empty() ;
} }
bool FileIndexMonitor::findLocalFile(const RsFileHash& hash,FileSearchFlags hint_flags, const RsPeerId& peer_id,std::string &fullpath, uint64_t &size,FileStorageFlags& storage_flags,std::list<std::string>& parent_groups) const bool FileIndexMonitor::findLocalFile(const RsFileHash& hash,FileSearchFlags hint_flags, const RsPeerId& peer_id,std::string &fullpath, uint64_t &size,FileStorageFlags& storage_flags,std::list<RsNodeGroupId>& parent_groups) const
{ {
std::list<FileEntry *> results; std::list<FileEntry *> results;
bool ok = false; bool ok = false;
@ -1668,7 +1668,7 @@ int FileIndexMonitor::RequestDirDetails(void *ref, DirDetails &details, FileSear
return true ; return true ;
} }
void FileIndexMonitor::locked_findShareFlagsAndParentGroups(FileEntry *file,FileStorageFlags& flags,std::list<std::string>& parent_groups) const void FileIndexMonitor::locked_findShareFlagsAndParentGroups(FileEntry *file,FileStorageFlags& flags,std::list<RsNodeGroupId>& parent_groups) const
{ {
flags.clear() ; flags.clear() ;
static const FileStorageFlags PERMISSION_MASK = DIR_FLAGS_BROWSABLE_OTHERS | DIR_FLAGS_NETWORK_WIDE_OTHERS | DIR_FLAGS_BROWSABLE_GROUPS | DIR_FLAGS_NETWORK_WIDE_GROUPS ; static const FileStorageFlags PERMISSION_MASK = DIR_FLAGS_BROWSABLE_OTHERS | DIR_FLAGS_NETWORK_WIDE_OTHERS | DIR_FLAGS_BROWSABLE_GROUPS | DIR_FLAGS_NETWORK_WIDE_GROUPS ;

View File

@ -110,7 +110,7 @@ class FileIndexMonitor: public CacheSource, public RsTickingThread
virtual ~FileIndexMonitor(); virtual ~FileIndexMonitor();
/* external interface for filetransfer */ /* external interface for filetransfer */
bool findLocalFile(const RsFileHash& hash,FileSearchFlags flags,const RsPeerId& peer_id, std::string &fullpath, uint64_t &size,FileStorageFlags& storage_flags,std::list<std::string>& parent_groups) const; bool findLocalFile(const RsFileHash& hash,FileSearchFlags flags,const RsPeerId& peer_id, std::string &fullpath, uint64_t &size,FileStorageFlags& storage_flags,std::list<RsNodeGroupId>& parent_groups) const;
int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) ; int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) ;
int SearchBoolExp(Expression *exp, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) const ; int SearchBoolExp(Expression *exp, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) const ;
@ -176,7 +176,7 @@ class FileIndexMonitor: public CacheSource, public RsTickingThread
time_t locked_saveFileIndexes(bool update_cache) ; time_t locked_saveFileIndexes(bool update_cache) ;
// Finds the share flags associated with this file entry. // Finds the share flags associated with this file entry.
void locked_findShareFlagsAndParentGroups(FileEntry *fe,FileStorageFlags& shareflags,std::list<std::string>& parent_groups) const ; void locked_findShareFlagsAndParentGroups(FileEntry *fe, FileStorageFlags& shareflags, std::list<RsNodeGroupId> &parent_groups) const ;
std::string locked_findRealRoot(std::string base) const; std::string locked_findRealRoot(std::string base) const;

View File

@ -25,6 +25,7 @@
#include "ft/ftdbase.h" #include "ft/ftdbase.h"
#include "util/rsdir.h" #include "util/rsdir.h"
#include "retroshare/rspeers.h"
#include "serialiser/rsconfigitems.h" #include "serialiser/rsconfigitems.h"
@ -237,11 +238,13 @@ bool ftFiMonitor::saveList(bool &cleanup, std::list<RsItem *>& sList)
for(it = dirList.begin(); it != dirList.end(); ++it) for(it = dirList.begin(); it != dirList.end(); ++it)
{ {
RsFileConfigItem *fi = new RsFileConfigItem(); RsFileConfigItem *fi = new RsFileConfigItem();
fi->file.path = (*it).filename ; fi->file.path = (*it).filename ;
fi->file.name = (*it).virtualname ; fi->file.name = (*it).virtualname ;
fi->flags = (*it).shareflags.toUInt32() ; fi->flags = (*it).shareflags.toUInt32() ;
fi->parent_groups = (*it).parent_groups ;
for(std::list<RsNodeGroupId>::const_iterator it2( (*it).parent_groups.begin());it2!=(*it).parent_groups.end();++it2)
fi->parent_groups.ids.insert(*it2) ;
sList.push_back(fi); sList.push_back(fi);
} }
@ -332,24 +335,52 @@ bool ftFiMonitor::loadList(std::list<RsItem *>& load)
continue ; continue ;
} }
RsFileConfigItem *fi = dynamic_cast<RsFileConfigItem *>(*it); // 07/05/2016 - This ensures backward compatibility. Can be removed in a few weeks.
if (!fi) RsFileConfigItem_deprecated *fib = dynamic_cast<RsFileConfigItem_deprecated *>(*it);
{ if (fib)
delete (*it); {
continue; /* ensure that it exists? */
}
/* ensure that it exists? */ SharedDirInfo info ;
info.filename = RsDirUtil::convertPathToUnix(fib->file.path);
info.virtualname = fib->file.name;
info.shareflags = FileStorageFlags(fib->flags) ;
info.shareflags &= PERMISSION_MASK ;
info.shareflags &= ~DIR_FLAGS_NETWORK_WIDE_GROUPS ; // disabling this flag for know, for consistency reasons
SharedDirInfo info ; for(std::list<std::string>::const_iterator itt(fib->parent_groups.begin());itt!=fib->parent_groups.end();++itt)
info.filename = RsDirUtil::convertPathToUnix(fi->file.path); {
info.virtualname = fi->file.name; RsGroupInfo ginfo;
info.parent_groups = fi->parent_groups;
info.shareflags = FileStorageFlags(fi->flags) ;
info.shareflags &= PERMISSION_MASK ;
info.shareflags &= ~DIR_FLAGS_NETWORK_WIDE_GROUPS ; // disabling this flag for know, for consistency reasons
dirList.push_back(info) ; if(rsPeers->getGroupInfoByName(*itt,ginfo) )
{
info.parent_groups.push_back(ginfo.id) ;
std::cerr << "(II) converted old group ID \"" << *itt << "\" into corresponding new group id " << ginfo.id << std::endl;
}
else
std::cerr << "(EE) cannot convert old group ID \"" << *itt << "\" into corresponding new group id: no candidate found. " << std::endl;
}
dirList.push_back(info) ;
}
RsFileConfigItem *fi = dynamic_cast<RsFileConfigItem *>(*it);
if (fi)
{
/* ensure that it exists? */
SharedDirInfo info ;
info.filename = RsDirUtil::convertPathToUnix(fi->file.path);
info.virtualname = fi->file.name;
info.shareflags = FileStorageFlags(fi->flags) ;
info.shareflags &= PERMISSION_MASK ;
info.shareflags &= ~DIR_FLAGS_NETWORK_WIDE_GROUPS ; // disabling this flag for know, for consistency reasons
for(std::set<RsNodeGroupId>::const_iterator itt(fi->parent_groups.ids.begin());itt!=fi->parent_groups.ids.end();++itt)
info.parent_groups.push_back(*itt) ;
dirList.push_back(info) ;
}
delete *it ; delete *it ;
} }

View File

@ -395,7 +395,7 @@ bool ftExtraList::saveList(bool &cleanup, std::list<RsItem *>& sList)
std::map<RsFileHash, FileDetails>::const_iterator it; std::map<RsFileHash, FileDetails>::const_iterator it;
for(it = mFiles.begin(); it != mFiles.end(); ++it) for(it = mFiles.begin(); it != mFiles.end(); ++it)
{ {
RsFileConfigItem *fi = new RsFileConfigItem(); RsFileConfigItem_deprecated *fi = new RsFileConfigItem_deprecated();
fi->file.path = (it->second).info.path; fi->file.path = (it->second).info.path;
fi->file.name = (it->second).info.fname; fi->file.name = (it->second).info.fname;
fi->file.hash = (it->second).info.hash; fi->file.hash = (it->second).info.hash;
@ -428,7 +428,7 @@ bool ftExtraList::loadList(std::list<RsItem *>& load)
for(it = load.begin(); it != load.end(); ++it) for(it = load.begin(); it != load.end(); ++it)
{ {
RsFileConfigItem *fi = dynamic_cast<RsFileConfigItem *>(*it); RsFileConfigItem_deprecated *fi = dynamic_cast<RsFileConfigItem_deprecated *>(*it);
if (!fi) if (!fi)
{ {
delete (*it); delete (*it);

View File

@ -206,6 +206,7 @@
#include "retroshare/rsconfig.h" #include "retroshare/rsconfig.h"
#include "retroshare/rsgxsflags.h" #include "retroshare/rsgxsflags.h"
#include "retroshare/rsgxscircles.h" #include "retroshare/rsgxscircles.h"
#include "retroshare/rspeers.h"
#include "pgp/pgpauxutils.h" #include "pgp/pgpauxutils.h"
#include "util/rsdir.h" #include "util/rsdir.h"
#include "util/rsmemory.h" #include "util/rsmemory.h"
@ -265,7 +266,7 @@ static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_GXS_KEY_MISSING = 0x05 ;
|| defined(NXS_NET_DEBUG_4) || defined(NXS_NET_DEBUG_5) || defined(NXS_NET_DEBUG_6) || defined(NXS_NET_DEBUG_7) || defined(NXS_NET_DEBUG_4) || defined(NXS_NET_DEBUG_5) || defined(NXS_NET_DEBUG_6) || defined(NXS_NET_DEBUG_7)
static const RsPeerId peer_to_print = RsPeerId(std::string("")) ; static const RsPeerId peer_to_print = RsPeerId(std::string("")) ;
static const RsGxsGroupId group_id_to_print = RsGxsGroupId(std::string("" )) ; // use this to allow to this group id only, or "" for all IDs static const RsGxsGroupId group_id_to_print = RsGxsGroupId(std::string("87c769d3ffeafdc4433f557d50cdf2e8" )) ; // use this to allow to this group id only, or "" for all IDs
static const uint32_t service_to_print = 0x215 ; // use this to allow to this service id only, or 0 for all services static const uint32_t service_to_print = 0x215 ; // use this to allow to this service id only, or 0 for all services
// warning. Numbers should be SERVICE IDS (see serialiser/rsserviceids.h. E.g. 0x0215 for forums) // warning. Numbers should be SERVICE IDS (see serialiser/rsserviceids.h. E.g. 0x0215 for forums)
@ -4092,7 +4093,7 @@ void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrpReqItem *item)
bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& toVet, bool& should_encrypt) bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& /* toVet */, bool& should_encrypt)
{ {
#ifdef NXS_NET_DEBUG_4 #ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << "RsGxsNetService::canSendGrpId()"<< std::endl; GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << "RsGxsNetService::canSendGrpId()"<< std::endl;
@ -4123,101 +4124,21 @@ bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpM
#endif #endif
should_encrypt = true ; should_encrypt = true ;
return true ; return true ;
#ifdef TO_BE_REMOVED_OLD_VETTING_FOR_EXTERNAL_CIRCLES
const RsGxsCircleId& circleId = grpMeta.mCircleId;
if(circleId.isNull())
{
std::cerr << " EXTERNAL_CIRCLE missing NULL CircleId: " << grpMeta.mGroupId<< std::endl;
// ERROR, will never be shared.
return false;
}
if(mCircles->isLoaded(circleId))
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId)<< " EXTERNAL_CIRCLE, checking mCircles->canSend"<< std::endl;
#endif
// the sending authorisation is based on:
// getPgpId(peer_id) being a signer of one GxsId in the Circle
//
const RsPgpId& pgpId = mPgpUtils->getPGPId(sslId);
bool res = mCircles->canSend(circleId, pgpId);
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId)<< " answer is: " << res << std::endl;
#endif
return res ;
}
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId)<< " grp not ready. Adding to vetting list." << std::endl;
#endif
toVet.push_back(GrpIdCircleVet(grpMeta.mGroupId, circleId, grpMeta.mAuthorId));
return false;
#endif
} }
if(circleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY) if(circleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY)
{ {
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " YOUREYESONLY, checking further" << std::endl;
#endif
bool res = checkPermissionsForFriendGroup(sslId,grpMeta) ;
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Final answer: " << res << std::endl;
#endif
return res ;
#ifdef NXS_NET_DEBUG_4 #ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId)<< " YOUREYESONLY, checking further"<< std::endl; GXSNETDEBUG_PG(sslId,grpMeta.mGroupId)<< " YOUREYESONLY, checking further"<< std::endl;
#endif #endif
// a non empty internal circle id means this
// is the personal circle owner
if(!grpMeta.mInternalCircle.isNull())
{
const RsGxsCircleId& internalCircleId = grpMeta.mInternalCircle;
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " have mInternalCircle - we are Group creator" << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " mCircleId: " << grpMeta.mCircleId << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " mInternalCircle: " << grpMeta.mInternalCircle << std::endl;
#endif
if(mCircles->isLoaded(internalCircleId))
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " circle Loaded - checking mCircles->canSend" << std::endl;
#endif
const RsPgpId& pgpId = mPgpUtils->getPGPId(sslId);
bool should_encrypt = false ;
bool res = mCircles->canSend(internalCircleId, pgpId,should_encrypt);
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " answer is: " << res << std::endl;
#endif
return res ;
}
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle Not Loaded - add to vetting"<< std::endl;
#endif
toVet.push_back(GrpIdCircleVet(grpMeta.mGroupId, internalCircleId, grpMeta.mAuthorId));
return false;
}
else
{
// an empty internal circle id means this peer can only
// send circle related info from peer he received it
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " mInternalCircle not set, someone else's personal circle"<< std::endl;
#endif
if(grpMeta.mOriginator == sslId)
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Originator matches -> can send"<< std::endl;
#endif
return true;
}
else
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Originator doesn't match -> cannot send"<< std::endl;
#endif
return false;
}
}
} }
return true; return true;
@ -4227,121 +4148,51 @@ bool RsGxsNetService::checkCanRecvMsgFromPeer(const RsPeerId& sslId, const RsGxs
{ {
#ifdef NXS_NET_DEBUG_4 #ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << "RsGxsNetService::checkCanRecvMsgFromPeer()"; GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << "RsGxsNetService::checkCanRecvMsgFromPeer()";
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " peer Id = " << sslId << ", grpId=" << grpMeta.mGroupId <<std::endl; GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " peer Id = " << sslId << ", grpId=" << grpMeta.mGroupId <<std::endl;
#endif #endif
// first do the simple checks // first do the simple checks
uint8_t circleType = grpMeta.mCircleType; uint8_t circleType = grpMeta.mCircleType;
should_encrypt_id.clear() ; should_encrypt_id.clear() ;
if(circleType == GXS_CIRCLE_TYPE_LOCAL) if(circleType == GXS_CIRCLE_TYPE_LOCAL)
{ {
#ifdef NXS_NET_DEBUG_4 #ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " LOCAL_CIRCLE, cannot request sync from peer" << std::endl; GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " LOCAL_CIRCLE, cannot request sync from peer" << std::endl;
#endif #endif
return false; return false;
} }
if(circleType == GXS_CIRCLE_TYPE_PUBLIC) if(circleType == GXS_CIRCLE_TYPE_PUBLIC)
{ {
#ifdef NXS_NET_DEBUG_4 #ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " PUBLIC_CIRCLE, can request msg sync" << std::endl; GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " PUBLIC_CIRCLE, can request msg sync" << std::endl;
#endif #endif
return true; return true;
} }
if(circleType == GXS_CIRCLE_TYPE_EXTERNAL) if(circleType == GXS_CIRCLE_TYPE_EXTERNAL)
{ {
#ifdef NXS_NET_DEBUG_4 #ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: EXTERNAL => returning true. Msgs will be encrypted." << std::endl; GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: EXTERNAL => returning true. Msgs will be encrypted." << std::endl;
#endif
should_encrypt_id = grpMeta.mCircleId ;
return true ;
#ifdef TO_BE_REMOVED_OLD_VETTING_FOR_EXTERNAL_CIRCLES
const RsGxsCircleId& circleId = grpMeta.mCircleId;
if(circleId.isNull())
{
#ifdef NXS_NET_DEBUG_0
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " ERROR; EXTERNAL_CIRCLE missing NULL CircleId";
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << grpMeta.mGroupId;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << std::endl;
#endif #endif
should_encrypt_id = grpMeta.mCircleId ;
return true ;
}
// should just be shared. ? no - this happens for if(circleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY) // do not attempt to sync msg unless to originator or those permitted
// Circle Groups which lose their CircleIds. {
// return true; #ifdef NXS_NET_DEBUG_4
} GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " YOUREYESONLY, checking further" << std::endl;
#endif
bool res = checkPermissionsForFriendGroup(sslId,grpMeta) ;
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Final answer: " << res << std::endl;
#endif
return res ;
}
if(mCircles->isLoaded(circleId)) return true;
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " EXTERNAL_CIRCLE, checking mCircles->canSend" << std::endl;
#endif
const RsPgpId& pgpId = mPgpUtils->getPGPId(sslId);
return mCircles->canSend(circleId, pgpId);
}
else
mCircles->loadCircle(circleId); // simply request for next pass
return false;
#endif
}
if(circleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY) // do not attempt to sync msg unless to originator or those permitted
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " YOUREYESONLY, checking further" << std::endl;
#endif
// a non empty internal circle id means this
// is the personal circle owner
if(!grpMeta.mInternalCircle.isNull())
{
const RsGxsCircleId& internalCircleId = grpMeta.mInternalCircle;
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " have mInternalCircle - we are Group creator" << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " mCircleId: " << grpMeta.mCircleId << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " mInternalCircle: " << grpMeta.mInternalCircle << std::endl;
#endif
if(mCircles->isLoaded(internalCircleId))
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " circle Loaded - checking mCircles->canSend" << std::endl;
#endif
const RsPgpId& pgpId = mPgpUtils->getPGPId(sslId);
bool should_encrypt ;
return mCircles->canSend(internalCircleId, pgpId,should_encrypt);
}
else
mCircles->loadCircle(internalCircleId); // request for next pass
return false;
}
else
{
// an empty internal circle id means this peer can only
// send circle related info from peer he received it
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " mInternalCircle not set, someone else's personal circle" << std::endl;
#endif
if(grpMeta.mOriginator == sslId)
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Originator matches -> can send" << std::endl;
#endif
return true;
}
else
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Originator doesn't match -> cannot send"<< std::endl;
#endif
return false;
}
}
}
return true;
} }
bool RsGxsNetService::locked_CanReceiveUpdate(RsNxsSyncMsgReqItem *item,bool& grp_is_known) bool RsGxsNetService::locked_CanReceiveUpdate(RsNxsSyncMsgReqItem *item,bool& grp_is_known)
@ -4618,17 +4469,17 @@ bool RsGxsNetService::canSendMsgIds(std::vector<RsGxsMsgMetaData*>& msgMetas, co
if(circleType == GXS_CIRCLE_TYPE_LOCAL) if(circleType == GXS_CIRCLE_TYPE_LOCAL)
{ {
#ifdef NXS_NET_DEBUG_4 #ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: LOCAL => returning false" << std::endl; GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: LOCAL => returning false" << std::endl;
#endif #endif
return false; return false;
} }
if(circleType == GXS_CIRCLE_TYPE_PUBLIC) if(circleType == GXS_CIRCLE_TYPE_PUBLIC)
{ {
#ifdef NXS_NET_DEBUG_4 #ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: PUBLIC => returning true" << std::endl; GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: PUBLIC => returning true" << std::endl;
#endif #endif
return true; return true;
} }
const RsGxsCircleId& circleId = grpMeta.mCircleId; const RsGxsCircleId& circleId = grpMeta.mCircleId;
@ -4636,119 +4487,116 @@ bool RsGxsNetService::canSendMsgIds(std::vector<RsGxsMsgMetaData*>& msgMetas, co
if(circleType == GXS_CIRCLE_TYPE_EXTERNAL) if(circleType == GXS_CIRCLE_TYPE_EXTERNAL)
{ {
#ifdef NXS_NET_DEBUG_4 #ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: EXTERNAL => returning true. Msgs ids list will be encrypted." << std::endl; GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: EXTERNAL => returning true. Msgs ids list will be encrypted." << std::endl;
#endif #endif
should_encrypt_id = circleId ; should_encrypt_id = circleId ;
// For each message ID, check that the author is in the circle. If not, do not send the message, which means, remove it from the list. // For each message ID, check that the author is in the circle. If not, do not send the message, which means, remove it from the list.
// Unsigned messages are still transmitted. This is because in some groups (channels) the posts are not signed. Whether an unsigned post // Unsigned messages are still transmitted. This is because in some groups (channels) the posts are not signed. Whether an unsigned post
// is allowed at this point is anyway already vetted by the RsGxsGenExchange service. // is allowed at this point is anyway already vetted by the RsGxsGenExchange service.
// Messages that stay in the list will be sent. As a consequence true is always returned. // Messages that stay in the list will be sent. As a consequence true is always returned.
// Messages put in vetting list will be dealt with later // Messages put in vetting list will be dealt with later
std::vector<MsgIdCircleVet> toVet; std::vector<MsgIdCircleVet> toVet;
for(uint32_t i=0;i<msgMetas.size();) for(uint32_t i=0;i<msgMetas.size();)
if( msgMetas[i]->mAuthorId.isNull() ) // keep the message in this case if( msgMetas[i]->mAuthorId.isNull() ) // keep the message in this case
++i ; ++i ;
else else
{ {
if(mCircles->isLoaded(circleId) && mCircles->isRecipient(circleId, grpMeta.mGroupId, msgMetas[i]->mAuthorId)) if(mCircles->isLoaded(circleId) && mCircles->isRecipient(circleId, grpMeta.mGroupId, msgMetas[i]->mAuthorId))
{ {
++i ; ++i ;
continue ; continue ;
} }
MsgIdCircleVet mic(msgMetas[i]->mMsgId, msgMetas[i]->mAuthorId); MsgIdCircleVet mic(msgMetas[i]->mMsgId, msgMetas[i]->mAuthorId);
toVet.push_back(mic); toVet.push_back(mic);
#ifdef NXS_NET_DEBUG_4 #ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " deleting MsgMeta entry for msg ID " << msgMetas[i]->mMsgId << " signed by " << msgMetas[i]->mAuthorId << " who is not in group circle " << circleId << std::endl; GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " deleting MsgMeta entry for msg ID " << msgMetas[i]->mMsgId << " signed by " << msgMetas[i]->mAuthorId << " who is not in group circle " << circleId << std::endl;
#endif #endif
delete msgMetas[i] ; delete msgMetas[i] ;
msgMetas[i] = msgMetas[msgMetas.size()-1] ; msgMetas[i] = msgMetas[msgMetas.size()-1] ;
msgMetas.pop_back() ; msgMetas.pop_back() ;
} }
#ifdef NXS_NET_DEBUG_4 #ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle info not loaded. Putting in vetting list and returning false." << std::endl; GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle info not loaded. Putting in vetting list and returning false." << std::endl;
#endif #endif
if(!toVet.empty()) if(!toVet.empty())
mPendingCircleVets.push_back(new MsgCircleIdsRequestVetting(mCircles, mPgpUtils, toVet, grpMeta.mGroupId, sslId, grpMeta.mCircleId)); mPendingCircleVets.push_back(new MsgCircleIdsRequestVetting(mCircles, mPgpUtils, toVet, grpMeta.mGroupId, sslId, grpMeta.mCircleId));
return true ; return true ;
} }
if(circleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY) if(circleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY)
{ {
#ifdef NXS_NET_DEBUG_4 #ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: YOUR EYES ONLY" << std::endl; GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " YOUREYESONLY, checking further" << std::endl;
#endif #endif
// a non empty internal circle id means this bool res = checkPermissionsForFriendGroup(sslId,grpMeta) ;
// is the personal circle owner
if(!grpMeta.mInternalCircle.isNull())
{
const RsGxsCircleId& internalCircleId = grpMeta.mInternalCircle;
#ifdef NXS_NET_DEBUG_4 #ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Group internal circle: " << internalCircleId << std::endl; GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Final answer: " << res << std::endl;
#endif #endif
if(mCircles->isLoaded(internalCircleId)) return res ;
{ }
const RsPgpId& pgpId = mPgpUtils->getPGPId(sslId);
bool should_encrypt = false ;
bool res= mCircles->canSend(internalCircleId, pgpId,should_encrypt); return false;
if(should_encrypt)
std::cerr << "(EE) inconsistent response: vetting requests to encrypt circle of type YOUR_EYES_ONLY" << std::endl;
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Answer from circle::canSend(): " << res << std::endl;
#endif
return res ;
}
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Not loaded. Putting in vetting list and returning false." << std::endl;
#endif
std::vector<MsgIdCircleVet> toVet;
std::vector<RsGxsMsgMetaData*>::const_iterator vit = msgMetas.begin();
for(; vit != msgMetas.end(); ++vit)
{
const RsGxsMsgMetaData* const& meta = *vit;
MsgIdCircleVet mic(meta->mMsgId, meta->mAuthorId);
toVet.push_back(mic);
}
if(!toVet.empty())
mPendingCircleVets.push_back(new MsgCircleIdsRequestVetting(mCircles, mPgpUtils,
toVet, grpMeta.mGroupId,
sslId, grpMeta.mCircleId));
return false;
}
else
{
// an empty internal circle id means this peer can only
// send circle related info from peer he received it
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Empty internal circle: cannot only send info from Peer we received it (grpMeta.mOriginator=" << grpMeta.mOriginator << " answer is: " << (grpMeta.mOriginator == sslId) << std::endl;
#endif
if(grpMeta.mOriginator == sslId)
return true;
else
return false;
}
}
return false;
} }
/** inherited methods **/ /** inherited methods **/
bool RsGxsNetService::checkPermissionsForFriendGroup(const RsPeerId& sslId,const RsGxsGrpMetaData& grpMeta)
{
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: YOUR EYES ONLY - ID = " << grpMeta.mInternalCircle << std::endl;
#endif
// a non empty internal circle id means this
// is the personal circle owner
if(!grpMeta.mInternalCircle.isNull())
{
RsGroupInfo ginfo ;
RsPgpId pgpId = mPgpUtils->getPGPId(sslId) ;
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Group internal circle: " << grpMeta.mInternalCircle << ", We're owner. Sending to everyone in the group." << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Current destination is PGP Id: " << pgpId << std::endl;
#endif
if(!rsPeers->getGroupInfo(RsNodeGroupId(grpMeta.mInternalCircle),ginfo))
{
std::cerr << "(EE) Cannot get information for internal circle (group node) ID " << grpMeta.mInternalCircle << " which conditions dissemination of GXS group " << grpMeta.mGroupId << std::endl;
return false ;
}
bool res = (ginfo.peerIds.find(pgpId) != ginfo.peerIds.end());
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Final Answer is: " << res << std::endl;
#endif
return res ;
}
else
{
// An empty internal circle id means this peer can only
// send circle related info from peer he received it from.
// Normally this should be a pgp-based decision, but if we do that,
// A ---> B ----> A' ---...--->B' , then A' will also send to B' since B is the
// originator for A'. So A will lose control of who can see the data. This should
// be discussed further...
#ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Empty internal circle: cannot only send/recv info to/from Peer we received it from (grpMeta.mOriginator=" << grpMeta.mOriginator << ")" << std::endl;
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Final answer is: " << (grpMeta.mOriginator == sslId) << std::endl;
#endif
if(grpMeta.mOriginator == sslId)
return true;
else
return false;
}
}
void RsGxsNetService::pauseSynchronisation(bool /* enabled */) void RsGxsNetService::pauseSynchronisation(bool /* enabled */)
{ {

View File

@ -354,6 +354,15 @@ private:
bool canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& toVet, bool &should_encrypt); bool canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& toVet, bool &should_encrypt);
bool canSendMsgIds(std::vector<RsGxsMsgMetaData*>& msgMetas, const RsGxsGrpMetaData&, const RsPeerId& sslId, RsGxsCircleId &should_encrypt_id); bool canSendMsgIds(std::vector<RsGxsMsgMetaData*>& msgMetas, const RsGxsGrpMetaData&, const RsPeerId& sslId, RsGxsCircleId &should_encrypt_id);
/*!
* \brief checkPermissionsForFriendGroup
* Checks that we can send/recv from that node, given that the grpMeta has a distribution limited to a local circle.
* \param sslId Candidate peer to send to or to receive from.
* \param grpMeta Contains info about the group id, internal circle id, etc.
* \return true only when the internal exists and validates as a friend node group, and contains the owner of sslId.
*/
bool checkPermissionsForFriendGroup(const RsPeerId& sslId,const RsGxsGrpMetaData& grpMeta) ;
bool checkCanRecvMsgFromPeer(const RsPeerId& sslId, const RsGxsGrpMetaData& meta, RsGxsCircleId& should_encrypt_id); bool checkCanRecvMsgFromPeer(const RsPeerId& sslId, const RsGxsGrpMetaData& meta, RsGxsCircleId& should_encrypt_id);
void locked_createTransactionFromPending(MsgRespPending* grpPend); void locked_createTransactionFromPending(MsgRespPending* grpPend);

View File

@ -138,8 +138,6 @@ p3LinkMgrIMPL::p3LinkMgrIMPL(p3PeerMgrIMPL *peerMgr, p3NetMgrIMPL *netMgr)
mDNSResolver = new DNSResolver(); mDNSResolver = new DNSResolver();
mRetryPeriod = MIN_RETRY_PERIOD; mRetryPeriod = MIN_RETRY_PERIOD;
lastGroupId = 1;
/* setup Banned Ip Address - static for now /* setup Banned Ip Address - static for now
*/ */

View File

@ -132,7 +132,7 @@ class peerConnectState
}; };
class p3tunnel; class p3tunnel;
class RsPeerGroupItem; class RsPeerGroupItem_deprecated;
class RsGroupInfo; class RsGroupInfo;
class p3PeerMgr; class p3PeerMgr;
@ -339,9 +339,6 @@ private:
std::map<RsPeerId, peerConnectState> mFriendList; std::map<RsPeerId, peerConnectState> mFriendList;
std::map<RsPeerId, peerConnectState> mOthersList; std::map<RsPeerId, peerConnectState> mOthersList;
std::list<RsPeerGroupItem *> groupList;
uint32_t lastGroupId;
/* relatively static list of banned ip addresses */ /* relatively static list of banned ip addresses */
std::list<struct sockaddr_storage> mBannedIpList; std::list<struct sockaddr_storage> mBannedIpList;
}; };

View File

@ -130,8 +130,6 @@ p3PeerMgrIMPL::p3PeerMgrIMPL(const RsPeerId& ssl_own_id, const RsPgpId& gpg_own_
mOwnState.vs_disc = RS_VS_DISC_FULL; mOwnState.vs_disc = RS_VS_DISC_FULL;
mOwnState.vs_dht = RS_VS_DHT_FULL; mOwnState.vs_dht = RS_VS_DHT_FULL;
lastGroupId = 1;
// setup default ProxyServerAddress. // setup default ProxyServerAddress.
// Tor // Tor
sockaddr_storage_clear(mProxyServerAddressTor); sockaddr_storage_clear(mProxyServerAddressTor);
@ -1071,7 +1069,7 @@ bool p3PeerMgrIMPL::removeFriend(const RsPgpId &id)
std::list<RsPgpId> ids ; std::list<RsPgpId> ids ;
ids.push_back(id) ; ids.push_back(id) ;
assignPeersToGroup("", ids, false); assignPeersToGroup(RsNodeGroupId(), ids, false);
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
@ -1145,7 +1143,7 @@ bool p3PeerMgrIMPL::removeFriend(const RsPeerId &id, bool removePgpId)
/* remove id from all groups */ /* remove id from all groups */
assignPeersToGroup("", pgpid_toRemove, false); assignPeersToGroup(RsNodeGroupId(), pgpid_toRemove, false);
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
@ -1915,7 +1913,7 @@ RsSerialiser *p3PeerMgrIMPL::setupSerialiser()
bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData) bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
{ {
/* create a list of current peers */ /* create a list of current peers */
cleanup = false; cleanup = true;
bool useExtAddrFinder = mNetMgr->getIPServersEnabled(); bool useExtAddrFinder = mNetMgr->getIPServersEnabled();
/* gather these information before mPeerMtx is locked! */ /* gather these information before mPeerMtx is locked! */
@ -1971,7 +1969,6 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
#endif #endif
saveData.push_back(item); saveData.push_back(item);
saveCleanupList.push_back(item);
/* iterate through all friends and save */ /* iterate through all friends and save */
std::map<RsPeerId, peerState>::iterator it; std::map<RsPeerId, peerState>::iterator it;
@ -2003,7 +2000,6 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
item->domain_port = (it->second).hiddenPort; item->domain_port = (it->second).hiddenPort;
saveData.push_back(item); saveData.push_back(item);
saveCleanupList.push_back(item);
#ifdef PEER_DEBUG #ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::saveList() Peer Config Item:" << std::endl; std::cerr << "p3PeerMgrIMPL::saveList() Peer Config Item:" << std::endl;
item->print(std::cerr, 10); item->print(std::cerr, 10);
@ -2024,7 +2020,6 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
} }
saveData.push_back(sitem) ; saveData.push_back(sitem) ;
saveCleanupList.push_back(sitem);
// Now save config for network digging strategies // Now save config for network digging strategies
@ -2066,14 +2061,14 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
vitem->tlvkvs.pairs.push_back(kv) ; vitem->tlvkvs.pairs.push_back(kv) ;
saveData.push_back(vitem); saveData.push_back(vitem);
saveCleanupList.push_back(vitem);
/* save groups */ /* save groups */
std::list<RsPeerGroupItem *>::iterator groupIt; for ( std::map<RsNodeGroupId,RsGroupInfo>::iterator groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt)
for (groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt) { {
saveData.push_back(*groupIt); // no delete RsNodeGroupItem *itm = new RsNodeGroupItem(groupIt->second);
} saveData.push_back(itm) ;
}
return true; return true;
} }
@ -2294,7 +2289,8 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
continue; continue;
} }
RsPeerGroupItem *gitem = dynamic_cast<RsPeerGroupItem *>(*it) ; RsPeerGroupItem_deprecated *gitem = dynamic_cast<RsPeerGroupItem_deprecated *>(*it) ;
if (gitem) if (gitem)
{ {
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
@ -2304,20 +2300,54 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
gitem->print(std::cerr, 10); gitem->print(std::cerr, 10);
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
RsGroupInfo ginfo ;
ginfo.flag = gitem->flag ;
ginfo.name = gitem->name ;
ginfo.peerIds = gitem->pgpList.ids ;
groupList.push_back(gitem); // don't delete do { ginfo.id = RsNodeGroupId::random(); } while(groupList.find(ginfo.id) != groupList.end()) ;
if ((gitem->flag & RS_GROUP_FLAG_STANDARD) == 0) { // Ensure backward compatibility when loading the group in old format. The id must matchthe standard default id.
/* calculate group id */
uint32_t groupId = atoi(gitem->id.c_str());
if (groupId > lastGroupId) {
lastGroupId = groupId;
}
}
continue; if(gitem->id == std::string(RS_GROUP_DEFAULT_NAME_FRIENDS )) ginfo.id = RS_GROUP_ID_FRIENDS ;
if(gitem->id == std::string(RS_GROUP_DEFAULT_NAME_COWORKERS)) ginfo.id = RS_GROUP_ID_COWORKERS ;
if(gitem->id == std::string(RS_GROUP_DEFAULT_NAME_FAMILY )) ginfo.id = RS_GROUP_ID_FAMILY ;
if(gitem->id == std::string(RS_GROUP_DEFAULT_NAME_FAVORITES)) ginfo.id = RS_GROUP_ID_FAVORITES ;
if(gitem->id == std::string(RS_GROUP_DEFAULT_NAME_OTHERS )) ginfo.id = RS_GROUP_ID_OTHERS ;
if(!ginfo.id.isNull())
{
groupList[ginfo.id] = ginfo ;
std::cerr << "(II) Creating new group for old format local group \"" << gitem->name << "\". Id=" << ginfo.id << std::endl;
}
else
std::cerr << "(EE) no group corresponding to old format group with ID=\"" << gitem->id << "\"" << std::endl;
continue;
} }
RsNodeGroupItem *gitem2 = dynamic_cast<RsNodeGroupItem*>(*it) ;
if (gitem2)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::loadList() Peer group item:" << std::endl;
gitem->print(std::cerr, 10);
std::cerr << std::endl;
#endif
RsGroupInfo info ;
info.peerIds = gitem2->pgpList.ids ;
info.id = gitem2->id ;
info.name = gitem2->name ;
info.flag = gitem2->flag ;
std::cerr << "(II) Loaded group in new format. ID = " << info.id << std::endl;
groupList[info.id] = info ;
continue;
}
RsPeerBandwidthLimitsItem *pblitem = dynamic_cast<RsPeerBandwidthLimitsItem*>(*it) ; RsPeerBandwidthLimitsItem *pblitem = dynamic_cast<RsPeerBandwidthLimitsItem*>(*it) ;
if(pblitem) if(pblitem)
@ -2363,42 +2393,19 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
/* Standard groups */ /* Standard groups */
const int standardGroupCount = 5; const int standardGroupCount = 5;
const char *standardGroup[standardGroupCount] = { RS_GROUP_ID_FRIENDS, RS_GROUP_ID_FAMILY, RS_GROUP_ID_COWORKERS, RS_GROUP_ID_OTHERS, RS_GROUP_ID_FAVORITES }; const RsNodeGroupId standardGroupIds [standardGroupCount] = { RS_GROUP_ID_FRIENDS, RS_GROUP_ID_FAMILY, RS_GROUP_ID_COWORKERS, RS_GROUP_ID_OTHERS, RS_GROUP_ID_FAVORITES };
bool foundStandardGroup[standardGroupCount] = { false, false, false, false, false }; const char *standardGroupNames[standardGroupCount] = { RS_GROUP_DEFAULT_NAME_FRIENDS, RS_GROUP_DEFAULT_NAME_FAMILY, RS_GROUP_DEFAULT_NAME_COWORKERS, RS_GROUP_DEFAULT_NAME_OTHERS, RS_GROUP_DEFAULT_NAME_FAVORITES };
std::list<RsPeerGroupItem *>::iterator groupIt; for(uint32_t k=0;k<standardGroupCount;++k)
for (groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt) { if(groupList.find(standardGroupIds[k]) == groupList.end())
if ((*groupIt)->flag & RS_GROUP_FLAG_STANDARD) { {
int i; RsGroupInfo info ;
for (i = 0; i < standardGroupCount; ++i) { info.id = standardGroupIds[k];
if ((*groupIt)->id == standardGroup[i]) { info.name = standardGroupNames[k];
foundStandardGroup[i] = true; info.flag |= RS_GROUP_FLAG_STANDARD;
break;
}
}
if (i >= standardGroupCount) { groupList[info.id] = info;
/* No more a standard group, remove the flag standard */
(*groupIt)->flag &= ~RS_GROUP_FLAG_STANDARD;
}
} else {
uint32_t groupId = atoi((*groupIt)->id.c_str());
if (groupId == 0) {
rs_sprintf((*groupIt)->id, "%lu", lastGroupId++);
}
} }
}
/* Initialize standard groups */
for (int i = 0; i < standardGroupCount; ++i) {
if (foundStandardGroup[i] == false) {
RsPeerGroupItem *gitem = new RsPeerGroupItem;
gitem->id = standardGroup[i];
gitem->name = standardGroup[i];
gitem->flag |= RS_GROUP_FLAG_STANDARD;
groupList.push_back(gitem);
}
}
} }
// If we are hidden - don't want ExtAddrFinder - ever! // If we are hidden - don't want ExtAddrFinder - ever!
@ -2478,19 +2485,16 @@ bool p3PeerMgrIMPL::addGroup(RsGroupInfo &groupInfo)
{ {
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
RsPeerGroupItem *groupItem = new RsPeerGroupItem; do { groupInfo.id = RsNodeGroupId::random(); } while(groupList.find(groupInfo.id) != groupList.end()) ;
groupItem->set(groupInfo);
rs_sprintf(groupItem->id, "%lu", ++lastGroupId); RsGroupInfo groupItem(groupInfo) ;
// remove standard flag // remove standard flag
groupItem->flag &= ~RS_GROUP_FLAG_STANDARD;
groupItem->PeerId(getOwnId()); groupItem.flag &= ~RS_GROUP_FLAG_STANDARD;
groupList[groupInfo.id] = groupItem;
groupList.push_back(groupItem); std::cerr << "(II) Added new group with ID " << groupInfo.id << ", name=\"" << groupInfo.name << "\"" << std::endl;
groupInfo.id = groupItem->id;
} }
RsServer::notify()->notifyListChange(NOTIFY_LIST_GROUPLIST, NOTIFY_TYPE_ADD); RsServer::notify()->notifyListChange(NOTIFY_LIST_GROUPLIST, NOTIFY_TYPE_ADD);
@ -2500,35 +2504,39 @@ bool p3PeerMgrIMPL::addGroup(RsGroupInfo &groupInfo)
return true; return true;
} }
bool p3PeerMgrIMPL::editGroup(const std::string &groupId, RsGroupInfo &groupInfo) bool p3PeerMgrIMPL::editGroup(const RsNodeGroupId& groupId, RsGroupInfo &groupInfo)
{ {
if (groupId.empty()) { if (groupId.isNull())
return false; return false;
}
bool changed = false; bool changed = false;
{ {
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
std::list<RsPeerGroupItem*>::iterator groupIt; std::map<RsNodeGroupId,RsGroupInfo>::iterator it = groupList.find(groupId) ;
for (groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt) {
if ((*groupIt)->id == groupId) {
break;
}
}
if (groupIt != groupList.end()) { if(it == groupList.end())
if ((*groupIt)->flag & RS_GROUP_FLAG_STANDARD) { {
// can't edit standard groups std::cerr << "(EE) cannot find local node group with ID " << groupId << std::endl;
} else { return false ;
changed = true; }
(*groupIt)->set(groupInfo);
}
}
}
if (changed) { if (it->second.flag & RS_GROUP_FLAG_STANDARD)
{
// can't edit standard groups
std::cerr << "(EE) cannot edit standard group with ID " << groupId << std::endl;
return false ;
}
else
{
changed = true;
it->second = groupInfo;
}
}
if (changed)
{
RsServer::notify()->notifyListChange(NOTIFY_LIST_GROUPLIST, NOTIFY_TYPE_MOD); RsServer::notify()->notifyListChange(NOTIFY_LIST_GROUPLIST, NOTIFY_TYPE_MOD);
IndicateConfigChanged(); IndicateConfigChanged();
@ -2537,31 +2545,35 @@ bool p3PeerMgrIMPL::editGroup(const std::string &groupId, RsGroupInfo &groupInfo
return changed; return changed;
} }
bool p3PeerMgrIMPL::removeGroup(const std::string &groupId) bool p3PeerMgrIMPL::removeGroup(const RsNodeGroupId& groupId)
{ {
if (groupId.empty()) {
return false;
}
bool changed = false; bool changed = false;
{ {
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
std::list<RsPeerGroupItem*>::iterator groupIt; std::map<RsNodeGroupId,RsGroupInfo>::iterator it = groupList.find(groupId) ;
for (groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt) {
if ((*groupIt)->id == groupId) {
break;
}
}
if (groupIt != groupList.end()) { if (it != groupList.end()) {
if ((*groupIt)->flag & RS_GROUP_FLAG_STANDARD) { if (it->second.flag & RS_GROUP_FLAG_STANDARD)
{
// can't remove standard groups // can't remove standard groups
} else { std::cerr << "(EE) cannot remove standard group with ID " << groupId << std::endl;
return false ;
}
#warning we need to check that the local group is not used. Otherwise deleting it is going to cause problems!
// else if(!it->second.used_gxs_groups.empty())
// {
// std::cerr << "(EE) cannot remove standard group with ID " << groupId << " because it is used in the following groups: " << std::endl;
// for(std::set<RsGxsGroupId>::const_iterator it2(it->second.used_gxs_groups.begin());it2!=it->second.used_gxs_groups.end();++it2)
// std::cerr << " " << *it2 << std::endl;
//
// return false ;
// }
else
{
changed = true; changed = true;
delete(*groupIt); groupList.erase(it);
groupList.erase(groupIt);
} }
} }
} }
@ -2575,82 +2587,83 @@ bool p3PeerMgrIMPL::removeGroup(const std::string &groupId)
return changed; return changed;
} }
bool p3PeerMgrIMPL::getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) bool p3PeerMgrIMPL::getGroupInfoByName(const std::string& groupName, RsGroupInfo &groupInfo)
{ {
if (groupId.empty()) { RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
return false;
}
for(std::map<RsNodeGroupId,RsGroupInfo>::iterator it = groupList.begin();it!=groupList.end();++it)
if(it->second.name == groupName)
{
groupInfo = it->second ;
return true ;
}
std::cerr << "(EE) getGroupInfoByName: no known group for name " << groupName << std::endl;
return false ;
}
bool p3PeerMgrIMPL::getGroupInfo(const RsNodeGroupId& groupId, RsGroupInfo &groupInfo)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
std::list<RsPeerGroupItem*>::iterator groupIt; std::map<RsNodeGroupId,RsGroupInfo>::iterator it = groupList.find(groupId) ;
for (groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt) {
if ((*groupIt)->id == groupId) {
(*groupIt)->get(groupInfo);
return true; if(it == groupList.end())
} return false ;
}
return false; groupInfo = it->second;
return true;
} }
bool p3PeerMgrIMPL::getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) bool p3PeerMgrIMPL::getGroupInfoList(std::list<RsGroupInfo>& groupInfoList)
{ {
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
std::list<RsPeerGroupItem*>::iterator groupIt; for (std::map<RsNodeGroupId,RsGroupInfo> ::const_iterator groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt)
for (groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt) { groupInfoList.push_back(groupIt->second);
RsGroupInfo groupInfo;
(*groupIt)->get(groupInfo);
groupInfoList.push_back(groupInfo);
}
return true; return true;
} }
// groupId == "" && assign == false -> remove from all groups // groupId.isNull() && assign == false -> remove from all groups
bool p3PeerMgrIMPL::assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign)
{
if (groupId.empty() && assign == true) {
return false;
}
if (peerIds.empty()) { bool p3PeerMgrIMPL::assignPeersToGroup(const RsNodeGroupId &groupId, const std::list<RsPgpId> &peerIds, bool assign)
{
if (groupId.isNull() && assign == true)
return false;
if (peerIds.empty())
return false; return false;
}
bool changed = false; bool changed = false;
{ {
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
std::list<RsPeerGroupItem*>::iterator groupIt; for (std::map<RsNodeGroupId,RsGroupInfo>::iterator groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt)
for (groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt) { if (groupId.isNull() || groupIt->first == groupId)
if (groupId.empty() || (*groupIt)->id == groupId) { {
RsPeerGroupItem *groupItem = *groupIt; RsGroupInfo& groupItem = groupIt->second;
std::list<RsPgpId>::const_iterator peerIt; for (std::list<RsPgpId>::const_iterator peerIt = peerIds.begin(); peerIt != peerIds.end(); ++peerIt)
for (peerIt = peerIds.begin(); peerIt != peerIds.end(); ++peerIt) { {
std::set<RsPgpId>::iterator peerIt1 = std::find(groupItem->pgpList.ids.begin(), groupItem->pgpList.ids.end(), *peerIt); std::set<RsPgpId>::iterator peerIt1 = groupItem.peerIds.find(*peerIt);
if (assign) {
if (peerIt1 == groupItem->pgpList.ids.end()) { if (assign)
groupItem->pgpList.ids.insert(*peerIt); {
changed = true; groupItem.peerIds.insert(*peerIt);
} changed = true;
} else { }
if (peerIt1 != groupItem->pgpList.ids.end()) { else
groupItem->pgpList.ids.erase(peerIt1); {
changed = true; groupItem.peerIds.erase(*peerIt);
} changed = true;
} }
} }
if (groupId.empty() == false) { if (!groupId.isNull())
break; break;
}
} }
}
} }
if (changed) { if (changed) {

View File

@ -106,7 +106,7 @@ class peerState
uint32_t maxDnRate ; uint32_t maxDnRate ;
}; };
class RsPeerGroupItem; class RsNodeGroupItem;
class RsGroupInfo; class RsGroupInfo;
std::string textPeerState(peerState &state); std::string textPeerState(peerState &state);
@ -139,11 +139,12 @@ virtual bool removeAllFriendLocations(const RsPgpId &gpgid) = 0;
/* This is solely used by p3peers - makes sense */ /* This is solely used by p3peers - makes sense */
virtual bool addGroup(RsGroupInfo &groupInfo) = 0; virtual bool addGroup(RsGroupInfo &groupInfo) = 0;
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo) = 0; virtual bool editGroup(const RsNodeGroupId &groupId, RsGroupInfo &groupInfo) = 0;
virtual bool removeGroup(const std::string &groupId) = 0; virtual bool removeGroup(const RsNodeGroupId &groupId) = 0;
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0; virtual bool getGroupInfo(const RsNodeGroupId &groupId, RsGroupInfo &groupInfo) = 0;
virtual bool getGroupInfoByName(const std::string& groupName, RsGroupInfo &groupInfo) = 0;
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0; virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign) = 0; virtual bool assignPeersToGroup(const RsNodeGroupId &groupId, const std::list<RsPgpId> &peerIds, bool assign) = 0;
virtual bool resetOwnExternalAddressList() = 0 ; virtual bool resetOwnExternalAddressList() = 0 ;
@ -231,181 +232,182 @@ virtual bool locked_computeCurrentBestOwnExtAddressCandidate(sockaddr_storage
class p3PeerMgrIMPL: public p3PeerMgr, public p3Config class p3PeerMgrIMPL: public p3PeerMgr, public p3Config
{ {
public: public:
/************************************************************************************************/ /************************************************************************************************/
/* EXTERNAL INTERFACE */ /* EXTERNAL INTERFACE */
/************************************************************************************************/ /************************************************************************************************/
virtual bool addFriend(const RsPeerId&ssl_id, const RsPgpId&gpg_id, uint32_t netMode = RS_NET_MODE_UDP, virtual bool addFriend(const RsPeerId&ssl_id, const RsPgpId&gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL, uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL,
time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_NODE_PERM_DEFAULT)); time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_NODE_PERM_DEFAULT));
virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId); virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId);
virtual bool removeFriend(const RsPgpId &pgp_id); virtual bool removeFriend(const RsPgpId &pgp_id);
virtual bool isFriend(const RsPeerId &ssl_id); virtual bool isFriend(const RsPeerId &ssl_id);
virtual bool getAssociatedPeers(const RsPgpId &gpg_id, std::list<RsPeerId> &ids); virtual bool getAssociatedPeers(const RsPgpId &gpg_id, std::list<RsPeerId> &ids);
virtual bool removeAllFriendLocations(const RsPgpId &gpgid); virtual bool removeAllFriendLocations(const RsPgpId &gpgid);
/******************** Groups **********************/ /******************** Groups **********************/
/* This is solely used by p3peers - makes sense */ /* This is solely used by p3peers - makes sense */
virtual bool addGroup(RsGroupInfo &groupInfo); virtual bool addGroup(RsGroupInfo &groupInfo);
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo); virtual bool editGroup(const RsNodeGroupId &groupId, RsGroupInfo &groupInfo);
virtual bool removeGroup(const std::string &groupId); virtual bool removeGroup(const RsNodeGroupId &groupId);
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo); virtual bool getGroupInfo(const RsNodeGroupId &groupId, RsGroupInfo &groupInfo);
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList); virtual bool getGroupInfoByName(const std::string& groupName, RsGroupInfo &groupInfo) ;
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign); virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
virtual bool assignPeersToGroup(const RsNodeGroupId &groupId, const std::list<RsPgpId> &peerIds, bool assign);
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) ; virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) ;
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) ; virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) ;
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) ; virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) ;
/**************** Set Net Info ****************/ /**************** Set Net Info ****************/
/* /*
* These functions are used by: * These functions are used by:
* 1) p3linkmgr * 1) p3linkmgr
* 2) p3peers - reasonable * 2) p3peers - reasonable
* 3) p3disc - reasonable * 3) p3disc - reasonable
*/ */
virtual bool setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr); virtual bool setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr);
virtual bool setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr); virtual bool setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr);
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns); virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns);
virtual bool addCandidateForOwnExternalAddress(const RsPeerId& from, const struct sockaddr_storage &addr) ; virtual bool addCandidateForOwnExternalAddress(const RsPeerId& from, const struct sockaddr_storage &addr) ;
virtual bool getExtAddressReportedByFriends(struct sockaddr_storage& addr, uint8_t &isstable) ; virtual bool getExtAddressReportedByFriends(struct sockaddr_storage& addr, uint8_t &isstable) ;
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode); virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode);
virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht); virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht);
virtual bool setLocation(const RsPeerId &pid, const std::string &location); virtual bool setLocation(const RsPeerId &pid, const std::string &location);
virtual bool setHiddenDomainPort(const RsPeerId &id, const std::string &domain_addr, const uint16_t domain_port); virtual bool setHiddenDomainPort(const RsPeerId &id, const std::string &domain_addr, const uint16_t domain_port);
virtual bool updateCurrentAddress(const RsPeerId& id, const pqiIpAddress &addr); virtual bool updateCurrentAddress(const RsPeerId& id, const pqiIpAddress &addr);
virtual bool updateLastContact(const RsPeerId& id); virtual bool updateLastContact(const RsPeerId& id);
virtual bool updateAddressList(const RsPeerId& id, const pqiIpAddrSet &addrs); virtual bool updateAddressList(const RsPeerId& id, const pqiIpAddrSet &addrs);
virtual bool resetOwnExternalAddressList() ; virtual bool resetOwnExternalAddressList() ;
// THIS MUST ONLY BE CALLED BY NETMGR!!!! // THIS MUST ONLY BE CALLED BY NETMGR!!!!
virtual bool UpdateOwnAddress(const struct sockaddr_storage &local_addr, const struct sockaddr_storage &ext_addr); virtual bool UpdateOwnAddress(const struct sockaddr_storage &local_addr, const struct sockaddr_storage &ext_addr);
/**************** Net Status Info ****************/ /**************** Net Status Info ****************/
/* /*
* MUST RATIONALISE THE DATA FROM THESE FUNCTIONS * MUST RATIONALISE THE DATA FROM THESE FUNCTIONS
* These functions are used by: * These functions are used by:
* 1) p3face-config ... to remove! * 1) p3face-config ... to remove!
* 2) p3peers - reasonable * 2) p3peers - reasonable
* 3) p3disc - reasonable * 3) p3disc - reasonable
*/ */
virtual bool getOwnNetStatus(peerState &state); virtual bool getOwnNetStatus(peerState &state);
virtual bool getFriendNetStatus(const RsPeerId &id, peerState &state); virtual bool getFriendNetStatus(const RsPeerId &id, peerState &state);
virtual bool getOthersNetStatus(const RsPeerId &id, peerState &state); virtual bool getOthersNetStatus(const RsPeerId &id, peerState &state);
virtual bool getPeerName(const RsPeerId& ssl_id, std::string& name); virtual bool getPeerName(const RsPeerId& ssl_id, std::string& name);
virtual bool getGpgId(const RsPeerId& sslId, RsPgpId& gpgId); virtual bool getGpgId(const RsPeerId& sslId, RsPgpId& gpgId);
virtual uint32_t getConnectionType(const RsPeerId& sslId); virtual uint32_t getConnectionType(const RsPeerId& sslId);
virtual bool setProxyServerAddress(const uint32_t type, const struct sockaddr_storage &proxy_addr); virtual bool setProxyServerAddress(const uint32_t type, const struct sockaddr_storage &proxy_addr);
virtual bool getProxyServerAddress(const uint32_t type, struct sockaddr_storage &proxy_addr); virtual bool getProxyServerAddress(const uint32_t type, struct sockaddr_storage &proxy_addr);
virtual bool getProxyServerStatus(const uint32_t type, uint32_t &proxy_status); virtual bool getProxyServerStatus(const uint32_t type, uint32_t &proxy_status);
virtual bool isHidden(); virtual bool isHidden();
virtual bool isHidden(const uint32_t type); virtual bool isHidden(const uint32_t type);
virtual bool isHiddenPeer(const RsPeerId &ssl_id); virtual bool isHiddenPeer(const RsPeerId &ssl_id);
virtual bool isHiddenPeer(const RsPeerId &ssl_id, const uint32_t type); virtual bool isHiddenPeer(const RsPeerId &ssl_id, const uint32_t type);
virtual bool getProxyAddress(const RsPeerId& ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port); virtual bool getProxyAddress(const RsPeerId& ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port);
virtual uint32_t hiddenDomainToHiddenType(const std::string &domain); virtual uint32_t hiddenDomainToHiddenType(const std::string &domain);
virtual uint32_t getHiddenType(const RsPeerId &ssl_id); virtual uint32_t getHiddenType(const RsPeerId &ssl_id);
virtual int getFriendCount(bool ssl, bool online); virtual int getFriendCount(bool ssl, bool online);
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/ /************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
// Single Use Function... shouldn't be here. used by p3serverconfig.cc // Single Use Function... shouldn't be here. used by p3serverconfig.cc
virtual bool haveOnceConnected(); virtual bool haveOnceConnected();
virtual bool setMaxRates(const RsPgpId& pid,uint32_t maxUp,uint32_t maxDn); virtual bool setMaxRates(const RsPgpId& pid,uint32_t maxUp,uint32_t maxDn);
virtual bool getMaxRates(const RsPgpId& pid,uint32_t& maxUp,uint32_t& maxDn); virtual bool getMaxRates(const RsPgpId& pid,uint32_t& maxUp,uint32_t& maxDn);
virtual bool getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& maxDn); virtual bool getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& maxDn);
/************************************************************************************************/ /************************************************************************************************/
/* Extra IMPL Functions (used by p3LinkMgr, p3NetMgr + Setup) */ /* Extra IMPL Functions (used by p3LinkMgr, p3NetMgr + Setup) */
/************************************************************************************************/ /************************************************************************************************/
p3PeerMgrIMPL( const RsPeerId& ssl_own_id, p3PeerMgrIMPL( const RsPeerId& ssl_own_id,
const RsPgpId& gpg_own_id, const RsPgpId& gpg_own_id,
const std::string& gpg_own_name, const std::string& gpg_own_name,
const std::string& ssl_own_location) ; const std::string& ssl_own_location) ;
void setManagers(p3LinkMgrIMPL *linkMgr, p3NetMgrIMPL *netMgr); void setManagers(p3LinkMgrIMPL *linkMgr, p3NetMgrIMPL *netMgr);
bool forceHiddenNode(); bool forceHiddenNode();
bool setupHiddenNode(const std::string &hiddenAddress, const uint16_t hiddenPort); bool setupHiddenNode(const std::string &hiddenAddress, const uint16_t hiddenPort);
void tick(); void tick();
const RsPeerId& getOwnId(); const RsPeerId& getOwnId();
bool setOwnNetworkMode(uint32_t netMode); bool setOwnNetworkMode(uint32_t netMode);
bool setOwnVisState(uint16_t vs_disc, uint16_t vs_dht); bool setOwnVisState(uint16_t vs_disc, uint16_t vs_dht);
int getConnectAddresses(const RsPeerId &id, int getConnectAddresses(const RsPeerId &id,
struct sockaddr_storage &lAddr, struct sockaddr_storage &eAddr, struct sockaddr_storage &lAddr, struct sockaddr_storage &eAddr,
pqiIpAddrSet &histAddrs, std::string &dyndns); pqiIpAddrSet &histAddrs, std::string &dyndns);
protected: protected:
/* Internal Functions */ /* Internal Functions */
bool removeUnusedLocations(); bool removeUnusedLocations();
bool removeBannedIps(); bool removeBannedIps();
void printPeerLists(std::ostream &out); void printPeerLists(std::ostream &out);
virtual bool locked_computeCurrentBestOwnExtAddressCandidate(sockaddr_storage &addr, uint32_t &count); virtual bool locked_computeCurrentBestOwnExtAddressCandidate(sockaddr_storage &addr, uint32_t &count);
protected: protected:
/*****************************************************************/ /*****************************************************************/
/*********************** p3config ******************************/ /*********************** p3config ******************************/
/* Key Functions to be overloaded for Full Configuration */ /* Key Functions to be overloaded for Full Configuration */
virtual RsSerialiser *setupSerialiser(); virtual RsSerialiser *setupSerialiser();
virtual bool saveList(bool &cleanup, std::list<RsItem *>&); virtual bool saveList(bool &cleanup, std::list<RsItem *>&);
virtual void saveDone(); virtual void saveDone();
virtual bool loadList(std::list<RsItem *>& load); virtual bool loadList(std::list<RsItem *>& load);
/*****************************************************************/ /*****************************************************************/
/* other important managers */ /* other important managers */
p3LinkMgrIMPL *mLinkMgr; p3LinkMgrIMPL *mLinkMgr;
p3NetMgrIMPL *mNetMgr; p3NetMgrIMPL *mNetMgr;
private: private:
RsMutex mPeerMtx; /* protects below */ RsMutex mPeerMtx; /* protects below */
bool mStatusChanged; bool mStatusChanged;
std::list<pqiMonitor *> clients; std::list<pqiMonitor *> clients;
peerState mOwnState; peerState mOwnState;
std::map<RsPeerId, peerState> mFriendList; // <SSLid , peerState> std::map<RsPeerId, peerState> mFriendList; // <SSLid , peerState>
std::map<RsPeerId, peerState> mOthersList; std::map<RsPeerId, peerState> mOthersList;
std::map<RsPeerId,sockaddr_storage> mReportedOwnAddresses ; std::map<RsPeerId,sockaddr_storage> mReportedOwnAddresses ;
std::list<RsPeerGroupItem *> groupList; std::map<RsNodeGroupId,RsGroupInfo> groupList;
uint32_t lastGroupId; uint32_t lastGroupId;
std::list<RsItem *> saveCleanupList; /* TEMPORARY LIST WHEN SAVING */ std::list<RsItem *> saveCleanupList; /* TEMPORARY LIST WHEN SAVING */
std::map<RsPgpId, ServicePermissionFlags> mFriendsPermissionFlags ; // permission flags for each gpg key std::map<RsPgpId, ServicePermissionFlags> mFriendsPermissionFlags ; // permission flags for each gpg key
std::map<RsPgpId, PeerBandwidthLimits> mPeerBandwidthLimits ; // bandwidth limits for each gpg key std::map<RsPgpId, PeerBandwidthLimits> mPeerBandwidthLimits ; // bandwidth limits for each gpg key
struct sockaddr_storage mProxyServerAddressTor; struct sockaddr_storage mProxyServerAddressTor;
struct sockaddr_storage mProxyServerAddressI2P; struct sockaddr_storage mProxyServerAddressI2P;
uint32_t mProxyServerStatusTor ; uint32_t mProxyServerStatusTor ;
uint32_t mProxyServerStatusI2P ; uint32_t mProxyServerStatusI2P ;
}; };

View File

@ -99,7 +99,7 @@ struct SharedDirInfo
std::string filename ; std::string filename ;
std::string virtualname ; std::string virtualname ;
FileStorageFlags shareflags ; // DIR_FLAGS_NETWORK_WIDE_OTHERS | DIR_FLAGS_BROWSABLE_GROUPS | ... FileStorageFlags shareflags ; // DIR_FLAGS_NETWORK_WIDE_OTHERS | DIR_FLAGS_BROWSABLE_GROUPS | ...
std::list<std::string> parent_groups ; std::list<RsNodeGroupId> parent_groups ;
}; };
class RsFiles class RsFiles

View File

@ -73,14 +73,13 @@ template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER> c
memcpy(bytes,id.toByteArray(),ID_SIZE_IN_BYTES) ; memcpy(bytes,id.toByteArray(),ID_SIZE_IN_BYTES) ;
} }
// Random initialization. Can be useful for testing. // Random initialization. Can be useful for testing and to generate new ids.
// //
static t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER> random() static t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER> random()
{ {
t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER> id ; t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER> id ;
for(uint32_t i=0;i<ID_SIZE_IN_BYTES;++i) RSRandom::random_bytes(id.bytes,ID_SIZE_IN_BYTES) ;
id.bytes[i] = RSRandom::random_u32() & 0xff ;
return id ; return id ;
} }
@ -220,6 +219,7 @@ static const uint32_t RS_GENERIC_ID_GXS_CIRCLE_ID_TYPE = 0x0008 ;
static const uint32_t RS_GENERIC_ID_GROUTER_ID_TYPE = 0x0009 ; static const uint32_t RS_GENERIC_ID_GROUTER_ID_TYPE = 0x0009 ;
static const uint32_t RS_GENERIC_ID_GXS_TUNNEL_ID_TYPE = 0x0010 ; static const uint32_t RS_GENERIC_ID_GXS_TUNNEL_ID_TYPE = 0x0010 ;
static const uint32_t RS_GENERIC_ID_GXS_DISTANT_CHAT_ID_TYPE = 0x0011 ; static const uint32_t RS_GENERIC_ID_GXS_DISTANT_CHAT_ID_TYPE = 0x0011 ;
static const uint32_t RS_GENERIC_ID_NODE_GROUP_ID_TYPE = 0x0012 ;
typedef t_RsGenericIdType< SSL_ID_SIZE , false, RS_GENERIC_ID_SSL_ID_TYPE> SSLIdType ; typedef t_RsGenericIdType< SSL_ID_SIZE , false, RS_GENERIC_ID_SSL_ID_TYPE> SSLIdType ;
typedef t_RsGenericIdType< PGP_KEY_ID_SIZE , true, RS_GENERIC_ID_PGP_ID_TYPE> PGPIdType ; typedef t_RsGenericIdType< PGP_KEY_ID_SIZE , true, RS_GENERIC_ID_PGP_ID_TYPE> PGPIdType ;
@ -231,4 +231,5 @@ typedef t_RsGenericIdType< CERT_SIGN_LEN , false, RS_GENERIC_ID_GXS_I
typedef t_RsGenericIdType< CERT_SIGN_LEN , false, RS_GENERIC_ID_GXS_CIRCLE_ID_TYPE > GXSCircleId ; typedef t_RsGenericIdType< CERT_SIGN_LEN , false, RS_GENERIC_ID_GXS_CIRCLE_ID_TYPE > GXSCircleId ;
typedef t_RsGenericIdType< SSL_ID_SIZE , false, RS_GENERIC_ID_GXS_TUNNEL_ID_TYPE > GXSTunnelId ; typedef t_RsGenericIdType< SSL_ID_SIZE , false, RS_GENERIC_ID_GXS_TUNNEL_ID_TYPE > GXSTunnelId ;
typedef t_RsGenericIdType< SSL_ID_SIZE , false, RS_GENERIC_ID_GXS_DISTANT_CHAT_ID_TYPE > DistantChatPeerId ; typedef t_RsGenericIdType< SSL_ID_SIZE , false, RS_GENERIC_ID_GXS_DISTANT_CHAT_ID_TYPE > DistantChatPeerId ;
typedef t_RsGenericIdType< CERT_SIGN_LEN , false, RS_GENERIC_ID_NODE_GROUP_ID_TYPE > RsNodeGroupId ;

View File

@ -185,11 +185,17 @@ const uint32_t RS_NET_PROXY_STATUS_OK = 0x0001 ;
/* Groups */ /* Groups */
#define RS_GROUP_ID_FRIENDS "Friends" static const RsNodeGroupId RS_GROUP_ID_FRIENDS ("00000000000000000000000000000001");
#define RS_GROUP_ID_FAMILY "Family" static const RsNodeGroupId RS_GROUP_ID_FAMILY ("00000000000000000000000000000002");
#define RS_GROUP_ID_COWORKERS "Co-Workers" static const RsNodeGroupId RS_GROUP_ID_COWORKERS ("00000000000000000000000000000003");
#define RS_GROUP_ID_OTHERS "Other Contacts" static const RsNodeGroupId RS_GROUP_ID_OTHERS ("00000000000000000000000000000004");
#define RS_GROUP_ID_FAVORITES "Favorites" static const RsNodeGroupId RS_GROUP_ID_FAVORITES ("00000000000000000000000000000005");
#define RS_GROUP_DEFAULT_NAME_FRIENDS "Friends"
#define RS_GROUP_DEFAULT_NAME_FAMILY "Family"
#define RS_GROUP_DEFAULT_NAME_COWORKERS "Co-Workers"
#define RS_GROUP_DEFAULT_NAME_OTHERS "Other Contacts"
#define RS_GROUP_DEFAULT_NAME_FAVORITES "Favorites"
const uint32_t RS_GROUP_FLAG_STANDARD = 0x0001; const uint32_t RS_GROUP_FLAG_STANDARD = 0x0001;
@ -295,7 +301,7 @@ class RsGroupInfo
public: public:
RsGroupInfo(); RsGroupInfo();
std::string id; RsNodeGroupId id;
std::string name; std::string name;
uint32_t flag; uint32_t flag;
@ -399,14 +405,15 @@ public:
virtual bool trustGPGCertificate(const RsPgpId &gpg_id, uint32_t trustlvl) = 0; virtual bool trustGPGCertificate(const RsPgpId &gpg_id, uint32_t trustlvl) = 0;
/* Group Stuff */ /* Group Stuff */
virtual bool addGroup(RsGroupInfo &groupInfo) = 0; virtual bool addGroup(RsGroupInfo& groupInfo) = 0;
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo) = 0; virtual bool editGroup(const RsNodeGroupId& groupId, RsGroupInfo& groupInfo) = 0;
virtual bool removeGroup(const std::string &groupId) = 0; virtual bool removeGroup(const RsNodeGroupId& groupId) = 0;
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0; virtual bool getGroupInfo(const RsNodeGroupId& groupId, RsGroupInfo& groupInfo) = 0;
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0; virtual bool getGroupInfoByName(const std::string& groupId, RsGroupInfo& groupInfo) = 0;
virtual bool getGroupInfoList(std::list<RsGroupInfo>& groupInfoList) = 0;
// groupId == "" && assign == false -> remove from all groups // groupId == "" && assign == false -> remove from all groups
virtual bool assignPeerToGroup(const std::string &groupId, const RsPgpId& peerId, bool assign) = 0; virtual bool assignPeerToGroup(const RsNodeGroupId& groupId, const RsPgpId& peerId, bool assign) = 0;
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign) = 0; virtual bool assignPeersToGroup(const RsNodeGroupId& groupId, const std::list<RsPgpId>& peerIds, bool assign) = 0;
/* Group sharing permission */ /* Group sharing permission */
@ -421,7 +428,7 @@ public:
// //
virtual FileSearchFlags computePeerPermissionFlags( virtual FileSearchFlags computePeerPermissionFlags(
const RsPeerId& peer_id, FileStorageFlags file_sharing_flags, const RsPeerId& peer_id, FileStorageFlags file_sharing_flags,
const std::list<std::string>& file_parent_groups) = 0; const std::list<RsNodeGroupId>& file_parent_groups) = 0;
/* Service permission flags */ /* Service permission flags */

View File

@ -211,7 +211,7 @@ class FileInfo
DwlSpeed priority ; DwlSpeed priority ;
time_t lastTS; time_t lastTS;
std::list<std::string> parent_groups ; std::list<RsNodeGroupId> parent_groups ;
}; };
std::ostream &operator<<(std::ostream &out, const FileInfo &info); std::ostream &operator<<(std::ostream &out, const FileInfo &info);
@ -243,7 +243,7 @@ class DirDetails
uint32_t min_age ; // minimum age of files in this subtree uint32_t min_age ; // minimum age of files in this subtree
std::list<DirStub> children; std::list<DirStub> children;
std::list<std::string> parent_groups; // parent groups for the shared directory std::list<RsNodeGroupId> parent_groups; // parent groups for the shared directory
}; };
class FileDetail class FileDetail

View File

@ -1280,7 +1280,7 @@ bool p3Peers::addGroup(RsGroupInfo &groupInfo)
return res ; return res ;
} }
bool p3Peers::editGroup(const std::string &groupId, RsGroupInfo &groupInfo) bool p3Peers::editGroup(const RsNodeGroupId &groupId, RsGroupInfo &groupInfo)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::editGroup()" << std::endl; std::cerr << "p3Peers::editGroup()" << std::endl;
@ -1292,7 +1292,7 @@ bool p3Peers::editGroup(const std::string &groupId, RsGroupInfo &groupInfo)
return res ; return res ;
} }
bool p3Peers::removeGroup(const std::string &groupId) bool p3Peers::removeGroup(const RsNodeGroupId &groupId)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::removeGroup()" << std::endl; std::cerr << "p3Peers::removeGroup()" << std::endl;
@ -1303,7 +1303,15 @@ bool p3Peers::removeGroup(const std::string &groupId)
return res ; return res ;
} }
bool p3Peers::getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) bool p3Peers::getGroupInfoByName(const std::string& groupName, RsGroupInfo &groupInfo)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getGroupInfo()" << std::endl;
#endif
return mPeerMgr->getGroupInfoByName(groupName, groupInfo);
}
bool p3Peers::getGroupInfo(const RsNodeGroupId &groupId, RsGroupInfo &groupInfo)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getGroupInfo()" << std::endl; std::cerr << "p3Peers::getGroupInfo()" << std::endl;
@ -1321,7 +1329,7 @@ bool p3Peers::getGroupInfoList(std::list<RsGroupInfo> &groupInfoList)
return mPeerMgr->getGroupInfoList(groupInfoList); return mPeerMgr->getGroupInfoList(groupInfoList);
} }
bool p3Peers::assignPeerToGroup(const std::string &groupId, const RsPgpId& peerId, bool assign) bool p3Peers::assignPeerToGroup(const RsNodeGroupId &groupId, const RsPgpId& peerId, bool assign)
{ {
std::list<RsPgpId> peerIds; std::list<RsPgpId> peerIds;
peerIds.push_back(peerId); peerIds.push_back(peerId);
@ -1329,7 +1337,7 @@ bool p3Peers::assignPeerToGroup(const std::string &groupId, const RsPgpId& peerI
return assignPeersToGroup(groupId, peerIds, assign); return assignPeersToGroup(groupId, peerIds, assign);
} }
bool p3Peers::assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign) bool p3Peers::assignPeersToGroup(const RsNodeGroupId &groupId, const std::list<RsPgpId> &peerIds, bool assign)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::assignPeersToGroup()" << std::endl; std::cerr << "p3Peers::assignPeersToGroup()" << std::endl;
@ -1343,7 +1351,7 @@ bool p3Peers::assignPeersToGroup(const std::string &groupId, const std::list<RsP
FileSearchFlags p3Peers::computePeerPermissionFlags(const RsPeerId& peer_ssl_id, FileSearchFlags p3Peers::computePeerPermissionFlags(const RsPeerId& peer_ssl_id,
FileStorageFlags share_flags, FileStorageFlags share_flags,
const std::list<std::string>& directory_parent_groups) const std::list<RsNodeGroupId>& directory_parent_groups)
{ {
// We should be able to do that in O(1), using groups based on packs of bits. // We should be able to do that in O(1), using groups based on packs of bits.
// //
@ -1354,7 +1362,7 @@ FileSearchFlags p3Peers::computePeerPermissionFlags(const RsPeerId& peer_ssl_id,
bool found = false ; bool found = false ;
RsPgpId pgp_id = getGPGId(peer_ssl_id) ; RsPgpId pgp_id = getGPGId(peer_ssl_id) ;
for(std::list<std::string>::const_iterator it(directory_parent_groups.begin());it!=directory_parent_groups.end() && !found;++it) for(std::list<RsNodeGroupId>::const_iterator it(directory_parent_groups.begin());it!=directory_parent_groups.end() && !found;++it)
{ {
RsGroupInfo info ; RsGroupInfo info ;
if(!getGroupInfo(*it,info)) if(!getGroupInfo(*it,info))

View File

@ -124,14 +124,15 @@ public:
/* Group Stuff */ /* Group Stuff */
virtual bool addGroup(RsGroupInfo &groupInfo); virtual bool addGroup(RsGroupInfo &groupInfo);
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo); virtual bool editGroup(const RsNodeGroupId &groupId, RsGroupInfo &groupInfo);
virtual bool removeGroup(const std::string &groupId); virtual bool removeGroup(const RsNodeGroupId &groupId);
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo); virtual bool getGroupInfo(const RsNodeGroupId &groupId, RsGroupInfo &groupInfo);
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList); virtual bool getGroupInfoByName(const std::string& groupName, RsGroupInfo& groupInfo);
virtual bool assignPeerToGroup(const std::string &groupId, const RsPgpId &peerId, bool assign); virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId>& peerIds, bool assign); virtual bool assignPeerToGroup(const RsNodeGroupId &groupId, const RsPgpId &peerId, bool assign);
virtual bool assignPeersToGroup(const RsNodeGroupId &groupId, const std::list<RsPgpId>& peerIds, bool assign);
virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id,FileStorageFlags share_flags,const std::list<std::string>& parent_groups); virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id, FileStorageFlags share_flags, const std::list<RsNodeGroupId> &parent_groups);
// service permission stuff // service permission stuff

View File

@ -43,34 +43,34 @@
uint32_t RsFileConfigSerialiser::size(RsItem *i) uint32_t RsFileConfigSerialiser::size(RsItem *i)
{ {
RsFileTransfer *rft; RsFileTransfer *rft;
RsFileConfigItem *rfi; RsFileConfigItem *rfj;
if (NULL != (rft = dynamic_cast<RsFileTransfer *>(i))) if (NULL != (rft = dynamic_cast<RsFileTransfer *>(i)))
{ {
return sizeTransfer(rft); return sizeTransfer(rft);
} }
if (NULL != (rfi = dynamic_cast<RsFileConfigItem *>(i))) if (NULL != (rfj = dynamic_cast<RsFileConfigItem *>(i)))
{ {
return sizeFileItem(rfi); return sizeFileItem(rfj);
} }
return 0; return 0;
} }
/* serialise the data to the buffer */ /* serialise the data to the buffer */
bool RsFileConfigSerialiser::serialise(RsItem *i, void *data, uint32_t *pktsize) bool RsFileConfigSerialiser::serialise(RsItem *i, void *data, uint32_t *pktsize)
{ {
RsFileTransfer *rft; RsFileTransfer *rft;
RsFileConfigItem *rfi; RsFileConfigItem *rfj;
if (NULL != (rft = dynamic_cast<RsFileTransfer *>(i))) if (NULL != (rft = dynamic_cast<RsFileTransfer *>(i)))
{ {
return serialiseTransfer(rft, data, pktsize); return serialiseTransfer(rft, data, pktsize);
} }
if (NULL != (rfi = dynamic_cast<RsFileConfigItem *>(i))) if (NULL != (rfj = dynamic_cast<RsFileConfigItem*>(i)))
{ {
return serialiseFileItem(rfi, data, pktsize); return serialiseFileItem(rfj, data, pktsize);
} }
return false; return false;
} }
RsItem *RsFileConfigSerialiser::deserialise(void *data, uint32_t *pktsize) RsItem *RsFileConfigSerialiser::deserialise(void *data, uint32_t *pktsize)
@ -90,10 +90,13 @@ RsItem *RsFileConfigSerialiser::deserialise(void *data, uint32_t *pktsize)
case RS_PKT_SUBTYPE_FILE_TRANSFER: case RS_PKT_SUBTYPE_FILE_TRANSFER:
return deserialiseTransfer(data, pktsize); return deserialiseTransfer(data, pktsize);
break; break;
case RS_PKT_SUBTYPE_FILE_ITEM: case RS_PKT_SUBTYPE_FILE_ITEM_deprecated:
return deserialiseFileItem(data, pktsize); return deserialiseFileItem_deprecated(data, pktsize);
break; break;
default: case RS_PKT_SUBTYPE_FILE_ITEM:
return deserialiseFileItem(data, pktsize);
break;
default:
return NULL; return NULL;
break; break;
} }
@ -158,20 +161,20 @@ std::ostream &RsFileTransfer::print(std::ostream &out, uint16_t indent)
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
RsFileConfigItem::~RsFileConfigItem() void RsFileConfigItem_deprecated::clear()
{ {
return;
}
void RsFileConfigItem::clear()
{
file.TlvClear(); file.TlvClear();
flags = 0; flags = 0;
parent_groups.clear() ; parent_groups.clear() ;
} }
std::ostream &RsFileConfigItem::print(std::ostream &out, uint16_t indent) void RsFileConfigItem::clear()
{
file.TlvClear();
flags = 0;
parent_groups.TlvClear() ;
}
std::ostream &RsFileConfigItem_deprecated::print(std::ostream &out, uint16_t indent)
{ {
printRsItemBase(out, "RsFileConfigItem", indent); printRsItemBase(out, "RsFileConfigItem", indent);
uint16_t int_Indent = indent + 2; uint16_t int_Indent = indent + 2;
@ -188,6 +191,22 @@ std::ostream &RsFileConfigItem::print(std::ostream &out, uint16_t indent)
return out; return out;
} }
std::ostream &RsFileConfigItem::print(std::ostream &out, uint16_t indent)
{
printRsItemBase(out, "RsFileConfigItem", indent);
uint16_t int_Indent = indent + 2;
file.print(out, int_Indent);
printIndent(out, int_Indent); out << "flags: " << flags << std::endl;
printIndent(out, int_Indent); out << "groups:" ;
for(std::set<RsNodeGroupId>::const_iterator it(parent_groups.ids.begin());it!=parent_groups.ids.end();++it)
out << (*it) << " " ;
out << std::endl;
printRsItemEnd(out, "RsFileConfigItem", indent);
return out;
}
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
@ -351,8 +370,7 @@ uint32_t RsFileConfigSerialiser::sizeFileItem(RsFileConfigItem *item)
s += item->file.TlvSize(); s += item->file.TlvSize();
s += 4; // flags s += 4; // flags
for(std::list<std::string>::const_iterator it(item->parent_groups.begin());it!=item->parent_groups.end();++it) // parent groups s += item->parent_groups.TlvSize() ;
s += GetTlvStringSize(*it);
return s; return s;
} }
@ -382,9 +400,7 @@ bool RsFileConfigSerialiser::serialiseFileItem(RsFileConfigItem *item, void
/* add mandatory parts first */ /* add mandatory parts first */
ok &= item->file.SetTlv(data, tlvsize, &offset); ok &= item->file.SetTlv(data, tlvsize, &offset);
ok &= setRawUInt32(data, tlvsize, &offset, item->flags); ok &= setRawUInt32(data, tlvsize, &offset, item->flags);
ok &= item->parent_groups.SetTlv(data, tlvsize, &offset);
for(std::list<std::string>::const_iterator it(item->parent_groups.begin());ok && it!=item->parent_groups.end();++it) // parent groups
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GROUPID, *it);
if (offset != tlvsize) if (offset != tlvsize)
{ {
@ -397,6 +413,66 @@ bool RsFileConfigSerialiser::serialiseFileItem(RsFileConfigItem *item, void
return ok; return ok;
} }
RsFileConfigItem_deprecated *RsFileConfigSerialiser::deserialiseFileItem_deprecated(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_VERSION1 != getRsItemVersion(rstype)) ||
(RS_PKT_CLASS_CONFIG != getRsItemClass(rstype)) ||
(RS_PKT_TYPE_FILE_CONFIG != getRsItemType(rstype)) ||
(RS_PKT_SUBTYPE_FILE_ITEM_deprecated != 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 */
RsFileConfigItem_deprecated *item = new RsFileConfigItem_deprecated();
item->clear();
/* skip the header */
offset += 8;
/* get mandatory parts first */
ok &= item->file.GetTlv(data, rssize, &offset);
ok &= getRawUInt32(data, rssize, &offset, &(item->flags));
while(offset < rssize)
{
std::string tmp ;
if(GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GROUPID, tmp))
item->parent_groups.push_back(tmp) ;
else
break ;
}
if (offset != rssize)
{
/* error */
delete item;
return NULL;
}
if (!ok)
{
delete item;
return NULL;
}
return item;
}
RsFileConfigItem *RsFileConfigSerialiser::deserialiseFileItem(void *data, uint32_t *pktsize) RsFileConfigItem *RsFileConfigSerialiser::deserialiseFileItem(void *data, uint32_t *pktsize)
{ {
/* get the type and size */ /* get the type and size */
@ -409,7 +485,7 @@ RsFileConfigItem *RsFileConfigSerialiser::deserialiseFileItem(void *data, uint32
if ((RS_PKT_VERSION1 != getRsItemVersion(rstype)) || if ((RS_PKT_VERSION1 != getRsItemVersion(rstype)) ||
(RS_PKT_CLASS_CONFIG != getRsItemClass(rstype)) || (RS_PKT_CLASS_CONFIG != getRsItemClass(rstype)) ||
(RS_PKT_TYPE_FILE_CONFIG != getRsItemType(rstype)) || (RS_PKT_TYPE_FILE_CONFIG != getRsItemType(rstype)) ||
(RS_PKT_SUBTYPE_FILE_ITEM != getRsItemSubType(rstype))) (RS_PKT_SUBTYPE_FILE_ITEM != getRsItemSubType(rstype)))
{ {
return NULL; /* wrong type */ return NULL; /* wrong type */
} }
@ -423,7 +499,7 @@ RsFileConfigItem *RsFileConfigSerialiser::deserialiseFileItem(void *data, uint32
bool ok = true; bool ok = true;
/* ready to load */ /* ready to load */
RsFileConfigItem *item = new RsFileConfigItem(); RsFileConfigItem *item = new RsFileConfigItem();
item->clear(); item->clear();
/* skip the header */ /* skip the header */
@ -432,15 +508,7 @@ RsFileConfigItem *RsFileConfigSerialiser::deserialiseFileItem(void *data, uint32
/* get mandatory parts first */ /* get mandatory parts first */
ok &= item->file.GetTlv(data, rssize, &offset); ok &= item->file.GetTlv(data, rssize, &offset);
ok &= getRawUInt32(data, rssize, &offset, &(item->flags)); ok &= getRawUInt32(data, rssize, &offset, &(item->flags));
ok &= item->parent_groups.GetTlv(data, rssize, &offset) ;
while(offset < rssize)
{
std::string tmp ;
if(GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GROUPID, tmp))
item->parent_groups.push_back(tmp) ;
else
break ;
}
if (offset != rssize) if (offset != rssize)
{ {
@ -682,7 +750,7 @@ uint32_t RsPeerConfigSerialiser::size(RsItem *i)
{ {
RsPeerStunItem *psi; RsPeerStunItem *psi;
RsPeerNetItem *pni; RsPeerNetItem *pni;
RsPeerGroupItem *pgi; RsNodeGroupItem *pgi;
RsPeerServicePermissionItem *pri; RsPeerServicePermissionItem *pri;
RsPeerBandwidthLimitsItem *pblitem; RsPeerBandwidthLimitsItem *pblitem;
@ -694,7 +762,7 @@ uint32_t RsPeerConfigSerialiser::size(RsItem *i)
{ {
return sizeStun(psi); return sizeStun(psi);
} }
else if (NULL != (pgi = dynamic_cast<RsPeerGroupItem *>(i))) else if (NULL != (pgi = dynamic_cast<RsNodeGroupItem*>(i)))
{ {
return sizeGroup(pgi); return sizeGroup(pgi);
} }
@ -715,7 +783,7 @@ bool RsPeerConfigSerialiser::serialise(RsItem *i, void *data, uint32_t *pktsi
{ {
RsPeerNetItem *pni; RsPeerNetItem *pni;
RsPeerStunItem *psi; RsPeerStunItem *psi;
RsPeerGroupItem *pgi; RsNodeGroupItem *pgi;
RsPeerServicePermissionItem *pri; RsPeerServicePermissionItem *pri;
RsPeerBandwidthLimitsItem *pblitem; RsPeerBandwidthLimitsItem *pblitem;
@ -727,7 +795,7 @@ bool RsPeerConfigSerialiser::serialise(RsItem *i, void *data, uint32_t *pktsi
{ {
return serialiseStun(psi, data, pktsize); return serialiseStun(psi, data, pktsize);
} }
else if (NULL != (pgi = dynamic_cast<RsPeerGroupItem *>(i))) else if (NULL != (pgi = dynamic_cast<RsNodeGroupItem*>(i)))
{ {
return serialiseGroup(pgi, data, pktsize); return serialiseGroup(pgi, data, pktsize);
} }
@ -764,9 +832,11 @@ RsItem *RsPeerConfigSerialiser::deserialise(void *data, uint32_t *pktsize)
return deserialiseNet(data, pktsize); return deserialiseNet(data, pktsize);
case RS_PKT_SUBTYPE_PEER_STUN: case RS_PKT_SUBTYPE_PEER_STUN:
return deserialiseStun(data, pktsize); return deserialiseStun(data, pktsize);
case RS_PKT_SUBTYPE_PEER_GROUP: case RS_PKT_SUBTYPE_PEER_GROUP_deprecated:
return deserialiseGroup(data, pktsize); return deserialiseGroup_deprecated(data, pktsize);
case RS_PKT_SUBTYPE_PEER_PERMISSIONS: case RS_PKT_SUBTYPE_NODE_GROUP:
return deserialiseGroup(data, pktsize);
case RS_PKT_SUBTYPE_PEER_PERMISSIONS:
return deserialisePermissions(data, pktsize); return deserialisePermissions(data, pktsize);
case RS_PKT_SUBTYPE_PEER_BANDLIMITS: case RS_PKT_SUBTYPE_PEER_BANDLIMITS:
return deserialisePeerBandwidthLimits(data, pktsize); return deserialisePeerBandwidthLimits(data, pktsize);
@ -1312,16 +1382,64 @@ RsPeerStunItem *RsPeerConfigSerialiser::deserialiseStun(void *data, uint32_t *si
} }
/*************************************************************************/ /*************************************************************************/
RsNodeGroupItem::RsNodeGroupItem() : RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG, RS_PKT_TYPE_PEER_CONFIG, RS_PKT_SUBTYPE_NODE_GROUP)
RsPeerGroupItem::RsPeerGroupItem() : RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG, RS_PKT_TYPE_PEER_CONFIG, RS_PKT_SUBTYPE_PEER_GROUP)
{ {
} }
RsPeerGroupItem::~RsPeerGroupItem() RsNodeGroupItem::RsNodeGroupItem(const RsGroupInfo& g)
:RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG, RS_PKT_TYPE_PEER_CONFIG, RS_PKT_SUBTYPE_NODE_GROUP)
{
id = g.id ;
name = g.name ;
flag = g.flag ;
pgpList.ids = g.peerIds;
}
void RsNodeGroupItem::clear()
{
id.clear();
name.clear();
flag = 0;
pgpList.ids.clear();
}
std::ostream &RsNodeGroupItem::print(std::ostream &out, uint16_t indent)
{
printRsItemBase(out, "RsNodeGroupItem", indent);
uint16_t int_Indent = indent + 2;
printIndent(out, int_Indent);
out << "groupId: " << id << std::endl;
printIndent(out, int_Indent);
out << "groupName: " << name << std::endl;
printIndent(out, int_Indent);
out << "groupFlag: " << flag << std::endl;
std::set<RsPgpId>::iterator it;
for (it = pgpList.ids.begin(); it != pgpList.ids.end(); ++it) {
printIndent(out, int_Indent);
out << "peerId: " << it->toStdString() << std::endl;
}
printRsItemEnd(out, "RsNodeGroupItem", indent);
return out;
}
/*************************************************************************/
/* DEPRECATED CODE. SHOULD BE REMOVED WHEN EVERYONE USES THE NEW CLASS */
/*************************************************************************/
RsPeerGroupItem_deprecated::RsPeerGroupItem_deprecated() : RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG, RS_PKT_TYPE_PEER_CONFIG, RS_PKT_SUBTYPE_PEER_GROUP_deprecated)
{ {
} }
void RsPeerGroupItem::clear() RsPeerGroupItem_deprecated::~RsPeerGroupItem_deprecated()
{
}
void RsPeerGroupItem_deprecated::clear()
{ {
id.clear(); id.clear();
name.clear(); name.clear();
@ -1329,7 +1447,7 @@ void RsPeerGroupItem::clear()
pgpList.ids.clear(); pgpList.ids.clear();
} }
std::ostream &RsPeerGroupItem::print(std::ostream &out, uint16_t indent) std::ostream &RsPeerGroupItem_deprecated::print(std::ostream &out, uint16_t indent)
{ {
printRsItemBase(out, "RsPeerGroupItem", indent); printRsItemBase(out, "RsPeerGroupItem", indent);
uint16_t int_Indent = indent + 2; uint16_t int_Indent = indent + 2;
@ -1353,38 +1471,67 @@ std::ostream &RsPeerGroupItem::print(std::ostream &out, uint16_t indent)
return out; return out;
} }
/* set data from RsGroupInfo to RsPeerGroupItem */ RsPeerGroupItem_deprecated *RsPeerConfigSerialiser::deserialiseGroup_deprecated(void *data, uint32_t *size)
void RsPeerGroupItem::set(RsGroupInfo &groupInfo)
{ {
id = groupInfo.id; /* get the type and size */
name = groupInfo.name; uint32_t rstype = getRsItemId(data);
flag = groupInfo.flag; uint32_t rssize = getRsItemSize(data);
pgpList.ids = groupInfo.peerIds;
}
/* get data from RsGroupInfo to RsPeerGroupItem */ uint32_t offset = 0;
void RsPeerGroupItem::get(RsGroupInfo &groupInfo)
{
groupInfo.id = id;
groupInfo.name = name;
groupInfo.flag = flag;
groupInfo.peerIds = pgpList.ids;
}
if ((RS_PKT_VERSION1 != getRsItemVersion(rstype)) ||
(RS_PKT_CLASS_CONFIG != getRsItemClass(rstype)) ||
(RS_PKT_TYPE_PEER_CONFIG != getRsItemType(rstype)) ||
(RS_PKT_SUBTYPE_PEER_GROUP_deprecated != getRsItemSubType(rstype)))
{
return NULL; /* wrong type */
}
if (*size < rssize) /* check size */
return NULL; /* not enough data */
/* set the packet length */
*size = rssize;
bool ok = true;
RsPeerGroupItem_deprecated *item = new RsPeerGroupItem_deprecated();
item->clear();
/* skip the header */
offset += 8;
/* get mandatory parts first */
uint32_t version;
ok &= getRawUInt32(data, rssize, &offset, &version);
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_KEY, item->id);
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->name);
ok &= getRawUInt32(data, rssize, &offset, &(item->flag));
ok &= item->pgpList.GetTlv(data, rssize, &offset);
if (offset != rssize)
{
/* error */
delete item;
return NULL;
}
return item;
}
/*************************************************************************/ /*************************************************************************/
uint32_t RsPeerConfigSerialiser::sizeGroup(RsPeerGroupItem *i) uint32_t RsPeerConfigSerialiser::sizeGroup(RsNodeGroupItem *i)
{ {
uint32_t s = 8; /* header */ uint32_t s = 8; /* header */
s += 4; /* version */ s += 4; /* version */
s += GetTlvStringSize(i->id); s += RsNodeGroupId::serial_size();
s += GetTlvStringSize(i->name); s += GetTlvStringSize(i->name);
s += 4; /* flag */ s += 4; /* flag */
s += i->pgpList.TlvSize(); s += i->pgpList.TlvSize();
return s; return s;
} }
bool RsPeerConfigSerialiser::serialiseGroup(RsPeerGroupItem *item, void *data, uint32_t *size) bool RsPeerConfigSerialiser::serialiseGroup(RsNodeGroupItem *item, void *data, uint32_t *size)
{ {
uint32_t tlvsize = RsPeerConfigSerialiser::sizeGroup(item); uint32_t tlvsize = RsPeerConfigSerialiser::sizeGroup(item);
uint32_t offset = 0; uint32_t offset = 0;
@ -1410,7 +1557,7 @@ bool RsPeerConfigSerialiser::serialiseGroup(RsPeerGroupItem *item, void *data, u
/* add mandatory parts first */ /* add mandatory parts first */
ok &= setRawUInt32(data, tlvsize, &offset, 0); ok &= setRawUInt32(data, tlvsize, &offset, 0);
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_KEY, item->id); ok &= item->id.serialise(data, tlvsize, offset);
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->name); ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->name);
ok &= setRawUInt32(data, tlvsize, &offset, item->flag); ok &= setRawUInt32(data, tlvsize, &offset, item->flag);
ok &= item->pgpList.SetTlv(data, tlvsize, &offset); ok &= item->pgpList.SetTlv(data, tlvsize, &offset);
@ -1426,7 +1573,7 @@ bool RsPeerConfigSerialiser::serialiseGroup(RsPeerGroupItem *item, void *data, u
return ok; return ok;
} }
RsPeerGroupItem *RsPeerConfigSerialiser::deserialiseGroup(void *data, uint32_t *size) RsNodeGroupItem *RsPeerConfigSerialiser::deserialiseGroup(void *data, uint32_t *size)
{ {
/* get the type and size */ /* get the type and size */
uint32_t rstype = getRsItemId(data); uint32_t rstype = getRsItemId(data);
@ -1437,7 +1584,7 @@ RsPeerGroupItem *RsPeerConfigSerialiser::deserialiseGroup(void *data, uint32_t *
if ((RS_PKT_VERSION1 != getRsItemVersion(rstype)) || if ((RS_PKT_VERSION1 != getRsItemVersion(rstype)) ||
(RS_PKT_CLASS_CONFIG != getRsItemClass(rstype)) || (RS_PKT_CLASS_CONFIG != getRsItemClass(rstype)) ||
(RS_PKT_TYPE_PEER_CONFIG != getRsItemType(rstype)) || (RS_PKT_TYPE_PEER_CONFIG != getRsItemType(rstype)) ||
(RS_PKT_SUBTYPE_PEER_GROUP != getRsItemSubType(rstype))) (RS_PKT_SUBTYPE_NODE_GROUP != getRsItemSubType(rstype)))
{ {
return NULL; /* wrong type */ return NULL; /* wrong type */
} }
@ -1450,7 +1597,7 @@ RsPeerGroupItem *RsPeerConfigSerialiser::deserialiseGroup(void *data, uint32_t *
bool ok = true; bool ok = true;
RsPeerGroupItem *item = new RsPeerGroupItem(); RsNodeGroupItem *item = new RsNodeGroupItem();
item->clear(); item->clear();
/* skip the header */ /* skip the header */
@ -1459,7 +1606,7 @@ RsPeerGroupItem *RsPeerConfigSerialiser::deserialiseGroup(void *data, uint32_t *
/* get mandatory parts first */ /* get mandatory parts first */
uint32_t version; uint32_t version;
ok &= getRawUInt32(data, rssize, &offset, &version); ok &= getRawUInt32(data, rssize, &offset, &version);
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_KEY, item->id); ok &= item->id.deserialise(data, rssize, offset);
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->name); ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->name);
ok &= getRawUInt32(data, rssize, &offset, &(item->flag)); ok &= getRawUInt32(data, rssize, &offset, &(item->flag));
ok &= item->pgpList.GetTlv(data, rssize, &offset); ok &= item->pgpList.GetTlv(data, rssize, &offset);

View File

@ -50,15 +50,17 @@ const uint8_t RS_PKT_TYPE_HISTORY_CONFIG = 0x06;
const uint8_t RS_PKT_SUBTYPE_KEY_VALUE = 0x01; const uint8_t RS_PKT_SUBTYPE_KEY_VALUE = 0x01;
/* PEER CONFIG SUBTYPES */ /* PEER CONFIG SUBTYPES */
const uint8_t RS_PKT_SUBTYPE_PEER_STUN = 0x02; const uint8_t RS_PKT_SUBTYPE_PEER_STUN = 0x02;
const uint8_t RS_PKT_SUBTYPE_PEER_NET = 0x03; const uint8_t RS_PKT_SUBTYPE_PEER_NET = 0x03;
const uint8_t RS_PKT_SUBTYPE_PEER_GROUP = 0x04; const uint8_t RS_PKT_SUBTYPE_PEER_GROUP_deprecated = 0x04;
const uint8_t RS_PKT_SUBTYPE_PEER_PERMISSIONS = 0x05; const uint8_t RS_PKT_SUBTYPE_PEER_PERMISSIONS = 0x05;
const uint8_t RS_PKT_SUBTYPE_PEER_BANDLIMITS = 0x06; const uint8_t RS_PKT_SUBTYPE_PEER_BANDLIMITS = 0x06;
const uint8_t RS_PKT_SUBTYPE_NODE_GROUP = 0x07;
/* FILE CONFIG SUBTYPES */ /* FILE CONFIG SUBTYPES */
const uint8_t RS_PKT_SUBTYPE_FILE_TRANSFER = 0x01; const uint8_t RS_PKT_SUBTYPE_FILE_TRANSFER = 0x01;
const uint8_t RS_PKT_SUBTYPE_FILE_ITEM = 0x02; const uint8_t RS_PKT_SUBTYPE_FILE_ITEM_deprecated = 0x02;
const uint8_t RS_PKT_SUBTYPE_FILE_ITEM = 0x03;
/**************************************************************************/ /**************************************************************************/
@ -134,11 +136,11 @@ class RsPeerBandwidthLimitsItem : public RsItem
std::map<RsPgpId,PeerBandwidthLimits> peers ; std::map<RsPgpId,PeerBandwidthLimits> peers ;
}; };
class RsPeerGroupItem : public RsItem class RsPeerGroupItem_deprecated : public RsItem
{ {
public: public:
RsPeerGroupItem(); RsPeerGroupItem_deprecated();
virtual ~RsPeerGroupItem(); virtual ~RsPeerGroupItem_deprecated();
virtual void clear(); virtual void clear();
std::ostream &print(std::ostream &out, uint16_t indent = 0); std::ostream &print(std::ostream &out, uint16_t indent = 0);
@ -156,6 +158,29 @@ public:
RsTlvPgpIdSet pgpList; RsTlvPgpIdSet pgpList;
}; };
class RsNodeGroupItem: public RsItem
{
public:
RsNodeGroupItem();
virtual ~RsNodeGroupItem() {}
virtual void clear();
std::ostream &print(std::ostream &out, uint16_t indent = 0);
explicit RsNodeGroupItem(const RsGroupInfo&) ;
// /* set data from RsGroupInfo to RsPeerGroupItem */
// void set(RsGroupInfo &groupInfo);
// /* get data from RsGroupInfo to RsPeerGroupItem */
// void get(RsGroupInfo &groupInfo);
/* Mandatory */
RsNodeGroupId id;
std::string name;
uint32_t flag;
RsTlvPgpIdSet pgpList;
};
class RsPeerStunItem: public RsItem class RsPeerStunItem: public RsItem
{ {
@ -197,9 +222,10 @@ virtual uint32_t sizeStun(RsPeerStunItem *);
virtual bool serialiseStun (RsPeerStunItem *item, void *data, uint32_t *size); virtual bool serialiseStun (RsPeerStunItem *item, void *data, uint32_t *size);
virtual RsPeerStunItem * deserialiseStun(void *data, uint32_t *size); virtual RsPeerStunItem * deserialiseStun(void *data, uint32_t *size);
virtual uint32_t sizeGroup(RsPeerGroupItem *); virtual uint32_t sizeGroup(RsNodeGroupItem *);
virtual bool serialiseGroup (RsPeerGroupItem *item, void *data, uint32_t *size); virtual bool serialiseGroup (RsNodeGroupItem *item, void *data, uint32_t *size);
virtual RsPeerGroupItem * deserialiseGroup(void *data, uint32_t *size); virtual RsNodeGroupItem *deserialiseGroup(void *data, uint32_t *size);
virtual RsPeerGroupItem_deprecated * deserialiseGroup_deprecated(void *data, uint32_t *size);
virtual uint32_t sizePeerBandwidthLimits(RsPeerBandwidthLimitsItem *); virtual uint32_t sizePeerBandwidthLimits(RsPeerBandwidthLimitsItem *);
virtual bool serialisePeerBandwidthLimits (RsPeerBandwidthLimitsItem *item, void *data, uint32_t *size); virtual bool serialisePeerBandwidthLimits (RsPeerBandwidthLimitsItem *item, void *data, uint32_t *size);
@ -303,23 +329,39 @@ class RsFileTransfer: public RsItem
const uint32_t RS_FILE_CONFIG_CLEANUP_DELETE = 0x0001; const uint32_t RS_FILE_CONFIG_CLEANUP_DELETE = 0x0001;
/* Used by ft / extralist / configdirs / anyone who wants a basic file */ /* Used by ft / extralist / configdirs / anyone who wants a basic file */
class RsFileConfigItem: public RsItem class RsFileConfigItem_deprecated: public RsItem
{ {
public: public:
RsFileConfigItem() RsFileConfigItem_deprecated()
:RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG, :RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG,
RS_PKT_TYPE_FILE_CONFIG, RS_PKT_TYPE_FILE_CONFIG,
RS_PKT_SUBTYPE_FILE_ITEM) RS_PKT_SUBTYPE_FILE_ITEM_deprecated)
{ return; } {}
virtual ~RsFileConfigItem(); virtual ~RsFileConfigItem_deprecated() {}
virtual void clear(); virtual void clear();
std::ostream &print(std::ostream &out, uint16_t indent = 0); std::ostream &print(std::ostream &out, uint16_t indent = 0);
RsTlvFileItem file; RsTlvFileItem file;
uint32_t flags; uint32_t flags;
std::list<std::string> parent_groups ; std::list<std::string> parent_groups ;
}; };
class RsFileConfigItem: public RsItem
{
public:
RsFileConfigItem()
:RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG,
RS_PKT_TYPE_FILE_CONFIG,
RS_PKT_SUBTYPE_FILE_ITEM)
{}
virtual ~RsFileConfigItem() {}
virtual void clear();
std::ostream &print(std::ostream &out, uint16_t indent = 0);
RsTlvFileItem file;
uint32_t flags;
RsTlvNodeGroupIdSet parent_groups ;
};
/**************************************************************************/ /**************************************************************************/
class RsFileConfigSerialiser: public RsSerialType class RsFileConfigSerialiser: public RsSerialType
@ -341,9 +383,11 @@ virtual uint32_t sizeTransfer(RsFileTransfer *);
virtual bool serialiseTransfer(RsFileTransfer *item, void *data, uint32_t *size); virtual bool serialiseTransfer(RsFileTransfer *item, void *data, uint32_t *size);
virtual RsFileTransfer * deserialiseTransfer(void *data, uint32_t *size); virtual RsFileTransfer * deserialiseTransfer(void *data, uint32_t *size);
virtual RsFileConfigItem_deprecated * deserialiseFileItem_deprecated(void *data, uint32_t *size);
virtual uint32_t sizeFileItem(RsFileConfigItem *); virtual uint32_t sizeFileItem(RsFileConfigItem *);
virtual bool serialiseFileItem(RsFileConfigItem *item, void *data, uint32_t *size); virtual bool serialiseFileItem(RsFileConfigItem *item, void *data, uint32_t *size);
virtual RsFileConfigItem * deserialiseFileItem(void *data, uint32_t *size); virtual RsFileConfigItem *deserialiseFileItem(void *data, uint32_t *size);
}; };

View File

@ -204,6 +204,7 @@ const uint16_t TLV_TYPE_PGPIDSET = 0x1023;
const uint16_t TLV_TYPE_RECOGNSET = 0x1024; const uint16_t TLV_TYPE_RECOGNSET = 0x1024;
const uint16_t TLV_TYPE_GXSIDSET = 0x1025; const uint16_t TLV_TYPE_GXSIDSET = 0x1025;
const uint16_t TLV_TYPE_GXSCIRCLEIDSET= 0x1026; const uint16_t TLV_TYPE_GXSCIRCLEIDSET= 0x1026;
const uint16_t TLV_TYPE_NODEGROUPIDSET= 0x1027;
const uint16_t TLV_TYPE_SERVICESET = 0x1030; const uint16_t TLV_TYPE_SERVICESET = 0x1030;

View File

@ -115,11 +115,12 @@ template<class ID_CLASS,uint32_t TLV_TYPE> class t_RsTlvIdSet: public RsTlvItem
std::set<ID_CLASS> ids ; std::set<ID_CLASS> ids ;
}; };
typedef t_RsTlvIdSet<RsPeerId,TLV_TYPE_PEERSET> RsTlvPeerIdSet ; typedef t_RsTlvIdSet<RsPeerId, TLV_TYPE_PEERSET> RsTlvPeerIdSet ;
typedef t_RsTlvIdSet<RsPgpId,TLV_TYPE_PGPIDSET> RsTlvPgpIdSet ; typedef t_RsTlvIdSet<RsPgpId, TLV_TYPE_PGPIDSET> RsTlvPgpIdSet ;
typedef t_RsTlvIdSet<Sha1CheckSum,TLV_TYPE_HASHSET> RsTlvHashSet ; typedef t_RsTlvIdSet<Sha1CheckSum, TLV_TYPE_HASHSET> RsTlvHashSet ;
typedef t_RsTlvIdSet<RsGxsId,TLV_TYPE_GXSIDSET> RsTlvGxsIdSet ; typedef t_RsTlvIdSet<RsGxsId, TLV_TYPE_GXSIDSET> RsTlvGxsIdSet ;
typedef t_RsTlvIdSet<RsGxsCircleId,TLV_TYPE_GXSCIRCLEIDSET> RsTlvGxsCircleIdSet ; typedef t_RsTlvIdSet<RsGxsCircleId,TLV_TYPE_GXSCIRCLEIDSET> RsTlvGxsCircleIdSet ;
typedef t_RsTlvIdSet<RsNodeGroupId,TLV_TYPE_NODEGROUPIDSET> RsTlvNodeGroupIdSet ;
class RsTlvServiceIdSet: public RsTlvItem class RsTlvServiceIdSet: public RsTlvItem
{ {

View File

@ -380,6 +380,7 @@ bool p3GxsCircles::loadCircle(const RsGxsCircleId &circleId)
return cache_request_load(circleId); return cache_request_load(circleId);
} }
int p3GxsCircles::canSend(const RsGxsCircleId &circleId, const RsPgpId &id, bool& should_encrypt) int p3GxsCircles::canSend(const RsGxsCircleId &circleId, const RsPgpId &id, bool& should_encrypt)
{ {
RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/ RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/

View File

@ -103,7 +103,7 @@ CreateCircleDialog::CreateCircleDialog()
#endif #endif
//ui.idChooser->loadIds(0,RsGxsId()); //ui.idChooser->loadIds(0,RsGxsId());
ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL, RsGxsCircleId()); ui.circleComboBox->loadCircles(RsGxsCircleId());
} }
CreateCircleDialog::~CreateCircleDialog() CreateCircleDialog::~CreateCircleDialog()
@ -604,7 +604,7 @@ void CreateCircleDialog::updateCircleGUI()
else else
ui.radioButton_Restricted->setChecked(true); ui.radioButton_Restricted->setChecked(true);
ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL, mCircleGroup.mMeta.mCircleId); ui.circleComboBox->loadCircles(mCircleGroup.mMeta.mCircleId);
break; break;

View File

@ -56,8 +56,9 @@
*****/ *****/
MessengerWindow* MessengerWindow::_instance = NULL; MessengerWindow* MessengerWindow::_instance = NULL;
static std::set<std::string> *expandedPeers = NULL;
static std::set<std::string> *expandedGroups = NULL; std::set<std::string> MessengerWindow::expandedPeers ;
std::set<RsNodeGroupId> MessengerWindow::expandedGroups ;
/*static*/ void MessengerWindow::showYourself () /*static*/ void MessengerWindow::showYourself ()
{ {
@ -79,16 +80,6 @@ void MessengerWindow::releaseInstance()
if (_instance) { if (_instance) {
delete _instance; delete _instance;
} }
if (expandedPeers) {
/* delete saved expanded peers */
delete(expandedPeers);
expandedPeers = NULL;
}
if (expandedGroups) {
/* delete saved expanded groups */
delete(expandedGroups);
expandedGroups = NULL;
}
} }
/** Constructor */ /** Constructor */
@ -108,21 +99,15 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WindowFlags flags)
connect(NotifyQt::getInstance(), SIGNAL(ownStatusMessageChanged()), this, SLOT(loadmystatusmessage())); connect(NotifyQt::getInstance(), SIGNAL(ownStatusMessageChanged()), this, SLOT(loadmystatusmessage()));
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateOwnStatus(QString,int))); connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateOwnStatus(QString,int)));
if (expandedPeers != NULL) { for (std::set<std::string>::iterator peerIt = expandedPeers.begin(); peerIt != expandedPeers.end(); ++peerIt) {
for (std::set<std::string>::iterator peerIt = expandedPeers->begin(); peerIt != expandedPeers->end(); ++peerIt) {
ui.friendList->addPeerToExpand(*peerIt); ui.friendList->addPeerToExpand(*peerIt);
} }
delete expandedPeers; expandedPeers.clear();
expandedPeers = NULL;
}
if (expandedGroups != NULL) { for (std::set<RsNodeGroupId>::iterator groupIt = expandedGroups.begin(); groupIt != expandedGroups.end(); ++groupIt) {
for (std::set<std::string>::iterator groupIt = expandedGroups->begin(); groupIt != expandedGroups->end(); ++groupIt) {
ui.friendList->addGroupToExpand(*groupIt); ui.friendList->addGroupToExpand(*groupIt);
} }
delete expandedGroups; expandedGroups.clear();
expandedGroups = NULL;
}
ui.messagelineEdit->setMinimumWidth(20); ui.messagelineEdit->setMinimumWidth(20);
@ -203,22 +188,12 @@ void MessengerWindow::addFriend()
void MessengerWindow::closeEvent (QCloseEvent * /*event*/) void MessengerWindow::closeEvent (QCloseEvent * /*event*/)
{ {
/* save the expanded peers */ /* save the expanded peers */
if (expandedPeers == NULL) { expandedPeers.clear();
expandedPeers = new std::set<std::string>; ui.friendList->getExpandedPeers(expandedPeers);
} else {
expandedPeers->clear();
}
ui.friendList->getExpandedPeers(*expandedPeers);
/* save the expanded groups */ /* save the expanded groups */
if (expandedGroups == NULL) { expandedGroups.clear();
expandedGroups = new std::set<std::string>; ui.friendList->getExpandedGroups(expandedGroups);
} else {
expandedGroups->clear();
}
ui.friendList->getExpandedGroups(*expandedGroups);
} }
/** Shows Share Manager */ /** Shows Share Manager */

View File

@ -66,6 +66,9 @@ private:
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::MessengerWindow ui; Ui::MessengerWindow ui;
static std::set<std::string> expandedPeers ;
static std::set<RsNodeGroupId> expandedGroups ;
}; };
#endif #endif

View File

@ -212,12 +212,12 @@ QString RetroshareDirModel::getFlagsString(FileStorageFlags flags)
return QString(str) ; return QString(str) ;
} }
QString RetroshareDirModel::getGroupsString(const std::list<std::string>& group_ids) QString RetroshareDirModel::getGroupsString(const std::list<RsNodeGroupId>& group_ids)
{ {
QString groups_str ; QString groups_str ;
RsGroupInfo group_info ; RsGroupInfo group_info ;
for(std::list<std::string>::const_iterator it(group_ids.begin());it!=group_ids.end();) for(std::list<RsNodeGroupId>::const_iterator it(group_ids.begin());it!=group_ids.end();)
if(rsPeers->getGroupInfo(*it,group_info)) if(rsPeers->getGroupInfo(*it,group_info))
{ {
groups_str += GroupDefs::name(group_info) ; groups_str += GroupDefs::name(group_info) ;

View File

@ -91,7 +91,7 @@ class RetroshareDirModel : public QAbstractItemModel
void treeStyle(); void treeStyle();
void downloadDirectory(const DirDetails & details, int prefixLen); void downloadDirectory(const DirDetails & details, int prefixLen);
static QString getFlagsString(FileStorageFlags f) ; static QString getFlagsString(FileStorageFlags f) ;
static QString getGroupsString(const std::list<std::string>&) ; static QString getGroupsString(const std::list<RsNodeGroupId> &) ;
QString getAgeIndicatorString(const DirDetails &) const; QString getAgeIndicatorString(const DirDetails &) const;
// void getAgeIndicatorRec(const DirDetails &details, QString &ret) const; // void getAgeIndicatorRec(const DirDetails &details, QString &ret) const;

View File

@ -249,7 +249,7 @@ void ShareManager::updateGroups()
QString group_string; QString group_string;
int n = 0; int n = 0;
for (std::list<std::string>::const_iterator it2((*it).parent_groups.begin());it2!=(*it).parent_groups.end();++it2,++n) for (std::list<RsNodeGroupId>::const_iterator it2((*it).parent_groups.begin());it2!=(*it).parent_groups.end();++it2,++n)
{ {
if (n>0) if (n>0)
group_string += ", " ; group_string += ", " ;

View File

@ -116,9 +116,7 @@ FriendList::FriendList(QWidget *parent) :
mShowGroups(true), mShowGroups(true),
mShowState(false), mShowState(false),
mHideUnconnected(false), mHideUnconnected(false),
groupsHasChanged(false), groupsHasChanged(false)
openGroups(NULL),
openPeers(NULL)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -219,7 +217,17 @@ void FriendList::processSettings(bool load)
int arrayIndex = Settings->beginReadArray("Groups"); int arrayIndex = Settings->beginReadArray("Groups");
for (int index = 0; index < arrayIndex; ++index) { for (int index = 0; index < arrayIndex; ++index) {
Settings->setArrayIndex(index); Settings->setArrayIndex(index);
addGroupToExpand(Settings->value("open").toString().toStdString());
std::string gids = Settings->value("open").toString().toStdString();
RsGroupInfo ginfo ;
if(rsPeers->getGroupInfoByName(gids,ginfo)) // backward compatibility
addGroupToExpand(ginfo.id) ;
else if(rsPeers->getGroupInfo(RsNodeGroupId(gids),ginfo)) // backward compatibility
addGroupToExpand(ginfo.id) ;
else
std::cerr << "(EE) Cannot find group info for openned group \"" << gids << "\"" << std::endl;
} }
Settings->endArray(); Settings->endArray();
} else { } else {
@ -236,11 +244,11 @@ void FriendList::processSettings(bool load)
// open groups // open groups
Settings->beginWriteArray("Groups"); Settings->beginWriteArray("Groups");
int arrayIndex = 0; int arrayIndex = 0;
std::set<std::string> expandedPeers; std::set<RsNodeGroupId> expandedPeers;
getExpandedGroups(expandedPeers); getExpandedGroups(expandedPeers);
foreach (std::string groupId, expandedPeers) { foreach (RsNodeGroupId groupId, expandedPeers) {
Settings->setArrayIndex(arrayIndex++); Settings->setArrayIndex(arrayIndex++);
Settings->setValue("open", QString::fromStdString(groupId)); Settings->setValue("open", QString::fromStdString(groupId.toStdString()));
} }
Settings->endArray(); Settings->endArray();
} }
@ -369,7 +377,7 @@ void FriendList::peerTreeWidgetCustomPopupMenu()
addToGroupMenu = new QMenu(tr("Add to group"), &contextMnu); addToGroupMenu = new QMenu(tr("Add to group"), &contextMnu);
} }
QAction* addToGroupAction = new QAction(GroupDefs::name(*groupIt), addToGroupMenu); QAction* addToGroupAction = new QAction(GroupDefs::name(*groupIt), addToGroupMenu);
addToGroupAction->setData(QString::fromStdString(groupIt->id)); addToGroupAction->setData(QString::fromStdString(groupIt->id.toStdString()));
connect(addToGroupAction, SIGNAL(triggered()), this, SLOT(addToGroup())); connect(addToGroupAction, SIGNAL(triggered()), this, SLOT(addToGroup()));
addToGroupMenu->addAction(addToGroupAction); addToGroupMenu->addAction(addToGroupAction);
} }
@ -378,7 +386,7 @@ void FriendList::peerTreeWidgetCustomPopupMenu()
moveToGroupMenu = new QMenu(tr("Move to group"), &contextMnu); moveToGroupMenu = new QMenu(tr("Move to group"), &contextMnu);
} }
QAction* moveToGroupAction = new QAction(GroupDefs::name(*groupIt), moveToGroupMenu); QAction* moveToGroupAction = new QAction(GroupDefs::name(*groupIt), moveToGroupMenu);
moveToGroupAction->setData(QString::fromStdString(groupIt->id)); moveToGroupAction->setData(QString::fromStdString(groupIt->id.toStdString()));
connect(moveToGroupAction, SIGNAL(triggered()), this, SLOT(moveToGroup())); connect(moveToGroupAction, SIGNAL(triggered()), this, SLOT(moveToGroup()));
moveToGroupMenu->addAction(moveToGroupAction); moveToGroupMenu->addAction(moveToGroupAction);
} else { } else {
@ -456,7 +464,7 @@ void FriendList::peerTreeWidgetCustomPopupMenu()
void FriendList::createNewGroup() void FriendList::createNewGroup()
{ {
CreateGroup createGrpDialog ("", this); CreateGroup createGrpDialog (RsNodeGroupId(), this);
createGrpDialog.exec(); createGrpDialog.exec();
} }
@ -596,7 +604,7 @@ void FriendList::insertPeers()
if (mShowGroups && groupsHasChanged) { if (mShowGroups && groupsHasChanged) {
if (parent) { if (parent) {
if (parent->type() == TYPE_GROUP) { if (parent->type() == TYPE_GROUP) {
std::string groupId = getRsId(parent); RsNodeGroupId groupId(getRsId(parent));
// the parent is a group, check if the gpg id is assigned to the group // the parent is a group, check if the gpg id is assigned to the group
for (groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); ++groupIt) { for (groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); ++groupIt) {
@ -630,7 +638,7 @@ void FriendList::insertPeers()
} }
} else if (groupsHasChanged) { } else if (groupsHasChanged) {
// remove deleted groups // remove deleted groups
std::string groupId = getRsId(item); RsNodeGroupId groupId ( getRsId(item));
for (groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); ++groupIt) { for (groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); ++groupIt) {
if (groupIt->id == groupId) { if (groupIt->id == groupId) {
break; break;
@ -671,7 +679,7 @@ void FriendList::insertPeers()
int itemCount = peerTreeWidget->topLevelItemCount(); int itemCount = peerTreeWidget->topLevelItemCount();
for (int index = 0; index < itemCount; ++index) { for (int index = 0; index < itemCount; ++index) {
QTreeWidgetItem *groupItemLoop = peerTreeWidget->topLevelItem(index); QTreeWidgetItem *groupItemLoop = peerTreeWidget->topLevelItem(index);
if (groupItemLoop->type() == TYPE_GROUP && getRsId(groupItemLoop) == groupInfo->id) { if (groupItemLoop->type() == TYPE_GROUP && RsNodeGroupId(getRsId(groupItemLoop)) == groupInfo->id) {
groupItem = groupItemLoop; groupItem = groupItemLoop;
break; break;
} }
@ -690,7 +698,7 @@ void FriendList::insertPeers()
groupItem->setForeground(COLUMN_NAME, QBrush(textColorGroup())); groupItem->setForeground(COLUMN_NAME, QBrush(textColorGroup()));
/* used to find back the item */ /* used to find back the item */
groupItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(groupInfo->id)); groupItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(groupInfo->id.toStdString()));
groupItem->setData(COLUMN_DATA, ROLE_STANDARD, (groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? true : false); groupItem->setData(COLUMN_DATA, ROLE_STANDARD, (groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? true : false);
/* Sort data */ /* Sort data */
@ -716,7 +724,7 @@ void FriendList::insertPeers()
} }
} }
if (openGroups != NULL && openGroups->find(groupInfo->id) != openGroups->end()) { if (openGroups.find(groupInfo->id) != openGroups.end()) {
groupItem->setExpanded(true); groupItem->setExpanded(true);
} }
@ -1182,7 +1190,7 @@ void FriendList::insertPeers()
gpgItem->setFont(i, gpgFont); gpgItem->setFont(i, gpgFont);
} }
if (openPeers != NULL && openPeers->find(gpgId.toStdString()) != openPeers->end()) { if (openPeers.find(gpgId.toStdString()) != openPeers.end()) {
gpgItem->setExpanded(true); gpgItem->setExpanded(true);
} }
} }
@ -1217,14 +1225,6 @@ void FriendList::insertPeers()
} }
groupsHasChanged = false; groupsHasChanged = false;
if (openGroups != NULL) {
delete(openGroups);
openGroups = NULL;
}
if (openPeers != NULL) {
delete(openPeers);
openPeers = NULL;
}
ui->peerTreeWidget->resort(); ui->peerTreeWidget->resort();
} }
@ -1232,13 +1232,13 @@ void FriendList::insertPeers()
/** /**
* Returns a list with all groupIds that are expanded * Returns a list with all groupIds that are expanded
*/ */
bool FriendList::getExpandedGroups(std::set<std::string> &groups) const bool FriendList::getExpandedGroups(std::set<RsNodeGroupId> &groups) const
{ {
int itemCount = ui->peerTreeWidget->topLevelItemCount(); int itemCount = ui->peerTreeWidget->topLevelItemCount();
for (int index = 0; index < itemCount; ++index) { for (int index = 0; index < itemCount; ++index) {
QTreeWidgetItem *item = ui->peerTreeWidget->topLevelItem(index); QTreeWidgetItem *item = ui->peerTreeWidget->topLevelItem(index);
if (item->type() == TYPE_GROUP && item->isExpanded()) { if (item->type() == TYPE_GROUP && item->isExpanded()) {
groups.insert(item->data(COLUMN_DATA, ROLE_ID).toString().toStdString()); groups.insert(RsNodeGroupId(item->data(COLUMN_DATA, ROLE_ID).toString().toStdString()));
} }
} }
return true; return true;
@ -1626,7 +1626,7 @@ void FriendList::getSslIdsFromItem(QTreeWidgetItem *item, std::list<RsPeerId> &s
case TYPE_GROUP: case TYPE_GROUP:
{ {
RsGroupInfo groupInfo; RsGroupInfo groupInfo;
if (rsPeers->getGroupInfo(peerId, groupInfo)) { if (rsPeers->getGroupInfo(RsNodeGroupId(peerId), groupInfo)) {
std::set<RsPgpId>::iterator gpgIt; std::set<RsPgpId>::iterator gpgIt;
for (gpgIt = groupInfo.peerIds.begin(); gpgIt != groupInfo.peerIds.end(); ++gpgIt) { for (gpgIt = groupInfo.peerIds.begin(); gpgIt != groupInfo.peerIds.end(); ++gpgIt) {
rsPeers->getAssociatedSSLIds(*gpgIt, sslIds); rsPeers->getAssociatedSSLIds(*gpgIt, sslIds);
@ -1649,10 +1649,10 @@ void FriendList::addToGroup()
return; return;
} }
std::string groupId = qobject_cast<QAction*>(sender())->data().toString().toStdString(); RsNodeGroupId groupId ( qobject_cast<QAction*>(sender())->data().toString().toStdString());
RsPgpId gpgId ( getRsId(c)); RsPgpId gpgId ( getRsId(c));
if (gpgId.isNull() || groupId.empty()) { if (gpgId.isNull() || groupId.isNull()) {
return; return;
} }
@ -1675,15 +1675,15 @@ void FriendList::moveToGroup()
return; return;
} }
std::string groupId = qobject_cast<QAction*>(sender())->data().toString().toStdString(); RsNodeGroupId groupId ( qobject_cast<QAction*>(sender())->data().toString().toStdString());
RsPgpId gpgId ( getRsId(c)); RsPgpId gpgId ( getRsId(c));
if (gpgId.isNull() || groupId.empty()) { if (gpgId.isNull() || groupId.isNull()) {
return; return;
} }
// remove from all groups // remove from all groups
rsPeers->assignPeerToGroup("", gpgId, false); rsPeers->assignPeerToGroup(RsNodeGroupId(), gpgId, false);
// automatically expand the group, the peer is added to // automatically expand the group, the peer is added to
addGroupToExpand(groupId); addGroupToExpand(groupId);
@ -1704,7 +1704,7 @@ void FriendList::removeFromGroup()
return; return;
} }
std::string groupId = qobject_cast<QAction*>(sender())->data().toString().toStdString(); RsNodeGroupId groupId ( qobject_cast<QAction*>(sender())->data().toString().toStdString());
RsPgpId gpgId ( getRsId(c)); RsPgpId gpgId ( getRsId(c));
if (gpgId.isNull()) { if (gpgId.isNull()) {
@ -1727,14 +1727,13 @@ void FriendList::editGroup()
return; return;
} }
std::string groupId = getRsId(c); RsNodeGroupId groupId ( getRsId(c));
if (groupId.empty()) { if (!groupId.isNull())
return; {
CreateGroup editGrpDialog(groupId, this);
editGrpDialog.exec();
} }
CreateGroup editGrpDialog(groupId, this);
editGrpDialog.exec();
} }
void FriendList::removeGroup() void FriendList::removeGroup()
@ -1749,13 +1748,10 @@ void FriendList::removeGroup()
return; return;
} }
std::string groupId = getRsId(c); RsNodeGroupId groupId ( getRsId(c));
if (groupId.empty()) { if (!groupId.isNull())
return; rsPeers->removeGroup(groupId);
}
rsPeers->removeGroup(groupId);
} }
void FriendList::exportFriendlistClicked() void FriendList::exportFriendlistClicked()
@ -2089,7 +2085,7 @@ bool FriendList::importFriendlist(QString &fileName, bool &errorPeers, bool &err
// get name and flags and try to get the group ID // get name and flags and try to get the group ID
std::string groupName = group.attribute("name").toStdString(); std::string groupName = group.attribute("name").toStdString();
uint32_t flag = group.attribute("flag").toInt(); uint32_t flag = group.attribute("flag").toInt();
std::string groupId; RsNodeGroupId groupId;
if(getOrCreateGroup(groupName, flag, groupId)) { if(getOrCreateGroup(groupName, flag, groupId)) {
// group id found! // group id found!
QDomElement pgpID = group.firstChildElement("pgpID"); QDomElement pgpID = group.firstChildElement("pgpID");
@ -2123,7 +2119,7 @@ bool FriendList::importFriendlist(QString &fileName, bool &errorPeers, bool &err
* @param id groupd id for the given name * @param id groupd id for the given name
* @return success or fail * @return success or fail
*/ */
bool FriendList::getGroupIdByName(const std::string &name, std::string &id) bool FriendList::getGroupIdByName(const std::string &name, RsNodeGroupId &id)
{ {
std::list<RsGroupInfo> grpList; std::list<RsGroupInfo> grpList;
if(!rsPeers->getGroupInfoList(grpList)) if(!rsPeers->getGroupInfoList(grpList))
@ -2146,14 +2142,14 @@ bool FriendList::getGroupIdByName(const std::string &name, std::string &id)
* @param id groupd id * @param id groupd id
* @return success or failure * @return success or failure
*/ */
bool FriendList::getOrCreateGroup(const std::string &name, const uint &flag, std::string &id) bool FriendList::getOrCreateGroup(const std::string &name, const uint &flag, RsNodeGroupId &id)
{ {
if(getGroupIdByName(name, id)) if(getGroupIdByName(name, id))
return true; return true;
// -> create one // -> create one
RsGroupInfo grp; RsGroupInfo grp;
grp.id = "0"; // RS will generate an ID grp.id.clear(); // RS will generate an ID
grp.name = name; grp.name = name;
grp.flag = flag; grp.flag = flag;
@ -2271,12 +2267,9 @@ void FriendList::filterItems(const QString &text)
* Add a groupId to the openGroups list. These groups * Add a groupId to the openGroups list. These groups
* will be expanded, when they're added to the QTreeWidget * will be expanded, when they're added to the QTreeWidget
*/ */
void FriendList::addGroupToExpand(const std::string &groupId) void FriendList::addGroupToExpand(const RsNodeGroupId &groupId)
{ {
if (openGroups == NULL) { openGroups.insert(groupId);
openGroups = new std::set<std::string>;
}
openGroups->insert(groupId);
} }
/** /**
@ -2285,10 +2278,7 @@ void FriendList::addGroupToExpand(const std::string &groupId)
*/ */
void FriendList::addPeerToExpand(const std::string &gpgId) void FriendList::addPeerToExpand(const std::string &gpgId)
{ {
if (openPeers == NULL) { openPeers.insert(gpgId);
openPeers = new std::set<std::string>;
}
openPeers->insert(gpgId);
} }
void FriendList::createDisplayMenu() void FriendList::createDisplayMenu()

View File

@ -63,8 +63,8 @@ public:
// Add a tool button to the tool area // Add a tool button to the tool area
void addToolButton(QToolButton *toolButton); void addToolButton(QToolButton *toolButton);
void processSettings(bool load); void processSettings(bool load);
void addGroupToExpand(const std::string &groupId); void addGroupToExpand(const RsNodeGroupId &groupId);
bool getExpandedGroups(std::set<std::string> &groups) const; bool getExpandedGroups(std::set<RsNodeGroupId> &groups) const;
void addPeerToExpand(const std::string &gpgId); void addPeerToExpand(const std::string &gpgId);
bool getExpandedPeers(std::set<std::string> &peers) const; bool getExpandedPeers(std::set<std::string> &peers) const;
@ -119,8 +119,9 @@ private:
QString mFilterText; QString mFilterText;
bool groupsHasChanged; bool groupsHasChanged;
std::set<std::string> *openGroups; std::set<RsNodeGroupId> openGroups;
std::set<std::string> *openPeers; #warning this would needs an ID, not a std::string.
std::set<std::string> openPeers;
/* Color definitions (for standard see qss.default) */ /* Color definitions (for standard see qss.default) */
QColor mTextColorGroup; QColor mTextColorGroup;
@ -129,8 +130,8 @@ private:
QTreeWidgetItem *getCurrentPeer() const; QTreeWidgetItem *getCurrentPeer() const;
void getSslIdsFromItem(QTreeWidgetItem *item, std::list<RsPeerId> &sslIds); void getSslIdsFromItem(QTreeWidgetItem *item, std::list<RsPeerId> &sslIds);
bool getOrCreateGroup(const std::string &name, const uint &flag, std::string &id); bool getOrCreateGroup(const std::string &name, const uint &flag, RsNodeGroupId &id);
bool getGroupIdByName(const std::string &name, std::string &id); bool getGroupIdByName(const std::string &name, RsNodeGroupId &id);
bool importExportFriendlistFileDialog(QString &fileName, bool import); bool importExportFriendlistFileDialog(QString &fileName, bool import);
bool exportFriendlist(QString &fileName); bool exportFriendlist(QString &fileName);

View File

@ -271,9 +271,9 @@ void FriendSelectionWidget::secured_fillList()
selectedIds<RsPeerId,IDTYPE_SSL>(sslIdsSelected,true); selectedIds<RsPeerId,IDTYPE_SSL>(sslIdsSelected,true);
} }
std::set<std::string> groupIdsSelected; std::set<RsNodeGroupId> groupIdsSelected;
if (mShowTypes & SHOW_GROUP) { if (mShowTypes & SHOW_GROUP) {
selectedIds<std::string,IDTYPE_GROUP>(groupIdsSelected,true); selectedIds<RsNodeGroupId,IDTYPE_GROUP>(groupIdsSelected,true);
} }
std::set<RsPgpId> gpgIdsSelected; std::set<RsPgpId> gpgIdsSelected;
@ -305,6 +305,9 @@ void FriendSelectionWidget::secured_fillList()
else else
rsPeers->getGPGAcceptedList(gpgIds); rsPeers->getGPGAcceptedList(gpgIds);
// add own pgp id to the list
gpgIds.push_back(rsPeers->getGPGOwnId()) ;
std::list<RsPeerId> sslIds; std::list<RsPeerId> sslIds;
std::list<RsPeerId>::iterator sslIt; std::list<RsPeerId>::iterator sslIt;
@ -347,7 +350,7 @@ void FriendSelectionWidget::secured_fillList()
groupItem->setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter); groupItem->setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter);
groupItem->setIcon(COLUMN_NAME, QIcon(IMAGE_GROUP16)); groupItem->setIcon(COLUMN_NAME, QIcon(IMAGE_GROUP16));
groupItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(groupInfo->id)); groupItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(groupInfo->id.toStdString()));
groupItem->setExpanded(true); groupItem->setExpanded(true);
@ -363,7 +366,7 @@ void FriendSelectionWidget::secured_fillList()
groupItem->setCheckState(0, Qt::Unchecked); groupItem->setCheckState(0, Qt::Unchecked);
} }
emit itemAdded(IDTYPE_GROUP, QString::fromStdString(groupInfo->id), groupItem); emit itemAdded(IDTYPE_GROUP, QString::fromStdString(groupInfo->id.toStdString()), groupItem);
if (std::find(groupIdsSelected.begin(), groupIdsSelected.end(), groupInfo->id) != groupIdsSelected.end()) { if (std::find(groupIdsSelected.begin(), groupIdsSelected.end(), groupInfo->id) != groupIdsSelected.end()) {
setSelected(mListModus, groupItem, true); setSelected(mListModus, groupItem, true);

View File

@ -0,0 +1,117 @@
/*
* Retroshare Gxs Support
*
* Copyright 2012-2013 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "GroupChooser.h"
#include <algorithm>
#include <iostream>
#include <retroshare/rspeers.h>
/** Constructor */
GroupChooser::GroupChooser(QWidget *parent)
: QComboBox(parent), mFlags(0)
{
return;
}
void GroupChooser::loadGroups(uint32_t chooserFlags, const RsNodeGroupId& defaultId)
{
mFlags = chooserFlags;
mDefaultGroupId = defaultId;
loadGroups();
}
bool GroupChooser::makeNodeGroupDesc(const RsGroupInfo& info, QString &desc)
{
desc.clear();
if(info.name.empty())
desc = tr("[Unknown]") ;
else
desc = "\"" + QString::fromUtf8(info.name.c_str()) + "\"";
desc += " [" ;
desc += QString::fromStdString(info.id.toStdString().substr(0,3));
desc += "...";
desc += QString::fromStdString(info.id.toStdString().substr(info.id.toStdString().length()-2,2));
desc += "]";
return true;
}
void GroupChooser::loadGroups()
{
std::list<RsGroupInfo> ids;
rsPeers->getGroupInfoList(ids);
if (ids.empty())
{
std::cerr << "GroupChooser::loadGroups() ERROR no ids";
std::cerr << std::endl;
return;
}
int i = 0;
int def = -1;
for( std::list<RsGroupInfo>::iterator it = ids.begin(); it != ids.end(); ++it, ++i)
{
/* add to Chooser */
QString str;
if (!makeNodeGroupDesc(*it, str))
{
std::cerr << "GroupChooser::loadGroups() ERROR Desc for Id: " << it->id;
std::cerr << std::endl;
continue;
}
QString id = QString::fromStdString(it->id.toStdString());
addItem(str, id);
if (mDefaultGroupId == it->id)
def = i;
}
if (def >= 0)
{
setCurrentIndex(def);
}
}
bool GroupChooser::getChosenGroup(RsNodeGroupId& id)
{
if (count() < 1)
return false;
int idx = currentIndex();
QVariant var = itemData(idx);
id = RsNodeGroupId(var.toString().toStdString());
return true;
}

View File

@ -0,0 +1,45 @@
/*
* Retroshare Gxs Support
*
* Copyright 2012-2013 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#pragma once
#include <QComboBox>
#include <retroshare/rspeers.h>
class GroupChooser : public QComboBox
{
public:
GroupChooser(QWidget *parent = NULL);
void loadGroups(uint32_t chooserFlags, const RsNodeGroupId& defaultId);
bool getChosenGroup(RsNodeGroupId& id);
static bool makeNodeGroupDesc(const RsGroupInfo& info, QString &desc);
private:
void loadGroups();
uint32_t mFlags;
RsNodeGroupId mDefaultGroupId;
};

View File

@ -51,7 +51,7 @@ const QString GroupDefs::name(const RsGroupInfo &groupInfo)
return qApp->translate("GroupDefs", "Favorites"); return qApp->translate("GroupDefs", "Favorites");
} }
std::cerr << "GroupDefs::name: Unknown group id requested " << groupInfo.id; std::cerr << "GroupDefs::name: Unknown group id requested " << groupInfo.id << std::endl;
return ""; return "";
} }

View File

@ -20,7 +20,7 @@ GroupSelectionBox::GroupSelectionBox(QWidget *parent)
void GroupSelectionBox::fillGroups() void GroupSelectionBox::fillGroups()
{ {
std::list<std::string> selectedIds; std::list<RsNodeGroupId> selectedIds;
selectedGroupIds(selectedIds); selectedGroupIds(selectedIds);
clear(); clear();
@ -30,7 +30,7 @@ void GroupSelectionBox::fillGroups()
for (std::list<RsGroupInfo>::const_iterator it(groupIds.begin()); it != groupIds.end(); ++it) { for (std::list<RsGroupInfo>::const_iterator it(groupIds.begin()); it != groupIds.end(); ++it) {
QListWidgetItem *item = new QListWidgetItem(GroupDefs::name(*it)); QListWidgetItem *item = new QListWidgetItem(GroupDefs::name(*it));
item->setData(ROLE_ID, QString::fromStdString(it->id)); item->setData(ROLE_ID, QString::fromStdString(it->id.toStdString()));
item->setBackgroundColor(QColor(183,236,181)); item->setBackgroundColor(QColor(183,236,181));
addItem(item); addItem(item);
} }
@ -38,27 +38,27 @@ void GroupSelectionBox::fillGroups()
setSelectedGroupIds(selectedIds); setSelectedGroupIds(selectedIds);
} }
void GroupSelectionBox::selectedGroupIds(std::list<std::string> &groupIds) const void GroupSelectionBox::selectedGroupIds(std::list<RsNodeGroupId> &groupIds) const
{ {
int itemCount = count(); int itemCount = count();
for (int i = 0; i < itemCount; ++i) { for (int i = 0; i < itemCount; ++i) {
QListWidgetItem *listItem = item(i); QListWidgetItem *listItem = item(i);
if (listItem->checkState() == Qt::Checked) { if (listItem->checkState() == Qt::Checked) {
groupIds.push_back(item(i)->data(ROLE_ID).toString().toStdString()); groupIds.push_back(RsNodeGroupId(item(i)->data(ROLE_ID).toString().toStdString()));
std::cerr << "Adding selected item " << groupIds.back() << std::endl; std::cerr << "Adding selected item " << groupIds.back() << std::endl;
} }
} }
} }
void GroupSelectionBox::setSelectedGroupIds(const std::list<std::string>& groupIds) void GroupSelectionBox::setSelectedGroupIds(const std::list<RsNodeGroupId>& groupIds)
{ {
int itemCount = count(); int itemCount = count();
for (int i = 0; i < itemCount; ++i) { for (int i = 0; i < itemCount; ++i) {
QListWidgetItem *listItem = item(i); QListWidgetItem *listItem = item(i);
if (std::find(groupIds.begin(), groupIds.end(), listItem->data(ROLE_ID).toString().toStdString()) != groupIds.end()) { if (std::find(groupIds.begin(), groupIds.end(), RsNodeGroupId(listItem->data(ROLE_ID).toString().toStdString())) != groupIds.end()) {
listItem->setCheckState(Qt::Checked); listItem->setCheckState(Qt::Checked);
} else { } else {
listItem->setCheckState(Qt::Unchecked); listItem->setCheckState(Qt::Unchecked);

View File

@ -1,4 +1,5 @@
#include <QListWidget> #include <QListWidget>
#include <retroshare/rsids.h>
class GroupSelectionBox: public QListWidget class GroupSelectionBox: public QListWidget
{ {
@ -7,10 +8,10 @@ class GroupSelectionBox: public QListWidget
public: public:
GroupSelectionBox(QWidget *parent); GroupSelectionBox(QWidget *parent);
void selectedGroupIds(std::list<std::string> &groupIds) const; void selectedGroupIds(std::list<RsNodeGroupId> &groupIds) const;
void selectedGroupNames(QList<QString> &groupNames) const; void selectedGroupNames(QList<QString> &groupNames) const;
void setSelectedGroupIds(const std::list<std::string> &groupIds); void setSelectedGroupIds(const std::list<RsNodeGroupId> &groupIds);
private slots: private slots:
void fillGroups(); void fillGroups();

View File

@ -297,7 +297,7 @@ static void fillGroups(ConnectFriendWizard *wizard, QComboBox *comboBox, const Q
GroupDefs::sortByName(groupInfoList); GroupDefs::sortByName(groupInfoList);
comboBox->addItem("", ""); // empty value comboBox->addItem("", ""); // empty value
for (std::list<RsGroupInfo>::iterator groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); ++groupIt) { for (std::list<RsGroupInfo>::iterator groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); ++groupIt) {
comboBox->addItem(GroupDefs::name(*groupIt), QString::fromStdString(groupIt->id)); comboBox->addItem(GroupDefs::name(*groupIt), QString::fromStdString(groupIt->id.toStdString()));
} }
if (groupId.isEmpty() == false) { if (groupId.isEmpty() == false) {
@ -853,7 +853,7 @@ void ConnectFriendWizard::accept()
} }
if (!groupId.isEmpty()) if (!groupId.isEmpty())
rsPeers->assignPeerToGroup(groupId.toStdString(), peerDetails.gpg_id, true); rsPeers->assignPeerToGroup(RsNodeGroupId(groupId.toStdString()), peerDetails.gpg_id, true);
} }
if ((accept_connection) && (!peerDetails.id.isNull())) if ((accept_connection) && (!peerDetails.id.isNull()))

View File

@ -31,7 +31,7 @@
#include <algorithm> #include <algorithm>
/** Default constructor */ /** Default constructor */
CreateGroup::CreateGroup(const std::string &groupId, QWidget *parent) CreateGroup::CreateGroup(const RsNodeGroupId &groupId, QWidget *parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
{ {
/* Invoke Qt Designer generated QObject setup routine */ /* Invoke Qt Designer generated QObject setup routine */
@ -45,13 +45,18 @@ CreateGroup::CreateGroup(const std::string &groupId, QWidget *parent)
mGroupId = groupId; mGroupId = groupId;
if(!mGroupId.isNull())
ui.groupId_LE->setText(QString::fromStdString(mGroupId.toStdString())) ;
else
ui.groupId_LE->setText(tr("To be defined")) ;
/* Initialize friends list */ /* Initialize friends list */
ui.friendList->setHeaderText(tr("Friends")); ui.friendList->setHeaderText(tr("Friends"));
ui.friendList->setModus(FriendSelectionWidget::MODUS_CHECK); ui.friendList->setModus(FriendSelectionWidget::MODUS_CHECK);
ui.friendList->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_GPG); ui.friendList->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_GPG);
ui.friendList->start(); ui.friendList->start();
if (mGroupId.empty() == false) { if (!mGroupId.isNull()) {
/* edit exisiting group */ /* edit exisiting group */
RsGroupInfo groupInfo; RsGroupInfo groupInfo;
if (rsPeers->getGroupInfo(mGroupId, groupInfo)) { if (rsPeers->getGroupInfo(mGroupId, groupInfo)) {
@ -83,7 +88,7 @@ CreateGroup::CreateGroup(const std::string &groupId, QWidget *parent)
std::list<RsGroupInfo>::iterator groupIt; std::list<RsGroupInfo>::iterator groupIt;
for (groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); ++groupIt) { for (groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); ++groupIt) {
if (mGroupId.empty() || groupIt->id != mGroupId) { if (mGroupId.isNull() || groupIt->id != mGroupId) {
mUsedGroupNames.append(GroupDefs::name(*groupIt)); mUsedGroupNames.append(GroupDefs::name(*groupIt));
} }
} }
@ -104,9 +109,9 @@ CreateGroup::~CreateGroup()
void CreateGroup::groupNameChanged(QString text) void CreateGroup::groupNameChanged(QString text)
{ {
if (text.isEmpty() || mUsedGroupNames.contains(misc::removeNewLine(text))) { if (text.isEmpty() || mUsedGroupNames.contains(misc::removeNewLine(text))) {
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
} else { } else {
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
} }
} }
@ -114,14 +119,19 @@ void CreateGroup::changeGroup()
{ {
RsGroupInfo groupInfo; RsGroupInfo groupInfo;
if (mGroupId.empty()) { if (mGroupId.isNull())
{
// add new group // add new group
groupInfo.name = misc::removeNewLine(ui.groupName->text()).toUtf8().constData(); groupInfo.name = misc::removeNewLine(ui.groupName->text()).toUtf8().constData();
if (!rsPeers->addGroup(groupInfo)) {
if (!rsPeers->addGroup(groupInfo))
return; return;
}
} else { }
if (rsPeers->getGroupInfo(mGroupId, groupInfo) == true) { else
{
if (rsPeers->getGroupInfo(mGroupId, groupInfo))
{
if (!mIsStandard) { if (!mIsStandard) {
groupInfo.name = misc::removeNewLine(ui.groupName->text()).toUtf8().constData(); groupInfo.name = misc::removeNewLine(ui.groupName->text()).toUtf8().constData();
if (!rsPeers->editGroup(mGroupId, groupInfo)) { if (!rsPeers->editGroup(mGroupId, groupInfo)) {

View File

@ -30,7 +30,7 @@ class CreateGroup : public QDialog
public: public:
/** Default constructor */ /** Default constructor */
CreateGroup(const std::string &groupId, QWidget *parent = 0); CreateGroup(const RsNodeGroupId &groupId, QWidget *parent = 0);
/** Default destructor */ /** Default destructor */
~CreateGroup(); ~CreateGroup();
@ -39,7 +39,7 @@ private slots:
void groupNameChanged(QString); void groupNameChanged(QString);
private: private:
std::string mGroupId; RsNodeGroupId mGroupId;
QStringList mUsedGroupNames; QStringList mUsedGroupNames;
bool mIsStandard; bool mIsStandard;

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>386</width> <width>575</width>
<height>298</height> <height>485</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -23,9 +23,6 @@
<property name="margin"> <property name="margin">
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0">
<widget class="HeaderFrame" name="headerFrame"/>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QFrame" name="frame"> <widget class="QFrame" name="frame">
<property name="frameShape"> <property name="frameShape">
@ -36,27 +33,35 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QHBoxLayout" name="groupLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="spacing"> <item row="0" column="0">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="groupLabel"> <widget class="QLabel" name="groupLabel">
<property name="text"> <property name="text">
<string>Group Name</string> <string>Group Name:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="1">
<widget class="QLineEdit" name="groupName"> <widget class="QLineEdit" name="groupName">
<property name="toolTip"> <property name="toolTip">
<string>Enter a name for your group</string> <string>Enter a name for your group</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="groupId_LB">
<property name="text">
<string>Group ID:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="groupId_LE">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@ -79,6 +84,9 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="0" column="0">
<widget class="HeaderFrame" name="headerFrame"/>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>

View File

@ -31,14 +31,13 @@
/** Constructor */ /** Constructor */
GxsCircleChooser::GxsCircleChooser(QWidget *parent) GxsCircleChooser::GxsCircleChooser(QWidget *parent)
: QComboBox(parent), mFlags(0) : QComboBox(parent)
{ {
return; return;
} }
void GxsCircleChooser::loadCircles(uint32_t chooserFlags, const RsGxsCircleId &defaultId) void GxsCircleChooser::loadCircles(const RsGxsCircleId &defaultId)
{ {
mFlags = chooserFlags;
mDefaultCircleId = defaultId; mDefaultCircleId = defaultId;
loadGxsCircles(); loadGxsCircles();
} }
@ -68,14 +67,7 @@ bool MakeGxsCircleDesc(const RsGxsCircleId &id, QString &desc)
void GxsCircleChooser::loadGxsCircles() void GxsCircleChooser::loadGxsCircles()
{ {
std::list<RsGxsCircleId> ids; std::list<RsGxsCircleId> ids;
if (mFlags & GXS_CIRCLE_CHOOSER_EXTERNAL) rsGxsCircles->getCircleExternalIdList(ids);
{
rsGxsCircles->getCircleExternalIdList(ids);
}
if (mFlags & GXS_CIRCLE_CHOOSER_PERSONAL)
{
rsGxsCircles->getCirclePersonalIdList(ids);
}
if (ids.empty()) if (ids.empty())
{ {

View File

@ -28,11 +28,6 @@
#include <QComboBox> #include <QComboBox>
#include <retroshare/rsgxscircles.h> #include <retroshare/rsgxscircles.h>
#define GXS_CIRCLE_CHOOSER_EXTERNAL 0x0001
#define GXS_CIRCLE_CHOOSER_PERSONAL 0x0002
#define GXS_CIRCLE_CHOOSER_ALLCIRCLES 0x0003 // OR of other two.
class GxsCircleChooser : public QComboBox class GxsCircleChooser : public QComboBox
{ {
Q_OBJECT Q_OBJECT
@ -40,12 +35,11 @@ class GxsCircleChooser : public QComboBox
public: public:
GxsCircleChooser(QWidget *parent = NULL); GxsCircleChooser(QWidget *parent = NULL);
void loadCircles(uint32_t chooserFlags, const RsGxsCircleId &defaultId); void loadCircles(const RsGxsCircleId &defaultId);
bool getChosenCircle(RsGxsCircleId &id); bool getChosenCircle(RsGxsCircleId &id);
private: private:
void loadGxsCircles(); void loadGxsCircles();
uint32_t mFlags;
RsGxsCircleId mDefaultCircleId; RsGxsCircleId mDefaultCircleId;
}; };

View File

@ -124,8 +124,8 @@ void GxsGroupDialog::init()
/* Setup Reasonable Defaults */ /* Setup Reasonable Defaults */
ui.idChooser->loadIds(0,RsGxsId()); ui.idChooser->loadIds(0,RsGxsId());
ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL, RsGxsCircleId()); ui.circleComboBox->loadCircles(RsGxsCircleId());
ui.localComboBox->loadCircles(GXS_CIRCLE_CHOOSER_PERSONAL, RsGxsCircleId()); ui.localComboBox->loadGroups(0, RsNodeGroupId());
ui.groupDesc->setPlaceholderText(tr("Set a descriptive description here")); ui.groupDesc->setPlaceholderText(tr("Set a descriptive description here"));
@ -321,8 +321,6 @@ void GxsGroupDialog::setupDefaults()
ui.typeGroup_3->setEnabled(false); ui.typeGroup_3->setEnabled(false);
ui.typeLocal_3->setEnabled(false); ui.typeLocal_3->setEnabled(false);
#endif #endif
ui.typeLocal->setEnabled(false); // for now, since local circles not fully tested.
ui.typeLocal->setToolTip(tr("This feature is not yet available, but it will be available very soon!")); // for now, since local circles not fully tested.
} }
void GxsGroupDialog::setupVisibility() void GxsGroupDialog::setupVisibility()
@ -400,85 +398,97 @@ void GxsGroupDialog::newGroup()
void GxsGroupDialog::updateFromExistingMeta(const QString &description) void GxsGroupDialog::updateFromExistingMeta(const QString &description)
{ {
std::cerr << "void GxsGroupDialog::updateFromExistingMeta()"; std::cerr << "void GxsGroupDialog::updateFromExistingMeta()";
std::cerr << std::endl; std::cerr << std::endl;
std::cerr << "void GxsGroupDialog::updateFromExistingMeta() mGrpMeta.mCircleType: "; std::cerr << "void GxsGroupDialog::updateFromExistingMeta() mGrpMeta.mCircleType: ";
std::cerr << mGrpMeta.mCircleType << " Internal: " << mGrpMeta.mInternalCircle; std::cerr << mGrpMeta.mCircleType << " Internal: " << mGrpMeta.mInternalCircle;
std::cerr << " External: " << mGrpMeta.mCircleId; std::cerr << " External: " << mGrpMeta.mCircleId;
std::cerr << std::endl; std::cerr << std::endl;
setupDefaults(); setupDefaults();
setupVisibility(); setupVisibility();
setupReadonly(); setupReadonly();
clearForm(); clearForm();
setGroupSignFlags(mGrpMeta.mSignFlags) ; setGroupSignFlags(mGrpMeta.mSignFlags) ;
/* setup name */ /* setup name */
ui.groupName->setText(QString::fromUtf8(mGrpMeta.mGroupName.c_str())); ui.groupName->setText(QString::fromUtf8(mGrpMeta.mGroupName.c_str()));
/* Show Mode */ /* Show Mode */
ui.nameline->setText(QString::fromUtf8(mGrpMeta.mGroupName.c_str())); ui.nameline->setText(QString::fromUtf8(mGrpMeta.mGroupName.c_str()));
ui.popline->setText(QString::number( mGrpMeta.mPop)) ; ui.popline->setText(QString::number( mGrpMeta.mPop)) ;
ui.postsline->setText(QString::number(mGrpMeta.mVisibleMsgCount)); ui.postsline->setText(QString::number(mGrpMeta.mVisibleMsgCount));
ui.lastpostline->setText(DateTime::formatLongDateTime(mGrpMeta.mLastPost)); ui.lastpostline->setText(DateTime::formatLongDateTime(mGrpMeta.mLastPost));
ui.authorLabel->setId(mGrpMeta.mAuthorId); ui.authorLabel->setId(mGrpMeta.mAuthorId);
ui.IDline->setText(QString::fromStdString(mGrpMeta.mGroupId.toStdString())); ui.IDline->setText(QString::fromStdString(mGrpMeta.mGroupId.toStdString()));
ui.descriptiontextEdit->setPlainText(description); ui.descriptiontextEdit->setPlainText(description);
switch (mode()) switch (mode())
{ {
case MODE_CREATE:{ case MODE_CREATE:{
} }
break; break;
case MODE_SHOW:{ case MODE_SHOW:{
ui.headerFrame->setHeaderText(QString::fromUtf8(mGrpMeta.mGroupName.c_str())); ui.headerFrame->setHeaderText(QString::fromUtf8(mGrpMeta.mGroupName.c_str()));
if (!mPicture.isNull()) if (!mPicture.isNull())
ui.headerFrame->setHeaderImage(mPicture); ui.headerFrame->setHeaderImage(mPicture);
} }
break; break;
case MODE_EDIT:{ case MODE_EDIT:{
} }
break; break;
} }
/* set description */ /* set description */
ui.groupDesc->setPlainText(description); ui.groupDesc->setPlainText(description);
QString distribution_string = "[Unknown]"; QString distribution_string = "[Unknown]";
switch(mGrpMeta.mCircleType) switch(mGrpMeta.mCircleType)
{ {
case GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY: case GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY:
ui.typeLocal->setChecked(true); {
distribution_string = tr("Your friends only") ; ui.typeLocal->setChecked(true);
ui.localComboBox->loadCircles(GXS_CIRCLE_CHOOSER_PERSONAL, mGrpMeta.mInternalCircle); distribution_string = tr("Only friends nodes in group ") ;
ui.distributionCircleComboBox->setVisible(true) ;
ui.distributionCircleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_PERSONAL, mGrpMeta.mInternalCircle); RsGroupInfo ginfo ;
break; rsPeers->getGroupInfo(RsNodeGroupId(mGrpMeta.mInternalCircle),ginfo) ;
case GXS_CIRCLE_TYPE_PUBLIC:
ui.typePublic->setChecked(true); QString desc;
distribution_string = tr("Public") ; GroupChooser::makeNodeGroupDesc(ginfo, desc);
ui.distributionCircleComboBox->setVisible(false) ; distribution_string += desc ;
break;
case GXS_CIRCLE_TYPE_EXTERNAL: ui.localComboBox->loadGroups(0, RsNodeGroupId(mGrpMeta.mInternalCircle));
ui.typeGroup->setChecked(true); ui.distributionCircleComboBox->setVisible(false) ;
distribution_string = tr("Restricted to circle:") ; ui.localComboBox->setVisible(true) ;
ui.distributionCircleComboBox->setVisible(true) ; }
ui.distributionCircleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL, mGrpMeta.mCircleId); break;
ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL, mGrpMeta.mCircleId); case GXS_CIRCLE_TYPE_PUBLIC:
break; ui.typePublic->setChecked(true);
default: distribution_string = tr("Public") ;
std::cerr << "CreateCircleDialog::updateCircleGUI() INVALID mCircleType"; ui.distributionCircleComboBox->setVisible(false) ;
std::cerr << std::endl; ui.localComboBox->setVisible(false) ;
break; break;
} case GXS_CIRCLE_TYPE_EXTERNAL:
ui.typeGroup->setChecked(true);
distribution_string = tr("Restricted to circle:") ;
ui.localComboBox->setVisible(false) ;
ui.distributionCircleComboBox->setVisible(true) ;
ui.distributionCircleComboBox->loadCircles(mGrpMeta.mCircleId);
ui.circleComboBox->loadCircles(mGrpMeta.mCircleId);
break;
default:
std::cerr << "CreateCircleDialog::updateCircleGUI() INVALID mCircleType";
std::cerr << std::endl;
break;
}
ui.distributionValueLabel->setText(distribution_string) ; ui.distributionValueLabel->setText(distribution_string) ;
ui.idChooser->loadIds(0, mGrpMeta.mAuthorId); ui.idChooser->loadIds(0, mGrpMeta.mAuthorId);
if(!mGrpMeta.mAuthorId.isNull()) if(!mGrpMeta.mAuthorId.isNull())
ui.idChooser->setChosenId(mGrpMeta.mAuthorId) ; ui.idChooser->setChosenId(mGrpMeta.mAuthorId) ;
updateCircleOptions(); updateCircleOptions();
} }
void GxsGroupDialog::submitGroup() void GxsGroupDialog::submitGroup()
@ -739,41 +749,42 @@ void GxsGroupDialog::updateCircleOptions()
bool GxsGroupDialog::setCircleParameters(RsGroupMetaData &meta) bool GxsGroupDialog::setCircleParameters(RsGroupMetaData &meta)
{ {
meta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC; meta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC;
meta.mCircleId.clear(); meta.mCircleId.clear();
meta.mOriginator.clear(); meta.mOriginator.clear();
meta.mInternalCircle.clear(); meta.mInternalCircle.clear();
if (ui.typePublic->isChecked()) if (ui.typePublic->isChecked())
{ {
meta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC; meta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC;
meta.mCircleId.clear(); meta.mCircleId.clear();
} }
else if (ui.typeGroup->isChecked()) else if (ui.typeGroup->isChecked())
{ {
meta.mCircleType = GXS_CIRCLE_TYPE_EXTERNAL; meta.mCircleType = GXS_CIRCLE_TYPE_EXTERNAL;
if (!ui.circleComboBox->getChosenCircle(meta.mCircleId)) if (!ui.circleComboBox->getChosenCircle(meta.mCircleId))
{ {
return false; return false;
} }
} }
else if (ui.typeLocal->isChecked()) else if (ui.typeLocal->isChecked())
{ {
meta.mCircleType = GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY; meta.mCircleType = GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY;
meta.mCircleId.clear(); meta.mCircleId.clear();
meta.mOriginator.clear(); meta.mOriginator.clear();
meta.mInternalCircle.clear() ; meta.mInternalCircle.clear() ;
if (!ui.localComboBox->getChosenCircle(meta.mInternalCircle)) RsNodeGroupId ngi ;
{
return false; if (!ui.localComboBox->getChosenGroup(ngi))
} return false;
}
else meta.mInternalCircle = RsGxsCircleId(ngi) ;
{ }
return false; else
} return false;
return true;
return true;
} }
void GxsGroupDialog::cancelDialog() void GxsGroupDialog::cancelDialog()

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>935</width> <width>860</width>
<height>785</height> <height>775</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -301,6 +301,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Messsages will spread way beyond your friend nodes, as long as people subscribe to the channel/forum/posted you're creating.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Public</string> <string>Public</string>
</property> </property>
@ -326,6 +329,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Messages will spread among Retroshare nodes that host one of the identities listed as member of the circle and who also subscribe the media. Only these nodes will be able to see that this forum/channel/posted media exists. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Restricted to Circle</string> <string>Restricted to Circle</string>
</property> </property>
@ -356,6 +362,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Messages will only be distributed to the selected subset of your friend nodes. They will not forward messages with each other, but only use your own node as a central hub to distribute them.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Only For Your Friends</string> <string>Only For Your Friends</string>
</property> </property>
@ -372,7 +381,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="GxsCircleChooser" name="localComboBox"/> <widget class="GroupChooser" name="localComboBox"/>
</item> </item>
</layout> </layout>
</item> </item>
@ -842,6 +851,11 @@
<extends>QTextEdit</extends> <extends>QTextEdit</extends>
<header location="global">gui/common/MimeTextEdit.h</header> <header location="global">gui/common/MimeTextEdit.h</header>
</customwidget> </customwidget>
<customwidget>
<class>GroupChooser</class>
<extends>QComboBox</extends>
<header>gui/common/GroupChooser.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../images.qrc"/> <include location="../images.qrc"/>

View File

@ -817,9 +817,20 @@ void GxsForumThreadWidget::insertGroupData()
distrib_string = tr("Restricted to members of circle ")+QString::fromStdString(group.mMeta.mCircleId.toStdString()) ; distrib_string = tr("Restricted to members of circle ")+QString::fromStdString(group.mMeta.mCircleId.toStdString()) ;
} }
break ; break ;
case GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY: distrib_string = tr("Your eyes only"); case GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY:
break ; {
case GXS_CIRCLE_TYPE_LOCAL: distrib_string = tr("You and your friend nodes"); distrib_string = tr("Only friends nodes in group ") ;
RsGroupInfo ginfo ;
rsPeers->getGroupInfo(RsNodeGroupId(group.mMeta.mInternalCircle),ginfo) ;
QString desc;
GroupChooser::makeNodeGroupDesc(ginfo, desc);
distrib_string += desc ;
}
break ;
case GXS_CIRCLE_TYPE_LOCAL: distrib_string = tr("Your eyes only"); // this is not yet supported. If you see this, it is a bug!
break ; break ;
default: default:
std::cerr << "(EE) badly initialised group distribution ID = " << group.mMeta.mCircleType << std::endl; std::cerr << "(EE) badly initialised group distribution ID = " << group.mMeta.mCircleType << std::endl;

View File

@ -887,7 +887,7 @@ void MessageComposer::calculateTitle()
setWindowTitle(tr("Compose") + ": " + misc::removeNewLine(ui.titleEdit->text())); setWindowTitle(tr("Compose") + ": " + misc::removeNewLine(ui.titleEdit->text()));
} }
static void calculateGroupsOfSslIds(const std::list<RsGroupInfo> &existingGroupInfos, std::list<RsPeerId> &checkSslIds, std::list<std::string> &checkGroupIds) static void calculateGroupsOfSslIds(const std::list<RsGroupInfo> &existingGroupInfos, std::list<RsPeerId> &checkSslIds, std::list<RsNodeGroupId> &checkGroupIds)
{ {
checkGroupIds.clear(); checkGroupIds.clear();
@ -1342,7 +1342,7 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
{ {
case PEER_TYPE_GROUP: { case PEER_TYPE_GROUP: {
RsGroupInfo groupInfo; RsGroupInfo groupInfo;
if (rsPeers->getGroupInfo(id, groupInfo) == false) { if (rsPeers->getGroupInfo(RsNodeGroupId(id), groupInfo) == false) {
// group not found // group not found
continue; continue;
} }
@ -1587,7 +1587,7 @@ void MessageComposer::setRecipientToRow(int row, enumType type, destinationType
icon = QIcon(IMAGE_GROUP16); icon = QIcon(IMAGE_GROUP16);
RsGroupInfo groupInfo; RsGroupInfo groupInfo;
if (rsPeers->getGroupInfo(id, groupInfo)) { if (rsPeers->getGroupInfo(RsNodeGroupId(id), groupInfo)) {
name = GroupDefs::name(groupInfo); name = GroupDefs::name(groupInfo);
} else { } else {
name = tr("Unknown"); name = tr("Unknown");
@ -1771,7 +1771,7 @@ void MessageComposer::editingRecipientFinished()
QString groupName = GroupDefs::name(*groupIt); QString groupName = GroupDefs::name(*groupIt);
if (text.compare(groupName, Qt::CaseSensitive) == 0) { if (text.compare(groupName, Qt::CaseSensitive) == 0) {
// found it // found it
setRecipientToRow(row, type, PEER_TYPE_GROUP, groupIt->id); setRecipientToRow(row, type, PEER_TYPE_GROUP, groupIt->id.toStdString());
return; return;
} }
} }

View File

@ -473,6 +473,7 @@ HEADERS += rshare.h \
gui/common/AvatarDefs.h \ gui/common/AvatarDefs.h \
gui/common/GroupFlagsWidget.h \ gui/common/GroupFlagsWidget.h \
gui/common/GroupSelectionBox.h \ gui/common/GroupSelectionBox.h \
gui/common/GroupChooser.h \
gui/common/StatusDefs.h \ gui/common/StatusDefs.h \
gui/common/TagDefs.h \ gui/common/TagDefs.h \
gui/common/GroupDefs.h \ gui/common/GroupDefs.h \
@ -782,6 +783,7 @@ SOURCES += main.cpp \
gui/common/AvatarDialog.cpp \ gui/common/AvatarDialog.cpp \
gui/common/GroupFlagsWidget.cpp \ gui/common/GroupFlagsWidget.cpp \
gui/common/GroupSelectionBox.cpp \ gui/common/GroupSelectionBox.cpp \
gui/common/GroupChooser.cpp \
gui/common/StatusDefs.cpp \ gui/common/StatusDefs.cpp \
gui/common/TagDefs.cpp \ gui/common/TagDefs.cpp \
gui/common/GroupDefs.cpp \ gui/common/GroupDefs.cpp \