Merge of branch v0.6-rssocialnet 7419 to 7488. Changes from electron and myself:

- added possibility to modify groups (e.g. edit circles)
- fixed mismatched free/delete in fimonitor.cc, authssl.cc, pqibin.cc (saving encrypted hash cache file)
- improved plugin interface class to allow plugins to access GXS objects.
- added method to un-register notify clients from RsNotify
- fixed pqisslproxy for windows, due to win not properly supporting sockets in non blocking mode.
- removed static members form RsInitConfig and made RsAccounts object a pointer. This prevents plugin initialisation problems at symbol resolving time.
- removed bool return from p3IdService::getOwnIds()



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7492 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-08-25 21:07:07 +00:00
parent 906efa6f6c
commit f6db432c74
24 changed files with 525 additions and 322 deletions

View file

@ -220,9 +220,15 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
#endif
// for new circles we need to add them to the list.
RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/
RsGxsCircleId tempId(git->toStdString());
mCircleExternalIdList.push_back(tempId);
// we don't know the type of this circle here
// original behavior was to add all ids to the external ids list
addCircleIdToList(RsGxsCircleId(*git), 0);
// reset the cached circle data for this id
{
RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/
mCircleCache.erase(RsGxsCircleId(*git));
}
}
}
}
@ -419,7 +425,7 @@ bool p3GxsCircles::getGroupData(const uint32_t &token, std::vector<RsGxsCircleGr
/********************************************************************************/
/********************************************************************************/
bool p3GxsCircles::createGroup(uint32_t& token, RsGxsCircleGroup &group)
void p3GxsCircles::createGroup(uint32_t& token, RsGxsCircleGroup &group)
{
#ifdef DEBUG_CIRCLES
std::cerr << "p3GxsCircles::createGroup()";
@ -432,7 +438,15 @@ bool p3GxsCircles::createGroup(uint32_t& token, RsGxsCircleGroup &group)
item->convertFrom(group);
RsGenExchange::publishGroup(token, item);
return true;
}
void p3GxsCircles::updateGroup(uint32_t &token, RsGxsCircleGroup &group)
{
// note: refresh of circle cache gets triggered in the RsGenExchange::notifyChanges() callback
RsGxsCircleGroupItem* item = new RsGxsCircleGroupItem();
item->convertFrom(group);
RsGenExchange::updateGroup(token, item);
}
RsGenExchange::ServiceCreate_Return p3GxsCircles::service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& /*keySet*/)
@ -457,18 +471,9 @@ RsGenExchange::ServiceCreate_Return p3GxsCircles::service_CreateGroup(RsGxsGrpIt
item->meta.mCircleId = RsGxsCircleId(item->meta.mGroupId);
}
{
RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/
if (item->meta.mCircleType == GXS_CIRCLE_TYPE_LOCAL)
{
mCirclePersonalIdList.push_back(RsGxsCircleId(item->meta.mGroupId.toStdString()));
}
else
{
mCircleExternalIdList.push_back(RsGxsCircleId(item->meta.mGroupId.toStdString()));
}
}
// the advantage of adding the id to the list now is, that we know the cirlce type at this point
// this is not the case in NotifyChanges()
addCircleIdToList(RsGxsCircleId(item->meta.mGroupId), item->meta.mCircleType);
return SERVICE_CREATE_SUCCESS;
}
@ -596,29 +601,21 @@ bool p3GxsCircles::load_CircleIdList(uint32_t token)
std::cerr << std::endl;
#endif // DEBUG_CIRCLES
std::list<RsGroupMetaData> groups;
bool ok = RsGenExchange::getGroupMeta(token, groups);
std::list<RsGroupMetaData> groups;
bool ok = RsGenExchange::getGroupMeta(token, groups);
if(ok)
{
// Save List
std::list<RsGroupMetaData>::iterator it;
RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/
{
RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/
mCirclePersonalIdList.clear();
mCircleExternalIdList.clear();
}
mCirclePersonalIdList.clear();
mCircleExternalIdList.clear();
for(it = groups.begin(); it != groups.end(); it++)
for(std::list<RsGroupMetaData>::iterator it = groups.begin(); it != groups.end(); it++)
{
RsGxsCircleId tempId(it->mGroupId.toStdString());
if (it->mCircleType == GXS_CIRCLE_TYPE_LOCAL)
{
mCirclePersonalIdList.push_back(tempId);
}
else
{
mCircleExternalIdList.push_back(tempId);
}
addCircleIdToList(RsGxsCircleId(it->mGroupId), it->mCircleType);
}
}
else
@ -1261,6 +1258,24 @@ bool p3GxsCircles::checkCircleCacheForAutoSubscribe(RsGxsCircleCache &cache)
return false;
}
void p3GxsCircles::addCircleIdToList(const RsGxsCircleId &circleId, uint32_t circleType)
{
RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/
if (circleType == GXS_CIRCLE_TYPE_LOCAL)
{
if(mCirclePersonalIdList.end() == std::find(mCirclePersonalIdList.begin(), mCirclePersonalIdList.end(), circleId)){
mCirclePersonalIdList.push_back(circleId);
}
}
else
{
if(mCircleExternalIdList.end() == std::find(mCircleExternalIdList.begin(), mCircleExternalIdList.end(), circleId)){
mCircleExternalIdList.push_back(circleId);
}
}
}
#ifdef HANDLE_SUBCIRCLES

