using new notification system for connection attempts

This commit is contained in:
csoler 2019-12-02 20:53:51 +01:00
parent d8569d813c
commit 65fa54c206
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
13 changed files with 127 additions and 131 deletions

View File

@ -1220,6 +1220,7 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
{ {
ev->mSslCn = sslCn; ev->mSslCn = sslCn;
ev->mPgpId = pgpId; ev->mPgpId = pgpId;
ev->mErrorMsg = errMsg;
ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::MISSING_AUTHENTICATION_INFO; ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::MISSING_AUTHENTICATION_INFO;
rsEvents->postEvent(std::move(ev)); rsEvents->postEvent(std::move(ev));
@ -1332,17 +1333,6 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
<< "sslId: " << sslId << " isSslOnlyFriend: " << isSslOnlyFriend << "sslId: " << sslId << " isSslOnlyFriend: " << isSslOnlyFriend
<< std::endl; << std::endl;
if(rsEvents)
{
ev->mSuccess = true;
ev->mSslId = sslId;
ev->mSslCn = sslCn;
ev->mPgpId = pgpId;
ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::NO_ERROR;
rsEvents->postEvent(std::move(ev));
}
return verificationSuccess; return verificationSuccess;
} }
@ -1795,9 +1785,6 @@ bool AuthSSLimpl::loadList(std::list<RsItem*>& load)
return true; return true;
} }
RsAuthSslConnectionAutenticationEvent::RsAuthSslConnectionAutenticationEvent() :
RsEvent(RsEventType::AUTHSSL_CONNECTION_AUTENTICATION), mSuccess(false) {}
const EVP_PKEY*RsX509Cert::getPubKey(const X509& x509) const EVP_PKEY*RsX509Cert::getPubKey(const X509& x509)
{ {
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)

View File

@ -479,20 +479,29 @@ void p3LinkMgrIMPL::tickMonitors()
if (notify) if (notify)
{ {
// normally these two below should disappear: there's no notion of popup in libretroshare. auto e = std::make_shared<RsConnectionEvent>() ;
// all GUI-type display features should be chosen in NotifyQt.
notify->AddPopupMessage(RS_POPUP_CONNECT, peer.id.toStdString(),"", "Online: ");
notify->AddFeedItem(RS_FEED_ITEM_PEER_CONNECT, peer.id.toStdString());
notify->notifyPeerConnected(peer.id.toStdString()); e->mType = RsConnectionEvent::PEER_CONNECTED;
e->mSslId = peer.id;
rsEvents->postEvent(e);
// normally these this below should disappear: there's no notion of popup in libretroshare.
// all GUI-type display features should be chosen in NotifyQt.
notify->AddPopupMessage(RS_POPUP_CONNECT, peer.id.toStdString(),"", "Online: ");
} }
} }
if (peer.actions & RS_PEER_DISCONNECTED) if (peer.actions & RS_PEER_DISCONNECTED)
{ {
p3Notify *notify = RsServer::notify(); p3Notify *notify = RsServer::notify();
if (notify) auto e = std::make_shared<RsConnectionEvent>() ;
notify->notifyPeerDisconnected(peer.id.toStdString());
e->mType = RsConnectionEvent::PEER_DISCONNECTED;
e->mSslId = peer.id;
rsEvents->postEvent(e);
} }
} }
} }

View File

@ -217,8 +217,6 @@ void p3Notify::notifyChatLobbyEvent(uint64_t lobby_id, uint32_t event_type,const
void p3Notify::notifyListPreChange(int list, int type) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyListPreChange(list,type) ; } void p3Notify::notifyListPreChange(int list, int type) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyListPreChange(list,type) ; }
void p3Notify::notifyListChange (int list, int type) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyListChange (list,type) ; } void p3Notify::notifyListChange (int list, int type) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyListChange (list,type) ; }
void p3Notify::notifyPeerConnected (const std::string& peer_id) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerConnected(peer_id); }
void p3Notify::notifyPeerDisconnected (const std::string& peer_id) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerDisconnected(peer_id); }
void p3Notify::notifyErrorMsg (int list, int sev, std::string msg) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyErrorMsg(list,sev,msg) ; } void p3Notify::notifyErrorMsg (int list, int sev, std::string msg) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyErrorMsg(list,sev,msg) ; }
void p3Notify::notifyChatMessage (const ChatMessage &msg) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyChatMessage(msg) ; } void p3Notify::notifyChatMessage (const ChatMessage &msg) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyChatMessage(msg) ; }
void p3Notify::notifyChatStatus (const ChatId& chat_id, const std::string& status_string) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyChatStatus(chat_id,status_string) ; } void p3Notify::notifyChatStatus (const ChatId& chat_id, const std::string& status_string) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyChatStatus(chat_id,status_string) ; }

