finished cleaning GxsCircle Notifications

This commit is contained in:
csoler 2020-05-02 15:09:32 +02:00
parent 26dd716967
commit 32baccae97
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
8 changed files with 160 additions and 172 deletions

View File

@ -45,25 +45,23 @@ extern RsGxsCircles* rsGxsCircles;
enum class RsGxsCircleType : uint32_t // 32 bit overkill, just for retrocompat enum class RsGxsCircleType : uint32_t // 32 bit overkill, just for retrocompat
{ {
UNKNOWN = 0, /// Used to detect uninizialized values. UNKNOWN = 0, /// Used to detect uninizialized values.
PUBLIC = 1, /// Public distribution PUBLIC = 1, /// Public distribution, based on GxsIds
EXTERNAL = 2, /// Restricted to an external circle EXTERNAL = 2, /// Restricted to an external circle, based on GxsIds
/** Restricted to a group of friend nodes, the administrator of the circle NODES_GROUP = 3, /// Restricted to a group of friend nodes, the administrator of the circle behave as a hub for them
* behave as a hub for them */ /// Based on PGP nodes ids.
NODES_GROUP = 3,
LOCAL = 4, /// not distributed at all LOCAL = 4, /// not distributed at all
/** Self-restricted. Used only at creation time of self-restricted circles /** Self-restricted. Used only at creation time of self-restricted circles
* when the circle id isn't known yet. Once the circle id is known the type * when the circle id isn't known yet. Once the circle id is known the type
* is set to EXTERNAL, and the external circle id is set to the id of the * is set to EXTERNAL, and the external circle id is set to the id of the
* circle itself. * circle itself. Based on GxsIds.
*/ */
EXT_SELF = 5, EXT_SELF = 5,
/// distributed to nodes signed by your own PGP key only. YOUR_EYES_ONLY = 6 /// distributed to nodes signed by your own PGP key only.
YOUR_EYES_ONLY = 6
}; };
// TODO: convert to enum class // TODO: convert to enum class
@ -121,15 +119,29 @@ struct RsGxsCircleMsg : RsSerializable
struct RsGxsCircleDetails : RsSerializable struct RsGxsCircleDetails : RsSerializable
{ {
RsGxsCircleDetails() : RsGxsCircleDetails() : mCircleType(RsGxsCircleType::EXTERNAL), mAmIAllowed(false),mAmIAdmin(false) {}
mCircleType(static_cast<uint32_t>(RsGxsCircleType::EXTERNAL)),
mAmIAllowed(false),mAmIAdmin(false) {}
~RsGxsCircleDetails() override; ~RsGxsCircleDetails() override;
// helper functions.
bool isIdInCircle(const RsGxsId& id) const { return mAllowedGxsIds.find(id) != mAllowedGxsIds.end(); }
bool isIdInInviteeList(const RsGxsId& id) const
{
auto it = mSubscriptionFlags.find(id);
return (it != mSubscriptionFlags.end()) && (it->second & GXS_EXTERNAL_CIRCLE_FLAGS_IN_ADMIN_LIST );
}
bool isIdRequestingMembership(const RsGxsId& id) const
{
auto it = mSubscriptionFlags.find(id);
return it != mSubscriptionFlags.end() && (it->second & GXS_EXTERNAL_CIRCLE_FLAGS_SUBSCRIBED );
}
bool isGxsIdBased() const { return mCircleType==RsGxsCircleType::PUBLIC || mCircleType==RsGxsCircleType::EXTERNAL || mCircleType==RsGxsCircleType::EXT_SELF; }
// Members
RsGxsCircleId mCircleId; RsGxsCircleId mCircleId;
std::string mCircleName; std::string mCircleName;
uint32_t mCircleType; RsGxsCircleType mCircleType;
RsGxsCircleId mRestrictedCircleId; RsGxsCircleId mRestrictedCircleId;
/** true when one of load GXS ids belong to the circle allowed list (admin /** true when one of load GXS ids belong to the circle allowed list (admin
@ -165,39 +177,6 @@ struct RsGxsCircleDetails : RsSerializable
enum class RsGxsCircleEventCode: uint8_t enum class RsGxsCircleEventCode: uint8_t
{ {
// Notications received depending on wether you got a membership request, if you
// are admin of that circle, etc.
//
// Message-based notifications:
//
// +---------------------------+----------------------------+
// | Membership request | Membership cancellation |
// +-------------+-------------+-------------+--------------+
// | Admin | Not admin | Admin | Not admin |
// +--------------------+-------------+-------------+----------------------------+
// | in invitee list | 0x04 | 0x04 | 0x03 | 0x03 |
// +--------------------+-------------+-------------+-------------+--------------+
// |not in invitee list | 0x01 | X | X | X |
// +--------------------+-------------+-------------+-------------+--------------+
//
// Note: in this case, the GxsId never belongs to you, since you dont need to handle
// notifications for actions you took yourself (leave/join a circle)
//
// Group-based notifications, the GxsId belongs to you:
//
// +---------------------------+----------------------------+
// | GxsId joins invitee list | GxsId leaves invitee list |
// +-------------+-------------+-------------+--------------+
// | Id is yours| Id is not | Id is yours | Id is not |
// +--------------------+-------------+-------------+-------------+--------------+
// | Has Member request | 0x06 | 0x04 | 0x05 | 0x03 |
// +--------------------+-------------+-------------+-------------+--------------+
// | No Member request | 0x02 | X | 0x05 | X |
// +--------------------+-------------+-------------+-------------+--------------+
//
// Note: In this case you're never an admin of the circle, since these notification
// would be a direct consequence of your own actions.
// Notifications be only have 4 different possibilities: // Notifications be only have 4 different possibilities:
// //
// invitee list join/leave and // invitee list join/leave and
@ -215,37 +194,37 @@ enum class RsGxsCircleEventCode: uint8_t
* Sent when we receive a membership request msg for a particular circle. * Sent when we receive a membership request msg for a particular circle.
* *
* mCircleId contains the circle id and mGxsId is the id requesting membership */ * mCircleId contains the circle id and mGxsId is the id requesting membership */
CIRCLE_MEMBERSHIP_REQUEST = 0x01, CIRCLE_MEMBERSHIP_REQUEST = 0x01,
/** /**
* Sent when the ID has been added to the circle invitee list. * Sent when the ID has been added to the circle invitee list.
* *
* mCircleId is the circle that invites me, and mGxsId is my own Id that is invited */ * mCircleId is the circle that invites me, and mGxsId is my own Id that is invited */
CIRCLE_MEMBERSHIP_INVITE = 0x02, CIRCLE_MEMBERSHIP_ID_ADDED_TO_INVITEE_LIST = 0x02,
/** /**
* Sent when a GxsId annouces its will to not be in the circle. * Sent when a GxsId annouces its will to not be in the circle.
* *
* mCircleId contains the circle id and mGxsId is the id dropping membership */ * mCircleId contains the circle id and mGxsId is the id dropping membership */
CIRCLE_MEMBERSHIP_LEAVE = 0x03, CIRCLE_MEMBERSHIP_LEAVE = 0x03,
/** /**
* Sent when the Id has been removed from the invitee list. * Sent when the Id has been removed from the invitee list.
* *
* mCircleId contains the circle id and mGxsId is the id that was revoqued * by admin */ * mCircleId contains the circle id and mGxsId is the id that was revoqued * by admin */
CIRCLE_MEMBERSHIP_REVOKED = 0x05, CIRCLE_MEMBERSHIP_ID_REMOVED_FROM_INVITEE_LIST = 0x04,
/** /**
* Means a new circle has been received. * Means a new circle has been received.
* *
* mCircleId contains the circle id */ * mCircleId contains the circle id */
NEW_CIRCLE = 0x07, NEW_CIRCLE = 0x05,
/** /**
* Means that the circle cache has updated, and membership status that is displayed should probably be updated to. * Means that the circle cache has updated, and membership status that is displayed should probably be updated to.
* *
* no additional information. Simply means that the info previously from the cache has changed. */ * no additional information. Simply means that the info previously from the cache has changed. */
CACHE_DATA_UPDATED = 0x08, CACHE_DATA_UPDATED = 0x06,
}; };
struct RsGxsCircleEvent: RsEvent struct RsGxsCircleEvent: RsEvent

