From 2edb3afc8152745d0103e3feecd77284de818224 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 7 Jun 2025 15:50:24 +0200 Subject: [PATCH 01/38] moved hashing status info from notify to rsEvents --- retroshare-gui/src/gui/common/HashBox.cpp | 2 +- retroshare-gui/src/gui/notifyqt.cpp | 47 ++++---- retroshare-gui/src/gui/notifyqt.h | 14 +-- .../src/gui/statusbar/hashingstatus.cpp | 111 +++++++++--------- .../src/gui/statusbar/hashingstatus.h | 1 - retroshare-gui/src/main.cpp | 4 +- 6 files changed, 90 insertions(+), 89 deletions(-) diff --git a/retroshare-gui/src/gui/common/HashBox.cpp b/retroshare-gui/src/gui/common/HashBox.cpp index 0a96068e5..44f2ebeb7 100644 --- a/retroshare-gui/src/gui/common/HashBox.cpp +++ b/retroshare-gui/src/gui/common/HashBox.cpp @@ -259,7 +259,7 @@ void HashBox::checkAttachmentReady() emit fileHashingFinished(hashedFiles); auto ev = std::make_shared(); - ev->mEventCode = RsSharedDirectoriesEventCode::DIRECTORY_SWEEP_ENDED; + ev->mEventCode = RsSharedDirectoriesEventCode::HASHING_PROCESS_FINISHED; if(rsEvents) rsEvents->postEvent(ev); } diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index d2dee5ac4..67a61ff7a 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -109,15 +109,15 @@ NotifyQt::NotifyQt() : cDialog(NULL) qRegisterMetaType("RsGxsId"); } -void NotifyQt::notifyErrorMsg(int list, int type, std::string msg) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - emit errorOccurred(list,type,QString::fromUtf8(msg.c_str())) ; -} +//void NotifyQt::notifyErrorMsg(int list, int type, std::string msg) +//{ +// { +// QMutexLocker m(&_mutex) ; +// if(!_enabled) +// return ; +// } +// emit errorOccurred(list,type,QString::fromUtf8(msg.c_str())) ; +//} void NotifyQt::notifyChatMessage(const ChatMessage &msg) { @@ -477,10 +477,10 @@ void NotifyQt::notifyChatCleared(const ChatId& chat_id) emit chatCleared(chat_id); } -void NotifyQt::notifyTurtleSearchResult(uint32_t /*search_id*/,const std::list& /*found_groups*/) -{ - std::cerr << "(EE) missing code to handle GXS turtle search result." << std::endl; -} +//void NotifyQt::notifyTurtleSearchResult(uint32_t /*search_id*/,const std::list& /*found_groups*/) +//{ +// std::cerr << "(EE) missing code to handle GXS turtle search result." << std::endl; +//} #ifdef TO_REMOVE // Mai 2023: distant turtle search now uses RsEvents. @@ -564,16 +564,6 @@ void NotifyQt::notifyListChange(int list, int type) #endif emit filesPostModChanged(false) ; /* Local */ break; - case NOTIFY_LIST_SEARCHLIST: - break; - case NOTIFY_LIST_CHANNELLIST: - break; - case NOTIFY_LIST_TRANSFERLIST: -#ifdef NOTIFY_DEBUG - std::cerr << "received transfer changed" << std::endl ; -#endif - emit transfersChanged() ; - break; case NOTIFY_LIST_CONFIG: #ifdef NOTIFY_DEBUG std::cerr << "received config changed" << std::endl ; @@ -582,6 +572,17 @@ void NotifyQt::notifyListChange(int list, int type) break ; #ifdef REMOVE + case NOTIFY_LIST_SEARCHLIST: + break; + case NOTIFY_LIST_CHANNELLIST: + break; + case NOTIFY_LIST_TRANSFERLIST: +#ifdef NOTIFY_DEBUG + std::cerr << "received transfer changed" << std::endl ; +#endif + emit transfersChanged() ; + break; + case NOTIFY_LIST_FORUMLIST_LOCKED: #ifdef NOTIFY_DEBUG std::cerr << "received forum msg changed" << std::endl ; diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index 5782ef5b7..3ee7180d3 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -62,15 +62,15 @@ class NotifyQt: public QObject, public NotifyClient virtual void notifyListPreChange(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); virtual void notifyChatMessage(const ChatMessage& /* msg */); virtual void notifyChatStatus(const ChatId &chat_id,const std::string& status_string); virtual void notifyChatCleared(const ChatId &chat_id); virtual void notifyCustomState(const std::string& peer_id, const std::string& status_string); -#ifdef TO_REMOVE - virtual void notifyTurtleSearchResult(const RsPeerId &pid, uint32_t search_id, const std::list& found_files); -#endif - virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list& found_groups); +//#ifdef TO_REMOVE +// virtual void notifyTurtleSearchResult(const RsPeerId &pid, uint32_t search_id, const std::list& found_files); +//#endif +// virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list& found_groups); virtual void notifyPeerHasNewAvatar(std::string peer_id) ; virtual void notifyOwnAvatarChanged() ; virtual void notifyChatLobbyEvent(uint64_t /* lobby id */, uint32_t /* event type */, const RsGxsId & /*nickname*/, const std::string& /* any string */) ; @@ -107,7 +107,7 @@ class NotifyQt: public QObject, public NotifyClient void hashingInfoChanged(const QString&) const ; void filesPreModChanged(bool) const ; void filesPostModChanged(bool) const ; - void transfersChanged() const ; +// void transfersChanged() const ; void friendsChanged() const ; void lobbyListChanged() const ; void chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&) ; @@ -130,7 +130,7 @@ class NotifyQt: public QObject, public NotifyClient void discInfoChanged() const ; void historyChanged(uint msgId, int type); void chatLobbyInviteReceived() ; - void deferredSignatureHandlingRequested() ; +// void deferredSignatureHandlingRequested() ; void chatLobbyTimeShift(int time_shift) ; void connectionWithoutCert(); diff --git a/retroshare-gui/src/gui/statusbar/hashingstatus.cpp b/retroshare-gui/src/gui/statusbar/hashingstatus.cpp index fc57bb286..283c92028 100644 --- a/retroshare-gui/src/gui/statusbar/hashingstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/hashingstatus.cpp @@ -27,6 +27,7 @@ #include "hashingstatus.h" #include "gui/common/ElidedLabel.h" #include "util/qtthreadsutils.h" +#include "util/misc.h" #include "gui/notifyqt.h" #include "gui/common/FilesDefs.h" @@ -69,27 +70,66 @@ void HashingStatus::handleEvent_main_thread(std::shared_ptr event if(!fe) return; - QString info; + std::cerr << "HashStatusEventHandler: received event " << (void*)fe->mEventCode << std::endl; switch (fe->mEventCode) { default: - case RsSharedDirectoriesEventCode::STARTING_DIRECTORY_SWEEP: - info = tr("Examining shared files..."); - break; - case RsSharedDirectoriesEventCode::DIRECTORY_SWEEP_ENDED: - break; - case RsSharedDirectoriesEventCode::HASHING_FILE: - info = tr("Hashing file") + " " + QString::fromUtf8(fe->mMessage.c_str()); - break; + + case RsSharedDirectoriesEventCode::HASHING_PROCESS_RESUMED: + statusHashing->setText(mLastText); // fallthrough + case RsSharedDirectoriesEventCode::HASHING_PROCESS_STARTED: + { + hashloader->show() ; + hashloader->setMovie(movie) ; + movie->start() ; + + statusHashing->setVisible(!_compactMode) ; + } + break; + + case RsSharedDirectoriesEventCode::HASHING_PROCESS_PAUSED: + { + movie->stop() ; + hashloader->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/resume.png")) ; + + mLastText = statusHashing->text(); + statusHashing->setText(QObject::tr("[Hashing is paused]")); + setToolTip(QObject::tr("Click to resume the hashing process")); + } + break; + + case RsSharedDirectoriesEventCode::HASHING_PROCESS_FINISHED: + { + movie->stop() ; + statusHashing->setText(QString()); + statusHashing->hide() ; + setToolTip(QString()); + hashloader->hide() ; + } + break; + + case RsSharedDirectoriesEventCode::HASHING_FILE: + { + QString msg = QString::number((unsigned long int)fe->mHashCounter+1) + "/" + QString::number((unsigned long int)fe->mTotalFilesToHash); + + msg += " (" + misc::friendlyUnit(fe->mTotalHashedSize) + " - " + + QString::number(int(fe->mTotalHashedSize/double(fe->mTotalSizeToHash)*100.0)) + "%" + + ((fe->mHashingSpeed>0)?("," + QString::number((double)fe->mHashingSpeed,'f',2) + " MB/s)"):(QString())) + + " : " + QString::fromUtf8(fe->mFilePath.c_str()) ; + + statusHashing->setText(tr("Hashing file") + " " + msg); + setToolTip(msg + "\n"+QObject::tr("Click to pause the hashing process")); + } + break; + case RsSharedDirectoriesEventCode::SAVING_FILE_INDEX: - info = tr("Saving file index..."); - break; - } + { + statusHashing->setText(tr("Saving file index...")); + } + break; - // GUI calls should only happen in the GUI thread, which is achieved by postToObject(). - - updateHashingInfo(info); + }; } HashingStatus::~HashingStatus() @@ -98,47 +138,8 @@ HashingStatus::~HashingStatus() delete(movie); } -void HashingStatus::updateHashingInfo(const QString& s) -{ - if (s.isEmpty()) - { - statusHashing->hide() ; - hashloader->hide() ; - setToolTip(QString()); - - movie->stop() ; - } else { - setToolTip(s + "\n"+QObject::tr("Click to pause the hashing process")); - - if (_compactMode) { - statusHashing->hide() ; - } else { - statusHashing->setText(s) ; - statusHashing->show() ; - } - hashloader->show() ; - - movie->start() ; - } -} - void HashingStatus::mousePressEvent(QMouseEvent *) { rsFiles->togglePauseHashingProcess() ; - - if(rsFiles->hashingProcessPaused()) - { - movie->stop() ; - hashloader->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/resume.png")) ; - - mLastText = statusHashing->text(); - statusHashing->setText(QObject::tr("[Hashing is paused]")); - setToolTip(QObject::tr("Click to resume the hashing process")); - } - else - { - hashloader->setMovie(movie) ; - statusHashing->setText(mLastText); - movie->start() ; - } } + diff --git a/retroshare-gui/src/gui/statusbar/hashingstatus.h b/retroshare-gui/src/gui/statusbar/hashingstatus.h index 8f09120a1..180206088 100644 --- a/retroshare-gui/src/gui/statusbar/hashingstatus.h +++ b/retroshare-gui/src/gui/statusbar/hashingstatus.h @@ -39,7 +39,6 @@ public: void mousePressEvent(QMouseEvent *); private: - void updateHashingInfo(const QString& s); void handleEvent_main_thread(std::shared_ptr event); ElidedLabel *statusHashing; diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 228f24067..c349df404 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -725,11 +725,11 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); #ifdef DEBUG std::cerr << "connecting signals and slots" << std::endl ; #endif - QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ; +// QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(chatLobbyTimeShift(int)),notify,SLOT(handleChatLobbyTimeShift(int)),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool)) ,Qt::QueuedConnection ) ; - QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; +// QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ; From df02d745d83881e0cd78591a16c6655274ad347d Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 11 Jun 2025 20:50:38 +0200 Subject: [PATCH 02/38] removed friendsChanged() and NOTIFY_LIST_FRIENDS --- .../src/gui/FriendServerControl.cpp | 2 +- retroshare-gui/src/gui/MainWindow.cpp | 30 ++- retroshare-gui/src/gui/MainWindow.h | 4 + retroshare-gui/src/gui/NewsFeed.cpp | 16 +- .../src/gui/common/FriendSelectionWidget.cpp | 10 +- .../src/gui/common/NewFriendList.cpp | 4 +- .../src/gui/connect/ConnectFriendWizard.cpp | 184 ------------------ retroshare-gui/src/gui/feeds/PeerItem.cpp | 19 +- retroshare-gui/src/gui/feeds/PeerItem.h | 1 + retroshare-gui/src/gui/feeds/SecurityItem.cpp | 19 +- retroshare-gui/src/gui/feeds/SecurityItem.h | 2 + retroshare-gui/src/gui/notifyqt.cpp | 4 + retroshare-gui/src/gui/notifyqt.h | 2 +- retroshare-gui/src/retroshare-gui.pro | 9 +- 14 files changed, 91 insertions(+), 215 deletions(-) diff --git a/retroshare-gui/src/gui/FriendServerControl.cpp b/retroshare-gui/src/gui/FriendServerControl.cpp index 7b031e7e2..a4afd4537 100644 --- a/retroshare-gui/src/gui/FriendServerControl.cpp +++ b/retroshare-gui/src/gui/FriendServerControl.cpp @@ -118,7 +118,7 @@ FriendServerControl::FriendServerControl(QWidget *parent) rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this ); - }, mEventHandlerId_peer, RsEventType::PEER_CONNECTION ); + }, mEventHandlerId_peer, RsEventType::PEER_STATE ); } void FriendServerControl::onAutoAddFriends(bool b) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index da25bc2c6..a8ed9bc5d 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -30,9 +30,10 @@ #include #include -#include -#include -#include +#include "retroshare/rsplugin.h" +#include "retroshare/rsconfig.h" +#include "util/argstream.h" +#include "util/qtthreadsutils.h" #if defined(Q_OS_DARWIN) #include "gui/common/MacDockIconHandler.h" @@ -340,10 +341,27 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) createNotifyIcons(); - /* calculate friend count */ + /* intialize friend count */ updateFriends(); - connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateFriends())); - connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateFriends())); + +// connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateFriends())); +// connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateFriends())); + + mEventHandlerId = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); + + if(!fe) + return; + + updateFriends(); + } + , this ); + }, mEventHandlerId, RsEventType::FRIEND_LIST ); loadOwnStatus(); diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index b435524f0..218d84e47 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -25,6 +25,8 @@ #include #include +#include "retroshare/rsevents.h" + #include "gui/common/rwindow.h" #include "gui/common/RSComboBox.h" #include "util/FontSizeHandler.h" @@ -375,6 +377,8 @@ private: FontSizeHandler mFontSizeHandler; Ui::MainWindow *ui ; + + RsEventsHandlerId_t mEventHandlerId; }; #endif diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index dc0834e71..529556012 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -76,7 +76,7 @@ static NewsFeed* instance = nullptr; NewsFeed::NewsFeed(QWidget *parent) : MainPage(parent), ui(new Ui::NewsFeed), mEventTypes({ RsEventType::AUTHSSL_CONNECTION_AUTENTICATION, - RsEventType::PEER_CONNECTION , + RsEventType::FRIEND_LIST , RsEventType::GXS_CIRCLES , RsEventType::GXS_CHANNELS , RsEventType::GXS_FORUMS , @@ -197,7 +197,7 @@ void NewsFeed::handleEvent_main_thread(std::shared_ptr event) if(event->mType == RsEventType::AUTHSSL_CONNECTION_AUTENTICATION && (flags & RS_FEED_TYPE_SECURITY)) handleSecurityEvent(event); - if(event->mType == RsEventType::PEER_CONNECTION && (flags & RS_FEED_TYPE_PEER)) + if(event->mType == RsEventType::FRIEND_LIST && (flags & RS_FEED_TYPE_PEER)) handleConnectionEvent(event); if(event->mType == RsEventType::GXS_CIRCLES && (flags & RS_FEED_TYPE_CIRCLE)) @@ -428,7 +428,7 @@ void NewsFeed::handleCircleEvent(std::shared_ptr event) void NewsFeed::handleConnectionEvent(std::shared_ptr event) { - const RsConnectionEvent *pe = dynamic_cast(event.get()); + const RsFriendListEvent *pe = dynamic_cast(event.get()); if(!pe) return; auto& e(*pe); @@ -437,18 +437,18 @@ void NewsFeed::handleConnectionEvent(std::shared_ptr event) std::cerr << "NotifyQt: handling connection event from peer " << e.mSslId << std::endl; #endif - switch(e.mConnectionInfoCode) + switch(e.mEventCode) { - case RsConnectionEventCode::PEER_CONNECTED: + case RsFriendListEventCode::NODE_CONNECTED: addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_CONNECT, false), true); NotifyQt::getInstance()->addToaster(RS_POPUP_CONNECT, e.mSslId.toStdString().c_str(), "", ""); break; - case RsConnectionEventCode::PEER_DISCONNECTED: // not handled yet + case RsFriendListEventCode::NODE_DISCONNECTED: // not handled yet break; - case RsConnectionEventCode::PEER_TIME_SHIFT: + case RsFriendListEventCode::NODE_TIME_SHIFT: addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_OFFSET, false),false); break; - case RsConnectionEventCode::PEER_REPORTS_WRONG_IP: + case RsFriendListEventCode::NODE_REPORTS_WRONG_IP: addFeedItemIfUnique(new SecurityIpItem( this, e.mSslId, e.mOwnLocator.toString(), e.mReportedLocator.toString(), diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index d9fc4b8dc..6e7e89b58 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -134,7 +134,7 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }) ;}, mEventHandlerId_identities, RsEventType::GXS_IDENTITY ); mEventHandlerId_peers = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr event) { - RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }) ;}, mEventHandlerId_peers, RsEventType::PEER_CONNECTION ); + RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }) ;}, mEventHandlerId_peers, RsEventType::FRIEND_LIST ); mFontSizeHandler.registerFontSize(ui->friendList); } @@ -149,13 +149,13 @@ void FriendSelectionWidget::handleEvent_main_thread(std::shared_ptr(event.get()); + const RsFriendListEvent *fp = dynamic_cast(event.get()); if(fp) - switch(fp->mConnectionInfoCode) + switch(fp->mEventCode) { - case RsConnectionEventCode::PEER_REMOVED: - case RsConnectionEventCode::PEER_ADDED: + case RsFriendListEventCode::NODE_REMOVED: + case RsFriendListEventCode::NODE_ADDED: updateDisplay(true); update(); // Qt flush break; diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 38e141e86..34bc75de2 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -199,8 +199,8 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par mEventHandlerId_gssp=0; // forces initialization mEventHandlerId_pssc=0; // forces initialization - rsEvents->registerEventsHandler( [this](std::shared_ptr e) { handleEvent(e); }, mEventHandlerId_pssc, RsEventType::PEER_STATE_CHANGED ); - rsEvents->registerEventsHandler( [this](std::shared_ptr e) { handleEvent(e); }, mEventHandlerId_peer, RsEventType::PEER_CONNECTION ); +// rsEvents->registerEventsHandler( [this](std::shared_ptr e) { handleEvent(e); }, mEventHandlerId_pssc, RsEventType::PEER_STATE_CHANGED ); + rsEvents->registerEventsHandler( [this](std::shared_ptr e) { handleEvent(e); }, mEventHandlerId_peer, RsEventType::FRIEND_LIST ); rsEvents->registerEventsHandler( [this](std::shared_ptr e) { handleEvent(e); }, mEventHandlerId_gssp, RsEventType::GOSSIP_DISCOVERY ); connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(QString)), this, SLOT(forceUpdateDisplay())); diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index 7ffdcd687..2e2c5e789 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -968,190 +968,6 @@ void ConnectFriendWizard::openCert() } } -#ifdef TO_BE_REMOVED -//========================== CertificatePage ================================= - -void ConnectFriendWizard::loadFriendCert() -{ - QString fileName ; - if(!misc::getOpenFileName(this, RshareSettings::LASTDIR_CERT, tr("Select Certificate"), tr("RetroShare Certificate (*.rsc );;All Files (*)"),fileName)) - return ; - - if (!fileName.isNull()) { - ui->friendFileNameEdit->setText(fileName); - } -} - -void ConnectFriendWizard::generateCertificateCalled() -{ -#ifdef FRIEND_WIZARD_DEBUG - std::cerr << " generateCertificateCalled" << std::endl; -#endif - - std::string cert = rsPeers->GetRetroshareInvite(); - if (cert.empty()) { - QMessageBox::information(this, "RetroShare", tr("Sorry, create certificate failed"), QMessageBox::Ok, QMessageBox::Ok); - return; - } - - QString qdir = QFileDialog::getSaveFileName(this, tr("Please choose a filename"), QDir::homePath(), tr("RetroShare Certificate (*.rsc );;All Files (*)")); - - //Todo: move save to file to p3Peers::SaveCertificateToFile - - if (qdir.isEmpty() == false) { - QFile CertFile(qdir); - if (CertFile.open(QIODevice::WriteOnly/* | QIODevice::Text*/)) { - if (CertFile.write(QByteArray(cert.c_str())) > 0) { - QMessageBox::information(this, "RetroShare", tr("Certificate file successfully created"), QMessageBox::Ok, QMessageBox::Ok); - } else { - QMessageBox::information(this, "RetroShare", tr("Sorry, certificate file creation failed"), QMessageBox::Ok, QMessageBox::Ok); - } - CertFile.close(); - } else { - QMessageBox::information(this, "RetroShare", tr("Sorry, certificate file creation failed"), QMessageBox::Ok, QMessageBox::Ok); - } - } -} - -//============================= FofPage ====================================== - -void ConnectFriendWizard::updatePeersList(int index) -{ - - ui->selectedPeersTW->clearContents(); - ui->selectedPeersTW->setRowCount(0); - - RsPgpId ownId = rsPeers->getGPGOwnId(); - - int row = 0; - - _id_boxes.clear(); - - // We have to use this trick because signers are given by their names instead of their ids. That's a cause - // for some confusion when two peers have the same name. - // - std::list gpg_ids; - rsPeers->getGPGAllList(gpg_ids); - for (std::list::const_iterator it(gpg_ids.begin()); it != gpg_ids.end(); ++it) { - if (*it == ownId) { - // its me - continue; - } - -#ifdef FRIEND_WIZARD_DEBUG - std::cerr << "examining peer " << *it << " (name=" << rsPeers->getPeerName(*it); -#endif - - RsPeerDetails details ; - if (!rsPeers->getGPGDetails(*it,details)) { -#ifdef FRIEND_WIZARD_DEBUG - std::cerr << " no details." << std::endl ; -#endif - continue; - } - - // determine common friends - - std::list common_friends; - - for (std::list::const_iterator it2(details.gpgSigners.begin()); it2 != details.gpgSigners.end(); ++it2) { - if(rsPeers->isGPGAccepted(*it2)) { - common_friends.push_back(*it2); - } - } - bool show = false; - - switch(index) { - case 0: // "All unsigned friends of my friends" - show = !details.ownsign; -#ifdef FRIEND_WIZARD_DEBUG - std::cerr << "case 0: ownsign=" << details.ownsign << ", show=" << show << std::endl; -#endif - break ; - case 1: // "Unsigned peers who already signed my certificate" - show = details.hasSignedMe && !(details.state & RS_PEER_STATE_FRIEND); -#ifdef FRIEND_WIZARD_DEBUG - std::cerr << "case 1, ownsign=" << details.ownsign << ", is_authed_me=" << details.hasSignedMe << ", show=" << show << std::endl; -#endif - break ; - case 2: // "Peers shown as denied" - show = details.ownsign && !(details.state & RS_PEER_STATE_FRIEND); -#ifdef FRIEND_WIZARD_DEBUG - std::cerr << "case 2, ownsign=" << details.ownsign << ", state_friend=" << (details.state & RS_PEER_STATE_FRIEND) << ", show=" << show << std::endl; -#endif - break ; - } - - if (show) { - ui->selectedPeersTW->insertRow(row); - - QCheckBox *cb = new QCheckBox; - cb->setChecked(true); - _id_boxes[cb] = details.id; - _gpg_id_boxes[cb] = details.gpg_id; - - ui->selectedPeersTW->setCellWidget(row, 0, cb); - ui->selectedPeersTW->setItem(row, 1, new QTableWidgetItem(QString::fromUtf8(details.name.c_str()))); - - QComboBox *qcb = new QComboBox; - - if (common_friends.empty()) { - qcb->addItem(tr("*** None ***")); - } else { - for (std::list::const_iterator it2(common_friends.begin()); it2 != common_friends.end(); ++it2) { - qcb->addItem(QString::fromStdString( (*it2).toStdString())); - } - } - - ui->selectedPeersTW->setCellWidget(row, 2, qcb); - ui->selectedPeersTW->setItem(row, 3, new QTableWidgetItem(QString::fromStdString(details.id.toStdString()))); - ++row; - } - } -#ifdef FRIEND_WIZARD_DEBUG - std::cerr << "FofPage::updatePeersList() finished iterating over peers" << std::endl; -#endif - - if (row>0) { - ui->selectedPeersTW->resizeColumnsToContents(); - ui->makeFriendButton->setEnabled(true); - } else { - ui->makeFriendButton->setEnabled(false); - } -} - -void ConnectFriendWizard::signAllSelectedUsers() -{ -#ifdef FRIEND_WIZARD_DEBUG - std::cerr << "making lots of friends !!" << std::endl; -#endif - - for (std::map::const_iterator it(_id_boxes.begin()); it != _id_boxes.end(); ++it) { - if (it->first->isChecked()) { -#ifdef FRIEND_WIZARD_DEBUG - std::cerr << "Making friend with " << it->second << std::endl ; -#endif - //rsPeers->AuthCertificate(it->second, ""); - rsPeers->addFriend(it->second, _gpg_id_boxes[it->first]); - } - } - - ui->FofPage->setComplete(true); - - ui->userSelectionCB->setEnabled(false); - ui->selectedPeersTW->setEnabled(false); - ui->makeFriendButton->setEnabled(false); - - NotifyQt::getInstance()->notifyListChange(NOTIFY_LIST_NEIGHBOURS,0); - NotifyQt::getInstance()->notifyListChange(NOTIFY_LIST_FRIENDS,0); -} - -//============================= RsidPage ===================================== - - -//============================ Emailpage ===================================== -#endif - //========================= ErrorMessagePage ================================= //========================== ConclusionPage ================================== diff --git a/retroshare-gui/src/gui/feeds/PeerItem.cpp b/retroshare-gui/src/gui/feeds/PeerItem.cpp index 7961abce2..43112ced6 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.cpp +++ b/retroshare-gui/src/gui/feeds/PeerItem.cpp @@ -28,6 +28,7 @@ #include "gui/common/StatusDefs.h" #include "gui/common/FilesDefs.h" #include "gui/common/AvatarDefs.h" +#include "util/qtthreadsutils.h" #include "util/DateTime.h" #include "gui/notifyqt.h" @@ -58,7 +59,23 @@ PeerItem::PeerItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId, connect( chatButton, SIGNAL( clicked() ), this, SLOT( openChat() ) ); connect( sendmsgButton, SIGNAL( clicked() ), this, SLOT( sendMsg() ) ); - connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateItem())); + //connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateItem())); + + mEventHandlerId = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); + + if(!fe) + return; + + updateItem(); + } + , this ); + }, mEventHandlerId, RsEventType::FRIEND_LIST ); avatar->setId(ChatId(mPeerId));// TODO: remove unnecesary converstation diff --git a/retroshare-gui/src/gui/feeds/PeerItem.h b/retroshare-gui/src/gui/feeds/PeerItem.h index 22b9bbaf0..7e38bb08f 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.h +++ b/retroshare-gui/src/gui/feeds/PeerItem.h @@ -66,6 +66,7 @@ private: RsPeerId mPeerId; uint32_t mType; bool mIsHome; + RsEventsHandlerId_t mEventHandlerId ; }; #endif diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.cpp b/retroshare-gui/src/gui/feeds/SecurityItem.cpp index 584eee212..0d0729125 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityItem.cpp @@ -33,6 +33,7 @@ #include "gui/connect/ConnectFriendWizard.h" #include "gui/common/AvatarDefs.h" #include "util/DateTime.h" +#include "util/qtthreadsutils.h" #include "gui/notifyqt.h" @@ -72,7 +73,23 @@ SecurityItem::SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &g connect( peerDetailsButton, SIGNAL(clicked()), this, SLOT(peerDetails())); connect( friendRequesttoolButton, SIGNAL(clicked()), this, SLOT(friendRequest())); - connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateItem())); + //connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateItem())); + + mEventHandlerId = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); + + if(!fe) + return; + + updateItem(); + } + , this ); + }, mEventHandlerId, RsEventType::FRIEND_LIST ); avatar->setId(ChatId(mSslId)); diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.h b/retroshare-gui/src/gui/feeds/SecurityItem.h index 7f99c8377..c9758107f 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.h +++ b/retroshare-gui/src/gui/feeds/SecurityItem.h @@ -67,6 +67,8 @@ private: std::string mIP; uint32_t mType; bool mIsHome; + + RsEventsHandlerId_t mEventHandlerId; }; #endif diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 67a61ff7a..253e66d73 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -540,12 +540,14 @@ void NotifyQt::notifyListChange(int list, int type) #endif emit neighboursChanged(); break; +#ifdef TO_REMOVE case NOTIFY_LIST_FRIENDS: #ifdef NOTIFY_DEBUG std::cerr << "received friends changed" << std::endl ; #endif emit friendsChanged() ; break; +#endif case NOTIFY_LIST_DIRLIST_LOCAL: #ifdef NOTIFY_DEBUG std::cerr << "received files changed" << std::endl ; @@ -644,9 +646,11 @@ void NotifyQt::notifyListPreChange(int list, int /*type*/) { case NOTIFY_LIST_NEIGHBOURS: break; +#ifdef TO_REMOVE case NOTIFY_LIST_FRIENDS: emit friendsChanged() ; break; +#endif case NOTIFY_LIST_DIRLIST_FRIENDS: emit filesPreModChanged(false) ; /* remote */ break ; diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index 3ee7180d3..a39f648c3 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -108,7 +108,7 @@ class NotifyQt: public QObject, public NotifyClient void filesPreModChanged(bool) const ; void filesPostModChanged(bool) const ; // void transfersChanged() const ; - void friendsChanged() const ; +// void friendsChanged() const ; void lobbyListChanged() const ; void chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&) ; void neighboursChanged() const ; diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 6f217db9c..99c373070 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -1045,12 +1045,9 @@ unfinishedtranslations { } messenger { - SOURCES += gui/MessengerWindow.cpp \ - gui/common/FriendList.cpp - HEADERS += gui/MessengerWindow.h \ - gui/common/FriendList.h - FORMS += gui/MessengerWindow.ui \ - gui/common/FriendList.ui + SOURCES += gui/MessengerWindow.cpp + HEADERS += gui/MessengerWindow.h + FORMS += gui/MessengerWindow.ui DEFiNES += MESSENGER_WINDOW } From 0ce2dd8486a85232e8aa8ffdec23a632aeff9d57 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 12 Jun 2025 21:12:47 +0200 Subject: [PATCH 03/38] removed groupsChanged and used rsEvents::FRIEND_LIST instead --- retroshare-gui/src/gui/MainWindow.cpp | 2 ++ retroshare-gui/src/gui/ShareManager.cpp | 20 +++++++++++- retroshare-gui/src/gui/ShareManager.h | 1 + .../src/gui/common/FriendSelectionWidget.cpp | 30 +++++++++++------ .../src/gui/common/FriendSelectionWidget.h | 6 ++-- .../src/gui/common/GroupSelectionBox.cpp | 32 ++++++++++++++++++- .../src/gui/common/GroupSelectionBox.h | 5 +++ .../src/gui/common/NewFriendList.cpp | 4 +-- retroshare-gui/src/gui/common/NewFriendList.h | 2 +- retroshare-gui/src/gui/feeds/PeerItem.cpp | 4 +++ retroshare-gui/src/gui/feeds/PeerItem.h | 1 + retroshare-gui/src/gui/feeds/SecurityItem.cpp | 4 +++ retroshare-gui/src/gui/feeds/SecurityItem.h | 1 + .../gui/gxschannels/GxsChannelPostsModel.cpp | 2 +- .../gui/gxschannels/GxsChannelPostsModel.h | 2 +- retroshare-gui/src/gui/notifyqt.cpp | 3 +- retroshare-gui/src/gui/notifyqt.h | 2 +- .../src/gui/settings/ServerPage.cpp | 6 +++- retroshare-gui/src/gui/settings/ServerPage.h | 2 +- 19 files changed, 106 insertions(+), 23 deletions(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index a8ed9bc5d..8803783a4 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -390,6 +390,8 @@ MainWindow::~MainWindow() Settings->setValueToGroup("MainWindow", "SplitterState", ui->splitter->saveState()); Settings->setValueToGroup("MainWindow", "State", saveState()); + rsEvents->unregisterEventsHandler(mEventHandlerId); + delete statusComboBox; delete peerstatus; delete natstatus; diff --git a/retroshare-gui/src/gui/ShareManager.cpp b/retroshare-gui/src/gui/ShareManager.cpp index 6681e30c5..f22d4182a 100644 --- a/retroshare-gui/src/gui/ShareManager.cpp +++ b/retroshare-gui/src/gui/ShareManager.cpp @@ -38,6 +38,7 @@ #include "gui/notifyqt.h" #include "util/QtVersion.h" #include "util/misc.h" +#include "util/qtthreadsutils.h" #include "gui/common/FilesDefs.h" /* Images for context menu icons */ @@ -73,7 +74,23 @@ ShareManager::ShareManager() connect(ui.shareddirList, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(doubleClickedCell(int,int))); connect(ui.shareddirList, SIGNAL(cellChanged(int,int)), this, SLOT(handleCellChange(int,int))); - connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(reload())); + // connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(reload())); + + mEventHandlerId = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); + + if(!fe) + return; + + reload(); + } + , this ); + }, mEventHandlerId, RsEventType::FRIEND_LIST ); QHeaderView* header = ui.shareddirList->horizontalHeader(); QHeaderView_setSectionResizeModeColumn(header, COLUMN_PATH, QHeaderView::Stretch); @@ -152,6 +169,7 @@ ShareManager::~ShareManager() { _instance = NULL; + rsEvents->unregisterEventsHandler(mEventHandlerId); Settings->saveWidgetInformation(this); } diff --git a/retroshare-gui/src/gui/ShareManager.h b/retroshare-gui/src/gui/ShareManager.h index 1ddfaa0a9..b6d579894 100644 --- a/retroshare-gui/src/gui/ShareManager.h +++ b/retroshare-gui/src/gui/ShareManager.h @@ -77,6 +77,7 @@ private: Ui::ShareManager ui; std::vector mDirInfos ; + RsEventsHandlerId_t mEventHandlerId; }; #endif diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index 6e7e89b58..3c7ba5a29 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -101,8 +101,8 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) connect(ui->friendList, SIGNAL(itemSelectionChanged()), this, SIGNAL(itemSelectionChanged())); connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString))); - connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(groupsChanged(int))); - connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&,int)), this, SLOT(peerStatusChanged(const QString&,int))); + //connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(groupsChanged(int))); + //connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&,int)), this, SLOT(peerStatusChanged(const QString&,int))); mCompareRole = new RSTreeWidgetItemCompareRole; mActionSortByState = new QAction(tr("Sort by state"), this); @@ -159,7 +159,21 @@ void FriendSelectionWidget::handleEvent_main_thread(std::shared_ptrgetStatus(fp->mSslId,i); + + peerStatusChanged(fp->mSslId,i.status); + } + default: + break ; } } @@ -770,21 +784,18 @@ template<> inline void FriendSelectionWidget::setSelectedIdsdata(COLUMN_DATA, ROLE_ID).toString() == peerId) { + if (RsPeerId(item->data(COLUMN_DATA, ROLE_ID).toString().toStdString()) == peerid) + { if (status != (int) RS_STATUS_OFFLINE) { item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline()); } else { diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.h b/retroshare-gui/src/gui/common/FriendSelectionWidget.h index 425e16774..c01c888e7 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.h +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.h @@ -137,8 +137,7 @@ public slots: void filterConnected(bool filter); private slots: - void groupsChanged(int type); - void peerStatusChanged(const QString& peerId, int status); + void peerStatusChanged(const RsPeerId &peerid, int status); void filterItems(const QString &text); void contextMenuRequested(const QPoint &pos); void itemDoubleClicked(QTreeWidgetItem *item, int column); @@ -147,7 +146,8 @@ private slots: void deselectAll() ; private: - void fillList(); + void groupsChanged(); + void fillList(); void secured_fillList(); void selectedIds_internal(IdType idType, std::set &ids, bool onlyDirectSelected); diff --git a/retroshare-gui/src/gui/common/GroupSelectionBox.cpp b/retroshare-gui/src/gui/common/GroupSelectionBox.cpp index 18cdff34d..1a1f27a39 100644 --- a/retroshare-gui/src/gui/common/GroupSelectionBox.cpp +++ b/retroshare-gui/src/gui/common/GroupSelectionBox.cpp @@ -24,6 +24,7 @@ #include "GroupSelectionBox.h" #include "GroupDefs.h" #include "gui/notifyqt.h" +#include "util/qtthreadsutils.h" #include @@ -34,11 +35,40 @@ GroupSelectionBox::GroupSelectionBox(QWidget *parent) { setSelectionMode(QAbstractItemView::SingleSelection); - connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(fillGroups())); + //connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(fillGroups())); + + mEventHandlerId = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); + + if(!fe) + return; + + switch(fe->mEventCode) + { + case RsFriendListEventCode::GROUP_ADDED: + case RsFriendListEventCode::GROUP_REMOVED: + case RsFriendListEventCode::GROUP_CHANGED: fillGroups(); + + default: + break; + } + } + , this ); + }, mEventHandlerId, RsEventType::FRIEND_LIST ); // Fill with available groups fillGroups(); } + +GroupSelectionBox::~GroupSelectionBox() +{ + rsEvents->unregisterEventsHandler(mEventHandlerId); +} void GroupSelectionBox::fillGroups() { std::list selectedIds; diff --git a/retroshare-gui/src/gui/common/GroupSelectionBox.h b/retroshare-gui/src/gui/common/GroupSelectionBox.h index 09ae741c2..6cd4ac9cb 100644 --- a/retroshare-gui/src/gui/common/GroupSelectionBox.h +++ b/retroshare-gui/src/gui/common/GroupSelectionBox.h @@ -21,6 +21,7 @@ #include #include #include +#include class GroupSelectionBox: public QListWidget { @@ -28,6 +29,7 @@ class GroupSelectionBox: public QListWidget public: GroupSelectionBox(QWidget *parent); + virtual ~GroupSelectionBox(); static void selectGroups(const std::list& default_groups) ; @@ -38,6 +40,9 @@ public: private slots: void fillGroups(); + +private: + RsEventsHandlerId_t mEventHandlerId ; }; class GroupSelectionDialog: public QDialog diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 34bc75de2..86966d7fd 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -195,9 +195,9 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par ui->filterLineEdit->setPlaceholderText(tr("Search")) ; ui->filterLineEdit->showFilterIcon(); +// mEventHandlerId_pssc=0; // forces initialization mEventHandlerId_peer=0; // forces initialization mEventHandlerId_gssp=0; // forces initialization - mEventHandlerId_pssc=0; // forces initialization // rsEvents->registerEventsHandler( [this](std::shared_ptr e) { handleEvent(e); }, mEventHandlerId_pssc, RsEventType::PEER_STATE_CHANGED ); rsEvents->registerEventsHandler( [this](std::shared_ptr e) { handleEvent(e); }, mEventHandlerId_peer, RsEventType::FRIEND_LIST ); @@ -293,7 +293,7 @@ NewFriendList::~NewFriendList() { rsEvents->unregisterEventsHandler(mEventHandlerId_peer); rsEvents->unregisterEventsHandler(mEventHandlerId_gssp); - rsEvents->unregisterEventsHandler(mEventHandlerId_pssc); +// rsEvents->unregisterEventsHandler(mEventHandlerId_pssc); delete mModel; delete mProxyModel; diff --git a/retroshare-gui/src/gui/common/NewFriendList.h b/retroshare-gui/src/gui/common/NewFriendList.h index cf4c68e6f..18a7d4b97 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.h +++ b/retroshare-gui/src/gui/common/NewFriendList.h @@ -127,7 +127,7 @@ private: bool mShowState; RsEventsHandlerId_t mEventHandlerId_peer; RsEventsHandlerId_t mEventHandlerId_gssp; - RsEventsHandlerId_t mEventHandlerId_pssc; +// RsEventsHandlerId_t mEventHandlerId_pssc; std::set openGroups; std::set openPeers; diff --git a/retroshare-gui/src/gui/feeds/PeerItem.cpp b/retroshare-gui/src/gui/feeds/PeerItem.cpp index 43112ced6..388f3cbc8 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.cpp +++ b/retroshare-gui/src/gui/feeds/PeerItem.cpp @@ -85,6 +85,10 @@ PeerItem::PeerItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId, updateItem(); } +PeerItem::~PeerItem() +{ + rsEvents->unregisterEventsHandler(mEventHandlerId); +} uint64_t PeerItem::uniqueIdentifier() const { return hash_64bits("PeerItem " + mPeerId.toStdString() + " " + QString::number(mType).toStdString()) ; diff --git a/retroshare-gui/src/gui/feeds/PeerItem.h b/retroshare-gui/src/gui/feeds/PeerItem.h index 7e38bb08f..8a7a2abc3 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.h +++ b/retroshare-gui/src/gui/feeds/PeerItem.h @@ -40,6 +40,7 @@ class PeerItem : public FeedItem, private Ui::PeerItem public: /** Default Constructor */ PeerItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId, uint32_t type, bool isHome); + virtual ~PeerItem(); void updateItemStatic(); diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.cpp b/retroshare-gui/src/gui/feeds/SecurityItem.cpp index 0d0729125..2b5cf281d 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityItem.cpp @@ -99,6 +99,10 @@ SecurityItem::SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &g updateItem(); } +SecurityItem::~SecurityItem() +{ + rsEvents->unregisterEventsHandler(mEventHandlerId); +} uint64_t SecurityItem::uniqueIdentifier() const { return hash_64bits("SecurityItem " + QString::number(mType).toStdString() + " " + mSslId.toStdString()); diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.h b/retroshare-gui/src/gui/feeds/SecurityItem.h index c9758107f..b51943f89 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.h +++ b/retroshare-gui/src/gui/feeds/SecurityItem.h @@ -39,6 +39,7 @@ class SecurityItem : public FeedItem, private Ui::SecurityItem public: /** Default Constructor */ SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &gpgId, const RsPeerId &sslId, const std::string &sslCn, const std::string& ip_addr,uint32_t type, bool isHome); + ~SecurityItem(); void updateItemStatic(); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 8b5b7e707..45b465955 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -53,7 +53,7 @@ RsGxsChannelPostsModel::RsGxsChannelPostsModel(QObject *parent) RsGxsChannelPostsModel::~RsGxsChannelPostsModel() { - rsEvents->unregisterEventsHandler(mEventHandlerId); +// rsEvents->unregisterEventsHandler(mEventHandlerId); } void RsGxsChannelPostsModel::setMode(TreeMode mode) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h index c447f11a3..b0829c28c 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h @@ -256,6 +256,6 @@ private: QColor mTextColorNotSubscribed ; QColor mTextColorMissing ; - RsEventsHandlerId_t mEventHandlerId ; + //RsEventsHandlerId_t mEventHandlerId ; friend class const_iterator; }; diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 253e66d73..e230b2eb1 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -618,13 +618,14 @@ void NotifyQt::notifyListChange(int list, int type) #endif emit lobbyListChanged(); break; - +#ifdef TO_REMOVE case NOTIFY_LIST_GROUPLIST: #ifdef NOTIFY_DEBUG std::cerr << "received groups changed" << std::endl ; #endif emit groupsChanged(type); break; +#endif default: break; } diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index a39f648c3..6e0adb7d8 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -126,7 +126,7 @@ class NotifyQt: public QObject, public NotifyClient void peerStatusChangedSummary() const; void gxsChange(const RsGxsChanges& /* changes */); void chatMessageReceived(ChatMessage msg); - void groupsChanged(int type) const ; +// void groupsChanged(int type) const ; void discInfoChanged() const ; void historyChanged(uint msgId, int type); void chatLobbyInviteReceived() ; diff --git a/retroshare-gui/src/gui/settings/ServerPage.cpp b/retroshare-gui/src/gui/settings/ServerPage.cpp index be2404bc8..72fe6d614 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.cpp +++ b/retroshare-gui/src/gui/settings/ServerPage.cpp @@ -85,7 +85,6 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags) , manager(NULL), mOngoingConnectivityCheck(-1) , mIsHiddenNode(false), mHiddenType(RS_HIDDEN_TYPE_NONE) , mSamAccessible(false) - , mEventHandlerId(0) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); @@ -262,10 +261,15 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags) if (ui.tabWidget->currentIndex() == TAB_HIDDEN_SERVICE) updateOutProxyIndicator(); + mEventHandlerId = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr event) { handleEvent(event); }, mEventHandlerId, RsEventType::NETWORK ); } +ServerPage::~ServerPage() +{ + rsEvents->unregisterEventsHandler(mEventHandlerId); +} void ServerPage::handleEvent(std::shared_ptr e) { if(e->mType != RsEventType::NETWORK) diff --git a/retroshare-gui/src/gui/settings/ServerPage.h b/retroshare-gui/src/gui/settings/ServerPage.h index 7d82f2190..c6b5e311e 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.h +++ b/retroshare-gui/src/gui/settings/ServerPage.h @@ -53,7 +53,7 @@ class ServerPage: public ConfigPage, public autoProxyCallback public: ServerPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); - ~ServerPage() {} + ~ServerPage() ; /** Loads the settings for this page */ virtual void load(); From e6cacc4d3437c3f66bf9bf04ec7234af3055f9bd Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 14 Jun 2025 21:56:09 +0200 Subject: [PATCH 04/38] moved peerStatusChanged() from notify to rsEvents --- .../src/gui/Identity/IdentityListModel.h | 2 +- retroshare-gui/src/gui/MainWindow.cpp | 34 +++---- retroshare-gui/src/gui/MainWindow.h | 3 +- retroshare-gui/src/gui/MessengerWindow.cpp | 22 ++++- retroshare-gui/src/gui/MessengerWindow.h | 3 +- retroshare-gui/src/gui/chat/ChatDialog.cpp | 6 +- retroshare-gui/src/gui/chat/ChatDialog.h | 6 +- retroshare-gui/src/gui/chat/ChatTabWidget.cpp | 4 +- retroshare-gui/src/gui/chat/ChatWidget.cpp | 39 +++++--- retroshare-gui/src/gui/chat/ChatWidget.h | 13 +-- .../src/gui/chat/PopupChatWindow.cpp | 4 +- .../src/gui/chat/PopupDistantChatDialog.cpp | 8 +- .../src/gui/common/AvatarWidget.cpp | 60 ++++++++----- retroshare-gui/src/gui/common/AvatarWidget.h | 10 ++- .../src/gui/common/FriendListModel.cpp | 44 ++++----- .../src/gui/common/FriendListModel.h | 4 +- .../src/gui/common/FriendSelectionWidget.cpp | 38 ++++---- .../src/gui/common/FriendSelectionWidget.h | 3 +- .../src/gui/common/NewFriendList.cpp | 8 +- retroshare-gui/src/gui/common/NewFriendList.h | 20 ++--- retroshare-gui/src/gui/common/StatusDefs.cpp | 90 ++++++++++--------- retroshare-gui/src/gui/common/StatusDefs.h | 14 +-- .../src/gui/msgs/MessageComposer.cpp | 20 ++++- retroshare-gui/src/gui/msgs/MessageComposer.h | 3 +- retroshare-gui/src/gui/notifyqt.cpp | 2 + retroshare-gui/src/gui/notifyqt.h | 8 +- 26 files changed, 281 insertions(+), 187 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h index 4c3cb43e2..0e1fb5e28 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.h +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -168,7 +168,7 @@ public: /* Color definitions (for standard see default.qss) */ QColor mTextColorGroup; - QColor mTextColorStatus[RS_STATUS_COUNT]; + QColor mTextColorStatus[(int)RsStatusValue::RS_STATUS_COUNT]; void setIdentities(const std::list& identities_meta); diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 8803783a4..964b42c92 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -1471,7 +1471,7 @@ MainWindow::retranslateUi() } /* set status object to status value */ -static void setStatusObject(QObject *pObject, int nStatus) +static void setStatusObject(QObject *pObject, RsStatusValue nStatus) { QMenu *pMenu = dynamic_cast(pObject); if (pMenu) { @@ -1482,7 +1482,7 @@ static void setStatusObject(QObject *pObject, int nStatus) continue; } - if (pAction->data().toInt() == nStatus) { + if (pAction->data().toInt() == (int)nStatus) { pAction->setChecked(true); break; } @@ -1492,7 +1492,7 @@ static void setStatusObject(QObject *pObject, int nStatus) RSComboBox *pComboBox = dynamic_cast(pObject); if (pComboBox) { /* set index of combobox */ - int nIndex = pComboBox->findData(nStatus, Qt::UserRole); + int nIndex = pComboBox->findData((int)nStatus, Qt::UserRole); if (nIndex != -1) { pComboBox->setCurrentIndex(nIndex); } @@ -1555,20 +1555,20 @@ void MainWindow::initializeStatusObject(QObject *pObject, bool bConnect) /* initialize menu */ QActionGroup *pGroup = new QActionGroup(pMenu); - QAction *pAction = new QAction(QIcon(StatusDefs::imageStatus(RS_STATUS_ONLINE)), StatusDefs::name(RS_STATUS_ONLINE), pMenu); - pAction->setData(RS_STATUS_ONLINE); + QAction *pAction = new QAction(QIcon(StatusDefs::imageStatus(RsStatusValue::RS_STATUS_ONLINE)), StatusDefs::name(RsStatusValue::RS_STATUS_ONLINE), pMenu); + pAction->setData((int)RsStatusValue::RS_STATUS_ONLINE); pAction->setCheckable(true); pMenu->addAction(pAction); pGroup->addAction(pAction); - pAction = new QAction(QIcon(StatusDefs::imageStatus(RS_STATUS_BUSY)), StatusDefs::name(RS_STATUS_BUSY), pMenu); - pAction->setData(RS_STATUS_BUSY); + pAction = new QAction(QIcon(StatusDefs::imageStatus(RsStatusValue::RS_STATUS_BUSY)), StatusDefs::name(RsStatusValue::RS_STATUS_BUSY), pMenu); + pAction->setData((int)RsStatusValue::RS_STATUS_BUSY); pAction->setCheckable(true); pMenu->addAction(pAction); pGroup->addAction(pAction); - pAction = new QAction(QIcon(StatusDefs::imageStatus(RS_STATUS_AWAY)), StatusDefs::name(RS_STATUS_AWAY), pMenu); - pAction->setData(RS_STATUS_AWAY); + pAction = new QAction(QIcon(StatusDefs::imageStatus(RsStatusValue::RS_STATUS_AWAY)), StatusDefs::name(RsStatusValue::RS_STATUS_AWAY), pMenu); + pAction->setData((int)RsStatusValue::RS_STATUS_AWAY); pAction->setCheckable(true); pMenu->addAction(pAction); pGroup->addAction(pAction); @@ -1580,9 +1580,9 @@ void MainWindow::initializeStatusObject(QObject *pObject, bool bConnect) /* initialize combobox */ RSComboBox *pComboBox = dynamic_cast(pObject); if (pComboBox) { - pComboBox->addItem(QIcon(StatusDefs::imageStatus(RS_STATUS_ONLINE)), StatusDefs::name(RS_STATUS_ONLINE), RS_STATUS_ONLINE); - pComboBox->addItem(QIcon(StatusDefs::imageStatus(RS_STATUS_BUSY)), StatusDefs::name(RS_STATUS_BUSY), RS_STATUS_BUSY); - pComboBox->addItem(QIcon(StatusDefs::imageStatus(RS_STATUS_AWAY)), StatusDefs::name(RS_STATUS_AWAY), RS_STATUS_AWAY); + pComboBox->addItem(QIcon(StatusDefs::imageStatus(RsStatusValue::RS_STATUS_ONLINE)), StatusDefs::name(RsStatusValue::RS_STATUS_ONLINE), (int)RsStatusValue::RS_STATUS_ONLINE); + pComboBox->addItem(QIcon(StatusDefs::imageStatus(RsStatusValue::RS_STATUS_BUSY)), StatusDefs::name(RsStatusValue::RS_STATUS_BUSY), (int)RsStatusValue::RS_STATUS_BUSY); + pComboBox->addItem(QIcon(StatusDefs::imageStatus(RsStatusValue::RS_STATUS_AWAY)), StatusDefs::name(RsStatusValue::RS_STATUS_AWAY), (int)RsStatusValue::RS_STATUS_AWAY); if (bConnect) { connect(pComboBox, SIGNAL(activated(int)), this, SLOT(statusChangedComboBox(int))); @@ -1610,11 +1610,11 @@ void MainWindow::removeStatusObject(QObject *pObject) } /** Save own status Online,Away,Busy **/ -void MainWindow::setStatus(QObject *pObject, int nStatus) +void MainWindow::setStatus(QObject *pObject, RsStatusValue nStatus) { - if (isIdle && nStatus == (int) RS_STATUS_ONLINE) { + if (isIdle && nStatus == RsStatusValue::RS_STATUS_ONLINE) { /* set idle only when I am online */ - nStatus = RS_STATUS_INACTIVE; + nStatus = RsStatusValue::RS_STATUS_INACTIVE; } rsStatus->sendStatus(RsPeerId(), nStatus); @@ -1634,7 +1634,7 @@ void MainWindow::statusChangedMenu(QAction *pAction) return; } - setStatus(pAction->parent(), pAction->data().toInt()); + setStatus(pAction->parent(), RsStatusValue(pAction->data().toInt())); } /* new status from combobox in statusbar */ @@ -1645,7 +1645,7 @@ void MainWindow::statusChangedComboBox(int index) } /* no object known */ - setStatus(NULL, statusComboBox->itemData(index, Qt::UserRole).toInt()); + setStatus(NULL, RsStatusValue(statusComboBox->itemData(index, Qt::UserRole).toInt())); } /*new setting*/ diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index 218d84e47..2f458c4ab 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -26,6 +26,7 @@ #include #include "retroshare/rsevents.h" +#include "retroshare/rsstatus.h" #include "gui/common/rwindow.h" #include "gui/common/RSComboBox.h" @@ -185,7 +186,7 @@ public: /* initialize widget with status informations, status constant stored in data or in Qt::UserRole */ void initializeStatusObject(QObject *pObject, bool bConnect); void removeStatusObject(QObject *pObject); - void setStatus(QObject *pObject, int nStatus); + void setStatus(QObject *pObject, RsStatusValue nStatus); RSComboBox *statusComboBoxInstance(); PeerStatus *peerstatusInstance(); diff --git a/retroshare-gui/src/gui/MessengerWindow.cpp b/retroshare-gui/src/gui/MessengerWindow.cpp index 77396a928..ca2a5530e 100644 --- a/retroshare-gui/src/gui/MessengerWindow.cpp +++ b/retroshare-gui/src/gui/MessengerWindow.cpp @@ -40,6 +40,7 @@ #include "notifyqt.h" #include "connect/ConnectFriendWizard.h" #include "util/PixmapMerging.h" +#include "util/qtthreadsutils.h" #include "LogoBar.h" #include "util/Widget.h" #include "util/misc.h" @@ -94,9 +95,23 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WindowFlags flags) ui.avatar->setOwnId(); connect(ui.messagelineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(savestatusmessage())); - connect(NotifyQt::getInstance(), SIGNAL(ownStatusMessageChanged()), this, SLOT(loadmystatusmessage())); - connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateOwnStatus(QString,int))); + + //connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateOwnStatus(QString,int))); + + mEventHandlerId = 0; + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=](){ + auto fe = dynamic_cast(e.get()); + + if(!fe || fe->mEventCode != RsFriendListEventCode::NODE_STATUS_CHANGED) + return; + + updateOwnStatus(QString::fromStdString(fe->mSslId.toStdString()),fe->mStatus); + + }, this ); + },mEventHandlerId,RsEventType::FRIEND_LIST); for (std::set::iterator peerIt = expandedPeers.begin(); peerIt != expandedPeers.end(); ++peerIt) { ui.friendList->addPeerToExpand(*peerIt); @@ -159,6 +174,7 @@ MessengerWindow::~MessengerWindow () { // save settings processSettings(false); + rsEvents->unregisterEventsHandler(mEventHandlerId); MainWindow *pMainWindow = MainWindow::getInstance(); if (pMainWindow) { @@ -214,7 +230,7 @@ void MessengerWindow::savestatusmessage() rsMsgs->setCustomStateString(ui.messagelineEdit->currentText().toUtf8().constData()); } -void MessengerWindow::updateOwnStatus(const QString &peer_id, int status) +void MessengerWindow::updateOwnStatus(const QString &peer_id, RsStatusValue status) { // add self nick + own status if (peer_id == QString::fromStdString(rsPeers->getOwnId().toStdString())) diff --git a/retroshare-gui/src/gui/MessengerWindow.h b/retroshare-gui/src/gui/MessengerWindow.h index d683ec744..26c5e547a 100644 --- a/retroshare-gui/src/gui/MessengerWindow.h +++ b/retroshare-gui/src/gui/MessengerWindow.h @@ -52,7 +52,7 @@ private slots: /** Open Shared Manager **/ void openShareManager(); - void updateOwnStatus(const QString &peer_id, int status); + void updateOwnStatus(const QString &peer_id, RsStatusValue status); void savestatusmessage(); @@ -68,6 +68,7 @@ private: static std::set expandedPeers ; static std::set expandedGroups ; + RsEventsHandlerId_t mEventHandlerId ; }; #endif diff --git a/retroshare-gui/src/gui/chat/ChatDialog.cpp b/retroshare-gui/src/gui/chat/ChatDialog.cpp index d7edd2152..0b7017a88 100644 --- a/retroshare-gui/src/gui/chat/ChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatDialog.cpp @@ -330,7 +330,7 @@ QString ChatDialog::getOwnName() const return "ChatDialog::getOwnName(): invalid id type passed (RsPeerId is required). This is a bug."; } -void ChatDialog::setPeerStatus(uint32_t status) +void ChatDialog::setPeerStatus(RsStatusValue status) { ChatWidget *cw = getChatWidget(); if (cw) @@ -346,14 +346,14 @@ void ChatDialog::setPeerStatus(uint32_t status) cw->updateStatus(QString::fromStdString(vpid.toStdString()), status); } } -int ChatDialog::getPeerStatus() +RsStatusValue ChatDialog::getPeerStatus() { ChatWidget *cw = getChatWidget(); if (cw) { return cw->getPeerStatus(); } - return 0; + return RsStatusValue::RS_STATUS_UNKNOWN; } QString ChatDialog::getTitle() diff --git a/retroshare-gui/src/gui/chat/ChatDialog.h b/retroshare-gui/src/gui/chat/ChatDialog.h index 7bfbc16ec..0145fe678 100644 --- a/retroshare-gui/src/gui/chat/ChatDialog.h +++ b/retroshare-gui/src/gui/chat/ChatDialog.h @@ -23,6 +23,8 @@ #ifndef CHATDIALOG_H #define CHATDIALOG_H +#include "retroshare/rsstatus.h" + #include #include @@ -58,8 +60,8 @@ public: bool setStyle(); const RSStyle *getStyle(); - int getPeerStatus(); - void setPeerStatus(uint32_t state); + RsStatusValue getPeerStatus(); + void setPeerStatus(RsStatusValue state); void focusDialog(); diff --git a/retroshare-gui/src/gui/chat/ChatTabWidget.cpp b/retroshare-gui/src/gui/chat/ChatTabWidget.cpp index 03357a3e4..9008b250c 100644 --- a/retroshare-gui/src/gui/chat/ChatTabWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatTabWidget.cpp @@ -113,7 +113,7 @@ void ChatTabWidget::tabInfoChanged(ChatDialog *dialog) } } else if (dialog->hasPeerStatus()) { setBlinking(tab, false); - setTabIcon(tab, QIcon(StatusDefs::imageIM(dialog->getPeerStatus()))); + setTabIcon(tab, QIcon(StatusDefs::imageIM((RsStatusValue)dialog->getPeerStatus()))); } else { setBlinking(tab, false); setTabIcon(tab, QIcon()); @@ -155,7 +155,7 @@ void ChatTabWidget::getInfo(bool &isTyping, bool &hasNewMessage, QIcon *icon) } else { cd = dynamic_cast(currentWidget()); if (cd && cd->hasPeerStatus()) { - *icon = QIcon(StatusDefs::imageIM(cd->getPeerStatus())); + *icon = QIcon(StatusDefs::imageIM((RsStatusValue)cd->getPeerStatus())); } else { *icon = QIcon(); } diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index abab8336a..0cac7c497 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -38,6 +38,7 @@ #include "gui/chat/ChatUserNotify.h"//For BradCast #include "util/DateTime.h" #include "util/imageutil.h" +#include "util/qtthreadsutils.h" #include "gui/im_history/ImHistoryBrowser.h" #include @@ -74,7 +75,7 @@ ChatWidget::ChatWidget(QWidget *parent) : QWidget(parent) - , completionPosition(0), newMessages(false), typing(false), peerStatus(0) + , completionPosition(0), newMessages(false), typing(false), peerStatus(RsStatusValue::RS_STATUS_UNKNOWN) , sendingBlocked(false), useCMark(false) , lastStatusSendTime(0) , firstShow(true), inChatCharFormatChanged(false), firstSearch(true) @@ -171,8 +172,23 @@ ChatWidget::ChatWidget(QWidget *parent) connect(ui->hashBox, SIGNAL(fileHashingFinished(QList)), this, SLOT(fileHashingFinished(QList))); - connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&, int)), this, SLOT(updateStatus(const QString&, int))); - connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&))); + //connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&, int)), this, SLOT(updateStatus(const QString&, int))); + + mEventHandlerId = 0; + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=](){ + auto fe = dynamic_cast(e.get()); + + if(!fe || fe->mEventCode != RsFriendListEventCode::NODE_STATUS_CHANGED) + return; + + updateStatus(QString::fromStdString(fe->mSslId.toStdString()),fe->mStatus); + + }, this ); + },mEventHandlerId,RsEventType::FRIEND_LIST); + + connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&))); connect(NotifyQt::getInstance(), SIGNAL(chatFontChanged()), this, SLOT(resetFonts())); connect(ui->textBrowser, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTextBrowser(QPoint))); @@ -254,6 +270,7 @@ ChatWidget::ChatWidget(QWidget *parent) ChatWidget::~ChatWidget() { processSettings(false); + rsEvents->unregisterEventsHandler(mEventHandlerId); /* Cleanup plugin functions */ foreach (ChatWidgetHolder *chatWidgetHolder, mChatWidgetHolder) { @@ -1788,7 +1805,7 @@ void ChatWidget::setCurrentFileName(const QString &fileName) setWindowModified(false); } -void ChatWidget::updateStatus(const QString &peer_id, int status) +void ChatWidget::updateStatus(const QString &peer_id, RsStatusValue status) { if (! (chatType() == CHATTYPE_PRIVATE || chatType() == CHATTYPE_DISTANT)) { @@ -1842,26 +1859,27 @@ void ChatWidget::updateStatus(const QString &peer_id, int status) bool atEnd = (scrollbar->value() == scrollbar->maximum()); switch (status) { - case RS_STATUS_OFFLINE: + default: + case RsStatusValue::RS_STATUS_OFFLINE: ui->info_Frame->setVisible(true); ui->infoLabel->setText(peerName + " " + tr("appears to be Offline.") +"\n" + tr("Messages you send will be delivered after Friend is again Online.")); break; - case RS_STATUS_INACTIVE: + case RsStatusValue::RS_STATUS_INACTIVE: ui->info_Frame->setVisible(true); ui->infoLabel->setText(peerName + " " + tr("is Idle and may not reply")); break; - case RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_ONLINE: ui->info_Frame->setVisible(false); break; - case RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_AWAY: ui->infoLabel->setText(peerName + " " + tr("is Away and may not reply")); ui->info_Frame->setVisible(true); break; - case RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_BUSY: ui->infoLabel->setText(peerName + " " + tr("is Busy and may not reply")); ui->info_Frame->setVisible(true); break; @@ -1869,7 +1887,8 @@ void ChatWidget::updateStatus(const QString &peer_id, int status) ui->titleLabel->setText(peerName); ui->titleLabel->setToolTip(tooltip_info); - ui->statusLabel->setText(QString("(%1)").arg(StatusDefs::name(status))); +#warning inconsistent conversion here + ui->statusLabel->setText(QString("(%1)").arg(StatusDefs::name((RsStatusValue)status))); peerStatus = status; diff --git a/retroshare-gui/src/gui/chat/ChatWidget.h b/retroshare-gui/src/gui/chat/ChatWidget.h index e42df06fe..0b9a28ccb 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.h +++ b/retroshare-gui/src/gui/chat/ChatWidget.h @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -62,7 +63,7 @@ public: // status comes from notifyPeerStatusChanged // see rststaus.h for possible values - virtual void updateStatus(int /*status*/) {} + virtual void updateStatus(RsStatusValue /*status*/) {} protected: ChatWidget *mChatWidget; @@ -105,7 +106,7 @@ public: void addToolsAction(QAction *action); QString getTitle() { return title; } - int getPeerStatus() { return peerStatus; } + RsStatusValue getPeerStatus() { return peerStatus; } void setName(const QString &name); bool setStyle(); @@ -130,7 +131,7 @@ public: const QList &chatWidgetHolderList() { return mChatWidgetHolder; } public slots: - void updateStatus(const QString &peer_id, int status); + void updateStatus(const QString &peer_id, RsStatusValue status); void setUseCMark(const bool bUseCMark); void updateCMPreview(); @@ -144,7 +145,7 @@ private slots: signals: void infoChanged(ChatWidget*); void newMessage(ChatWidget*); - void statusChanged(int); + void statusChanged(RsStatusValue); void textBrowserAskContextMenu(QMenu* contextMnu, QString anchorForPosition, const QPoint point); protected: @@ -229,7 +230,7 @@ private: bool newMessages; bool typing; - int peerStatus; + RsStatusValue peerStatus; bool sendingBlocked; bool useCMark; @@ -272,6 +273,8 @@ private: ChatLobbyUserNotify* notify; Ui::ChatWidget *ui; + + RsEventsHandlerId_t mEventHandlerId ; }; #endif // CHATWIDGET_H diff --git a/retroshare-gui/src/gui/chat/PopupChatWindow.cpp b/retroshare-gui/src/gui/chat/PopupChatWindow.cpp index 1f15345b1..f60b7b7e4 100644 --- a/retroshare-gui/src/gui/chat/PopupChatWindow.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatWindow.cpp @@ -350,7 +350,7 @@ void PopupChatWindow::calculateTitle(ChatDialog *dialog) } else { mBlinkIcon = QIcon(); if (cd && cd->hasPeerStatus()) { - icon = QIcon(StatusDefs::imageIM(cd->getPeerStatus())); + icon = QIcon(StatusDefs::imageIM((RsStatusValue)cd->getPeerStatus())); } else { icon = qApp->windowIcon(); } @@ -361,7 +361,7 @@ void PopupChatWindow::calculateTitle(ChatDialog *dialog) if (cd) { QString title = cd->getTitle(); if (cd->hasPeerStatus()) { - title += " (" + StatusDefs::name(cd->getPeerStatus()) + ")"; + title += " (" + StatusDefs::name((RsStatusValue)cd->getPeerStatus()) + ")"; } setWindowTitle(title); } else { diff --git a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp index c5ab40cbf..0e8faba80 100644 --- a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp @@ -121,7 +121,7 @@ void PopupDistantChatDialog::updateDisplay() getChatWidget()->blockSending(tr( "Can't send message immediately, " "because there is no tunnel " "available." )); - setPeerStatus(RS_STATUS_OFFLINE); + setPeerStatus(RsStatusValue::RS_STATUS_OFFLINE); break ; case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED: std::cerr << "Chat remotely closed. " << std::endl; @@ -131,7 +131,7 @@ void PopupDistantChatDialog::updateDisplay() getChatWidget()->updateStatusString("%1", tr( "Your partner closed the conversation." ), true ); getChatWidget()->blockSending(tr( "Your partner closed the conversation.")); - setPeerStatus(RS_STATUS_OFFLINE) ; + setPeerStatus(RsStatusValue::RS_STATUS_OFFLINE) ; break ; case RS_DISTANT_CHAT_STATUS_TUNNEL_DN: @@ -145,7 +145,7 @@ void PopupDistantChatDialog::updateDisplay() _status_label->setToolTip(msg); getChatWidget()->updateStatusString("%1", msg, true); getChatWidget()->blockSending(msg); - setPeerStatus(RS_STATUS_OFFLINE); + setPeerStatus(RsStatusValue::RS_STATUS_OFFLINE); break; case RS_DISTANT_CHAT_STATUS_CAN_TALK: @@ -153,7 +153,7 @@ void PopupDistantChatDialog::updateDisplay() msg = QObject::tr( "End-to-end encrypted conversation established"); _status_label->setToolTip(msg); getChatWidget()->unblockSending(); - setPeerStatus(RS_STATUS_ONLINE); + setPeerStatus(RsStatusValue::RS_STATUS_ONLINE); break; } } diff --git a/retroshare-gui/src/gui/common/AvatarWidget.cpp b/retroshare-gui/src/gui/common/AvatarWidget.cpp index 02151730a..afb4c883c 100644 --- a/retroshare-gui/src/gui/common/AvatarWidget.cpp +++ b/retroshare-gui/src/gui/common/AvatarWidget.cpp @@ -27,6 +27,7 @@ #include "gui/notifyqt.h" #include "util/misc.h" +#include "util/qtthreadsutils.h" #include "gui/common/AvatarDefs.h" #include "gui/common/AvatarDialog.h" @@ -39,21 +40,36 @@ AvatarWidget::AvatarWidget(QWidget *parent) : QLabel(parent), ui(new Ui::AvatarWidget) { - ui->setupUi(this); + ui->setupUi(this); - mFlag.isOwnId = false; - defaultAvatar = ":/images/no_avatar_background.png"; - mPeerState = RS_STATUS_OFFLINE ; + mFlag.isOwnId = false; + defaultAvatar = ":/images/no_avatar_background.png"; + mPeerState = RsStatusValue::RS_STATUS_OFFLINE ; - setFrameType(NO_FRAME); + setFrameType(NO_FRAME); + + /* connect signals */ + connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&))); + connect(NotifyQt::getInstance(), SIGNAL(ownAvatarChanged()), this, SLOT(updateOwnAvatar())); + + mEventHandlerId = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr event) + { + RsQThreadUtils::postToObject([=](){ + + const RsFriendListEvent *e = dynamic_cast(event.get()); + if(!e) + return; + updateStatus(QString::fromStdString(e->mSslId.toStdString()),e->mStatus); + }, this ); + }, mEventHandlerId, RsEventType::FRIEND_LIST ); - /* connect signals */ - connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&))); - connect(NotifyQt::getInstance(), SIGNAL(ownAvatarChanged()), this, SLOT(updateOwnAvatar())); } AvatarWidget::~AvatarWidget() { + rsEvents->unregisterEventsHandler(mEventHandlerId); delete ui; } @@ -68,15 +84,15 @@ QString AvatarWidget::frameState() case STATUS_FRAME: switch (mPeerState) { - case RS_STATUS_OFFLINE: + case RsStatusValue::RS_STATUS_OFFLINE: return "OFFLINE"; - case RS_STATUS_INACTIVE: + case RsStatusValue::RS_STATUS_INACTIVE: return "INACTIVE"; - case RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_ONLINE: return "ONLINE"; - case RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_AWAY: return "AWAY"; - case RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_BUSY: return "BUSY"; } } @@ -107,6 +123,7 @@ void AvatarWidget::setFrameType(FrameType type) { mFrameType = type; +#ifdef TO_REMOVE switch (mFrameType) { case NO_FRAME: disconnect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateStatus(const QString&, int))); @@ -118,6 +135,9 @@ void AvatarWidget::setFrameType(FrameType type) connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateStatus(const QString&, int))); break; } +#endif + + //refreshAvatarImage(); refreshStatus(); @@ -179,7 +199,7 @@ void AvatarWidget::refreshStatus() } case STATUS_FRAME: { - uint32_t status = 0; + RsStatusValue status = RsStatusValue::RS_STATUS_UNKNOWN; if (mId.isNotSet()) return; @@ -193,7 +213,7 @@ void AvatarWidget::refreshStatus() status = statusInfo.status ; } else if(mId.isDistantChatId()) - status = RS_STATUS_ONLINE ; + status = RsStatusValue::RS_STATUS_ONLINE ; else { std::cerr << "Unhandled chat id type in AvatarWidget::refreshStatus()" << std::endl; @@ -217,10 +237,10 @@ void AvatarWidget::refreshStatus() { switch (dcpinfo.status) { - case RS_DISTANT_CHAT_STATUS_CAN_TALK : status = RS_STATUS_ONLINE ; break; + case RS_DISTANT_CHAT_STATUS_CAN_TALK : status = RsStatusValue::RS_STATUS_ONLINE ; break; case RS_DISTANT_CHAT_STATUS_UNKNOWN : // Fall-through case RS_DISTANT_CHAT_STATUS_TUNNEL_DN : // Fall-through - case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED : status = RS_STATUS_OFFLINE; + case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED : status = RsStatusValue::RS_STATUS_OFFLINE; } } else @@ -238,20 +258,20 @@ void AvatarWidget::refreshStatus() } } -void AvatarWidget::updateStatus(const QString& peerId, int status) +void AvatarWidget::updateStatus(const QString& peerId, RsStatusValue status) { if (mId.isPeerId() && mId.toPeerId() == RsPeerId(peerId.toStdString())) updateStatus(status) ; } -void AvatarWidget::updateStatus(int status) +void AvatarWidget::updateStatus(RsStatusValue status) { if (mFrameType != STATUS_FRAME) return; mPeerState = status; - setEnabled(((uint32_t) status == RS_STATUS_OFFLINE) ? false : true); + setEnabled((status == RsStatusValue::RS_STATUS_OFFLINE) ? false : true); RsApplication::refreshStyleSheet(this, false); } diff --git a/retroshare-gui/src/gui/common/AvatarWidget.h b/retroshare-gui/src/gui/common/AvatarWidget.h index e3b90022b..4e81b3ef1 100644 --- a/retroshare-gui/src/gui/common/AvatarWidget.h +++ b/retroshare-gui/src/gui/common/AvatarWidget.h @@ -24,7 +24,9 @@ #include #include #include +#include #include +#include namespace Ui { class AvatarWidget; @@ -57,14 +59,14 @@ protected: void mouseReleaseEvent(QMouseEvent *event); private slots: - void updateStatus(const QString& peerId, int status); + void updateStatus(const QString& peerId, RsStatusValue status); void updateAvatar(const QString& peerId); void updateOwnAvatar(); private: void refreshAvatarImage() ; void refreshStatus(); - void updateStatus(int status); + void updateStatus(RsStatusValue status); QString defaultAvatar; Ui::AvatarWidget *ui; @@ -77,7 +79,9 @@ private: // bool isGpg : 1; } mFlag; FrameType mFrameType; - uint32_t mPeerState; + RsStatusValue mPeerState; + + RsEventsHandlerId_t mEventHandlerId; }; #endif // AVATARWIDGET_H diff --git a/retroshare-gui/src/gui/common/FriendListModel.cpp b/retroshare-gui/src/gui/common/FriendListModel.cpp index 9ea271f86..efab4243a 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.cpp +++ b/retroshare-gui/src/gui/common/FriendListModel.cpp @@ -458,7 +458,7 @@ QVariant RsFriendListModel::statusRole(const EntryIndex& fmpe,int /*column*/) co StatusInfo status; rsStatus->getStatus(node->node_info.id, status); - return QVariant(status.status); + return QVariant((int)status.status); } return QVariant(); } @@ -603,7 +603,7 @@ QVariant RsFriendListModel::onlineRole(const EntryIndex& e, int /*col*/) const for(uint32_t i=0;ichild_node_indices.size();++i) if(mLocations[prof->child_node_indices[i]].node_info.state & RS_PEER_STATE_CONNECTED) - return QVariant(RS_STATUS_ONLINE); + return QVariant((int)RsStatusValue::RS_STATUS_ONLINE); } } break; @@ -626,12 +626,12 @@ QVariant RsFriendListModel::onlineRole(const EntryIndex& e, int /*col*/) const const HierarchicalNodeInformation *node = getNodeInfo(e); if(node && bool(node->node_info.state & RS_PEER_STATE_CONNECTED)) - return QVariant(RS_STATUS_ONLINE); + return QVariant((int)RsStatusValue::RS_STATUS_ONLINE); else - return QVariant(RS_STATUS_OFFLINE); + return QVariant((int)RsStatusValue::RS_STATUS_OFFLINE); } } - return QVariant(RS_STATUS_OFFLINE); + return QVariant((int)RsStatusValue::RS_STATUS_OFFLINE); } QVariant RsFriendListModel::fontRole(const EntryIndex& e, int col) const @@ -640,14 +640,14 @@ QVariant RsFriendListModel::fontRole(const EntryIndex& e, int col) const std::cerr << " font role " << e.type << ", (" << (int)e.group_index << ","<< (int)e.profile_index << ","<< (int)e.node_index << ") col="<< col<<": " << std::endl; #endif - int status = onlineRole(e,col).toInt(); + auto status = RsStatusValue(onlineRole(e,col).toInt()); switch (status) { - case RS_STATUS_AWAY: - case RS_STATUS_BUSY: - case RS_STATUS_ONLINE: - case RS_STATUS_INACTIVE: + case RsStatusValue::RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_INACTIVE: { QFont font ; QTreeView* myParent = dynamic_cast(QAbstractItemModel::parent()); @@ -781,7 +781,7 @@ QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const else { return QVariant(QString::fromUtf8(node->node_info.location.c_str())+"\n" - + "(" + StatusDefs::name(statusRole(e,col).toInt()) + ")"); + + "(" + StatusDefs::name(RsStatusValue(statusRole(e,col).toInt())) + ")"); } else return QVariant(QString::fromUtf8(node->node_info.location.c_str())); @@ -900,10 +900,10 @@ bool RsFriendListModel::getPeerOnlineStatus(const EntryIndex& e) const return (noded && (noded->node_info.state & RS_PEER_STATE_CONNECTED)); } -const RsFriendListModel::HierarchicalNodeInformation *RsFriendListModel::getBestNodeInformation(const HierarchicalProfileInformation *profileInfo, uint32_t *status) const +const RsFriendListModel::HierarchicalNodeInformation *RsFriendListModel::getBestNodeInformation(const HierarchicalProfileInformation *profileInfo, RsStatusValue *status) const { if (status) { - *status = RS_STATUS_OFFLINE; + *status = RsStatusValue::RS_STATUS_OFFLINE; } if (!profileInfo) { @@ -921,28 +921,28 @@ const RsFriendListModel::HierarchicalNodeInformation *RsFriendListModel::getBest int statusIndex = 0; switch (statusInfo.status) { - case RS_STATUS_OFFLINE: + case RsStatusValue::RS_STATUS_OFFLINE: statusIndex = 1; break; - case RS_STATUS_INACTIVE: + case RsStatusValue::RS_STATUS_INACTIVE: statusIndex = 2; break; - case RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_AWAY: statusIndex = 3; break; - case RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_BUSY: statusIndex = 4; break; - case RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_ONLINE: statusIndex = 5; break; default: - std::cerr << "FriendListModel: Unknown status " << statusInfo.status << std::endl; + std::cerr << "FriendListModel: Unknown status " << (int)statusInfo.status << std::endl; } if (bestStatusIndex == 0 || statusIndex > bestStatusIndex) { @@ -999,7 +999,7 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons QPixmap sslAvatar; bool foundAvatar = false; const HierarchicalProfileInformation *hn = getProfileInfo(entry); - uint32_t status = RS_STATUS_OFFLINE; + RsStatusValue status = RsStatusValue::RS_STATUS_OFFLINE; const HierarchicalNodeInformation *bestNodeInformation = NULL; if (mDisplayStatusIcon) { @@ -1049,7 +1049,7 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons QPixmap sslAvatar; AvatarDefs::getAvatarFromSslId(RsPeerId(hn->node_info.id.toStdString()), sslAvatar); if (mDisplayStatusIcon) { - QPixmap sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(statusRole(entry, col).toInt())); + QPixmap sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(RsStatusValue(statusRole(entry, col).toInt()))); return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon))); } diff --git a/retroshare-gui/src/gui/common/FriendListModel.h b/retroshare-gui/src/gui/common/FriendListModel.h index e19a84f04..4020e6fc7 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.h +++ b/retroshare-gui/src/gui/common/FriendListModel.h @@ -162,7 +162,7 @@ public: /* Color definitions (for standard see default.qss) */ QColor mTextColorGroup; - QColor mTextColorStatus[RS_STATUS_COUNT]; + QColor mTextColorStatus[(int)RsStatusValue::RS_STATUS_COUNT]; private: const HierarchicalGroupInformation *getGroupInfo (const EntryIndex&) const; @@ -223,7 +223,7 @@ private: uint32_t updateFilterStatus(ForumModelIndex i,int column,const QStringList& strings); - const HierarchicalNodeInformation *getBestNodeInformation(const HierarchicalProfileInformation *profileInfo, uint32_t *status = NULL) const; + const HierarchicalNodeInformation *getBestNodeInformation(const HierarchicalProfileInformation *profileInfo, RsStatusValue *status = NULL) const; QStringList mFilterStrings; FilterType mFilterType; diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index 3c7ba5a29..47cf2b802 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -255,7 +255,7 @@ static void initSslItem(QTreeWidgetItem *item, const RsPeerDetails &detail, cons QString name = PeerDefs::nameWithLocation(detail); item->setText(COLUMN_NAME, name); - int state = RS_STATUS_OFFLINE; + RsStatusValue state = RsStatusValue::RS_STATUS_OFFLINE; if (detail.state & RS_PEER_STATE_CONNECTED) { std::list::const_iterator it; for (it = statusInfo.begin(); it != statusInfo.end() ; ++it) { @@ -266,7 +266,7 @@ static void initSslItem(QTreeWidgetItem *item, const RsPeerDetails &detail, cons } } - if (state != (int) RS_STATUS_OFFLINE) { + if (state != RsStatusValue::RS_STATUS_OFFLINE) { item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline); } @@ -276,7 +276,7 @@ static void initSslItem(QTreeWidgetItem *item, const RsPeerDetails &detail, cons item->setData(COLUMN_NAME, ROLE_SORT_GROUP, 1); item->setData(COLUMN_NAME, ROLE_SORT_STANDARD_GROUP, 0); item->setData(COLUMN_NAME, ROLE_SORT_NAME, name); - item->setData(COLUMN_NAME, ROLE_SORT_STATE, state); + item->setData(COLUMN_NAME, ROLE_SORT_STATE, (int)state); } void FriendSelectionWidget::fillList() @@ -515,17 +515,17 @@ void FriendSelectionWidget::secured_fillList() sslIds.clear(); rsPeers->getAssociatedSSLIds(*gpgIt, sslIds); - int state = RS_STATUS_OFFLINE; + RsStatusValue state = RsStatusValue::RS_STATUS_OFFLINE; for (statusIt = statusInfo.begin(); statusIt != statusInfo.end() ; ++statusIt) { if (std::find(sslIds.begin(), sslIds.end(), statusIt->id) != sslIds.end()) { - if (statusIt->status != RS_STATUS_OFFLINE) { - state = RS_STATUS_ONLINE; + if (statusIt->status != RsStatusValue::RS_STATUS_OFFLINE) { + state = RsStatusValue::RS_STATUS_ONLINE; break; } } } - if (state != (int) RS_STATUS_OFFLINE) { + if (state != RsStatusValue::RS_STATUS_OFFLINE) { gpgItem->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline()); } @@ -536,7 +536,7 @@ void FriendSelectionWidget::secured_fillList() gpgItem->setData(COLUMN_NAME, ROLE_SORT_GROUP, 1); gpgItem->setData(COLUMN_NAME, ROLE_SORT_STANDARD_GROUP, 0); gpgItem->setData(COLUMN_NAME, ROLE_SORT_NAME, name); - gpgItem->setData(COLUMN_NAME, ROLE_SORT_STATE, state); + gpgItem->setData(COLUMN_NAME, ROLE_SORT_STATE, (int)state); if (mListModus == MODUS_CHECK) { gpgItem->setCheckState(0, Qt::Unchecked); @@ -791,13 +791,13 @@ void FriendSelectionWidget::groupsChanged() } } -void FriendSelectionWidget::peerStatusChanged(const RsPeerId& peerid, int status) +void FriendSelectionWidget::peerStatusChanged(const RsPeerId& peerid, RsStatusValue status) { if(!isVisible()) return ; QString gpgId; - int gpgStatus = RS_STATUS_OFFLINE; + RsStatusValue gpgStatus = RsStatusValue::RS_STATUS_OFFLINE; if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG)) { /* need gpg id and online state */ @@ -806,7 +806,7 @@ void FriendSelectionWidget::peerStatusChanged(const RsPeerId& peerid, int status { gpgId = QString::fromStdString(detail.gpg_id.toStdString()); - if (status == (int) RS_STATUS_OFFLINE) { + if (status == RsStatusValue::RS_STATUS_OFFLINE) { /* try other nodes */ std::list sslIds; rsPeers->getAssociatedSSLIds(detail.gpg_id, sslIds); @@ -817,15 +817,15 @@ void FriendSelectionWidget::peerStatusChanged(const RsPeerId& peerid, int status for (statusIt = statusInfo.begin(); statusIt != statusInfo.end() ; ++statusIt) { if (std::find(sslIds.begin(), sslIds.end(), statusIt->id) != sslIds.end()) { - if (statusIt->status != RS_STATUS_OFFLINE) { - gpgStatus = RS_STATUS_ONLINE; + if (statusIt->status != RsStatusValue::RS_STATUS_OFFLINE) { + gpgStatus = RsStatusValue::RS_STATUS_ONLINE; break; } } } } else { /* one node is online */ - gpgStatus = RS_STATUS_ONLINE; + gpgStatus = RsStatusValue::RS_STATUS_ONLINE; } } } @@ -845,7 +845,7 @@ void FriendSelectionWidget::peerStatusChanged(const RsPeerId& peerid, int status case IDTYPE_GPG: { if (item->data(COLUMN_DATA, ROLE_ID).toString() == gpgId) { - if (status != (int) RS_STATUS_OFFLINE) { + if (status != RsStatusValue::RS_STATUS_OFFLINE) { item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline()); } else { item->setData(COLUMN_NAME, Qt::ForegroundRole, QVariant()); @@ -853,7 +853,7 @@ void FriendSelectionWidget::peerStatusChanged(const RsPeerId& peerid, int status item->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(gpgStatus))); - item->setData(COLUMN_NAME, ROLE_SORT_STATE, gpgStatus); + item->setData(COLUMN_NAME, ROLE_SORT_STATE, (int)gpgStatus); bFoundGPG = true; } @@ -863,7 +863,7 @@ void FriendSelectionWidget::peerStatusChanged(const RsPeerId& peerid, int status { if (RsPeerId(item->data(COLUMN_DATA, ROLE_ID).toString().toStdString()) == peerid) { - if (status != (int) RS_STATUS_OFFLINE) { + if (status != RsStatusValue::RS_STATUS_OFFLINE) { item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline()); } else { item->setData(COLUMN_NAME, Qt::ForegroundRole, QVariant()); @@ -871,7 +871,7 @@ void FriendSelectionWidget::peerStatusChanged(const RsPeerId& peerid, int status item->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(status))); - item->setData(COLUMN_NAME, ROLE_SORT_STATE, status); + item->setData(COLUMN_NAME, ROLE_SORT_STATE, (int)status); bFoundSSL = true; } @@ -1274,7 +1274,7 @@ bool FriendSelectionWidget::isSortByState() void FriendSelectionWidget::filterConnected(bool filter) { - ui->friendList->filterMinValItems(COLUMN_NAME, filter ? RS_STATUS_AWAY : RS_STATUS_OFFLINE, ROLE_SORT_STATE); + ui->friendList->filterMinValItems(COLUMN_NAME, filter ? double(RsStatusValue::RS_STATUS_AWAY) : double(RsStatusValue::RS_STATUS_OFFLINE), ROLE_SORT_STATE); mActionFilterConnected->setChecked(filter); diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.h b/retroshare-gui/src/gui/common/FriendSelectionWidget.h index c01c888e7..c9be4bf6b 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.h +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.h @@ -25,6 +25,7 @@ #include #include "retroshare/rsevents.h" +#include "retroshare/rsstatus.h" #include #include "util/FontSizeHandler.h" @@ -137,7 +138,7 @@ public slots: void filterConnected(bool filter); private slots: - void peerStatusChanged(const RsPeerId &peerid, int status); + void peerStatusChanged(const RsPeerId &peerid, RsStatusValue status); void filterItems(const QString &text); void contextMenuRequested(const QPoint &pos); void itemDoubleClicked(QTreeWidgetItem *item, int column); diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 86966d7fd..e2b920ec1 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -132,8 +132,8 @@ public: if(is_group_1 ^ is_group_2) // if the two are different, put the group first. return is_group_1 ; - bool online1 = (left .data(RsFriendListModel::OnlineRole).toInt() != RS_STATUS_OFFLINE); - bool online2 = (right.data(RsFriendListModel::OnlineRole).toInt() != RS_STATUS_OFFLINE); + bool online1 = (left .data(RsFriendListModel::OnlineRole).toInt() != (int)RsStatusValue::RS_STATUS_OFFLINE); + bool online2 = (right.data(RsFriendListModel::OnlineRole).toInt() != (int)RsStatusValue::RS_STATUS_OFFLINE); if((online1 != online2) && m_sortByState) return (m_header->sortIndicatorOrder()==Qt::AscendingOrder)?online1:online2 ; // always put online nodes first @@ -155,7 +155,7 @@ public: // Filter offline friends - if(!m_showOfflineNodes && (index.data(RsFriendListModel::OnlineRole).toInt() == RS_STATUS_OFFLINE)) + if(!m_showOfflineNodes && (RsStatusValue(index.data(RsFriendListModel::OnlineRole).toInt()) == RsStatusValue::RS_STATUS_OFFLINE)) return false; return index.data(RsFriendListModel::FilterRole).toString() == RsFriendListModel::FilterString ; @@ -204,7 +204,7 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par rsEvents->registerEventsHandler( [this](std::shared_ptr e) { handleEvent(e); }, mEventHandlerId_gssp, RsEventType::GOSSIP_DISCOVERY ); connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(QString)), this, SLOT(forceUpdateDisplay())); - connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(forceUpdateDisplay())); +// connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(forceUpdateDisplay())); mModel = new RsFriendListModel(ui->peerTreeWidget); mProxyModel = new FriendListSortFilterProxyModel(ui->peerTreeWidget->header(),this); diff --git a/retroshare-gui/src/gui/common/NewFriendList.h b/retroshare-gui/src/gui/common/NewFriendList.h index 18a7d4b97..204d984d5 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.h +++ b/retroshare-gui/src/gui/common/NewFriendList.h @@ -66,18 +66,18 @@ public: //void updateDisplay() override; QColor textColorGroup() const { return mModel->mTextColorGroup; } - QColor textColorStatusOffline() const { return mModel->mTextColorStatus[RS_STATUS_OFFLINE ]; } - QColor textColorStatusAway() const { return mModel->mTextColorStatus[RS_STATUS_AWAY ]; } - QColor textColorStatusBusy() const { return mModel->mTextColorStatus[RS_STATUS_BUSY ]; } - QColor textColorStatusOnline() const { return mModel->mTextColorStatus[RS_STATUS_ONLINE ]; } - QColor textColorStatusInactive() const { return mModel->mTextColorStatus[RS_STATUS_INACTIVE]; } + QColor textColorStatusOffline() const { return mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_OFFLINE ]; } + QColor textColorStatusAway() const { return mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_AWAY ]; } + QColor textColorStatusBusy() const { return mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_BUSY ]; } + QColor textColorStatusOnline() const { return mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_ONLINE ]; } + QColor textColorStatusInactive() const { return mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_INACTIVE]; } void setTextColorGroup(QColor color) { mModel->mTextColorGroup = color; } - void setTextColorStatusOffline(QColor color) { mModel->mTextColorStatus[RS_STATUS_OFFLINE ] = color; } - void setTextColorStatusAway(QColor color) { mModel->mTextColorStatus[RS_STATUS_AWAY ] = color; } - void setTextColorStatusBusy(QColor color) { mModel->mTextColorStatus[RS_STATUS_BUSY ] = color; } - void setTextColorStatusOnline(QColor color) { mModel->mTextColorStatus[RS_STATUS_ONLINE ] = color; } - void setTextColorStatusInactive(QColor color) { mModel->mTextColorStatus[RS_STATUS_INACTIVE] = color; } + void setTextColorStatusOffline(QColor color) { mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_OFFLINE ] = color; } + void setTextColorStatusAway(QColor color) { mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_AWAY ] = color; } + void setTextColorStatusBusy(QColor color) { mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_BUSY ] = color; } + void setTextColorStatusOnline(QColor color) { mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_ONLINE ] = color; } + void setTextColorStatusInactive(QColor color) { mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_INACTIVE] = color; } public slots: void filterItems(const QString &text); diff --git a/retroshare-gui/src/gui/common/StatusDefs.cpp b/retroshare-gui/src/gui/common/StatusDefs.cpp index 5d0db8395..a9fa4e3f9 100644 --- a/retroshare-gui/src/gui/common/StatusDefs.cpp +++ b/retroshare-gui/src/gui/common/StatusDefs.cpp @@ -24,118 +24,124 @@ #include "StatusDefs.h" -QString StatusDefs::name(unsigned int status) +QString StatusDefs::name(RsStatusValue status) { switch (status) { - case RS_STATUS_OFFLINE: + default: + case RsStatusValue::RS_STATUS_OFFLINE: return qApp->translate("StatusDefs", "Offline"); - case RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_AWAY: return qApp->translate("StatusDefs", "Away"); - case RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_BUSY: return qApp->translate("StatusDefs", "Busy"); - case RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_ONLINE: return qApp->translate("StatusDefs", "Online"); - case RS_STATUS_INACTIVE: + case RsStatusValue::RS_STATUS_INACTIVE: return qApp->translate("StatusDefs", "Idle"); } - std::cerr << "StatusDefs::name: Unknown status requested " << status; + RsErr() << "StatusDefs::name: Unknown status requested " << (int)status; return ""; } -const char *StatusDefs::imageIM(unsigned int status) +const char *StatusDefs::imageIM(RsStatusValue status) { switch (status) { - case RS_STATUS_OFFLINE: + default: + case RsStatusValue::RS_STATUS_OFFLINE: return ":/images/im-user-offline.png"; - case RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_AWAY: return ":/images/im-user-away.png"; - case RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_BUSY: return ":/images/im-user-busy.png"; - case RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_ONLINE: return ":/images/im-user.png"; - case RS_STATUS_INACTIVE: + case RsStatusValue::RS_STATUS_INACTIVE: return ":/images/im-user-inactive.png"; } - std::cerr << "StatusDefs::imageIM: Unknown status requested " << status; + RsErr() << "StatusDefs::imageIM: Unknown status requested " << (int)status; return ""; } -const char *StatusDefs::imageUser(unsigned int status) +const char *StatusDefs::imageUser(RsStatusValue status) { switch (status) { - case RS_STATUS_OFFLINE: + default: + case RsStatusValue::RS_STATUS_OFFLINE: return ":/images/user/identityoffline24.png"; - case RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_AWAY: return ":/images/user/identity24away.png"; - case RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_BUSY: return ":/images/user/identity24busy.png"; - case RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_ONLINE: return ":/images/user/identity24.png"; - case RS_STATUS_INACTIVE: + case RsStatusValue::RS_STATUS_INACTIVE: return ":/images/user/identity24idle.png"; } - std::cerr << "StatusDefs::imageUser: Unknown status requested " << status; + RsErr() << "StatusDefs::imageUser: Unknown status requested " << (int)status; return ""; } -const char *StatusDefs::imageStatus(unsigned int status) +const char *StatusDefs::imageStatus(RsStatusValue status) { switch (status) { - case RS_STATUS_OFFLINE: + default: + case RsStatusValue::RS_STATUS_OFFLINE: return ":/icons/user-offline_64.png"; - case RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_AWAY: return ":/icons/user-away_64.png"; - case RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_BUSY: return ":/icons/user-busy_64.png"; - case RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_ONLINE: return ":/icons/user-online_64.png"; - case RS_STATUS_INACTIVE: + case RsStatusValue::RS_STATUS_INACTIVE: return ":/icons/user-away-extended_64.png"; } - std::cerr << "StatusDefs::imageUser: Unknown status requested " << status; + RsErr() << "StatusDefs::imageUser: Unknown status requested " << (int)status; return ""; } -QString StatusDefs::tooltip(unsigned int status) +QString StatusDefs::tooltip(RsStatusValue status) { switch (status) { - case RS_STATUS_OFFLINE: + default: + case RsStatusValue::RS_STATUS_OFFLINE: return qApp->translate("StatusDefs", "Friend is offline"); - case RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_AWAY: return qApp->translate("StatusDefs", "Friend is away"); - case RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_BUSY: return qApp->translate("StatusDefs", "Friend is busy"); - case RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_ONLINE: return qApp->translate("StatusDefs", "Friend is online"); - case RS_STATUS_INACTIVE: + case RsStatusValue::RS_STATUS_INACTIVE: return qApp->translate("StatusDefs", "Friend is idle"); } - std::cerr << "StatusDefs::tooltip: Unknown status requested " << status; + RsErr() << "StatusDefs::tooltip: Unknown status requested " << (int)status; return ""; } -QFont StatusDefs::font(unsigned int status) +QFont StatusDefs::font(RsStatusValue status) { QFont font; switch (status) { - case RS_STATUS_AWAY: - case RS_STATUS_BUSY: - case RS_STATUS_ONLINE: - case RS_STATUS_INACTIVE: + default: + case RsStatusValue::RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_INACTIVE: font.setBold(true); return font; - case RS_STATUS_OFFLINE: + case RsStatusValue::RS_STATUS_OFFLINE: font.setBold(false); return font; } - std::cerr << "StatusDefs::font: Unknown status requested " << status; + RsErr() << "StatusDefs::font: Unknown status requested " << (int)status; return font; } diff --git a/retroshare-gui/src/gui/common/StatusDefs.h b/retroshare-gui/src/gui/common/StatusDefs.h index b922e28e4..3a167930b 100644 --- a/retroshare-gui/src/gui/common/StatusDefs.h +++ b/retroshare-gui/src/gui/common/StatusDefs.h @@ -24,18 +24,20 @@ #include #include +#include "retroshare/rsstatus.h" + struct RsPeerDetails; class StatusDefs { public: - static QString name(unsigned int status); - static const char* imageIM(unsigned int status); - static const char* imageUser(unsigned int status); - static const char* imageStatus(unsigned int status); - static QString tooltip(unsigned int status); + static QString name(RsStatusValue status); + static const char* imageIM(RsStatusValue status); + static const char* imageUser(RsStatusValue status); + static const char* imageStatus(RsStatusValue status); + static QString tooltip(RsStatusValue status); - static QFont font(unsigned int status); + static QFont font(RsStatusValue status); static QString peerStateString(int peerState); static QString connectStateString(RsPeerDetails &details); diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 0ee408685..a12bab40b 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -65,6 +65,7 @@ #include "util/misc.h" #include "util/DateTime.h" #include "util/HandleRichText.h" +#include "util/qtthreadsutils.h" #include "util/QtVersion.h" #include "textformat.h" #include "TagsMenu.h" @@ -214,7 +215,21 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags) connect(ui.addBccButton, SIGNAL(clicked()), this, SLOT(addBcc())); connect(ui.addRecommendButton, SIGNAL(clicked()), this, SLOT(addRecommend())); - connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(peerStatusChanged(QString,int))); + //connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(peerStatusChanged(QString,int))); + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=](){ + auto fe = dynamic_cast(e.get()); + + if(!fe || fe->mEventCode != RsFriendListEventCode::NODE_STATUS_CHANGED) + return; + + peerStatusChanged(QString::fromStdString(fe->mSslId.toStdString()),fe->mStatus); + + }, this ); + },mEventHandlerId,RsEventType::FRIEND_LIST); + connect(ui.friendSelectionWidget, SIGNAL(contentChanged()), this, SLOT(buildCompleter())); connect(ui.friendSelectionWidget, SIGNAL(doubleClicked(int,QString)), this, SLOT(addTo())); connect(ui.friendSelectionWidget, SIGNAL(itemSelectionChanged()), this, SLOT(friendSelectionChanged())); @@ -420,6 +435,7 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags) MessageComposer::~MessageComposer() { + rsEvents->unregisterEventsHandler(mEventHandlerId); delete(m_compareRole); } @@ -811,7 +827,7 @@ void MessageComposer::buildCompleter() setNewCompleter(ui.recipientWidget, m_completer); } -void MessageComposer::peerStatusChanged(const QString& peer_id, int status) +void MessageComposer::peerStatusChanged(const QString& peer_id, RsStatusValue status) { int rowCount = ui.recipientWidget->rowCount(); int row; diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.h b/retroshare-gui/src/gui/msgs/MessageComposer.h index 27bf28458..121578f3f 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.h +++ b/retroshare-gui/src/gui/msgs/MessageComposer.h @@ -157,7 +157,7 @@ private slots: void editingRecipientFinished(); void contactDetails(); - void peerStatusChanged(const QString& peer_id, int status); + void peerStatusChanged(const QString& peer_id, RsStatusValue status); void friendSelectionChanged(); void tagAboutToShow(); @@ -274,6 +274,7 @@ private: Ui::MessageComposer ui; std::list _recList ; + RsEventsHandlerId_t mEventHandlerId; }; #endif diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index e230b2eb1..d3fe147a8 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -333,6 +333,7 @@ void NotifyQt::notifyDiskFull(uint32_t loc,uint32_t size_in_mb) emit diskFull(loc,size_in_mb) ; } +#ifdef TO_REMOVE /* peer has changed the state */ void NotifyQt::notifyPeerStatusChanged(const std::string& peer_id, uint32_t state) { @@ -364,6 +365,7 @@ void NotifyQt::notifyPeerStatusChangedSummary() emit peerStatusChangedSummary(); } +#endif void NotifyQt::notifyOwnStatusMessageChanged() { diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index 6e0adb7d8..eb52fad1a 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -79,9 +79,9 @@ class NotifyQt: public QObject, public NotifyClient virtual void notifyOwnStatusMessageChanged() ; virtual void notifyDiskFull(uint32_t loc,uint32_t size_in_mb) ; /* peer has changed the state */ - virtual void notifyPeerStatusChanged(const std::string& peer_id, uint32_t state); +// virtual void notifyPeerStatusChanged(const std::string& peer_id, uint32_t state); /* one or more peers has changed the states */ - virtual void notifyPeerStatusChangedSummary(); +// virtual void notifyPeerStatusChangedSummary(); virtual void notifyHistoryChanged(uint32_t msgId, int type); @@ -122,8 +122,8 @@ class NotifyQt: public QObject, public NotifyClient void ownStatusMessageChanged() const ; void errorOccurred(int,int,const QString&) const ; void diskFull(int,int) const ; - void peerStatusChanged(const QString& /* peer_id */, int /* status */); - void peerStatusChangedSummary() const; +// void peerStatusChanged(const QString& /* peer_id */, int /* status */); +// void peerStatusChangedSummary() const; void gxsChange(const RsGxsChanges& /* changes */); void chatMessageReceived(ChatMessage msg); // void groupsChanged(int type) const ; From c70b84497ac1bde2ac515701f18116d3dc913cd6 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 17 Jun 2025 20:40:56 +0200 Subject: [PATCH 05/38] moved pre/post-ModDirectories to rsEvents --- .../gui/FileTransfer/SharedFilesDialog.cpp | 36 ++++++++++++++++--- .../src/gui/FileTransfer/SharedFilesDialog.h | 3 ++ retroshare-gui/src/gui/notifyqt.cpp | 20 +++++------ retroshare-gui/src/gui/notifyqt.h | 2 +- retroshare-gui/src/main.cpp | 2 +- 5 files changed, 47 insertions(+), 16 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp index 8978ccf71..a7cc487fc 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp @@ -22,7 +22,6 @@ #include "rshare.h" #include "gui/MainWindow.h" -#include "gui/notifyqt.h" #include "gui/RemoteDirModel.h" #include "gui/RetroShareLink.h" #include "gui/ShareManager.h" @@ -35,6 +34,7 @@ #include "gui/settings/rsharesettings.h" #include "util/QtVersion.h" #include "util/RsAction.h" +#include "util/qtthreadsutils.h" #include "util/misc.h" #include "util/rstime.h" #include "util/rsdir.h" @@ -166,6 +166,7 @@ public: SharedFilesDialog::~SharedFilesDialog() { + rsEvents->unregisterEventsHandler(mEventHandlerId); delete tree_model; delete flat_model; delete tree_proxyModel; @@ -177,9 +178,36 @@ SharedFilesDialog::SharedFilesDialog(bool remote_mode, QWidget *parent) /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); - NotifyQt *notify = NotifyQt::getInstance(); - connect(notify, SIGNAL(filesPreModChanged(bool)), this, SLOT(preModDirectories(bool))); - connect(notify, SIGNAL(filesPostModChanged(bool)), this, SLOT(postModDirectories(bool))); + //connect(notify, SIGNAL(filesPreModChanged(bool)), this, SLOT(preModDirectories(bool))); + //connect(notify, SIGNAL(filesPostModChanged(bool)), this, SLOT(postModDirectories(bool))); + + mEventHandlerId = 0; + + rsEvents->registerEventsHandler([this](std::shared_ptr event) + { + RsQThreadUtils::postToObject([=](){ + + auto e = dynamic_cast(event.get()); + + switch(e->mEventCode) + { + case RsSharedDirectoriesEventCode::OWN_DIR_LIST_PROCESSING: + preModDirectories(true); + break; + + case RsSharedDirectoriesEventCode::OWN_DIR_LIST_UPDATED: + postModDirectories(true); + break; + + case RsSharedDirectoriesEventCode::FRIEND_DIR_LIST_UPDATED: + preModDirectories(false); + postModDirectories(false); + break; + + default: + break; + };}, this); + }, mEventHandlerId,RsEventType::SHARED_DIRECTORIES); connect(ui.viewType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCurrentViewModel(int))); connect(ui.dirTreeView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT( spawnCustomPopupMenu( QPoint ) ) ); diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h index 7524d5035..375b6c075 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h @@ -21,6 +21,7 @@ #ifndef _SHAREDFILESDIALOG_H #define _SHAREDFILESDIALOG_H +#include #include "ui_SharedFilesDialog.h" #include @@ -145,6 +146,8 @@ protected: QString lastFilterString; QString mLastFilterText ; RsProtectedTimer* mFilterTimer; + + RsEventsHandlerId_t mEventHandlerId ; }; class LocalSharedFilesDialog : public SharedFilesDialog diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index d3fe147a8..860ce043f 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -549,26 +549,26 @@ void NotifyQt::notifyListChange(int list, int type) #endif emit friendsChanged() ; break; -#endif case NOTIFY_LIST_DIRLIST_LOCAL: #ifdef NOTIFY_DEBUG std::cerr << "received files changed" << std::endl ; #endif emit filesPostModChanged(true) ; /* Local */ break; - case NOTIFY_LIST_CHAT_LOBBY_INVITATION: -#ifdef NOTIFY_DEBUG - std::cerr << "received files changed" << std::endl ; -#endif - emit chatLobbyInviteReceived() ; /* Local */ - break; case NOTIFY_LIST_DIRLIST_FRIENDS: #ifdef NOTIFY_DEBUG std::cerr << "received files changed" << std::endl ; #endif emit filesPostModChanged(false) ; /* Local */ break; - case NOTIFY_LIST_CONFIG: +#endif + case NOTIFY_LIST_CHAT_LOBBY_INVITATION: +#ifdef NOTIFY_DEBUG + std::cerr << "received files changed" << std::endl ; +#endif + emit chatLobbyInviteReceived() ; /* Local */ + break; + case NOTIFY_LIST_CONFIG: #ifdef NOTIFY_DEBUG std::cerr << "received config changed" << std::endl ; #endif @@ -653,14 +653,14 @@ void NotifyQt::notifyListPreChange(int list, int /*type*/) case NOTIFY_LIST_FRIENDS: emit friendsChanged() ; break; -#endif case NOTIFY_LIST_DIRLIST_FRIENDS: emit filesPreModChanged(false) ; /* remote */ break ; case NOTIFY_LIST_DIRLIST_LOCAL: emit filesPreModChanged(true) ; /* local */ break; - case NOTIFY_LIST_SEARCHLIST: +#endif + case NOTIFY_LIST_SEARCHLIST: break; case NOTIFY_LIST_CHANNELLIST: break; diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index eb52fad1a..7be023772 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -105,7 +105,7 @@ class NotifyQt: public QObject, public NotifyClient // as they get queued by Qt. // void hashingInfoChanged(const QString&) const ; - void filesPreModChanged(bool) const ; +// void filesPreModChanged(bool) const ; void filesPostModChanged(bool) const ; // void transfersChanged() const ; // void friendsChanged() const ; diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index c349df404..ad37fb54c 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -728,7 +728,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); // QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(chatLobbyTimeShift(int)),notify,SLOT(handleChatLobbyTimeShift(int)),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; - QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool)) ,Qt::QueuedConnection ) ; +// QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool)) ,Qt::QueuedConnection ) ; // QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ; From 41d972b3593984db4b8199655e8e3977b82ab6af Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 17 Jun 2025 21:22:39 +0200 Subject: [PATCH 06/38] removed unused stuff --- retroshare-gui/src/gui/notifyqt.cpp | 10 +++++----- retroshare-gui/src/gui/notifyqt.h | 8 ++++---- retroshare-gui/src/main.cpp | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 860ce043f..b7eb36bd2 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -536,13 +536,13 @@ void NotifyQt::notifyListChange(int list, int type) #endif switch(list) { - case NOTIFY_LIST_NEIGHBOURS: +#ifdef TO_REMOVE + case NOTIFY_LIST_NEIGHBOURS: #ifdef NOTIFY_DEBUG std::cerr << "received neighbours changed" << std::endl ; #endif emit neighboursChanged(); break; -#ifdef TO_REMOVE case NOTIFY_LIST_FRIENDS: #ifdef NOTIFY_DEBUG std::cerr << "received friends changed" << std::endl ; @@ -634,6 +634,7 @@ void NotifyQt::notifyListChange(int list, int type) return; } +#ifdef TO_REMOVE void NotifyQt::notifyListPreChange(int list, int /*type*/) { { @@ -649,7 +650,6 @@ void NotifyQt::notifyListPreChange(int list, int /*type*/) { case NOTIFY_LIST_NEIGHBOURS: break; -#ifdef TO_REMOVE case NOTIFY_LIST_FRIENDS: emit friendsChanged() ; break; @@ -659,7 +659,6 @@ void NotifyQt::notifyListPreChange(int list, int /*type*/) case NOTIFY_LIST_DIRLIST_LOCAL: emit filesPreModChanged(true) ; /* local */ break; -#endif case NOTIFY_LIST_SEARCHLIST: break; case NOTIFY_LIST_CHANNELLIST: @@ -671,6 +670,7 @@ void NotifyQt::notifyListPreChange(int list, int /*type*/) } return; } +#endif void NotifyQt::enable() { @@ -694,7 +694,7 @@ void NotifyQt::UpdateGUI() // the gui is running, then they get updated by callbacks. if(!already_updated) { - emit neighboursChanged(); +// emit neighboursChanged(); emit configChanged(); already_updated = true ; diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index 7be023772..8adfd9fd7 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -60,7 +60,7 @@ class NotifyQt: public QObject, public NotifyClient void setNetworkDialog(NetworkDialog *c) { cDialog = c; } - virtual void notifyListPreChange(int list, int type); +// virtual void notifyListPreChange(int list, int type); virtual void notifyListChange(int list, int type); // virtual void notifyErrorMsg(int list, int sev, std::string msg); virtual void notifyChatMessage(const ChatMessage& /* msg */); @@ -104,14 +104,14 @@ class NotifyQt: public QObject, public NotifyClient // It's beneficial to send info to the GUI using signals, because signals are thread-safe // as they get queued by Qt. // - void hashingInfoChanged(const QString&) const ; +// void hashingInfoChanged(const QString&) const ; // void filesPreModChanged(bool) const ; - void filesPostModChanged(bool) const ; +// void filesPostModChanged(bool) const ; // void transfersChanged() const ; // void friendsChanged() const ; void lobbyListChanged() const ; void chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&) ; - void neighboursChanged() const ; +// void neighboursChanged() const ; void configChanged() const ; void logInfoChanged(const QString&) const ; void chatStatusChanged(const ChatId&,const QString&) const ; diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index ad37fb54c..dffe7e133 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -731,7 +731,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); // QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool)) ,Qt::QueuedConnection ) ; // QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); - QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ; +// QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ; QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->friendsDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool))); QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->friendsDialog,SLOT(loadmypersonalstatus())); From 4b9d060c8172308f1a8b32003b88db2a4d1aaf5f Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 25 Jun 2025 16:49:26 +0200 Subject: [PATCH 07/38] swiched some of the chat room notify to RsEvent and added new event code for SYSTEM errors --- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 42 ++++++++++++++++--- retroshare-gui/src/gui/ChatLobbyWidget.h | 6 ++- retroshare-gui/src/gui/MainWindow.cpp | 24 +++++++++++ .../src/gui/chat/ChatLobbyDialog.cpp | 14 +++---- retroshare-gui/src/gui/chat/ChatLobbyDialog.h | 2 +- retroshare-gui/src/gui/notifyqt.cpp | 6 +-- retroshare-gui/src/gui/notifyqt.h | 14 +++---- retroshare-gui/src/main.cpp | 4 +- 8 files changed, 85 insertions(+), 27 deletions(-) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index 4caa97706..79a6664b3 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -35,6 +35,7 @@ #include "settings/rsharesettings.h" #include "util/HandleRichText.h" #include "util/misc.h" +#include "util/qtthreadsutils.h" #include "util/QtVersion.h" #include "retroshare/rsmsgs.h" @@ -105,9 +106,39 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags) myInviteYesButton = NULL; myInviteIdChooser = NULL; - QObject::connect( NotifyQt::getInstance(), SIGNAL(lobbyListChanged()), SLOT(lobbyChanged())); - QObject::connect( NotifyQt::getInstance(), SIGNAL(chatLobbyEvent(qulonglong,int,RsGxsId,QString)), this, SLOT(displayChatLobbyEvent(qulonglong,int,RsGxsId,QString))); - QObject::connect( NotifyQt::getInstance(), SIGNAL(chatLobbyInviteReceived()), this, SLOT(readChatLobbyInvites())); + //QObject::connect( NotifyQt::getInstance(), SIGNAL(lobbyListChanged()), SLOT(lobbyChanged())); + //QObject::connect( NotifyQt::getInstance(), SIGNAL(chatLobbyEvent(qulonglong,int,RsGxsId,QString)), this, SLOT(displayChatLobbyEvent(qulonglong,int,RsGxsId,QString))); + //QObject::connect( NotifyQt::getInstance(), SIGNAL(chatLobbyInviteReceived()), this, SLOT(readChatLobbyInvites())); + + rsEvents->registerEventsHandler( [this](std::shared_ptr event) + { + RsQThreadUtils::postToObject([=](){ + auto ev = dynamic_cast(event.get()); + + switch(ev->mEventCode) + { + case RsChatStatusEventCode::CHAT_LOBBY_INVITE_RECEIVED: + readChatLobbyInvites(); + break; + + case RsChatStatusEventCode::CHAT_LOBBY_LIST_CHANGED: + lobbyChanged(); + break; + + case RsChatStatusEventCode::CHAT_LOBBY_EVENT_PEER_LEFT: + case RsChatStatusEventCode::CHAT_LOBBY_EVENT_PEER_STATUS: + case RsChatStatusEventCode::CHAT_LOBBY_EVENT_PEER_JOINED: + case RsChatStatusEventCode::CHAT_LOBBY_EVENT_PEER_CHANGE_NICKNAME: + case RsChatStatusEventCode::CHAT_LOBBY_EVENT_KEEP_ALIVE: + + handleChatLobbyEvent(ev->mLobbyId,ev->mEventCode,ev->mGxsId,QString::fromUtf8(ev->str.c_str())); + break; + + default: + break; + } + }, this ); + }, mEventHandlerId, RsEventType::CHAT_SERVICE ); QObject::connect( ui.lobbyTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(lobbyTreeWidgetCustomPopupMenu(QPoint))); QObject::connect( ui.lobbyTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*,int))); @@ -236,6 +267,7 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags) ChatLobbyWidget::~ChatLobbyWidget() { + rsEvents->unregisterEventsHandler(mEventHandlerId); // save settings processSettings(false); @@ -1158,10 +1190,10 @@ void ChatLobbyWidget::itemDoubleClicked(QTreeWidgetItem *item, int /*column*/) subscribeChatLobbyAtItem(item); } -void ChatLobbyWidget::displayChatLobbyEvent(qulonglong lobby_id, int event_type, const RsGxsId &gxs_id, const QString& str) +void ChatLobbyWidget::handleChatLobbyEvent(uint64_t lobby_id, RsChatStatusEventCode event_type, const RsGxsId &gxs_id, const QString& str) { if (ChatLobbyDialog *cld = dynamic_cast(ChatDialog::getExistingChat(ChatId(lobby_id)))) { - cld->displayLobbyEvent(event_type, gxs_id, str); + cld->handleLobbyEvent(event_type, gxs_id, str); } } diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.h b/retroshare-gui/src/gui/ChatLobbyWidget.h index 424780dac..648e7dac9 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.h +++ b/retroshare-gui/src/gui/ChatLobbyWidget.h @@ -89,8 +89,8 @@ protected slots: void unsubscribeItem(); void itemDoubleClicked(QTreeWidgetItem *item, int column); void updateCurrentLobby() ; - void displayChatLobbyEvent(qulonglong lobby_id, int event_type, const RsGxsId& gxs_id, const QString& str); - void readChatLobbyInvites(); + void handleChatLobbyEvent(uint64_t lobby_id, RsChatStatusEventCode event_type, const RsGxsId &gxs_id, const QString& str); + void readChatLobbyInvites(); void showLobby(QTreeWidgetItem *lobby_item) ; void showBlankPage(ChatLobbyId id, bool subscribed = false) ; void unsubscribeChatLobby(ChatLobbyId id) ; @@ -151,5 +151,7 @@ private: /* UI - from Designer */ Ui::ChatLobbyWidget ui; + + RsEventsHandlerId_t mEventHandlerId; }; diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 964b42c92..b9abc4ae9 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -32,6 +32,7 @@ #include "retroshare/rsplugin.h" #include "retroshare/rsconfig.h" +#include "retroshare/rsevents.h" #include "util/argstream.h" #include "util/qtthreadsutils.h" @@ -380,6 +381,29 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) settingsChanged(); mFontSizeHandler.registerFontSize(ui->listWidget, 1.5f); + + rsEvents->registerEventsHandler( [this](std::shared_ptr event) + { + RsQThreadUtils::postToObject([=](){ + auto ev = dynamic_cast(event.get()); + + switch(ev->mEventCode) + { + case RsSystemErrorEventCode::TIME_SHIFT_PROBLEM: + std::cerr << "Time shift problem notification. Ignored." << std::endl; + break; + + case RsSystemErrorEventCode::DISK_SPACE_ERROR: + displayDiskSpaceWarning(ev->mDiskErrorLocation,ev->mDiskErrorSizeLimit); + + break; + + default: + break; + } + }, this ); + }, mEventHandlerId, RsEventType::SYSTEM_ERROR ); + } /** Destructor. */ diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index dd4a128a4..a0bed44f9 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -846,7 +846,7 @@ QString ChatLobbyDialog::getParticipantName(const RsGxsId& gxs_id) const } -void ChatLobbyDialog::displayLobbyEvent(int event_type, const RsGxsId& gxs_id, const QString& str) +void ChatLobbyDialog::handleLobbyEvent(RsChatStatusEventCode event_type, const RsGxsId& gxs_id, const QString& str) { RsGxsId qsParticipant; @@ -854,17 +854,17 @@ void ChatLobbyDialog::displayLobbyEvent(int event_type, const RsGxsId& gxs_id, c switch (event_type) { - case RS_CHAT_LOBBY_EVENT_PEER_LEFT: + case RsChatStatusEventCode::CHAT_LOBBY_EVENT_PEER_LEFT: qsParticipant=gxs_id; ui.chatWidget->addChatMsg(true, tr("Chat room management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 has left the room.").arg(RsHtml::plainText(name)), ChatWidget::MSGTYPE_SYSTEM); emit peerLeft(id()) ; break; - case RS_CHAT_LOBBY_EVENT_PEER_JOINED: + case RsChatStatusEventCode::CHAT_LOBBY_EVENT_PEER_JOINED: qsParticipant=gxs_id; ui.chatWidget->addChatMsg(true, tr("Chat room management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 joined the room.").arg(RsHtml::plainText(name)), ChatWidget::MSGTYPE_SYSTEM); emit peerJoined(id()) ; break; - case RS_CHAT_LOBBY_EVENT_PEER_STATUS: + case RsChatStatusEventCode::CHAT_LOBBY_EVENT_PEER_STATUS: { qsParticipant=gxs_id; @@ -876,7 +876,7 @@ void ChatLobbyDialog::displayLobbyEvent(int event_type, const RsGxsId& gxs_id, c } break; - case RS_CHAT_LOBBY_EVENT_PEER_CHANGE_NICKNAME: + case RsChatStatusEventCode::CHAT_LOBBY_EVENT_PEER_CHANGE_NICKNAME: { qsParticipant=gxs_id; @@ -892,11 +892,11 @@ void ChatLobbyDialog::displayLobbyEvent(int event_type, const RsGxsId& gxs_id, c muteParticipant(RsGxsId(str.toStdString())) ; } break; - case RS_CHAT_LOBBY_EVENT_KEEP_ALIVE: + case RsChatStatusEventCode::CHAT_LOBBY_EVENT_KEEP_ALIVE: //std::cerr << "Received keep alive packet from " << nickname.toStdString() << " in chat room " << getPeerId() << std::endl; break; default: - std::cerr << "ChatLobbyDialog::displayLobbyEvent() Unhandled chat room event type " << event_type << std::endl; + std::cerr << "ChatLobbyDialog::handledLobbyEvent() Unhandled chat room event type " << (int)event_type << std::endl; } if (!qsParticipant.isNull()) diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h index c3572cc4b..1d388b57f 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h @@ -42,7 +42,7 @@ class ChatLobbyDialog: public ChatDialog friend class ChatDialog; public: - void displayLobbyEvent(int event_type, const RsGxsId &gxs_id, const QString& str); + void handleLobbyEvent(RsChatStatusEventCode event_type, const RsGxsId& gxs_id, const QString& str); virtual void showDialog(uint chatflags); virtual ChatWidget *getChatWidget(); diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index b7eb36bd2..aa0da0b12 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -320,6 +320,7 @@ void NotifyQt::notifyDiscInfoChanged() emit discInfoChanged() ; } +#ifdef TO_REMOVE void NotifyQt::notifyDiskFull(uint32_t loc,uint32_t size_in_mb) { { @@ -333,7 +334,6 @@ void NotifyQt::notifyDiskFull(uint32_t loc,uint32_t size_in_mb) emit diskFull(loc,size_in_mb) ; } -#ifdef TO_REMOVE /* peer has changed the state */ void NotifyQt::notifyPeerStatusChanged(const std::string& peer_id, uint32_t state) { @@ -408,6 +408,7 @@ void NotifyQt::notifyCustomState(const std::string& peer_id, const std::string& emit peerHasNewCustomStateString(QString::fromStdString(peer_id), QString::fromUtf8(status_string.c_str())) ; } +#ifdef TO_REMOVE void NotifyQt::notifyChatLobbyTimeShift(int shift) { { @@ -450,6 +451,7 @@ void NotifyQt::notifyChatLobbyEvent(uint64_t lobby_id,uint32_t event_type,const #endif emit chatLobbyEvent(lobby_id,event_type,nickname,QString::fromUtf8(str.c_str())) ; } +#endif void NotifyQt::notifyChatStatus(const ChatId& chat_id,const std::string& status_string) { @@ -561,7 +563,6 @@ void NotifyQt::notifyListChange(int list, int type) #endif emit filesPostModChanged(false) ; /* Local */ break; -#endif case NOTIFY_LIST_CHAT_LOBBY_INVITATION: #ifdef NOTIFY_DEBUG std::cerr << "received files changed" << std::endl ; @@ -575,7 +576,6 @@ void NotifyQt::notifyListChange(int list, int type) emit configChanged() ; break ; -#ifdef REMOVE case NOTIFY_LIST_SEARCHLIST: break; case NOTIFY_LIST_CHANNELLIST: diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index 8adfd9fd7..fd3d51e7f 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -73,11 +73,11 @@ class NotifyQt: public QObject, public NotifyClient // virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list& found_groups); virtual void notifyPeerHasNewAvatar(std::string peer_id) ; virtual void notifyOwnAvatarChanged() ; - virtual void notifyChatLobbyEvent(uint64_t /* lobby id */, uint32_t /* event type */, const RsGxsId & /*nickname*/, const std::string& /* any string */) ; - virtual void notifyChatLobbyTimeShift(int time_shift) ; +// virtual void notifyChatLobbyEvent(uint64_t /* lobby id */, uint32_t /* event type */, const RsGxsId & /*nickname*/, const std::string& /* any string */) ; +// virtual void notifyChatLobbyTimeShift(int time_shift) ; virtual void notifyOwnStatusMessageChanged() ; - virtual void notifyDiskFull(uint32_t loc,uint32_t size_in_mb) ; +// virtual void notifyDiskFull(uint32_t loc,uint32_t size_in_mb) ; /* peer has changed the state */ // virtual void notifyPeerStatusChanged(const std::string& peer_id, uint32_t state); /* one or more peers has changed the states */ @@ -110,7 +110,7 @@ class NotifyQt: public QObject, public NotifyClient // void transfersChanged() const ; // void friendsChanged() const ; void lobbyListChanged() const ; - void chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&) ; +// void chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&) ; // void neighboursChanged() const ; void configChanged() const ; void logInfoChanged(const QString&) const ; @@ -129,9 +129,9 @@ class NotifyQt: public QObject, public NotifyClient // void groupsChanged(int type) const ; void discInfoChanged() const ; void historyChanged(uint msgId, int type); - void chatLobbyInviteReceived() ; +// void chatLobbyInviteReceived() ; // void deferredSignatureHandlingRequested() ; - void chatLobbyTimeShift(int time_shift) ; +// void chatLobbyTimeShift(int time_shift) ; void connectionWithoutCert(); /* Notify from GUI */ @@ -147,7 +147,7 @@ class NotifyQt: public QObject, public NotifyClient private slots: void runningTick(); void handleSignatureEvent() ; - void handleChatLobbyTimeShift(int) ; +// void handleChatLobbyTimeShift(int) ; private: NotifyQt(); diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index dffe7e133..71daf5271 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -726,8 +726,8 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); std::cerr << "connecting signals and slots" << std::endl ; #endif // QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ; - QObject::connect(notify,SIGNAL(chatLobbyTimeShift(int)),notify,SLOT(handleChatLobbyTimeShift(int)),Qt::QueuedConnection) ; - QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; +// QObject::connect(notify,SIGNAL(chatLobbyTimeShift(int)),notify,SLOT(handleChatLobbyTimeShift(int)),Qt::QueuedConnection) ; +// QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; // QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool)) ,Qt::QueuedConnection ) ; // QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); From 9b881a62146342264d67e0cb5207305bb87fe6c2 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 10 Jul 2025 15:39:10 +0200 Subject: [PATCH 08/38] moved ownAvatarChanged() and ownStatusChanged() to rsEvents --- retroshare-gui/src/gui/MessengerWindow.cpp | 15 +++++++++++---- retroshare-gui/src/gui/common/AvatarWidget.cpp | 18 +++++++++++++++--- .../src/gui/common/NewFriendList.cpp | 2 +- retroshare-gui/src/gui/notifyqt.cpp | 4 +++- retroshare-gui/src/gui/notifyqt.h | 14 +++++++------- retroshare-gui/src/main.cpp | 2 +- 6 files changed, 38 insertions(+), 17 deletions(-) diff --git a/retroshare-gui/src/gui/MessengerWindow.cpp b/retroshare-gui/src/gui/MessengerWindow.cpp index ca2a5530e..28db4a7ee 100644 --- a/retroshare-gui/src/gui/MessengerWindow.cpp +++ b/retroshare-gui/src/gui/MessengerWindow.cpp @@ -95,8 +95,8 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WindowFlags flags) ui.avatar->setOwnId(); connect(ui.messagelineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(savestatusmessage())); - connect(NotifyQt::getInstance(), SIGNAL(ownStatusMessageChanged()), this, SLOT(loadmystatusmessage())); + //connect(NotifyQt::getInstance(), SIGNAL(ownStatusMessageChanged()), this, SLOT(loadmystatusmessage())); //connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateOwnStatus(QString,int))); mEventHandlerId = 0; @@ -105,10 +105,17 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WindowFlags flags) RsQThreadUtils::postToObject([=](){ auto fe = dynamic_cast(e.get()); - if(!fe || fe->mEventCode != RsFriendListEventCode::NODE_STATUS_CHANGED) - return; + if(!fe) return; - updateOwnStatus(QString::fromStdString(fe->mSslId.toStdString()),fe->mStatus); + switch(fe->mEventCode) + { + case RsFriendListEventCode::NODE_STATUS_CHANGED: updateOwnStatus(QString::fromStdString(fe->mSslId.toStdString()),fe->mStatus); + break; + case RsFriendListEventCode::OWN_STATUS_CHANGED: loadmystatusmessage(); + break; + default: + break; + } }, this ); },mEventHandlerId,RsEventType::FRIEND_LIST); diff --git a/retroshare-gui/src/gui/common/AvatarWidget.cpp b/retroshare-gui/src/gui/common/AvatarWidget.cpp index afb4c883c..75ac697f5 100644 --- a/retroshare-gui/src/gui/common/AvatarWidget.cpp +++ b/retroshare-gui/src/gui/common/AvatarWidget.cpp @@ -49,8 +49,8 @@ AvatarWidget::AvatarWidget(QWidget *parent) : QLabel(parent), ui(new Ui::AvatarW setFrameType(NO_FRAME); /* connect signals */ - connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&))); - connect(NotifyQt::getInstance(), SIGNAL(ownAvatarChanged()), this, SLOT(updateOwnAvatar())); + //connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&))); + //connect(NotifyQt::getInstance(), SIGNAL(ownAvatarChanged()), this, SLOT(updateOwnAvatar())); mEventHandlerId = 0; @@ -61,7 +61,19 @@ AvatarWidget::AvatarWidget(QWidget *parent) : QLabel(parent), ui(new Ui::AvatarW const RsFriendListEvent *e = dynamic_cast(event.get()); if(!e) return; - updateStatus(QString::fromStdString(e->mSslId.toStdString()),e->mStatus); + + switch(e->mEventCode) + { + case RsFriendListEventCode::OWN_AVATAR_CHANGED: + case RsFriendListEventCode::NODE_AVATAR_CHANGED: updateAvatar(QString::fromStdString(e->mSslId.toStdString())); + break; + case RsFriendListEventCode::OWN_STATUS_CHANGED: + case RsFriendListEventCode::NODE_STATUS_CHANGED: updateStatus(QString::fromStdString(e->mSslId.toStdString()),e->mStatus); + default: + break; + } + + }, this ); }, mEventHandlerId, RsEventType::FRIEND_LIST ); diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index e2b920ec1..94381859c 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -203,7 +203,7 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par rsEvents->registerEventsHandler( [this](std::shared_ptr e) { handleEvent(e); }, mEventHandlerId_peer, RsEventType::FRIEND_LIST ); rsEvents->registerEventsHandler( [this](std::shared_ptr e) { handleEvent(e); }, mEventHandlerId_gssp, RsEventType::GOSSIP_DISCOVERY ); - connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(QString)), this, SLOT(forceUpdateDisplay())); +// connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(QString)), this, SLOT(forceUpdateDisplay())); // connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(forceUpdateDisplay())); mModel = new RsFriendListModel(ui->peerTreeWidget); diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index aa0da0b12..3c415b115 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -133,6 +133,7 @@ void NotifyQt::notifyChatMessage(const ChatMessage &msg) emit chatMessageReceived(msg); } +#ifdef TO_REMOVE void NotifyQt::notifyOwnAvatarChanged() { { @@ -146,6 +147,7 @@ void NotifyQt::notifyOwnAvatarChanged() #endif emit ownAvatarChanged() ; } +#endif class SignatureEventData { @@ -365,7 +367,6 @@ void NotifyQt::notifyPeerStatusChangedSummary() emit peerStatusChangedSummary(); } -#endif void NotifyQt::notifyOwnStatusMessageChanged() { @@ -393,6 +394,7 @@ void NotifyQt::notifyPeerHasNewAvatar(std::string peer_id) #endif emit peerHasNewAvatar(QString::fromStdString(peer_id)) ; } +#endif void NotifyQt::notifyCustomState(const std::string& peer_id, const std::string& status_string) { diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index fd3d51e7f..c2c2a831a 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -71,12 +71,12 @@ class NotifyQt: public QObject, public NotifyClient // virtual void notifyTurtleSearchResult(const RsPeerId &pid, uint32_t search_id, const std::list& found_files); //#endif // virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list& found_groups); - virtual void notifyPeerHasNewAvatar(std::string peer_id) ; - virtual void notifyOwnAvatarChanged() ; -// virtual void notifyChatLobbyEvent(uint64_t /* lobby id */, uint32_t /* event type */, const RsGxsId & /*nickname*/, const std::string& /* any string */) ; +// virtual void notifyPeerHasNewAvatar(std::string peer_id) ; +// virtual void notifyOwnAvatarChanged() ; +// virtual void notifyChatLobbyEvent(uint64_t /* lobby id */, uint32_t /* event type */, const RsGxsId & /*nickname*/, const std::string& /* any string */) ; // virtual void notifyChatLobbyTimeShift(int time_shift) ; - virtual void notifyOwnStatusMessageChanged() ; +// virtual void notifyOwnStatusMessageChanged() ; // virtual void notifyDiskFull(uint32_t loc,uint32_t size_in_mb) ; /* peer has changed the state */ // virtual void notifyPeerStatusChanged(const std::string& peer_id, uint32_t state); @@ -117,9 +117,9 @@ class NotifyQt: public QObject, public NotifyClient void chatStatusChanged(const ChatId&,const QString&) const ; void chatCleared(const ChatId&) const ; void peerHasNewCustomStateString(const QString& /* peer_id */, const QString& /* status_string */) const ; - void peerHasNewAvatar(const QString& peer_id) const ; - void ownAvatarChanged() const ; - void ownStatusMessageChanged() const ; +// void peerHasNewAvatar(const QString& peer_id) const ; +// void ownAvatarChanged() const ; +// void ownStatusMessageChanged() const ; void errorOccurred(int,int,const QString&) const ; void diskFull(int,int) const ; // void peerStatusChanged(const QString& /* peer_id */, int /* status */); diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 71daf5271..9a30fb464 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -734,7 +734,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); // QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ; QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->friendsDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool))); - QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->friendsDialog,SLOT(loadmypersonalstatus())); +// QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->friendsDialog,SLOT(loadmypersonalstatus())); // QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)) ,w->friendsDialog->networkDialog,SLOT(setLogInfo(QString))) ; QObject::connect(notify,SIGNAL(discInfoChanged()) ,w->friendsDialog->networkView,SLOT(update()),Qt::QueuedConnection) ; From 2506bc5672d7dabb08fa7a5de338a9498134e902 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 12 Aug 2025 21:00:11 +0200 Subject: [PATCH 09/38] using rsEvents for Chat rooms --- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 22 ++++--- retroshare-gui/src/gui/ChatLobbyWidget.h | 2 +- retroshare-gui/src/gui/FriendsDialog.cpp | 64 +++++++++++++------ retroshare-gui/src/gui/FriendsDialog.h | 9 ++- .../src/gui/chat/ChatLobbyDialog.cpp | 12 ++-- retroshare-gui/src/gui/chat/ChatLobbyDialog.h | 2 +- .../src/gui/chat/ChatUserNotify.cpp | 26 +++++++- retroshare-gui/src/gui/chat/ChatUserNotify.h | 9 +-- retroshare-gui/src/gui/notifyqt.cpp | 20 +++--- retroshare-gui/src/gui/notifyqt.h | 4 +- 10 files changed, 111 insertions(+), 59 deletions(-) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index 79a6664b3..d751dabf3 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -113,25 +113,27 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags) rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject([=](){ - auto ev = dynamic_cast(event.get()); + auto ev = dynamic_cast(event.get()); + + if(!ev) return; switch(ev->mEventCode) { - case RsChatStatusEventCode::CHAT_LOBBY_INVITE_RECEIVED: + case RsChatLobbyEventCode::CHAT_LOBBY_INVITE_RECEIVED: readChatLobbyInvites(); break; - case RsChatStatusEventCode::CHAT_LOBBY_LIST_CHANGED: + case RsChatLobbyEventCode::CHAT_LOBBY_LIST_CHANGED: lobbyChanged(); break; - case RsChatStatusEventCode::CHAT_LOBBY_EVENT_PEER_LEFT: - case RsChatStatusEventCode::CHAT_LOBBY_EVENT_PEER_STATUS: - case RsChatStatusEventCode::CHAT_LOBBY_EVENT_PEER_JOINED: - case RsChatStatusEventCode::CHAT_LOBBY_EVENT_PEER_CHANGE_NICKNAME: - case RsChatStatusEventCode::CHAT_LOBBY_EVENT_KEEP_ALIVE: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_PEER_LEFT: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_PEER_STATUS: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_PEER_JOINED: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_PEER_CHANGE_NICKNAME: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_KEEP_ALIVE: - handleChatLobbyEvent(ev->mLobbyId,ev->mEventCode,ev->mGxsId,QString::fromUtf8(ev->str.c_str())); + handleChatLobbyEvent(ev->mLobbyId,ev->mEventCode,ev->mGxsId,QString::fromUtf8(ev->mStr.c_str())); break; default: @@ -1190,7 +1192,7 @@ void ChatLobbyWidget::itemDoubleClicked(QTreeWidgetItem *item, int /*column*/) subscribeChatLobbyAtItem(item); } -void ChatLobbyWidget::handleChatLobbyEvent(uint64_t lobby_id, RsChatStatusEventCode event_type, const RsGxsId &gxs_id, const QString& str) +void ChatLobbyWidget::handleChatLobbyEvent(uint64_t lobby_id, RsChatLobbyEventCode event_type, const RsGxsId &gxs_id, const QString& str) { if (ChatLobbyDialog *cld = dynamic_cast(ChatDialog::getExistingChat(ChatId(lobby_id)))) { cld->handleLobbyEvent(event_type, gxs_id, str); diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.h b/retroshare-gui/src/gui/ChatLobbyWidget.h index 648e7dac9..8b355515a 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.h +++ b/retroshare-gui/src/gui/ChatLobbyWidget.h @@ -89,7 +89,7 @@ protected slots: void unsubscribeItem(); void itemDoubleClicked(QTreeWidgetItem *item, int column); void updateCurrentLobby() ; - void handleChatLobbyEvent(uint64_t lobby_id, RsChatStatusEventCode event_type, const RsGxsId &gxs_id, const QString& str); + void handleChatLobbyEvent(uint64_t lobby_id, RsChatLobbyEventCode event_type, const RsGxsId &gxs_id, const QString& str); void readChatLobbyInvites(); void showLobby(QTreeWidgetItem *lobby_item) ; void showBlankPage(ChatLobbyId id, bool subscribed = false) ; diff --git a/retroshare-gui/src/gui/FriendsDialog.cpp b/retroshare-gui/src/gui/FriendsDialog.cpp index 532a87f4a..4fe8e50be 100644 --- a/retroshare-gui/src/gui/FriendsDialog.cpp +++ b/retroshare-gui/src/gui/FriendsDialog.cpp @@ -40,6 +40,7 @@ #include "RetroShareLink.h" #include "settings/rsharesettings.h" #include "util/misc.h" +#include "util/qtthreadsutils.h" #include "util/DateTime.h" #include "FriendsDialog.h" #include "NetworkView.h" @@ -77,8 +78,29 @@ FriendsDialog::FriendsDialog(QWidget *parent) : MainPage(parent) ui.chatWidget->setWelcomeMessage(msg); ui.chatWidget->init(ChatId::makeBroadcastId(), tr("Broadcast")); - connect(NotifyQt::getInstance(), SIGNAL(chatMessageReceived(ChatMessage)), this, SLOT(chatMessageReceived(ChatMessage))); - connect(NotifyQt::getInstance(), SIGNAL(chatStatusChanged(ChatId,QString)), this, SLOT(chatStatusReceived(ChatId,QString))); + //connect(NotifyQt::getInstance(), SIGNAL(chatMessageReceived(ChatMessage)), this, SLOT(chatMessageReceived(ChatMessage))); + //connect(NotifyQt::getInstance(), SIGNAL(chatStatusChanged(ChatId,QString)), this, SLOT(chatStatusReceived(ChatId,QString))); + + mEventHandlerId = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); if(!fe) return; + + switch(fe->mEventCode) + { + case RsChatServiceEventCode::CHAT_MESSAGE_RECEIVED: chatMessageReceived(fe->mMsg); break; + case RsChatServiceEventCode::CHAT_STATUS_CHANGED: chatStatusReceived(fe->mCid,QString::fromUtf8(fe->mStr.c_str())); break; + default: + break; + } + + } + , this ); + }, mEventHandlerId, RsEventType::CHAT_SERVICE ); + #else // def RS_DIRECT_CHAT ui.tabWidget->removeTab(ui.tabWidget->indexOf(ui.groupChatTab)); #endif // def RS_DIRECT_CHAT @@ -200,31 +222,31 @@ void FriendsDialog::processSettings(bool bLoad) void FriendsDialog::chatMessageReceived(const ChatMessage &msg) { - if(msg.chat_id.isBroadcast()) + if(!msg.chat_id.isBroadcast()) + return; + + QDateTime sendTime = QDateTime::fromTime_t(msg.sendTime); + QDateTime recvTime = QDateTime::fromTime_t(msg.recvTime); + QString message = QString::fromUtf8(msg.msg.c_str()); + QString name = QString::fromUtf8(rsPeers->getPeerName(msg.broadcast_peer_id).c_str()); + + ui.chatWidget->addChatMsg(msg.incoming, name, sendTime, recvTime, message, ChatWidget::MSGTYPE_NORMAL); + + if(ui.chatWidget->isActive()) { - QDateTime sendTime = QDateTime::fromTime_t(msg.sendTime); - QDateTime recvTime = QDateTime::fromTime_t(msg.recvTime); - QString message = QString::fromUtf8(msg.msg.c_str()); - QString name = QString::fromUtf8(rsPeers->getPeerName(msg.broadcast_peer_id).c_str()); - - ui.chatWidget->addChatMsg(msg.incoming, name, sendTime, recvTime, message, ChatWidget::MSGTYPE_NORMAL); - - if(ui.chatWidget->isActive()) - { - // clear the chat notify when control returns to the Qt event loop - // we have to do this later, because we don't know if we or the notify receives the chat message first - QMetaObject::invokeMethod(this, "clearChatNotify", Qt::QueuedConnection); - } + // clear the chat notify when control returns to the Qt event loop + // we have to do this later, because we don't know if we or the notify receives the chat message first + QMetaObject::invokeMethod(this, "clearChatNotify", Qt::QueuedConnection); } } void FriendsDialog::chatStatusReceived(const ChatId &chat_id, const QString &status_string) { - if(chat_id.isBroadcast()) - { - QString name = QString::fromUtf8(rsPeers->getPeerName(chat_id.broadcast_status_peer_id).c_str()); - ui.chatWidget->updateStatusString(name + " %1", status_string); - } + if(!chat_id.isBroadcast()) + return; + + QString name = QString::fromUtf8(rsPeers->getPeerName(chat_id.broadcast_status_peer_id).c_str()); + ui.chatWidget->updateStatusString(name + " %1", status_string); } void FriendsDialog::addFriend() diff --git a/retroshare-gui/src/gui/FriendsDialog.h b/retroshare-gui/src/gui/FriendsDialog.h index 7e86669b8..af85b6f76 100644 --- a/retroshare-gui/src/gui/FriendsDialog.h +++ b/retroshare-gui/src/gui/FriendsDialog.h @@ -70,9 +70,6 @@ public: IdDialog *idDialog; private slots: - void chatMessageReceived(const ChatMessage& msg); - void chatStatusReceived(const ChatId& chat_id, const QString& status_string); - void addFriend(); void statusmessage(); @@ -89,10 +86,16 @@ signals: void notifyGroupChat(const QString&,const QString&) ; private: + void chatMessageReceived(const ChatMessage& msg); + void chatStatusReceived(const ChatId& chat_id, const QString& status_string); + void processSettings(bool bLoad); /** Qt Designer generated object */ Ui::FriendsDialog ui; +#ifdef RS_DIRECT_CHAT + RsEventsHandlerId_t mEventHandlerId ; +#endif }; #endif diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index a0bed44f9..d6c7788a6 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -846,7 +846,7 @@ QString ChatLobbyDialog::getParticipantName(const RsGxsId& gxs_id) const } -void ChatLobbyDialog::handleLobbyEvent(RsChatStatusEventCode event_type, const RsGxsId& gxs_id, const QString& str) +void ChatLobbyDialog::handleLobbyEvent(RsChatLobbyEventCode event_type, const RsGxsId& gxs_id, const QString& str) { RsGxsId qsParticipant; @@ -854,17 +854,17 @@ void ChatLobbyDialog::handleLobbyEvent(RsChatStatusEventCode event_type, const R switch (event_type) { - case RsChatStatusEventCode::CHAT_LOBBY_EVENT_PEER_LEFT: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_PEER_LEFT: qsParticipant=gxs_id; ui.chatWidget->addChatMsg(true, tr("Chat room management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 has left the room.").arg(RsHtml::plainText(name)), ChatWidget::MSGTYPE_SYSTEM); emit peerLeft(id()) ; break; - case RsChatStatusEventCode::CHAT_LOBBY_EVENT_PEER_JOINED: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_PEER_JOINED: qsParticipant=gxs_id; ui.chatWidget->addChatMsg(true, tr("Chat room management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 joined the room.").arg(RsHtml::plainText(name)), ChatWidget::MSGTYPE_SYSTEM); emit peerJoined(id()) ; break; - case RsChatStatusEventCode::CHAT_LOBBY_EVENT_PEER_STATUS: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_PEER_STATUS: { qsParticipant=gxs_id; @@ -876,7 +876,7 @@ void ChatLobbyDialog::handleLobbyEvent(RsChatStatusEventCode event_type, const R } break; - case RsChatStatusEventCode::CHAT_LOBBY_EVENT_PEER_CHANGE_NICKNAME: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_PEER_CHANGE_NICKNAME: { qsParticipant=gxs_id; @@ -892,7 +892,7 @@ void ChatLobbyDialog::handleLobbyEvent(RsChatStatusEventCode event_type, const R muteParticipant(RsGxsId(str.toStdString())) ; } break; - case RsChatStatusEventCode::CHAT_LOBBY_EVENT_KEEP_ALIVE: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_KEEP_ALIVE: //std::cerr << "Received keep alive packet from " << nickname.toStdString() << " in chat room " << getPeerId() << std::endl; break; default: diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h index 1d388b57f..5d2d36817 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h @@ -42,7 +42,7 @@ class ChatLobbyDialog: public ChatDialog friend class ChatDialog; public: - void handleLobbyEvent(RsChatStatusEventCode event_type, const RsGxsId& gxs_id, const QString& str); + void handleLobbyEvent(RsChatLobbyEventCode event_type, const RsGxsId& gxs_id, const QString& str); virtual void showDialog(uint chatflags); virtual ChatWidget *getChatWidget(); diff --git a/retroshare-gui/src/gui/chat/ChatUserNotify.cpp b/retroshare-gui/src/gui/chat/ChatUserNotify.cpp index dcafae59a..ac80761bc 100644 --- a/retroshare-gui/src/gui/chat/ChatUserNotify.cpp +++ b/retroshare-gui/src/gui/chat/ChatUserNotify.cpp @@ -26,6 +26,7 @@ #include "gui/MainWindow.h" #include "gui/chat/ChatDialog.h" #include "gui/settings/rsharesettings.h" +#include "util/qtthreadsutils.h" #include #include @@ -57,8 +58,31 @@ static ChatUserNotify* instance = 0; ChatUserNotify::ChatUserNotify(QObject *parent) : UserNotify(parent) { - connect(NotifyQt::getInstance(), SIGNAL(chatMessageReceived(ChatMessage)), this, SLOT(chatMessageReceived(ChatMessage))); + //connect(NotifyQt::getInstance(), SIGNAL(chatMessageReceived(ChatMessage)), this, SLOT(chatMessageReceived(ChatMessage))); instance = this; + + mEventHandlerId = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); if(!fe) return; + + if(!fe) + return; + + switch(fe->mEventCode) + { + case RsChatServiceEventCode::CHAT_MESSAGE_RECEIVED: chatMessageReceived(fe->mMsg); break; + default: + break; + } + + } + , this ); + }, mEventHandlerId, RsEventType::CHAT_SERVICE ); + } ChatUserNotify::~ChatUserNotify() diff --git a/retroshare-gui/src/gui/chat/ChatUserNotify.h b/retroshare-gui/src/gui/chat/ChatUserNotify.h index 5ce8cb10a..2824acf5f 100644 --- a/retroshare-gui/src/gui/chat/ChatUserNotify.h +++ b/retroshare-gui/src/gui/chat/ChatUserNotify.h @@ -42,11 +42,10 @@ public: virtual bool hasSetting(QString *name, QString *group) override; -private slots: - void chatMessageReceived(ChatMessage msg); - private: - virtual QIcon getIcon() override; + void chatMessageReceived(ChatMessage msg); + + virtual QIcon getIcon() override; virtual QIcon getMainIcon(bool hasNew) override; virtual unsigned int getNewCount() override; @@ -54,6 +53,8 @@ private: virtual QString getNotifyMessage(bool plural) override; virtual void iconClicked() override; + + RsEventsHandlerId_t mEventHandlerId; }; #endif // CHATUSERNOTIFY_H diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 3c415b115..c4bd08799 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -109,15 +109,16 @@ NotifyQt::NotifyQt() : cDialog(NULL) qRegisterMetaType("RsGxsId"); } -//void NotifyQt::notifyErrorMsg(int list, int type, std::string msg) -//{ -// { -// QMutexLocker m(&_mutex) ; -// if(!_enabled) -// return ; -// } -// emit errorOccurred(list,type,QString::fromUtf8(msg.c_str())) ; -//} +#ifdef TO_REMOVE +void NotifyQt::notifyErrorMsg(int list, int type, std::string msg) +{ + { + QMutexLocker m(&_mutex) ; + if(!_enabled) + return ; + } + emit errorOccurred(list,type,QString::fromUtf8(msg.c_str())) ; +} void NotifyQt::notifyChatMessage(const ChatMessage &msg) { @@ -133,7 +134,6 @@ void NotifyQt::notifyChatMessage(const ChatMessage &msg) emit chatMessageReceived(msg); } -#ifdef TO_REMOVE void NotifyQt::notifyOwnAvatarChanged() { { diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index c2c2a831a..f581f45e1 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -63,7 +63,7 @@ class NotifyQt: public QObject, public NotifyClient // virtual void notifyListPreChange(int list, int type); virtual void notifyListChange(int list, int type); // virtual void notifyErrorMsg(int list, int sev, std::string msg); - virtual void notifyChatMessage(const ChatMessage& /* msg */); +// virtual void notifyChatMessage(const ChatMessage& /* msg */); virtual void notifyChatStatus(const ChatId &chat_id,const std::string& status_string); virtual void notifyChatCleared(const ChatId &chat_id); virtual void notifyCustomState(const std::string& peer_id, const std::string& status_string); @@ -125,7 +125,7 @@ class NotifyQt: public QObject, public NotifyClient // void peerStatusChanged(const QString& /* peer_id */, int /* status */); // void peerStatusChangedSummary() const; void gxsChange(const RsGxsChanges& /* changes */); - void chatMessageReceived(ChatMessage msg); +// void chatMessageReceived(ChatMessage msg); // void groupsChanged(int type) const ; void discInfoChanged() const ; void historyChanged(uint msgId, int type); From e6bd8335dc1c0bd87e839199ce444584c3dcd68e Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 13 Aug 2025 19:32:24 +0200 Subject: [PATCH 10/38] fixed faulty merge --- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 1 - retroshare-gui/src/gui/msgs/MessageComposer.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index 7d416d449..9a7b51756 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -36,7 +36,6 @@ #include "util/HandleRichText.h" #include "util/misc.h" #include "util/qtthreadsutils.h" -#include "util/QtVersion.h" #include "util/RsQtVersion.h" #include "retroshare/rsmsgs.h" diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 27cbf1f2f..2c07e1f58 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -67,7 +67,6 @@ #include "util/DateTime.h" #include "util/HandleRichText.h" #include "util/qtthreadsutils.h" -#include "util/QtVersion.h" #include "util/RsQtVersion.h" #include "textformat.h" #include "TagsMenu.h" From 798775e12b369a8187e3869154bbc75efaa5fa0f Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 17 Aug 2025 17:34:46 +0200 Subject: [PATCH 11/38] moved notifyChatStatus to rsEvents --- retroshare-gui/src/gui/MainWindow.cpp | 44 +++++++++++-------- retroshare-gui/src/gui/MainWindow.h | 3 +- retroshare-gui/src/gui/NetworkView.cpp | 25 ++++++++++- retroshare-gui/src/gui/NetworkView.h | 2 + retroshare-gui/src/gui/chat/ChatWidget.cpp | 23 +++++++--- retroshare-gui/src/gui/chat/ChatWidget.h | 2 +- .../src/gui/chat/PopupChatDialog.cpp | 2 +- .../src/gui/connect/ConnectFriendWizard.cpp | 9 +++- retroshare-gui/src/gui/notifyqt.cpp | 15 +++---- retroshare-gui/src/gui/notifyqt.h | 28 ++++++------ retroshare-gui/src/main.cpp | 6 +-- 11 files changed, 101 insertions(+), 58 deletions(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 3b99b7252..49293165d 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -349,22 +349,6 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) // connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateFriends())); // connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateFriends())); - mEventHandlerId = 0; - - rsEvents->registerEventsHandler( [this](std::shared_ptr e) - { - RsQThreadUtils::postToObject([=]() - { - auto fe = dynamic_cast(e.get()); - - if(!fe) - return; - - updateFriends(); - } - , this ); - }, mEventHandlerId, RsEventType::FRIEND_LIST ); - loadOwnStatus(); /* Set focus to the current page */ @@ -383,6 +367,24 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) mFontSizeHandler.registerFontSize(ui->listWidget, 1.5f); + mEventHandlerId_friends = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); + + if(!fe) + return; + + updateFriends(); + } + , this ); + }, mEventHandlerId_friends, RsEventType::FRIEND_LIST ); + + mEventHandlerId_system = 0; + rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject([=](){ @@ -391,19 +393,22 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) switch(ev->mEventCode) { case RsSystemErrorEventCode::TIME_SHIFT_PROBLEM: - std::cerr << "Time shift problem notification. Ignored." << std::endl; + std::cerr << "Time shift problem notification. Make sure your machine is on time, because it will break chat rooms." << std::endl; break; case RsSystemErrorEventCode::DISK_SPACE_ERROR: displayDiskSpaceWarning(ev->mDiskErrorLocation,ev->mDiskErrorSizeLimit); + break; + case RsSystemErrorEventCode::GENERAL_ERROR: + displayErrorMessage(0,0,QString::fromUtf8(ev->mErrorMsg.c_str())); break; default: break; } }, this ); - }, mEventHandlerId, RsEventType::SYSTEM_ERROR ); + }, mEventHandlerId_system, RsEventType::SYSTEM_ERROR ); } @@ -415,7 +420,8 @@ MainWindow::~MainWindow() Settings->setValueToGroup("MainWindow", "SplitterState", ui->splitter->saveState()); Settings->setValueToGroup("MainWindow", "State", saveState()); - rsEvents->unregisterEventsHandler(mEventHandlerId); + rsEvents->unregisterEventsHandler(mEventHandlerId_friends); + rsEvents->unregisterEventsHandler(mEventHandlerId_system); delete statusComboBox; delete peerstatus; diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index 2f458c4ab..78138b877 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -379,7 +379,8 @@ private: Ui::MainWindow *ui ; - RsEventsHandlerId_t mEventHandlerId; + RsEventsHandlerId_t mEventHandlerId_friends; + RsEventsHandlerId_t mEventHandlerId_system; }; #endif diff --git a/retroshare-gui/src/gui/NetworkView.cpp b/retroshare-gui/src/gui/NetworkView.cpp index 402e14063..0a41c82ef 100644 --- a/retroshare-gui/src/gui/NetworkView.cpp +++ b/retroshare-gui/src/gui/NetworkView.cpp @@ -28,6 +28,7 @@ #include #include "gui/elastic/elnode.h" +#include "util/qtthreadsutils.h" /******** * #define DEBUG_NETWORKVIEW @@ -60,12 +61,32 @@ NetworkView::NetworkView(QWidget *parent) connect( ui.nameBox, SIGNAL(textChanged(QString)), this, SLOT(setNameSearch(QString))); _should_update = true ; + + rsEvents->registerEventsHandler( [this](std::shared_ptr event) + { + RsQThreadUtils::postToObject([=](){ + auto ev = dynamic_cast(event.get()); + + if(!ev) return; + + switch(ev->mGossipDiscoveryEventType) + { + case RsGossipDiscoveryEventType::DISCOVERY_INFO_RECEIVED: update(); + [[fallthrough]]; + default: + break; + } + }, this ); + }, mEventHandlerId, RsEventType::GOSSIP_DISCOVERY ); + } NetworkView::~NetworkView() { - if(mScene != NULL) - delete mScene ; + rsEvents->unregisterEventsHandler(mEventHandlerId); + + if(mScene != NULL) + delete mScene ; } void NetworkView::setEdgeLength(int l) diff --git a/retroshare-gui/src/gui/NetworkView.h b/retroshare-gui/src/gui/NetworkView.h index f6fcfe0b1..c439cb6c4 100644 --- a/retroshare-gui/src/gui/NetworkView.h +++ b/retroshare-gui/src/gui/NetworkView.h @@ -24,6 +24,7 @@ #include #include +#include #include #include "ui_NetworkView.h" @@ -65,6 +66,7 @@ class NetworkView : public RsAutoUpdatePage std::map _node_ids ; bool _should_update ; + RsEventsHandlerId_t mEventHandlerId; }; #endif diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index f904f55e5..9f46fa1ce 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -34,6 +34,7 @@ #include "gui/chat/ChatLobbyDialog.h" #include "gui/gxs/GxsIdDetails.h" #include "util/misc.h" +#include "util/qtthreadsutils.h" #include "util/HandleRichText.h" #include "gui/chat/ChatUserNotify.h"//For BradCast #include "util/DateTime.h" @@ -181,15 +182,25 @@ ChatWidget::ChatWidget(QWidget *parent) RsQThreadUtils::postToObject([=](){ auto fe = dynamic_cast(e.get()); - if(!fe || fe->mEventCode != RsFriendListEventCode::NODE_STATUS_CHANGED) + if(!fe) return; - updateStatus(QString::fromStdString(fe->mSslId.toStdString()),fe->mStatus); + switch(fe->mEventCode) + { + case RsFriendListEventCode::NODE_STATUS_CHANGED: updateStatus(QString::fromStdString(fe->mSslId.toStdString()),fe->mStatus); + break; + + case RsFriendListEventCode::NODE_STATE_STRING_CHANGED: updatePeersCustomStateString(ChatId(fe->mSslId),QString::fromUtf8(fe->mStateString.c_str())); + break; + + default: + break; + } }, this ); },mEventHandlerId,RsEventType::FRIEND_LIST); - connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&))); + //connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&))); connect(NotifyQt::getInstance(), SIGNAL(chatFontChanged()), this, SLOT(resetFonts())); connect(ui->textBrowser, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTextBrowser(QPoint))); @@ -390,7 +401,7 @@ void ChatWidget::init(const ChatId &chat_id, const QString &title) // initialize first custom state string QString customStateString = QString::fromUtf8(rsMsgs->getCustomStateString(chatId.toPeerId()).c_str()); - updatePeersCustomStateString(QString::fromStdString(chatId.toPeerId().toStdString()), customStateString); + updatePeersCustomStateString(chatId, customStateString); } else if (chatType() == CHATTYPE_DISTANT){ hist_chat_type = RS_HISTORY_TYPE_DISTANT ; messageCount = Settings->getDistantChatHistoryCount(); @@ -1925,7 +1936,7 @@ void ChatWidget::updateTitle() ui->titleLabel->setText(RsHtml::plainText(name) + "@" + RsHtml::plainText(title)); } -void ChatWidget::updatePeersCustomStateString(const QString& peer_id, const QString& status_string) +void ChatWidget::updatePeersCustomStateString(const ChatId& id, const QString& status_string) { if (chatType() != CHATTYPE_PRIVATE ) { @@ -1934,7 +1945,7 @@ void ChatWidget::updatePeersCustomStateString(const QString& peer_id, const QStr QString status_text; - if (RsPeerId(peer_id.toStdString()) == chatId.toPeerId()) { + if (id.toPeerId() == chatId.toPeerId()) { // the peers status string has changed if (status_string.isEmpty()) { ui->statusMessageLabel->hide(); diff --git a/retroshare-gui/src/gui/chat/ChatWidget.h b/retroshare-gui/src/gui/chat/ChatWidget.h index 0b9a28ccb..b308bcc81 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.h +++ b/retroshare-gui/src/gui/chat/ChatWidget.h @@ -190,7 +190,7 @@ private slots: void updateLenOfChatTextEdit(); void sendChat(); - void updatePeersCustomStateString(const QString& peer_id, const QString& status_string) ; + void updatePeersCustomStateString(const ChatId& id, const QString& status_string) ; bool fileSave(); bool fileSaveAs(); diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 7bcf515df..09706990e 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -50,7 +50,7 @@ PopupChatDialog::PopupChatDialog(QWidget *parent, Qt::WindowFlags flags) connect(ui.avatarFrameButton, SIGNAL(toggled(bool)), this, SLOT(showAvatarFrame(bool))); connect(ui.actionClearOfflineMessages, SIGNAL(triggered()), this, SLOT(clearOfflineMessages())); - connect(NotifyQt::getInstance(), SIGNAL(chatStatusChanged(ChatId,QString)), this, SLOT(chatStatusChanged(ChatId,QString))); + //connect(NotifyQt::getInstance(), SIGNAL(chatStatusChanged(ChatId,QString)), this, SLOT(chatStatusChanged(ChatId,QString))); } void PopupChatDialog::init(const ChatId &chat_id, const QString &title) diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index 2e2c5e789..4b5d9d314 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -855,7 +855,14 @@ void ConnectFriendWizard::accept() ConnectProgressDialog::showProgress(ssl_id); } - NotifyQt::getInstance()->notifyListChange(NOTIFY_LIST_NEIGHBOURS,1) ; + //NotifyQt::getInstance()->notifyListChange(NOTIFY_LIST_NEIGHBOURS,1) ; + + auto ev = std::make_shared(); + ev->mEventCode = RsFriendListEventCode::NODE_ADDED; + ev->mSslId = peerDetails.id; + ev->mPgpId = peerDetails.gpg_id; + rsEvents->postEvent(ev); + QDialog::accept(); } diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 6b49c0ff4..a8450d1f2 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -102,11 +102,13 @@ NotifyQt::NotifyQt() : cDialog(NULL) _enabled = false ; } +#ifdef TO_REMOVE // register to allow sending over Qt::QueuedConnection qRegisterMetaType("ChatId"); qRegisterMetaType("ChatMessage"); qRegisterMetaType("RsGxsChanges"); qRegisterMetaType("RsGxsId"); +#endif } #ifdef TO_REMOVE @@ -307,6 +309,7 @@ bool NotifyQt::askForPluginConfirmation(const std::string& plugin_file_name, con return false; } +#ifdef TO_REMOVE void NotifyQt::notifyDiscInfoChanged() { { @@ -322,7 +325,6 @@ void NotifyQt::notifyDiscInfoChanged() emit discInfoChanged() ; } -#ifdef TO_REMOVE void NotifyQt::notifyDiskFull(uint32_t loc,uint32_t size_in_mb) { { @@ -394,7 +396,6 @@ void NotifyQt::notifyPeerHasNewAvatar(std::string peer_id) #endif emit peerHasNewAvatar(QString::fromStdString(peer_id)) ; } -#endif void NotifyQt::notifyCustomState(const std::string& peer_id, const std::string& status_string) { @@ -410,7 +411,6 @@ void NotifyQt::notifyCustomState(const std::string& peer_id, const std::string& emit peerHasNewCustomStateString(QString::fromStdString(peer_id), QString::fromUtf8(status_string.c_str())) ; } -#ifdef TO_REMOVE void NotifyQt::notifyChatLobbyTimeShift(int shift) { { @@ -453,7 +453,6 @@ void NotifyQt::notifyChatLobbyEvent(uint64_t lobby_id,uint32_t event_type,const #endif emit chatLobbyEvent(lobby_id,event_type,nickname,QString::fromUtf8(str.c_str())) ; } -#endif void NotifyQt::notifyChatStatus(const ChatId& chat_id,const std::string& status_string) { @@ -488,7 +487,6 @@ void NotifyQt::notifyChatCleared(const ChatId& chat_id) // std::cerr << "(EE) missing code to handle GXS turtle search result." << std::endl; //} -#ifdef TO_REMOVE // Mai 2023: distant turtle search now uses RsEvents. void NotifyQt::notifyTurtleSearchResult(const RsPeerId& pid,uint32_t search_id,const std::list& files) { @@ -528,6 +526,7 @@ void NotifyQt::notifyHistoryChanged(uint32_t msgId, int type) emit historyChanged(msgId, type); } +#ifdef TO_REMOVE void NotifyQt::notifyListChange(int list, int type) { { @@ -540,7 +539,6 @@ void NotifyQt::notifyListChange(int list, int type) #endif switch(list) { -#ifdef TO_REMOVE case NOTIFY_LIST_NEIGHBOURS: #ifdef NOTIFY_DEBUG std::cerr << "received neighbours changed" << std::endl ; @@ -614,7 +612,6 @@ void NotifyQt::notifyListChange(int list, int type) #endif emit privateChatChanged(list, type); break; -#endif case NOTIFY_LIST_CHAT_LOBBY_LIST: #ifdef NOTIFY_DEBUG @@ -622,21 +619,18 @@ void NotifyQt::notifyListChange(int list, int type) #endif emit lobbyListChanged(); break; -#ifdef TO_REMOVE case NOTIFY_LIST_GROUPLIST: #ifdef NOTIFY_DEBUG std::cerr << "received groups changed" << std::endl ; #endif emit groupsChanged(type); break; -#endif default: break; } return; } -#ifdef TO_REMOVE void NotifyQt::notifyListPreChange(int list, int /*type*/) { { @@ -1233,6 +1227,7 @@ void NotifyQt::addToaster(uint notifyFlags, const std::string& id, const std::st } toaster = new ToasterItem(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); } + break; case RS_POPUP_GROUPCHAT: #ifdef RS_DIRECT_CHAT if ((popupflags & RS_POPUP_GROUPCHAT) && !_disableAllToaster) diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index f581f45e1..c27803390 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -58,15 +58,15 @@ class NotifyQt: public QObject, public NotifyClient virtual ~NotifyQt() = default; - void setNetworkDialog(NetworkDialog *c) { cDialog = c; } +// void setNetworkDialog(NetworkDialog *c) { cDialog = c; } // 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 notifyChatMessage(const ChatMessage& /* msg */); - virtual void notifyChatStatus(const ChatId &chat_id,const std::string& status_string); - virtual void notifyChatCleared(const ChatId &chat_id); - virtual void notifyCustomState(const std::string& peer_id, const std::string& status_string); +// virtual void notifyChatStatus(const ChatId &chat_id,const std::string& status_string); +// virtual void notifyChatCleared(const ChatId &chat_id); +// virtual void notifyCustomState(const std::string& peer_id, const std::string& status_string); //#ifdef TO_REMOVE // virtual void notifyTurtleSearchResult(const RsPeerId &pid, uint32_t search_id, const std::list& found_files); //#endif @@ -85,7 +85,7 @@ class NotifyQt: public QObject, public NotifyClient virtual void notifyHistoryChanged(uint32_t msgId, int type); - virtual void notifyDiscInfoChanged() ; +// virtual void notifyDiscInfoChanged() ; virtual bool askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password, bool &cancelled); virtual bool askForPluginConfirmation(const std::string& plugin_filename, const std::string& plugin_file_hash,bool first_time); @@ -109,25 +109,25 @@ class NotifyQt: public QObject, public NotifyClient // void filesPostModChanged(bool) const ; // void transfersChanged() const ; // void friendsChanged() const ; - void lobbyListChanged() const ; -// void chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&) ; +// void lobbyListChanged() const ; +// void chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&) ; // void neighboursChanged() const ; void configChanged() const ; void logInfoChanged(const QString&) const ; - void chatStatusChanged(const ChatId&,const QString&) const ; +// void chatStatusChanged(const ChatId&,const QString&) const ; void chatCleared(const ChatId&) const ; - void peerHasNewCustomStateString(const QString& /* peer_id */, const QString& /* status_string */) const ; +// void peerHasNewCustomStateString(const QString& /* peer_id */, const QString& /* status_string */) const ; // void peerHasNewAvatar(const QString& peer_id) const ; // void ownAvatarChanged() const ; // void ownStatusMessageChanged() const ; - void errorOccurred(int,int,const QString&) const ; - void diskFull(int,int) const ; +// void errorOccurred(int,int,const QString&) const ; +// void diskFull(int,int) const ; // void peerStatusChanged(const QString& /* peer_id */, int /* status */); // void peerStatusChangedSummary() const; - void gxsChange(const RsGxsChanges& /* changes */); +// void gxsChange(const RsGxsChanges& /* changes */); // void chatMessageReceived(ChatMessage msg); // void groupsChanged(int type) const ; - void discInfoChanged() const ; +// void discInfoChanged() const ; void historyChanged(uint msgId, int type); // void chatLobbyInviteReceived() ; // void deferredSignatureHandlingRequested() ; diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 1e9c57a0f..022ae227c 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -734,12 +734,12 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); // QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ; - QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->friendsDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool))); +// QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->friendsDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool))); // QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->friendsDialog,SLOT(loadmypersonalstatus())); // QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)) ,w->friendsDialog->networkDialog,SLOT(setLogInfo(QString))) ; - QObject::connect(notify,SIGNAL(discInfoChanged()) ,w->friendsDialog->networkView,SLOT(update()),Qt::QueuedConnection) ; - QObject::connect(notify,SIGNAL(errorOccurred(int,int,const QString&)),w,SLOT(displayErrorMessage(int,int,const QString&))) ; +// QObject::connect(notify,SIGNAL(discInfoChanged()) ,w->friendsDialog->networkView,SLOT(update()),Qt::QueuedConnection) ; +// QObject::connect(notify,SIGNAL(errorOccurred(int,int,const QString&)),w,SLOT(displayErrorMessage(int,int,const QString&))) ; w->installGroupChatNotifier(); From bfcfa2293b2767fc4ec5a7a4150875be57a1a193 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 17 Aug 2025 18:06:08 +0200 Subject: [PATCH 12/38] fixed compilation --- .../src/gui/im_history/ImHistoryBrowser.cpp | 16 +++++++++++++++- .../src/gui/im_history/ImHistoryBrowser.h | 1 + retroshare-gui/src/gui/notifyqt.cpp | 2 -- retroshare-gui/src/gui/notifyqt.h | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp index 114071ae7..18d4bb553 100644 --- a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp +++ b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp @@ -32,6 +32,7 @@ #include "IMHistoryItemDelegate.h" #include "IMHistoryItemPainter.h" #include "util/HandleRichText.h" +#include "util/qtthreadsutils.h" #include "gui/common/FilesDefs.h" #include "rshare.h" @@ -101,7 +102,7 @@ ImHistoryBrowser::ImHistoryBrowser(const ChatId &chatId, QTextEdit *edit,const Q m_chatId = chatId; textEdit = edit; - connect(NotifyQt::getInstance(), SIGNAL(historyChanged(uint, int)), this, SLOT(historyChanged(uint, int))); + //connect(NotifyQt::getInstance(), SIGNAL(historyChanged(uint, int)), this, SLOT(historyChanged(uint, int))); connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); @@ -138,6 +139,19 @@ ImHistoryBrowser::ImHistoryBrowser(const ChatId &chatId, QTextEdit *edit,const Q connect(m_createThread, SIGNAL(finished()), this, SLOT(createThreadFinished())); connect(m_createThread, SIGNAL(progress(int,int)), this, SLOT(createThreadProgress(int,int))); m_createThread->start(); + + mEventHandlerId = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr event) + { + RsQThreadUtils::postToObject([=](){ + + auto ev = dynamic_cast(event.get()); + + if(ev->mEventCode == RsChatServiceEventCode::CHAT_HISTORY_CHANGED) + historyChanged(ev->mMsgHistoryId,ev->mHistoryChangeType); + }, this ); + }, mEventHandlerId, RsEventType::CHAT_SERVICE ); } ImHistoryBrowser::~ImHistoryBrowser() diff --git a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h index 84ee95234..a9230661c 100644 --- a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h +++ b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h @@ -86,6 +86,7 @@ private: /** Qt Designer generated object */ Ui::ImHistoryBrowser ui; + RsEventsHandlerId_t mEventHandlerId; }; class ImHistoryBrowserCreateItemsThread : public QThread diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index a8450d1f2..474999ad8 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -513,7 +513,6 @@ void NotifyQt::notifyTurtleSearchResult(const RsPeerId& pid,uint32_t search_id,c emit gotTurtleSearchResult(search_id,det) ; } } -#endif void NotifyQt::notifyHistoryChanged(uint32_t msgId, int type) { @@ -526,7 +525,6 @@ void NotifyQt::notifyHistoryChanged(uint32_t msgId, int type) emit historyChanged(msgId, type); } -#ifdef TO_REMOVE void NotifyQt::notifyListChange(int list, int type) { { diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index c27803390..93baf845e 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -83,7 +83,7 @@ class NotifyQt: public QObject, public NotifyClient /* one or more peers has changed the states */ // virtual void notifyPeerStatusChangedSummary(); - virtual void notifyHistoryChanged(uint32_t msgId, int type); +// virtual void notifyHistoryChanged(uint32_t msgId, int type); // virtual void notifyDiscInfoChanged() ; virtual bool askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password, bool &cancelled); From af36a0b6d962658b6290b1afa33f678101634a0b Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 23 Aug 2025 19:08:26 +0200 Subject: [PATCH 13/38] fixed hashing status --- .../src/gui/statusbar/hashingstatus.cpp | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/statusbar/hashingstatus.cpp b/retroshare-gui/src/gui/statusbar/hashingstatus.cpp index 2be7ff1f5..8638acb3e 100644 --- a/retroshare-gui/src/gui/statusbar/hashingstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/hashingstatus.cpp @@ -31,6 +31,8 @@ #include "gui/notifyqt.h" #include "gui/common/FilesDefs.h" +//#define DEBUG_HASHING_STATUS 1 + HashingStatus::HashingStatus(QWidget *parent) : QWidget(parent) { @@ -61,25 +63,32 @@ HashingStatus::HashingStatus(QWidget *parent) void HashingStatus::handleEvent_main_thread(std::shared_ptr event) { - // Warning: no GUI calls should happen here! - if(event->mType != RsEventType::SHARED_DIRECTORIES) return; - const RsSharedDirectoriesEvent *fe = dynamic_cast(event.get()); + const RsSharedDirectoriesEvent *fe = dynamic_cast(event.get()); + if(!fe) return; - std::cerr << "HashStatusEventHandler: received event " << (void*)fe->mEventCode << std::endl; - switch (fe->mEventCode) { default: + break; case RsSharedDirectoriesEventCode::HASHING_PROCESS_RESUMED: statusHashing->setText(mLastText); // fallthrough +#ifdef DEBUG_HASHING_STATUS + std::cerr << "HashStatusEventHandler: received event " << (void*)fe->mEventCode << ": " ; + std::cerr << "HASHING RESUMED" << std::endl; +#endif + case RsSharedDirectoriesEventCode::HASHING_PROCESS_STARTED: { +#ifdef DEBUG_HASHING_STATUS + std::cerr << "HashStatusEventHandler: received event " << (void*)fe->mEventCode << ": " ; + std::cerr << "HASHING STARTED" << std::endl; +#endif hashloader->show() ; hashloader->setMovie(movie) ; movie->start() ; @@ -90,6 +99,10 @@ void HashingStatus::handleEvent_main_thread(std::shared_ptr event case RsSharedDirectoriesEventCode::HASHING_PROCESS_PAUSED: { +#ifdef DEBUG_HASHING_STATUS + std::cerr << "HashStatusEventHandler: received event " << (void*)fe->mEventCode << ": " ; + std::cerr << "HASHING PAUSED" << std::endl; +#endif movie->stop() ; hashloader->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/resume.png")) ; @@ -101,6 +114,10 @@ void HashingStatus::handleEvent_main_thread(std::shared_ptr event case RsSharedDirectoriesEventCode::HASHING_PROCESS_FINISHED: { +#ifdef DEBUG_HASHING_STATUS + std::cerr << "HashStatusEventHandler: received event " << (void*)fe->mEventCode << ": " ; + std::cerr << "HASHING FINISHED" << std::endl; +#endif movie->stop() ; statusHashing->setText(QString()); statusHashing->hide() ; @@ -120,11 +137,19 @@ void HashingStatus::handleEvent_main_thread(std::shared_ptr event statusHashing->setText(tr("Hashing file") + " " + msg); setToolTip(msg + "\n"+QObject::tr("Click to pause the hashing process")); +#ifdef DEBUG_HASHING_STATUS + std::cerr << "HashStatusEventHandler: received event " << (void*)fe->mEventCode << ": " ; + std::cerr << "HASHING FILE " << msg.toStdString() << std::endl; +#endif } break; case RsSharedDirectoriesEventCode::SAVING_FILE_INDEX: { +#ifdef DEBUG_HASHING_STATUS + std::cerr << "HashStatusEventHandler: received event " << (void*)fe->mEventCode << ": " ; + std::cerr << "SAVING FILE INDEX" << std::endl; +#endif statusHashing->setText(tr("Saving file index...")); } break; From 42f0bd41ae1f7e88b1588c3f57b8163a861da548 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 26 Aug 2025 20:28:59 +0200 Subject: [PATCH 14/38] fixed missing update of own status --- retroshare-gui/src/gui/FriendsDialog.cpp | 25 ++++++++++++++++++++++-- retroshare-gui/src/gui/FriendsDialog.h | 3 ++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/FriendsDialog.cpp b/retroshare-gui/src/gui/FriendsDialog.cpp index 770abb37a..effab40cf 100644 --- a/retroshare-gui/src/gui/FriendsDialog.cpp +++ b/retroshare-gui/src/gui/FriendsDialog.cpp @@ -81,7 +81,8 @@ FriendsDialog::FriendsDialog(QWidget *parent) : MainPage(parent) //connect(NotifyQt::getInstance(), SIGNAL(chatMessageReceived(ChatMessage)), this, SLOT(chatMessageReceived(ChatMessage))); //connect(NotifyQt::getInstance(), SIGNAL(chatStatusChanged(ChatId,QString)), this, SLOT(chatStatusReceived(ChatId,QString))); - mEventHandlerId = 0; + mEventHandlerId_friends = 0; + mEventHandlerId_chat = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr e) { @@ -99,7 +100,25 @@ FriendsDialog::FriendsDialog(QWidget *parent) : MainPage(parent) } , this ); - }, mEventHandlerId, RsEventType::CHAT_SERVICE ); + }, mEventHandlerId_chat, RsEventType::CHAT_SERVICE ); + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); if(!fe) return; + + switch(fe->mEventCode) + { + case RsFriendListEventCode::OWN_STATUS_CHANGED: loadmypersonalstatus(); + break; + default: // OWN_AVATAR_CHANGED is handled in AvatarWidget + break; + } + + } + , this ); + }, mEventHandlerId_friends, RsEventType::FRIEND_LIST ); #else // def RS_DIRECT_CHAT ui.tabWidget->removeTab(ui.tabWidget->indexOf(ui.groupChatTab)); @@ -175,6 +194,8 @@ FriendsDialog::~FriendsDialog () if (this == instance) { instance = NULL; } + rsEvents->unregisterEventsHandler(mEventHandlerId_friends); + rsEvents->unregisterEventsHandler(mEventHandlerId_chat); } void FriendsDialog::activatePage(FriendsDialog::Page page) diff --git a/retroshare-gui/src/gui/FriendsDialog.h b/retroshare-gui/src/gui/FriendsDialog.h index af85b6f76..968bc57f9 100644 --- a/retroshare-gui/src/gui/FriendsDialog.h +++ b/retroshare-gui/src/gui/FriendsDialog.h @@ -94,7 +94,8 @@ private: /** Qt Designer generated object */ Ui::FriendsDialog ui; #ifdef RS_DIRECT_CHAT - RsEventsHandlerId_t mEventHandlerId ; + RsEventsHandlerId_t mEventHandlerId_friends ; + RsEventsHandlerId_t mEventHandlerId_chat ; #endif }; From 96fddc906639855af53b1d63cc60e55adba40fb2 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 27 Aug 2025 17:37:45 +0200 Subject: [PATCH 15/38] fixed typing message missing --- retroshare-gui/src/gui/chat/ChatDialog.cpp | 7 +- retroshare-gui/src/gui/chat/ChatWidget.cpp | 193 +++++++++--------- retroshare-gui/src/gui/chat/ChatWidget.h | 5 +- .../src/gui/chat/PopupChatDialog.cpp | 20 ++ retroshare-gui/src/gui/chat/PopupChatDialog.h | 2 + .../src/gui/chat/PopupChatWindow.ui | 4 +- 6 files changed, 123 insertions(+), 108 deletions(-) diff --git a/retroshare-gui/src/gui/chat/ChatDialog.cpp b/retroshare-gui/src/gui/chat/ChatDialog.cpp index 0b7017a88..da31dbe3c 100644 --- a/retroshare-gui/src/gui/chat/ChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatDialog.cpp @@ -338,12 +338,7 @@ void ChatDialog::setPeerStatus(RsStatusValue status) // convert to virtual peer id // this is only required for private and distant chat, // because lobby and broadcast does not have a status - RsPeerId vpid; - if(mChatId.isPeerId()) - vpid = mChatId.toPeerId(); - if(mChatId.isDistantChatId()) - vpid = RsPeerId(mChatId.toDistantChatId()); - cw->updateStatus(QString::fromStdString(vpid.toStdString()), status); + cw->updateStatus(mChatId, status); } } RsStatusValue ChatDialog::getPeerStatus() diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 9f46fa1ce..8a842616d 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -176,7 +176,8 @@ ChatWidget::ChatWidget(QWidget *parent) //connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&, int)), this, SLOT(updateStatus(const QString&, int))); - mEventHandlerId = 0; + mEventHandlerId_friends = 0; + rsEvents->registerEventsHandler( [this](std::shared_ptr e) { RsQThreadUtils::postToObject([=](){ @@ -187,7 +188,7 @@ ChatWidget::ChatWidget(QWidget *parent) switch(fe->mEventCode) { - case RsFriendListEventCode::NODE_STATUS_CHANGED: updateStatus(QString::fromStdString(fe->mSslId.toStdString()),fe->mStatus); + case RsFriendListEventCode::NODE_STATUS_CHANGED: updateStatus(ChatId(fe->mSslId),fe->mStatus); break; case RsFriendListEventCode::NODE_STATE_STRING_CHANGED: updatePeersCustomStateString(ChatId(fe->mSslId),QString::fromUtf8(fe->mStateString.c_str())); @@ -198,7 +199,7 @@ ChatWidget::ChatWidget(QWidget *parent) } }, this ); - },mEventHandlerId,RsEventType::FRIEND_LIST); + },mEventHandlerId_friends,RsEventType::FRIEND_LIST); //connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&))); connect(NotifyQt::getInstance(), SIGNAL(chatFontChanged()), this, SLOT(resetFonts())); @@ -282,7 +283,7 @@ ChatWidget::ChatWidget(QWidget *parent) ChatWidget::~ChatWidget() { processSettings(false); - rsEvents->unregisterEventsHandler(mEventHandlerId); + rsEvents->unregisterEventsHandler(mEventHandlerId_friends); /* Cleanup plugin functions */ foreach (ChatWidgetHolder *chatWidgetHolder, mChatWidgetHolder) { @@ -397,7 +398,7 @@ void ChatWidget::init(const ChatId &chat_id, const QString &title) StatusInfo peerStatusInfo; // No check of return value. Non existing status info is handled as offline. rsStatus->getStatus(chatId.toPeerId(), peerStatusInfo); - updateStatus(QString::fromStdString(chatId.toPeerId().toStdString()), peerStatusInfo.status); + updateStatus(chatId, peerStatusInfo.status); // initialize first custom state string QString customStateString = QString::fromUtf8(rsMsgs->getCustomStateString(chatId.toPeerId()).c_str()); @@ -1820,110 +1821,106 @@ void ChatWidget::setCurrentFileName(const QString &fileName) setWindowModified(false); } -void ChatWidget::updateStatus(const QString &peer_id, RsStatusValue status) +void ChatWidget::updateStatus(const ChatId& cid, RsStatusValue status) { if (! (chatType() == CHATTYPE_PRIVATE || chatType() == CHATTYPE_DISTANT)) { - // updateTitle is used - return; + // updateTitle is used + return; } - // make virtual peer id from gxs id in case of distant chat - RsPeerId vpid; + // // make virtual peer id from gxs id in case of distant chat + // RsPeerId vpid; + // if(chatId.isDistantChatId()) + // vpid = RsPeerId(chatId.toDistantChatId()); + // else + // vpid = chatId.toPeerId(); + + /* set font size for status */ + if (!(cid == chatId)) + return; + + // the peers status has changed + + QString tooltip_info ; + QString peerName ; + if(chatId.isDistantChatId()) - vpid = RsPeerId(chatId.toDistantChatId()); - else - vpid = chatId.toPeerId(); - - /* set font size for status */ - if (peer_id.toStdString() == vpid.toStdString()) { - // the peers status has changed + DistantChatPeerInfo dcpinfo ; + RsIdentityDetails details ; - QString tooltip_info ; - QString peerName ; + if(rsMsgs->getDistantChatStatus(chatId.toDistantChatId(),dcpinfo)) + { + if(rsIdentity->getIdDetails(dcpinfo.to_id,details)) + peerName = QString::fromUtf8( details.mNickname.c_str() ) ; + else + peerName = QString::fromStdString(dcpinfo.to_id.toStdString()) ; - if(chatId.isDistantChatId()) - { - DistantChatPeerInfo dcpinfo ; - RsIdentityDetails details ; - - if(rsMsgs->getDistantChatStatus(chatId.toDistantChatId(),dcpinfo)) - { - if(rsIdentity->getIdDetails(dcpinfo.to_id,details)) - peerName = QString::fromUtf8( details.mNickname.c_str() ) ; - else - peerName = QString::fromStdString(dcpinfo.to_id.toStdString()) ; - - tooltip_info = QString("Identity Id: ")+QString::fromStdString(dcpinfo.to_id.toStdString()); - } - else - { - peerName = QString::fromStdString(chatId.toDistantChatId().toStdString()) ; - tooltip_info = QString("Identity Id: unknown (bug?)"); - } - } - else - { - peerName = QString::fromUtf8(rsPeers->getPeerName(chatId.toPeerId()).c_str()); - tooltip_info = QString("Peer Id: ") + QString::fromStdString(chatId.toPeerId().toStdString()); - } - - // is scrollbar at the end? - QScrollBar *scrollbar = ui->textBrowser->verticalScrollBar(); - bool atEnd = (scrollbar->value() == scrollbar->maximum()); - - switch (status) { - default: - case RsStatusValue::RS_STATUS_OFFLINE: - ui->info_Frame->setVisible(true); - ui->infoLabel->setText(peerName + " " + tr("appears to be Offline.") +"\n" + tr("Messages you send will be delivered after Friend is again Online.")); - break; - - case RsStatusValue::RS_STATUS_INACTIVE: - ui->info_Frame->setVisible(true); - ui->infoLabel->setText(peerName + " " + tr("is Idle and may not reply")); - break; - - case RsStatusValue::RS_STATUS_ONLINE: - ui->info_Frame->setVisible(false); - break; - - case RsStatusValue::RS_STATUS_AWAY: - ui->infoLabel->setText(peerName + " " + tr("is Away and may not reply")); - ui->info_Frame->setVisible(true); - break; - - case RsStatusValue::RS_STATUS_BUSY: - ui->infoLabel->setText(peerName + " " + tr("is Busy and may not reply")); - ui->info_Frame->setVisible(true); - break; - } - - ui->titleLabel->setText(peerName); - ui->titleLabel->setToolTip(tooltip_info); -#warning inconsistent conversion here - ui->statusLabel->setText(QString("(%1)").arg(StatusDefs::name((RsStatusValue)status))); - - peerStatus = status; - - if (atEnd) { - // scroll to the end - scrollbar->setValue(scrollbar->maximum()); - } - - emit infoChanged(this); - emit statusChanged(status); - - // Notify all ChatWidgetHolder - foreach (ChatWidgetHolder *chatWidgetHolder, mChatWidgetHolder) { - chatWidgetHolder->updateStatus(status); - } - - return; + tooltip_info = QString("Identity Id: ")+QString::fromStdString(dcpinfo.to_id.toStdString()); + } + else + { + peerName = QString::fromStdString(chatId.toDistantChatId().toStdString()) ; + tooltip_info = QString("Identity Id: unknown (bug?)"); + } + } + else + { + peerName = QString::fromUtf8(rsPeers->getPeerName(chatId.toPeerId()).c_str()); + tooltip_info = QString("Peer Id: ") + QString::fromStdString(chatId.toPeerId().toStdString()); } - // ignore status change + // is scrollbar at the end? + QScrollBar *scrollbar = ui->textBrowser->verticalScrollBar(); + bool atEnd = (scrollbar->value() == scrollbar->maximum()); + + switch (status) { + default: + case RsStatusValue::RS_STATUS_OFFLINE: + ui->info_Frame->setVisible(true); + ui->infoLabel->setText(peerName + " " + tr("appears to be Offline.") +"\n" + tr("Messages you send will be delivered after Friend is again Online.")); + break; + + case RsStatusValue::RS_STATUS_INACTIVE: + ui->info_Frame->setVisible(true); + ui->infoLabel->setText(peerName + " " + tr("is Idle and may not reply")); + break; + + case RsStatusValue::RS_STATUS_ONLINE: + ui->info_Frame->setVisible(false); + break; + + case RsStatusValue::RS_STATUS_AWAY: + ui->infoLabel->setText(peerName + " " + tr("is Away and may not reply")); + ui->info_Frame->setVisible(true); + break; + + case RsStatusValue::RS_STATUS_BUSY: + ui->infoLabel->setText(peerName + " " + tr("is Busy and may not reply")); + ui->info_Frame->setVisible(true); + break; + } + + ui->titleLabel->setText(peerName); + ui->titleLabel->setToolTip(tooltip_info); +#warning inconsistent conversion here + ui->statusLabel->setText(QString("(%1)").arg(StatusDefs::name((RsStatusValue)status))); + + peerStatus = status; + + if (atEnd) { + // scroll to the end + scrollbar->setValue(scrollbar->maximum()); + } + + emit infoChanged(this); + emit statusChanged(status); + + // Notify all ChatWidgetHolder + foreach (ChatWidgetHolder *chatWidgetHolder, mChatWidgetHolder) { + chatWidgetHolder->updateStatus(status); + } } void ChatWidget::updateTitle() diff --git a/retroshare-gui/src/gui/chat/ChatWidget.h b/retroshare-gui/src/gui/chat/ChatWidget.h index b308bcc81..ed1645b14 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.h +++ b/retroshare-gui/src/gui/chat/ChatWidget.h @@ -131,7 +131,7 @@ public: const QList &chatWidgetHolderList() { return mChatWidgetHolder; } public slots: - void updateStatus(const QString &peer_id, RsStatusValue status); + void updateStatus(const ChatId &cid, RsStatusValue status); void setUseCMark(const bool bUseCMark); void updateCMPreview(); @@ -274,7 +274,8 @@ private: Ui::ChatWidget *ui; - RsEventsHandlerId_t mEventHandlerId ; +// RsEventsHandlerId_t mEventHandlerId_chat ; + RsEventsHandlerId_t mEventHandlerId_friends ; }; #endif // CHATWIDGET_H diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 09706990e..a440a2493 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -28,6 +28,7 @@ #include "gui/settings/RsharePeerSettings.h" #include "gui/notifyqt.h" #include "util/DateTime.h" +#include "util/qtthreadsutils.h" #include #include @@ -51,6 +52,25 @@ PopupChatDialog::PopupChatDialog(QWidget *parent, Qt::WindowFlags flags) connect(ui.avatarFrameButton, SIGNAL(toggled(bool)), this, SLOT(showAvatarFrame(bool))); connect(ui.actionClearOfflineMessages, SIGNAL(triggered()), this, SLOT(clearOfflineMessages())); //connect(NotifyQt::getInstance(), SIGNAL(chatStatusChanged(ChatId,QString)), this, SLOT(chatStatusChanged(ChatId,QString))); + + mEventHandlerId_chat =0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); if(!fe) return; + + switch(fe->mEventCode) + { + case RsChatServiceEventCode::CHAT_STATUS_CHANGED: chatStatusChanged(fe->mCid,QString::fromUtf8(fe->mStr.c_str())); break; + default: + break; + } + + } + , this ); + }, mEventHandlerId_chat, RsEventType::CHAT_SERVICE ); } void PopupChatDialog::init(const ChatId &chat_id, const QString &title) diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.h b/retroshare-gui/src/gui/chat/PopupChatDialog.h index a88df7a2f..9708fbaae 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.h +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.h @@ -65,6 +65,8 @@ protected: /** Qt Designer generated object */ Ui::PopupChatDialog ui; + + RsEventsHandlerId_t mEventHandlerId_chat; }; #endif diff --git a/retroshare-gui/src/gui/chat/PopupChatWindow.ui b/retroshare-gui/src/gui/chat/PopupChatWindow.ui index 0394a1c31..7f1dc2f24 100644 --- a/retroshare-gui/src/gui/chat/PopupChatWindow.ui +++ b/retroshare-gui/src/gui/chat/PopupChatWindow.ui @@ -85,7 +85,7 @@ - + :/images/tab-dock.png:/images/tab-dock.png @@ -97,7 +97,7 @@ - + :/images/tab-undock.png:/images/tab-undock.png From a991521cd0f44093be138d44c819e5b607522673 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 27 Aug 2025 17:53:58 +0200 Subject: [PATCH 16/38] updated libretroshare submodule --- libretroshare | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretroshare b/libretroshare index da6b849a4..fdd0d9f4f 160000 --- a/libretroshare +++ b/libretroshare @@ -1 +1 @@ -Subproject commit da6b849a41f3cf6e60f6f76e1f3c4463876a8741 +Subproject commit fdd0d9f4f1522c2536548025587eca08430d5d63 From 483a68000adad09a65306a93ae9f2012569a0039 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 2 Sep 2025 22:16:42 +0200 Subject: [PATCH 17/38] fixed compilation with rs_efs --- retroshare-gui/src/gui/FriendServerControl.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/retroshare-gui/src/gui/FriendServerControl.cpp b/retroshare-gui/src/gui/FriendServerControl.cpp index a4afd4537..eb5988589 100644 --- a/retroshare-gui/src/gui/FriendServerControl.cpp +++ b/retroshare-gui/src/gui/FriendServerControl.cpp @@ -118,7 +118,7 @@ FriendServerControl::FriendServerControl(QWidget *parent) rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this ); - }, mEventHandlerId_peer, RsEventType::PEER_STATE ); + }, mEventHandlerId_peer, RsEventType::FRIEND_LIST ); } void FriendServerControl::onAutoAddFriends(bool b) @@ -145,14 +145,14 @@ void FriendServerControl::handleEvent_main_thread(std::shared_ptr } { - const RsConnectionEvent *pe = dynamic_cast(event.get()); + const RsFriendListEvent *pe = dynamic_cast(event.get()); if(pe) - switch(pe->mConnectionInfoCode) + switch(pe->mEventCode) { - case RsConnectionEventCode::PEER_ADDED: - case RsConnectionEventCode::PEER_REMOVED: - case RsConnectionEventCode::PEER_CONNECTED: updateContactsStatus(); + case RsFriendListEventCode::NODE_ADDED: + case RsFriendListEventCode::NODE_REMOVED: + case RsFriendListEventCode::NODE_CONNECTED: updateContactsStatus(); break; default: ; @@ -169,7 +169,7 @@ FriendServerControl::~FriendServerControl() rsEvents->unregisterEventsHandler(mEventHandlerId_peer); } -void FriendServerControl::launchStatusContextMenu(QPoint p) +void FriendServerControl::launchStatusContextMenu(QPoint /* p */) { RsPeerId peer_id = getCurrentPeer(); From bb97e48db2f70c725559d25b92a446b0e4d24153 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 9 Sep 2025 19:49:24 +0200 Subject: [PATCH 18/38] fixed bug causing crashes after closing a chat window --- retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp | 1 + retroshare-gui/src/gui/chat/PopupChatDialog.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index aeb474e0f..fc45b65cc 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -854,6 +854,7 @@ void ChatLobbyDialog::handleLobbyEvent(RsChatLobbyEventCode event_type, const Rs QString name= getParticipantName(gxs_id) ; + //std::cerr << "Received ChatLobby event " << (int)event_type << " for lobby " << (void*)lobbyId << std::endl; switch (event_type) { case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_PEER_LEFT: diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index a440a2493..4da5d6fe4 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -101,6 +101,7 @@ void PopupChatDialog::init(const ChatId &chat_id, const QString &title) /** Destructor. */ PopupChatDialog::~PopupChatDialog() { + rsEvents->unregisterEventsHandler(mEventHandlerId_chat); // save settings processSettings(false); } From d64e4b6e787816f098bbdf929b063c9c06d54e0a Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 11 Sep 2025 20:49:35 +0200 Subject: [PATCH 19/38] fixed bug causing crash in chat history browser --- retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp index 18d4bb553..c9966b67b 100644 --- a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp +++ b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp @@ -148,6 +148,9 @@ ImHistoryBrowser::ImHistoryBrowser(const ChatId &chatId, QTextEdit *edit,const Q auto ev = dynamic_cast(event.get()); + if(!ev) + return; + if(ev->mEventCode == RsChatServiceEventCode::CHAT_HISTORY_CHANGED) historyChanged(ev->mMsgHistoryId,ev->mHistoryChangeType); }, this ); From ee3afd9f40c68e5afbb7ef3b5901f1fde86679c8 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 11 Sep 2025 21:23:12 +0200 Subject: [PATCH 20/38] fixed ifdef problem --- retroshare-gui/src/gui/FriendsDialog.cpp | 10 +++++----- retroshare-gui/src/gui/FriendsDialog.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/FriendsDialog.cpp b/retroshare-gui/src/gui/FriendsDialog.cpp index effab40cf..b68033478 100644 --- a/retroshare-gui/src/gui/FriendsDialog.cpp +++ b/retroshare-gui/src/gui/FriendsDialog.cpp @@ -81,7 +81,6 @@ FriendsDialog::FriendsDialog(QWidget *parent) : MainPage(parent) //connect(NotifyQt::getInstance(), SIGNAL(chatMessageReceived(ChatMessage)), this, SLOT(chatMessageReceived(ChatMessage))); //connect(NotifyQt::getInstance(), SIGNAL(chatStatusChanged(ChatId,QString)), this, SLOT(chatStatusReceived(ChatId,QString))); - mEventHandlerId_friends = 0; mEventHandlerId_chat = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr e) @@ -102,6 +101,10 @@ FriendsDialog::FriendsDialog(QWidget *parent) : MainPage(parent) , this ); }, mEventHandlerId_chat, RsEventType::CHAT_SERVICE ); +#else // def RS_DIRECT_CHAT + ui.tabWidget->removeTab(ui.tabWidget->indexOf(ui.groupChatTab)); +#endif // def RS_DIRECT_CHAT + rsEvents->registerEventsHandler( [this](std::shared_ptr e) { RsQThreadUtils::postToObject([=]() @@ -120,10 +123,7 @@ FriendsDialog::FriendsDialog(QWidget *parent) : MainPage(parent) , this ); }, mEventHandlerId_friends, RsEventType::FRIEND_LIST ); -#else // def RS_DIRECT_CHAT - ui.tabWidget->removeTab(ui.tabWidget->indexOf(ui.groupChatTab)); -#endif // def RS_DIRECT_CHAT - + mEventHandlerId_friends = 0; connect( ui.mypersonalstatusLabel, SIGNAL(clicked()), SLOT(statusmessage())); connect( ui.actionSet_your_Avatar, SIGNAL(triggered()), this, SLOT(getAvatar())); diff --git a/retroshare-gui/src/gui/FriendsDialog.h b/retroshare-gui/src/gui/FriendsDialog.h index 968bc57f9..f6ec0e0a8 100644 --- a/retroshare-gui/src/gui/FriendsDialog.h +++ b/retroshare-gui/src/gui/FriendsDialog.h @@ -93,8 +93,8 @@ private: /** Qt Designer generated object */ Ui::FriendsDialog ui; -#ifdef RS_DIRECT_CHAT RsEventsHandlerId_t mEventHandlerId_friends ; +#ifdef RS_DIRECT_CHAT RsEventsHandlerId_t mEventHandlerId_chat ; #endif }; From 43e028960477cf7bdbaeb32c8d5c1052d542902c Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 13 Sep 2025 11:20:00 +0200 Subject: [PATCH 21/38] moved log notify to a rsEvent --- retroshare-gui/src/gui/MainWindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 49293165d..2d9eccc9f 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -400,6 +400,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) displayDiskSpaceWarning(ev->mDiskErrorLocation,ev->mDiskErrorSizeLimit); break; + case RsSystemErrorEventCode::DATA_STREAMING_ERROR: case RsSystemErrorEventCode::GENERAL_ERROR: displayErrorMessage(0,0,QString::fromUtf8(ev->mErrorMsg.c_str())); break; From e2b2c1ae4480b568ac01c93c68367ec7adae2e96 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 16 Sep 2025 16:29:47 +0200 Subject: [PATCH 22/38] fixed toasters in notifyQt to use rsEvents --- .../gui/FileTransfer/SharedFilesDialog.cpp | 1 - .../src/gui/FileTransfer/TransfersDialog.cpp | 10 - retroshare-gui/src/gui/MainWindow.cpp | 55 --- retroshare-gui/src/gui/MainWindow.h | 4 - retroshare-gui/src/gui/NewsFeed.cpp | 3 - .../src/gui/msgs/MessageUserNotify.cpp | 7 +- retroshare-gui/src/gui/notifyqt.cpp | 402 ++++++++++-------- retroshare-gui/src/gui/notifyqt.h | 12 +- .../src/gui/toaster/DownloadToaster.cpp | 7 +- .../src/gui/toaster/DownloadToaster.h | 2 +- .../src/gui/toaster/FriendRequestToaster.cpp | 9 +- .../src/gui/toaster/FriendRequestToaster.h | 2 +- 12 files changed, 255 insertions(+), 259 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp index 6955b9dcd..7e1477864 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp @@ -767,7 +767,6 @@ void SharedFilesDialog::collCreate() model->getDirDetailsFromSelect(lst, dirVec); auto RemoteMode = isRemote(); - FileSearchFlags f = RemoteMode?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL ; QString dir_name; diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index 3be6343bd..3d5b7d8c7 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -1115,16 +1115,6 @@ void TransfersDialog::handleEvent_main_thread(std::shared_ptr eve switch (fe->mFileTransferEventCode) { case RsFileTransferEventCode::DOWNLOAD_COMPLETE: - { - FileInfo nfo ; - if(!rsFiles->FileDetails(fe->mHash, RS_FILE_HINTS_DOWNLOAD, nfo)) - break; - - SoundManager::play(SOUND_DOWNLOAD_COMPLETE); - NotifyQt::getInstance()->addToaster(RS_POPUP_DOWNLOAD, fe->mHash.toStdString(), nfo.fname.c_str(),""); - } - [[fallthrough]]; - case RsFileTransferEventCode::COMPLETED_FILES_REMOVED: getUserNotify()->updateIcon(); diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 2d9eccc9f..9984436fa 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -383,33 +383,6 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) , this ); }, mEventHandlerId_friends, RsEventType::FRIEND_LIST ); - mEventHandlerId_system = 0; - - rsEvents->registerEventsHandler( [this](std::shared_ptr event) - { - RsQThreadUtils::postToObject([=](){ - auto ev = dynamic_cast(event.get()); - - switch(ev->mEventCode) - { - case RsSystemErrorEventCode::TIME_SHIFT_PROBLEM: - std::cerr << "Time shift problem notification. Make sure your machine is on time, because it will break chat rooms." << std::endl; - break; - - case RsSystemErrorEventCode::DISK_SPACE_ERROR: - displayDiskSpaceWarning(ev->mDiskErrorLocation,ev->mDiskErrorSizeLimit); - break; - - case RsSystemErrorEventCode::DATA_STREAMING_ERROR: - case RsSystemErrorEventCode::GENERAL_ERROR: - displayErrorMessage(0,0,QString::fromUtf8(ev->mErrorMsg.c_str())); - break; - - default: - break; - } - }, this ); - }, mEventHandlerId_system, RsEventType::SYSTEM_ERROR ); } @@ -422,7 +395,6 @@ MainWindow::~MainWindow() Settings->setValueToGroup("MainWindow", "State", saveState()); rsEvents->unregisterEventsHandler(mEventHandlerId_friends); - rsEvents->unregisterEventsHandler(mEventHandlerId_system); delete statusComboBox; delete peerstatus; @@ -648,28 +620,6 @@ void MainWindow::setNewPage(int page) } } -void MainWindow::displayDiskSpaceWarning(int loc,int size_limit_mb) -{ - QString locString ; - switch(loc) - { - case RS_PARTIALS_DIRECTORY: locString = "Partials" ; - break ; - - case RS_CONFIG_DIRECTORY: locString = "Config" ; - break ; - - case RS_DOWNLOAD_DIRECTORY: locString = "Download" ; - break ; - - default: - std::cerr << "Error: " << __PRETTY_FUNCTION__ << " was called with an unknown parameter loc=" << loc << std::endl ; - return ; - } - QMessageBox::critical(NULL,tr("Low disk space warning"), - tr("The disk space in your")+" "+locString +" "+tr("directory is running low (current limit is")+" "+QString::number(size_limit_mb)+tr("MB). \n\n RetroShare will now safely suspend any disk access to this directory. \n\n Please make some free space and click Ok.")) ; -} - /** Creates a tray icon with a context menu and adds it to the system * notification area. */ void MainWindow::createTrayIcon() @@ -1403,11 +1353,6 @@ void MainWindow::receiveNewArgs(QStringList args) retroshareLinkActivated(link.toUrl()); } -void MainWindow::displayErrorMessage(int /*a*/,int /*b*/,const QString& error_msg) -{ - QMessageBox::critical(NULL, tr("Internal Error"),error_msg) ; -} - void MainWindow::closeEvent(QCloseEvent *e) { e->ignore(); diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index 78138b877..59f927ac6 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -210,9 +210,7 @@ public: public slots: void receiveNewArgs(QStringList args); - void displayErrorMessage(int,int,const QString&) ; void postModDirectories(bool update_local); - void displayDiskSpaceWarning(int loc,int size_limit_mb) ; void checkAndSetIdle(int idleTime); void externalLinkActivated(const QUrl &url); @@ -380,7 +378,5 @@ private: Ui::MainWindow *ui ; RsEventsHandlerId_t mEventHandlerId_friends; - RsEventsHandlerId_t mEventHandlerId_system; }; - #endif diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index 529556012..320184e74 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -441,7 +441,6 @@ void NewsFeed::handleConnectionEvent(std::shared_ptr event) { case RsFriendListEventCode::NODE_CONNECTED: addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_CONNECT, false), true); - NotifyQt::getInstance()->addToaster(RS_POPUP_CONNECT, e.mSslId.toStdString().c_str(), "", ""); break; case RsFriendListEventCode::NODE_DISCONNECTED: // not handled yet break; @@ -506,8 +505,6 @@ void NewsFeed::handleSecurityEvent(std::shared_ptr event) if (Settings->getMessageFlags() & RS_MESSAGE_CONNECT_ATTEMPT) MessageComposer::addConnectAttemptMsg(e.mPgpId, e.mSslId, QString::fromStdString(det.name + "(" + det.location + ")")); - - NotifyQt::getInstance()->addToaster(RS_POPUP_CONNECT_ATTEMPT, e.mPgpId.toStdString().c_str(), det.location, e.mSslId.toStdString().c_str()); } void NewsFeed::testFeeds(uint /*notifyFlags*/) diff --git a/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp b/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp index b29f264fb..ed4ad1dd6 100644 --- a/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp +++ b/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp @@ -97,12 +97,7 @@ void MessageUserNotify::handleEvent_main_thread(std::shared_ptr e switch (fe->mMailStatusEventCode) { case RsMailStatusEventCode::NEW_MESSAGE: - for (it = fe->mChangedMsgIds.begin(); it != fe->mChangedMsgIds.end(); ++it) { - MessageInfo msgInfo; - if (rsMail->getMessage(*it, msgInfo)) { - NotifyQt::getInstance()->addToaster(RS_POPUP_MSG, msgInfo.msgId.c_str(), msgInfo.title.c_str(), msgInfo.msg.c_str() ); - } - } + updateIcon(); break; case RsMailStatusEventCode::MESSAGE_CHANGED: diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 474999ad8..42fd5a614 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -25,7 +25,9 @@ #include #include #include +#include #include +#include #include @@ -102,6 +104,13 @@ NotifyQt::NotifyQt() : cDialog(NULL) _enabled = false ; } +#warning TODO: do we need a timer anymore?? + + // Catch all events that require toasters and + + mEventHandlerId = 0; + rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject([=](){ handleIncomingEvent(event); }, this ); }, mEventHandlerId); // No event type means we expect to catch all possible events + #ifdef TO_REMOVE // register to allow sending over Qt::QueuedConnection qRegisterMetaType("ChatId"); @@ -673,22 +682,13 @@ void NotifyQt::enable() _enabled = true ; } -void NotifyQt::UpdateGUI() +void NotifyQt::handleIncomingEvent(std::shared_ptr event) { - if(RsAutoUpdatePage::eventsLocked()) - return ; - - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - static bool already_updated = false ; // these only update once at start because they may already have been set before // the gui is running, then they get updated by callbacks. +#warning Is this needed anymore?? if(!already_updated) { -// emit neighboursChanged(); emit configChanged(); already_updated = true ; @@ -696,177 +696,197 @@ void NotifyQt::UpdateGUI() /* Finally Check for PopupMessages / System Error Messages */ - if (rsNotify) - { - uint32_t sysid; - uint32_t type; - std::string title, id, msg; + uint popupflags = Settings->getNotifyFlags(); - /* You can set timeToShow, timeToLive and timeToHide or can leave the standard */ - ToasterItem *toaster = NULL; - if (rsNotify->NotifyPopupMessage(type, id, title, msg)) - { - uint popupflags = Settings->getNotifyFlags(); + auto insertToaster = [this](ToasterItem *toaster) { - switch(type) - { - case RS_POPUP_ENCRYPTED_MSG: - SoundManager::play(SOUND_MESSAGE_ARRIVED); + /* init attributes */ + toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint); - if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster) - { - toaster = new ToasterItem(new MessageToaster("", tr("Encrypted message"), QString("[%1]").arg(tr("Encrypted message")))); - } - break; - case RS_POPUP_MSG: - SoundManager::play(SOUND_MESSAGE_ARRIVED); + /* add toaster to waiting list */ + waitingToasterList.push_back(toaster); + }; - if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster) - { - toaster = new ToasterItem(new MessageToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str()))); - } - break; - case RS_POPUP_CONNECT: - SoundManager::play(SOUND_USER_ONLINE); + // check for all possibly handled events - if ((popupflags & RS_POPUP_CONNECT) && !_disableAllToaster) - { - toaster = new ToasterItem(new OnlineToaster(RsPeerId(id))); - } - break; - case RS_POPUP_DOWNLOAD: - SoundManager::play(SOUND_DOWNLOAD_COMPLETE); + auto ev1 = dynamic_cast(event.get()); - if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster) - { - /* id = file hash */ - toaster = new ToasterItem(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str()))); - } - break; - case RS_POPUP_CHAT: - if ((popupflags & RS_POPUP_CHAT) && !_disableAllToaster) - { - // TODO: fix for distant chat, look up if dstant chat uses RS_POPUP_CHAT - ChatDialog *chatDialog = ChatDialog::getChat(ChatId(RsPeerId(id))); - ChatWidget *chatWidget; - if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) { - // do not show when active - break; - } - toaster = new ToasterItem(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); - } - break; - case RS_POPUP_GROUPCHAT: + if(ev1) + { + if(ev1->mMailStatusEventCode == RsMailStatusEventCode::NEW_MESSAGE) + { + SoundManager::play(SOUND_MESSAGE_ARRIVED); + + if((popupflags & RS_POPUP_MSG) && !_disableAllToaster) + { + for(auto msgid:ev1->mChangedMsgIds) + { + Rs::Msgs::MessageInfo msgInfo; + if(rsMsgs->getMessage(msgid, msgInfo)) + insertToaster(new ToasterItem(new MessageToaster(msgInfo.from.toStdString(), QString::fromUtf8(msgInfo.title.c_str()), QString::fromUtf8(msgInfo.msg.c_str())))); + } + } + } + return; + } + + auto ev2 = dynamic_cast(event.get()); + + if(ev2) + { + if(ev2->mEventCode == RsFriendListEventCode::NODE_CONNECTED) + { + SoundManager::play(SOUND_USER_ONLINE); + + if ((popupflags & RS_POPUP_CONNECT) && !_disableAllToaster) + insertToaster(new ToasterItem(new OnlineToaster(ev2->mSslId))); + } + return; + } + + auto ev3 = dynamic_cast(event.get()); + + if(ev3) + { + if(ev3->mFileTransferEventCode == RsFileTransferEventCode::DOWNLOAD_COMPLETE) + { + SoundManager::play(SOUND_DOWNLOAD_COMPLETE); + + if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster) + insertToaster(new ToasterItem(new DownloadToaster(ev3->mHash))); + } + return; + } + + auto ev4 = dynamic_cast(event.get()); + + if(ev4) + { + if(ev4->mErrorCode == RsAuthSslError::NOT_A_FRIEND) + { + if ((popupflags & RS_POPUP_CONNECT_ATTEMPT) && !_disableAllToaster) + // id = gpgid + // title = ssl name + // msg = peer id + insertToaster(new ToasterItem(new FriendRequestToaster(ev4->mPgpId, ev4->mSslId))); + } + return; + } + + // Probably an old thing. To be removed. + // case RS_POPUP_ENCRYPTED_MSG: + // SoundManager::play(SOUND_MESSAGE_ARRIVED); + // + // if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster) + // { + // toaster = new ToasterItem(new MessageToaster("", tr("Encrypted message"), QString("[%1]").arg(tr("Encrypted message")))); + // } + // break; + + auto ev5 = dynamic_cast(event.get()); + + if(ev5) + { + // This code below should be simplified. In particular GroupChatToaster, ChatToaster and ChatLobbyToaster should be only one class. + + if(ev5->mEventCode == RsChatServiceEventCode::CHAT_MESSAGE_RECEIVED) + { + if (ev5->mCid.isPeerId() && (popupflags & RS_POPUP_CHAT) && !_disableAllToaster) + { + // TODO: fix for distant chat, look up if dstant chat uses RS_POPUP_CHAT + ChatDialog *chatDialog = ChatDialog::getChat(ev5->mCid); + ChatWidget *chatWidget; + + if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) // do not show when active + return; + + insertToaster(new ToasterItem(new ChatToaster(ev5->mCid.toPeerId(), QString::fromUtf8(ev5->mMsg.msg.c_str())))); + } #ifdef RS_DIRECT_CHAT - if ((popupflags & RS_POPUP_GROUPCHAT) && !_disableAllToaster) - { - MainWindow *mainWindow = MainWindow::getInstance(); - if (mainWindow && mainWindow->isActiveWindow() && !mainWindow->isMinimized()) { - if (MainWindow::getActivatePage() == MainWindow::Friends) { - if (FriendsDialog::isGroupChatActive()) { - // do not show when active - break; - } - } - } - toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); - } -#endif // RS_DIRECT_CHAT - break; - case RS_POPUP_CHATLOBBY: - if ((popupflags & RS_POPUP_CHATLOBBY) && !_disableAllToaster) - { - ChatId chat_id(id); + else if (ev5->mCid.isBroadcast() && (popupflags & RS_POPUP_GROUPCHAT) && !_disableAllToaster) + { + MainWindow *mainWindow = MainWindow::getInstance(); + if (mainWindow && mainWindow->isActiveWindow() && !mainWindow->isMinimized() + && (MainWindow::getActivatePage() == MainWindow::Friends) && (FriendsDialog::isGroupChatActive())) + return; - ChatDialog *chatDialog = ChatDialog::getChat(chat_id); - ChatWidget *chatWidget; - if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) { - // do not show when active - break; - } - ChatLobbyDialog *chatLobbyDialog = dynamic_cast(chatDialog); + insertToaster(new ToasterItem(new GroupChatToaster(ev5->mCid.toPeerId(), QString::fromUtf8(ev5->mMsg.msg.c_str())))); + } +#endif + else if (ev5->mCid.isLobbyId() && (popupflags & RS_POPUP_CHATLOBBY) && !_disableAllToaster) + { + ChatDialog *chatDialog = ChatDialog::getChat(ev5->mCid); + ChatWidget *chatWidget; - RsGxsId sender(title); - if (!chatLobbyDialog || chatLobbyDialog->isParticipantMuted(sender)) - break; // participant is muted + if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) + return; - toaster = new ToasterItem(new ChatLobbyToaster(chat_id.toLobbyId(), sender, QString::fromUtf8(msg.c_str()))); - } - break; - case RS_POPUP_CONNECT_ATTEMPT: - if ((popupflags & RS_POPUP_CONNECT_ATTEMPT) && !_disableAllToaster) - { - // id = gpgid - // title = ssl name - // msg = peer id - toaster = new ToasterItem(new FriendRequestToaster(RsPgpId(id), QString::fromUtf8(title.c_str()), RsPeerId(msg))); - } - break; - } - } + ChatLobbyDialog *chatLobbyDialog = dynamic_cast(chatDialog); - /*Now check Plugins*/ - if (!toaster) { - int pluginCount = rsPlugins->nbPlugins(); - for (int i = 0; i < pluginCount; ++i) { - RsPlugin *rsPlugin = rsPlugins->plugin(i); - if (rsPlugin) { - ToasterNotify *toasterNotify = rsPlugin->qt_toasterNotify(); - if (toasterNotify) { - toaster = toasterNotify->toasterItem(); - continue; - } - } - } - } + if (!chatLobbyDialog || chatLobbyDialog->isParticipantMuted(ev5->mMsg.lobby_peer_gxs_id)) + return; - if (toaster) { - /* init attributes */ - toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint); + insertToaster(new ToasterItem(new ChatLobbyToaster(ev5->mCid.toLobbyId(), ev5->mMsg.lobby_peer_gxs_id, QString::fromUtf8(ev5->mMsg.msg.c_str())))); + } + else + return; + } - /* add toaster to waiting list */ - //QMutexLocker lock(&waitingToasterMutex); - waitingToasterList.push_back(toaster); - } + return; + } - if (rsNotify->NotifySysMessage(sysid, type, title, msg)) - { - /* make a warning message */ - switch(type) - { - case RS_SYS_ERROR: - QMessageBox::critical(MainWindow::getInstance(), - QString::fromUtf8(title.c_str()), - QString::fromUtf8(msg.c_str())); - break; - case RS_SYS_WARNING: - QMessageBox::warning(MainWindow::getInstance(), - QString::fromUtf8(title.c_str()), - QString::fromUtf8(msg.c_str())); - break; - default: - case RS_SYS_INFO: - QMessageBox::information(MainWindow::getInstance(), - QString::fromUtf8(title.c_str()), - QString::fromUtf8(msg.c_str())); - break; - } - } + auto ev6 = dynamic_cast(event.get()); - if (rsNotify->NotifyLogMessage(sysid, type, title, msg)) - { - /* make a log message */ - std::string logMesString = title + " " + msg; - switch(type) - { - case RS_SYS_ERROR: - case RS_SYS_WARNING: - case RS_SYS_INFO: - emit logInfoChanged(QString::fromUtf8(logMesString.c_str())); - } - } - } + if(ev6) + { + switch(ev6->mEventCode) + { + case RsSystemErrorEventCode::TIME_SHIFT_PROBLEM: + displayErrorMessage(RS_SYS_WARNING,tr("System time mismatch"),tr("Time shift problem notification. Make sure your machine is on time, because it will break chat rooms.")); + break; + case RsSystemErrorEventCode::DISK_SPACE_ERROR: + displayDiskSpaceWarning(ev6->mDiskErrorLocation,ev6->mDiskErrorSizeLimit); + break; + + case RsSystemErrorEventCode::DATA_STREAMING_ERROR: + case RsSystemErrorEventCode::GENERAL_ERROR: + displayErrorMessage(RS_SYS_WARNING,tr("Internal error"),QString::fromUtf8(ev6->mErrorMsg.c_str())); + break; + + default: break; + } + return; + }; + + + /*Now check Plugins*/ + int pluginCount = rsPlugins->nbPlugins(); + + for (int i = 0; i < pluginCount; ++i) { + RsPlugin *rsPlugin = rsPlugins->plugin(i); + if (rsPlugin) { + ToasterNotify *toasterNotify = rsPlugin->qt_toasterNotify(); + if (toasterNotify) { + insertToaster(toasterNotify->toasterItem()); + continue; + } + } + } + +// if (rsNotify->NotifyLogMessage(sysid, type, title, msg)) +// { +// /* make a log message */ +// std::string logMesString = title + " " + msg; +// switch(type) +// { +// case RS_SYS_ERROR: +// case RS_SYS_WARNING: +// case RS_SYS_INFO: +// emit logInfoChanged(QString::fromUtf8(logMesString.c_str())); +// } +// } +// } /* Now start the waiting toasters */ startWaitingToasters(); } @@ -900,7 +920,7 @@ void NotifyQt::testToasters(uint notifyFlags, /*RshareSettings::enumToasterPosit toaster = new ToasterItem(new OnlineToaster(id)); break; case RS_POPUP_DOWNLOAD: - toaster = new ToasterItem(new DownloadToaster(RsFileHash::random(), title)); + toaster = new ToasterItem(new DownloadToaster(RsFileHash::random())); break; case RS_POPUP_CHAT: toaster = new ToasterItem(new ChatToaster(id, message)); @@ -919,7 +939,7 @@ void NotifyQt::testToasters(uint notifyFlags, /*RshareSettings::enumToasterPosit break; } case RS_POPUP_CONNECT_ATTEMPT: - toaster = new ToasterItem(new FriendRequestToaster(pgpid, title, id)); + toaster = new ToasterItem(new FriendRequestToaster(pgpid, id)); break; } @@ -1166,6 +1186,7 @@ void NotifyQt::runningTick() } } +#ifdef TO_REMOVE void NotifyQt::addToaster(uint notifyFlags, const std::string& id, const std::string& title, const std::string& msg) { uint pos = 0; @@ -1210,7 +1231,7 @@ void NotifyQt::addToaster(uint notifyFlags, const std::string& id, const std::st if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster) { - toaster = new ToasterItem(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str()))); + toaster = new ToasterItem(new DownloadToaster(RsFileHash(id))); } break; case RS_POPUP_CHAT: @@ -1287,3 +1308,46 @@ void NotifyQt::addToaster(uint notifyFlags, const std::string& id, const std::st /* Now start the waiting toasters */ startWaitingToasters(); } +#endif + +void NotifyQt::displayErrorMessage(int type,const QString& title,const QString& error_msg) +{ + /* make a warning message */ + switch(type) + { + case RS_SYS_ERROR: QMessageBox::critical(MainWindow::getInstance(),title,error_msg); + break; + + case RS_SYS_WARNING: QMessageBox::warning(MainWindow::getInstance(),title,error_msg); + break; + + case RS_SYS_INFO: QMessageBox::information(MainWindow::getInstance(),title,error_msg); + break; + + default: std::cerr << "Warning: unhandled system error type " << type << std::endl; + break; + } +} + +void NotifyQt::displayDiskSpaceWarning(int loc,int size_limit_mb) +{ + QString locString ; + switch(loc) + { + case RS_PARTIALS_DIRECTORY: locString = "Partials" ; + break ; + + case RS_CONFIG_DIRECTORY: locString = "Config" ; + break ; + + case RS_DOWNLOAD_DIRECTORY: locString = "Download" ; + break ; + + default: + std::cerr << "Error: " << __PRETTY_FUNCTION__ << " was called with an unknown parameter loc=" << loc << std::endl ; + return ; + } + QMessageBox::critical(NULL,tr("Low disk space warning"), + tr("The disk space in your")+" "+locString +" "+tr("directory is running low (current limit is")+" "+QString::number(size_limit_mb)+tr("MB). \n\n RetroShare will now safely suspend any disk access to this directory. \n\n Please make some free space and click Ok.")) ; +} + diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index 93baf845e..5871c510a 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -96,8 +96,9 @@ class NotifyQt: public QObject, public NotifyClient void testToasters(uint notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin); void testToaster(ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin); void testToaster(QString tag, ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin); - +#ifdef TO_REMOVE void addToaster(uint notifyFlags, const std::string& id, const std::string& title, const std::string& msg); +#endif void notifySettingsChanged(); signals: @@ -141,7 +142,6 @@ class NotifyQt: public QObject, public NotifyClient void disableAllChanged(bool disableAll) const; public slots: - void UpdateGUI(); /* called by timer */ void SetDisableAll(bool bValue); private slots: @@ -152,7 +152,10 @@ class NotifyQt: public QObject, public NotifyClient private: NotifyQt(); - static NotifyQt *_instance; + static void displayDiskSpaceWarning(int loc,int size_limit_mb); + static void displayErrorMessage(int type,const QString& title,const QString& error_msg); + + static NotifyQt *_instance; static bool _disableAllToaster; /* system notifications */ @@ -172,6 +175,9 @@ class NotifyQt: public QObject, public NotifyClient /* so we can update windows */ NetworkDialog *cDialog; + + void handleIncomingEvent(std::shared_ptr e); /* called by timer */ + RsEventsHandlerId_t mEventHandlerId; }; #endif diff --git a/retroshare-gui/src/gui/toaster/DownloadToaster.cpp b/retroshare-gui/src/gui/toaster/DownloadToaster.cpp index 2818ba265..41b77c842 100644 --- a/retroshare-gui/src/gui/toaster/DownloadToaster.cpp +++ b/retroshare-gui/src/gui/toaster/DownloadToaster.cpp @@ -28,7 +28,7 @@ #include -DownloadToaster::DownloadToaster(const RsFileHash &hash, const QString &name) : QWidget(NULL) +DownloadToaster::DownloadToaster(const RsFileHash &hash) : QWidget(NULL) { ui.setupUi(this); @@ -38,8 +38,11 @@ DownloadToaster::DownloadToaster(const RsFileHash &hash, const QString &name) : connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(hide())); connect(ui.toasterButton, SIGNAL(clicked()), this, SLOT(play())); + FileInfo info; + rsFiles->FileDetails(hash, RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_DOWNLOAD, info ) ; + /* set informations */ - ui.textLabel->setText(name); + ui.textLabel->setText(QString::fromStdString(info.fname)); } void DownloadToaster::play() diff --git a/retroshare-gui/src/gui/toaster/DownloadToaster.h b/retroshare-gui/src/gui/toaster/DownloadToaster.h index 3d67e1af1..f63a6aadc 100644 --- a/retroshare-gui/src/gui/toaster/DownloadToaster.h +++ b/retroshare-gui/src/gui/toaster/DownloadToaster.h @@ -30,7 +30,7 @@ class DownloadToaster : public QWidget Q_OBJECT public: - DownloadToaster(const RsFileHash &hash, const QString &name); + DownloadToaster(const RsFileHash &hash); private slots: void play(); diff --git a/retroshare-gui/src/gui/toaster/FriendRequestToaster.cpp b/retroshare-gui/src/gui/toaster/FriendRequestToaster.cpp index 90bde9d10..f4968d55f 100644 --- a/retroshare-gui/src/gui/toaster/FriendRequestToaster.cpp +++ b/retroshare-gui/src/gui/toaster/FriendRequestToaster.cpp @@ -24,8 +24,8 @@ #include -FriendRequestToaster::FriendRequestToaster(const RsPgpId &gpgId, const QString &sslName, const RsPeerId &peerId) - : QWidget(NULL), mGpgId(gpgId), mSslId(peerId), mSslName(sslName) +FriendRequestToaster::FriendRequestToaster(const RsPgpId &gpgId, const RsPeerId &peerId) + : QWidget(NULL), mGpgId(gpgId), mSslId(peerId) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); @@ -33,7 +33,8 @@ FriendRequestToaster::FriendRequestToaster(const RsPgpId &gpgId, const QString & bool knownPeer = false; RsPeerDetails details; if (rsPeers->getGPGDetails(mGpgId, details)) { - knownPeer = true; + knownPeer = true; + mSslName = QString::fromUtf8(details.name.c_str()); } if (knownPeer) { @@ -51,7 +52,7 @@ FriendRequestToaster::FriendRequestToaster(const RsPgpId &gpgId, const QString & ui.textLabel->setText( peerName + " " + tr("wants to be friend with you on RetroShare")); ui.avatarWidget->setDefaultAvatar(":/images/avatar_request.png"); } else { - ui.textLabel->setText( sslName + " " + tr("Unknown (Incoming) Connect Attempt")); + ui.textLabel->setText( mSslName + " " + tr("Unknown (Incoming) Connect Attempt")); ui.avatarWidget->setDefaultAvatar(":/images/avatar_request_unknown.png"); } } diff --git a/retroshare-gui/src/gui/toaster/FriendRequestToaster.h b/retroshare-gui/src/gui/toaster/FriendRequestToaster.h index 07e7c11f8..eebc85301 100644 --- a/retroshare-gui/src/gui/toaster/FriendRequestToaster.h +++ b/retroshare-gui/src/gui/toaster/FriendRequestToaster.h @@ -33,7 +33,7 @@ class FriendRequestToaster : public QWidget Q_OBJECT public: - FriendRequestToaster(const RsPgpId &gpgId, const QString &sslName, const RsPeerId &peerId); + FriendRequestToaster(const RsPgpId &gpgId, const RsPeerId &peerId); private slots: void friendrequestButtonSlot(); From 5592c667aefed2ec1a71efd455c6e78da8d9a720 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 25 Sep 2025 18:05:35 +0200 Subject: [PATCH 23/38] fixed bug causing crash when rsPlugins is not initialized yet --- retroshare-gui/src/gui/notifyqt.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 42fd5a614..1a365cb65 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -861,15 +861,19 @@ void NotifyQt::handleIncomingEvent(std::shared_ptr event) /*Now check Plugins*/ - int pluginCount = rsPlugins->nbPlugins(); - for (int i = 0; i < pluginCount; ++i) { - RsPlugin *rsPlugin = rsPlugins->plugin(i); - if (rsPlugin) { - ToasterNotify *toasterNotify = rsPlugin->qt_toasterNotify(); - if (toasterNotify) { - insertToaster(toasterNotify->toasterItem()); - continue; + if(rsPlugins) // rsPlugins may not be initialized yet if we're handlign TorManager events. + { + int pluginCount = rsPlugins->nbPlugins(); + + for (int i = 0; i < pluginCount; ++i) { + RsPlugin *rsPlugin = rsPlugins->plugin(i); + if (rsPlugin) { + ToasterNotify *toasterNotify = rsPlugin->qt_toasterNotify(); + if (toasterNotify) { + insertToaster(toasterNotify->toasterItem()); + continue; + } } } } From 670475b67d44f6b4f8e95c5585cf03dae0c76318 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 27 Sep 2025 18:59:28 +0200 Subject: [PATCH 24/38] moved pgp passphrase handling to RsLoginHandler and removed irrelevant notify handles --- retroshare-gui/src/gui/GenCertDialog.cpp | 4 +- .../src/gui/Identity/IdEditDialog.cpp | 9 ++-- retroshare-gui/src/gui/StartDialog.cpp | 6 +-- .../src/gui/connect/ConnectFriendWizard.cpp | 3 +- .../src/gui/connect/PGPKeyDialog.cpp | 5 ++- retroshare-gui/src/gui/notifyqt.cpp | 41 +++++++++++-------- retroshare-gui/src/gui/notifyqt.h | 2 +- 7 files changed, 40 insertions(+), 30 deletions(-) diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index 7f836be89..3fe5321d3 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -656,7 +656,7 @@ void GenCertDialog::genPerson() // Normally we should clear the cached passphrase as soon as possible. However,some other GUI components may still need it at start. // (csoler) This is really bad: we have to guess that 30 secs will be enough. I have no better way to do this. - QTimer::singleShot(30000, []() { rsNotify->clearPgpPassphrase(); } ); + QTimer::singleShot(30000, []() { RsLoginHelper::clearPgpPassphrase(); } ); accept(); } @@ -664,7 +664,7 @@ void GenCertDialog::genPerson() else { // Now clear the cached passphrase - rsNotify->clearPgpPassphrase(); + RsLoginHelper::clearPgpPassphrase(); /* Message Dialog */ QMessageBox::warning(this, diff --git a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp index f22bf238e..6e3b015b0 100644 --- a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp @@ -33,6 +33,7 @@ #include "retroshare/rsidentity.h" #include "retroshare/rspeers.h" +#include "retroshare/rsinit.h" #include "gui/common/FilesDefs.h" #include "util/imageutil.h" #include "util/RsQtVersion.h" @@ -596,9 +597,9 @@ void IdEditDialog::createId() std::string gpg_name = rsPeers->getGPGName(rsPeers->getGPGOwnId()); bool cancelled; - rsNotify->clearPgpPassphrase(); // just in case + RsLoginHelper::clearPgpPassphrase(); // just in case - if(!NotifyQt::getInstance()->askForPassword(tr("Profile password needed.").toStdString(), + if(!RsLoginHelper::askForPassword(tr("Profile password needed.").toStdString(), gpg_name + " (" + rsPeers->getOwnId().toStdString() + ")", false, gpg_password,cancelled)) @@ -670,9 +671,9 @@ void IdEditDialog::updateId() std::string gpg_name = rsPeers->getGPGName(rsPeers->getGPGOwnId()); bool cancelled; - rsNotify->clearPgpPassphrase(); // just in case + RsLoginHelper::clearPgpPassphrase(); // just in case - if(!NotifyQt::getInstance()->askForPassword(tr("Profile password needed.").toStdString(), + if(!RsLoginHelper::askForPassword(tr("Profile password needed.").toStdString(), gpg_name + " (" + rsPeers->getOwnId().toStdString() + ")", false, gpg_password,cancelled)) diff --git a/retroshare-gui/src/gui/StartDialog.cpp b/retroshare-gui/src/gui/StartDialog.cpp index e53af6455..4f71b102f 100644 --- a/retroshare-gui/src/gui/StartDialog.cpp +++ b/retroshare-gui/src/gui/StartDialog.cpp @@ -119,13 +119,11 @@ void StartDialog::loadPerson() RsPeerId accountId = RsPeerId((data.toString()).toStdString()); // Cache the passphrase, so that it is not asked again. - rsNotify->cachePgpPassphrase(ui.password_input->text().toUtf8().constData()) ; - rsNotify->setDisableAskPassword(true); + RsLoginHelper::cachePgpPassphrase(ui.password_input->text().toUtf8().constData()) ; bool res = RsApplication::loadCertificate(accountId, ui.autologin_checkbox->isChecked()) ; - rsNotify->setDisableAskPassword(false); - rsNotify->clearPgpPassphrase(); + RsLoginHelper::clearPgpPassphrase(); if(res) accept(); diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index 4b5d9d314..dcc1bb5ea 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -46,6 +46,7 @@ #include "gui/msgs/MessageComposer.h" #include +#include #include #include @@ -767,7 +768,7 @@ void ConnectFriendWizard::accept() bool cancelled; std::string pgp_password; - if(!NotifyQt::getInstance()->askForPassword(tr("Profile password needed.").toStdString(), pgp_name + " (" + rsPeers->getOwnId().toStdString() + ")", prev_is_bad, pgp_password,cancelled)) + if(!RsLoginHelper::askForPassword(tr("Profile password needed.").toStdString(), pgp_name + " (" + rsPeers->getOwnId().toStdString() + ")", prev_is_bad, pgp_password,cancelled)) { QMessageBox::critical(NULL,tr("Identity creation failed"),tr("Cannot create an identity linked to your profile without your profile password.")); return; diff --git a/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp b/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp index 36b6057b4..3277dff30 100644 --- a/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp +++ b/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -364,13 +365,13 @@ void PGPKeyDialog::signGPGKey() bool cancelled; std::string gpg_password; - if(!NotifyQt::getInstance()->askForPassword(tr("Profile password needed.").toStdString(), gpg_name + " (" + rsPeers->getOwnId().toStdString() + ")", false, gpg_password,cancelled)) + if(!RsLoginHelper::askForPassword(tr("Profile password needed.").toStdString(), gpg_name + " (" + rsPeers->getOwnId().toStdString() + ")", false, gpg_password,cancelled)) { QMessageBox::critical(NULL,tr("Identity creation failed"),tr("Cannot create an identity linked to your profile without your profile password.")); return; } - rsNotify->clearPgpPassphrase(); // just in case + RsLoginHelper::clearPgpPassphrase(); // just in case if(!rsPeers->signGPGCertificate(pgpId,gpg_password)) QMessageBox::warning ( NULL, tr("Signature Failure"), tr("Check the password!"), QMessageBox::Ok); diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 1a365cb65..26d6f3890 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -231,27 +232,25 @@ void NotifyQt::handleSignatureEvent() } } - - -bool NotifyQt::askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password,bool& cancelled) +bool NotifyQt::graphical_askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password,bool& cancelled) { RsAutoUpdatePage::lockAllEvents() ; QString windowTitle; - if (title == "") { + if (title == "") windowTitle = tr("Passphrase required"); - } else if (title == "AuthSSLimpl::SignX509ReqWithGPG()") { + else if (title == "AuthSSLimpl::SignX509ReqWithGPG()") windowTitle = tr("You need to sign your node's certificate."); - } else if (title == "p3IdService::service_CreateGroup()") { + else if (title == "p3IdService::service_CreateGroup()") windowTitle = tr("You need to sign your forum/chatrooms identity."); - } else { + else windowTitle = QString::fromStdString(title); - } QString labelText = ( prev_is_bad ? QString("%1

").arg(tr("Wrong password !")) : QString() ) + QString("%1
Profile: %2\n") .arg( tr("Please enter your Retroshare passphrase") , QString::fromUtf8(key_details.c_str()) ); + QLineEdit::EchoMode textEchoMode = QLineEdit::Password; bool modal = true; @@ -267,12 +266,12 @@ bool NotifyQt::askForPassword(const std::string& title, const std::string& key_d , Q_ARG(QLineEdit::EchoMode, textEchoMode) , Q_ARG(bool, modal) ); - cancelled = false ; RsAutoUpdatePage::unlockAllEvents() ; if (ret.execReturn == QDialog::Rejected) { + RsLoginHelper::clearPgpPassphrase(); password.clear() ; cancelled = true ; return true ; @@ -280,10 +279,12 @@ bool NotifyQt::askForPassword(const std::string& title, const std::string& key_d if (ret.execReturn == QDialog::Accepted) { password = ret.textValue.toUtf8().constData(); - return true; + RsLoginHelper::cachePgpPassphrase(password); + return true; } - return false; + RsLoginHelper::clearPgpPassphrase(); + return false; } bool NotifyQt::askForPluginConfirmation(const std::string& plugin_file_name, const std::string& plugin_file_hash, bool first_time) { @@ -835,25 +836,33 @@ void NotifyQt::handleIncomingEvent(std::shared_ptr event) return; } - auto ev6 = dynamic_cast(event.get()); + auto ev6 = dynamic_cast(event.get()); if(ev6) { switch(ev6->mEventCode) { - case RsSystemErrorEventCode::TIME_SHIFT_PROBLEM: + case RsSystemEventCode::TIME_SHIFT_PROBLEM: displayErrorMessage(RS_SYS_WARNING,tr("System time mismatch"),tr("Time shift problem notification. Make sure your machine is on time, because it will break chat rooms.")); break; - case RsSystemErrorEventCode::DISK_SPACE_ERROR: + case RsSystemEventCode::DISK_SPACE_ERROR: displayDiskSpaceWarning(ev6->mDiskErrorLocation,ev6->mDiskErrorSizeLimit); break; - case RsSystemErrorEventCode::DATA_STREAMING_ERROR: - case RsSystemErrorEventCode::GENERAL_ERROR: + case RsSystemEventCode::DATA_STREAMING_ERROR: + case RsSystemEventCode::GENERAL_ERROR: displayErrorMessage(RS_SYS_WARNING,tr("Internal error"),QString::fromUtf8(ev6->mErrorMsg.c_str())); break; + case RsSystemEventCode::PASSWORD_REQUESTED: + { + std::string password; + bool cancelled; + graphical_askForPassword(ev6->passwd_request_title, ev6->passwd_request_key_details, ev6->passwd_request_prev_is_bad, password,cancelled); + break; + } + default: break; } return; diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index 5871c510a..4843c55dc 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -86,7 +86,7 @@ class NotifyQt: public QObject, public NotifyClient // virtual void notifyHistoryChanged(uint32_t msgId, int type); // virtual void notifyDiscInfoChanged() ; - virtual bool askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password, bool &cancelled); + virtual bool graphical_askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password, bool &cancelled); virtual bool askForPluginConfirmation(const std::string& plugin_filename, const std::string& plugin_file_hash,bool first_time); /* Notify from GUI */ From 86b9d6da08c397b201371ce50b0363a494adedba Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 27 Sep 2025 19:04:15 +0200 Subject: [PATCH 25/38] fixed bug using the wrong handler ID --- retroshare-gui/src/gui/msgs/MessagesDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index 4a558cce0..aaae460bb 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -309,7 +309,7 @@ MessagesDialog::MessagesDialog(QWidget *parent) rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }); }, mEventHandlerId, RsEventType::MAIL_STATUS ); mTagEventHandlerId = 0; - rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject( [this,event]() { handleTagEvent_main_thread(event); }); }, mEventHandlerId, RsEventType::MAIL_TAG ); + rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject( [this,event]() { handleTagEvent_main_thread(event); }); }, mTagEventHandlerId, RsEventType::MAIL_TAG ); mFontSizeHandler.registerFontSize(ui.listWidget, 1.5f, [this] (QAbstractItemView*, int fontSize) { // Set new font size on all items From 3f21b4bf65ee684d0b801348cb43465cae499606 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 28 Sep 2025 13:10:09 +0200 Subject: [PATCH 26/38] fixed bug causing passwd request to fail --- retroshare-gui/src/gui/notifyqt.cpp | 33 ++++++++++++++++++----------- retroshare-gui/src/gui/notifyqt.h | 6 ++++-- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 26d6f3890..c1d9b441e 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -110,7 +110,13 @@ NotifyQt::NotifyQt() : cDialog(NULL) // Catch all events that require toasters and mEventHandlerId = 0; - rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject([=](){ handleIncomingEvent(event); }, this ); }, mEventHandlerId); // No event type means we expect to catch all possible events + rsEvents->registerEventsHandler( [this](std::shared_ptr event) + { + if(event->mType == RsEventType::SYSTEM_ERROR && dynamic_cast(event.get())->mEventCode == RsSystemEventCode::PASSWORD_REQUESTED) + sync_handleIncomingEvent(event); + else + RsQThreadUtils::postToObject([=](){ async_handleIncomingEvent(event); }, this ); + }, mEventHandlerId); // No event type means we expect to catch all possible events #ifdef TO_REMOVE // register to allow sending over Qt::QueuedConnection @@ -270,7 +276,7 @@ bool NotifyQt::graphical_askForPassword(const std::string& title, const std::str RsAutoUpdatePage::unlockAllEvents() ; - if (ret.execReturn == QDialog::Rejected) { + if (ret.execReturn == QDialog::Rejected) { RsLoginHelper::clearPgpPassphrase(); password.clear() ; cancelled = true ; @@ -683,7 +689,19 @@ void NotifyQt::enable() _enabled = true ; } -void NotifyQt::handleIncomingEvent(std::shared_ptr event) +void NotifyQt::sync_handleIncomingEvent(std::shared_ptr event) +{ + auto ev6 = dynamic_cast(event.get()); + + if(ev6->mEventCode == RsSystemEventCode::PASSWORD_REQUESTED) + { + std::string password; + bool cancelled; + graphical_askForPassword(ev6->passwd_request_title, ev6->passwd_request_key_details, ev6->passwd_request_prev_is_bad, password,cancelled); + } +} + +void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) { static bool already_updated = false ; // these only update once at start because they may already have been set before // the gui is running, then they get updated by callbacks. @@ -854,15 +872,6 @@ void NotifyQt::handleIncomingEvent(std::shared_ptr event) case RsSystemEventCode::GENERAL_ERROR: displayErrorMessage(RS_SYS_WARNING,tr("Internal error"),QString::fromUtf8(ev6->mErrorMsg.c_str())); break; - - case RsSystemEventCode::PASSWORD_REQUESTED: - { - std::string password; - bool cancelled; - graphical_askForPassword(ev6->passwd_request_title, ev6->passwd_request_key_details, ev6->passwd_request_prev_is_bad, password,cancelled); - break; - } - default: break; } return; diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index 4843c55dc..a669864c6 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -146,7 +146,7 @@ class NotifyQt: public QObject, public NotifyClient private slots: void runningTick(); - void handleSignatureEvent() ; + void handleSignatureEvent() ; // void handleChatLobbyTimeShift(int) ; private: @@ -176,7 +176,9 @@ class NotifyQt: public QObject, public NotifyClient /* so we can update windows */ NetworkDialog *cDialog; - void handleIncomingEvent(std::shared_ptr e); /* called by timer */ + void async_handleIncomingEvent(std::shared_ptr e); + void sync_handleIncomingEvent(std::shared_ptr e); + RsEventsHandlerId_t mEventHandlerId; }; From 116c7f1aec9190b7d16a0f90dd173ac6f63e005c Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 30 Sep 2025 21:03:02 +0200 Subject: [PATCH 27/38] fixed passwd handling in retroshare-service --- retroshare-gui/src/gui/notifyqt.cpp | 36 ++++++++++---------- retroshare-gui/src/gui/notifyqt.h | 9 ++--- retroshare-gui/src/main.cpp | 4 +-- retroshare-service/src/retroshare-service.cc | 31 +++++++++++++++-- 4 files changed, 53 insertions(+), 27 deletions(-) diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index c1d9b441e..606fa5178 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -112,7 +112,7 @@ NotifyQt::NotifyQt() : cDialog(NULL) mEventHandlerId = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr event) { - if(event->mType == RsEventType::SYSTEM_ERROR && dynamic_cast(event.get())->mEventCode == RsSystemEventCode::PASSWORD_REQUESTED) + if(event->mType == RsEventType::SYSTEM && dynamic_cast(event.get())->mEventCode == RsSystemEventCode::PASSWORD_REQUESTED) sync_handleIncomingEvent(event); else RsQThreadUtils::postToObject([=](){ async_handleIncomingEvent(event); }, this ); @@ -165,7 +165,6 @@ void NotifyQt::notifyOwnAvatarChanged() #endif emit ownAvatarChanged() ; } -#endif class SignatureEventData { @@ -237,8 +236,9 @@ void NotifyQt::handleSignatureEvent() working = false ; } } +#endif -bool NotifyQt::graphical_askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password,bool& cancelled) +bool NotifyQt::GUI_askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad) { RsAutoUpdatePage::lockAllEvents() ; @@ -272,19 +272,18 @@ bool NotifyQt::graphical_askForPassword(const std::string& title, const std::str , Q_ARG(QLineEdit::EchoMode, textEchoMode) , Q_ARG(bool, modal) ); - cancelled = false ; + //cancelled = false ; RsAutoUpdatePage::unlockAllEvents() ; if (ret.execReturn == QDialog::Rejected) { RsLoginHelper::clearPgpPassphrase(); - password.clear() ; - cancelled = true ; + //cancelled = true ; return true ; } if (ret.execReturn == QDialog::Accepted) { - password = ret.textValue.toUtf8().constData(); + auto password = ret.textValue.toUtf8().constData(); RsLoginHelper::cachePgpPassphrase(password); return true; } @@ -292,7 +291,7 @@ bool NotifyQt::graphical_askForPassword(const std::string& title, const std::str RsLoginHelper::clearPgpPassphrase(); return false; } -bool NotifyQt::askForPluginConfirmation(const std::string& plugin_file_name, const std::string& plugin_file_hash, bool first_time) +bool NotifyQt::GUI_askForPluginConfirmation(const std::string& plugin_file_name, const RsFileHash& plugin_file_hash, bool first_time) { // By default, when no information is known about plugins, just dont load them. They will be enabled from the GUI by the user. @@ -307,7 +306,7 @@ bool NotifyQt::askForPluginConfirmation(const std::string& plugin_file_name, con QString text ; text += tr( "RetroShare has detected an unregistered plugin. This happens in two cases:
  • Your RetroShare executable has changed.
  • The plugin has changed
Click on Yes to authorize this plugin, or No to deny it. You can change your mind later in Options -> Plugins, then restart." ) ; text += "
    " ; - text += "
  • Hash:\t" + QString::fromStdString(plugin_file_hash) + "
  • " ; + text += "
  • Hash:\t" + QString::fromStdString(plugin_file_hash.toStdString()) + "
  • " ; text += "
  • File:\t" + QString::fromStdString(plugin_file_name) + "
  • "; text += "
" ; @@ -319,10 +318,13 @@ bool NotifyQt::askForPluginConfirmation(const std::string& plugin_file_name, con RsAutoUpdatePage::unlockAllEvents() ; - if (ret == QMessageBox::Yes) - return true ; - else - return false; + if (ret == QMessageBox::Yes) + return true; + else + { + rsPlugins->disablePlugin(plugin_file_hash); + return false; + } } #ifdef TO_REMOVE @@ -694,11 +696,9 @@ void NotifyQt::sync_handleIncomingEvent(std::shared_ptr event) auto ev6 = dynamic_cast(event.get()); if(ev6->mEventCode == RsSystemEventCode::PASSWORD_REQUESTED) - { - std::string password; - bool cancelled; - graphical_askForPassword(ev6->passwd_request_title, ev6->passwd_request_key_details, ev6->passwd_request_prev_is_bad, password,cancelled); - } + GUI_askForPassword(ev6->passwd_request_title, ev6->passwd_request_key_details, ev6->passwd_request_prev_is_bad); + else if(ev6->mEventCode == RsSystemEventCode::NEW_PLUGIN_FOUND) + GUI_askForPluginConfirmation(ev6->plugin_file_name, ev6->plugin_file_hash, ev6->plugin_first_time); } void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index a669864c6..042fd7ef9 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -47,7 +47,7 @@ class SignatureEventData ; struct TurtleFileInfo; struct TurtleGxsInfo; -class NotifyQt: public QObject, public NotifyClient +class NotifyQt: public QObject { Q_OBJECT public: @@ -86,8 +86,9 @@ class NotifyQt: public QObject, public NotifyClient // virtual void notifyHistoryChanged(uint32_t msgId, int type); // virtual void notifyDiscInfoChanged() ; - virtual bool graphical_askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password, bool &cancelled); - virtual bool askForPluginConfirmation(const std::string& plugin_filename, const std::string& plugin_file_hash,bool first_time); + + virtual bool GUI_askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad); + virtual bool GUI_askForPluginConfirmation(const std::string& plugin_filename, const RsFileHash& plugin_file_hash,bool first_time); /* Notify from GUI */ void notifyChatFontChanged(); @@ -146,7 +147,7 @@ class NotifyQt: public QObject, public NotifyClient private slots: void runningTick(); - void handleSignatureEvent() ; +// void handleSignatureEvent() ; // void handleChatLobbyTimeShift(int) ; private: diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 022ae227c..031c917b3 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -346,8 +346,8 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); // RsControl::earlyInitNotificationSystem() ; - NotifyQt *notify = NotifyQt::Create(); - rsNotify->registerNotifyClient(notify); + //NotifyQt *notify = NotifyQt::Create(); + //rsNotify->registerNotifyClient(notify); /* RetroShare Core Objects */ RsInit::InitRsConfig(); diff --git a/retroshare-service/src/retroshare-service.cc b/retroshare-service/src/retroshare-service.cc index ac82593da..4ca2c8a7a 100644 --- a/retroshare-service/src/retroshare-service.cc +++ b/retroshare-service/src/retroshare-service.cc @@ -71,7 +71,29 @@ std::string colored(int color,const std::string& s) } } +static void eventHandler(std::shared_ptr e) +{ + auto fe = dynamic_cast(e.get()); + + if(!fe) + return; + #ifdef RS_SERVICE_TERMINAL_LOGIN + if(fe->mEventCode == RsSystemEventCode::PASSWORD_REQUESTED) + { + std::string question1 = fe->passwd_request_title + colored(COLOR_GREEN,"Please enter your PGP password for key:\n ") + fe->passwd_request_key_details + " :"; + std::string password = RsUtil::rs_getpass(question1.c_str()) ; + + if(!password.empty()) + RsLoginHelper::cachePgpPassphrase(password); + } +#endif + + // We should also handle plugin loading +} + + +#ifdef TO_REMOVE class RsServiceNotify: public NotifyClient { public: @@ -86,7 +108,7 @@ public: password = RsUtil::rs_getpass(question1.c_str()) ; cancel = false ; - return !password.empty(); + return !password.empty(); } }; #endif // def RS_SERVICE_TERMINAL_LOGIN @@ -149,6 +171,9 @@ int main(int argc, char* argv[]) RsInit::InitRsConfig(); RsControl::earlyInitNotificationSystem(); + RsEventsHandlerId_t EventHandlerId = 0; + rsEvents->registerEventsHandler(eventHandler,EventHandlerId, RsEventType::SYSTEM); + #ifdef __APPLE__ // TODO: is this still needed with argstream? /* HACK to avoid stupid OSX Finder behaviour @@ -330,8 +355,8 @@ int main(int argc, char* argv[]) return -EINVAL; } - RsServiceNotify* notify = new RsServiceNotify(); - rsNotify->registerNotifyClient(notify); + //RsServiceNotify* notify = new RsServiceNotify(); + //rsNotify->registerNotifyClient(notify); // supply empty passwd so that it is properly asked 3 times on console RsInit::LoadCertificateStatus result = rsLoginHelper->attemptLogin(ssl_id, ""); From ff68c770d8942fb5a51cba38dda53482869c1b67 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 7 Oct 2025 21:13:24 +0200 Subject: [PATCH 28/38] removed all left rsnotify elements and moved uint32 flags to proper enum classes --- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 6 +- retroshare-gui/src/gui/GenCertDialog.cpp | 2 +- retroshare-gui/src/gui/NewsFeed.cpp | 52 +++++------ retroshare-gui/src/gui/NewsFeed.h | 17 ++-- retroshare-gui/src/gui/RetroShareLink.cpp | 2 +- retroshare-gui/src/gui/chat/ChatDialog.cpp | 10 +-- retroshare-gui/src/gui/chat/ChatDialog.h | 7 +- .../src/gui/chat/ChatLobbyDialog.cpp | 6 +- retroshare-gui/src/gui/chat/ChatLobbyDialog.h | 8 +- .../src/gui/chat/ChatUserNotify.cpp | 4 +- retroshare-gui/src/gui/chat/ChatWidget.h | 11 +++ .../src/gui/chat/PopupChatDialog.cpp | 4 +- retroshare-gui/src/gui/chat/PopupChatDialog.h | 10 +-- .../src/gui/chat/PopupChatWindow.cpp | 12 +-- retroshare-gui/src/gui/chat/PopupChatWindow.h | 5 +- .../src/gui/common/AvatarWidget.cpp | 2 + retroshare-gui/src/gui/feeds/FeedItem.cpp | 2 +- retroshare-gui/src/gui/feeds/FeedItem.h | 60 +++++++++++++ .../src/gui/feeds/GxsCircleItem.cpp | 24 ++--- retroshare-gui/src/gui/feeds/GxsCircleItem.h | 4 +- .../src/gui/feeds/SecurityIpItem.cpp | 14 +-- retroshare-gui/src/gui/feeds/SecurityIpItem.h | 6 +- retroshare-gui/src/gui/feeds/SecurityItem.cpp | 22 ++--- retroshare-gui/src/gui/feeds/SecurityItem.h | 4 +- .../src/gui/im_history/ImHistoryBrowser.cpp | 8 +- .../src/gui/im_history/ImHistoryBrowser.h | 2 +- retroshare-gui/src/gui/msgs/MessageWidget.cpp | 4 +- .../src/gui/msgs/MessagesDialog.cpp | 10 ++- retroshare-gui/src/gui/notifyqt.cpp | 53 +++++------ retroshare-gui/src/gui/notifyqt.h | 6 +- retroshare-gui/src/gui/settings/ChatPage.cpp | 22 ++--- .../src/gui/settings/MessagePage.cpp | 8 +- .../src/gui/settings/NotifyPage.cpp | 87 ++++++++++--------- retroshare-gui/src/gui/settings/NotifyPage.h | 6 +- .../src/gui/settings/rsharesettings.cpp | 34 ++++---- .../src/gui/settings/rsharesettings.h | 50 +++++++++-- retroshare-gui/src/main.cpp | 11 ++- 37 files changed, 360 insertions(+), 235 deletions(-) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index 9a7b51756..3e1b600fa 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -684,7 +684,7 @@ void ChatLobbyWidget::updateDisplay() if (autoSubscribe && subscribed && _lobby_infos.find(lobby.lobby_id) == _lobby_infos.end()) { - ChatDialog *cd = ChatDialog::getChat(ChatId(lobby.lobby_id), RS_CHAT_OPEN); + ChatDialog *cd = ChatDialog::getChat(ChatId(lobby.lobby_id), RsChatFlags::RS_CHAT_OPEN); addChatPage(dynamic_cast(cd)); } @@ -787,7 +787,7 @@ void ChatLobbyWidget::showLobby(QTreeWidgetItem *item) showBlankPage(id) ; else { - _lobby_infos[id].dialog->showDialog(RS_CHAT_FOCUS); + _lobby_infos[id].dialog->showDialog(RsChatFlags::RS_CHAT_FOCUS); if (_lobby_infos[id].dialog->isWindowed()) showBlankPage(id, true); } @@ -850,7 +850,7 @@ bool ChatLobbyWidget::showLobbyAnchor(ChatLobbyId id, QString anchor) if(_lobby_infos.find(id) == _lobby_infos.end()) { showBlankPage(id) ; } else { - _lobby_infos[id].dialog->showDialog(RS_CHAT_FOCUS); + _lobby_infos[id].dialog->showDialog(RsChatFlags::RS_CHAT_FOCUS); if (_lobby_infos[id].dialog->isWindowed()) showBlankPage(id, true); diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index 3fe5321d3..93f56d00f 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -643,7 +643,7 @@ void GenCertDialog::genPerson() std::cout << "RsAccounts::GenerateSSLCertificate" << std::endl; // now cache the PGP password so that it's not asked again for immediately signing the key - rsNotify->cachePgpPassphrase(ui.password_input->text().toUtf8().constData()) ; + rsLoginHelper->cachePgpPassphrase(ui.password_input->text().toUtf8().constData()) ; bool okGen = RsAccounts::createNewAccount(PGPId, "", genLoc, "", isHiddenLoc, isAutoTor, sslPasswd, sslId, err); diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index 320184e74..60791d975 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -192,27 +192,27 @@ void NewsFeed::handleEvent(std::shared_ptr event) void NewsFeed::handleEvent_main_thread(std::shared_ptr event) { - uint flags = Settings->getNewsFeedFlags(); + RsFeedTypeFlags flags = (RsFeedTypeFlags)Settings->getNewsFeedFlags(); - if(event->mType == RsEventType::AUTHSSL_CONNECTION_AUTENTICATION && (flags & RS_FEED_TYPE_SECURITY)) + if(event->mType == RsEventType::AUTHSSL_CONNECTION_AUTENTICATION && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_SECURITY))) handleSecurityEvent(event); - if(event->mType == RsEventType::FRIEND_LIST && (flags & RS_FEED_TYPE_PEER)) + if(event->mType == RsEventType::FRIEND_LIST && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_PEER))) handleConnectionEvent(event); - if(event->mType == RsEventType::GXS_CIRCLES && (flags & RS_FEED_TYPE_CIRCLE)) + if(event->mType == RsEventType::GXS_CIRCLES && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_CIRCLE))) handleCircleEvent(event); - if(event->mType == RsEventType::GXS_CHANNELS && (flags & RS_FEED_TYPE_CHANNEL)) + if(event->mType == RsEventType::GXS_CHANNELS && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_CHANNEL))) handleChannelEvent(event); - if(event->mType == RsEventType::GXS_FORUMS && (flags & RS_FEED_TYPE_FORUM)) + if(event->mType == RsEventType::GXS_FORUMS && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_FORUM))) handleForumEvent(event); - if(event->mType == RsEventType::GXS_POSTED && (flags & RS_FEED_TYPE_POSTED)) + if(event->mType == RsEventType::GXS_POSTED && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_POSTED))) handlePostedEvent(event); - if(event->mType == RsEventType::MAIL_STATUS && (flags & RS_FEED_TYPE_MSG)) + if(event->mType == RsEventType::MAIL_STATUS && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_MSG))) handleMailEvent(event); } @@ -389,25 +389,25 @@ void NewsFeed::handleCircleEvent(std::shared_ptr event) case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REQUEST: // only show membership requests if we're an admin of that circle if(details.isIdInInviteeList(pe->mGxsId)) - addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_JOIN),true); + addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_JOIN),true); else if(details.mAmIAdmin) - addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_REQ),true); + addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_REQ),true); break; case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE: if(details.isIdInInviteeList(pe->mGxsId)) - addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_LEAVE),true); + addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_LEAVE),true); break; case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_ID_ADDED_TO_INVITEE_LIST: if(rsIdentity->isOwnId(pe->mGxsId)) { if(details.isIdRequestingMembership(pe->mGxsId)) - addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_ACCEPTED),true); + addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_ACCEPTED),true); else - addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_INVITE_REC),true); + addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_INVITE_REC),true); } break; @@ -415,9 +415,9 @@ void NewsFeed::handleCircleEvent(std::shared_ptr event) if(rsIdentity->isOwnId(pe->mGxsId)) { if(details.isIdRequestingMembership(pe->mGxsId)) - addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_REVOKED),true); + addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_REVOKED),true); else - addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_INVITE_CANCELLED),true); + addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_INVITE_CANCELLED),true); } break; @@ -451,7 +451,7 @@ void NewsFeed::handleConnectionEvent(std::shared_ptr event) addFeedItemIfUnique(new SecurityIpItem( this, e.mSslId, e.mOwnLocator.toString(), e.mReportedLocator.toString(), - RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED, + RsFeedTypeFlags::RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED, false ), false); break; default: break; @@ -469,31 +469,31 @@ void NewsFeed::handleSecurityEvent(std::shared_ptr event) #ifdef NEWS_DEBUG std::cerr << "NotifyQt: handling security event from (" << e.mSslId << "," << e.mPgpId << ") error code: " << (int)e.mErrorCode << std::endl; #endif - uint flags = Settings->getNewsFeedFlags(); + RsFeedTypeFlags flags = (RsFeedTypeFlags)Settings->getNewsFeedFlags(); - if(e.mErrorCode == RsAuthSslError::PEER_REFUSED_CONNECTION && (flags & RS_FEED_TYPE_SECURITY_IP)) + if(e.mErrorCode == RsAuthSslError::PEER_REFUSED_CONNECTION && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_SECURITY_IP))) { addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_HELLO, false), true ); return; } - uint32_t FeedItemType=0; + RsFeedTypeFlags FeedItemType(RsFeedTypeFlags::RS_FEED_TYPE_NONE); switch(e.mErrorCode) { case RsAuthSslError::NO_CERTIFICATE_SUPPLIED: // fallthrough case RsAuthSslError::MISMATCHED_PGP_ID: // fallthrough case RsAuthSslError::MISSING_AUTHENTICATION_INFO: - FeedItemType = RS_FEED_ITEM_SEC_BAD_CERTIFICATE; break; + FeedItemType = RsFeedTypeFlags::RS_FEED_ITEM_SEC_BAD_CERTIFICATE; break; case RsAuthSslError::PGP_SIGNATURE_VALIDATION_FAILED: - FeedItemType = RS_FEED_ITEM_SEC_WRONG_SIGNATURE; break; + FeedItemType = RsFeedTypeFlags::RS_FEED_ITEM_SEC_WRONG_SIGNATURE; break; case RsAuthSslError::NOT_A_FRIEND: - FeedItemType = RS_FEED_ITEM_SEC_CONNECT_ATTEMPT; break; + FeedItemType = RsFeedTypeFlags::RS_FEED_ITEM_SEC_CONNECT_ATTEMPT; break; case RsAuthSslError::IP_IS_BLACKLISTED: - FeedItemType = RS_FEED_ITEM_SEC_IP_BLACKLISTED; break; + FeedItemType = RsFeedTypeFlags::RS_FEED_ITEM_SEC_IP_BLACKLISTED; break; case RsAuthSslError::MISSING_CERTIFICATE: - FeedItemType = RS_FEED_ITEM_SEC_MISSING_CERTIFICATE; break; + FeedItemType = RsFeedTypeFlags::RS_FEED_ITEM_SEC_MISSING_CERTIFICATE; break; default: return; // display nothing } @@ -503,11 +503,11 @@ void NewsFeed::handleSecurityEvent(std::shared_ptr event) addFeedItemIfUnique(new SecurityItem(this, NEWSFEED_SECLIST, e.mPgpId, e.mSslId, det.location, e.mLocator.toString(), FeedItemType, false), true ); - if (Settings->getMessageFlags() & RS_MESSAGE_CONNECT_ATTEMPT) + if (Settings->getMessageFlags() & RshareSettings::RS_MESSAGE_CONNECT_ATTEMPT) MessageComposer::addConnectAttemptMsg(e.mPgpId, e.mSslId, QString::fromStdString(det.name + "(" + det.location + ")")); } -void NewsFeed::testFeeds(uint /*notifyFlags*/) +void NewsFeed::testFeeds(RsFeedTypeFlags /*notifyFlags*/) { #ifdef TO_REMOVE if (!instance) { diff --git a/retroshare-gui/src/gui/NewsFeed.h b/retroshare-gui/src/gui/NewsFeed.h index 2b246fb4c..fed1d41b5 100644 --- a/retroshare-gui/src/gui/NewsFeed.h +++ b/retroshare-gui/src/gui/NewsFeed.h @@ -24,6 +24,7 @@ #include #include "gui/feeds/FeedHolder.h" +#include "gui/feeds/FeedItem.h" #include #define IMAGE_NEWSFEED ":/icons/png/newsfeed.png" @@ -67,19 +68,19 @@ public: /** Default Destructor */ virtual ~NewsFeed(); - virtual QIcon iconPixmap() const { return QIcon(IMAGE_NEWSFEED) ; } //MainPage - virtual QString pageName() const { return tr("Activity") ; } //MainPage - virtual QString helpText() const { return ""; } //MainPage + virtual QIcon iconPixmap() const override { return QIcon(IMAGE_NEWSFEED) ; } //MainPage + virtual QString pageName() const override { return tr("Activity") ; } //MainPage + virtual QString helpText() const override { return ""; } //MainPage virtual UserNotify *createUserNotify(QObject *parent) override; /* FeedHolder Functions (for FeedItem functionality) */ - virtual QScrollArea *getScrollArea(); - virtual void deleteFeedItem(FeedItem *item, uint32_t type); - virtual void openChat(const RsPeerId& peerId); - virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const QVector &versions, const RsGxsMessageId &msgId, const QString &title); + virtual QScrollArea *getScrollArea()override ; + virtual void deleteFeedItem(FeedItem *item, uint32_t type)override ; + virtual void openChat(const RsPeerId& peerId)override ; + virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const QVector &versions, const RsGxsMessageId &msgId, const QString &title)override ; - static void testFeeds(uint notifyFlags); + static void testFeeds(RsFeedTypeFlags notifyFlags); static void testFeed(FeedNotify *feedNotify); void handleEvent(std::shared_ptr event); // get events from libretroshare diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp index 0001cd9bc..212ca95b5 100644 --- a/retroshare-gui/src/gui/RetroShareLink.cpp +++ b/retroshare-gui/src/gui/RetroShareLink.cpp @@ -1758,7 +1758,7 @@ static void processList(const QStringList &list, const QString &textSingular, co } else { - ChatDialog* chatDialog = ChatDialog::getChat(chatId, Settings->getChatFlags()); + ChatDialog* chatDialog = ChatDialog::getChat(chatId, (RsChatFlags)Settings->getChatFlags()); if (chatDialog) { chatroomFound.append(link.name()); } else { diff --git a/retroshare-gui/src/gui/chat/ChatDialog.cpp b/retroshare-gui/src/gui/chat/ChatDialog.cpp index da31dbe3c..90389c36f 100644 --- a/retroshare-gui/src/gui/chat/ChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatDialog.cpp @@ -86,7 +86,7 @@ void ChatDialog::init(const ChatId &id, const QString &title) return NULL; } -/*static*/ ChatDialog* ChatDialog::getChat(ChatId id, uint chatflags) +/*static*/ ChatDialog* ChatDialog::getChat(ChatId id, RsChatFlags chatflags) { if(id.isBroadcast() || id.isNotSet()) return NULL; // broadcast is not handled by a chat dialog @@ -97,9 +97,9 @@ void ChatDialog::init(const ChatId &id, const QString &title) if (cd == NULL) { if(id.isDistantChatId()) - chatflags = RS_CHAT_OPEN | RS_CHAT_FOCUS; // force open for distant chat + chatflags = RsChatFlags::RS_CHAT_OPEN | RsChatFlags::RS_CHAT_FOCUS; // force open for distant chat - if (chatflags & RS_CHAT_OPEN) { + if (!!(chatflags & RsChatFlags::RS_CHAT_OPEN)) { if (id.isLobbyId()) { ChatLobbyDialog* cld = new ChatLobbyDialog(id.toLobbyId()); cld->init(ChatId(), ""); @@ -176,7 +176,7 @@ void ChatDialog::init(const ChatId &id, const QString &title) // play sound when recv a message SoundManager::play(SOUND_NEW_CHAT_MESSAGE); - ChatDialog *cd = getChat(msg.chat_id, Settings->getChatFlags()); + ChatDialog *cd = getChat(msg.chat_id, (RsChatFlags)Settings->getChatFlags()); if(cd) cd->addChatMsg(msg); else @@ -185,7 +185,7 @@ void ChatDialog::init(const ChatId &id, const QString &title) /*static*/ void ChatDialog::chatFriend(const ChatId &peerId, const bool forceFocus) { - getChat(peerId, forceFocus ? RS_CHAT_OPEN | RS_CHAT_FOCUS : RS_CHAT_OPEN); + getChat(peerId, forceFocus ? (RsChatFlags::RS_CHAT_OPEN | RsChatFlags::RS_CHAT_FOCUS) : RsChatFlags::RS_CHAT_OPEN); // below is the old code witch does lots of error checking. // because there are many different chat types, there are also different ways to check if the id is valid diff --git a/retroshare-gui/src/gui/chat/ChatDialog.h b/retroshare-gui/src/gui/chat/ChatDialog.h index 9d2cb6dd7..9db8e76d1 100644 --- a/retroshare-gui/src/gui/chat/ChatDialog.h +++ b/retroshare-gui/src/gui/chat/ChatDialog.h @@ -28,7 +28,8 @@ #include #include -class ChatWidget; +#include "gui/chat/ChatWidget.h" + class RSStyle; class ChatDialog : public QWidget @@ -37,14 +38,14 @@ class ChatDialog : public QWidget public: static ChatDialog *getExistingChat(ChatId id); - static ChatDialog *getChat(ChatId id, uint chatflags = 0); + static ChatDialog *getChat(ChatId id, RsChatFlags chatflags = RsChatFlags::RS_CHAT_NONE); static void cleanupChat(); static void chatFriend(const ChatId &peerId, bool forceFocus = true); static void chatFriend(const RsPgpId &gpgId, bool forceFocus = true); static void closeChat(const ChatId &chat_id); static void chatMessageReceived(ChatMessage msg); - virtual void showDialog(uint /*chatflags*/) {} + virtual void showDialog(RsChatFlags /*chatflags*/) {} virtual ChatWidget *getChatWidget() = 0; virtual bool hasPeerStatus() = 0; diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index fc45b65cc..cec0095e0 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -930,9 +930,9 @@ bool ChatLobbyDialog::canClose() return false; } -void ChatLobbyDialog::showDialog(uint chatflags) +void ChatLobbyDialog::showDialog(RsChatFlags chatflags) { - if (chatflags & RS_CHAT_FOCUS) + if (!!(chatflags & RsChatFlags::RS_CHAT_FOCUS)) { if (isWindowed() && mPCWindow) { mPCWindow->showDialog(this, chatflags); @@ -1020,5 +1020,5 @@ void ChatLobbyDialog::setWindowed(bool windowed) } show(); if (chatLobbyPage)// If not defined, we are on autosubscribe loop of lobby widget constructor. So don't recall it. - showDialog(RS_CHAT_FOCUS); + showDialog(RsChatFlags::RS_CHAT_FOCUS); } diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h index 0eb54bdc9..973509fe7 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h @@ -44,10 +44,10 @@ class ChatLobbyDialog: public ChatDialog public: void handleLobbyEvent(RsChatLobbyEventCode event_type, const RsGxsId& gxs_id, const QString& str); - virtual void showDialog(uint chatflags); - virtual ChatWidget *getChatWidget(); - virtual bool hasPeerStatus() { return false; } - virtual bool notifyBlink(); + virtual void showDialog(RsChatFlags chatflags) override; + virtual ChatWidget *getChatWidget() override; + virtual bool hasPeerStatus() override{ return false; } + virtual bool notifyBlink() override; void setIdentity(const RsGxsId& gxs_id); bool isParticipantMuted(const RsGxsId &participant); ChatLobbyId id() const { return lobbyId ;} diff --git a/retroshare-gui/src/gui/chat/ChatUserNotify.cpp b/retroshare-gui/src/gui/chat/ChatUserNotify.cpp index ac80761bc..0ee262dff 100644 --- a/retroshare-gui/src/gui/chat/ChatUserNotify.cpp +++ b/retroshare-gui/src/gui/chat/ChatUserNotify.cpp @@ -132,7 +132,7 @@ void ChatUserNotify::iconClicked() { ChatDialog *chatDialog = NULL; // ChatWidget removes the waiting chat from the list with clearWaitingChat() - chatDialog = ChatDialog::getChat(waitingChats.begin()->first, RS_CHAT_OPEN | RS_CHAT_FOCUS); + chatDialog = ChatDialog::getChat(waitingChats.begin()->first, RsChatFlags::RS_CHAT_OPEN | RsChatFlags::RS_CHAT_FOCUS); if (chatDialog == NULL) { MainWindow::showWindow(MainWindow::Friends); @@ -144,7 +144,7 @@ void ChatUserNotify::chatMessageReceived(ChatMessage msg) { if(!msg.chat_id.isBroadcast() &&( ChatDialog::getExistingChat(msg.chat_id) - || (Settings->getChatFlags() & RS_CHAT_OPEN) + || (Settings->getChatFlags() & (uint32_t)RsChatFlags::RS_CHAT_OPEN) || msg.chat_id.isDistantChatId())) { ChatDialog::chatMessageReceived(msg); diff --git a/retroshare-gui/src/gui/chat/ChatWidget.h b/retroshare-gui/src/gui/chat/ChatWidget.h index ed1645b14..cdef805c8 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.h +++ b/retroshare-gui/src/gui/chat/ChatWidget.h @@ -53,6 +53,17 @@ namespace Ui { class ChatWidget; } +enum class RsChatFlags: uint32_t { + RS_CHAT_NONE = 0x0000, + RS_CHAT_OPEN = 0x0001, + RS_CHAT_FOCUS = 0x0004, + RS_CHAT_TABBED_WINDOW = 0x0008, + RS_CHAT_BLINK = 0x0010, +}; + +RS_REGISTER_ENUM_FLAGS_TYPE(RsChatFlags); + + // a Container for the logic behind buttons in a PopupChatDialog // Plugins can implement this interface to provide their own buttons class ChatWidgetHolder diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 4da5d6fe4..6d5c9dd0b 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -113,7 +113,7 @@ ChatWidget *PopupChatDialog::getChatWidget() bool PopupChatDialog::notifyBlink() { - return (Settings->getChatFlags() & RS_CHAT_BLINK); + return (Settings->getChatFlags() & (uint32_t)RsChatFlags::RS_CHAT_BLINK); } void PopupChatDialog::processSettings(bool load) @@ -129,7 +129,7 @@ void PopupChatDialog::processSettings(bool load) Settings->endGroup(); } -void PopupChatDialog::showDialog(uint chatflags) +void PopupChatDialog::showDialog(RsChatFlags chatflags) { PopupChatWindow *window = WINDOW(this); if (window) { diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.h b/retroshare-gui/src/gui/chat/PopupChatDialog.h index 9708fbaae..7c2711971 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.h +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.h @@ -46,11 +46,11 @@ protected: /** Default destructor */ virtual ~PopupChatDialog(); - virtual void init(const ChatId &chat_id, const QString &title); - virtual void showDialog(uint chatflags); - virtual ChatWidget *getChatWidget(); - virtual bool hasPeerStatus() { return true; } - virtual bool notifyBlink(); + virtual void init(const ChatId &chat_id, const QString &title) override; + virtual void showDialog(RsChatFlags chatflags) override; + virtual ChatWidget *getChatWidget() override; + virtual bool hasPeerStatus() override{ return true; } + virtual bool notifyBlink() override; virtual void updateStatus(int /*status*/) {} diff --git a/retroshare-gui/src/gui/chat/PopupChatWindow.cpp b/retroshare-gui/src/gui/chat/PopupChatWindow.cpp index 7300b0a8e..2c02ba8e0 100644 --- a/retroshare-gui/src/gui/chat/PopupChatWindow.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatWindow.cpp @@ -49,7 +49,7 @@ static PopupChatWindow *instance = NULL; /*static*/ PopupChatWindow *PopupChatWindow::getWindow(bool needSingleWindow) { - if (needSingleWindow == false && (Settings->getChatFlags() & RS_CHAT_TABBED_WINDOW)) { + if (needSingleWindow == false && (Settings->getChatFlags() & (uint32_t)RsChatFlags::RS_CHAT_TABBED_WINDOW)) { if (instance == NULL) { instance = new PopupChatWindow(true); } @@ -162,7 +162,7 @@ void PopupChatWindow::showContextMenu(QPoint) } } - if (Settings->getChatFlags() & RS_CHAT_TABBED_WINDOW) + if (Settings->getChatFlags() & (uint32_t)RsChatFlags::RS_CHAT_TABBED_WINDOW) { if(tabbedWindow) contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/tab-dock.png"),tr("Dock window"),this,SLOT(docTab())); @@ -300,9 +300,9 @@ void PopupChatWindow::removeDialog(ChatDialog *dialog) } } -void PopupChatWindow::showDialog(ChatDialog *dialog, uint chatflags) +void PopupChatWindow::showDialog(ChatDialog *dialog, RsChatFlags chatflags) { - if (chatflags & RS_CHAT_FOCUS) { + if (!!(chatflags & RsChatFlags::RS_CHAT_FOCUS)) { if (tabbedWindow) { ui.tabWidget->setCurrentWidget(dialog); } @@ -352,7 +352,7 @@ void PopupChatWindow::calculateTitle(ChatDialog *dialog) icon = FilesDefs::getIconFromQtResourcePath(IMAGE_TYPING); } else if (hasNewMessages) { icon = FilesDefs::getIconFromQtResourcePath(IMAGE_CHAT); - if (Settings->getChatFlags() & RS_CHAT_BLINK) { + if (Settings->getChatFlags() & (uint32_t)RsChatFlags::RS_CHAT_BLINK) { mBlinkIcon = icon; } else { mBlinkIcon = QIcon(); @@ -423,7 +423,7 @@ void PopupChatWindow::tabNewMessage(ChatDialog *dialog) void PopupChatWindow::dockTab() { - if ((Settings->getChatFlags() & RS_CHAT_TABBED_WINDOW) && chatDialog) { + if ((Settings->getChatFlags() & (uint32_t)RsChatFlags::RS_CHAT_TABBED_WINDOW) && chatDialog) { PopupChatWindow *pcw = getWindow(false); if (pcw) { ChatDialog *pcd = chatDialog; diff --git a/retroshare-gui/src/gui/chat/PopupChatWindow.h b/retroshare-gui/src/gui/chat/PopupChatWindow.h index 4deb77bfb..036df8924 100644 --- a/retroshare-gui/src/gui/chat/PopupChatWindow.h +++ b/retroshare-gui/src/gui/chat/PopupChatWindow.h @@ -27,6 +27,9 @@ #include "ui_PopupChatWindow.h" #include #include + +#include "gui/chat/ChatWidget.h" + Q_DECLARE_METATYPE(RsGxsId) Q_DECLARE_METATYPE(QList) @@ -43,7 +46,7 @@ public: public: void addDialog(ChatDialog *dialog); void removeDialog(ChatDialog *dialog); - void showDialog(ChatDialog *dialog, uint chatflags); + void showDialog(ChatDialog *dialog, RsChatFlags chatflags); void alertDialog(ChatDialog *dialog); void calculateTitle(ChatDialog *dialog); diff --git a/retroshare-gui/src/gui/common/AvatarWidget.cpp b/retroshare-gui/src/gui/common/AvatarWidget.cpp index 75ac697f5..df1584686 100644 --- a/retroshare-gui/src/gui/common/AvatarWidget.cpp +++ b/retroshare-gui/src/gui/common/AvatarWidget.cpp @@ -106,6 +106,8 @@ QString AvatarWidget::frameState() return "AWAY"; case RsStatusValue::RS_STATUS_BUSY: return "BUSY"; + default: + break; } } return "NOTHING"; diff --git a/retroshare-gui/src/gui/feeds/FeedItem.cpp b/retroshare-gui/src/gui/feeds/FeedItem.cpp index e9991e6d0..fbaa7226d 100644 --- a/retroshare-gui/src/gui/feeds/FeedItem.cpp +++ b/retroshare-gui/src/gui/feeds/FeedItem.cpp @@ -48,7 +48,7 @@ uint64_t FeedItem::hash_64bits(const std::string& s) const if(mHash == 0) mHash = hash64(s); - return mHash; + return mHash; } uint64_t FeedItem::hash64(const std::string& s) diff --git a/retroshare-gui/src/gui/feeds/FeedItem.h b/retroshare-gui/src/gui/feeds/FeedItem.h index 7739ac122..f2bb92e9f 100644 --- a/retroshare-gui/src/gui/feeds/FeedItem.h +++ b/retroshare-gui/src/gui/feeds/FeedItem.h @@ -21,10 +21,70 @@ #ifndef _FEED_ITEM_H #define _FEED_ITEM_H +#include #include class FeedHolder; +enum class RsFeedTypeFlags: uint32_t { + RS_FEED_TYPE_NONE = 0x0000, + RS_FEED_TYPE_PEER = 0x0010, + RS_FEED_TYPE_CHANNEL = 0x0020, + RS_FEED_TYPE_FORUM = 0x0040, + RS_FEED_TYPE_CHAT = 0x0100, + RS_FEED_TYPE_MSG = 0x0200, + RS_FEED_TYPE_FILES = 0x0400, + RS_FEED_TYPE_SECURITY = 0x0800, + RS_FEED_TYPE_POSTED = 0x1000, + RS_FEED_TYPE_SECURITY_IP = 0x2000, + RS_FEED_TYPE_CIRCLE = 0x4000, + + RS_FEED_ITEM_PEER_CONNECT = RS_FEED_TYPE_PEER | 0x0001, + RS_FEED_ITEM_PEER_DISCONNECT = RS_FEED_TYPE_PEER | 0x0002, + RS_FEED_ITEM_PEER_HELLO = RS_FEED_TYPE_PEER | 0x0003, + RS_FEED_ITEM_PEER_NEW = RS_FEED_TYPE_PEER | 0x0004, + RS_FEED_ITEM_PEER_OFFSET = RS_FEED_TYPE_PEER | 0x0005, + RS_FEED_ITEM_PEER_DENIES_CONNEXION = RS_FEED_TYPE_PEER | 0x0006, + + RS_FEED_ITEM_SEC_CONNECT_ATTEMPT = RS_FEED_TYPE_SECURITY | 0x0001, + RS_FEED_ITEM_SEC_AUTH_DENIED = RS_FEED_TYPE_SECURITY | 0x0002, // locally denied connection + RS_FEED_ITEM_SEC_UNKNOWN_IN = RS_FEED_TYPE_SECURITY | 0x0003, + RS_FEED_ITEM_SEC_UNKNOWN_OUT = RS_FEED_TYPE_SECURITY | 0x0004, + RS_FEED_ITEM_SEC_WRONG_SIGNATURE = RS_FEED_TYPE_SECURITY | 0x0005, + RS_FEED_ITEM_SEC_BAD_CERTIFICATE = RS_FEED_TYPE_SECURITY | 0x0006, + RS_FEED_ITEM_SEC_INTERNAL_ERROR = RS_FEED_TYPE_SECURITY | 0x0007, + RS_FEED_ITEM_SEC_MISSING_CERTIFICATE = RS_FEED_TYPE_SECURITY | 0x0008, + + RS_FEED_ITEM_SEC_IP_BLACKLISTED = RS_FEED_TYPE_SECURITY_IP | 0x0001, + RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED = RS_FEED_TYPE_SECURITY_IP | 0x0002, + + RS_FEED_ITEM_CHANNEL_NEW = RS_FEED_TYPE_CHANNEL | 0x0002, + RS_FEED_ITEM_CHANNEL_MSG = RS_FEED_TYPE_CHANNEL | 0x0003, + RS_FEED_ITEM_CHANNEL_PUBLISHKEY = RS_FEED_TYPE_CHANNEL| 0x0004, + + RS_FEED_ITEM_FORUM_NEW = RS_FEED_TYPE_FORUM | 0x0001, + RS_FEED_ITEM_FORUM_MSG = RS_FEED_TYPE_FORUM | 0x0003, + RS_FEED_ITEM_FORUM_PUBLISHKEY = RS_FEED_TYPE_FORUM | 0x0004, + + RS_FEED_ITEM_POSTED_NEW = RS_FEED_TYPE_POSTED | 0x0001, + RS_FEED_ITEM_POSTED_MSG = RS_FEED_TYPE_POSTED | 0x0003, + + RS_FEED_ITEM_CHAT_NEW = RS_FEED_TYPE_CHAT | 0x0001, + RS_FEED_ITEM_MESSAGE = RS_FEED_TYPE_MSG | 0x0001, + RS_FEED_ITEM_FILES_NEW = RS_FEED_TYPE_FILES | 0x0001, + + RS_FEED_ITEM_CIRCLE_MEMB_REQ = RS_FEED_TYPE_CIRCLE | 0x0001, + RS_FEED_ITEM_CIRCLE_INVITE_REC = RS_FEED_TYPE_CIRCLE | 0x0002, + RS_FEED_ITEM_CIRCLE_MEMB_LEAVE = RS_FEED_TYPE_CIRCLE | 0x0003, + RS_FEED_ITEM_CIRCLE_MEMB_JOIN = RS_FEED_TYPE_CIRCLE | 0x0004, + RS_FEED_ITEM_CIRCLE_MEMB_ACCEPTED = RS_FEED_TYPE_CIRCLE | 0x0005, + RS_FEED_ITEM_CIRCLE_MEMB_REVOKED = RS_FEED_TYPE_CIRCLE | 0x0006, + RS_FEED_ITEM_CIRCLE_INVITE_CANCELLED= RS_FEED_TYPE_CIRCLE | 0x0007, +}; + + +RS_REGISTER_ENUM_FLAGS_TYPE(RsFeedTypeFlags); + class FeedItem : public QWidget { Q_OBJECT diff --git a/retroshare-gui/src/gui/feeds/GxsCircleItem.cpp b/retroshare-gui/src/gui/feeds/GxsCircleItem.cpp index aa7dfa705..aacfb4129 100644 --- a/retroshare-gui/src/gui/feeds/GxsCircleItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsCircleItem.cpp @@ -40,7 +40,7 @@ #define CIRCLESDIALOG_GROUPUPDATE 3 -GxsCircleItem::GxsCircleItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsCircleId &circleId, const RsGxsId &gxsId, const uint32_t type) +GxsCircleItem::GxsCircleItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsCircleId &circleId, const RsGxsId &gxsId, RsFeedTypeFlags type) :FeedItem(feedHolder,feedId,NULL), mType(type), mCircleId(circleId), mGxsId(gxsId) { setup(); @@ -92,7 +92,7 @@ void GxsCircleItem::setup() // from here we can figure out if we already have requested membership or not - if (mType == RS_FEED_ITEM_CIRCLE_MEMB_REQ) + if (mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_REQ) { ui->titleLabel->setText(tr("You received a membership request a circle you're administrating:")); ui->iconLabel->setPixmap(pixmap); @@ -105,7 +105,7 @@ void GxsCircleItem::setup() ui->membershipButton->setHidden(true); } - else if (mType == RS_FEED_ITEM_CIRCLE_INVITE_REC) + else if (mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_INVITE_REC) { ui->titleLabel->setText(tr("You received an invitation to join this circle:")); ui->iconLabel->setPixmap(pixmap); @@ -118,7 +118,7 @@ void GxsCircleItem::setup() connect(ui->membershipButton, SIGNAL(clicked()), this, SLOT(requestCircleSubscription())); ui->inviteeButton->setHidden(true); } - else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_LEAVE) + else if (mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_LEAVE) { ui->titleLabel->setText(idName + tr(" has left this circle.")); ui->iconLabel->setPixmap(pixmap); @@ -127,7 +127,7 @@ void GxsCircleItem::setup() ui->membershipButton->setHidden(true); ui->inviteeButton->setHidden(true); } - else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_JOIN) + else if (mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_JOIN) { if(circleDetails.mAmIAdmin) { @@ -148,7 +148,7 @@ void GxsCircleItem::setup() ui->membershipButton->setHidden(true); } - else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_REVOKED) + else if (mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_REVOKED) { ui->titleLabel->setText(tr("Your identity %1 has been revoked from this circle.").arg(idName)); @@ -162,7 +162,7 @@ void GxsCircleItem::setup() ui->inviteeButton->setHidden(true); } - else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_ACCEPTED) + else if (mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_ACCEPTED) { ui->titleLabel->setText(tr("Your identity %1 as been accepted in this circle.").arg(idName)); @@ -198,7 +198,7 @@ void GxsCircleItem::showCircleDetails() { CreateCircleDialog dlg; - dlg.editExistingId(RsGxsGroupId(mCircleId), true, mType != RS_FEED_ITEM_CIRCLE_MEMB_REQ) ; + dlg.editExistingId(RsGxsGroupId(mCircleId), true, mType != RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_REQ) ; dlg.exec(); } @@ -215,9 +215,9 @@ void GxsCircleItem::toggleCircleMembership() return; } - if(mType == RS_FEED_ITEM_CIRCLE_INVITE_REC) + if(mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_INVITE_REC) rsGxsCircles->requestCircleMembership(mGxsId,mCircleId); - else if(mType == RS_FEED_ITEM_CIRCLE_MEMB_REVOKED) + else if(mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_REVOKED) rsGxsCircles->cancelCircleMembership(mGxsId,mCircleId); else RsErr() << __PRETTY_FUNCTION__ << ": inconsistent call. mType is " << mType << std::endl; @@ -225,12 +225,12 @@ void GxsCircleItem::toggleCircleMembership() void GxsCircleItem::toggleCircleInvite() { - if(mType == RS_FEED_ITEM_CIRCLE_MEMB_JOIN) + if(mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_JOIN) RsThread::async([this]() { rsGxsCircles->revokeIdsFromCircle(std::set( { mGxsId } ),mCircleId); }); - else if(mType == RS_FEED_ITEM_CIRCLE_MEMB_REQ) + else if(mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_REQ) RsThread::async([this]() { rsGxsCircles->inviteIdsToCircle(std::set( { mGxsId } ),mCircleId); diff --git a/retroshare-gui/src/gui/feeds/GxsCircleItem.h b/retroshare-gui/src/gui/feeds/GxsCircleItem.h index 74f2cf44a..8133b8fa7 100644 --- a/retroshare-gui/src/gui/feeds/GxsCircleItem.h +++ b/retroshare-gui/src/gui/feeds/GxsCircleItem.h @@ -37,7 +37,7 @@ class GxsCircleItem : public FeedItem public: /** Default Constructor */ - GxsCircleItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsCircleId &circleId, const RsGxsId &gxsId, const uint32_t type); + GxsCircleItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsCircleId &circleId, const RsGxsId &gxsId, RsFeedTypeFlags type); virtual ~GxsCircleItem(); uint64_t uniqueIdentifier() const override; @@ -60,7 +60,7 @@ private slots: private: void setup(); - uint32_t mType; + RsFeedTypeFlags mType; RsGxsCircleId mCircleId; RsGxsId mGxsId; diff --git a/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp b/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp index 6ba4df6f5..2039e0804 100644 --- a/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp @@ -40,14 +40,14 @@ ****/ /** Constructor */ -SecurityIpItem::SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string &ipAddr, uint32_t result, uint32_t type, bool isTest) : +SecurityIpItem::SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string &ipAddr, uint32_t result, RsFeedTypeFlags type, bool isTest) : FeedItem(parent,0,NULL), mType(type), mSslId(sslId), mIpAddr(ipAddr), mResult(result), mIsTest(isTest), ui(new(Ui::SecurityIpItem)) { setup(); } -SecurityIpItem::SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string& ipAddr, const std::string& ipAddrReported, uint32_t type, bool isTest) : +SecurityIpItem::SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string& ipAddr, const std::string& ipAddrReported, RsFeedTypeFlags type, bool isTest) : FeedItem(parent,0,NULL), mType(type), mSslId(sslId), mIpAddr(ipAddr), mIpAddrReported(ipAddrReported), mResult(0), mIsTest(isTest), ui(new(Ui::SecurityIpItem)) { @@ -81,7 +81,7 @@ void SecurityIpItem::setup() uint64_t SecurityIpItem::uniqueIdentifier() const { - return hash_64bits("SecurityItem " + QString::number(mType).toStdString() + " " + mSslId.toStdString() + " " + mIpAddr + " " + mIpAddrReported) ; + return hash_64bits("SecurityItem " + QString::number((int)mType).toStdString() + " " + mSslId.toStdString() + " " + mIpAddr + " " + mIpAddrReported) ; } void SecurityIpItem::updateItemStatic() @@ -97,12 +97,12 @@ void SecurityIpItem::updateItemStatic() /* Specific type */ switch (mType) { - case RS_FEED_ITEM_SEC_IP_BLACKLISTED: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_IP_BLACKLISTED: ui->rsBanListButton->setDisabled(mIsTest); ui->ipAddrReported->hide(); ui->ipAddrReportedLabel->hide(); break; - case RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED: ui->rsBanListButton->hide(); break; default: @@ -126,7 +126,7 @@ void SecurityIpItem::updateItem() if(!RsAutoUpdatePage::eventsLocked()) { switch (mType) { - case RS_FEED_ITEM_SEC_IP_BLACKLISTED: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_IP_BLACKLISTED: ui->titleLabel->setText(RsBanListDefs::resultString(mResult)); ui->ipAddr->setText(QString::fromStdString(mIpAddr)); @@ -145,7 +145,7 @@ void SecurityIpItem::updateItem() } } break; - case RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED: ui->titleLabel->setText(tr("Wrong external ip address reported")); ui->ipAddr->setText(QString::fromStdString(mIpAddr)); ui->ipAddr->setToolTip(tr("

This is the external IP your Retroshare node thinks it is using.

")) ; diff --git a/retroshare-gui/src/gui/feeds/SecurityIpItem.h b/retroshare-gui/src/gui/feeds/SecurityIpItem.h index bfef10634..506bb3de9 100644 --- a/retroshare-gui/src/gui/feeds/SecurityIpItem.h +++ b/retroshare-gui/src/gui/feeds/SecurityIpItem.h @@ -38,8 +38,8 @@ class SecurityIpItem : public FeedItem public: /** Default Constructor */ - SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string& ipAddr, uint32_t result, uint32_t type, bool isTest); - SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string& ipAddr, const std::string& ipAddrReported, uint32_t type, bool isTest); + SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string& ipAddr, uint32_t result, RsFeedTypeFlags type, bool isTest); + SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string& ipAddr, const std::string& ipAddrReported, RsFeedTypeFlags type, bool isTest); void updateItemStatic(); @@ -60,7 +60,7 @@ private slots: void banIpListChanged(const QString &ipAddress); private: - uint32_t mType; + RsFeedTypeFlags mType; RsPeerId mSslId; std::string mIpAddr; std::string mIpAddrReported; diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.cpp b/retroshare-gui/src/gui/feeds/SecurityItem.cpp index 64ee198de..7d4059a08 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityItem.cpp @@ -45,7 +45,7 @@ ****/ /** Constructor */ -SecurityItem::SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &gpgId, const RsPeerId &sslId, const std::string &sslCn, const std::string& ip_address,uint32_t type, bool isHome) : +SecurityItem::SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &gpgId, const RsPeerId &sslId, const std::string &sslCn, const std::string& ip_address,RsFeedTypeFlags type, bool isHome) : FeedItem(parent,feedId,NULL), mGpgId(gpgId), mSslId(sslId), mSslCn(sslCn), mIP(ip_address), mType(type), mIsHome(isHome) { @@ -105,7 +105,7 @@ SecurityItem::~SecurityItem() } uint64_t SecurityItem::uniqueIdentifier() const { - return hash_64bits("SecurityItem " + QString::number(mType).toStdString() + " " + mSslId.toStdString()); + return hash_64bits("SecurityItem " + QString::number((uint)mType).toStdString() + " " + mSslId.toStdString()); } void SecurityItem::updateItemStatic() @@ -122,35 +122,35 @@ void SecurityItem::updateItemStatic() switch(mType) { - case RS_FEED_ITEM_SEC_CONNECT_ATTEMPT: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_CONNECT_ATTEMPT: title = tr("Connect Attempt"); requestLabel->show(); avatar->setDefaultAvatar(":images/avatar_request.png"); break; - case RS_FEED_ITEM_SEC_AUTH_DENIED: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_AUTH_DENIED: title = tr("Connection refused by remote peer"); requestLabel->hide(); avatar->setDefaultAvatar(":images/avatar_refused.png"); break; - case RS_FEED_ITEM_SEC_UNKNOWN_IN: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_UNKNOWN_IN: title = tr("Unknown (Incoming) Connect Attempt"); requestLabel->hide(); avatar->setDefaultAvatar(":images/avatar_request_unknown.png"); break; - case RS_FEED_ITEM_SEC_UNKNOWN_OUT: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_UNKNOWN_OUT: title = tr("Unknown (Outgoing) Connect Attempt"); requestLabel->hide(); break; - case RS_FEED_ITEM_SEC_WRONG_SIGNATURE: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_WRONG_SIGNATURE: title = tr("Certificate has wrong signature!! This peer is not who he claims to be."); requestLabel->hide(); break; - case RS_FEED_ITEM_SEC_MISSING_CERTIFICATE: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_MISSING_CERTIFICATE: title = tr("Peer/node not in friendlist (PGP id=")+QString::fromStdString(mGpgId.toStdString())+")"; avatar->setDefaultAvatar(":images/avatar_request_unknown.png"); requestLabel->show(); break; - case RS_FEED_ITEM_SEC_BAD_CERTIFICATE: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_BAD_CERTIFICATE: { RsPeerDetails details ; if(rsPeers->getGPGDetails(mGpgId, details)) @@ -161,7 +161,7 @@ void SecurityItem::updateItemStatic() } avatar->setDefaultAvatar(":icons/ssl.png"); break; - case RS_FEED_ITEM_SEC_INTERNAL_ERROR: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_INTERNAL_ERROR: title = tr("Certificate caused an internal error."); requestLabel->hide(); break; @@ -232,7 +232,7 @@ void SecurityItem::updateItem() removeFriendButton->hide(); peerDetailsButton->setEnabled(false); - if(mType == RS_FEED_ITEM_SEC_BAD_CERTIFICATE) + if(mType == RsFeedTypeFlags::RS_FEED_ITEM_SEC_BAD_CERTIFICATE) { peerNameLabel->setText(tr("SSL request")); friendRequesttoolButton->hide(); diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.h b/retroshare-gui/src/gui/feeds/SecurityItem.h index b51943f89..03887c121 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.h +++ b/retroshare-gui/src/gui/feeds/SecurityItem.h @@ -38,7 +38,7 @@ class SecurityItem : public FeedItem, private Ui::SecurityItem public: /** Default Constructor */ - SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &gpgId, const RsPeerId &sslId, const std::string &sslCn, const std::string& ip_addr,uint32_t type, bool isHome); + SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &gpgId, const RsPeerId &sslId, const std::string &sslCn, const std::string& ip_addr,RsFeedTypeFlags type, bool isHome); ~SecurityItem(); void updateItemStatic(); @@ -66,7 +66,7 @@ private: RsPeerId mSslId; std::string mSslCn; std::string mIP; - uint32_t mType; + RsFeedTypeFlags mType; bool mIsHome; RsEventsHandlerId_t mEventHandlerId; diff --git a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp index c9966b67b..f4f274a2c 100644 --- a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp +++ b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp @@ -238,9 +238,9 @@ void ImHistoryBrowser::historyAdd(HistoryMsg& msg) } } -void ImHistoryBrowser::historyChanged(uint msgId, int type) +void ImHistoryBrowser::historyChanged(uint msgId, RsChatHistoryChangeFlags type) { - if (type == NOTIFY_TYPE_ADD) { + if (type == RsChatHistoryChangeFlags::ADD) { /* history message added */ HistoryMsg msg; if (rsHistory->getMessage(msgId, msg) == false) { @@ -254,7 +254,7 @@ void ImHistoryBrowser::historyChanged(uint msgId, int type) return; } - if (type == NOTIFY_TYPE_DEL) { + if (type == RsChatHistoryChangeFlags::DEL) { /* history message removed */ int count = ui.listWidget->count(); for (int i = 0; i < count; ++i) { @@ -267,7 +267,7 @@ void ImHistoryBrowser::historyChanged(uint msgId, int type) return; } - if (type == NOTIFY_TYPE_MOD) { + if (type == RsChatHistoryChangeFlags::MOD) { /* clear history */ // As no ChatId nor msgId are send via Notify, // only check if history of this chat is empty before clear our list. diff --git a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h index a9230661c..0ebf2353e 100644 --- a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h +++ b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h @@ -52,7 +52,7 @@ private slots: void createThreadFinished(); void createThreadProgress(int current, int count); - void historyChanged(uint msgId, int type); + void historyChanged(uint msgId, RsChatHistoryChangeFlags type); void filterChanged(const QString& text); diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.cpp b/retroshare-gui/src/gui/msgs/MessageWidget.cpp index 13cb46753..bcbdaf219 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWidget.cpp @@ -261,7 +261,9 @@ void MessageWidget::handleEvent_main_thread(std::shared_ptr event case RsMailStatusEventCode::MESSAGE_RECEIVED_ACK: case RsMailStatusEventCode::SIGNATURE_FAILED: break; - } + default: + break; + } } void MessageWidget::connectAction(enumActionType actionType, QToolButton* button) diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index aaae460bb..22eb0f88b 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -351,6 +351,8 @@ void MessagesDialog::handleEvent_main_thread(std::shared_ptr even case RsMailStatusEventCode::MESSAGE_RECEIVED_ACK: case RsMailStatusEventCode::SIGNATURE_FAILED: break; + default: + break; } } @@ -1088,11 +1090,13 @@ void MessagesDialog::doubleClicked(const QModelIndex& proxy_index) } /* edit message */ - switch (Settings->getMsgOpen()) { - case RshareSettings::MSG_OPEN_TAB: + switch (Settings->getMsgOpen()) + { + default: + case RsSettingsMsgOptions::MSG_OPEN_TAB: openAsTab(); break; - case RshareSettings::MSG_OPEN_WINDOW: + case RsSettingsMsgOptions::MSG_OPEN_WINDOW: openAsWindow(); break; } diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 606fa5178..e4ee26b85 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -715,7 +715,7 @@ void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) /* Finally Check for PopupMessages / System Error Messages */ - uint popupflags = Settings->getNotifyFlags(); + RsNotifyPopupFlags popupflags = (RsNotifyPopupFlags)Settings->getNotifyFlags(); auto insertToaster = [this](ToasterItem *toaster) { @@ -736,7 +736,7 @@ void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) { SoundManager::play(SOUND_MESSAGE_ARRIVED); - if((popupflags & RS_POPUP_MSG) && !_disableAllToaster) + if((!!(popupflags & RsNotifyPopupFlags::RS_POPUP_MSG)) && !_disableAllToaster) { for(auto msgid:ev1->mChangedMsgIds) { @@ -757,7 +757,7 @@ void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) { SoundManager::play(SOUND_USER_ONLINE); - if ((popupflags & RS_POPUP_CONNECT) && !_disableAllToaster) + if ((!!(popupflags & RsNotifyPopupFlags::RS_POPUP_CONNECT)) && !_disableAllToaster) insertToaster(new ToasterItem(new OnlineToaster(ev2->mSslId))); } return; @@ -771,7 +771,7 @@ void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) { SoundManager::play(SOUND_DOWNLOAD_COMPLETE); - if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster) + if ((!!(popupflags & RsNotifyPopupFlags::RS_POPUP_DOWNLOAD)) && !_disableAllToaster) insertToaster(new ToasterItem(new DownloadToaster(ev3->mHash))); } return; @@ -783,7 +783,7 @@ void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) { if(ev4->mErrorCode == RsAuthSslError::NOT_A_FRIEND) { - if ((popupflags & RS_POPUP_CONNECT_ATTEMPT) && !_disableAllToaster) + if ((!!(popupflags & RsNotifyPopupFlags::RS_POPUP_CONNECT_ATTEMPT)) && !_disableAllToaster) // id = gpgid // title = ssl name // msg = peer id @@ -810,7 +810,7 @@ void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) if(ev5->mEventCode == RsChatServiceEventCode::CHAT_MESSAGE_RECEIVED) { - if (ev5->mCid.isPeerId() && (popupflags & RS_POPUP_CHAT) && !_disableAllToaster) + if (ev5->mCid.isPeerId() && (!!(popupflags & RsNotifyPopupFlags::RS_POPUP_CHAT)) && !_disableAllToaster) { // TODO: fix for distant chat, look up if dstant chat uses RS_POPUP_CHAT ChatDialog *chatDialog = ChatDialog::getChat(ev5->mCid); @@ -822,7 +822,7 @@ void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) insertToaster(new ToasterItem(new ChatToaster(ev5->mCid.toPeerId(), QString::fromUtf8(ev5->mMsg.msg.c_str())))); } #ifdef RS_DIRECT_CHAT - else if (ev5->mCid.isBroadcast() && (popupflags & RS_POPUP_GROUPCHAT) && !_disableAllToaster) + else if (ev5->mCid.isBroadcast() && (!!(popupflags & RsNotifyPopupFlags::RS_POPUP_GROUPCHAT)) && !_disableAllToaster) { MainWindow *mainWindow = MainWindow::getInstance(); if (mainWindow && mainWindow->isActiveWindow() && !mainWindow->isMinimized() @@ -832,7 +832,7 @@ void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) insertToaster(new ToasterItem(new GroupChatToaster(ev5->mCid.toPeerId(), QString::fromUtf8(ev5->mMsg.msg.c_str())))); } #endif - else if (ev5->mCid.isLobbyId() && (popupflags & RS_POPUP_CHATLOBBY) && !_disableAllToaster) + else if (ev5->mCid.isLobbyId() && (!!(popupflags & RsNotifyPopupFlags::RS_POPUP_CHATLOBBY)) && !_disableAllToaster) { ChatDialog *chatDialog = ChatDialog::getChat(ev5->mCid); ChatWidget *chatWidget; @@ -861,7 +861,7 @@ void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) switch(ev6->mEventCode) { case RsSystemEventCode::TIME_SHIFT_PROBLEM: - displayErrorMessage(RS_SYS_WARNING,tr("System time mismatch"),tr("Time shift problem notification. Make sure your machine is on time, because it will break chat rooms.")); + displayErrorMessage(RsNotifySysFlags::RS_SYS_WARNING,tr("System time mismatch"),tr("Time shift problem notification. Make sure your machine is on time, because it will break chat rooms.")); break; case RsSystemEventCode::DISK_SPACE_ERROR: @@ -870,7 +870,7 @@ void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) case RsSystemEventCode::DATA_STREAMING_ERROR: case RsSystemEventCode::GENERAL_ERROR: - displayErrorMessage(RS_SYS_WARNING,tr("Internal error"),QString::fromUtf8(ev6->mErrorMsg.c_str())); + displayErrorMessage(RsNotifySysFlags::RS_SYS_WARNING,tr("Internal error"),QString::fromUtf8(ev6->mErrorMsg.c_str())); break; default: break; } @@ -913,7 +913,7 @@ void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) startWaitingToasters(); } -void NotifyQt::testToasters(uint notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin) +void NotifyQt::testToasters(RsNotifyPopupFlags notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin) { QString title = tr("Test"); QString message = tr("This is a test."); @@ -922,37 +922,38 @@ void NotifyQt::testToasters(uint notifyFlags, /*RshareSettings::enumToasterPosit RsPgpId pgpid = rsPeers->getGPGOwnId(); uint pos = 0; + uint nf = (uint)notifyFlags; - while (notifyFlags) { - uint type = notifyFlags & (1 << pos); - notifyFlags &= ~(1 << pos); + while (nf) { + uint type = nf & (1 << pos); + nf &= ~(1 << pos); ++pos; ToasterItem *toaster = NULL; switch(type) { - case RS_POPUP_ENCRYPTED_MSG: + case (int)RsNotifyPopupFlags::RS_POPUP_ENCRYPTED_MSG: toaster = new ToasterItem(new MessageToaster(std::string(), tr("Unknown title"), QString("[%1]").arg(tr("Encrypted message")))); break; - case RS_POPUP_MSG: + case (int)RsNotifyPopupFlags::RS_POPUP_MSG: toaster = new ToasterItem(new MessageToaster(id.toStdString(), title, message)); break; - case RS_POPUP_CONNECT: + case (int)RsNotifyPopupFlags::RS_POPUP_CONNECT: toaster = new ToasterItem(new OnlineToaster(id)); break; - case RS_POPUP_DOWNLOAD: + case (int)RsNotifyPopupFlags::RS_POPUP_DOWNLOAD: toaster = new ToasterItem(new DownloadToaster(RsFileHash::random())); break; - case RS_POPUP_CHAT: + case (int)RsNotifyPopupFlags::RS_POPUP_CHAT: toaster = new ToasterItem(new ChatToaster(id, message)); break; - case RS_POPUP_GROUPCHAT: + case (int)RsNotifyPopupFlags::RS_POPUP_GROUPCHAT: #ifdef RS_DIRECT_CHAT toaster = new ToasterItem(new GroupChatToaster(id, message)); #endif // RS_DIRECT_CHAT break; - case RS_POPUP_CHATLOBBY: + case (int)RsNotifyPopupFlags::RS_POPUP_CHATLOBBY: { std::list gxsid; if(rsIdentity->getOwnIds(gxsid) && (gxsid.size() > 0)){ @@ -960,7 +961,7 @@ void NotifyQt::testToasters(uint notifyFlags, /*RshareSettings::enumToasterPosit } break; } - case RS_POPUP_CONNECT_ATTEMPT: + case (int)RsNotifyPopupFlags::RS_POPUP_CONNECT_ATTEMPT: toaster = new ToasterItem(new FriendRequestToaster(pgpid, id)); break; } @@ -1332,18 +1333,18 @@ void NotifyQt::addToaster(uint notifyFlags, const std::string& id, const std::st } #endif -void NotifyQt::displayErrorMessage(int type,const QString& title,const QString& error_msg) +void NotifyQt::displayErrorMessage(RsNotifySysFlags type,const QString& title,const QString& error_msg) { /* make a warning message */ switch(type) { - case RS_SYS_ERROR: QMessageBox::critical(MainWindow::getInstance(),title,error_msg); + case RsNotifySysFlags::RS_SYS_ERROR: QMessageBox::critical(MainWindow::getInstance(),title,error_msg); break; - case RS_SYS_WARNING: QMessageBox::warning(MainWindow::getInstance(),title,error_msg); + case RsNotifySysFlags::RS_SYS_WARNING: QMessageBox::warning(MainWindow::getInstance(),title,error_msg); break; - case RS_SYS_INFO: QMessageBox::information(MainWindow::getInstance(),title,error_msg); + case RsNotifySysFlags::RS_SYS_INFO: QMessageBox::information(MainWindow::getInstance(),title,error_msg); break; default: std::cerr << "Warning: unhandled system error type " << type << std::endl; diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index 042fd7ef9..aae3b1728 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -30,6 +30,8 @@ #include //#include +#include "settings/rsharesettings.h" + #include class QTimer; @@ -94,7 +96,7 @@ class NotifyQt: public QObject void notifyChatFontChanged(); void notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType); - void testToasters(uint notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin); + void testToasters(RsNotifyPopupFlags notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin); void testToaster(ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin); void testToaster(QString tag, ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin); #ifdef TO_REMOVE @@ -154,7 +156,7 @@ class NotifyQt: public QObject NotifyQt(); static void displayDiskSpaceWarning(int loc,int size_limit_mb); - static void displayErrorMessage(int type,const QString& title,const QString& error_msg); + static void displayErrorMessage(RsNotifySysFlags type,const QString& title,const QString& error_msg); static NotifyQt *_instance; static bool _disableAllToaster; diff --git a/retroshare-gui/src/gui/settings/ChatPage.cpp b/retroshare-gui/src/gui/settings/ChatPage.cpp index 2fc22a13d..769ec28c2 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.cpp +++ b/retroshare-gui/src/gui/settings/ChatPage.cpp @@ -354,18 +354,18 @@ void ChatPage::updateChatLobbyUserNotify() void ChatPage::updateChatFlags() { - uint chatflags = 0; + RsChatFlags chatflags(RsChatFlags::RS_CHAT_NONE); if (ui.chat_NewWindow->isChecked()) - chatflags |= RS_CHAT_OPEN; + chatflags |= RsChatFlags::RS_CHAT_OPEN; if (ui.chat_Focus->isChecked()) - chatflags |= RS_CHAT_FOCUS; + chatflags |= RsChatFlags::RS_CHAT_FOCUS; if (ui.chat_tabbedWindow->isChecked()) - chatflags |= RS_CHAT_TABBED_WINDOW; + chatflags |= RsChatFlags::RS_CHAT_TABBED_WINDOW; if (ui.chat_Blink->isChecked()) - chatflags |= RS_CHAT_BLINK; + chatflags |= RsChatFlags::RS_CHAT_BLINK; - Settings->setChatFlags(chatflags); + Settings->setChatFlags((uint32_t)chatflags); } void ChatPage::updateChatLobbyFlags() @@ -473,12 +473,12 @@ ChatPage::load() if(!gxs_id.isNull()) ui.chatLobbyIdentity_IC->setChosenId(gxs_id); - uint chatflags = Settings->getChatFlags(); + RsChatFlags chatflags = (RsChatFlags) Settings->getChatFlags(); - whileBlocking(ui.chat_NewWindow)->setChecked(chatflags & RS_CHAT_OPEN); - whileBlocking(ui.chat_Focus)->setChecked(chatflags & RS_CHAT_FOCUS); - whileBlocking(ui.chat_tabbedWindow)->setChecked(chatflags & RS_CHAT_TABBED_WINDOW); - whileBlocking(ui.chat_Blink)->setChecked(chatflags & RS_CHAT_BLINK); + whileBlocking(ui.chat_NewWindow)->setChecked(!!(chatflags & RsChatFlags::RS_CHAT_OPEN)); + whileBlocking(ui.chat_Focus)->setChecked(!!(chatflags & RsChatFlags::RS_CHAT_FOCUS)); + whileBlocking(ui.chat_tabbedWindow)->setChecked(!!(chatflags & RsChatFlags::RS_CHAT_TABBED_WINDOW)); + whileBlocking(ui.chat_Blink)->setChecked(!!(chatflags & RsChatFlags::RS_CHAT_BLINK)); uint chatLobbyFlags = Settings->getChatLobbyFlags(); diff --git a/retroshare-gui/src/gui/settings/MessagePage.cpp b/retroshare-gui/src/gui/settings/MessagePage.cpp index be8b515ff..0f11ef109 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.cpp +++ b/retroshare-gui/src/gui/settings/MessagePage.cpp @@ -49,8 +49,8 @@ MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags) ui.editpushButton->setEnabled(false); ui.deletepushButton->setEnabled(false); - ui.openComboBox->addItem(tr("A new tab"), RshareSettings::MSG_OPEN_TAB); - ui.openComboBox->addItem(tr("A new window"), RshareSettings::MSG_OPEN_WINDOW); + ui.openComboBox->addItem(tr("A new tab"), (int)RsSettingsMsgOptions::MSG_OPEN_TAB); + ui.openComboBox->addItem(tr("A new window"), (int)RsSettingsMsgOptions::MSG_OPEN_WINDOW); // Font size QFontDatabase db; @@ -97,7 +97,7 @@ void MessagePage::distantMsgsComboBoxChanged(int i) void MessagePage::updateMsgToReadOnActivate() { Settings->setMsgSetToReadOnActivate(ui.setMsgToReadOnActivate->isChecked()); } void MessagePage::updateLoadEmbededImages() { Settings->setMsgLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked()); } -void MessagePage::updateMsgOpen() { Settings->setMsgOpen( static_cast(ui.openComboBox->itemData(ui.openComboBox->currentIndex()).toInt()) ); } +void MessagePage::updateMsgOpen() { Settings->setMsgOpen( (RsSettingsMsgOptions)(ui.openComboBox->itemData(ui.openComboBox->currentIndex()).toInt()) ); } void MessagePage::updateDistantMsgs() { Settings->setValue("DistantMessages", ui.comboBox->currentIndex()); } void MessagePage::updateLoadEmoticons() { Settings->setValueToGroup("Messages", "Emoticons", ui.emoticonscheckBox->isChecked()); } @@ -128,7 +128,7 @@ MessagePage::load() { whileBlocking(ui.setMsgToReadOnActivate)->setChecked(Settings->getMsgSetToReadOnActivate()); whileBlocking(ui.loadEmbeddedImages)->setChecked(Settings->getMsgLoadEmbeddedImages()); - whileBlocking(ui.openComboBox)->setCurrentIndex(ui.openComboBox->findData(Settings->getMsgOpen())); + whileBlocking(ui.openComboBox)->setCurrentIndex(ui.openComboBox->findData((uint)Settings->getMsgOpen())); whileBlocking(ui.emoticonscheckBox)->setChecked(Settings->value("Emoticons", true).toBool()); whileBlocking(ui.minimumFontSize)->setCurrentIndex(ui.minimumFontSize->findData(Settings->getMessageFontSize())); diff --git a/retroshare-gui/src/gui/settings/NotifyPage.cpp b/retroshare-gui/src/gui/settings/NotifyPage.cpp index c0b2ea1a0..046895414 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.cpp +++ b/retroshare-gui/src/gui/settings/NotifyPage.cpp @@ -29,6 +29,7 @@ #include "gui/common/UserNotify.h" #include "gui/common/FeedNotify.h" #include "gui/common/ToasterNotify.h" +#include "gui/feeds/FeedItem.h" #include "gui/notifyqt.h" #include "gui/NewsFeed.h" #include "util/misc.h" @@ -180,32 +181,32 @@ NotifyPage::~NotifyPage() { } -uint NotifyPage::getNewsFlags() +RsFeedTypeFlags NotifyPage::getNewsFlags() { - uint newsFlags = 0; + RsFeedTypeFlags newsFlags(RsFeedTypeFlags::RS_FEED_TYPE_NONE); if (ui.notify_Peers->isChecked()) - newsFlags |= RS_FEED_TYPE_PEER; + newsFlags |= RsFeedTypeFlags::RS_FEED_TYPE_PEER; if (ui.notify_Circles->isChecked()) - newsFlags |= RS_FEED_TYPE_CIRCLE; + newsFlags |= RsFeedTypeFlags::RS_FEED_TYPE_CIRCLE; if (ui.notify_Channels->isChecked()) - newsFlags |= RS_FEED_TYPE_CHANNEL; + newsFlags |= RsFeedTypeFlags::RS_FEED_TYPE_CHANNEL; if (ui.notify_Forums->isChecked()) - newsFlags |= RS_FEED_TYPE_FORUM; + newsFlags |= RsFeedTypeFlags::RS_FEED_TYPE_FORUM; if (ui.notify_Posted->isChecked()) - newsFlags |= RS_FEED_TYPE_POSTED; + newsFlags |= RsFeedTypeFlags::RS_FEED_TYPE_POSTED; #if 0 if (ui.notify_Blogs->isChecked()) newsFlags |= RS_FEED_TYPE_BLOG; #endif if (ui.notify_Messages->isChecked()) - newsFlags |= RS_FEED_TYPE_MSG; + newsFlags |= RsFeedTypeFlags::RS_FEED_TYPE_MSG; if (ui.notify_Chat->isChecked()) - newsFlags |= RS_FEED_TYPE_CHAT; + newsFlags |= RsFeedTypeFlags::RS_FEED_TYPE_CHAT; if (ui.notify_Security->isChecked()) - newsFlags |= RS_FEED_TYPE_SECURITY; + newsFlags |= RsFeedTypeFlags::RS_FEED_TYPE_SECURITY; if (ui.notify_SecurityIp->isChecked()) - newsFlags |= RS_FEED_TYPE_SECURITY_IP; + newsFlags |= RsFeedTypeFlags::RS_FEED_TYPE_SECURITY_IP; return newsFlags; } @@ -220,24 +221,24 @@ QString NotifyPage::helpText() const } -uint NotifyPage::getNotifyFlags() +RsNotifyPopupFlags NotifyPage::getNotifyFlags() { - uint notifyFlags = 0; + RsNotifyPopupFlags notifyFlags(RsNotifyPopupFlags::RS_POPUP_NONE); if (ui.popup_Connect->isChecked()) - notifyFlags |= RS_POPUP_CONNECT; + notifyFlags |= RsNotifyPopupFlags::RS_POPUP_CONNECT; if (ui.popup_NewMsg->isChecked()) - notifyFlags |= RS_POPUP_MSG; + notifyFlags |= RsNotifyPopupFlags::RS_POPUP_MSG; if (ui.popup_DownloadFinished->isChecked()) - notifyFlags |= RS_POPUP_DOWNLOAD; + notifyFlags |= RsNotifyPopupFlags::RS_POPUP_DOWNLOAD; if (ui.popup_PrivateChat->isChecked()) - notifyFlags |= RS_POPUP_CHAT; + notifyFlags |= RsNotifyPopupFlags::RS_POPUP_CHAT; if (ui.popup_GroupChat->isChecked()) - notifyFlags |= RS_POPUP_GROUPCHAT; + notifyFlags |= RsNotifyPopupFlags::RS_POPUP_GROUPCHAT; if (ui.popup_ChatLobby->isChecked()) - notifyFlags |= RS_POPUP_CHATLOBBY; + notifyFlags |= RsNotifyPopupFlags::RS_POPUP_CHATLOBBY; if (ui.popup_ConnectAttempt->isChecked()) - notifyFlags |= RS_POPUP_CONNECT_ATTEMPT; + notifyFlags |= RsNotifyPopupFlags::RS_POPUP_CONNECT_ATTEMPT; return notifyFlags; } @@ -273,9 +274,9 @@ void NotifyPage::updateUserNotifySettings() MainWindow::installNotifyIcons(); } -void NotifyPage::updateMessageFlags() { Settings->setMessageFlags( ui.message_ConnectAttempt->isChecked()? RS_MESSAGE_CONNECT_ATTEMPT : 0); } -void NotifyPage::updateNotifyFlags() { Settings->setNotifyFlags(getNotifyFlags()); } -void NotifyPage::updateNewsFeedFlags(){ Settings->setNewsFeedFlags(getNewsFlags()); } +void NotifyPage::updateMessageFlags() { Settings->setMessageFlags( ui.message_ConnectAttempt->isChecked()? RshareSettings::RS_MESSAGE_CONNECT_ATTEMPT : 0); } +void NotifyPage::updateNotifyFlags() { Settings->setNotifyFlags((int)getNotifyFlags()); } +void NotifyPage::updateNewsFeedFlags(){ Settings->setNewsFeedFlags((int)getNewsFlags()); } void NotifyPage::updateSystrayChatLobby() { Settings->setDisplayTrayChatLobby(ui.systray_ChatLobby->isChecked()); } void NotifyPage::updateSystrayGroupChat() { Settings->setDisplayTrayGroupChat(ui.systray_GroupChat->isChecked()); MainWindow::installGroupChatNotifier(); } @@ -292,35 +293,35 @@ void NotifyPage::updateToasterPosition() void NotifyPage::load() { /* Extract from rsNotify the flags */ - uint notifyflags = Settings->getNotifyFlags() ; - uint newsflags = Settings->getNewsFeedFlags() ; + RsNotifyPopupFlags notifyflags = (RsNotifyPopupFlags)Settings->getNotifyFlags() ; + RsFeedTypeFlags newsflags = (RsFeedTypeFlags)Settings->getNewsFeedFlags() ; uint messageflags = Settings->getMessageFlags() ; - whileBlocking(ui.popup_Connect)->setChecked(notifyflags & RS_POPUP_CONNECT); - whileBlocking(ui.popup_NewMsg)->setChecked(notifyflags & RS_POPUP_MSG); - whileBlocking(ui.popup_DownloadFinished)->setChecked(notifyflags & RS_POPUP_DOWNLOAD); - whileBlocking(ui.popup_PrivateChat)->setChecked(notifyflags & RS_POPUP_CHAT); + whileBlocking(ui.popup_Connect)->setChecked(!!(notifyflags & RsNotifyPopupFlags::RS_POPUP_CONNECT)); + whileBlocking(ui.popup_NewMsg)->setChecked(!!(notifyflags & RsNotifyPopupFlags::RS_POPUP_MSG)); + whileBlocking(ui.popup_DownloadFinished)->setChecked(!!(notifyflags & RsNotifyPopupFlags::RS_POPUP_DOWNLOAD)); + whileBlocking(ui.popup_PrivateChat)->setChecked(!!(notifyflags & RsNotifyPopupFlags::RS_POPUP_CHAT)); #ifdef RS_DIRECT_CHAT - whileBlocking(ui.popup_GroupChat)->setChecked(notifyflags & RS_POPUP_GROUPCHAT); + whileBlocking(ui.popup_GroupChat)->setChecked(!!(notifyflags & RsNotifyPopupFlags::RS_POPUP_GROUPCHAT)); #endif // def RS_DIRECT_CHAT - whileBlocking(ui.popup_ChatLobby)->setChecked(notifyflags & RS_POPUP_CHATLOBBY); - whileBlocking(ui.popup_ConnectAttempt)->setChecked(notifyflags & RS_POPUP_CONNECT_ATTEMPT); + whileBlocking(ui.popup_ChatLobby)->setChecked(!!(notifyflags & RsNotifyPopupFlags::RS_POPUP_CHATLOBBY)); + whileBlocking(ui.popup_ConnectAttempt)->setChecked(!!(notifyflags & RsNotifyPopupFlags::RS_POPUP_CONNECT_ATTEMPT)); - whileBlocking(ui.notify_Peers)->setChecked(newsflags & RS_FEED_TYPE_PEER); - whileBlocking(ui.notify_Circles)->setChecked(newsflags & RS_FEED_TYPE_CIRCLE); - whileBlocking(ui.notify_Channels)->setChecked(newsflags & RS_FEED_TYPE_CHANNEL); - whileBlocking(ui.notify_Forums)->setChecked(newsflags & RS_FEED_TYPE_FORUM); - whileBlocking(ui.notify_Posted)->setChecked(newsflags & RS_FEED_TYPE_POSTED); + whileBlocking(ui.notify_Peers )->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_PEER)); + whileBlocking(ui.notify_Circles )->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_CIRCLE)); + whileBlocking(ui.notify_Channels )->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_CHANNEL)); + whileBlocking(ui.notify_Forums )->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_FORUM)); + whileBlocking(ui.notify_Posted )->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_POSTED)); #if 0 whileBlocking(ui.notify_Blogs)->setChecked(newsflags & RS_FEED_TYPE_BLOG); #endif - whileBlocking(ui.notify_Chat)->setChecked(newsflags & RS_FEED_TYPE_CHAT); - whileBlocking(ui.notify_Messages)->setChecked(newsflags & RS_FEED_TYPE_MSG); - whileBlocking(ui.notify_Chat)->setChecked(newsflags & RS_FEED_TYPE_CHAT); - whileBlocking(ui.notify_Security)->setChecked(newsflags & RS_FEED_TYPE_SECURITY); - whileBlocking(ui.notify_SecurityIp)->setChecked(newsflags & RS_FEED_TYPE_SECURITY_IP); + whileBlocking(ui.notify_Chat )->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_CHAT)); + whileBlocking(ui.notify_Messages )->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_MSG)); + whileBlocking(ui.notify_Chat )->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_CHAT)); + whileBlocking(ui.notify_Security )->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_SECURITY)); + whileBlocking(ui.notify_SecurityIp)->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_SECURITY_IP)); - whileBlocking(ui.message_ConnectAttempt)->setChecked(messageflags & RS_MESSAGE_CONNECT_ATTEMPT); + whileBlocking(ui.message_ConnectAttempt)->setChecked(messageflags & RshareSettings::RS_MESSAGE_CONNECT_ATTEMPT); whileBlocking(ui.systray_GroupChat)->setChecked(Settings->getDisplayTrayGroupChat()); whileBlocking(ui.systray_ChatLobby)->setChecked(Settings->getDisplayTrayChatLobby()); diff --git a/retroshare-gui/src/gui/settings/NotifyPage.h b/retroshare-gui/src/gui/settings/NotifyPage.h index e1090c6c5..3e240c1da 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.h +++ b/retroshare-gui/src/gui/settings/NotifyPage.h @@ -23,8 +23,10 @@ #include #include "ui_NotifyPage.h" +#include "rsharesettings.h" #include "gui/chat/ChatLobbyUserNotify.h" +#include "gui/feeds/FeedItem.h" #include "gui/common/FilesDefs.h" class UserNotify; @@ -102,8 +104,8 @@ private slots: void updateToasterPosition(); private: - uint getNewsFlags(); - uint getNotifyFlags(); + RsFeedTypeFlags getNewsFlags(); + RsNotifyPopupFlags getNotifyFlags(); QList mFeedNotifySettingList; QList mToasterNotifySettingList; diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index d878d6c99..17d8db2b5 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -27,8 +27,11 @@ #include #include +#include "rsharesettings.h" #include "rsharesettings.h" #include "gui/MainWindow.h" +#include "gui/chat/ChatWidget.h" +#include "gui/feeds/FeedItem.h" #ifdef RS_JSONAPI #include @@ -133,15 +136,15 @@ void RshareSettings::initSettings() /* defaults here are not ideal.... but dusent matter */ - uint defChat = RS_CHAT_OPEN; + uint defChat = (uint32_t)RsChatFlags::RS_CHAT_OPEN; // This is not default... RS_CHAT_FOCUS. - uint defNotify = (RS_POPUP_CONNECT | RS_POPUP_MSG); - uint defNewsFeed = (RS_FEED_TYPE_MSG | RS_FEED_TYPE_FILES | RS_FEED_TYPE_SECURITY | RS_FEED_TYPE_SECURITY_IP | RS_FEED_TYPE_CIRCLE | RS_FEED_TYPE_CHANNEL |RS_FEED_TYPE_FORUM | RS_FEED_TYPE_POSTED); + RsNotifyPopupFlags defNotify = (RsNotifyPopupFlags::RS_POPUP_CONNECT | RsNotifyPopupFlags::RS_POPUP_MSG); + RsFeedTypeFlags defNewsFeed = (RsFeedTypeFlags::RS_FEED_TYPE_MSG | RsFeedTypeFlags::RS_FEED_TYPE_FILES | RsFeedTypeFlags::RS_FEED_TYPE_SECURITY | RsFeedTypeFlags::RS_FEED_TYPE_SECURITY_IP | RsFeedTypeFlags::RS_FEED_TYPE_CIRCLE | RsFeedTypeFlags::RS_FEED_TYPE_CHANNEL |RsFeedTypeFlags::RS_FEED_TYPE_FORUM | RsFeedTypeFlags::RS_FEED_TYPE_POSTED); - setDefault(SETTING_NEWSFEED_FLAGS, defNewsFeed); + setDefault(SETTING_NEWSFEED_FLAGS, (int)defNewsFeed); setDefault(SETTING_CHAT_FLAGS, defChat); - setDefault(SETTING_NOTIFY_FLAGS, defNotify); + setDefault(SETTING_NOTIFY_FLAGS, (int)defNotify); setDefault("DisplayTrayGroupChat", true); setDefault("AddFeedsAtEnd", false); @@ -1023,30 +1026,31 @@ void RshareSettings::setMsgLoadEmbeddedImages(bool value) setValueToGroup("Message", "LoadEmbeddedImages", value); } -RshareSettings::enumMsgOpen RshareSettings::getMsgOpen() +RsSettingsMsgOptions RshareSettings::getMsgOpen() { - enumMsgOpen value = (enumMsgOpen) valueFromGroup("Message", "msgOpen", MSG_OPEN_TAB).toInt(); + RsSettingsMsgOptions value = (RsSettingsMsgOptions) valueFromGroup("Message", "msgOpen", (int)RsSettingsMsgOptions::MSG_OPEN_TAB).toInt(); switch (value) { - case MSG_OPEN_TAB: - case MSG_OPEN_WINDOW: + default: + case RsSettingsMsgOptions::MSG_OPEN_TAB: + case RsSettingsMsgOptions::MSG_OPEN_WINDOW: return value; } - return MSG_OPEN_TAB; + return RsSettingsMsgOptions::MSG_OPEN_TAB; } -void RshareSettings::setMsgOpen(enumMsgOpen value) +void RshareSettings::setMsgOpen(RsSettingsMsgOptions value) { switch (value) { - case MSG_OPEN_TAB: - case MSG_OPEN_WINDOW: + case RsSettingsMsgOptions::MSG_OPEN_TAB: + case RsSettingsMsgOptions::MSG_OPEN_WINDOW: break; default: - value = MSG_OPEN_TAB; + value = RsSettingsMsgOptions::MSG_OPEN_TAB; } - setValueToGroup("Message", "msgOpen", value); + setValueToGroup("Message", "msgOpen", (int)value); } /* Forum */ diff --git a/retroshare-gui/src/gui/settings/rsharesettings.h b/retroshare-gui/src/gui/settings/rsharesettings.h index 317dedb56..d4b39be9a 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.h +++ b/retroshare-gui/src/gui/settings/rsharesettings.h @@ -28,6 +28,7 @@ #include #include +#include #include #include "rsettings.h" @@ -56,6 +57,38 @@ public: bool mOpenAllInNewTab; bool mHideTabBarWithOneTab; }; +enum class RsNotifyPopupFlags: uint32_t { + RS_POPUP_NONE = 0x0000, + RS_POPUP_MSG = 0x0001, + RS_POPUP_CHAT = 0x0002, + RS_POPUP_CONNECT = 0x0008, +// RS_SYSTRAY_GROUP_MSG = 0x0010, + RS_POPUP_DOWNLOAD = 0x0020, + RS_POPUP_GROUPCHAT = 0x0040, + RS_POPUP_CHATLOBBY = 0x0080, + RS_POPUP_CONNECT_ATTEMPT = 0x0100, + RS_POPUP_ENCRYPTED_MSG = 0x0200, +}; +RS_REGISTER_ENUM_FLAGS_TYPE(RsNotifyPopupFlags); + +//enum class RsNotifySystrayFlags: uint32_t { +// RS_SYSTRAY_GROUP_MSG = 0x0010, +//} +enum class RsNotifySysFlags: uint32_t { + RS_SYS_ERROR = 0x0001, + RS_SYS_WARNING = 0x0002, + RS_SYS_INFO = 0x0004, +}; +RS_REGISTER_ENUM_FLAGS_TYPE(RsNotifySysFlags); + +enum class RsSettingsMsgOptions: uint8_t +{ + MSG_OPEN_NONE = 0x00, + MSG_OPEN_TAB = 0x01, + MSG_OPEN_WINDOW = 0x02, +}; + +RS_REGISTER_ENUM_FLAGS_TYPE(RsSettingsMsgOptions); /** Handles saving and restoring RShares's settings * @@ -86,11 +119,10 @@ public: TOASTERPOS_BOTTOMRIGHT }; - enum enumMsgOpen - { - MSG_OPEN_TAB, - MSG_OPEN_WINDOW - }; + enum enumMsgOptions :uint32_t + { + RS_MESSAGE_CONNECT_ATTEMPT = 0x0001, + }; public: /* create settings object */ @@ -191,8 +223,8 @@ public: uint getNewsFeedFlags(); void setNewsFeedFlags(uint flags); - uint getChatFlags(); - void setChatFlags(uint flags); + uint getChatFlags(); + void setChatFlags(uint flags); uint getChatLobbyFlags(); void setChatLobbyFlags(uint flags); @@ -305,8 +337,8 @@ public: bool getMsgLoadEmbeddedImages(); void setMsgLoadEmbeddedImages(bool value); - enumMsgOpen getMsgOpen(); - void setMsgOpen(enumMsgOpen value); + RsSettingsMsgOptions getMsgOpen(); + void setMsgOpen(RsSettingsMsgOptions value); /* Forum */ bool getForumMsgSetToReadOnActivate(); diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 031c917b3..664ee280c 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -731,7 +731,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); // QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; // QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool)) ,Qt::QueuedConnection ) ; // QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; - QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); +// QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); // QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ; // QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->friendsDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool))); @@ -752,11 +752,10 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); } /* Startup a Timer to keep the gui's updated */ - QTimer *timer = new QTimer(w); - timer -> connect(timer, SIGNAL(timeout()), notify, SLOT(UpdateGUI())); - timer->start(1000); - - notify->enable() ; // enable notification system after GUI creation, to avoid data races in Qt. + //QTimer *timer = new QTimer(w); + //timer -> connect(timer, SIGNAL(timeout()), notify, SLOT(UpdateGUI())); + //timer->start(1000); + //notify->enable() ; // enable notification system after GUI creation, to avoid data races in Qt. // Read webui params in settings. We cannot save them to some webui.cfg because cfg needs the node id and // jsonapi is started before node ID selection in retroshare-service. From 17cbf5da30f998d8b0697aba2849ae719fe910df Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 10 Oct 2025 16:39:11 +0200 Subject: [PATCH 29/38] removed rsnotify --- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 1 - retroshare-gui/src/gui/GenCertDialog.cpp | 1 - retroshare-gui/src/gui/MainWindow.cpp | 1 - retroshare-gui/src/gui/MessengerWindow.cpp | 1 - retroshare-gui/src/gui/NewsFeed.cpp | 1 - retroshare-gui/src/gui/RetroShareLink.cpp | 1 - retroshare-gui/src/gui/StartDialog.cpp | 1 - retroshare-gui/src/gui/chat/ChatDialog.cpp | 1 - retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp | 1 - retroshare-gui/src/gui/chat/ChatUserNotify.cpp | 1 - retroshare-gui/src/gui/chat/PopupChatDialog.cpp | 1 - retroshare-gui/src/gui/chat/PopupChatWindow.cpp | 1 - retroshare-gui/src/gui/feeds/SecurityIpItem.cpp | 1 - retroshare-gui/src/gui/notifyqt.cpp | 1 - retroshare-gui/src/gui/notifyqt.h | 1 - retroshare-gui/src/gui/settings/ChatPage.cpp | 1 - retroshare-gui/src/gui/settings/NotifyPage.cpp | 1 - retroshare-gui/src/gui/settings/rsharesettings.cpp | 1 - 18 files changed, 18 deletions(-) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index 3e1b600fa..c669df327 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -40,7 +40,6 @@ #include "retroshare/rsmsgs.h" #include "retroshare/rspeers.h" -#include "retroshare/rsnotify.h" #include "retroshare/rsidentity.h" #include diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index 93f56d00f..f829602b3 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -39,7 +39,6 @@ #include "retroshare/rstor.h" #include "retroshare/rsidentity.h" #include "retroshare/rsinit.h" -#include "retroshare/rsnotify.h" #include "rsserver/rsaccounts.h" #include "util/rsrandom.h" diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 9984436fa..12b2342a5 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -101,7 +101,6 @@ #include "retroshare/rsiface.h" #include "retroshare/rspeers.h" #include "retroshare/rsfiles.h" -#include "retroshare/rsnotify.h" #include "retroshare/rsinit.h" #include "gui/gxschannels/GxsChannelDialog.h" diff --git a/retroshare-gui/src/gui/MessengerWindow.cpp b/retroshare-gui/src/gui/MessengerWindow.cpp index 28db4a7ee..7e18cbb0b 100644 --- a/retroshare-gui/src/gui/MessengerWindow.cpp +++ b/retroshare-gui/src/gui/MessengerWindow.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include "rshare.h" #include "MessengerWindow.h" diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index 60791d975..8a9b506ce 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp index 212ca95b5..a22f9ced8 100644 --- a/retroshare-gui/src/gui/RetroShareLink.cpp +++ b/retroshare-gui/src/gui/RetroShareLink.cpp @@ -41,7 +41,6 @@ #include #include #include -#include #include #include diff --git a/retroshare-gui/src/gui/StartDialog.cpp b/retroshare-gui/src/gui/StartDialog.cpp index 4f71b102f..f52179c39 100644 --- a/retroshare-gui/src/gui/StartDialog.cpp +++ b/retroshare-gui/src/gui/StartDialog.cpp @@ -25,7 +25,6 @@ #include "settings/rsharesettings.h" #include "retroshare/rsinit.h" -#include "retroshare/rsnotify.h" #include #include diff --git a/retroshare-gui/src/gui/chat/ChatDialog.cpp b/retroshare-gui/src/gui/chat/ChatDialog.cpp index 90389c36f..22e45cdc9 100644 --- a/retroshare-gui/src/gui/chat/ChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatDialog.cpp @@ -35,7 +35,6 @@ #include "gui/SoundManager.h" #include -#include #include static std::map chatDialogsList; diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index cec0095e0..71f884ed5 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -45,7 +45,6 @@ #include "util/HandleRichText.h" #include "util/RsQtVersion.h" -#include "retroshare/rsnotify.h" #include "util/rstime.h" #include "util/DateTime.h" diff --git a/retroshare-gui/src/gui/chat/ChatUserNotify.cpp b/retroshare-gui/src/gui/chat/ChatUserNotify.cpp index 0ee262dff..2d438f022 100644 --- a/retroshare-gui/src/gui/chat/ChatUserNotify.cpp +++ b/retroshare-gui/src/gui/chat/ChatUserNotify.cpp @@ -29,7 +29,6 @@ #include "util/qtthreadsutils.h" #include -#include #include static std::map waitingChats; diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 6d5c9dd0b..793835d70 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -32,7 +32,6 @@ #include #include -#include #include diff --git a/retroshare-gui/src/gui/chat/PopupChatWindow.cpp b/retroshare-gui/src/gui/chat/PopupChatWindow.cpp index 2c02ba8e0..eb2f6d7a0 100644 --- a/retroshare-gui/src/gui/chat/PopupChatWindow.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatWindow.cpp @@ -39,7 +39,6 @@ #include #include -#include #define IMAGE_TYPING ":/images/white-bubble-64.png" diff --git a/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp b/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp index 2039e0804..9f306685d 100644 --- a/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp @@ -33,7 +33,6 @@ #include #include -#include /***** * #define DEBUG_ITEM 1 diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index e4ee26b85..fe7e387e4 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -22,7 +22,6 @@ #include #include "notifyqt.h" -#include #include #include #include diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index aae3b1728..8f7a75529 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -23,7 +23,6 @@ #include #include -#include #include #include #include diff --git a/retroshare-gui/src/gui/settings/ChatPage.cpp b/retroshare-gui/src/gui/settings/ChatPage.cpp index 769ec28c2..57a2a86f3 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.cpp +++ b/retroshare-gui/src/gui/settings/ChatPage.cpp @@ -31,7 +31,6 @@ #include "retroshare/rsconfig.h" #include "retroshare/rshistory.h" #include "retroshare/rsmsgs.h" -#include "retroshare/rsnotify.h" #include "retroshare/rspeers.h" #include diff --git a/retroshare-gui/src/gui/settings/NotifyPage.cpp b/retroshare-gui/src/gui/settings/NotifyPage.cpp index 046895414..0dc7e6d9e 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.cpp +++ b/retroshare-gui/src/gui/settings/NotifyPage.cpp @@ -21,7 +21,6 @@ #include #include "NotifyPage.h" -#include #include #include "rsharesettings.h" diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index 17d8db2b5..887d4276f 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -37,7 +37,6 @@ #include #endif -#include #include #ifdef Q_OS_WIN From 7621142c3410c508eba72df619c87dae66edd3cd Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 10 Oct 2025 16:45:17 +0200 Subject: [PATCH 30/38] cleaned up dead code in notifyQt --- retroshare-gui/src/gui/notifyqt.cpp | 644 +--------------------------- retroshare-gui/src/gui/notifyqt.h | 56 --- 2 files changed, 2 insertions(+), 698 deletions(-) diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index fe7e387e4..dd3d1a028 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -116,127 +116,8 @@ NotifyQt::NotifyQt() : cDialog(NULL) else RsQThreadUtils::postToObject([=](){ async_handleIncomingEvent(event); }, this ); }, mEventHandlerId); // No event type means we expect to catch all possible events - -#ifdef TO_REMOVE - // register to allow sending over Qt::QueuedConnection - qRegisterMetaType("ChatId"); - qRegisterMetaType("ChatMessage"); - qRegisterMetaType("RsGxsChanges"); - qRegisterMetaType("RsGxsId"); -#endif } -#ifdef TO_REMOVE -void NotifyQt::notifyErrorMsg(int list, int type, std::string msg) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - emit errorOccurred(list,type,QString::fromUtf8(msg.c_str())) ; -} - -void NotifyQt::notifyChatMessage(const ChatMessage &msg) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "notifyQt: Received chat message " << std::endl ; -#endif - emit chatMessageReceived(msg); -} - -void NotifyQt::notifyOwnAvatarChanged() -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "Notifyqt:: notified that own avatar changed" << std::endl ; -#endif - emit ownAvatarChanged() ; -} - -class SignatureEventData -{ - public: - SignatureEventData(const void *_data,int32_t _len,unsigned int _signlen, std::string _reason) - { - // We need a new memory chnk because there's no guarranty _sign nor _signlen are not in the stack - - sign = (unsigned char *)rs_malloc(_signlen) ; - - if(!sign) - { - signlen = NULL ; - signature_result = SELF_SIGNATURE_RESULT_FAILED ; - return ; - } - - signlen = new unsigned int ; - *signlen = _signlen ; - signature_result = SELF_SIGNATURE_RESULT_PENDING ; - data = rs_malloc(_len) ; - - if(!data) - { - len = 0 ; - return ; - } - len = _len ; - memcpy(data,_data,len) ; - reason = _reason ; - } - - ~SignatureEventData() - { - free(sign) ; - delete signlen ; - free(data) ; - } - - void performSignature() - { - if(rsPeers->gpgSignData(data,len,sign,signlen,reason)) - signature_result = SELF_SIGNATURE_RESULT_SUCCESS ; - else - signature_result = SELF_SIGNATURE_RESULT_FAILED ; - } - - void *data ; - uint32_t len ; - unsigned char *sign ; - unsigned int *signlen ; - int signature_result ; // 0=pending, 1=done, 2=failed/cancelled. - std::string reason ; -}; - -void NotifyQt::handleSignatureEvent() -{ - std::cerr << "NotifyQt:: performing a deferred signature in the main GUI thread." << std::endl; - - static bool working = false ; - - if(!working) - { - working = true ; - - for(std::map::const_iterator it(_deferred_signature_queue.begin());it!=_deferred_signature_queue.end();++it) - it->second->performSignature() ; - - working = false ; - } -} -#endif - bool NotifyQt::GUI_askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad) { RsAutoUpdatePage::lockAllEvents() ; @@ -326,363 +207,6 @@ bool NotifyQt::GUI_askForPluginConfirmation(const std::string& plugin_file_name, } } -#ifdef TO_REMOVE -void NotifyQt::notifyDiscInfoChanged() -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "Notifyqt:: notified that discoveryInfo changed" << std::endl ; -#endif - - emit discInfoChanged() ; -} - -void NotifyQt::notifyDiskFull(uint32_t loc,uint32_t size_in_mb) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - - std::cerr << "Notifyqt:: notified that disk is full" << std::endl ; - - emit diskFull(loc,size_in_mb) ; -} - -/* peer has changed the state */ -void NotifyQt::notifyPeerStatusChanged(const std::string& peer_id, uint32_t state) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "Notifyqt:: notified that peer " << peer_id << " has changed the state to " << state << std::endl; -#endif - - emit peerStatusChanged(QString::fromStdString(peer_id), state); -} - -/* one or more peers has changed the states */ -void NotifyQt::notifyPeerStatusChangedSummary() -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "Notifyqt:: notified that one peer has changed the state" << std::endl; -#endif - - emit peerStatusChangedSummary(); -} - -void NotifyQt::notifyOwnStatusMessageChanged() -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "Notifyqt:: notified that own avatar changed" << std::endl ; -#endif - emit ownStatusMessageChanged() ; -} - -void NotifyQt::notifyPeerHasNewAvatar(std::string peer_id) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } -#ifdef NOTIFY_DEBUG - std::cerr << "notifyQt: notification of new avatar." << std::endl ; -#endif - emit peerHasNewAvatar(QString::fromStdString(peer_id)) ; -} - -void NotifyQt::notifyCustomState(const std::string& peer_id, const std::string& status_string) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "notifyQt: Received custom status string notification" << std::endl ; -#endif - emit peerHasNewCustomStateString(QString::fromStdString(peer_id), QString::fromUtf8(status_string.c_str())) ; -} - -void NotifyQt::notifyChatLobbyTimeShift(int shift) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "notifyQt: Received chat lobby time shift message: shift = " << shift << std::endl; -#endif - emit chatLobbyTimeShift(shift) ; -} - -void NotifyQt::handleChatLobbyTimeShift(int /*shift*/) -{ - return ; // we say nothing. The help dialog of lobbies explains this already. - static bool already = false ; - - if(!already) - { - already = true ; - - QString string = tr("For the chat lobbies to work properly, the time of your computer needs to be correct. Please check that this is the case (A possible time shift of several minutes was detected with your friends).") ; - - QMessageBox::warning(NULL,tr("Please check your system clock."),string) ; - } -} - -void NotifyQt::notifyChatLobbyEvent(uint64_t lobby_id,uint32_t event_type,const RsGxsId& nickname,const std::string& str) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "notifyQt: Received chat lobby event message: lobby #" << std::hex << lobby_id << std::dec << ", event=" << event_type << ", str=\"" << str << "\"" << std::endl ; -#endif - emit chatLobbyEvent(lobby_id,event_type,nickname,QString::fromUtf8(str.c_str())) ; -} - -void NotifyQt::notifyChatStatus(const ChatId& chat_id,const std::string& status_string) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "notifyQt: Received chat status string: " << status_string << std::endl ; -#endif - emit chatStatusChanged(chat_id, QString::fromUtf8(status_string.c_str())); -} - -void NotifyQt::notifyChatCleared(const ChatId& chat_id) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "notifyQt: Received chat cleared." << std::endl ; -#endif - emit chatCleared(chat_id); -} - -//void NotifyQt::notifyTurtleSearchResult(uint32_t /*search_id*/,const std::list& /*found_groups*/) -//{ -// std::cerr << "(EE) missing code to handle GXS turtle search result." << std::endl; -//} - -// Mai 2023: distant turtle search now uses RsEvents. -void NotifyQt::notifyTurtleSearchResult(const RsPeerId& pid,uint32_t search_id,const std::list& files) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "in notify search result..." << std::endl ; -#endif - - for(std::list::const_iterator it(files.begin());it!=files.end();++it) - { - FileDetail det ; - det.rank = 0 ; - det.age = 0 ; - det.name = (*it).name ; - det.hash = (*it).hash ; - det.size = (*it).size ; - det.id = pid ; - - emit gotTurtleSearchResult(search_id,det) ; - } -} - -void NotifyQt::notifyHistoryChanged(uint32_t msgId, int type) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - - emit historyChanged(msgId, type); -} - -void NotifyQt::notifyListChange(int list, int type) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } -#ifdef NOTIFY_DEBUG - std::cerr << "NotifyQt::notifyListChange()" << std::endl; -#endif - switch(list) - { - case NOTIFY_LIST_NEIGHBOURS: -#ifdef NOTIFY_DEBUG - std::cerr << "received neighbours changed" << std::endl ; -#endif - emit neighboursChanged(); - break; - case NOTIFY_LIST_FRIENDS: -#ifdef NOTIFY_DEBUG - std::cerr << "received friends changed" << std::endl ; -#endif - emit friendsChanged() ; - break; - case NOTIFY_LIST_DIRLIST_LOCAL: -#ifdef NOTIFY_DEBUG - std::cerr << "received files changed" << std::endl ; -#endif - emit filesPostModChanged(true) ; /* Local */ - break; - case NOTIFY_LIST_DIRLIST_FRIENDS: -#ifdef NOTIFY_DEBUG - std::cerr << "received files changed" << std::endl ; -#endif - emit filesPostModChanged(false) ; /* Local */ - break; - case NOTIFY_LIST_CHAT_LOBBY_INVITATION: -#ifdef NOTIFY_DEBUG - std::cerr << "received files changed" << std::endl ; -#endif - emit chatLobbyInviteReceived() ; /* Local */ - break; - case NOTIFY_LIST_CONFIG: -#ifdef NOTIFY_DEBUG - std::cerr << "received config changed" << std::endl ; -#endif - emit configChanged() ; - break ; - - case NOTIFY_LIST_SEARCHLIST: - break; - case NOTIFY_LIST_CHANNELLIST: - break; - case NOTIFY_LIST_TRANSFERLIST: -#ifdef NOTIFY_DEBUG - std::cerr << "received transfer changed" << std::endl ; -#endif - emit transfersChanged() ; - break; - - case NOTIFY_LIST_FORUMLIST_LOCKED: -#ifdef NOTIFY_DEBUG - std::cerr << "received forum msg changed" << std::endl ; -#endif - emit forumsChanged(); // use connect with Qt::QueuedConnection - break; - case NOTIFY_LIST_CHANNELLIST_LOCKED: -#ifdef NOTIFY_DEBUG - std::cerr << "received channel msg changed" << std::endl ; -#endif - emit channelsChanged(type); // use connect with Qt::QueuedConnection - break; - case NOTIFY_LIST_PUBLIC_CHAT: -#ifdef NOTIFY_DEBUG - std::cerr << "received public chat changed" << std::endl ; -#endif - emit publicChatChanged(type); - break; - case NOTIFY_LIST_PRIVATE_INCOMING_CHAT: - case NOTIFY_LIST_PRIVATE_OUTGOING_CHAT: -#ifdef NOTIFY_DEBUG - std::cerr << "received private chat changed" << std::endl ; -#endif - emit privateChatChanged(list, type); - break; - - case NOTIFY_LIST_CHAT_LOBBY_LIST: -#ifdef NOTIFY_DEBUG - std::cerr << "received notify chat lobby list" << std::endl; -#endif - emit lobbyListChanged(); - break; - case NOTIFY_LIST_GROUPLIST: -#ifdef NOTIFY_DEBUG - std::cerr << "received groups changed" << std::endl ; -#endif - emit groupsChanged(type); - break; - default: - break; - } - return; -} - -void NotifyQt::notifyListPreChange(int list, int /*type*/) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "NotifyQt::notifyListPreChange()" << std::endl; -#endif - switch(list) - { - case NOTIFY_LIST_NEIGHBOURS: - break; - case NOTIFY_LIST_FRIENDS: - emit friendsChanged() ; - break; - case NOTIFY_LIST_DIRLIST_FRIENDS: - emit filesPreModChanged(false) ; /* remote */ - break ; - case NOTIFY_LIST_DIRLIST_LOCAL: - emit filesPreModChanged(true) ; /* local */ - break; - case NOTIFY_LIST_SEARCHLIST: - break; - case NOTIFY_LIST_CHANNELLIST: - break; - case NOTIFY_LIST_TRANSFERLIST: - break; - default: - break; - } - return; -} -#endif - void NotifyQt::enable() { QMutexLocker m(&_mutex) ; @@ -702,16 +226,6 @@ void NotifyQt::sync_handleIncomingEvent(std::shared_ptr event) void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) { - static bool already_updated = false ; // these only update once at start because they may already have been set before - // the gui is running, then they get updated by callbacks. -#warning Is this needed anymore?? - if(!already_updated) - { - emit configChanged(); - - already_updated = true ; - } - /* Finally Check for PopupMessages / System Error Messages */ RsNotifyPopupFlags popupflags = (RsNotifyPopupFlags)Settings->getNotifyFlags(); @@ -791,16 +305,6 @@ void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) return; } - // Probably an old thing. To be removed. - // case RS_POPUP_ENCRYPTED_MSG: - // SoundManager::play(SOUND_MESSAGE_ARRIVED); - // - // if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster) - // { - // toaster = new ToasterItem(new MessageToaster("", tr("Encrypted message"), QString("[%1]").arg(tr("Encrypted message")))); - // } - // break; - auto ev5 = dynamic_cast(event.get()); if(ev5) @@ -895,19 +399,6 @@ void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) } } -// if (rsNotify->NotifyLogMessage(sysid, type, title, msg)) -// { -// /* make a log message */ -// std::string logMesString = title + " " + msg; -// switch(type) -// { -// case RS_SYS_ERROR: -// case RS_SYS_WARNING: -// case RS_SYS_INFO: -// emit logInfoChanged(QString::fromUtf8(logMesString.c_str())); -// } -// } -// } /* Now start the waiting toasters */ startWaitingToasters(); } @@ -972,7 +463,7 @@ void NotifyQt::testToasters(RsNotifyPopupFlags notifyFlags, /*RshareSettings::en toaster->margin = margin; /* add toaster to waiting list */ - //QMutexLocker lock(&waitingToasterMutex); + waitingToasterList.push_back(toaster); } } @@ -1015,7 +506,7 @@ void NotifyQt::testToaster(QString tag, ToasterNotify *toasterNotify, /*RshareSe toaster->margin = margin; /* add toaster to waiting list */ - //QMutexLocker lock(&waitingToasterMutex); + waitingToasterList.push_back(toaster); } } @@ -1049,8 +540,6 @@ void NotifyQt::notifySettingsChanged() void NotifyQt::startWaitingToasters() { { - //QMutexLocker lock(&waitingToasterMutex); - if (waitingToasterList.empty()) { /* No toasters are waiting */ return; @@ -1058,8 +547,6 @@ void NotifyQt::startWaitingToasters() } { - //QMutexLocker lock(&runningToasterMutex); - if (runningToasterList.size() >= 3) { /* Don't show more than 3 toasters at once */ return; @@ -1069,8 +556,6 @@ void NotifyQt::startWaitingToasters() ToasterItem *toaster = NULL; { - //QMutexLocker lock(&waitingToasterMutex); - if (waitingToasterList.size()) { /* Take one toaster of the waiting list */ toaster = waitingToasterList.front(); @@ -1079,7 +564,6 @@ void NotifyQt::startWaitingToasters() } if (toaster) { - //QMutexLocker lock(&runningToasterMutex); /* Calculate positions */ QSize size = toaster->widget->size(); @@ -1208,130 +692,6 @@ void NotifyQt::runningTick() } } -#ifdef TO_REMOVE -void NotifyQt::addToaster(uint notifyFlags, const std::string& id, const std::string& title, const std::string& msg) -{ - uint pos = 0; - - while (notifyFlags) { - uint type = notifyFlags & (1 << pos); - notifyFlags &= ~(1 << pos); - ++pos; - - ToasterItem *toaster = NULL; - - uint popupflags = Settings->getNotifyFlags(); - - switch(type) - { - case RS_POPUP_ENCRYPTED_MSG: - SoundManager::play(SOUND_MESSAGE_ARRIVED); - - if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster) - { - toaster = new ToasterItem(new MessageToaster(std::string(), tr("Unknown title"), QString("[%1]").arg(tr("Encrypted message")))); - } - break; - case RS_POPUP_MSG: - SoundManager::play(SOUND_MESSAGE_ARRIVED); - - if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster) - { - toaster = new ToasterItem(new MessageToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str()))); - } - break; - case RS_POPUP_CONNECT: - SoundManager::play(SOUND_USER_ONLINE); - - if ((popupflags & RS_POPUP_CONNECT) && !_disableAllToaster) - { - toaster = new ToasterItem(new OnlineToaster(RsPeerId(id))); - } - break; - case RS_POPUP_DOWNLOAD: - SoundManager::play(SOUND_DOWNLOAD_COMPLETE); - - if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster) - { - toaster = new ToasterItem(new DownloadToaster(RsFileHash(id))); - } - break; - case RS_POPUP_CHAT: - if ((popupflags & RS_POPUP_CHAT) && !_disableAllToaster) - { - // TODO: fix for distant chat, look up if dstant chat uses RS_POPUP_CHAT - ChatDialog *chatDialog = ChatDialog::getChat(ChatId(RsPeerId(id))); - ChatWidget *chatWidget; - if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) { - // do not show when active - break; - } - toaster = new ToasterItem(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); - } - break; - case RS_POPUP_GROUPCHAT: -#ifdef RS_DIRECT_CHAT - if ((popupflags & RS_POPUP_GROUPCHAT) && !_disableAllToaster) - { - MainWindow *mainWindow = MainWindow::getInstance(); - if (mainWindow && mainWindow->isActiveWindow() && !mainWindow->isMinimized()) { - if (MainWindow::getActivatePage() == MainWindow::Friends) { - if (FriendsDialog::isGroupChatActive()) { - // do not show when active - break; - } - } - } - toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); - } -#endif // RS_DIRECT_CHAT - break; - case RS_POPUP_CHATLOBBY: - if ((popupflags & RS_POPUP_CHATLOBBY) && !_disableAllToaster) - { - ChatId chat_id(id); - - ChatDialog *chatDialog = ChatDialog::getChat(chat_id); - ChatWidget *chatWidget; - if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) { - // do not show when active - break; - } - - ChatLobbyDialog *chatLobbyDialog = dynamic_cast(chatDialog); - - RsGxsId sender(title); - if (!chatLobbyDialog || chatLobbyDialog->isParticipantMuted(sender)) - break; // participant is muted - - toaster = new ToasterItem(new ChatLobbyToaster(chat_id.toLobbyId(), sender, QString::fromUtf8(msg.c_str()))); - } - break; - case RS_POPUP_CONNECT_ATTEMPT: - if ((popupflags & RS_POPUP_CONNECT_ATTEMPT) && !_disableAllToaster) - { - // id = gpgid - // title = ssl name - // msg = peer id - toaster = new ToasterItem(new FriendRequestToaster(RsPgpId(id), QString::fromUtf8(title.c_str()), RsPeerId(msg))); - } - break; - } - - if (toaster) { - /* init attributes */ - toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint); - - /* add toaster to waiting list */ - //QMutexLocker lock(&waitingToasterMutex); - waitingToasterList.push_back(toaster); - } - } - /* Now start the waiting toasters */ - startWaitingToasters(); -} -#endif - void NotifyQt::displayErrorMessage(RsNotifySysFlags type,const QString& title,const QString& error_msg) { /* make a warning message */ diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index 8f7a75529..f012dd4d8 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -59,35 +59,6 @@ class NotifyQt: public QObject virtual ~NotifyQt() = default; -// void setNetworkDialog(NetworkDialog *c) { cDialog = c; } - -// virtual void notifyListPreChange(int list, int type); -// virtual void notifyListChange(int list, int type); -// virtual void notifyErrorMsg(int list, int sev, std::string msg); -// virtual void notifyChatMessage(const ChatMessage& /* msg */); -// virtual void notifyChatStatus(const ChatId &chat_id,const std::string& status_string); -// virtual void notifyChatCleared(const ChatId &chat_id); -// virtual void notifyCustomState(const std::string& peer_id, const std::string& status_string); -//#ifdef TO_REMOVE -// virtual void notifyTurtleSearchResult(const RsPeerId &pid, uint32_t search_id, const std::list& found_files); -//#endif -// virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list& found_groups); -// virtual void notifyPeerHasNewAvatar(std::string peer_id) ; -// virtual void notifyOwnAvatarChanged() ; -// virtual void notifyChatLobbyEvent(uint64_t /* lobby id */, uint32_t /* event type */, const RsGxsId & /*nickname*/, const std::string& /* any string */) ; -// virtual void notifyChatLobbyTimeShift(int time_shift) ; - -// virtual void notifyOwnStatusMessageChanged() ; -// virtual void notifyDiskFull(uint32_t loc,uint32_t size_in_mb) ; - /* peer has changed the state */ -// virtual void notifyPeerStatusChanged(const std::string& peer_id, uint32_t state); - /* one or more peers has changed the states */ -// virtual void notifyPeerStatusChangedSummary(); - -// virtual void notifyHistoryChanged(uint32_t msgId, int type); - -// virtual void notifyDiscInfoChanged() ; - virtual bool GUI_askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad); virtual bool GUI_askForPluginConfirmation(const std::string& plugin_filename, const RsFileHash& plugin_file_hash,bool first_time); @@ -107,34 +78,10 @@ class NotifyQt: public QObject // It's beneficial to send info to the GUI using signals, because signals are thread-safe // as they get queued by Qt. // -// void hashingInfoChanged(const QString&) const ; -// void filesPreModChanged(bool) const ; -// void filesPostModChanged(bool) const ; -// void transfersChanged() const ; -// void friendsChanged() const ; -// void lobbyListChanged() const ; -// void chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&) ; -// void neighboursChanged() const ; void configChanged() const ; void logInfoChanged(const QString&) const ; -// void chatStatusChanged(const ChatId&,const QString&) const ; void chatCleared(const ChatId&) const ; -// void peerHasNewCustomStateString(const QString& /* peer_id */, const QString& /* status_string */) const ; -// void peerHasNewAvatar(const QString& peer_id) const ; -// void ownAvatarChanged() const ; -// void ownStatusMessageChanged() const ; -// void errorOccurred(int,int,const QString&) const ; -// void diskFull(int,int) const ; -// void peerStatusChanged(const QString& /* peer_id */, int /* status */); -// void peerStatusChangedSummary() const; -// void gxsChange(const RsGxsChanges& /* changes */); -// void chatMessageReceived(ChatMessage msg); -// void groupsChanged(int type) const ; -// void discInfoChanged() const ; void historyChanged(uint msgId, int type); -// void chatLobbyInviteReceived() ; -// void deferredSignatureHandlingRequested() ; -// void chatLobbyTimeShift(int time_shift) ; void connectionWithoutCert(); /* Notify from GUI */ @@ -148,8 +95,6 @@ class NotifyQt: public QObject private slots: void runningTick(); -// void handleSignatureEvent() ; -// void handleChatLobbyTimeShift(int) ; private: NotifyQt(); @@ -164,7 +109,6 @@ class NotifyQt: public QObject void startWaitingToasters(); -// QMutex waitingToasterMutex; // for lock of the waiting toaster list QList waitingToasterList; QTimer *runningToasterTimer; From daaa7985a3dae7abae01316c0eea449df0a9e850 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 13 Oct 2025 22:49:15 +0200 Subject: [PATCH 31/38] fixed problematic re-numbering of status flags (non-backward compatible) --- retroshare-gui/src/gui/chat/ChatDialog.cpp | 2 +- retroshare-gui/src/gui/chat/ChatWidget.cpp | 2 +- retroshare-gui/src/gui/common/AvatarWidget.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/chat/ChatDialog.cpp b/retroshare-gui/src/gui/chat/ChatDialog.cpp index 22e45cdc9..9f91bc782 100644 --- a/retroshare-gui/src/gui/chat/ChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatDialog.cpp @@ -347,7 +347,7 @@ RsStatusValue ChatDialog::getPeerStatus() return cw->getPeerStatus(); } - return RsStatusValue::RS_STATUS_UNKNOWN; + return RsStatusValue::RS_STATUS_OFFLINE; } QString ChatDialog::getTitle() diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 8a842616d..927b8b5a1 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -77,7 +77,7 @@ ChatWidget::ChatWidget(QWidget *parent) : QWidget(parent) - , completionPosition(0), newMessages(false), typing(false), peerStatus(RsStatusValue::RS_STATUS_UNKNOWN) + , completionPosition(0), newMessages(false), typing(false), peerStatus(RsStatusValue::RS_STATUS_OFFLINE) , sendingBlocked(false), useCMark(false) , lastStatusSendTime(0) , firstShow(true), inChatCharFormatChanged(false), firstSearch(true) diff --git a/retroshare-gui/src/gui/common/AvatarWidget.cpp b/retroshare-gui/src/gui/common/AvatarWidget.cpp index df1584686..178ddc04a 100644 --- a/retroshare-gui/src/gui/common/AvatarWidget.cpp +++ b/retroshare-gui/src/gui/common/AvatarWidget.cpp @@ -213,7 +213,7 @@ void AvatarWidget::refreshStatus() } case STATUS_FRAME: { - RsStatusValue status = RsStatusValue::RS_STATUS_UNKNOWN; + RsStatusValue status = RsStatusValue::RS_STATUS_OFFLINE; if (mId.isNotSet()) return; From d7ff04c55273b26f82ae749dc1e49a007ac94460 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 15 Oct 2025 18:49:50 +0200 Subject: [PATCH 32/38] removed old calls to NotifyQt, and fixed missing initialization causing crash --- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 4 ---- .../src/gui/FileTransfer/TransfersDialog.cpp | 8 +++++--- .../src/gui/FileTransfer/TransfersDialog.h | 2 +- retroshare-gui/src/gui/FriendsDialog.cpp | 3 --- retroshare-gui/src/gui/MainWindow.cpp | 3 --- retroshare-gui/src/gui/MessengerWindow.cpp | 3 --- retroshare-gui/src/gui/NewsFeed.cpp | 7 ------- retroshare-gui/src/gui/ShareManager.cpp | 2 -- .../src/gui/chat/ChatUserNotify.cpp | 1 - retroshare-gui/src/gui/chat/ChatWidget.cpp | 3 --- .../src/gui/chat/PopupChatDialog.cpp | 1 - .../src/gui/common/AvatarWidget.cpp | 20 ------------------- .../src/gui/common/FriendSelectionWidget.cpp | 3 --- .../src/gui/common/GroupSelectionBox.cpp | 2 -- .../src/gui/common/NewFriendList.cpp | 3 --- .../src/gui/connect/ConnectFriendWizard.cpp | 2 -- retroshare-gui/src/gui/feeds/PeerItem.cpp | 2 -- retroshare-gui/src/gui/feeds/SecurityItem.cpp | 2 -- .../src/gui/im_history/ImHistoryBrowser.cpp | 2 -- .../src/gui/msgs/MessageComposer.cpp | 2 -- retroshare-gui/src/gui/notifyqt.cpp | 4 ++-- retroshare-gui/src/gui/notifyqt.h | 1 - .../src/gui/settings/ServerPage.cpp | 10 ---------- retroshare-gui/src/gui/settings/ServerPage.h | 2 -- retroshare-gui/src/main.cpp | 2 +- 25 files changed, 9 insertions(+), 85 deletions(-) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index c669df327..b9c87a9cf 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -105,10 +105,6 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags) myInviteYesButton = NULL; myInviteIdChooser = NULL; - //QObject::connect( NotifyQt::getInstance(), SIGNAL(lobbyListChanged()), SLOT(lobbyChanged())); - //QObject::connect( NotifyQt::getInstance(), SIGNAL(chatLobbyEvent(qulonglong,int,RsGxsId,QString)), this, SLOT(displayChatLobbyEvent(qulonglong,int,RsGxsId,QString))); - //QObject::connect( NotifyQt::getInstance(), SIGNAL(chatLobbyInviteReceived()), this, SLOT(readChatLobbyInvites())); - rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject([=](){ diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index 3d5b7d8c7..0260bb598 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -1010,7 +1010,6 @@ TransfersDialog::TransfersDialog(QWidget *parent) connect(collViewAct,SIGNAL(triggered()),this,SLOT(collView())); collOpenAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COLLOPEN), tr( "Download from collection file..." ), this ); connect(collOpenAct, SIGNAL(triggered()), this, SLOT(collOpen())); - connect(NotifyQt::getInstance(), SIGNAL(downloadComplete(QString)), this, SLOT(collAutoOpen(QString))); /** Setup the actions for the download header context menu */ showDLSizeAct= new QAction(tr("Size"),this); @@ -1115,6 +1114,10 @@ void TransfersDialog::handleEvent_main_thread(std::shared_ptr eve switch (fe->mFileTransferEventCode) { case RsFileTransferEventCode::DOWNLOAD_COMPLETE: + collAutoOpen(fe->mHash); + + [[fallthrough]]; + case RsFileTransferEventCode::COMPLETED_FILES_REMOVED: getUserNotify()->updateIcon(); @@ -2568,11 +2571,10 @@ void TransfersDialog::collOpen() QMessageBox::information(nullptr,tr("Error openning collection file"),RsCollection::errorString(code)); } -void TransfersDialog::collAutoOpen(const QString &fileHash) +void TransfersDialog::collAutoOpen(const RsFileHash& hash) { if (Settings->valueFromGroup("Transfer","AutoDLColl").toBool()) { - RsFileHash hash = RsFileHash(fileHash.toStdString()); FileInfo info; if (rsFiles->FileDetails(hash, RS_FILE_HINTS_DOWNLOAD, info)) { diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h index 19e2df363..8d167643e 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h @@ -145,7 +145,7 @@ private slots: void collModif(); void collView(); void collOpen(); - void collAutoOpen(const QString& fileHash); + void collAutoOpen(const RsFileHash &hash); void setShowDLSizeColumn(bool show); void setShowDLCompleteColumn(bool show); diff --git a/retroshare-gui/src/gui/FriendsDialog.cpp b/retroshare-gui/src/gui/FriendsDialog.cpp index b68033478..0a2707179 100644 --- a/retroshare-gui/src/gui/FriendsDialog.cpp +++ b/retroshare-gui/src/gui/FriendsDialog.cpp @@ -78,9 +78,6 @@ FriendsDialog::FriendsDialog(QWidget *parent) : MainPage(parent) ui.chatWidget->setWelcomeMessage(msg); ui.chatWidget->init(ChatId::makeBroadcastId(), tr("Broadcast")); - //connect(NotifyQt::getInstance(), SIGNAL(chatMessageReceived(ChatMessage)), this, SLOT(chatMessageReceived(ChatMessage))); - //connect(NotifyQt::getInstance(), SIGNAL(chatStatusChanged(ChatId,QString)), this, SLOT(chatStatusReceived(ChatId,QString))); - mEventHandlerId_chat = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr e) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 12b2342a5..2aa00b39a 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -345,9 +345,6 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) /* intialize friend count */ updateFriends(); -// connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateFriends())); -// connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateFriends())); - loadOwnStatus(); /* Set focus to the current page */ diff --git a/retroshare-gui/src/gui/MessengerWindow.cpp b/retroshare-gui/src/gui/MessengerWindow.cpp index 7e18cbb0b..5e13ab271 100644 --- a/retroshare-gui/src/gui/MessengerWindow.cpp +++ b/retroshare-gui/src/gui/MessengerWindow.cpp @@ -95,9 +95,6 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WindowFlags flags) connect(ui.messagelineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(savestatusmessage())); - //connect(NotifyQt::getInstance(), SIGNAL(ownStatusMessageChanged()), this, SLOT(loadmystatusmessage())); - //connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateOwnStatus(QString,int))); - mEventHandlerId = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr e) { diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index 8a9b506ce..0bdd5df24 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -432,10 +432,6 @@ void NewsFeed::handleConnectionEvent(std::shared_ptr event) auto& e(*pe); -#ifdef NEWS_DEBUG - std::cerr << "NotifyQt: handling connection event from peer " << e.mSslId << std::endl; -#endif - switch(e.mEventCode) { case RsFriendListEventCode::NODE_CONNECTED: @@ -465,9 +461,6 @@ void NewsFeed::handleSecurityEvent(std::shared_ptr event) return; auto& e(*pe); -#ifdef NEWS_DEBUG - std::cerr << "NotifyQt: handling security event from (" << e.mSslId << "," << e.mPgpId << ") error code: " << (int)e.mErrorCode << std::endl; -#endif RsFeedTypeFlags flags = (RsFeedTypeFlags)Settings->getNewsFeedFlags(); if(e.mErrorCode == RsAuthSslError::PEER_REFUSED_CONNECTION && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_SECURITY_IP))) diff --git a/retroshare-gui/src/gui/ShareManager.cpp b/retroshare-gui/src/gui/ShareManager.cpp index 224af7a22..50c708fcf 100644 --- a/retroshare-gui/src/gui/ShareManager.cpp +++ b/retroshare-gui/src/gui/ShareManager.cpp @@ -74,8 +74,6 @@ ShareManager::ShareManager() connect(ui.shareddirList, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(doubleClickedCell(int,int))); connect(ui.shareddirList, SIGNAL(cellChanged(int,int)), this, SLOT(handleCellChange(int,int))); - // connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(reload())); - mEventHandlerId = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr e) diff --git a/retroshare-gui/src/gui/chat/ChatUserNotify.cpp b/retroshare-gui/src/gui/chat/ChatUserNotify.cpp index 2d438f022..8d7aa6a8d 100644 --- a/retroshare-gui/src/gui/chat/ChatUserNotify.cpp +++ b/retroshare-gui/src/gui/chat/ChatUserNotify.cpp @@ -57,7 +57,6 @@ static ChatUserNotify* instance = 0; ChatUserNotify::ChatUserNotify(QObject *parent) : UserNotify(parent) { - //connect(NotifyQt::getInstance(), SIGNAL(chatMessageReceived(ChatMessage)), this, SLOT(chatMessageReceived(ChatMessage))); instance = this; mEventHandlerId = 0; diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 927b8b5a1..651a77376 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -174,8 +174,6 @@ ChatWidget::ChatWidget(QWidget *parent) connect(ui->hashBox, SIGNAL(fileHashingFinished(QList)), this, SLOT(fileHashingFinished(QList))); - //connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&, int)), this, SLOT(updateStatus(const QString&, int))); - mEventHandlerId_friends = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr e) @@ -201,7 +199,6 @@ ChatWidget::ChatWidget(QWidget *parent) }, this ); },mEventHandlerId_friends,RsEventType::FRIEND_LIST); - //connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&))); connect(NotifyQt::getInstance(), SIGNAL(chatFontChanged()), this, SLOT(resetFonts())); connect(ui->textBrowser, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTextBrowser(QPoint))); diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 793835d70..261534513 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -50,7 +50,6 @@ PopupChatDialog::PopupChatDialog(QWidget *parent, Qt::WindowFlags flags) connect(ui.avatarFrameButton, SIGNAL(toggled(bool)), this, SLOT(showAvatarFrame(bool))); connect(ui.actionClearOfflineMessages, SIGNAL(triggered()), this, SLOT(clearOfflineMessages())); - //connect(NotifyQt::getInstance(), SIGNAL(chatStatusChanged(ChatId,QString)), this, SLOT(chatStatusChanged(ChatId,QString))); mEventHandlerId_chat =0; diff --git a/retroshare-gui/src/gui/common/AvatarWidget.cpp b/retroshare-gui/src/gui/common/AvatarWidget.cpp index 178ddc04a..006076beb 100644 --- a/retroshare-gui/src/gui/common/AvatarWidget.cpp +++ b/retroshare-gui/src/gui/common/AvatarWidget.cpp @@ -48,10 +48,6 @@ AvatarWidget::AvatarWidget(QWidget *parent) : QLabel(parent), ui(new Ui::AvatarW setFrameType(NO_FRAME); - /* connect signals */ - //connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&))); - //connect(NotifyQt::getInstance(), SIGNAL(ownAvatarChanged()), this, SLOT(updateOwnAvatar())); - mEventHandlerId = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr event) @@ -137,22 +133,6 @@ void AvatarWidget::setFrameType(FrameType type) { mFrameType = type; -#ifdef TO_REMOVE - switch (mFrameType) { - case NO_FRAME: - disconnect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateStatus(const QString&, int))); - break; - case NORMAL_FRAME: - disconnect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateStatus(const QString&, int))); - break; - case STATUS_FRAME: - connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateStatus(const QString&, int))); - break; - } -#endif - - - //refreshAvatarImage(); refreshStatus(); RsApplication::refreshStyleSheet(this, false); diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index 47cf2b802..962927c99 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -101,9 +101,6 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) connect(ui->friendList, SIGNAL(itemSelectionChanged()), this, SIGNAL(itemSelectionChanged())); connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString))); - //connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(groupsChanged(int))); - //connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&,int)), this, SLOT(peerStatusChanged(const QString&,int))); - mCompareRole = new RSTreeWidgetItemCompareRole; mActionSortByState = new QAction(tr("Sort by state"), this); mActionSortByState->setCheckable(true); diff --git a/retroshare-gui/src/gui/common/GroupSelectionBox.cpp b/retroshare-gui/src/gui/common/GroupSelectionBox.cpp index e2eb533c0..05f18d622 100644 --- a/retroshare-gui/src/gui/common/GroupSelectionBox.cpp +++ b/retroshare-gui/src/gui/common/GroupSelectionBox.cpp @@ -35,8 +35,6 @@ GroupSelectionBox::GroupSelectionBox(QWidget *parent) { setSelectionMode(QAbstractItemView::SingleSelection); - //connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(fillGroups())); - mEventHandlerId = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr e) diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 554009818..ecc2f68db 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -203,9 +203,6 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par rsEvents->registerEventsHandler( [this](std::shared_ptr e) { handleEvent(e); }, mEventHandlerId_peer, RsEventType::FRIEND_LIST ); rsEvents->registerEventsHandler( [this](std::shared_ptr e) { handleEvent(e); }, mEventHandlerId_gssp, RsEventType::GOSSIP_DISCOVERY ); -// connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(QString)), this, SLOT(forceUpdateDisplay())); -// connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(forceUpdateDisplay())); - mModel = new RsFriendListModel(ui->peerTreeWidget); mProxyModel = new FriendListSortFilterProxyModel(ui->peerTreeWidget->header(),this); diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index dcc1bb5ea..b27bce36d 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -856,8 +856,6 @@ void ConnectFriendWizard::accept() ConnectProgressDialog::showProgress(ssl_id); } - //NotifyQt::getInstance()->notifyListChange(NOTIFY_LIST_NEIGHBOURS,1) ; - auto ev = std::make_shared(); ev->mEventCode = RsFriendListEventCode::NODE_ADDED; ev->mSslId = peerDetails.id; diff --git a/retroshare-gui/src/gui/feeds/PeerItem.cpp b/retroshare-gui/src/gui/feeds/PeerItem.cpp index 388f3cbc8..61e3191d1 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.cpp +++ b/retroshare-gui/src/gui/feeds/PeerItem.cpp @@ -59,8 +59,6 @@ PeerItem::PeerItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId, connect( chatButton, SIGNAL( clicked() ), this, SLOT( openChat() ) ); connect( sendmsgButton, SIGNAL( clicked() ), this, SLOT( sendMsg() ) ); - //connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateItem())); - mEventHandlerId = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr e) diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.cpp b/retroshare-gui/src/gui/feeds/SecurityItem.cpp index 7d4059a08..9fa5514b2 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityItem.cpp @@ -73,8 +73,6 @@ SecurityItem::SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &g connect( peerDetailsButton, SIGNAL(clicked()), this, SLOT(peerDetails())); connect( friendRequesttoolButton, SIGNAL(clicked()), this, SLOT(friendRequest())); - //connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateItem())); - mEventHandlerId = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr e) diff --git a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp index f4f274a2c..fd4f6f9ba 100644 --- a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp +++ b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp @@ -102,8 +102,6 @@ ImHistoryBrowser::ImHistoryBrowser(const ChatId &chatId, QTextEdit *edit,const Q m_chatId = chatId; textEdit = edit; - //connect(NotifyQt::getInstance(), SIGNAL(historyChanged(uint, int)), this, SLOT(historyChanged(uint, int))); - connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); connect(ui.copyButton, SIGNAL(clicked()), SLOT(copyMessage())); diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 2c07e1f58..41d55d9f2 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -216,8 +216,6 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags) connect(ui.addBccButton, SIGNAL(clicked()), this, SLOT(addBcc())); connect(ui.addRecommendButton, SIGNAL(clicked()), this, SLOT(addRecommend())); - //connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(peerStatusChanged(QString,int))); - rsEvents->registerEventsHandler( [this](std::shared_ptr e) { RsQThreadUtils::postToObject([=](){ diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index dd3d1a028..a088b10cf 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -62,12 +62,12 @@ * #define NOTIFY_DEBUG ****/ -/*static*/ NotifyQt *NotifyQt::_instance = NULL; +/*static*/ NotifyQt *NotifyQt::_instance = nullptr; /*static*/ bool NotifyQt::_disableAllToaster = false; /*static*/ NotifyQt *NotifyQt::Create () { - if (_instance == NULL) { + if (_instance == nullptr) { _instance = new NotifyQt (); } diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index f012dd4d8..4bd969ab8 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -82,7 +82,6 @@ class NotifyQt: public QObject void logInfoChanged(const QString&) const ; void chatCleared(const ChatId&) const ; void historyChanged(uint msgId, int type); - void connectionWithoutCert(); /* Notify from GUI */ void chatFontChanged(); diff --git a/retroshare-gui/src/gui/settings/ServerPage.cpp b/retroshare-gui/src/gui/settings/ServerPage.cpp index 72fe6d614..19bd3a7bf 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.cpp +++ b/retroshare-gui/src/gui/settings/ServerPage.cpp @@ -201,8 +201,6 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags) QObject::connect(ui.hiddenpage_proxyAddress_i2p, SIGNAL(textChanged(QString)), this, SLOT(syncI2PProxyAddrNormal(QString))); QObject::connect(ui.hiddenpage_proxyAddress_i2p_2, SIGNAL(textChanged(QString)), this, SLOT(syncI2PProxyAddrSam(QString))); - connect(NotifyQt::getInstance(), SIGNAL(connectionWithoutCert()), this, SLOT(connectionWithoutCert())); - QObject::connect(ui.localPort,SIGNAL(valueChanged(int)),this,SLOT(saveAddresses())); QObject::connect(ui.extPort,SIGNAL(valueChanged(int)),this,SLOT(saveAddresses())); @@ -1670,14 +1668,6 @@ void ServerPage::taskFinished(taskTicket *&ticket) #endif //RS_USE_I2P_SAM3 } -void ServerPage::connectionWithoutCert() -{ - if (mOngoingConnectivityCheck > 0) { - mOngoingConnectivityCheck = -1; - updateInProxyIndicatorResult(true); - } -} - void ServerPage::loadCommon() { /* HIDDEN PAGE SETTINGS - only Proxy (outgoing) */ diff --git a/retroshare-gui/src/gui/settings/ServerPage.h b/retroshare-gui/src/gui/settings/ServerPage.h index f4f0eee10..47d08a3f0 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.h +++ b/retroshare-gui/src/gui/settings/ServerPage.h @@ -111,8 +111,6 @@ private slots: void syncI2PProxyAddrNormal(QString); void syncI2PProxyAddrSam(QString); - void connectionWithoutCert(); - //Relay Tab void updateRelayOptions(); void updateEnabled(); diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 664ee280c..0aec1cd2a 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -346,7 +346,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); // RsControl::earlyInitNotificationSystem() ; - //NotifyQt *notify = NotifyQt::Create(); + NotifyQt *notify = NotifyQt::Create(); //rsNotify->registerNotifyClient(notify); /* RetroShare Core Objects */ From a08d0a62df223ae8130d2157421aafb6aaf0d608 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 26 Oct 2025 20:53:36 +0100 Subject: [PATCH 33/38] fixed missing initialization of Event handler ID in ChatLobbyDialog --- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index b9c87a9cf..7f2086cf8 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -105,6 +105,8 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags) myInviteYesButton = NULL; myInviteIdChooser = NULL; + mEventHandlerId = 0; + rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject([=](){ From ff04cd326a93b5fc5c44941fa1d9735c69ad7cbf Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 27 Oct 2025 13:48:18 +0100 Subject: [PATCH 34/38] removed warning --- retroshare-gui/src/gui/settings/NotifyPage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/settings/NotifyPage.cpp b/retroshare-gui/src/gui/settings/NotifyPage.cpp index 0dc7e6d9e..23408181d 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.cpp +++ b/retroshare-gui/src/gui/settings/NotifyPage.cpp @@ -273,7 +273,7 @@ void NotifyPage::updateUserNotifySettings() MainWindow::installNotifyIcons(); } -void NotifyPage::updateMessageFlags() { Settings->setMessageFlags( ui.message_ConnectAttempt->isChecked()? RshareSettings::RS_MESSAGE_CONNECT_ATTEMPT : 0); } +void NotifyPage::updateMessageFlags() { Settings->setMessageFlags( ui.message_ConnectAttempt->isChecked()? uint(RshareSettings::RS_MESSAGE_CONNECT_ATTEMPT) : 0); } void NotifyPage::updateNotifyFlags() { Settings->setNotifyFlags((int)getNotifyFlags()); } void NotifyPage::updateNewsFeedFlags(){ Settings->setNewsFeedFlags((int)getNewsFlags()); } From a91a0893cf5bbe18260fcea30b3a91768a4d1aba Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 11 Nov 2025 18:56:24 +0100 Subject: [PATCH 35/38] renamed NotifyQt into RsGUIEventManager --- retroshare-gui/src/gui/MainWindow.cpp | 2 +- .../gui/Posted/PostedListWidgetWithModel.cpp | 2 +- .../{notifyqt.cpp => RsGUIEventManager.cpp} | 53 +++++++++---------- .../gui/{notifyqt.h => RsGUIEventManager.h} | 14 ++--- retroshare-gui/src/gui/chat/ChatStyle.cpp | 2 +- retroshare-gui/src/gui/chat/ChatWidget.cpp | 2 +- .../src/gui/gxs/GxsGroupFrameDialog.cpp | 2 +- .../GxsChannelPostsWidgetWithModel.cpp | 2 +- .../src/gui/settings/AppearancePage.cpp | 8 +-- retroshare-gui/src/gui/settings/ChatPage.cpp | 8 +-- .../gui/settings/GroupFrameSettingsWidget.cpp | 2 +- .../src/gui/settings/MessagePage.cpp | 2 +- .../src/gui/settings/NotifyPage.cpp | 12 ++--- .../src/gui/settings/rsettingswin.cpp | 4 +- .../src/gui/statusbar/ToasterDisable.cpp | 6 +-- retroshare-gui/src/main.cpp | 2 +- retroshare-gui/src/util/FontSizeHandler.cpp | 4 +- 17 files changed, 62 insertions(+), 65 deletions(-) rename retroshare-gui/src/gui/{notifyqt.cpp => RsGUIEventManager.cpp} (92%) rename retroshare-gui/src/gui/{notifyqt.h => RsGUIEventManager.h} (92%) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 2aa00b39a..fb337321b 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -358,7 +358,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus())); timer->start(1000); - connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); + connect(RsGUIEventManager::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); settingsChanged(); mFontSizeHandler.registerFontSize(ui->listWidget, 1.5f); diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index aec3c7bdb..a674e5035 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -289,7 +289,7 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI connect(ui->submitPostButton, SIGNAL(clicked()), this, SLOT(createMsg())); connect(ui->subscribeToolButton, SIGNAL(subscribe(bool)), this, SLOT(subscribeGroup(bool))); connect(ui->filter_LE, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString))); - connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()),this, SLOT(settingsChanged())); + connect(RsGUIEventManager::getInstance(), SIGNAL(settingsChanged()),this, SLOT(settingsChanged())); /* add filter actions */ ui->postsTree->setPlaceholderText(tr("No posts available in this board")); diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/RsGUIEventManager.cpp similarity index 92% rename from retroshare-gui/src/gui/notifyqt.cpp rename to retroshare-gui/src/gui/RsGUIEventManager.cpp index a088b10cf..f7831dfbf 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/RsGUIEventManager.cpp @@ -1,5 +1,5 @@ /******************************************************************************* - * gui/NotifyQt.cpp * + * gui/RsGUIEventManager.cpp * * * * Copyright (c) 2010 Retroshare Team * * * @@ -62,29 +62,26 @@ * #define NOTIFY_DEBUG ****/ -/*static*/ NotifyQt *NotifyQt::_instance = nullptr; -/*static*/ bool NotifyQt::_disableAllToaster = false; +/*static*/ RsGUIEventManager *RsGUIEventManager::_instance = nullptr; +/*static*/ bool RsGUIEventManager::_disableAllToaster = false; -/*static*/ NotifyQt *NotifyQt::Create () +/*static*/ void RsGUIEventManager::Create () { - if (_instance == nullptr) { - _instance = new NotifyQt (); - } - - return _instance; + if (_instance == nullptr) + _instance = new RsGUIEventManager (); } -/*static*/ NotifyQt *NotifyQt::getInstance () +/*static*/ RsGUIEventManager *RsGUIEventManager::getInstance () { return _instance; } -/*static*/ bool NotifyQt::isAllDisable () +/*static*/ bool RsGUIEventManager::isAllDisable () { return _disableAllToaster; } -void NotifyQt::SetDisableAll(bool bValue) +void RsGUIEventManager::SetDisableAll(bool bValue) { if (bValue!=_disableAllToaster) { @@ -93,7 +90,7 @@ void NotifyQt::SetDisableAll(bool bValue) } } -NotifyQt::NotifyQt() : cDialog(NULL) +RsGUIEventManager::RsGUIEventManager() : cDialog(NULL) { runningToasterTimer = new QTimer(this); connect(runningToasterTimer, SIGNAL(timeout()), this, SLOT(runningTick())); @@ -118,7 +115,7 @@ NotifyQt::NotifyQt() : cDialog(NULL) }, mEventHandlerId); // No event type means we expect to catch all possible events } -bool NotifyQt::GUI_askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad) +bool RsGUIEventManager::GUI_askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad) { RsAutoUpdatePage::lockAllEvents() ; @@ -171,7 +168,7 @@ bool NotifyQt::GUI_askForPassword(const std::string& title, const std::string& k RsLoginHelper::clearPgpPassphrase(); return false; } -bool NotifyQt::GUI_askForPluginConfirmation(const std::string& plugin_file_name, const RsFileHash& plugin_file_hash, bool first_time) +bool RsGUIEventManager::GUI_askForPluginConfirmation(const std::string& plugin_file_name, const RsFileHash& plugin_file_hash, bool first_time) { // By default, when no information is known about plugins, just dont load them. They will be enabled from the GUI by the user. @@ -207,14 +204,14 @@ bool NotifyQt::GUI_askForPluginConfirmation(const std::string& plugin_file_name, } } -void NotifyQt::enable() +void RsGUIEventManager::enable() { QMutexLocker m(&_mutex) ; std::cerr << "Enabling notification system" << std::endl; _enabled = true ; } -void NotifyQt::sync_handleIncomingEvent(std::shared_ptr event) +void RsGUIEventManager::sync_handleIncomingEvent(std::shared_ptr event) { auto ev6 = dynamic_cast(event.get()); @@ -224,7 +221,7 @@ void NotifyQt::sync_handleIncomingEvent(std::shared_ptr event) GUI_askForPluginConfirmation(ev6->plugin_file_name, ev6->plugin_file_hash, ev6->plugin_first_time); } -void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) +void RsGUIEventManager::async_handleIncomingEvent(std::shared_ptr event) { /* Finally Check for PopupMessages / System Error Messages */ @@ -403,7 +400,7 @@ void NotifyQt::async_handleIncomingEvent(std::shared_ptr event) startWaitingToasters(); } -void NotifyQt::testToasters(RsNotifyPopupFlags notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin) +void RsGUIEventManager::testToasters(RsNotifyPopupFlags notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin) { QString title = tr("Test"); QString message = tr("This is a test."); @@ -469,7 +466,7 @@ void NotifyQt::testToasters(RsNotifyPopupFlags notifyFlags, /*RshareSettings::en } } -void NotifyQt::testToaster(ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin) +void RsGUIEventManager::testToaster(ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin) { if (!toasterNotify) { @@ -490,7 +487,7 @@ void NotifyQt::testToaster(ToasterNotify *toasterNotify, /*RshareSettings::enumT } } -void NotifyQt::testToaster(QString tag, ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin) +void RsGUIEventManager::testToaster(QString tag, ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin) { if (!toasterNotify) { @@ -511,7 +508,7 @@ void NotifyQt::testToaster(QString tag, ToasterNotify *toasterNotify, /*RshareSe } } -void NotifyQt::notifyChatFontChanged() +void RsGUIEventManager::notifyChatFontChanged() { { QMutexLocker m(&_mutex) ; @@ -521,7 +518,7 @@ void NotifyQt::notifyChatFontChanged() emit chatFontChanged(); } -void NotifyQt::notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType) +void RsGUIEventManager::notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType) { { QMutexLocker m(&_mutex) ; @@ -532,12 +529,12 @@ void NotifyQt::notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType emit chatStyleChanged(styleType); } -void NotifyQt::notifySettingsChanged() +void RsGUIEventManager::notifySettingsChanged() { emit settingsChanged(); } -void NotifyQt::startWaitingToasters() +void RsGUIEventManager::startWaitingToasters() { { if (waitingToasterList.empty()) { @@ -607,7 +604,7 @@ void NotifyQt::startWaitingToasters() } } -void NotifyQt::runningTick() +void RsGUIEventManager::runningTick() { //QMutexLocker lock(&runningToasterMutex); @@ -692,7 +689,7 @@ void NotifyQt::runningTick() } } -void NotifyQt::displayErrorMessage(RsNotifySysFlags type,const QString& title,const QString& error_msg) +void RsGUIEventManager::displayErrorMessage(RsNotifySysFlags type,const QString& title,const QString& error_msg) { /* make a warning message */ switch(type) @@ -711,7 +708,7 @@ void NotifyQt::displayErrorMessage(RsNotifySysFlags type,const QString& title,co } } -void NotifyQt::displayDiskSpaceWarning(int loc,int size_limit_mb) +void RsGUIEventManager::displayDiskSpaceWarning(int loc,int size_limit_mb) { QString locString ; switch(loc) diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/RsGUIEventManager.h similarity index 92% rename from retroshare-gui/src/gui/notifyqt.h rename to retroshare-gui/src/gui/RsGUIEventManager.h index 4bd969ab8..2ae4ab464 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/RsGUIEventManager.h @@ -1,5 +1,5 @@ /******************************************************************************* - * gui/NotifyQt.h * + * gui/RsGUIEventManager.h * * * * Copyright (c) 2010 Retroshare Team * * * @@ -48,16 +48,16 @@ class SignatureEventData ; struct TurtleFileInfo; struct TurtleGxsInfo; -class NotifyQt: public QObject +class RsGUIEventManager: public QObject { Q_OBJECT public: - static NotifyQt *Create (); - static NotifyQt *getInstance (); + static void Create(); + static RsGUIEventManager *getInstance (); static bool isAllDisable(); void enable() ; - virtual ~NotifyQt() = default; + virtual ~RsGUIEventManager() = default; virtual bool GUI_askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad); virtual bool GUI_askForPluginConfirmation(const std::string& plugin_filename, const RsFileHash& plugin_file_hash,bool first_time); @@ -96,12 +96,12 @@ class NotifyQt: public QObject void runningTick(); private: - NotifyQt(); + RsGUIEventManager(); static void displayDiskSpaceWarning(int loc,int size_limit_mb); static void displayErrorMessage(RsNotifySysFlags type,const QString& title,const QString& error_msg); - static NotifyQt *_instance; + static RsGUIEventManager *_instance; static bool _disableAllToaster; /* system notifications */ diff --git a/retroshare-gui/src/gui/chat/ChatStyle.cpp b/retroshare-gui/src/gui/chat/ChatStyle.cpp index d6e380f40..8eca138ad 100644 --- a/retroshare-gui/src/gui/chat/ChatStyle.cpp +++ b/retroshare-gui/src/gui/chat/ChatStyle.cpp @@ -130,7 +130,7 @@ ChatStyle::ChatStyle() : QObject() { m_styleType = TYPE_UNKNOWN; - connect(NotifyQt::getInstance(), SIGNAL(chatStyleChanged(int)), SLOT(styleChanged(int))); + connect(RsGUIEventManager::getInstance(), SIGNAL(chatStyleChanged(int)), SLOT(styleChanged(int))); } /* Destructor. */ diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 651a77376..f278f4400 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -199,7 +199,7 @@ ChatWidget::ChatWidget(QWidget *parent) }, this ); },mEventHandlerId_friends,RsEventType::FRIEND_LIST); - connect(NotifyQt::getInstance(), SIGNAL(chatFontChanged()), this, SLOT(resetFonts())); + connect(RsGUIEventManager::getInstance(), SIGNAL(chatFontChanged()), this, SLOT(resetFonts())); connect(ui->textBrowser, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTextBrowser(QPoint))); diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index da745b122..750d714ed 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -173,7 +173,7 @@ void GxsGroupFrameDialog::initUi() processSettings(true); if (groupFrameSettingsType() != GroupFrameSettings::Nothing) { - connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); + connect(RsGUIEventManager::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); settingsChanged(); } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 13a189fb1..a95b42b15 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -446,7 +446,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI /* Connect signals */ connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createMsg())); connect(ui->subscribeToolButton, SIGNAL(subscribe(bool)), this, SLOT(subscribeGroup(bool))); - connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); + connect(RsGUIEventManager::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); ui->postButton->setText(tr("Add new post")); diff --git a/retroshare-gui/src/gui/settings/AppearancePage.cpp b/retroshare-gui/src/gui/settings/AppearancePage.cpp index 2aecd6024..e9e32af47 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.cpp +++ b/retroshare-gui/src/gui/settings/AppearancePage.cpp @@ -173,7 +173,7 @@ void AppearancePage::updateRbtPageOnToolBar() ui.cmboTollButtonsStyle->show(); } - NotifyQt::getInstance()->notifySettingsChanged(); + RsGUIEventManager::getInstance()->notifySettingsChanged(); } void AppearancePage::updateStatusToolTip() { MainWindow::getInstance()->toggleStatusToolTip(ui.checkBoxDisableSysTrayToolTip->isChecked()); } @@ -194,7 +194,7 @@ void AppearancePage::updateCmboToolButtonStyle() default: Settings->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); } - NotifyQt::getInstance()->notifySettingsChanged(); + RsGUIEventManager::getInstance()->notifySettingsChanged(); } void AppearancePage::updateCmboToolButtonSize() @@ -226,7 +226,7 @@ void AppearancePage::updateCmboToolButtonSize() Settings->setToolButtonSize(128); Settings->setListItemIconSize(128); } - NotifyQt::getInstance()->notifySettingsChanged(); + RsGUIEventManager::getInstance()->notifySettingsChanged(); } // void AppearancePage::updateCmboListItemSize() // { @@ -369,5 +369,5 @@ void AppearancePage::updateFontSize() { Settings->setFontSize(ui.minimumFontSize_SB->value()); - NotifyQt::getInstance()->notifySettingsChanged(); + RsGUIEventManager::getInstance()->notifySettingsChanged(); } diff --git a/retroshare-gui/src/gui/settings/ChatPage.cpp b/retroshare-gui/src/gui/settings/ChatPage.cpp index ed551aa10..a319d4b6c 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.cpp +++ b/retroshare-gui/src/gui/settings/ChatPage.cpp @@ -126,7 +126,7 @@ void ChatPage::updateFontsAndEmotes() void ChatPage::updateChatParams() { Settings->setChatScreenFont(fontTempChat.toString()); - NotifyQt::getInstance()->notifyChatFontChanged(); + RsGUIEventManager::getInstance()->notifyChatFontChanged(); Settings->setChatSendMessageWithCtrlReturn(ui.sendMessageWithCtrlReturn->isChecked()); Settings->setChatSendAsPlainTextByDef(ui.sendAsPlainTextByDef->isChecked()); @@ -186,7 +186,7 @@ void ChatPage::updatePublicStyle() if (publicStylePath != info.stylePath || publicStyleVariant != ui.publicComboBoxVariant->currentText()) { Settings->setPublicChatStyle(info.stylePath, ui.publicComboBoxVariant->currentText()); - NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PUBLIC); + RsGUIEventManager::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PUBLIC); } } @@ -196,7 +196,7 @@ void ChatPage::updatePrivateStyle() if (privateStylePath != info.stylePath || privateStyleVariant != ui.privateComboBoxVariant->currentText()) { Settings->setPrivateChatStyle(info.stylePath, ui.privateComboBoxVariant->currentText()); - NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PRIVATE); + RsGUIEventManager::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PRIVATE); } } @@ -206,7 +206,7 @@ void ChatPage::updateHistoryStyle() if (historyStylePath != info.stylePath || historyStyleVariant != ui.historyComboBoxVariant->currentText()) { Settings->setHistoryChatStyle(info.stylePath, ui.historyComboBoxVariant->currentText()); - NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_HISTORY); + RsGUIEventManager::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_HISTORY); } } diff --git a/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.cpp b/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.cpp index 6bf4c1886..c3aadbf3a 100644 --- a/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.cpp +++ b/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.cpp @@ -78,6 +78,6 @@ void GroupFrameSettingsWidget::saveSettings() Settings->setGroupFrameSettings(mType, groupFrameSettings); - NotifyQt::getInstance()->notifySettingsChanged(); + RsGUIEventManager::getInstance()->notifySettingsChanged(); } } diff --git a/retroshare-gui/src/gui/settings/MessagePage.cpp b/retroshare-gui/src/gui/settings/MessagePage.cpp index 0f11ef109..283be7bef 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.cpp +++ b/retroshare-gui/src/gui/settings/MessagePage.cpp @@ -311,5 +311,5 @@ void MessagePage::updateFontSize() { Settings->setMessageFontSize(ui.minimumFontSize->currentData().toInt()); - NotifyQt::getInstance()->notifySettingsChanged(); + RsGUIEventManager::getInstance()->notifySettingsChanged(); } diff --git a/retroshare-gui/src/gui/settings/NotifyPage.cpp b/retroshare-gui/src/gui/settings/NotifyPage.cpp index 23408181d..ba37d1f82 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.cpp +++ b/retroshare-gui/src/gui/settings/NotifyPage.cpp @@ -44,8 +44,8 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags) connect(ui.testFeedButton, SIGNAL(clicked()), this, SLOT(testFeed())); connect(ui.testToasterButton, SIGNAL(clicked()), this, SLOT(testToaster())); - connect(ui.pushButtonDisableAll,SIGNAL(toggled(bool)), NotifyQt::getInstance(), SLOT(SetDisableAll(bool))); - connect(NotifyQt::getInstance(),SIGNAL(disableAllChanged(bool)), ui.pushButtonDisableAll, SLOT(setChecked(bool))); + connect(ui.pushButtonDisableAll,SIGNAL(toggled(bool)), RsGUIEventManager::getInstance(), SLOT(SetDisableAll(bool))); + connect(RsGUIEventManager::getInstance(),SIGNAL(disableAllChanged(bool)), ui.pushButtonDisableAll, SLOT(setChecked(bool))); ui.notify_Blogs->hide(); @@ -325,7 +325,7 @@ void NotifyPage::load() whileBlocking(ui.systray_GroupChat)->setChecked(Settings->getDisplayTrayGroupChat()); whileBlocking(ui.systray_ChatLobby)->setChecked(Settings->getDisplayTrayChatLobby()); - whileBlocking(ui.pushButtonDisableAll)->setChecked(NotifyQt::isAllDisable()); + whileBlocking(ui.pushButtonDisableAll)->setChecked(RsGUIEventManager::isAllDisable()); RshareSettings::enumToasterPosition toasterPosition = Settings->getToasterPosition(); ui.comboBoxToasterPosition->clear(); @@ -412,16 +412,16 @@ void NotifyPage::testToaster() { RshareSettings::enumToasterPosition pos = (RshareSettings::enumToasterPosition) ui.comboBoxToasterPosition->itemData(ui.comboBoxToasterPosition->currentIndex()).toInt(); QPoint margin = QPoint(ui.spinBoxToasterXMargin->value(), ui.spinBoxToasterYMargin->value()); - NotifyQt::getInstance()->testToasters(getNotifyFlags(), pos, margin); + RsGUIEventManager::getInstance()->testToasters(getNotifyFlags(), pos, margin); /* notify of plugins */ QList::iterator toasterNotifyIt; for (toasterNotifyIt = mToasterNotifySettingList.begin(); toasterNotifyIt != mToasterNotifySettingList.end(); ++toasterNotifyIt) { if (toasterNotifyIt->mEnabledCheckBox->isChecked()){ if (toasterNotifyIt->mEnabledCheckBox->accessibleName().isEmpty()){ - NotifyQt::getInstance()->testToaster(toasterNotifyIt->mToasterNotify, pos, margin) ; + RsGUIEventManager::getInstance()->testToaster(toasterNotifyIt->mToasterNotify, pos, margin) ; } else { - NotifyQt::getInstance()->testToaster(toasterNotifyIt->mEnabledCheckBox->accessibleName(), toasterNotifyIt->mToasterNotify, pos, margin) ; + RsGUIEventManager::getInstance()->testToaster(toasterNotifyIt->mEnabledCheckBox->accessibleName(), toasterNotifyIt->mToasterNotify, pos, margin) ; } } } diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp index a9fab8895..b0e5064ff 100644 --- a/retroshare-gui/src/gui/settings/rsettingswin.cpp +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -238,6 +238,6 @@ void SettingsPage::notifySettingsChanged() /* call to RsIface save function.... */ //rsicontrol -> ConfigSave(); - if (NotifyQt::getInstance()) - NotifyQt::getInstance()->notifySettingsChanged(); + if (RsGUIEventManager::getInstance()) + RsGUIEventManager::getInstance()->notifySettingsChanged(); } diff --git a/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp b/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp index a304f8721..d92b58220 100644 --- a/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp +++ b/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp @@ -47,11 +47,11 @@ ToasterDisable::ToasterDisable(QWidget *parent) setLayout(hbox); - bool isDisable = NotifyQt::isAllDisable(); + bool isDisable = RsGUIEventManager::isAllDisable(); imageButton->setChecked(isDisable); - connect(NotifyQt::getInstance(), SIGNAL(disableAllChanged(bool)), this, SLOT(disable(bool))); - connect(imageButton, SIGNAL(toggled(bool)), NotifyQt::getInstance(), SLOT(SetDisableAll(bool))); + connect(RsGUIEventManager::getInstance(), SIGNAL(disableAllChanged(bool)), this, SLOT(disable(bool))); + connect(imageButton, SIGNAL(toggled(bool)), RsGUIEventManager::getInstance(), SLOT(SetDisableAll(bool))); disable(isDisable); } diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 0aec1cd2a..130b32775 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -346,7 +346,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); // RsControl::earlyInitNotificationSystem() ; - NotifyQt *notify = NotifyQt::Create(); + RsGUIEventManager::Create(); //rsNotify->registerNotifyClient(notify); /* RetroShare Core Objects */ diff --git a/retroshare-gui/src/util/FontSizeHandler.cpp b/retroshare-gui/src/util/FontSizeHandler.cpp index c184da0de..0dc153e60 100644 --- a/retroshare-gui/src/util/FontSizeHandler.cpp +++ b/retroshare-gui/src/util/FontSizeHandler.cpp @@ -71,7 +71,7 @@ public: data.callback = callback; mWidget.insert(widget, data); - QObject::connect(NotifyQt::getInstance(), &NotifyQt::settingsChanged, widget, [this, widget, callback]() { + QObject::connect(RsGUIEventManager::getInstance(), &RsGUIEventManager::settingsChanged, widget, [this, widget, callback]() { mFontSizeHandlerBase->updateFontSize(widget, callback); }); @@ -93,7 +93,7 @@ public: data.callback = callback; mView.insert(view, data); - QObject::connect(NotifyQt::getInstance(), &NotifyQt::settingsChanged, view, [this, view, iconHeightFactor, callback]() { + QObject::connect(RsGUIEventManager::getInstance(), &RsGUIEventManager::settingsChanged, view, [this, view, iconHeightFactor, callback]() { mFontSizeHandlerBase->updateFontSize(view, iconHeightFactor, callback); }); From b8bb7971717b0128581f34d245a26a8b4b4f16a6 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 11 Nov 2025 19:01:04 +0100 Subject: [PATCH 36/38] fixed compilation --- plugins/FeedReader/gui/FeedReaderDialog.cpp | 2 +- retroshare-gui/src/gui/RsGUIEventManager.cpp | 2 +- retroshare-gui/src/main.cpp | 2 +- retroshare-gui/src/retroshare-gui.pro | 21 ++------------------ 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/plugins/FeedReader/gui/FeedReaderDialog.cpp b/plugins/FeedReader/gui/FeedReaderDialog.cpp index 87db9cf9c..4fa66f6d1 100644 --- a/plugins/FeedReader/gui/FeedReaderDialog.cpp +++ b/plugins/FeedReader/gui/FeedReaderDialog.cpp @@ -73,7 +73,7 @@ FeedReaderDialog::FeedReaderDialog(RsFeedReader *feedReader, FeedReaderNotify *n connect(mNotify, &FeedReaderNotify::feedChanged, this, &FeedReaderDialog::feedChanged, Qt::QueuedConnection); connect(mNotify, &FeedReaderNotify::optimizeImage, this, &FeedReaderDialog::optimizeImage, Qt::QueuedConnection); - connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); + connect(RsGUIEventManager::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); /* connect signals */ connect(ui->feedTreeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(feedTreeItemActivated(QTreeWidgetItem*))); diff --git a/retroshare-gui/src/gui/RsGUIEventManager.cpp b/retroshare-gui/src/gui/RsGUIEventManager.cpp index f7831dfbf..bad13ab9d 100644 --- a/retroshare-gui/src/gui/RsGUIEventManager.cpp +++ b/retroshare-gui/src/gui/RsGUIEventManager.cpp @@ -21,7 +21,6 @@ #include "gui/common/FilesDefs.h" #include -#include "notifyqt.h" #include #include #include @@ -42,6 +41,7 @@ #include "toaster/FriendRequestToaster.h" #include "toaster/ToasterItem.h" #include "common/ToasterNotify.h" +#include "RsGUIEventManager.h" #include "chat/ChatDialog.h" #include "chat/ChatLobbyDialog.h" diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 130b32775..dd343bf03 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -108,7 +108,7 @@ __declspec(dllexport) __cdecl BOOL _OPENSSL_isservice(void) #include #include #include -#include "gui/notifyqt.h" +#include "gui/RsGUIEventManager.h" #include static void showHelp(const argstream& as) diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 4be85fadc..32aa52360 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -371,7 +371,7 @@ HEADERS += rshare.h \ retroshare-gui/configpage.h \ retroshare-gui/RsAutoUpdatePage.h \ retroshare-gui/mainpage.h \ - gui/notifyqt.h \ + gui/RsGUIEventManager.h \ control/bandwidthevent.h \ control/eventtype.h \ gui/QuickStartWizard.h \ @@ -620,22 +620,6 @@ HEADERS += rshare.h \ gui/NetworkDialog/pgpid_item_proxy.h \ gui/common/RsCollection.h \ util/retroshareWin32.h -# gui/ForumsDialog.h \ -# gui/forums/ForumDetails.h \ -# gui/forums/EditForumDetails.h \ -# gui/forums/CreateForum.h \ -# gui/forums/CreateForumMsg.h \ -# gui/forums/ForumUserNotify.h \ -# gui/feeds/ForumNewItem.h \ -# gui/feeds/ForumMsgItem.h \ -# gui/ChannelFeed.h \ -# gui/feeds/ChanNewItem.h \ -# gui/feeds/ChanMsgItem.h \ -# gui/channels/CreateChannel.h \ -# gui/channels/ChannelDetails.h \ -# gui/channels/CreateChannelMsg.h \ -# gui/channels/EditChanDetails.h \ -# gui/channels/ChannelUserNotify.h \ FORMS += gui/StartDialog.ui \ gui/HomePage.ui\ @@ -654,7 +638,6 @@ FORMS += gui/StartDialog.ui \ gui/NetworkView.ui \ gui/FriendsDialog.ui \ gui/ShareManager.ui \ -# gui/ShareDialog.ui \ gui/help/browser/helpbrowser.ui \ gui/HelpDialog.ui \ gui/ServicePermissionDialog.ui \ @@ -761,7 +744,7 @@ FORMS += gui/StartDialog.ui \ SOURCES += main.cpp \ rshare.cpp \ - gui/notifyqt.cpp \ + gui/RsGUIEventManager.cpp \ gui/AboutDialog.cpp \ gui/AboutWidget.cpp \ gui/QuickStartWizard.cpp \ From d3069e9b44e740b968e27d2ce72cf803fff50aa2 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 11 Nov 2025 20:12:53 +0100 Subject: [PATCH 37/38] fixed compilation --- plugins/FeedReader/gui/FeedReaderDialog.cpp | 2 +- plugins/VOIP/gui/VOIPToasterItem.cpp | 2 +- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 1 - retroshare-gui/src/gui/FileTransfer/TransferUserNotify.cpp | 1 - retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp | 1 - retroshare-gui/src/gui/FriendsDialog.cpp | 1 - retroshare-gui/src/gui/HomePage.cpp | 1 - retroshare-gui/src/gui/Identity/IdEditDialog.cpp | 1 - retroshare-gui/src/gui/MainWindow.cpp | 3 +-- retroshare-gui/src/gui/MessengerWindow.cpp | 1 - retroshare-gui/src/gui/NewsFeed.cpp | 1 - retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp | 2 +- retroshare-gui/src/gui/ShareManager.cpp | 1 - retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp | 1 - retroshare-gui/src/gui/chat/ChatStyle.cpp | 2 +- retroshare-gui/src/gui/chat/ChatUserNotify.cpp | 1 - retroshare-gui/src/gui/chat/ChatWidget.cpp | 2 +- retroshare-gui/src/gui/chat/PopupChatDialog.cpp | 1 - retroshare-gui/src/gui/common/AvatarWidget.cpp | 1 - retroshare-gui/src/gui/common/FriendSelectionWidget.cpp | 1 - retroshare-gui/src/gui/common/GroupSelectionBox.cpp | 1 - retroshare-gui/src/gui/common/NewFriendList.cpp | 1 - retroshare-gui/src/gui/connect/ConfCertDialog.cpp | 2 +- retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp | 1 - retroshare-gui/src/gui/connect/PGPKeyDialog.cpp | 1 - retroshare-gui/src/gui/feeds/ChatMsgItem.cpp | 1 - retroshare-gui/src/gui/feeds/GxsCircleItem.cpp | 1 - retroshare-gui/src/gui/feeds/MsgItem.cpp | 1 - retroshare-gui/src/gui/feeds/PeerItem.cpp | 2 -- retroshare-gui/src/gui/feeds/SecurityItem.cpp | 2 -- retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp | 2 +- retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp | 1 - .../src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp | 2 +- retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp | 1 - retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp | 1 - retroshare-gui/src/gui/msgs/MessageComposer.cpp | 1 - retroshare-gui/src/gui/msgs/MessageUserNotify.cpp | 1 - retroshare-gui/src/gui/msgs/MessageWidget.cpp | 1 - retroshare-gui/src/gui/msgs/MessagesDialog.cpp | 1 - retroshare-gui/src/gui/msgs/TagsMenu.cpp | 1 - retroshare-gui/src/gui/settings/AppearancePage.cpp | 2 +- retroshare-gui/src/gui/settings/ChannelPage.cpp | 1 - retroshare-gui/src/gui/settings/ChatPage.cpp | 2 +- retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.cpp | 2 +- retroshare-gui/src/gui/settings/MessagePage.cpp | 2 +- retroshare-gui/src/gui/settings/NotifyPage.cpp | 2 +- retroshare-gui/src/gui/settings/ServerPage.cpp | 1 - retroshare-gui/src/gui/settings/rsettingswin.cpp | 2 +- retroshare-gui/src/gui/statusbar/ToasterDisable.cpp | 2 +- retroshare-gui/src/gui/statusbar/hashingstatus.cpp | 1 - retroshare-gui/src/util/FontSizeHandler.cpp | 2 +- retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp | 1 - 52 files changed, 17 insertions(+), 55 deletions(-) diff --git a/plugins/FeedReader/gui/FeedReaderDialog.cpp b/plugins/FeedReader/gui/FeedReaderDialog.cpp index 4fa66f6d1..3ef2fabbe 100644 --- a/plugins/FeedReader/gui/FeedReaderDialog.cpp +++ b/plugins/FeedReader/gui/FeedReaderDialog.cpp @@ -34,7 +34,7 @@ #include "FeedReaderStringDefs.h" #include "gui/common/RSTreeWidgetItem.h" #include "gui/settings/rsharesettings.h" -#include "gui/notifyqt.h" +#include "gui/RsGUIEventManager.h" #include "FeedReaderUserNotify.h" #include "gui/Posted/PostedCreatePostDialog.h" #include "util/imageutil.h" diff --git a/plugins/VOIP/gui/VOIPToasterItem.cpp b/plugins/VOIP/gui/VOIPToasterItem.cpp index c250f67c3..6468aa34b 100644 --- a/plugins/VOIP/gui/VOIPToasterItem.cpp +++ b/plugins/VOIP/gui/VOIPToasterItem.cpp @@ -27,7 +27,7 @@ /*Retroshare-Gui*/ #include "gui/chat/ChatDialog.h" -#include "gui/notifyqt.h" +#include "gui/RsGUIEventManager.h" #include "util/HandleRichText.h" VOIPToasterItem::VOIPToasterItem(const RsPeerId &peer_id, const QString &msg, const voipToasterItem_Type type) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index 7f2086cf8..529d953fa 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -21,7 +21,6 @@ #include "ChatLobbyWidget.h" -#include "notifyqt.h" #include "RetroShareLink.h" #include "chat/ChatLobbyDialog.h" #include "chat/ChatLobbyUserNotify.h" diff --git a/retroshare-gui/src/gui/FileTransfer/TransferUserNotify.cpp b/retroshare-gui/src/gui/FileTransfer/TransferUserNotify.cpp index fa0c33046..dcb093a7b 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransferUserNotify.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransferUserNotify.cpp @@ -20,7 +20,6 @@ #include "retroshare/rsfiles.h" #include "TransferUserNotify.h" -#include "gui/notifyqt.h" #include "gui/MainWindow.h" TransferUserNotify::TransferUserNotify(QObject *parent) : diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index 0260bb598..ad7e86637 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -20,7 +20,6 @@ #include "TransfersDialog.h" -#include "gui/notifyqt.h" #include "gui/SoundManager.h" #include "gui/RetroShareLink.h" #include "gui/common/FilesDefs.h" diff --git a/retroshare-gui/src/gui/FriendsDialog.cpp b/retroshare-gui/src/gui/FriendsDialog.cpp index 0a2707179..3bc7965e4 100644 --- a/retroshare-gui/src/gui/FriendsDialog.cpp +++ b/retroshare-gui/src/gui/FriendsDialog.cpp @@ -34,7 +34,6 @@ #include "groups/CreateGroup.h" #include "MainWindow.h" #include "NewsFeed.h" -#include "notifyqt.h" #include "profile/ProfileWidget.h" #include "profile/StatusMessage.h" #include "RetroShareLink.h" diff --git a/retroshare-gui/src/gui/HomePage.cpp b/retroshare-gui/src/gui/HomePage.cpp index 89e1ac120..115281538 100644 --- a/retroshare-gui/src/gui/HomePage.cpp +++ b/retroshare-gui/src/gui/HomePage.cpp @@ -26,7 +26,6 @@ #include "util/qtthreadsutils.h" #include "util/misc.h" -#include "gui/notifyqt.h" #include "gui/common/FilesDefs.h" #include "gui/msgs/MessageComposer.h" #include "gui/connect/ConnectFriendWizard.h" diff --git a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp index 6e3b015b0..bb8530a05 100644 --- a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp @@ -29,7 +29,6 @@ #include "gui/gxs/GxsIdDetails.h" #include "util/qtthreadsutils.h" #include "util/misc.h" -#include "gui/notifyqt.h" #include "retroshare/rsidentity.h" #include "retroshare/rspeers.h" diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index fb337321b..a1688867d 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -67,7 +67,6 @@ #include "chat/ChatDialog.h" #include "RetroShareLink.h" #include "SoundManager.h" -#include "notifyqt.h" #include "common/UserNotify.h" #include "gui/ServicePermissionDialog.h" @@ -122,11 +121,11 @@ #include "gui/statistics/StatisticsWindow.h" #include "gui/connect/ConnectFriendWizard.h" +#include "gui/RsGUIEventManager.h" #include "gui/common/RsCollectionDialog.h" #include "settings/rsettingswin.h" #include "settings/rsharesettings.h" #include "common/StatusDefs.h" -#include "gui/notifyqt.h" #ifdef RS_WEBUI # include "settings/WebuiPage.h" diff --git a/retroshare-gui/src/gui/MessengerWindow.cpp b/retroshare-gui/src/gui/MessengerWindow.cpp index 5e13ab271..fca08966f 100644 --- a/retroshare-gui/src/gui/MessengerWindow.cpp +++ b/retroshare-gui/src/gui/MessengerWindow.cpp @@ -36,7 +36,6 @@ #include "MainWindow.h" #include "ShareManager.h" -#include "notifyqt.h" #include "connect/ConnectFriendWizard.h" #include "util/PixmapMerging.h" #include "util/qtthreadsutils.h" diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index 18f087f27..d509deab8 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -57,7 +57,6 @@ #include "msgs/MessageInterface.h" #include "common/FeedNotify.h" -#include "notifyqt.h" #define ROLE_RECEIVED FEED_TREEWIDGET_SORTROLE diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index a674e5035..625f743a7 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -37,8 +37,8 @@ #include "gui/common/UIStateHelper.h" #include "gui/common/RSTabWidget.h" #include "gui/settings/rsharesettings.h" +#include "gui/RsGUIEventManager.h" #include "gui/feeds/SubFileItem.h" -#include "gui/notifyqt.h" #include "gui/Identity/IdDialog.h" #include "gui/RetroShareLink.h" #include "util/HandleRichText.h" diff --git a/retroshare-gui/src/gui/ShareManager.cpp b/retroshare-gui/src/gui/ShareManager.cpp index 50c708fcf..d4426d3ae 100644 --- a/retroshare-gui/src/gui/ShareManager.cpp +++ b/retroshare-gui/src/gui/ShareManager.cpp @@ -35,7 +35,6 @@ #include "gui/common/GroupFlagsWidget.h" #include "gui/common/GroupSelectionBox.h" #include "gui/common/GroupDefs.h" -#include "gui/notifyqt.h" #include "util/RsQtVersion.h" #include "util/misc.h" #include "util/qtthreadsutils.h" diff --git a/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp b/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp index c15d6d0b4..13957fffe 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp @@ -28,7 +28,6 @@ #include "gui/ChatLobbyWidget.h" #include "gui/MainWindow.h" -#include "gui/notifyqt.h" #include "gui/SoundManager.h" #include "gui/settings/rsharesettings.h" #include "util/DateTime.h" diff --git a/retroshare-gui/src/gui/chat/ChatStyle.cpp b/retroshare-gui/src/gui/chat/ChatStyle.cpp index 8eca138ad..97759e837 100644 --- a/retroshare-gui/src/gui/chat/ChatStyle.cpp +++ b/retroshare-gui/src/gui/chat/ChatStyle.cpp @@ -107,7 +107,7 @@ #include "ChatStyle.h" #include "gui/settings/rsharesettings.h" -#include "gui/notifyqt.h" +#include "gui/RsGUIEventManager.h" #include "util/DateTime.h" #include "util/HandleRichText.h" diff --git a/retroshare-gui/src/gui/chat/ChatUserNotify.cpp b/retroshare-gui/src/gui/chat/ChatUserNotify.cpp index 8d7aa6a8d..3cfdd9b88 100644 --- a/retroshare-gui/src/gui/chat/ChatUserNotify.cpp +++ b/retroshare-gui/src/gui/chat/ChatUserNotify.cpp @@ -22,7 +22,6 @@ #include "gui/common/FilesDefs.h" #include "ChatUserNotify.h" -#include "gui/notifyqt.h" #include "gui/MainWindow.h" #include "gui/chat/ChatDialog.h" #include "gui/settings/rsharesettings.h" diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index f278f4400..3f61badda 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -23,7 +23,6 @@ #include "ui_ChatWidget.h" #include "gui/MainWindow.h" -#include "gui/notifyqt.h" #include "gui/RetroShareLink.h" #include "gui/settings/rsharesettings.h" #include "gui/settings/rsettingswin.h" @@ -33,6 +32,7 @@ #include "gui/common/Emoticons.h" #include "gui/chat/ChatLobbyDialog.h" #include "gui/gxs/GxsIdDetails.h" +#include "gui/RsGUIEventManager.h" #include "util/misc.h" #include "util/qtthreadsutils.h" #include "util/HandleRichText.h" diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 261534513..b16a7e226 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -26,7 +26,6 @@ #include "gui/common/FilesDefs.h" #include "gui/settings/rsharesettings.h" #include "gui/settings/RsharePeerSettings.h" -#include "gui/notifyqt.h" #include "util/DateTime.h" #include "util/qtthreadsutils.h" diff --git a/retroshare-gui/src/gui/common/AvatarWidget.cpp b/retroshare-gui/src/gui/common/AvatarWidget.cpp index 006076beb..b19917c8b 100644 --- a/retroshare-gui/src/gui/common/AvatarWidget.cpp +++ b/retroshare-gui/src/gui/common/AvatarWidget.cpp @@ -25,7 +25,6 @@ #include #include -#include "gui/notifyqt.h" #include "util/misc.h" #include "util/qtthreadsutils.h" #include "gui/common/AvatarDefs.h" diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index 962927c99..e792518f0 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -25,7 +25,6 @@ #include "ui_FriendSelectionWidget.h" #include "gui/gxs/GxsIdDetails.h" #include -#include "gui/notifyqt.h" #include "gui/common/RSTreeWidgetItem.h" #include "gui/common/StatusDefs.h" #include "util/qtthreadsutils.h" diff --git a/retroshare-gui/src/gui/common/GroupSelectionBox.cpp b/retroshare-gui/src/gui/common/GroupSelectionBox.cpp index 05f18d622..469dd9db2 100644 --- a/retroshare-gui/src/gui/common/GroupSelectionBox.cpp +++ b/retroshare-gui/src/gui/common/GroupSelectionBox.cpp @@ -23,7 +23,6 @@ #include #include "GroupSelectionBox.h" #include "GroupDefs.h" -#include "gui/notifyqt.h" #include "util/qtthreadsutils.h" #include diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index ecc2f68db..22f960a9d 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -54,7 +54,6 @@ #include "gui/chat/ChatUserNotify.h" #include "gui/connect/ConnectProgressDialog.h" #include "gui/common/ElidedLabel.h" -#include "gui/notifyqt.h" #include "NewFriendList.h" #include "ui_NewFriendList.h" diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp index 6a407cb49..32eeaebae 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -38,7 +39,6 @@ #include "gui/common/PeerDefs.h" #include "gui/common/StatusDefs.h" #include "gui/RetroShareLink.h" -#include "gui/notifyqt.h" #include "gui/common/AvatarDefs.h" #include "gui/common/FilesDefs.h" #include "gui/MainWindow.h" diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index b27bce36d..efdf4cd15 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -41,7 +41,6 @@ #include "ui_ConnectFriendWizard.h" #include "gui/common/PeerDefs.h" #include "gui/connect/ConfCertDialog.h" -#include "gui/notifyqt.h" #include "gui/common/GroupDefs.h" #include "gui/msgs/MessageComposer.h" diff --git a/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp b/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp index 3277dff30..ce410f47e 100644 --- a/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp +++ b/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp @@ -40,7 +40,6 @@ #include "gui/common/PeerDefs.h" #include "gui/common/StatusDefs.h" #include "gui/RetroShareLink.h" -#include "gui/notifyqt.h" #include "gui/common/AvatarDefs.h" #include "gui/MainWindow.h" #include "util/DateTime.h" diff --git a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp index 573c65c9d..07d2f696d 100644 --- a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp @@ -30,7 +30,6 @@ #include "gui/common/AvatarDefs.h" #include "gui/settings/rsharesettings.h" -#include "gui/notifyqt.h" #include #include diff --git a/retroshare-gui/src/gui/feeds/GxsCircleItem.cpp b/retroshare-gui/src/gui/feeds/GxsCircleItem.cpp index aacfb4129..99825a078 100644 --- a/retroshare-gui/src/gui/feeds/GxsCircleItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsCircleItem.cpp @@ -22,7 +22,6 @@ #include "ui_GxsCircleItem.h" #include "FeedHolder.h" -#include "gui/notifyqt.h" #include "gui/Circles/CreateCircleDialog.h" #include "gui/gxs/GxsIdDetails.h" #include "gui/common/FilesDefs.h" diff --git a/retroshare-gui/src/gui/feeds/MsgItem.cpp b/retroshare-gui/src/gui/feeds/MsgItem.cpp index 0789d98c9..f1e7a8a69 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/MsgItem.cpp @@ -30,7 +30,6 @@ #include "util/DateTime.h" #include "gui/common/AvatarDefs.h" #include "gui/common/FilesDefs.h" -#include "gui/notifyqt.h" #include "util/qtthreadsutils.h" #include diff --git a/retroshare-gui/src/gui/feeds/PeerItem.cpp b/retroshare-gui/src/gui/feeds/PeerItem.cpp index 61e3191d1..f21f26c86 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.cpp +++ b/retroshare-gui/src/gui/feeds/PeerItem.cpp @@ -31,8 +31,6 @@ #include "util/qtthreadsutils.h" #include "util/DateTime.h" -#include "gui/notifyqt.h" - #include #include #include diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.cpp b/retroshare-gui/src/gui/feeds/SecurityItem.cpp index 9fa5514b2..bf9e0dce6 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityItem.cpp @@ -35,8 +35,6 @@ #include "util/DateTime.h" #include "util/qtthreadsutils.h" -#include "gui/notifyqt.h" - #include #include diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index 750d714ed..2a57147b6 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -31,9 +31,9 @@ #include "gui/gxs/GxsGroupShareKey.h" #include "gui/common/GroupTreeWidget.h" #include "gui/common/RSTreeWidget.h" -#include "gui/notifyqt.h" #include "gui/common/UIStateHelper.h" #include "gui/common/UserNotify.h" +#include "gui/RsGUIEventManager.h" #include "util/qtthreadsutils.h" #include "retroshare/rsgxsifacetypes.h" #include "GxsCommentDialog.h" diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp index b5d8b4ffc..31dcc25a1 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp @@ -32,7 +32,6 @@ #include "gui/gxs/GxsGroupShareKey.h" #include "gui/feeds/GxsChannelPostItem.h" #include "gui/settings/rsharesettings.h" -#include "gui/notifyqt.h" #include "gui/common/GroupTreeWidget.h" #include "util/qtthreadsutils.h" #include "util/misc.h" diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index a95b42b15..aa0525745 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -30,12 +30,12 @@ #include "gui/feeds/GxsChannelPostItem.h" #include "gui/gxs/GxsIdDetails.h" #include "gui/gxs/GxsGroupFrameDialog.h" +#include "gui/RsGUIEventManager.h" #include "util/misc.h" #include "gui/gxschannels/CreateGxsChannelMsg.h" #include "gui/common/UIStateHelper.h" #include "gui/settings/rsharesettings.h" #include "gui/feeds/SubFileItem.h" -#include "gui/notifyqt.h" #include "gui/RetroShareLink.h" #include "util/HandleRichText.h" #include "util/DateTime.h" diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp index 5733d5a39..a8a9f2b0a 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp @@ -23,7 +23,6 @@ #include "GxsForumThreadWidget.h" #include "CreateGxsForumMsg.h" #include "GxsForumUserNotify.h" -#include "gui/notifyqt.h" #include "gui/common/GroupTreeWidget.h" #include "gui/gxs/GxsGroupShareKey.h" #include "util/misc.h" diff --git a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp index fd4f6f9ba..8f006906a 100644 --- a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp +++ b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp @@ -39,7 +39,6 @@ #include #include #include "gui/settings/rsharesettings.h" -#include "gui/notifyqt.h" #include "util/DateTime.h" #define ROLE_MSGID Qt::UserRole diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 41d55d9f2..de8863449 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -51,7 +51,6 @@ #include #include -#include "gui/notifyqt.h" #include "gui/common/RSTreeWidgetItem.h" #include "gui/common/GroupDefs.h" #include "gui/common/StatusDefs.h" diff --git a/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp b/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp index ed4ad1dd6..dc338db3e 100644 --- a/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp +++ b/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp @@ -20,7 +20,6 @@ #include "gui/common/FilesDefs.h" #include "MessageUserNotify.h" -#include "gui/notifyqt.h" #include "gui/MainWindow.h" #include "util/qtthreadsutils.h" #include "gui/settings/rsharesettings.h" diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.cpp b/retroshare-gui/src/gui/msgs/MessageWidget.cpp index bcbdaf219..2f81b749d 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWidget.cpp @@ -31,7 +31,6 @@ #include #include -#include "gui/notifyqt.h" #include "gui/RetroShareLink.h" #include "gui/common/TagDefs.h" #include "gui/common/PeerDefs.h" diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index 22eb0f88b..f678adeb4 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -27,7 +27,6 @@ #include "MessagesDialog.h" -#include "gui/notifyqt.h" #include "gui/common/TagDefs.h" #include "gui/common/PeerDefs.h" #include "gui/common/RSElidedItemDelegate.h" diff --git a/retroshare-gui/src/gui/msgs/TagsMenu.cpp b/retroshare-gui/src/gui/msgs/TagsMenu.cpp index 881ec268d..986416514 100644 --- a/retroshare-gui/src/gui/msgs/TagsMenu.cpp +++ b/retroshare-gui/src/gui/msgs/TagsMenu.cpp @@ -29,7 +29,6 @@ #include "TagsMenu.h" #include "gui/common/TagDefs.h" #include "gui/settings/NewTag.h" -#include "gui/notifyqt.h" #include "util/qtthreadsutils.h" #include "gui/msgs/MessageInterface.h" diff --git a/retroshare-gui/src/gui/settings/AppearancePage.cpp b/retroshare-gui/src/gui/settings/AppearancePage.cpp index e9e32af47..0a767a20f 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.cpp +++ b/retroshare-gui/src/gui/settings/AppearancePage.cpp @@ -22,7 +22,7 @@ #include "rshare.h" #include "gui/MainWindow.h" -#include "gui/notifyqt.h" +#include "gui/RsGUIEventManager.h" #include "gui/common/FilesDefs.h" #include "gui/settings/rsharesettings.h" #include "gui/statusbar/peerstatus.h" diff --git a/retroshare-gui/src/gui/settings/ChannelPage.cpp b/retroshare-gui/src/gui/settings/ChannelPage.cpp index 857cc972e..2a5f413d2 100644 --- a/retroshare-gui/src/gui/settings/ChannelPage.cpp +++ b/retroshare-gui/src/gui/settings/ChannelPage.cpp @@ -21,7 +21,6 @@ #include "ChannelPage.h" #include "rsharesettings.h" #include "util/misc.h" -#include "gui/notifyqt.h" #include "retroshare/rsgxschannels.h" ChannelPage::ChannelPage(QWidget * parent, Qt::WindowFlags flags) diff --git a/retroshare-gui/src/gui/settings/ChatPage.cpp b/retroshare-gui/src/gui/settings/ChatPage.cpp index a319d4b6c..344257480 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.cpp +++ b/retroshare-gui/src/gui/settings/ChatPage.cpp @@ -22,7 +22,7 @@ #include "rsharesettings.h" #include "gui/MainWindow.h" -#include "gui/notifyqt.h" +#include "gui/RsGUIEventManager.h" #include "gui/RetroShareLink.h" #include "gui/chat/ChatDialog.h" #include "util/misc.h" diff --git a/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.cpp b/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.cpp index c3aadbf3a..2ea51fd57 100644 --- a/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.cpp +++ b/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.cpp @@ -20,8 +20,8 @@ #include -#include "gui/notifyqt.h" #include "util/misc.h" +#include "gui/RsGUIEventManager.h" #include "GroupFrameSettingsWidget.h" #include "ui_GroupFrameSettingsWidget.h" diff --git a/retroshare-gui/src/gui/settings/MessagePage.cpp b/retroshare-gui/src/gui/settings/MessagePage.cpp index 283be7bef..ac16048b2 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.cpp +++ b/retroshare-gui/src/gui/settings/MessagePage.cpp @@ -27,10 +27,10 @@ #include "MessagePage.h" #include "util/misc.h" #include "gui/common/TagDefs.h" +#include "gui/RsGUIEventManager.h" #include #include "NewTag.h" #include "util/qtthreadsutils.h" -#include "gui/notifyqt.h" MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags) : ConfigPage(parent, flags) diff --git a/retroshare-gui/src/gui/settings/NotifyPage.cpp b/retroshare-gui/src/gui/settings/NotifyPage.cpp index ba37d1f82..189a93cc2 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.cpp +++ b/retroshare-gui/src/gui/settings/NotifyPage.cpp @@ -25,11 +25,11 @@ #include "rsharesettings.h" #include "gui/MainWindow.h" +#include "gui/RsGUIEventManager.h" #include "gui/common/UserNotify.h" #include "gui/common/FeedNotify.h" #include "gui/common/ToasterNotify.h" #include "gui/feeds/FeedItem.h" -#include "gui/notifyqt.h" #include "gui/NewsFeed.h" #include "util/misc.h" diff --git a/retroshare-gui/src/gui/settings/ServerPage.cpp b/retroshare-gui/src/gui/settings/ServerPage.cpp index 998755007..9fba74a84 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.cpp +++ b/retroshare-gui/src/gui/settings/ServerPage.cpp @@ -20,7 +20,6 @@ #include "ServerPage.h" -#include #include "gui/MainWindow.h" #include "rshare.h" #include "rsharesettings.h" diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp index b0e5064ff..98c6dbdcb 100644 --- a/retroshare-gui/src/gui/settings/rsettingswin.cpp +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -40,7 +40,7 @@ #include "PluginsPage.h" #include "ServicePermissionsPage.h" #include "rsharesettings.h" -#include "gui/notifyqt.h" +#include "gui/RsGUIEventManager.h" #include "gui/common/FloatingHelpBrowser.h" #include "gui/common/RSElidedItemDelegate.h" diff --git a/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp b/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp index d92b58220..2bfa458bd 100644 --- a/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp +++ b/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp @@ -22,7 +22,7 @@ #include #include "ToasterDisable.h" -#include "gui/notifyqt.h" +#include "gui/RsGUIEventManager.h" #include "gui/common/FilesDefs.h" #define IMAGE_TOASTERDISABLE ":/images/toasterDisable.png" diff --git a/retroshare-gui/src/gui/statusbar/hashingstatus.cpp b/retroshare-gui/src/gui/statusbar/hashingstatus.cpp index 8638acb3e..fdbb5c4fa 100644 --- a/retroshare-gui/src/gui/statusbar/hashingstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/hashingstatus.cpp @@ -28,7 +28,6 @@ #include "gui/common/ElidedLabel.h" #include "util/qtthreadsutils.h" #include "util/misc.h" -#include "gui/notifyqt.h" #include "gui/common/FilesDefs.h" //#define DEBUG_HASHING_STATUS 1 diff --git a/retroshare-gui/src/util/FontSizeHandler.cpp b/retroshare-gui/src/util/FontSizeHandler.cpp index 0dc153e60..51da29032 100644 --- a/retroshare-gui/src/util/FontSizeHandler.cpp +++ b/retroshare-gui/src/util/FontSizeHandler.cpp @@ -25,7 +25,7 @@ #include "rshare.h" #include "FontSizeHandler.h" #include "gui/settings/rsharesettings.h" -#include "gui/notifyqt.h" +#include "gui/RsGUIEventManager.h" // Data for QAbstractItemView struct FontSizeHandlerWidgetData diff --git a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp index c228923e8..906388cc2 100644 --- a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp +++ b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp @@ -21,7 +21,6 @@ #include #include "RsGxsUpdateBroadcast.h" -#include "gui/notifyqt.h" #include "util/qtthreadsutils.h" #include From 28a5db7204ff216bd03c99d9d32b691ff5cb3583 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 24 Nov 2025 21:09:45 +0100 Subject: [PATCH 38/38] fixed compilation for feed reader plugin --- plugins/FeedReader/gui/FeedReaderDialog.cpp | 8 +-- plugins/FeedReader/gui/FeedReaderDialog.h | 6 +-- .../FeedReader/gui/FeedReaderFeedNotify.cpp | 2 +- .../gui/FeedReaderMessageWidget.cpp | 14 ++--- plugins/FeedReader/gui/FeedReaderNotify.h | 7 +++ .../FeedReader/gui/FeedReaderUserNotify.cpp | 2 +- plugins/FeedReader/gui/PreviewFeedDialog.cpp | 10 ++-- plugins/FeedReader/services/p3FeedReader.cc | 53 ++++++++++--------- plugins/FeedReader/services/p3FeedReader.h | 4 +- 9 files changed, 57 insertions(+), 49 deletions(-) diff --git a/plugins/FeedReader/gui/FeedReaderDialog.cpp b/plugins/FeedReader/gui/FeedReaderDialog.cpp index 3ef2fabbe..b560ed2f6 100644 --- a/plugins/FeedReader/gui/FeedReaderDialog.cpp +++ b/plugins/FeedReader/gui/FeedReaderDialog.cpp @@ -570,7 +570,7 @@ void FeedReaderDialog::feedChanged(uint32_t feedId, int type) } FeedInfo feedInfo; - if (type != NOTIFY_TYPE_DEL) { + if (type != FeedReaderNotify::NOTIFY_TYPE_DEL) { if (!mFeedReader->getFeedInfo(feedId, feedInfo)) { return; } @@ -580,12 +580,12 @@ void FeedReaderDialog::feedChanged(uint32_t feedId, int type) } } - if (type == NOTIFY_TYPE_MOD || type == NOTIFY_TYPE_DEL) { + if (type == FeedReaderNotify::NOTIFY_TYPE_MOD || type == FeedReaderNotify::NOTIFY_TYPE_DEL) { QTreeWidgetItemIterator it(ui->feedTreeWidget); QTreeWidgetItem *item; while ((item = *it) != NULL) { if (item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt() == feedId) { - if (type == NOTIFY_TYPE_MOD) { + if (type == FeedReaderNotify::NOTIFY_TYPE_MOD) { updateFeedItem(item, feedInfo); } else { delete(item); @@ -596,7 +596,7 @@ void FeedReaderDialog::feedChanged(uint32_t feedId, int type) } } - if (type == NOTIFY_TYPE_ADD) { + if (type == FeedReaderNotify::NOTIFY_TYPE_ADD) { QTreeWidgetItemIterator it(ui->feedTreeWidget); QTreeWidgetItem *itemParent; while ((itemParent = *it) != NULL) { diff --git a/plugins/FeedReader/gui/FeedReaderDialog.h b/plugins/FeedReader/gui/FeedReaderDialog.h index a9672bc76..ab9b61007 100644 --- a/plugins/FeedReader/gui/FeedReaderDialog.h +++ b/plugins/FeedReader/gui/FeedReaderDialog.h @@ -40,15 +40,15 @@ class FeedReaderDialog : public MainPage Q_OBJECT public: - FeedReaderDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent = 0); + FeedReaderDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent = 0); ~FeedReaderDialog(); static QIcon iconFromFeed(const FeedInfo &feedInfo); protected: virtual UserNotify *createUserNotify(QObject *parent) override; - virtual void showEvent(QShowEvent *event); - bool eventFilter(QObject *obj, QEvent *ev); + virtual void showEvent(QShowEvent *event) override; + bool eventFilter(QObject *obj, QEvent *ev) override; private slots: void settingsChanged(); diff --git a/plugins/FeedReader/gui/FeedReaderFeedNotify.cpp b/plugins/FeedReader/gui/FeedReaderFeedNotify.cpp index 566229311..424e74ff6 100644 --- a/plugins/FeedReader/gui/FeedReaderFeedNotify.cpp +++ b/plugins/FeedReader/gui/FeedReaderFeedNotify.cpp @@ -72,7 +72,7 @@ void FeedReaderFeedNotify::msgChanged(uint32_t feedId, const QString &msgId, int return; } - if (type != NOTIFY_TYPE_ADD) { + if (type != FeedReaderNotify::NOTIFY_TYPE_ADD) { return; } diff --git a/plugins/FeedReader/gui/FeedReaderMessageWidget.cpp b/plugins/FeedReader/gui/FeedReaderMessageWidget.cpp index db2b73709..b97aa4e8e 100644 --- a/plugins/FeedReader/gui/FeedReaderMessageWidget.cpp +++ b/plugins/FeedReader/gui/FeedReaderMessageWidget.cpp @@ -515,12 +515,12 @@ void FeedReaderMessageWidget::feedChanged(uint32_t feedId, int type) return; } - if (type == NOTIFY_TYPE_DEL) { + if (type == FeedReaderNotify::NOTIFY_TYPE_DEL) { setFeedId(0); return; } - if (type == NOTIFY_TYPE_MOD) { + if (type == FeedReaderNotify::NOTIFY_TYPE_MOD) { if (!mFeedReader->getFeedInfo(mFeedId, mFeedInfo)) { setFeedId(0); return; @@ -555,18 +555,18 @@ void FeedReaderMessageWidget::msgChanged(uint32_t feedId, const QString &msgId, } FeedMsgInfo msgInfo; - if (type != NOTIFY_TYPE_DEL) { + if (type != FeedReaderNotify::NOTIFY_TYPE_DEL) { if (!mFeedReader->getMsgInfo(feedId, msgId.toStdString(), msgInfo)) { return; } } - if (type == NOTIFY_TYPE_MOD || type == NOTIFY_TYPE_DEL) { + if (type == FeedReaderNotify::NOTIFY_TYPE_MOD || type == FeedReaderNotify::NOTIFY_TYPE_DEL) { QTreeWidgetItemIterator it(ui->msgTreeWidget); QTreeWidgetItem *item; while ((item = *it) != NULL) { if (item->data(COLUMN_MSG_DATA, ROLE_MSG_ID).toString() == msgId) { - if (type == NOTIFY_TYPE_MOD) { + if (type == FeedReaderNotify::NOTIFY_TYPE_MOD) { updateMsgItem(item, msgInfo); filterItem(item); } else { @@ -578,13 +578,13 @@ void FeedReaderMessageWidget::msgChanged(uint32_t feedId, const QString &msgId, } } - if (type == NOTIFY_TYPE_MOD) { + if (type == FeedReaderNotify::NOTIFY_TYPE_MOD) { if (msgId.toStdString() == currentMsgId()) { updateCurrentMessage(); } } - if (type == NOTIFY_TYPE_ADD) { + if (type == FeedReaderNotify::NOTIFY_TYPE_ADD) { QTreeWidgetItem *item = new RSTreeWidgetItem(mMsgCompareRole); updateMsgItem(item, msgInfo); ui->msgTreeWidget->addTopLevelItem(item); diff --git a/plugins/FeedReader/gui/FeedReaderNotify.h b/plugins/FeedReader/gui/FeedReaderNotify.h index 5913f1985..723f94f64 100644 --- a/plugins/FeedReader/gui/FeedReaderNotify.h +++ b/plugins/FeedReader/gui/FeedReaderNotify.h @@ -29,6 +29,13 @@ class FeedReaderNotify : public QObject, public RsFeedReaderNotify Q_OBJECT public: + // These replace the variables from the old notify system. It's simpler than switching the entire + // feedreader plugin to the new rsEvents system + + static const int NOTIFY_TYPE_ADD = 0x01; + static const int NOTIFY_TYPE_DEL = 0x02; + static const int NOTIFY_TYPE_MOD = 0x03; + FeedReaderNotify(); /* RsFeedReaderNotify */ diff --git a/plugins/FeedReader/gui/FeedReaderUserNotify.cpp b/plugins/FeedReader/gui/FeedReaderUserNotify.cpp index 68c23a7c6..8d0ea2194 100644 --- a/plugins/FeedReader/gui/FeedReaderUserNotify.cpp +++ b/plugins/FeedReader/gui/FeedReaderUserNotify.cpp @@ -67,7 +67,7 @@ void FeedReaderUserNotify::iconClicked() void FeedReaderUserNotify::feedChanged(uint32_t /*feedId*/, int type) { - if (type == NOTIFY_TYPE_DEL) { + if (type == FeedReaderNotify::NOTIFY_TYPE_DEL) { updateIcon(); } } diff --git a/plugins/FeedReader/gui/PreviewFeedDialog.cpp b/plugins/FeedReader/gui/PreviewFeedDialog.cpp index ea582c04f..44d27a297 100644 --- a/plugins/FeedReader/gui/PreviewFeedDialog.cpp +++ b/plugins/FeedReader/gui/PreviewFeedDialog.cpp @@ -294,13 +294,13 @@ void PreviewFeedDialog::feedChanged(uint32_t feedId, int type) return; } - if (type == NOTIFY_TYPE_DEL) { + if (type == FeedReaderNotify::NOTIFY_TYPE_DEL) { /* feed deleted */ mFeedId = 0; return; } - if (type == NOTIFY_TYPE_ADD || type == NOTIFY_TYPE_MOD) { + if (type == FeedReaderNotify::NOTIFY_TYPE_ADD || type == FeedReaderNotify::NOTIFY_TYPE_MOD) { FeedInfo feedInfo; if (!mFeedReader->getFeedInfo(mFeedId, feedInfo)) { return; @@ -320,18 +320,18 @@ void PreviewFeedDialog::msgChanged(uint32_t feedId, const QString &msgId, int ty } switch (type) { - case NOTIFY_TYPE_ADD: + case FeedReaderNotify::NOTIFY_TYPE_ADD: if (mMsgId.empty()) { mMsgId = msgId.toStdString(); updateMsg(); } break; - case NOTIFY_TYPE_MOD: + case FeedReaderNotify::NOTIFY_TYPE_MOD: if (mMsgId == msgId.toStdString()) { updateMsg(); } break; - case NOTIFY_TYPE_DEL: + case FeedReaderNotify::NOTIFY_TYPE_DEL: if (mMsgId == msgId.toStdString()) { std::list::iterator it = std::find(mMsgIds.begin(), mMsgIds.end(), mMsgId); if (it != mMsgIds.end()) { diff --git a/plugins/FeedReader/services/p3FeedReader.cc b/plugins/FeedReader/services/p3FeedReader.cc index 3e46a027c..10d54ac08 100644 --- a/plugins/FeedReader/services/p3FeedReader.cc +++ b/plugins/FeedReader/services/p3FeedReader.cc @@ -20,6 +20,7 @@ #include "rsFeedReaderItems.h" #include "p3FeedReader.h" +#include "gui/FeedReaderNotify.h" #include "p3FeedReaderThread.h" #include "rsitems/rsconfigitems.h" #include "retroshare/rsiface.h" @@ -415,7 +416,7 @@ RsFeedResult p3FeedReader::addFolder(uint32_t parentId, const std::string &name, IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW); if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_ADD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_ADD); } return RS_FEED_RESULT_SUCCESS; @@ -455,7 +456,7 @@ RsFeedResult p3FeedReader::setFolder(uint32_t feedId, const std::string &name) IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW); if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } return RS_FEED_RESULT_SUCCESS; @@ -502,7 +503,7 @@ RsFeedResult p3FeedReader::addFeed(const FeedInfo &feedInfo, uint32_t &feedId) IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW); if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_ADD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_ADD); } return RS_FEED_RESULT_SUCCESS; @@ -587,7 +588,7 @@ RsFeedResult p3FeedReader::setFeed(uint32_t feedId, const FeedInfo &feedInfo) IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW); if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } if (!forumId.empty()) { @@ -658,7 +659,7 @@ RsFeedResult p3FeedReader::setParent(uint32_t feedId, uint32_t parentId) IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW); if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } } @@ -756,7 +757,7 @@ bool p3FeedReader::removeFeed(uint32_t feedId) /* only notify remove of feed */ std::list::iterator it; for (it = removedFeedIds.begin(); it != removedFeedIds.end(); ++it) { - mNotify->notifyFeedChanged(*it, NOTIFY_TYPE_DEL); + mNotify->notifyFeedChanged(*it, FeedReaderNotify::NOTIFY_TYPE_DEL); } } @@ -803,7 +804,7 @@ bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, uint32_t &feedId) } if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_ADD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_ADD); } { @@ -925,8 +926,8 @@ bool p3FeedReader::removeMsg(uint32_t feedId, const std::string &msgId) } if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); - mNotify->notifyMsgChanged(feedId, msgId, NOTIFY_TYPE_DEL); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); + mNotify->notifyMsgChanged(feedId, msgId, FeedReaderNotify::NOTIFY_TYPE_DEL); } return true; @@ -977,11 +978,11 @@ bool p3FeedReader::removeMsgs(uint32_t feedId, const std::list &msg } if (mNotify && !removedMsgs.empty()) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); std::list::iterator it; for (it = removedMsgs.begin(); it != removedMsgs.end(); ++it) { - mNotify->notifyMsgChanged(feedId, *it, NOTIFY_TYPE_DEL); + mNotify->notifyMsgChanged(feedId, *it, FeedReaderNotify::NOTIFY_TYPE_DEL); } } @@ -1224,7 +1225,7 @@ bool p3FeedReader::processFeed(uint32_t feedId) if (mNotify) { for (it = notifyIds.begin(); it != notifyIds.end(); ++it) { - mNotify->notifyFeedChanged(*it, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(*it, FeedReaderNotify::NOTIFY_TYPE_MOD); } } @@ -1273,8 +1274,8 @@ bool p3FeedReader::setMessageRead(uint32_t feedId, const std::string &msgId, boo if (changed) { IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_OFTEN); if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); - mNotify->notifyMsgChanged(feedId, msgId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); + mNotify->notifyMsgChanged(feedId, msgId, FeedReaderNotify::NOTIFY_TYPE_MOD); } } @@ -1328,10 +1329,10 @@ bool p3FeedReader::retransformMsg(uint32_t feedId, const std::string &msgId) IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW); if (mNotify) { if (feedChanged) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } if (msgChanged) { - mNotify->notifyMsgChanged(feedId, msgId, NOTIFY_TYPE_MOD); + mNotify->notifyMsgChanged(feedId, msgId, FeedReaderNotify::NOTIFY_TYPE_MOD); } } } @@ -1466,7 +1467,7 @@ int p3FeedReader::tick() if (mNotify) { for (it = notifyIds.begin(); it != notifyIds.end(); ++it) { - mNotify->notifyFeedChanged(*it, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(*it, FeedReaderNotify::NOTIFY_TYPE_MOD); } if (imageToOptimze) { mNotify->notifyOptimizeImage(); @@ -1526,7 +1527,7 @@ void p3FeedReader::cleanFeeds() if (mNotify) { std::list >::iterator it; for (it = removedMsgIds.begin(); it != removedMsgIds.end(); ++it) { - mNotify->notifyMsgChanged(it->first, it->second, NOTIFY_TYPE_DEL); + mNotify->notifyMsgChanged(it->first, it->second, FeedReaderNotify::NOTIFY_TYPE_DEL); } } } @@ -1801,7 +1802,7 @@ bool p3FeedReader::getFeedToDownload(RsFeedReaderFeed &feed, uint32_t neededFeed } if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } return true; @@ -1852,7 +1853,7 @@ void p3FeedReader::onDownloadSuccess(uint32_t feedId, const std::string &content } if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } } @@ -1889,7 +1890,7 @@ void p3FeedReader::onDownloadError(uint32_t feedId, RsFeedReaderErrorState resul } if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } } @@ -1944,7 +1945,7 @@ bool p3FeedReader::getFeedToProcess(RsFeedReaderFeed &feed, uint32_t neededFeedI } if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } return true; @@ -2323,11 +2324,11 @@ void p3FeedReader::onProcessSuccess_addMsgs(uint32_t feedId, std::listnotifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); std::list::iterator it; for (it = addedMsgs.begin(); it != addedMsgs.end(); ++it) { - mNotify->notifyMsgChanged(feedId, *it, NOTIFY_TYPE_ADD); + mNotify->notifyMsgChanged(feedId, *it, FeedReaderNotify::NOTIFY_TYPE_ADD); } } } @@ -2365,7 +2366,7 @@ void p3FeedReader::onProcessError(uint32_t feedId, RsFeedReaderErrorState result } if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } } @@ -2433,7 +2434,7 @@ void p3FeedReader::setFeedInfo(uint32_t feedId, const std::string &name, const s } if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } } diff --git a/plugins/FeedReader/services/p3FeedReader.h b/plugins/FeedReader/services/p3FeedReader.h index 0df9bf79e..0bea5de82 100644 --- a/plugins/FeedReader/services/p3FeedReader.h +++ b/plugins/FeedReader/services/p3FeedReader.h @@ -32,9 +32,9 @@ class RsFeedReaderMsg; class p3FeedReaderThread; class RsGxsForums; -struct RsGxsForumGroup; +class RsGxsForumGroup; class RsPosted; -struct RsPostedGroup; +class RsPostedGroup; class RsGxsIfaceHelper; class p3FeedReader : public RsPQIService, public RsFeedReader