patch from electron with bugfixes for v0.6-rssocialnet branch, circles: don t add a new circle id to the list twice, identities: add new id to list of own ids immediately for faster feedback to the user

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-rssocialnet@7488 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-08-08 15:46:39 +00:00
parent b8d81e4af9
commit cb6e9c5694
5 changed files with 99 additions and 42 deletions

View File

@ -130,9 +130,11 @@ virtual bool getCirclePersonalIdList(std::list<RsGxsCircleId> &circleIds) = 0;
/* standard load */
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsCircleGroup> &groups) = 0;
/* make new group */
virtual bool createGroup(uint32_t& token, RsGxsCircleGroup &group) = 0;
/* make new group */
virtual void createGroup(uint32_t& token, RsGxsCircleGroup &group) = 0;
/* update an existing group */
virtual void updateGroup(uint32_t &token, RsGxsCircleGroup &group) = 0;
};

View File

@ -287,8 +287,9 @@ class RsPeers
virtual ~RsPeers() { return; }
/* Updates ... */
virtual bool FriendsChanged() = 0;
virtual bool OthersChanged() = 0;
// not implemented
//virtual bool FriendsChanged() = 0;
//virtual bool OthersChanged() = 0;
/* Peer Details (Net & Auth) */
virtual const RsPeerId& getOwnId() = 0;

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

@ -2288,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;
}