View File

@ -115,11 +115,13 @@ const uint32_t RS_FEED_ITEM_CHAT_NEW = RS_FEED_TYPE_CHAT | 0x0001;
const uint32_t RS_FEED_ITEM_MESSAGE = RS_FEED_TYPE_MSG | 0x0001; const uint32_t RS_FEED_ITEM_MESSAGE = RS_FEED_TYPE_MSG | 0x0001;
const uint32_t RS_FEED_ITEM_FILES_NEW = RS_FEED_TYPE_FILES | 0x0001; const uint32_t RS_FEED_ITEM_FILES_NEW = RS_FEED_TYPE_FILES | 0x0001;
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_REQ = RS_FEED_TYPE_CIRCLE | 0x0001; const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_REQ = RS_FEED_TYPE_CIRCLE | 0x0001;
const uint32_t RS_FEED_ITEM_CIRCLE_INVIT_REC = RS_FEED_TYPE_CIRCLE | 0x0002; const uint32_t RS_FEED_ITEM_CIRCLE_INVITE_REC = RS_FEED_TYPE_CIRCLE | 0x0002;
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_LEAVE = RS_FEED_TYPE_CIRCLE | 0x0003; const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_LEAVE = RS_FEED_TYPE_CIRCLE | 0x0003;
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_JOIN = RS_FEED_TYPE_CIRCLE | 0x0004; const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_JOIN = RS_FEED_TYPE_CIRCLE | 0x0004;
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_REVOKED = RS_FEED_TYPE_CIRCLE | 0x0005; const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_ACCEPTED = RS_FEED_TYPE_CIRCLE | 0x0005;
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_REVOKED = RS_FEED_TYPE_CIRCLE | 0x0006;
const uint32_t RS_FEED_ITEM_CIRCLE_INVITE_CANCELLED= RS_FEED_TYPE_CIRCLE | 0x0007;
const uint32_t RS_MESSAGE_CONNECT_ATTEMPT = 0x0001; const uint32_t RS_MESSAGE_CONNECT_ATTEMPT = 0x0001;