View file

@ -40,6 +40,35 @@
#include <map>
#include <string>
// TODO:
// can now edit circles. this leads to the following situation:
// if someone gets removed from a self.retricted circle, he won't notice
// because he can't receive the updated circle group if he is not part of the group anymore
//
// idea 1: refresh circle groups for example every week
// if a circle was not refreshed since two weeks we can assume we where deleted
// pro: does not leak info, simple to implement, does work even if the network topology changed (unfriending)
// con: delay until we know about the deletion
//
// idea 2: add a field with deleted members to the circle group
// then circle members can tell deleted circle members that they where deleted
// pro: faster notification about deletion
// con: more complicated, leaks info because the deleted member learns who is still a member
// question: how to authenticate the deletion message?
//
// idea 3: make a two phase deletion process
// first add members to a to-delete list
// then wait a week to let the changes propagate
// then remove from allowed peers list
// pro: easy to implement
// con: deletion process is slow
// improvement idea: let only circle groups sync when the member is on he to-delete list
// but don't allow sync of data from other services
// this requires that the netservice knows that he is dealing with a circle group
//
// fact: have to use a timeout mechanism.
// a timeout is the only thing which works even with a two months old backup
/*
* Circles Identity Service
*
@ -152,7 +181,8 @@ virtual RsServiceInfo getServiceInfo();
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsCircleGroup> &groups);
virtual bool createGroup(uint32_t& token, RsGxsCircleGroup &group);
virtual void createGroup(uint32_t& token, RsGxsCircleGroup &group);
virtual void updateGroup(uint32_t &token, RsGxsCircleGroup &group);
/**********************************************/
@ -198,6 +228,11 @@ virtual RsServiceInfo getServiceInfo();
p3IdService *mIdentities; // Needed for constructing Circle Info,
PgpAuxUtils *mPgpUtils;
// put a circle id into the external or personal circle id list
// this function locks the mutex
// if the id is already in the list, it will not be added again
void addCircleIdToList(const RsGxsCircleId& circleId, uint32_t circleType);
RsMutex mCircleMtx; /* Locked Below Here */
std::list<RsGxsCircleId> mCircleExternalIdList;

View file

@ -311,12 +311,10 @@ bool p3IdService:: getIdDetails(const RsGxsId &id, RsIdentityDetails &details)
}
bool p3IdService:: getOwnIds(std::list<RsGxsId> &ownIds)
void p3IdService::getOwnIds(std::list<RsGxsId> &ownIds)
{
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
ownIds = mOwnIds;
return true;
}
@ -2290,9 +2288,13 @@ RsGenExchange::ServiceCreate_Return p3IdService::service_CreateGroup(RsGxsGrpIte
// copy meta data to be sure its all the same.
//item->group.mMeta = item->meta;
// Reload in a little bit.
// HACK to get it to work.
RsTickEvent::schedule_in(GXSID_EVENT_CACHEOWNIDS, OWNID_RELOAD_DELAY);
// do it like p3gxscircles: save the new grp id
// this allows the user interface
// to see the grp id on the list of ownIds immediately after the group was created
{
RsStackMutex stack(mIdMtx);
mOwnIds.push_back(RsGxsId(item->meta.mGroupId));
}
return createStatus;
}

View file

@ -257,7 +257,7 @@ virtual bool deleteGroup(uint32_t& token, RsGxsIdGroup &group);
//virtual bool getNickname(const RsGxsId &id, std::string &nickname);
virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details);
virtual bool getOwnIds(std::list<RsGxsId> &ownIds);
virtual void getOwnIds(std::list<RsGxsId> &ownIds);