moved UserNotify to MainPage level, and added RsEvent handling code in Posted

This commit is contained in:
csoler 2020-01-26 23:19:20 +01:00
parent 9c65836503
commit fb9282f588
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
28 changed files with 140 additions and 51 deletions

View file

@ -122,6 +122,10 @@ enum class RsChannelEventCode: uint8_t
/// subscription for channel mChannelGroupId changed.
SUBSCRIBE_STATUS_CHANGED = 0x06,
/// existing message has been read or set to unread
READ_STATUS_CHANGED = 0x07,
};
struct RsGxsChannelEvent: RsEvent

View file

@ -70,9 +70,12 @@ std::ostream &operator<<(std::ostream &out, const RsPostedPost &post);
enum class RsPostedEventCode: uint8_t
{
UNKNOWN = 0x00,
NEW_POSTED_GROUP = 0x01,
NEW_MESSAGE = 0x02
UNKNOWN = 0x00,
NEW_POSTED_GROUP = 0x01,
NEW_MESSAGE = 0x02,
SUBSCRIBE_STATUS_CHANGED = 0x03,
UPDATED_POSTED_GROUP = 0x04,
UPDATED_MESSAGE = 0x05,
};

View file

@ -369,8 +369,8 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
if(!unprocessedGroups.empty())
request_SpecificSubscribedGroups(unprocessedGroups);
// the call below deletes changes and its content.
RsGxsIfaceHelper::receiveChanges(changes);
// // the call below deletes changes and its content.
// RsGxsIfaceHelper::receiveChanges(changes);
}
void p3GxsChannels::service_tick()
@ -1764,8 +1764,17 @@ void p3GxsChannels::setMessageReadStatus( uint32_t& token,
if (read) status = 0;
setMsgStatusFlags(token, msgId, status, mask);
}
if (rsEvents)
{
auto ev = std::make_shared<RsGxsChannelEvent>();
ev->mChannelMsgId = msgId.second;
ev->mChannelGroupId = msgId.first;
ev->mChannelEventCode = RsChannelEventCode::READ_STATUS_CHANGED;
rsEvents->postEvent(ev);
}
}
/********************************************************************************************/
/********************************************************************************************/

View file

@ -91,8 +91,8 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
for(it = changes.begin(); it != changes.end(); ++it)
{
RsGxsGroupChange *groupChange = dynamic_cast<RsGxsGroupChange *>(*it);
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(*it);
if (msgChange)
{
#ifdef POSTBASE_DEBUG
@ -124,31 +124,54 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
}
}
RsGxsGroupChange *grpChange = dynamic_cast<RsGxsGroupChange *>(*it);
/* pass on Group Changes to GUI */
if (groupChange)
if (grpChange && rsEvents)
{
#ifdef POSTBASE_DEBUG
std::cerr << "p3PostBase::notifyChanges() Found Group Change Notification";
std::cerr << std::endl;
#endif
std::list<RsGxsGroupId> &groupList = groupChange->mGrpIdList;
for(auto git = groupList.begin(); git != groupList.end(); ++git)
switch(grpChange->getType())
{
default:
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
{
#ifdef POSTBASE_DEBUG
std::cerr << "p3PostBase::notifyChanges() Incoming Group: " << *git;
std::cerr << std::endl;
#endif
if (rsEvents && groupChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
std::list<RsGxsGroupId>::iterator git;
for (git = grpList.begin(); git != grpList.end(); ++git)
{
auto ev = std::make_shared<RsGxsPostedEvent>();
ev->mPostedGroupId = *git;
ev->mPostedEventCode = RsPostedEventCode::SUBSCRIBE_STATUS_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)
{
#ifdef POSTBASE_DEBUG
std::cerr << "p3PostBase::notifyChanges() Incoming Group: " << *git;
std::cerr << std::endl;
#endif
auto ev = std::make_shared<RsGxsPostedEvent>();
ev->mPostedGroupId = *git;
ev->mPostedEventCode = RsPostedEventCode::NEW_POSTED_GROUP;
rsEvents->postEvent(ev);
}
}
}
break;
}
}
}
receiveHelperChanges(changes);