View File

@ -566,13 +566,15 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
ev->mGxsId = msg.mMeta.mAuthorId; ev->mGxsId = msg.mMeta.mAuthorId;
if (msg.stuff == "SUBSCRIPTION_REQUEST_UNSUBSCRIBE") if (msg.stuff == "SUBSCRIPTION_REQUEST_UNSUBSCRIBE")
{
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE; ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE;
else if(details.mAllowedGxsIds.find(msg.mMeta.mAuthorId) != details.mAllowedGxsIds.end()) rsEvents->postEvent(ev);
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_JOIN; }
else else if(msg.stuff == "SUBSCRIPTION_REQUEST_SUBSCRIBE")
{
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REQUEST; ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REQUEST;
rsEvents->postEvent(ev);
rsEvents->postEvent(ev); }
} }
mCircleCache.erase(circle_id); mCircleCache.erase(circle_id);
@ -615,13 +617,6 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
if(rsEvents) if(rsEvents)
{ {
std::list<RsGxsId> own_ids_lst;
rsIdentity->getOwnIds(own_ids_lst,false); // retrieve own identities
std::set<RsGxsId> own_ids;
for(auto& id:own_ids_lst)
own_ids.insert(id); // put them in a std::set for O(log(n)) search
if(c->getType() == RsGxsNotify::TYPE_RECEIVED_NEW|| c->getType() == RsGxsNotify::TYPE_PUBLISHED) if(c->getType() == RsGxsNotify::TYPE_RECEIVED_NEW|| c->getType() == RsGxsNotify::TYPE_PUBLISHED)
{ {
auto ev = std::make_shared<RsGxsCircleEvent>(); auto ev = std::make_shared<RsGxsCircleEvent>();
@ -634,17 +629,11 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
RsGxsCircleGroupItem *new_circle_grp_item = dynamic_cast<RsGxsCircleGroupItem*>(groupChange->mNewGroupItem); RsGxsCircleGroupItem *new_circle_grp_item = dynamic_cast<RsGxsCircleGroupItem*>(groupChange->mNewGroupItem);
std::list<RsGxsId> added_identities;
for(auto& gxs_id: new_circle_grp_item->gxsIdSet.ids) for(auto& gxs_id: new_circle_grp_item->gxsIdSet.ids)
if(own_ids.find(gxs_id)!=own_ids.end())
added_identities.push_back(gxs_id);
for(auto& gxs_id:added_identities)
{ {
auto ev = std::make_shared<RsGxsCircleEvent>(); auto ev = std::make_shared<RsGxsCircleEvent>();
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_INVITE; ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_ID_ADDED_TO_INVITEE_LIST;
ev->mCircleId = RsGxsCircleId(*git); ev->mCircleId = RsGxsCircleId(*git);
ev->mGxsId = gxs_id; ev->mGxsId = gxs_id;
@ -669,36 +658,29 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
// First of all, we check if there is a difference between the old and new list of invited members // First of all, we check if there is a difference between the old and new list of invited members
std::list<RsGxsId> added_identities, removed_identities;
for(auto& gxs_id: new_circle_grp_item->gxsIdSet.ids) for(auto& gxs_id: new_circle_grp_item->gxsIdSet.ids)
if(old_circle_grp_item->gxsIdSet.ids.find(gxs_id) == old_circle_grp_item->gxsIdSet.ids.end() && own_ids.find(gxs_id)!=own_ids.end()) if(old_circle_grp_item->gxsIdSet.ids.find(gxs_id) == old_circle_grp_item->gxsIdSet.ids.end())
added_identities.push_back(gxs_id); {
auto ev = std::make_shared<RsGxsCircleEvent>();
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_ID_ADDED_TO_INVITEE_LIST;
ev->mCircleId = circle_id;
ev->mGxsId = gxs_id;
rsEvents->sendEvent(ev);
}
for(auto& gxs_id: old_circle_grp_item->gxsIdSet.ids) for(auto& gxs_id: old_circle_grp_item->gxsIdSet.ids)
if(new_circle_grp_item->gxsIdSet.ids.find(gxs_id) == old_circle_grp_item->gxsIdSet.ids.end() && own_ids.find(gxs_id)!=own_ids.end()) if(new_circle_grp_item->gxsIdSet.ids.find(gxs_id) == old_circle_grp_item->gxsIdSet.ids.end())
removed_identities.push_back(gxs_id); {
auto ev = std::make_shared<RsGxsCircleEvent>();
for(auto& gxs_id:added_identities) ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_ID_REMOVED_FROM_INVITEE_LIST;
{ ev->mCircleId = circle_id;
auto ev = std::make_shared<RsGxsCircleEvent>(); ev->mGxsId = gxs_id;
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_INVITE; rsEvents->sendEvent(ev);
ev->mCircleId = circle_id; }
ev->mGxsId = gxs_id;
rsEvents->sendEvent(ev);
}
for(auto& gxs_id:removed_identities)
{
auto ev = std::make_shared<RsGxsCircleEvent>();
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REVOKED;
ev->mCircleId = circle_id;
ev->mGxsId = gxs_id;
rsEvents->sendEvent(ev);
}
} }
@ -720,8 +702,7 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
/******************* RsCircles Interface ***************************************/ /******************* RsCircles Interface ***************************************/
/********************************************************************************/ /********************************************************************************/
bool p3GxsCircles::getCircleDetails( bool p3GxsCircles::getCircleDetails(const RsGxsCircleId& id, RsGxsCircleDetails& details)
const RsGxsCircleId& id, RsGxsCircleDetails& details)
{ {
#ifdef DEBUG_CIRCLES #ifdef DEBUG_CIRCLES
@ -818,7 +799,7 @@ int p3GxsCircles::canSend(const RsGxsCircleId &circleId, const RsPgpId &id, bool
if (mCircleCache.is_cached(circleId)) if (mCircleCache.is_cached(circleId))
{ {
RsGxsCircleCache &data = mCircleCache.ref(circleId); RsGxsCircleCache &data = mCircleCache.ref(circleId);
should_encrypt = (data.mCircleType == GXS_CIRCLE_TYPE_EXTERNAL); should_encrypt = (data.mCircleType == RsGxsCircleType::EXTERNAL);
if (data.isAllowedPeer(id)) if (data.isAllowedPeer(id))
return 1; return 1;
@ -1051,7 +1032,7 @@ RsGenExchange::ServiceCreate_Return p3GxsCircles::service_CreateGroup(RsGxsGrpIt
RsGxsCircleCache::RsGxsCircleCache() RsGxsCircleCache::RsGxsCircleCache()
{ {
mCircleType = GXS_CIRCLE_TYPE_EXTERNAL; mCircleType = RsGxsCircleType::EXTERNAL;
mIsExternal = true; mIsExternal = true;
mUpdateTime = 0; mUpdateTime = 0;
mGroupStatus = 0; mGroupStatus = 0;
@ -1070,8 +1051,8 @@ bool RsGxsCircleCache::loadBaseCircle(const RsGxsCircleGroup &circle)
mUpdateTime = time(NULL); mUpdateTime = time(NULL);
// mProcessedCircles.insert(mCircleId); // mProcessedCircles.insert(mCircleId);
mCircleType = circle.mMeta.mCircleType; mCircleType = static_cast<RsGxsCircleType>(circle.mMeta.mCircleType);
mIsExternal = (mCircleType != GXS_CIRCLE_TYPE_LOCAL); mIsExternal = (mCircleType != RsGxsCircleType::LOCAL);
mGroupStatus = circle.mMeta.mGroupStatus; mGroupStatus = circle.mMeta.mGroupStatus;
mGroupSubscribeFlags = circle.mMeta.mSubscribeFlags; mGroupSubscribeFlags = circle.mMeta.mSubscribeFlags;
mOriginator = circle.mMeta.mOriginator ; mOriginator = circle.mMeta.mOriginator ;

View File

@ -145,7 +145,7 @@ class RsGxsCircleCache
RsGxsCircleId mCircleId; RsGxsCircleId mCircleId;
std::string mCircleName; std::string mCircleName;
uint32_t mCircleType; RsGxsCircleType mCircleType;
bool mIsExternal; bool mIsExternal;
RsGxsCircleId mRestrictedCircleId ; // circle ID that circle is restricted to. RsGxsCircleId mRestrictedCircleId ; // circle ID that circle is restricted to.

View File

@ -433,12 +433,11 @@ void IdDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
switch(e->mCircleEventType) switch(e->mCircleEventType)
{ {
case RsGxsCircleEventCode::NEW_CIRCLE:
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REQUEST: case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REQUEST:
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_INVITE: case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_ID_ADDED_TO_INVITEE_LIST:
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE: case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE:
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_JOIN: case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_ID_REMOVED_FROM_INVITEE_LIST:
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REVOKED: case RsGxsCircleEventCode::NEW_CIRCLE:
case RsGxsCircleEventCode::CACHE_DATA_UPDATED: case RsGxsCircleEventCode::CACHE_DATA_UPDATED:
updateCircles(); updateCircles();

View File

@ -309,10 +309,12 @@ void NewsFeed::handleCircleEvent(std::shared_ptr<const RsEvent> event)
return; return;
} }
// Check if the circle is one of which we belong to. If so, then notify in the GUI about other members leaving/subscribing if(!details.isGxsIdBased()) // not handled yet.
return;
// Notications received depending on wether you got a membership request, if you // Check if the circle is one of which we belong to or we are an admin of.
// are admin of that circle, etc. // If so, then notify in the GUI about other members leaving/subscribing, according
// to the following rules. The names correspond to the RS_FEED_CIRCLE_* variables:
// //
// Message-based notifications: // Message-based notifications:
// //
@ -321,57 +323,67 @@ void NewsFeed::handleCircleEvent(std::shared_ptr<const RsEvent> event)
// +-------------+-------------+-------------+--------------+ // +-------------+-------------+-------------+--------------+
// | Admin | Not admin | Admin | Not admin | // | Admin | Not admin | Admin | Not admin |
// +--------------------+-------------+-------------+----------------------------+ // +--------------------+-------------+-------------+----------------------------+
// | in invitee list | 0x04 | 0x04 | 0x03 | 0x03 | // | in invitee list | MEMB_JOIN | MEMB_JOIN | MEMB_LEAVE | MEMB_LEAVE |
// +--------------------+-------------+-------------+-------------+--------------+ // +--------------------+-------------+-------------+-------------+--------------+
// |not in invitee list | 0x01 | X | X | X | // |not in invitee list | MEMB_REQ | X | X | X |
// +--------------------+-------------+-------------+-------------+--------------+ // +--------------------+-------------+-------------+-------------+--------------+
// //
// Note: in this case, the GxsId never belongs to you, since you dont need to handle // Note: in this case, the GxsId never belongs to you, since you dont need to handle
// notifications for actions you took yourself (leave/join a circle) // notifications for actions you took yourself (leave/join a circle)
// //
// Group-based notifications, the GxsId belongs to you: // GroupData-based notifications, the GxsId belongs to you:
// //
// +---------------------------+----------------------------+ // +---------------------------+----------------------------+
// | GxsId joins invitee list | GxsId leaves invitee list | // | GxsId joins invitee list | GxsId leaves invitee list |
// +-------------+-------------+-------------+--------------+ // +-------------+-------------+-------------+--------------+
// | Id is yours| Id is not | Id is yours | Id is not | // | Id is yours| Id is not | Id is yours | Id is not |
// +--------------------+-------------+-------------+-------------+--------------+ // +--------------------+-------------+-------------+-------------+--------------+
// | Has Member request | 0x06 | 0x04 | 0x05 | 0x03 | // | Has Member request | MEMB_ACCEPT | (MEMB_JOIN) | MEMB_REVOKED| (MEMB_LEAVE) |
// +--------------------+-------------+-------------+-------------+--------------+ // +--------------------+-------------+-------------+-------------+--------------+
// | No Member request | 0x02 | X | 0x05 | X | // | No Member request | INVITE_REC | X | INVITE_REM | X |
// +--------------------+-------------+-------------+-------------+--------------+ // +--------------------+-------------+-------------+-------------+--------------+
// //
// Note: In this case you're never an admin of the circle, since these notification // Note: In this case you're never an admin of the circle, since these notification
// would be a direct consequence of your own actions. // would be a direct consequence of your own actions.
if(details.mAmIAllowed || details.mAmIAdmin) switch(pe->mCircleEventType)
{ {
switch(pe->mCircleEventType) case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REQUEST:
{ // only show membership requests if we're an admin of that circle
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REQUEST: if(details.isIdInInviteeList(pe->mGxsId))
// only show membership requests if we're an admin of that circle
if(details.mAmIAdmin)
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_REQ),true);
break;
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_JOIN:
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_JOIN),true); addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_JOIN),true);
break; else if(details.mAmIAdmin)
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_REQ),true);
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE: break;
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE:
if(details.isIdInInviteeList(pe->mGxsId))
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_LEAVE),true); addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_LEAVE),true);
break; break;
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_INVITE: case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_ID_ADDED_TO_INVITEE_LIST:
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_INVIT_REC),true); if(rsIdentity->isOwnId(pe->mGxsId))
break; {
if(details.isIdRequestingMembership(pe->mGxsId))
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_ACCEPTED),true);
else
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_INVITE_REC),true);
}
break;
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REVOKED: case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_ID_REMOVED_FROM_INVITEE_LIST:
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_REVOKED),true); if(rsIdentity->isOwnId(pe->mGxsId))
break; {
if(details.isIdRequestingMembership(pe->mGxsId))
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_REVOKED),true);
else
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_INVITE_CANCELLED),true);
}
break;
default: break; default: break;
}
} }
} }

View File

@ -287,9 +287,11 @@ void PeopleDialog::insertCircles(uint32_t token)
continue ; continue ;
}//if(!rsGxsCircles->getCircleDetails(RsGxsCircleId(git->mGroupId), details)) }//if(!rsGxsCircles->getCircleDetails(RsGxsCircleId(git->mGroupId), details))
if (details.mCircleType != GXS_CIRCLE_TYPE_EXTERNAL){ if (details.mCircleType != RsGxsCircleType::EXTERNAL)
{
std::map<RsGxsGroupId, CircleWidget*>::iterator itFound; std::map<RsGxsGroupId, CircleWidget*>::iterator itFound;
if((itFound=_int_circles_widgets.find(gsItem.mGroupId)) == _int_circles_widgets.end()) { if((itFound=_int_circles_widgets.find(gsItem.mGroupId)) == _int_circles_widgets.end())
{
std::cerr << "PeopleDialog::insertExtCircles() add new Internal GroupId: " << gsItem.mGroupId; std::cerr << "PeopleDialog::insertExtCircles() add new Internal GroupId: " << gsItem.mGroupId;
std::cerr << " GroupName: " << gsItem.mGroupName; std::cerr << " GroupName: " << gsItem.mGroupName;
std::cerr << std::endl; std::cerr << std::endl;
@ -307,7 +309,9 @@ void PeopleDialog::insertCircles(uint32_t token)
QPixmap pixmap = gitem->getImage(); QPixmap pixmap = gitem->getImage();
pictureFlowWidgetInternal->addSlide( pixmap ); pictureFlowWidgetInternal->addSlide( pixmap );
_intListCir << gitem; _intListCir << gitem;
} else {//if((itFound=_int_circles_widgets.find(gsItem.mGroupId)) == _int_circles_widgets.end()) }
else
{
std::cerr << "PeopleDialog::insertExtCircles() Update GroupId: " << gsItem.mGroupId; std::cerr << "PeopleDialog::insertExtCircles() Update GroupId: " << gsItem.mGroupId;
std::cerr << " GroupName: " << gsItem.mGroupName; std::cerr << " GroupName: " << gsItem.mGroupName;
std::cerr << std::endl; std::cerr << std::endl;
@ -318,8 +322,10 @@ void PeopleDialog::insertCircles(uint32_t token)
//int index = _intListCir.indexOf(cirWidget); //int index = _intListCir.indexOf(cirWidget);
//QPixmap pixmap = cirWidget->getImage(); //QPixmap pixmap = cirWidget->getImage();
//pictureFlowWidgetInternal->setSlide(index, pixmap); //pictureFlowWidgetInternal->setSlide(index, pixmap);
}//if((item=_int_circles_widgets.find(gsItem.mGroupId)) == _int_circles_widgets.end()) }
} else {//if (!details.mIsExternal) }
else
{
std::map<RsGxsGroupId, CircleWidget*>::iterator itFound; std::map<RsGxsGroupId, CircleWidget*>::iterator itFound;
if((itFound=_ext_circles_widgets.find(gsItem.mGroupId)) == _ext_circles_widgets.end()) { if((itFound=_ext_circles_widgets.find(gsItem.mGroupId)) == _ext_circles_widgets.end()) {
std::cerr << "PeopleDialog::insertExtCircles() add new GroupId: " << gsItem.mGroupId; std::cerr << "PeopleDialog::insertExtCircles() add new GroupId: " << gsItem.mGroupId;
@ -339,7 +345,9 @@ void PeopleDialog::insertCircles(uint32_t token)
QPixmap pixmap = gitem->getImage(); QPixmap pixmap = gitem->getImage();
pictureFlowWidgetExternal->addSlide( pixmap ); pictureFlowWidgetExternal->addSlide( pixmap );
_extListCir << gitem; _extListCir << gitem;
} else {//if((itFound=_circles_widgets.find(gsItem.mGroupId)) == _circles_widgets.end()) }
else
{
std::cerr << "PeopleDialog::insertExtCircles() Update GroupId: " << gsItem.mGroupId; std::cerr << "PeopleDialog::insertExtCircles() Update GroupId: " << gsItem.mGroupId;
std::cerr << " GroupName: " << gsItem.mGroupName; std::cerr << " GroupName: " << gsItem.mGroupName;
std::cerr << std::endl; std::cerr << std::endl;
@ -350,9 +358,9 @@ void PeopleDialog::insertCircles(uint32_t token)
//int index = _extListCir.indexOf(cirWidget); //int index = _extListCir.indexOf(cirWidget);
//QPixmap pixmap = cirWidget->getImage(); //QPixmap pixmap = cirWidget->getImage();
//pictureFlowWidgetExternal->setSlide(index, pixmap); //pictureFlowWidgetExternal->setSlide(index, pixmap);
}//if((item=_circles_items.find(gsItem.mGroupId)) == _circles_items.end()) }
}//else (!details.mIsExternal) }
}//for(gsIt = gSummaryList.begin(); gsIt != gSummaryList.end(); ++gsIt) }
} }
void PeopleDialog::requestIdList() void PeopleDialog::requestIdList()

View File

@ -77,34 +77,31 @@ void GxsCircleItem::setup()
/* update circle information */ /* update circle information */
ui->acceptButton->setToolTip(tr("Grant membership request"));
ui->revokeButton->setToolTip(tr("Revoke membership request"));
connect(ui->acceptButton, SIGNAL(clicked()), this, SLOT(grantCircleMembership()));
connect(ui->revokeButton, SIGNAL(clicked()), this, SLOT(revokeCircleMembership()));
RsGxsCircleDetails circleDetails; RsGxsCircleDetails circleDetails;
if (rsGxsCircles->getCircleDetails(mCircleId, circleDetails)) if (rsGxsCircles->getCircleDetails(mCircleId, circleDetails))
{ {
// from here we can figure out if we already have requested membership or not
if (mType == RS_FEED_ITEM_CIRCLE_MEMB_REQ) if (mType == RS_FEED_ITEM_CIRCLE_MEMB_REQ)
{ {
ui->titleLabel->setText(tr("You received a membership request for circle:")); ui->titleLabel->setText(tr("You received a membership request a circle you're administrating:"));
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str())); ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
ui->gxsIdLabel->setText(idName); ui->gxsIdLabel->setText(idName);
ui->iconLabel->setPixmap(pixmap); ui->iconLabel->setPixmap(pixmap);
ui->gxsIdLabel->setId(mGxsId); ui->gxsIdLabel->setId(mGxsId);
if(circleDetails.mAmIAdmin) ui->revokeButton->setHidden(true);
{ ui->acceptButton->setHidden(false);
ui->acceptButton->setToolTip(tr("Grant membership request"));
ui->revokeButton->setToolTip(tr("Revoke membership request"));
connect(ui->acceptButton, SIGNAL(clicked()), this, SLOT(grantCircleMembership()));
connect(ui->revokeButton, SIGNAL(clicked()), this, SLOT(revokeCircleMembership()));
}
else
{
ui->acceptButton->setEnabled(false);
ui->revokeButton->setEnabled(false);
}
} }
else if (mType == RS_FEED_ITEM_CIRCLE_INVIT_REC) else if (mType == RS_FEED_ITEM_CIRCLE_INVITE_REC)
{ {
ui->titleLabel->setText(tr("You received an invitation for circle:")); ui->titleLabel->setText(tr("You received an invitation for this circle:"));
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str())); ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
ui->gxsIdLabel->setText(idName); ui->gxsIdLabel->setText(idName);
ui->iconLabel->setPixmap(pixmap); ui->iconLabel->setPixmap(pixmap);
@ -116,7 +113,7 @@ void GxsCircleItem::setup()
} }
else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_LEAVE) else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_LEAVE)
{ {
ui->titleLabel->setText(idName + tr(" has left this circle you belong to.")); ui->titleLabel->setText(idName + tr(" has left this circle."));
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str())); ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
ui->gxsIdLabel->setText(idName); ui->gxsIdLabel->setText(idName);
ui->iconLabel->setPixmap(pixmap); ui->iconLabel->setPixmap(pixmap);
@ -127,21 +124,18 @@ void GxsCircleItem::setup()
} }
else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_JOIN) else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_JOIN)
{ {
ui->titleLabel->setText(idName + tr(" has join this circle you also belong to.")); ui->titleLabel->setText(idName + tr(" which you invited, has join this circle you're administrating."));
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str())); ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
ui->gxsIdLabel->setText(idName); ui->gxsIdLabel->setText(idName);
ui->iconLabel->setPixmap(pixmap); ui->iconLabel->setPixmap(pixmap);
ui->gxsIdLabel->setId(mGxsId); ui->gxsIdLabel->setId(mGxsId);
ui->acceptButton->setHidden(true); ui->acceptButton->setHidden(true);
ui->revokeButton->setHidden(true); ui->revokeButton->setHidden(false);
} }
else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_REVOKED) else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_REVOKED)
{ {
if(rsIdentity->isOwnId(mGxsId)) ui->titleLabel->setText(tr("Your identity %1 has been revoked from this circle.").arg(idName));
ui->titleLabel->setText(tr("Your identity %1 has been revoqued from this circle.").arg(idName));
else
ui->titleLabel->setText(tr("Identity %1 has been revoqued from this circle you belong to.").arg(idName));
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str())); ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
ui->gxsIdLabel->setText(idName); ui->gxsIdLabel->setText(idName);
@ -151,6 +145,19 @@ void GxsCircleItem::setup()
ui->acceptButton->setHidden(true); ui->acceptButton->setHidden(true);
ui->revokeButton->setHidden(true); ui->revokeButton->setHidden(true);
} }
else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_ACCEPTED)
{
ui->titleLabel->setText(tr("Your identity %1 as been accepted in this circle.").arg(idName));
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
ui->gxsIdLabel->setText(idName);
ui->iconLabel->setPixmap(pixmap);
ui->gxsIdLabel->setId(mGxsId);
ui->acceptButton->setHidden(true);
ui->revokeButton->setHidden(true);
}
} }
else else
{ {