finished removing last AddFeedItem from msg, posted, forums and channels

This commit is contained in:
csoler 2019-12-13 23:40:21 +01:00
parent 4fe6e46410
commit 3a3fc25205
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
10 changed files with 127 additions and 73 deletions

View file

@ -300,6 +300,15 @@ struct RsMailStatusEvent : RsEvent
{
RsMailStatusEvent() : RsEvent(RsEventType::MAIL_STATUS_CHANGE) {}
enum MailStatusEventCode: uint8_t {
NEW_MESSAGE = 0x00,
MESSAGE_REMOVED = 0x01,
MESSAGE_SENT = 0x02,
MESSAGE_RECEIVED_ACK = 0x03, // means the peer received the message
FAILED_SIGNATURE = 0x04, // means the signature of the message cannot be verified
};
MailStatusEventCode mMailStatusEventCode;
std::set<RsMailMessageId> mChangedMsgIds;
/// @see RsEvent
@ -308,6 +317,7 @@ struct RsMailStatusEvent : RsEvent
{
RsEvent::serial_process(j, ctx);
RS_SERIAL_PROCESS(mChangedMsgIds);
RS_SERIAL_PROCESS(mMailStatusEventCode);
}
~RsMailStatusEvent() override;

View file

@ -80,7 +80,6 @@ struct RsGxsPostedEvent: RsEvent
};
PostedEventCode mPostedEventCode;
RsPeerId mAuthorId;
RsGxsGroupId mPostedGroupId;
RsGxsMessageId mPostedMsgId;
@ -89,7 +88,6 @@ struct RsGxsPostedEvent: RsEvent
{
RsEvent::serial_process(j, ctx);
RS_SERIAL_PROCESS(mPostedEventCode);
RS_SERIAL_PROCESS(mAuthorId);
RS_SERIAL_PROCESS(mPostedGroupId);
RS_SERIAL_PROCESS(mPostedMsgId);
}

View file

@ -238,12 +238,6 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::cerr << "p3GxsChannels::notifyChanges() : " << changes.size() << "changes to notify" << std::endl;
#endif
p3Notify* notify = nullptr;
if (!changes.empty())
{
notify = RsServer::notify();
}
/* iterate through and grab any new messages */
std::list<RsGxsGroupId> unprocessedGroups;
@ -256,13 +250,19 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
if (msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
{
/* message received */
if (notify)
if (rsEvents)
{
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
{
notify->AddFeedItem(RS_FEED_ITEM_CHANNEL_MSG, mit->first.toStdString(), mit1->toStdString());
auto ev = std::make_shared<RsGxsChannelEvent>();
ev->mChannelMsgId = *mit1;
ev->mChannelGroupId = mit->first;
ev->mChannelEventCode = RsGxsChannelEvent::NEW_MESSAGE;
rsEvents->sendEvent(ev);
}
}
}
@ -298,7 +298,7 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
}
else
{
if (notify)
if (rsEvents)
{
RsGxsGroupChange *grpChange = dynamic_cast<RsGxsGroupChange*>(*it);
if (grpChange)
@ -320,8 +320,15 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
{
if(mKnownChannels.find(*git) == mKnownChannels.end())
{
notify->AddFeedItem(RS_FEED_ITEM_CHANNEL_NEW, git->toStdString());
mKnownChannels.insert(std::make_pair(*git,time(NULL))) ;
IndicateConfigChanged();
auto ev = std::make_shared<RsGxsChannelEvent>();
ev->mChannelGroupId = *git;
ev->mChannelEventCode = RsGxsChannelEvent::NEW_CHANNEL;
rsEvents->sendEvent(ev);
}
else
std::cerr << "(II) Not notifying already known channel " << *git << std::endl;
@ -336,7 +343,12 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::list<RsGxsGroupId>::iterator git;
for (git = grpList.begin(); git != grpList.end(); ++git)
{
notify->AddFeedItem(RS_FEED_ITEM_CHANNEL_PUBLISHKEY, git->toStdString());
auto ev = std::make_shared<RsGxsChannelEvent>();
ev->mChannelGroupId = *git;
ev->mChannelEventCode = RsGxsChannelEvent::RECEIVED_PUBLISH_KEY;
rsEvents->sendEvent(ev);
}
break;
}

View file

@ -438,8 +438,6 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
RsGxsCircleMsg msg;
getCircleRequest(RsGxsGroupId(circle_id),*msgIdIt,msg);
// notify->AddFeedItem(RS_FEED_ITEM_CIRCLE_MEMB_REQ,RsGxsCircleId(mit->first).toStdString(),msgId.toStdString());
auto ev = std::make_shared<RsGxsCircleEvent>();
ev->mCircleId = circle_id;
@ -534,7 +532,6 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
}
}
//notify->AddFeedItem(RS_FEED_ITEM_CIRCLE_INVIT_REC,RsGxsCircleId(*git).toStdString(),"");
}
#endif
}

