mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-03 14:45:12 -04:00
created a specific GxsEvent for Group Statistics changes and handle it in the GUI for all friends at once every 2 min at most
This commit is contained in:
parent
b7363b4d4e
commit
f74c65fcc0
13 changed files with 126 additions and 19 deletions
|
@ -1692,7 +1692,7 @@ void RsGenExchange::notifyChangedGroupStats(const RsGxsGroupId &grpId)
|
|||
{
|
||||
RS_STACK_MUTEX(mGenMtx);
|
||||
|
||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PROCESSED, false);
|
||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_STATISTICS_CHANGED, false);
|
||||
gc->mGrpIdList.push_back(grpId);
|
||||
mNotifications.push_back(gc);
|
||||
}
|
||||
|
|
|
@ -111,6 +111,7 @@ enum class RsChannelEventCode: uint8_t
|
|||
SUBSCRIBE_STATUS_CHANGED = 0x06, // subscription for channel mChannelGroupId changed.
|
||||
READ_STATUS_CHANGED = 0x07, // existing message has been read or set to unread
|
||||
RECEIVED_DISTANT_SEARCH_RESULT = 0x08, // result for the given group id available for the given turtle request id
|
||||
STATISTICS_CHANGED = 0x09, // stats (nb of supplier friends, how many msgs they have etc) has changed
|
||||
};
|
||||
|
||||
struct RsGxsChannelEvent: RsEvent
|
||||
|
|
|
@ -111,6 +111,7 @@ enum class RsForumEventCode: uint8_t
|
|||
UPDATED_MESSAGE = 0x04, /// existing message has been updated in a particular forum
|
||||
SUBSCRIBE_STATUS_CHANGED = 0x05, /// forum was subscribed or unsubscribed
|
||||
READ_STATUS_CHANGED = 0x06, /// msg was read or marked unread
|
||||
STATISTICS_CHANGED = 0x07, /// suppliers and how many messages they have changed
|
||||
};
|
||||
|
||||
struct RsGxsForumEvent: RsEvent
|
||||
|
|
|
@ -46,7 +46,8 @@ struct RsGxsNotify
|
|||
TYPE_RECEIVED_NEW = 0x02,
|
||||
TYPE_PROCESSED = 0x03,
|
||||
TYPE_RECEIVED_PUBLISHKEY = 0x04,
|
||||
TYPE_RECEIVED_DISTANT_SEARCH_RESULTS = 0x05
|
||||
TYPE_RECEIVED_DISTANT_SEARCH_RESULTS = 0x05,
|
||||
TYPE_STATISTICS_CHANGED = 0x06
|
||||
};
|
||||
|
||||
virtual ~RsGxsNotify() {}
|
||||
|
|
|
@ -114,6 +114,7 @@ enum class RsPostedEventCode: uint8_t
|
|||
UPDATED_POSTED_GROUP = 0x04,
|
||||
UPDATED_MESSAGE = 0x05,
|
||||
READ_STATUS_CHANGED = 0x06,
|
||||
STATISTICS_CHANGED = 0x07,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -302,7 +302,6 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
{
|
||||
switch (grpChange->getType())
|
||||
{
|
||||
default:
|
||||
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
||||
{
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
|
@ -318,6 +317,20 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
}
|
||||
break;
|
||||
|
||||
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
|
||||
{
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||
ev->mChannelGroupId = *git;
|
||||
ev->mChannelEventCode = RsChannelEventCode::STATISTICS_CHANGED;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RsGxsNotify::TYPE_PUBLISHED:
|
||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||
{
|
||||
|
@ -356,9 +369,14 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
RsErr() << " Got a GXS event of type " << grpChange->getType() << " Currently not handled." << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RsGxsDistantSearchResultChange *dsrChange = dynamic_cast<RsGxsDistantSearchResultChange*>(*it);
|
||||
|
|
|
@ -246,7 +246,6 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
{
|
||||
switch (grpChange->getType())
|
||||
{
|
||||
default:
|
||||
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
||||
{
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
|
@ -260,7 +259,7 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
}
|
||||
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case RsGxsNotify::TYPE_PUBLISHED:
|
||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||
|
@ -288,8 +287,26 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
<< " Not notifying already known forum "
|
||||
<< *git << std::endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
|
||||
{
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsForumEvent>();
|
||||
ev->mForumGroupId = *git;
|
||||
ev->mForumEventCode = RsForumEventCode::STATISTICS_CHANGED;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
RsErr() << " Got a GXS event of type " << grpChange->getType() << " Currently not handled." << std::endl;
|
||||
break;
|
||||
|
||||
|
||||
#ifdef NOT_USED_YET
|
||||
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:
|
||||
|
|
|
@ -133,8 +133,7 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
#endif
|
||||
|
||||
switch(grpChange->getType())
|
||||
{
|
||||
default:
|
||||
{
|
||||
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
||||
{
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
|
@ -148,15 +147,30 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
}
|
||||
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case RsGxsNotify::TYPE_PUBLISHED:
|
||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||
{
|
||||
/* group received */
|
||||
const std::list<RsGxsGroupId>& grpList = grpChange->mGrpIdList;
|
||||
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
|
||||
{
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
|
||||
for (auto git = grpList.begin(); git != grpList.end(); ++git)
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsPostedEvent>();
|
||||
ev->mPostedGroupId = *git;
|
||||
ev->mPostedEventCode = RsPostedEventCode::STATISTICS_CHANGED;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RsGxsNotify::TYPE_PUBLISHED:
|
||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||
{
|
||||
/* group received */
|
||||
const std::list<RsGxsGroupId>& grpList = grpChange->mGrpIdList;
|
||||
|
||||
for (auto git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
if(mKnownPosted.find(*git) == mKnownPosted.end())
|
||||
{
|
||||
|
@ -178,9 +192,13 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
<< " Not notifying already known forum "
|
||||
<< *git << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
RsErr() << " Got a GXS event of type " << grpChange->getType() << " Currently not handled." << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete *it;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue