diff --git a/libretroshare/src/pqi/p3linkmgr.cc b/libretroshare/src/pqi/p3linkmgr.cc index a9554f43c..a84090860 100644 --- a/libretroshare/src/pqi/p3linkmgr.cc +++ b/libretroshare/src/pqi/p3linkmgr.cc @@ -481,7 +481,7 @@ void p3LinkMgrIMPL::tickMonitors() { auto e = std::make_shared() ; - e->mType = RsConnectionEvent::PEER_CONNECTED; + e->mConnectionType = RsConnectionEvent::PEER_CONNECTED; e->mSslId = peer.id; rsEvents->postEvent(e); @@ -494,11 +494,9 @@ void p3LinkMgrIMPL::tickMonitors() } if (peer.actions & RS_PEER_DISCONNECTED) { - p3Notify *notify = RsServer::notify(); - auto e = std::make_shared() ; - e->mType = RsConnectionEvent::PEER_DISCONNECTED; + e->mConnectionType = RsConnectionEvent::PEER_DISCONNECTED; e->mSslId = peer.id; rsEvents->postEvent(e); diff --git a/libretroshare/src/retroshare/rsevents.h b/libretroshare/src/retroshare/rsevents.h index aa366e7bf..8bf2a6fe2 100644 --- a/libretroshare/src/retroshare/rsevents.h +++ b/libretroshare/src/retroshare/rsevents.h @@ -221,7 +221,7 @@ struct RsConnectionEvent : RsEvent { RsConnectionEvent() : RsEvent(RsEventType::PEER_CONNECTION), - mType(UNKNOWN) {} + mConnectionType(UNKNOWN) {} enum ConnectionType: uint8_t { UNKNOWN = 0x00, @@ -230,14 +230,14 @@ struct RsConnectionEvent : RsEvent PEER_REFUSED_CONNECTION = 0x03, }; - ConnectionType mType; + ConnectionType mConnectionType; RsPeerId mSslId; ///* @see RsEvent @see RsSerializable void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override { RsEvent::serial_process(j, ctx); - RS_SERIAL_PROCESS(mType); + RS_SERIAL_PROCESS(mConnectionType); RS_SERIAL_PROCESS(mSslId); } }; diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index ee0bc1eb8..20482a8f1 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -75,6 +75,7 @@ NewsFeed::NewsFeed(QWidget *parent) : RsAutoUpdatePage(1000,parent), ui(new Ui::NewsFeed) { + mEventHandlerId =0; // needed to force intialization by registerEventsHandler() rsEvents->registerEventsHandler( [this](std::shared_ptr event) { handleEvent(event); }, mEventHandlerId ); /* Invoke the Qt Designer generated object setup routine */ @@ -187,32 +188,30 @@ void NewsFeed::handleEvent(std::shared_ptr event) { uint flags = Settings->getNewsFeedFlags(); - const RsAuthSslConnectionAutenticationEvent *pssl_e = dynamic_cast(event.get()); - - if(pssl_e != nullptr && (flags & RS_FEED_TYPE_SECURITY)) + if(event->mType == RsEventType::AUTHSSL_CONNECTION_AUTENTICATION && (flags & RS_FEED_TYPE_SECURITY)) { - auto e = *pssl_e; // make a copy because we lose memory ownership here - - RsQThreadUtils::postToObject( [=]() { handleSecurityEvent(e); }, this ); + RsQThreadUtils::postToObject( [=]() { handleSecurityEvent(event); }, this ); return; } - const RsConnectionEvent *conn_e = dynamic_cast(event.get()); - - if(conn_e != nullptr && (flags & RS_FEED_TYPE_PEER)) + if(event->mType == RsEventType::PEER_STATE_CHANGED && (flags & RS_FEED_TYPE_PEER)) { - auto e = *conn_e; - - RsQThreadUtils::postToObject( [=]() { handleConnectionEvent(e); }, this ); + RsQThreadUtils::postToObject( [=]() { handleConnectionEvent(event); }, this ); return; } } -void NewsFeed::handleConnectionEvent(const RsConnectionEvent& e) +void NewsFeed::handleConnectionEvent(std::shared_ptr event) { + const RsConnectionEvent *pe = dynamic_cast(event.get()); + if(!pe) + return; + + auto& e(*pe); + std::cerr << "NotifyQt: handling connection event from peer " << e.mSslId << std::endl; - switch(e.mType) + switch(e.mConnectionType) { case RsConnectionEvent::PEER_CONNECTED: addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_CONNECT, false), @@ -250,8 +249,15 @@ void NewsFeed::handleConnectionEvent(const RsConnectionEvent& e) } } -void NewsFeed::handleSecurityEvent(const RsAuthSslConnectionAutenticationEvent& e) +void NewsFeed::handleSecurityEvent(std::shared_ptr event) { + const RsAuthSslConnectionAutenticationEvent *pe = dynamic_cast(event.get()); + + if(!pe) + return; + + auto& e(*pe); + std::cerr << "NotifyQt: handling security event from (" << e.mSslId << "," << e.mPgpId << ") error code: " << e.mErrorCode << std::endl; uint flags = Settings->getNewsFeedFlags(); @@ -280,7 +286,7 @@ void NewsFeed::handleSecurityEvent(const RsAuthSslConnectionAutenticationEvent& det.location, e.mLocator.toString(), FeedItemType, - false), + true), FeedItemType, e.mSslId.toStdString(), std::string(), diff --git a/retroshare-gui/src/gui/NewsFeed.h b/retroshare-gui/src/gui/NewsFeed.h index 9bc8e0afe..c7e50e47d 100644 --- a/retroshare-gui/src/gui/NewsFeed.h +++ b/retroshare-gui/src/gui/NewsFeed.h @@ -102,8 +102,8 @@ private slots: void sendNewsFeedChanged(); private: - void handleSecurityEvent(const RsAuthSslConnectionAutenticationEvent& e); - void handleConnectionEvent(const RsConnectionEvent& e); + void handleSecurityEvent(std::shared_ptr event); + void handleConnectionEvent(std::shared_ptr event); void addFeedItem(FeedItem *item); void addFeedItemIfUnique(FeedItem *item, int itemType, const std::string& id1, const std::string& id2, const std::string& id3, const std::string& id4, bool replace);