View File

@ -91,8 +91,6 @@ class p3Notify: public RsNotify
// Notifications of clients. Can be called from anywhere inside libretroshare. // Notifications of clients. Can be called from anywhere inside libretroshare.
// //
void notifyPeerConnected (const std::string& /* peer_id */);
void notifyPeerDisconnected (const std::string& /* peer_id */);
void notifyListPreChange (int /* list */, int /* type */) ; void notifyListPreChange (int /* list */, int /* type */) ;
void notifyListChange (int /* list */, int /* type */) ; void notifyListChange (int /* list */, int /* type */) ;
void notifyErrorMsg (int /* list */, int /* sev */, std::string /* msg */) ; void notifyErrorMsg (int /* list */, int /* sev */, std::string /* msg */) ;

View File

@ -493,8 +493,7 @@ int pqissllistenbase::continueSSL(IncomingSSLInfo& incoming_connexion_info, bool
ev->mSslId = incoming_connexion_info.sslid; ev->mSslId = incoming_connexion_info.sslid;
ev->mPgpId = incoming_connexion_info.gpgid; ev->mPgpId = incoming_connexion_info.gpgid;
ev->mSslCn = incoming_connexion_info.sslcn; ev->mSslCn = incoming_connexion_info.sslcn;
ev->mLocator = RsUrl(sockaddr_storage_iptostring(incoming_connexion_info.addr)); ev->mLocator = RsUrl(incoming_connexion_info.addr);
ev->mSuccess = false;
ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::MISSING_AUTHENTICATION_INFO; ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::MISSING_AUTHENTICATION_INFO;
rsEvents->postEvent(std::move(ev)); rsEvents->postEvent(std::move(ev));

View File

@ -59,7 +59,7 @@ enum class RsEventType : uint32_t
AUTHSSL_CONNECTION_AUTENTICATION = 3, AUTHSSL_CONNECTION_AUTENTICATION = 3,
/// @see pqissl /// @see pqissl
REMOTE_PEER_REFUSED_CONNECTION = 4, PEER_CONNECTION = 4,
/// @see RsGxsChanges /// @see RsGxsChanges
GXS_CHANGES = 5, GXS_CHANGES = 5,
@ -173,7 +173,7 @@ public:
}; };
//===================================================================================================// //===================================================================================================//
// Connexion events // // Connexion and security events //
//===================================================================================================// //===================================================================================================//
/** /**
@ -182,10 +182,10 @@ public:
*/ */
struct RsAuthSslConnectionAutenticationEvent : RsEvent struct RsAuthSslConnectionAutenticationEvent : RsEvent
{ {
RsAuthSslConnectionAutenticationEvent(); RsAuthSslConnectionAutenticationEvent() : RsEvent(RsEventType::AUTHSSL_CONNECTION_AUTENTICATION) {}
enum ConnextionErrorCode: uint8_t { enum ConnectionErrorCode: uint8_t {
UNKNOWN_ERROR = 0x00, NO_ERROR = 0x00,
MISSING_AUTHENTICATION_INFO = 0x01, MISSING_AUTHENTICATION_INFO = 0x01,
PGP_SIGNATURE_VALIDATION_FAILED = 0x02, PGP_SIGNATURE_VALIDATION_FAILED = 0x02,
MISMATCHED_PGP_ID = 0x03, MISMATCHED_PGP_ID = 0x03,
@ -193,23 +193,21 @@ struct RsAuthSslConnectionAutenticationEvent : RsEvent
NOT_A_FRIEND = 0x05, NOT_A_FRIEND = 0x05,
MISSING_CERTIFICATE = 0x06, MISSING_CERTIFICATE = 0x06,
IP_IS_BLACKLISTED = 0x07, IP_IS_BLACKLISTED = 0x07,
NO_ERROR = 0x08, UNKNOWN_ERROR = 0x08,
}; };
bool mSuccess;
RsPeerId mSslId; RsPeerId mSslId;
std::string mSslCn; std::string mSslCn;
RsPgpId mPgpId; RsPgpId mPgpId;
RsUrl mLocator; RsUrl mLocator;
std::string mErrorMsg; std::string mErrorMsg;
ConnextionErrorCode mErrorCode; ConnectionErrorCode mErrorCode;
///* @see RsEvent @see RsSerializable ///* @see RsEvent @see RsSerializable
void serial_process( RsGenericSerializer::SerializeJob j, void serial_process( RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx) override RsGenericSerializer::SerializeContext& ctx) override
{ {
RsEvent::serial_process(j, ctx); RsEvent::serial_process(j, ctx);
RS_SERIAL_PROCESS(mSuccess);
RS_SERIAL_PROCESS(mSslId); RS_SERIAL_PROCESS(mSslId);
RS_SERIAL_PROCESS(mSslCn); RS_SERIAL_PROCESS(mSslCn);
RS_SERIAL_PROCESS(mPgpId); RS_SERIAL_PROCESS(mPgpId);
@ -219,3 +217,28 @@ struct RsAuthSslConnectionAutenticationEvent : RsEvent
} }
}; };
struct RsConnectionEvent : RsEvent
{
RsConnectionEvent()
: RsEvent(RsEventType::PEER_CONNECTION),
mType(UNKNOWN) {}
enum ConnectionType: uint8_t {
UNKNOWN = 0x00,
PEER_CONNECTED = 0x01,
PEER_DISCONNECTED = 0x02,
PEER_REFUSED_CONNECTION = 0x03,
};
ConnectionType mType;
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(mSslId);
}
};

