mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-06 08:05:18 -04:00
added notifications for identities
This commit is contained in:
parent
90bb6c0011
commit
424e7be52f
7 changed files with 92 additions and 52 deletions
|
@ -85,6 +85,9 @@ enum class RsEventType : uint32_t
|
|||
/// @see RsGxsPostedEvent
|
||||
GXS_POSTED = 11,
|
||||
|
||||
/// @see RsGxsPostedEvent
|
||||
GXS_IDENTITY = 12,
|
||||
|
||||
MAX /// Used to detect invalid event type passed
|
||||
};
|
||||
|
||||
|
|
|
@ -304,6 +304,32 @@ private:
|
|||
RsIdentityUsage();
|
||||
};
|
||||
|
||||
enum class RsGxsIdentityEventCode: uint8_t
|
||||
{
|
||||
UNKNOWN = 0x00,
|
||||
NEW_IDENTITY = 0x01,
|
||||
DELETED_IDENTITY = 0x02,
|
||||
};
|
||||
|
||||
struct RsGxsIdentityEvent: public RsEvent
|
||||
{
|
||||
RsGxsIdentityEvent()
|
||||
: RsEvent(RsEventType::GXS_IDENTITY),
|
||||
mIdentityEventCode(RsGxsIdentityEventCode::UNKNOWN) {}
|
||||
|
||||
RsGxsIdentityEventCode mIdentityEventCode;
|
||||
RsGxsGroupId mIdentityId;
|
||||
|
||||
///* @see RsEvent @see RsSerializable
|
||||
void serial_process( RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext& ctx ) override
|
||||
{
|
||||
RsEvent::serial_process(j, ctx);
|
||||
RS_SERIAL_PROCESS(mIdentityEventCode);
|
||||
RS_SERIAL_PROCESS(mIdentityId);
|
||||
}
|
||||
|
||||
~RsGxsIdentityEvent() override = default;
|
||||
};
|
||||
|
||||
struct RsIdentityDetails : RsSerializable
|
||||
{
|
||||
|
|
|
@ -603,7 +603,6 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
|
||||
for(uint32_t i = 0;i<changes.size();++i)
|
||||
{
|
||||
RsGxsGroupChange *groupChange = dynamic_cast<RsGxsGroupChange *>(changes[i]);
|
||||
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(changes[i]);
|
||||
|
||||
if (msgChange && !msgChange->metaChange())
|
||||
|
@ -614,8 +613,8 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
#endif
|
||||
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> >::iterator mit;
|
||||
for(mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
|
||||
for(auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
std::cerr << "p3IdService::notifyChanges() Msgs for Group: " << mit->first;
|
||||
|
@ -624,7 +623,8 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
}
|
||||
}
|
||||
|
||||
/* shouldn't need to worry about groups - as they need to be subscribed to */
|
||||
RsGxsGroupChange *groupChange = dynamic_cast<RsGxsGroupChange *>(changes[i]);
|
||||
|
||||
if (groupChange && !groupChange->metaChange())
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
|
@ -632,9 +632,8 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
std::list<RsGxsGroupId> &groupList = groupChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
|
||||
for(git = groupList.begin(); git != groupList.end();)
|
||||
for(auto git = groupList.begin(); git != groupList.end();++git)
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
std::cerr << "p3IdService::notifyChanges() Auto Subscribe to Incoming Groups: " << *git;
|
||||
|
@ -649,16 +648,24 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
|
||||
timeStampKey(RsGxsId(*git),RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_DATA_UPDATE)) ;
|
||||
|
||||
++git;
|
||||
}
|
||||
else
|
||||
git = groupList.erase(git) ;
|
||||
}
|
||||
// notify that a new identity is received, if needed
|
||||
|
||||
if(groupList.empty())
|
||||
{
|
||||
delete changes[i] ;
|
||||
changes[i] = NULL ;
|
||||
switch(groupChange->getType())
|
||||
{
|
||||
case RsGxsNotify::TYPE_PUBLISHED:
|
||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsIdentityEvent>();
|
||||
ev->mIdentityId = *git;
|
||||
ev->mIdentityEventCode = RsGxsIdentityEventCode::NEW_IDENTITY;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1070,6 +1077,14 @@ bool p3IdService::deleteIdentity(RsGxsId& id)
|
|||
return false;
|
||||
}
|
||||
|
||||
if(rsEvents)
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsIdentityEvent>();
|
||||
ev->mIdentityId = grouId;
|
||||
ev->mIdentityEventCode = RsGxsIdentityEventCode::DELETED_IDENTITY;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue