mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 16:39:29 -05:00
fixed errors reported by review of PR1735
This commit is contained in:
parent
31968f82f2
commit
fcbecbaa16
@ -481,7 +481,7 @@ void p3LinkMgrIMPL::tickMonitors()
|
||||
{
|
||||
auto e = std::make_shared<RsConnectionEvent>() ;
|
||||
|
||||
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<RsConnectionEvent>() ;
|
||||
|
||||
e->mType = RsConnectionEvent::PEER_DISCONNECTED;
|
||||
e->mConnectionType = RsConnectionEvent::PEER_DISCONNECTED;
|
||||
e->mSslId = peer.id;
|
||||
|
||||
rsEvents->postEvent(e);
|
||||
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
@ -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<const RsEvent> event) { handleEvent(event); }, mEventHandlerId );
|
||||
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
@ -187,32 +188,30 @@ void NewsFeed::handleEvent(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
uint flags = Settings->getNewsFeedFlags();
|
||||
|
||||
const RsAuthSslConnectionAutenticationEvent *pssl_e = dynamic_cast<const RsAuthSslConnectionAutenticationEvent*>(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<const RsConnectionEvent*>(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<const RsEvent> event)
|
||||
{
|
||||
const RsConnectionEvent *pe = dynamic_cast<const RsConnectionEvent*>(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<const RsEvent> event)
|
||||
{
|
||||
const RsAuthSslConnectionAutenticationEvent *pe = dynamic_cast<const RsAuthSslConnectionAutenticationEvent*>(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(),
|
||||
|
@ -102,8 +102,8 @@ private slots:
|
||||
void sendNewsFeedChanged();
|
||||
|
||||
private:
|
||||
void handleSecurityEvent(const RsAuthSslConnectionAutenticationEvent& e);
|
||||
void handleConnectionEvent(const RsConnectionEvent& e);
|
||||
void handleSecurityEvent(std::shared_ptr<const RsEvent> event);
|
||||
void handleConnectionEvent(std::shared_ptr<const RsEvent> 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);
|
||||
|
Loading…
Reference in New Issue
Block a user