View File

@ -212,8 +212,6 @@ public:
NotifyClient() {} NotifyClient() {}
virtual ~NotifyClient() {} virtual ~NotifyClient() {}
virtual void notifyPeerConnected (const std::string& /* peer_id */) {}
virtual void notifyPeerDisconnected (const std::string& /* peer_id */) {}
virtual void notifyListPreChange (int /* list */, int /* type */) {} virtual void notifyListPreChange (int /* list */, int /* type */) {}
virtual void notifyListChange (int /* list */, int /* type */) {} virtual void notifyListChange (int /* list */, int /* type */) {}
virtual void notifyErrorMsg (int /* list */, int /* sev */, std::string /* msg */) {} virtual void notifyErrorMsg (int /* list */, int /* sev */, std::string /* msg */) {}

View File

@ -189,57 +189,83 @@ void NewsFeed::handleEvent(std::shared_ptr<const RsEvent> event)
const RsAuthSslConnectionAutenticationEvent *pssl_e = dynamic_cast<const RsAuthSslConnectionAutenticationEvent*>(event.get()); const RsAuthSslConnectionAutenticationEvent *pssl_e = dynamic_cast<const RsAuthSslConnectionAutenticationEvent*>(event.get());
if(pssl_e != nullptr && (flags & (RS_FEED_TYPE_SECURITY | RS_FEED_TYPE_PEER))) if(pssl_e != nullptr && (flags & RS_FEED_TYPE_SECURITY))
{ {
RsAuthSslConnectionAutenticationEvent e = *pssl_e; // make a copy because we lose memory ownership here auto e = *pssl_e; // make a copy because we lose memory ownership here
RsQThreadUtils::postToObject( [=]() RsQThreadUtils::postToObject( [=]() { handleSecurityEvent(e); }, this );
return;
}
const RsConnectionEvent *conn_e = dynamic_cast<const RsConnectionEvent*>(event.get());
if(conn_e != nullptr && (flags & RS_FEED_TYPE_PEER))
{ {
/* Here it goes any code you want to be executed on the Qt Gui auto e = *conn_e;
* thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete, note that
* Qt::QueuedConnection is important!
*/
handleSecurityEvent(e);
}, this ); RsQThreadUtils::postToObject( [=]() { handleConnectionEvent(e); }, this );
return;
}
}
void NewsFeed::handleConnectionEvent(const RsConnectionEvent& e)
{
std::cerr << "NotifyQt: handling connection event from peer " << e.mSslId << std::endl;
switch(e.mType)
{
case RsConnectionEvent::PEER_CONNECTED:
addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_CONNECT, false),
PEER_TYPE_CONNECT,
e.mSslId.toStdString(),
std::string(),
std::string(),
std::string(),
true);
break;
case RsConnectionEvent::PEER_DISCONNECTED: break;// not handled yet
case RsConnectionEvent::PEER_REFUSED_CONNECTION:
{
RsPeerDetails det;
if(!rsPeers->getPeerDetails(e.mSslId,det))
return;
addFeedItemIfUnique(new SecurityItem(this,
NEWSFEED_SECLIST,
det.gpg_id, det.id,
det.location,
std::string(),
RS_FEED_ITEM_SEC_AUTH_DENIED,
false),
RS_FEED_ITEM_SEC_AUTH_DENIED,
det.gpg_id.toStdString(),
std::string(),
std::string(),
std::string(),
true );
} break;
default: break;
} }
} }
void NewsFeed::handleSecurityEvent(const RsAuthSslConnectionAutenticationEvent& e) void NewsFeed::handleSecurityEvent(const RsAuthSslConnectionAutenticationEvent& e)
{ {
std::cerr << "NotifyQt: handling connection 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();
if(e.mSuccess)
if(flags & RS_FEED_TYPE_PEER)
{
addFeedItem(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_CONNECT, false));
return;
}
else
return;
uint32_t FeedItemType=0; uint32_t FeedItemType=0;
switch(e.mErrorCode) switch(e.mErrorCode)
{ {
case RsAuthSslConnectionAutenticationEvent::NO_CERTIFICATE_SUPPLIED: case RsAuthSslConnectionAutenticationEvent::NO_CERTIFICATE_SUPPLIED:
case RsAuthSslConnectionAutenticationEvent::MISMATCHED_PGP_ID: // fallthrough case RsAuthSslConnectionAutenticationEvent::MISMATCHED_PGP_ID: // fallthrough
case RsAuthSslConnectionAutenticationEvent::MISSING_AUTHENTICATION_INFO: FeedItemType = RS_FEED_ITEM_SEC_BAD_CERTIFICATE; case RsAuthSslConnectionAutenticationEvent::MISSING_AUTHENTICATION_INFO: FeedItemType = RS_FEED_ITEM_SEC_BAD_CERTIFICATE; break;
break; case RsAuthSslConnectionAutenticationEvent::PGP_SIGNATURE_VALIDATION_FAILED: FeedItemType = RS_FEED_ITEM_SEC_WRONG_SIGNATURE; break;
case RsAuthSslConnectionAutenticationEvent::NOT_A_FRIEND: FeedItemType = RS_FEED_ITEM_SEC_AUTH_DENIED; break;
case RsAuthSslConnectionAutenticationEvent::PGP_SIGNATURE_VALIDATION_FAILED: FeedItemType = RS_FEED_ITEM_SEC_WRONG_SIGNATURE; case RsAuthSslConnectionAutenticationEvent::IP_IS_BLACKLISTED: FeedItemType = RS_FEED_ITEM_SEC_IP_BLACKLISTED; break;
break; case RsAuthSslConnectionAutenticationEvent::MISSING_CERTIFICATE: FeedItemType = RS_FEED_ITEM_SEC_MISSING_CERTIFICATE; break;
case RsAuthSslConnectionAutenticationEvent::NOT_A_FRIEND: FeedItemType = RS_FEED_ITEM_SEC_AUTH_DENIED;
break;
case RsAuthSslConnectionAutenticationEvent::IP_IS_BLACKLISTED: FeedItemType = RS_FEED_ITEM_SEC_IP_BLACKLISTED;
break;
case RsAuthSslConnectionAutenticationEvent::MISSING_CERTIFICATE: FeedItemType = RS_FEED_ITEM_SEC_MISSING_CERTIFICATE;
break;
default: default:
return; // display nothing return; // display nothing
@ -255,12 +281,15 @@ void NewsFeed::handleSecurityEvent(const RsAuthSslConnectionAutenticationEvent&
e.mLocator.toString(), e.mLocator.toString(),
FeedItemType, FeedItemType,
false), false),
RS_FEED_ITEM_SEC_BAD_CERTIFICATE, FeedItemType,
det.gpg_id.toStdString(), det.gpg_id.toStdString(),
std::string(), std::string(),
std::string(), std::string(),
std::string(), std::string(),
true ); true );
if (Settings->getMessageFlags() & RS_MESSAGE_CONNECT_ATTEMPT)
MessageComposer::sendConnectAttemptMsg(e.mPgpId, e.mSslId, QString::fromStdString(det.name + "(" + det.location + ")"));
} }
void NewsFeed::updateDisplay() void NewsFeed::updateDisplay()
@ -276,14 +305,6 @@ void NewsFeed::updateDisplay()
{ {
switch(fi.mType) switch(fi.mType)
{ {
case RS_FEED_ITEM_PEER_CONNECT:
if (flags & RS_FEED_TYPE_PEER)
addFeedItemPeerConnect(fi);
break;
case RS_FEED_ITEM_PEER_DISCONNECT:
if (flags & RS_FEED_TYPE_PEER)
addFeedItemPeerDisconnect(fi);
break;
case RS_FEED_ITEM_PEER_HELLO: case RS_FEED_ITEM_PEER_HELLO:
if (flags & RS_FEED_TYPE_PEER) if (flags & RS_FEED_TYPE_PEER)
addFeedItemPeerHello(fi); addFeedItemPeerHello(fi);
@ -297,21 +318,9 @@ void NewsFeed::updateDisplay()
addFeedItemPeerOffset(fi); addFeedItemPeerOffset(fi);
break; break;
case RS_FEED_ITEM_SEC_CONNECT_ATTEMPT:
case RS_FEED_ITEM_SEC_WRONG_SIGNATURE:
case RS_FEED_ITEM_SEC_BAD_CERTIFICATE:
case RS_FEED_ITEM_SEC_MISSING_CERTIFICATE:
case RS_FEED_ITEM_SEC_INTERNAL_ERROR:
if (Settings->getMessageFlags() & RS_MESSAGE_CONNECT_ATTEMPT) {
MessageComposer::sendConnectAttemptMsg(RsPgpId(fi.mId1), RsPeerId(fi.mId2), QString::fromUtf8(fi.mId3.c_str()));
}
if (flags & RS_FEED_TYPE_SECURITY) if (flags & RS_FEED_TYPE_SECURITY)
addFeedItemSecurityConnectAttempt(fi); addFeedItemSecurityConnectAttempt(fi);
break; break;
case RS_FEED_ITEM_SEC_AUTH_DENIED:
if (flags & RS_FEED_TYPE_SECURITY)
addFeedItemSecurityAuthDenied(fi);
break;
case RS_FEED_ITEM_SEC_UNKNOWN_IN: case RS_FEED_ITEM_SEC_UNKNOWN_IN:
if (flags & RS_FEED_TYPE_SECURITY) if (flags & RS_FEED_TYPE_SECURITY)
addFeedItemSecurityUnknownIn(fi); addFeedItemSecurityUnknownIn(fi);
@ -321,11 +330,6 @@ void NewsFeed::updateDisplay()
addFeedItemSecurityUnknownOut(fi); addFeedItemSecurityUnknownOut(fi);
break; break;
case RS_FEED_ITEM_SEC_IP_BLACKLISTED:
if (flags & RS_FEED_TYPE_SECURITY_IP)
addFeedItemSecurityIpBlacklisted(fi, false);
break;
case RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED: case RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED:
if (flags & RS_FEED_TYPE_SECURITY_IP) if (flags & RS_FEED_TYPE_SECURITY_IP)
addFeedItemSecurityWrongExternalIpReported(fi, false); addFeedItemSecurityWrongExternalIpReported(fi, false);

View File

@ -103,6 +103,7 @@ private slots:
private: private:
void handleSecurityEvent(const RsAuthSslConnectionAutenticationEvent& e); void handleSecurityEvent(const RsAuthSslConnectionAutenticationEvent& e);
void handleConnectionEvent(const RsConnectionEvent& e);
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);

View File

@ -176,6 +176,8 @@ NewFriendList::NewFriendList(QWidget *parent) : /* RsAutoUpdatePage(5000,parent)
ui->filterLineEdit->setPlaceholderText(tr("Search")) ; ui->filterLineEdit->setPlaceholderText(tr("Search")) ;
ui->filterLineEdit->showFilterIcon(); ui->filterLineEdit->showFilterIcon();
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e) { handleEvent(e); }, mEventHandlerId );
mModel = new RsFriendListModel(); mModel = new RsFriendListModel();
mProxyModel = new FriendListSortFilterProxyModel(ui->peerTreeWidget->header(),this); mProxyModel = new FriendListSortFilterProxyModel(ui->peerTreeWidget->header(),this);
@ -236,8 +238,6 @@ NewFriendList::NewFriendList(QWidget *parent) : /* RsAutoUpdatePage(5000,parent)
connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()) , this, SLOT(forceUpdateDisplay()),Qt::QueuedConnection); connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()) , this, SLOT(forceUpdateDisplay()),Qt::QueuedConnection);
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)) , this, SLOT(forceUpdateDisplay()),Qt::QueuedConnection); connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)) , this, SLOT(forceUpdateDisplay()),Qt::QueuedConnection);
connect(NotifyQt::getInstance(), SIGNAL(peerConnected(const QString&)) , this, SLOT(forceUpdateDisplay()),Qt::QueuedConnection);
connect(NotifyQt::getInstance(), SIGNAL(peerDisconnected(const QString&)), this, SLOT(forceUpdateDisplay()),Qt::QueuedConnection);
connect(ui->actionShowOfflineFriends, SIGNAL(triggered(bool)), this, SLOT(setShowUnconnected(bool))); connect(ui->actionShowOfflineFriends, SIGNAL(triggered(bool)), this, SLOT(setShowUnconnected(bool)));
connect(ui->actionShowState, SIGNAL(triggered(bool)), this, SLOT(setShowState(bool)) ); connect(ui->actionShowState, SIGNAL(triggered(bool)), this, SLOT(setShowState(bool)) );
@ -254,6 +254,12 @@ NewFriendList::NewFriendList(QWidget *parent) : /* RsAutoUpdatePage(5000,parent)
} }
void NewFriendList::handleEvent(std::shared_ptr<const RsEvent> e)
{
if(dynamic_cast<const RsConnectionEvent*>(e.get()) != nullptr)
forceUpdateDisplay();
}
NewFriendList::~NewFriendList() NewFriendList::~NewFriendList()
{ {
delete ui; delete ui;

View File

@ -95,6 +95,7 @@ private slots:
protected: protected:
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
void handleEvent(std::shared_ptr<const RsEvent> e);
private: private:
Ui::NewFriendList *ui; Ui::NewFriendList *ui;
@ -117,6 +118,7 @@ private:
// Settings for peer list display // Settings for peer list display
bool mShowState; bool mShowState;
RsEventsHandlerId_t mEventHandlerId;
std::set<RsNodeGroupId> openGroups; std::set<RsNodeGroupId> openGroups;
std::set<RsPgpId> openPeers; std::set<RsPgpId> openPeers;

View File

@ -89,10 +89,6 @@ void NotifyQt::SetDisableAll(bool bValue)
} }
} }
NotifyQt::~NotifyQt()
{
}
NotifyQt::NotifyQt() : cDialog(NULL) NotifyQt::NotifyQt() : cDialog(NULL)
{ {
runningToasterTimer = new QTimer(this); runningToasterTimer = new QTimer(this);
@ -740,27 +736,6 @@ void NotifyQt::notifyListChange(int list, int type)
return; return;
} }
void NotifyQt::notifyPeerConnected(const std::string& peer_id)
{
{
QMutexLocker m(&_mutex) ;
if(!_enabled)
return ;
}
emit peerConnected(QString::fromStdString(peer_id));
}
void NotifyQt::notifyPeerDisconnected(const std::string& peer_id)
{
{
QMutexLocker m(&_mutex) ;
if(!_enabled)
return ;
}
emit peerDisconnected(QString::fromStdString(peer_id));
}
void NotifyQt::notifyListPreChange(int list, int /*type*/) void NotifyQt::notifyListPreChange(int list, int /*type*/)
{ {
{ {

View File

@ -56,12 +56,10 @@ class NotifyQt: public QObject, public NotifyClient
static bool isAllDisable(); static bool isAllDisable();
void enable() ; void enable() ;
virtual ~NotifyQt() ; virtual ~NotifyQt() = default;
void setNetworkDialog(NetworkDialog *c) { cDialog = c; } void setNetworkDialog(NetworkDialog *c) { cDialog = c; }
virtual void notifyPeerConnected(const std::string& /* peer_id */);
virtual void notifyPeerDisconnected(const std::string& /* peer_id */);
virtual void notifyListPreChange(int list, int type); virtual void notifyListPreChange(int list, int type);
virtual void notifyListChange(int list, int type); virtual void notifyListChange(int list, int type);
virtual void notifyErrorMsg(int list, int sev, std::string msg); virtual void notifyErrorMsg(int list, int sev, std::string msg);
@ -122,8 +120,6 @@ class NotifyQt: public QObject, public NotifyClient
// It's beneficial to send info to the GUI using signals, because signals are thread-safe // It's beneficial to send info to the GUI using signals, because signals are thread-safe
// as they get queued by Qt. // as they get queued by Qt.
// //
void peerConnected(const QString&) const ;
void peerDisconnected(const QString&) const ;
void hashingInfoChanged(const QString&) const ; void hashingInfoChanged(const QString&) const ;
void filesPreModChanged(bool) const ; void filesPreModChanged(bool) const ;
void filesPostModChanged(bool) const ; void filesPostModChanged(bool) const ;