View file

@ -183,9 +183,7 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
{
if (!changes.empty())
{
p3Notify *notify = RsServer::notify();
if (notify)
if (rsEvents)
{
std::vector<RsGxsNotify*>::iterator it;
for(it = changes.begin(); it != changes.end(); ++it)
@ -207,10 +205,17 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
{
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
notify->AddFeedItem(RS_FEED_ITEM_FORUM_MSG, mit->first.toStdString(), mit1->toStdString());
}
{
auto ev = std::make_shared<RsGxsForumEvent>();
ev->mForumGroupId = mit->first;
ev->mForumMsgId = *mit1;
ev->mForumEventCode = RsGxsForumEvent::NEW_MESSAGE;
rsEvents->sendEvent(ev);
}
break;
}
@ -225,9 +230,13 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
{
if(mKnownForums.find(*git) == mKnownForums.end())
{
notify->AddFeedItem(RS_FEED_ITEM_FORUM_NEW, git->toStdString());
mKnownForums.insert(std::make_pair(*git,time(NULL))) ;
auto ev = std::make_shared<RsGxsForumEvent>();
ev->mForumGroupId = *git;
ev->mForumEventCode = RsGxsForumEvent::NEW_FORUM;
rsEvents->sendEvent(ev);
mKnownForums.insert(std::make_pair(*git,time(NULL))) ;
IndicateConfigChanged();
}
else
@ -237,6 +246,9 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
}
break;
}
#ifdef UNUSED
// (Cyril) There's no publish key system for forums now. As a GXS group, it is possible to add one, just like channels
// but the possibility is not offered by the API yet.
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:
{
@ -254,6 +266,7 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
}
break;
}
#endif
}
}
}

View file

