mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-14 08:59:50 -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>() ;
|
auto e = std::make_shared<RsConnectionEvent>() ;
|
||||||
|
|
||||||
e->mType = RsConnectionEvent::PEER_CONNECTED;
|
e->mConnectionType = RsConnectionEvent::PEER_CONNECTED;
|
||||||
e->mSslId = peer.id;
|
e->mSslId = peer.id;
|
||||||
|
|
||||||
rsEvents->postEvent(e);
|
rsEvents->postEvent(e);
|
||||||
@ -494,11 +494,9 @@ void p3LinkMgrIMPL::tickMonitors()
|
|||||||
}
|
}
|
||||||
if (peer.actions & RS_PEER_DISCONNECTED)
|
if (peer.actions & RS_PEER_DISCONNECTED)
|
||||||
{
|
{
|
||||||
p3Notify *notify = RsServer::notify();
|
|
||||||
|
|
||||||
auto e = std::make_shared<RsConnectionEvent>() ;
|
auto e = std::make_shared<RsConnectionEvent>() ;
|
||||||
|
|
||||||
e->mType = RsConnectionEvent::PEER_DISCONNECTED;
|
e->mConnectionType = RsConnectionEvent::PEER_DISCONNECTED;
|
||||||
e->mSslId = peer.id;
|
e->mSslId = peer.id;
|
||||||
|
|
||||||
rsEvents->postEvent(e);
|
rsEvents->postEvent(e);
|
||||||
|
@ -221,7 +221,7 @@ struct RsConnectionEvent : RsEvent
|
|||||||
{
|
{
|
||||||
RsConnectionEvent()
|
RsConnectionEvent()
|
||||||
: RsEvent(RsEventType::PEER_CONNECTION),
|
: RsEvent(RsEventType::PEER_CONNECTION),
|
||||||
mType(UNKNOWN) {}
|
mConnectionType(UNKNOWN) {}
|
||||||
|
|
||||||
enum ConnectionType: uint8_t {
|
enum ConnectionType: uint8_t {
|
||||||
UNKNOWN = 0x00,
|
UNKNOWN = 0x00,
|
||||||
@ -230,14 +230,14 @@ struct RsConnectionEvent : RsEvent
|
|||||||
PEER_REFUSED_CONNECTION = 0x03,
|
PEER_REFUSED_CONNECTION = 0x03,
|
||||||
};
|
};
|
||||||
|
|
||||||
ConnectionType mType;
|
ConnectionType mConnectionType;
|
||||||
RsPeerId mSslId;
|
RsPeerId mSslId;
|
||||||
|
|
||||||
///* @see RsEvent @see RsSerializable
|
///* @see RsEvent @see RsSerializable
|
||||||
void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override
|
void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override
|
||||||
{
|
{
|
||||||
RsEvent::serial_process(j, ctx);
|
RsEvent::serial_process(j, ctx);
|
||||||
RS_SERIAL_PROCESS(mType);
|
RS_SERIAL_PROCESS(mConnectionType);
|
||||||
RS_SERIAL_PROCESS(mSslId);
|
RS_SERIAL_PROCESS(mSslId);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -75,6 +75,7 @@ NewsFeed::NewsFeed(QWidget *parent) :
|
|||||||
RsAutoUpdatePage(1000,parent),
|
RsAutoUpdatePage(1000,parent),
|
||||||
ui(new Ui::NewsFeed)
|
ui(new Ui::NewsFeed)
|
||||||
{
|
{
|
||||||
|
mEventHandlerId =0; // needed to force intialization by registerEventsHandler()
|
||||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { handleEvent(event); }, mEventHandlerId );
|
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { handleEvent(event); }, mEventHandlerId );
|
||||||
|
|
||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* 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();
|
uint flags = Settings->getNewsFeedFlags();
|
||||||
|
|
||||||
const RsAuthSslConnectionAutenticationEvent *pssl_e = dynamic_cast<const RsAuthSslConnectionAutenticationEvent*>(event.get());
|
if(event->mType == RsEventType::AUTHSSL_CONNECTION_AUTENTICATION && (flags & RS_FEED_TYPE_SECURITY))
|
||||||
|
|
||||||
if(pssl_e != nullptr && (flags & RS_FEED_TYPE_SECURITY))
|
|
||||||
{
|
{
|
||||||
auto e = *pssl_e; // make a copy because we lose memory ownership here
|
RsQThreadUtils::postToObject( [=]() { handleSecurityEvent(event); }, this );
|
||||||
|
|
||||||
RsQThreadUtils::postToObject( [=]() { handleSecurityEvent(e); }, this );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RsConnectionEvent *conn_e = dynamic_cast<const RsConnectionEvent*>(event.get());
|
if(event->mType == RsEventType::PEER_STATE_CHANGED && (flags & RS_FEED_TYPE_PEER))
|
||||||
|
|
||||||
if(conn_e != nullptr && (flags & RS_FEED_TYPE_PEER))
|
|
||||||
{
|
{
|
||||||
auto e = *conn_e;
|
RsQThreadUtils::postToObject( [=]() { handleConnectionEvent(event); }, this );
|
||||||
|
|
||||||
RsQThreadUtils::postToObject( [=]() { handleConnectionEvent(e); }, this );
|
|
||||||
return;
|
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;
|
std::cerr << "NotifyQt: handling connection event from peer " << e.mSslId << std::endl;
|
||||||
|
|
||||||
switch(e.mType)
|
switch(e.mConnectionType)
|
||||||
{
|
{
|
||||||
case RsConnectionEvent::PEER_CONNECTED:
|
case RsConnectionEvent::PEER_CONNECTED:
|
||||||
addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_CONNECT, false),
|
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;
|
std::cerr << "NotifyQt: handling security event from (" << e.mSslId << "," << e.mPgpId << ") error code: " << e.mErrorCode << std::endl;
|
||||||
uint flags = Settings->getNewsFeedFlags();
|
uint flags = Settings->getNewsFeedFlags();
|
||||||
|
|
||||||
@ -280,7 +286,7 @@ void NewsFeed::handleSecurityEvent(const RsAuthSslConnectionAutenticationEvent&
|
|||||||
det.location,
|
det.location,
|
||||||
e.mLocator.toString(),
|
e.mLocator.toString(),
|
||||||
FeedItemType,
|
FeedItemType,
|
||||||
false),
|
true),
|
||||||
FeedItemType,
|
FeedItemType,
|
||||||
e.mSslId.toStdString(),
|
e.mSslId.toStdString(),
|
||||||
std::string(),
|
std::string(),
|
||||||
|
@ -102,8 +102,8 @@ private slots:
|
|||||||
void sendNewsFeedChanged();
|
void sendNewsFeedChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleSecurityEvent(const RsAuthSslConnectionAutenticationEvent& e);
|
void handleSecurityEvent(std::shared_ptr<const RsEvent> event);
|
||||||
void handleConnectionEvent(const RsConnectionEvent& e);
|
void handleConnectionEvent(std::shared_ptr<const RsEvent> event);
|
||||||
|
|
||||||
void addFeedItem(FeedItem *item);
|
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);
|
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