diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index 2b342515f..bb516d5c1 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -1111,10 +1111,16 @@ void TransfersDialog::handleEvent_main_thread(std::shared_ptr eve if(!fe) return; + FileInfo nfo ; + if(!rsFiles->FileDetails(fe->mHash, RS_FILE_HINTS_DOWNLOAD, nfo)) + return ; + switch (fe->mFileTransferEventCode) { case RsFileTransferEventCode::DOWNLOAD_COMPLETE: SoundManager::play(SOUND_DOWNLOAD_COMPLETE); + if (Settings->getNotifyFlags() & RS_POPUP_DOWNLOAD) + NotifyQt::getInstance()->addToaster(RS_POPUP_DOWNLOAD, fe->mHash.toStdString(), nfo.fname.c_str(),""); case RsFileTransferEventCode::COMPLETED_FILES_REMOVED: getUserNotify()->updateIcon(); diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index 252560d43..36f547738 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -441,6 +441,8 @@ void NewsFeed::handleConnectionEvent(std::shared_ptr event) { case RsConnectionEventCode::PEER_CONNECTED: addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_CONNECT, false), true); + if (Settings->getNotifyFlags() & RS_POPUP_CONNECT) + NotifyQt::getInstance()->addToaster(RS_POPUP_CONNECT, e.mSslId.toStdString().c_str(), "", ""); break; case RsConnectionEventCode::PEER_DISCONNECTED: // not handled yet break; @@ -476,6 +478,7 @@ void NewsFeed::handleSecurityEvent(std::shared_ptr event) addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_HELLO, false), true ); return; } + uint32_t FeedItemType=0; @@ -504,6 +507,9 @@ 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 + ")")); + + if (Settings->getNotifyFlags() & RS_POPUP_CONNECT_ATTEMPT) + 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 fddf2c8d5..60e6ec197 100644 --- a/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp +++ b/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp @@ -23,6 +23,7 @@ #include "gui/notifyqt.h" #include "gui/MainWindow.h" #include "util/qtthreadsutils.h" +#include "gui/settings/rsharesettings.h" #include "gui/msgs/MessageInterface.h" @@ -91,8 +92,18 @@ void MessageUserNotify::handleEvent_main_thread(std::shared_ptr e return; } + std::set::const_iterator it; + switch (fe->mMailStatusEventCode) { case RsMailStatusEventCode::NEW_MESSAGE: + if (Settings->getNotifyFlags() & RS_POPUP_MSG) + 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() ); + } + } + break; case RsMailStatusEventCode::MESSAGE_CHANGED: case RsMailStatusEventCode::MESSAGE_REMOVED: updateIcon(); diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 7d2e9a207..59d102170 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -1162,3 +1162,82 @@ void NotifyQt::runningTick() } } +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; + + switch(type) + { + case RS_POPUP_ENCRYPTED_MSG: + SoundManager::play(SOUND_MESSAGE_ARRIVED); + + 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); + + 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); + + toaster = new ToasterItem(new OnlineToaster(RsPeerId(id))); + break; + case RS_POPUP_DOWNLOAD: + SoundManager::play(SOUND_DOWNLOAD_COMPLETE); + + toaster = new ToasterItem(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str()))); + break; + case RS_POPUP_CHAT: + toaster = new ToasterItem(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); + break; + case RS_POPUP_GROUPCHAT: +#ifdef RS_DIRECT_CHAT + toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); +#endif // RS_DIRECT_CHAT + break; + case RS_POPUP_CHATLOBBY: + { + 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: + // 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); + } + } +} diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index f4fc063c7..d2b15fa09 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -95,6 +95,7 @@ class NotifyQt: public QObject, public NotifyClient void testToaster(ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin); void testToaster(QString tag, ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin); + void addToaster(uint notifyFlags, const std::string& id, const std::string& title, const std::string& msg); void notifySettingsChanged(); signals: diff --git a/retroshare-gui/src/gui/toaster/MessageToaster.cpp b/retroshare-gui/src/gui/toaster/MessageToaster.cpp index 93772ca68..1f4894ba3 100644 --- a/retroshare-gui/src/gui/toaster/MessageToaster.cpp +++ b/retroshare-gui/src/gui/toaster/MessageToaster.cpp @@ -21,7 +21,11 @@ #include "MessageToaster.h" #include "../MainWindow.h" +#include #include +#include + +#include "gui/msgs/MessageInterface.h" MessageToaster::MessageToaster(const std::string &peerId, const QString &title, const QString &message) : QWidget(NULL) { @@ -39,8 +43,24 @@ MessageToaster::MessageToaster(const std::string &peerId, const QString &title, ui.textLabel->setText(message); ui.textLabel->setToolTip(message); - std::string name = (!RsPeerId(peerId).isNull())? (rsPeers->getPeerName(RsPeerId(peerId))): (rsPeers->getGPGName(RsPgpId(peerId))) ; - ui.toasterLabel->setText(ui.toasterLabel->text() + " " + QString::fromUtf8(name.c_str())); + MessageInfo mi; + + if (!rsMail->getMessage(peerId, mi)) + return; + + QString srcName; + + if(mi.msgflags & RS_MSG_DISTANT) + { + RsIdentityDetails details ; + rsIdentity->getIdDetails(mi.from.toGxsId(), details) ; + + srcName = QString::fromUtf8(details.mNickname.c_str()); + } + else + srcName = QString::fromUtf8(rsPeers->getPeerName(mi.from.toRsPeerId()).c_str()); + + ui.toasterLabel->setText(ui.toasterLabel->text() + " " + srcName); } void MessageToaster::openmessageClicked()