diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index abab8336a..e9128af2a 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -1931,7 +1931,12 @@ void ChatWidget::updatePeersCustomStateString(const QString& peer_id, const QStr void ChatWidget::updateStatusString(const QString &statusMask, const QString &statusString, bool permanent) { ui->typingLabel->setText(QString(statusMask).arg(trUtf8(statusString.toUtf8()))); // displays info for 5 secs. - ui->typingPixmapLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":icons/png/typing.png") ); + + if (statusString.contains("Connexion refused")){ + ui->typingPixmapLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":images/denied-32.png") ); + } else { + ui->typingPixmapLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":icons/png/typing.png") ); + } if (statusString == "is typing...") { typing = true; @@ -1943,6 +1948,11 @@ void ChatWidget::updateStatusString(const QString &statusMask, const QString &st QTimer::singleShot(5000, this, SLOT(resetStatusBar())) ; } +void ChatWidget::updatePixmapLabel(const QPixmap &pixmap) +{ + ui->typingPixmapLabel->setPixmap(pixmap); +} + void ChatWidget::setName(const QString &name) { this->name = name; diff --git a/retroshare-gui/src/gui/chat/ChatWidget.h b/retroshare-gui/src/gui/chat/ChatWidget.h index e42df06fe..470344fa7 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.h +++ b/retroshare-gui/src/gui/chat/ChatWidget.h @@ -101,6 +101,7 @@ public: void addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, MsgType chatType); void addChatMsg(bool incoming, const QString &name, const RsGxsId gxsId, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, MsgType chatType); void updateStatusString(const QString &statusMask, const QString &statusString, bool permanent = false); + void updatePixmapLabel(const QPixmap &pixmap); void addToolsAction(QAction *action); diff --git a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp index c5ab40cbf..bba3bae3f 100644 --- a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp @@ -26,7 +26,9 @@ #include +#include "gui/notifyqt.h" #include "gui/common/FilesDefs.h" + #include #include #include @@ -60,6 +62,8 @@ PopupDistantChatDialog::PopupDistantChatDialog(const DistantChatPeerId& tunnel_i _update_timer->setInterval(1000) ; QObject::connect(_update_timer,SIGNAL(timeout()),this,SLOT(updateDisplay())) ; + connect(NotifyQt::getInstance(), SIGNAL(distantchatStatusChanged(ChatId)), this, SLOT(updateDistantChatEvent())); + _update_timer->start() ; getChatWidget()->addTopBarWidget(_status_label) ; @@ -118,6 +122,7 @@ void PopupDistantChatDialog::updateDisplay() msg = tr("Remote status unknown."); _status_label->setToolTip(msg); getChatWidget()->updateStatusString("%1", msg, true); + getChatWidget()->updatePixmapLabel(FilesDefs::getPixmapFromQtResourcePath(":images/status_unknown.png")); getChatWidget()->blockSending(tr( "Can't send message immediately, " "because there is no tunnel " "available." )); @@ -129,6 +134,7 @@ void PopupDistantChatDialog::updateDisplay() _status_label->setToolTip( QObject::tr("Distant peer has closed the chat") ); getChatWidget()->updateStatusString("%1", tr( "Your partner closed the conversation." ), true ); + getChatWidget()->updatePixmapLabel(FilesDefs::getPixmapFromQtResourcePath(":images/status_unknown.png")); getChatWidget()->blockSending(tr( "Your partner closed the conversation.")); setPeerStatus(RS_STATUS_OFFLINE) ; @@ -144,6 +150,7 @@ void PopupDistantChatDialog::updateDisplay() _status_label->setToolTip(msg); getChatWidget()->updateStatusString("%1", msg, true); + getChatWidget()->updatePixmapLabel(FilesDefs::getPixmapFromQtResourcePath(":images/quick_restart24.png")); getChatWidget()->blockSending(msg); setPeerStatus(RS_STATUS_OFFLINE); break; @@ -158,6 +165,33 @@ void PopupDistantChatDialog::updateDisplay() } } +void PopupDistantChatDialog::updateDistantChatEvent() +{ + if(RsAutoUpdatePage::eventsLocked()) + return ; + + DistantChatPeerInfo tinfo; + rsMsgs->getDistantChatStatus(_tunnel_id,tinfo) ; + + switch(tinfo.status) + { + case RS_DISTANT_CHAT_STATUS_UNKNOWN: + break ; + case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED: + getChatWidget()->addChatMsg(true, tr("Chat status"), QDateTime::currentDateTime(), QDateTime::currentDateTime() + , tr("Your partner closed the conversation."), ChatWidget::MSGTYPE_SYSTEM); + break ; + case RS_DISTANT_CHAT_STATUS_TUNNEL_DN: + break; + case RS_DISTANT_CHAT_STATUS_CAN_TALK: + getChatWidget()->addChatMsg(true, tr("Chat status"), QDateTime::currentDateTime(), QDateTime::currentDateTime() + , tr("Tunnel is secured. You can talk!"), ChatWidget::MSGTYPE_SYSTEM); + getChatWidget()->unblockSending(); + break; + } + +} + void PopupDistantChatDialog::closeEvent(QCloseEvent *e) { DistantChatPeerInfo tinfo ; diff --git a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.h b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.h index 15a83232f..b9f29d1f2 100644 --- a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.h +++ b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.h @@ -47,6 +47,9 @@ class PopupDistantChatDialog: public PopupChatDialog protected slots: void updateDisplay() ; // overloads RsAutoUpdatePage + private slots: + void updateDistantChatEvent() ; + private: QTimer *_update_timer ; DistantChatPeerId _tunnel_id ; diff --git a/retroshare-gui/src/gui/images.qrc b/retroshare-gui/src/gui/images.qrc index de468d270..ee13f256f 100644 --- a/retroshare-gui/src/gui/images.qrc +++ b/retroshare-gui/src/gui/images.qrc @@ -84,6 +84,7 @@ images/closehover.png images/closepressed.png images/denied16.png + images/denied-32.png images/filetype-association.png images/foldermail.png images/folderopen.png diff --git a/retroshare-gui/src/gui/images/denied-32.png b/retroshare-gui/src/gui/images/denied-32.png new file mode 100644 index 000000000..1b2e691c8 Binary files /dev/null and b/retroshare-gui/src/gui/images/denied-32.png differ diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index d2dee5ac4..ad0b58f63 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -461,6 +461,22 @@ void NotifyQt::notifyChatStatus(const ChatId& chat_id,const std::string& status_ std::cerr << "notifyQt: Received chat status string: " << status_string << std::endl ; #endif emit chatStatusChanged(chat_id, QString::fromUtf8(status_string.c_str())); + +} + +void NotifyQt::notifyDistantChatStatus(const ChatId& chat_id) +{ + { + QMutexLocker m(&_mutex) ; + if(!_enabled) + return ; + } + +#ifdef NOTIFY_DEBUG + std::cerr << "notifyQt: Received distant chat status : " << status_string << std::endl ; +#endif + emit distantchatStatusChanged(chat_id); + } void NotifyQt::notifyChatCleared(const ChatId& chat_id) diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index 5782ef5b7..4d4f9a41f 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -65,6 +65,7 @@ class NotifyQt: public QObject, public NotifyClient 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 notifyDistantChatStatus(const ChatId &chat_id); virtual void notifyChatCleared(const ChatId &chat_id); virtual void notifyCustomState(const std::string& peer_id, const std::string& status_string); #ifdef TO_REMOVE @@ -115,6 +116,7 @@ class NotifyQt: public QObject, public NotifyClient void configChanged() const ; void logInfoChanged(const QString&) const ; void chatStatusChanged(const ChatId&,const QString&) const ; + void distantchatStatusChanged(const ChatId&) const ; void chatCleared(const ChatId&) const ; void peerHasNewCustomStateString(const QString& /* peer_id */, const QString& /* status_string */) const ; void peerHasNewAvatar(const QString& peer_id) const ;