@ -175,15 +175,14 @@ void p3MsgService::processIncomingMsg(RsMsgItem *mi)
mi->msgFlags &= (RS_MSG_FLAGS_DISTANT | RS_MSG_FLAGS_SYSTEM); // remove flags except those
mi->msgFlags |= RS_MSG_FLAGS_NEW;
p3Notify *notify = RsServer::notify();
if (notify)
if (rsEvents)
{
notify->AddPopupMessage(RS_POPUP_MSG, mi->PeerId().toStdString(), mi->subject, mi->message);
auto ev = std::make_shared<RsMailStatusEvent>();
ev->mMailStatusEventCode = RsMailStatusEvent::NEW_MESSAGE;
ev->mChangedMsgIds.insert(std::to_string(mi->msgId));
std::string out;
rs_sprintf(out, "%lu", mi->msgId);
notify->AddFeedItem(RS_FEED_ITEM_MESSAGE, out, "", "");
}
rsEvents->sendEvent(ev);
}
imsg[mi->msgId] = mi;
RsMsgSrcId* msi = new RsMsgSrcId();
@ -207,13 +206,6 @@ void p3MsgService::processIncomingMsg(RsMsgItem *mi)
}
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD);
if(rsEvents)
{
std::shared_ptr<RsMailStatusEvent> pEvent(new RsMailStatusEvent());
pEvent->mChangedMsgIds.insert(std::to_string(mi->msgId));
rsEvents->postEvent(pEvent);
}
}
bool p3MsgService::checkAndRebuildPartialMessage(RsMsgItem *ci)
@ -345,8 +337,8 @@ int p3MsgService::checkOutgoingMessages()
bool changed = false;
std::list<RsMsgItem*> output_queue;
using Evt_t = RsMailStatusEvent;
std::shared_ptr<Evt_t> pEvent(new Evt_t());
auto pEvent = std::make_shared<RsMailStatusEvent>();
pEvent->mMailStatusEventCode = RsMailStatusEvent::MESSAGE_SENT;
{
RS_STACK_MUTEX(mMsgMtx); /********** STACK LOCKED MTX ******/
@ -905,8 +897,10 @@ bool p3MsgService::removeMsgId(const std::string &mid)
}
bool changed = false;
using Evt_t = RsMailStatusEvent;
std::shared_ptr<Evt_t> pEvent(new Evt_t());
auto pEvent = std::make_shared<RsMailStatusEvent>();
pEvent->mMailStatusEventCode = RsMailStatusEvent::MESSAGE_REMOVED;
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
@ -1273,8 +1267,9 @@ uint32_t p3MsgService::sendMail(
std::back_inserter(msgInfo.files) );
uint32_t ret = 0;
using Evt_t = RsMailStatusEvent;
std::shared_ptr<Evt_t> pEvent(new Evt_t());
auto pEvent = std::make_shared<RsMailStatusEvent>();
pEvent->mMailStatusEventCode = RsMailStatusEvent::MESSAGE_SENT;
auto pSend = [&](const std::set<RsGxsId>& sDest)
{
@ -2088,9 +2083,11 @@ void p3MsgService::notifyDataStatus( const GRouterMsgPropagationId& id,
NOTIFY_TYPE_ADD );
IndicateConfigChanged();
using Evt_t = RsMailStatusEvent;
std::shared_ptr<Evt_t> pEvent(new Evt_t());
auto pEvent = std::make_shared<RsMailStatusEvent>();
pEvent->mMailStatusEventCode = RsMailStatusEvent::NEW_MESSAGE;
pEvent->mChangedMsgIds.insert(std::to_string(msg_id));
if(rsEvents) rsEvents->postEvent(pEvent);
return;
@ -2188,11 +2185,11 @@ bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
Dbg2() << __PRETTY_FUNCTION__ << " " << mailId << ", "
<< static_cast<uint32_t>(status) << std::endl;
using Evt_t = RsMailStatusEvent;
std::shared_ptr<Evt_t> pEvent(new Evt_t());
auto pEvent = std::make_shared<RsMailStatusEvent>();
if( status == GxsTransSendStatus::RECEIPT_RECEIVED )
{
pEvent->mMailStatusEventCode = RsMailStatusEvent::NEW_MESSAGE;
uint32_t msg_id;
{
@ -2247,6 +2244,7 @@ bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
else if( status >= GxsTransSendStatus::FAILED_RECEIPT_SIGNATURE )
{
uint32_t msg_id;
pEvent->mMailStatusEventCode = RsMailStatusEvent::FAILED_SIGNATURE;
{
RS_STACK_MUTEX(gxsOngoingMutex);

View file

@ -29,7 +29,7 @@
#include "rsitems/rsgxscommentitems.h"
#include "rsserver/p3face.h"
#include "retroshare/rsnotify.h"
#include "retroshare/rsposted.h"
// For Dummy Msgs.
#include "util/rsrandom.h"
@ -87,12 +87,6 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::cerr << std::endl;
#endif
p3Notify *notify = NULL;
if (!changes.empty())
{
notify = RsServer::notify();
}
std::vector<RsGxsNotify *>::iterator it;
for(it = changes.begin(); it != changes.end(); ++it)
@ -118,13 +112,17 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
// It could be taken a step further and directly request these msgs for an update.
addGroupForProcessing(mit->first);
if (notify && msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
{
if (rsEvents && msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
{
notify->AddFeedItem(RS_FEED_ITEM_POSTED_MSG, mit->first.toStdString(), mit1->toStdString());
auto ev = std::make_shared<RsGxsPostedEvent>();
ev->mPostedMsgId = *mit1;
ev->mPostedGroupId = mit->first;
ev->mPostedEventCode = RsGxsPostedEvent::NEW_MESSAGE;
rsEvents->sendEvent(ev);
}
}
}
}
@ -137,17 +135,22 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
#endif
std::list<RsGxsGroupId> &groupList = groupChange->mGrpIdList;
std::list<RsGxsGroupId>::iterator git;
for(git = groupList.begin(); git != groupList.end(); ++git)
for(auto git = groupList.begin(); git != groupList.end(); ++git)
{
#ifdef POSTBASE_DEBUG
std::cerr << "p3PostBase::notifyChanges() Incoming Group: " << *git;
std::cerr << std::endl;
#endif
if (notify && groupChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
if (rsEvents && groupChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
{
notify->AddFeedItem(RS_FEED_ITEM_POSTED_NEW, git->toStdString());
auto ev = std::make_shared<RsGxsPostedEvent>();
ev->mPostedGroupId = *git;
ev->mPostedEventCode = RsGxsPostedEvent::NEW_POSTED_GROUP;
rsEvents->sendEvent(ev);
}
}
}