From be82951e2e8f9e7da76e26cd68be13dc61fa6241 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 12 Jun 2014 22:06:43 +0000 Subject: [PATCH] fixed popup of distant chat dialog, and display of peer names. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7406 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/p3notify.cc | 1 + libretroshare/src/pqi/p3notify.h | 1 + libretroshare/src/retroshare/rsnotify.h | 1 + libretroshare/src/services/p3chatservice.cc | 17 ++-- .../src/gui/chat/PopupDistantChatDialog.cpp | 11 +-- retroshare-gui/src/gui/notifyqt.cpp | 94 +++---------------- retroshare-gui/src/gui/notifyqt.h | 3 + retroshare-gui/src/main.cpp | 2 + 8 files changed, 32 insertions(+), 98 deletions(-) diff --git a/libretroshare/src/pqi/p3notify.cc b/libretroshare/src/pqi/p3notify.cc index 5c77149f3..4ba899b17 100644 --- a/libretroshare/src/pqi/p3notify.cc +++ b/libretroshare/src/pqi/p3notify.cc @@ -232,6 +232,7 @@ void p3Notify::notifyListChange (int list, int type) { FOR_ALL_NOTIFY_CLIENTS void p3Notify::notifyErrorMsg (int list, int sev, std::string msg) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyErrorMsg(list,sev,msg) ; } void p3Notify::notifyChatStatus (const std::string& peer_id , const std::string& status_string ,bool is_private) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyChatStatus(peer_id,status_string,is_private) ; } +void p3Notify::notifyChatShow (const std::string& peer_id) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyChatShow(peer_id) ; } void p3Notify::notifyChatLobbyTimeShift (int time_shift) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyChatLobbyTimeShift(time_shift) ; } void p3Notify::notifyCustomState (const std::string& peer_id , const std::string& status_string ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyCustomState (peer_id,status_string) ; } diff --git a/libretroshare/src/pqi/p3notify.h b/libretroshare/src/pqi/p3notify.h index de5f01a64..74d72f5fc 100644 --- a/libretroshare/src/pqi/p3notify.h +++ b/libretroshare/src/pqi/p3notify.h @@ -99,6 +99,7 @@ class p3Notify: public RsNotify void notifyListChange (int /* list */, int /* type */) ; void notifyErrorMsg (int /* list */, int /* sev */, std::string /* msg */) ; void notifyChatStatus (const std::string& /* peer_id */, const std::string& /* status_string */ ,bool /* is_private */) ; + void notifyChatShow (const std::string& /* peer_id */) ; void notifyChatLobbyEvent (uint64_t /* lobby id */, uint32_t /* event type */ ,const std::string& /* nickname */,const std::string& /* any string */) ; void notifyChatLobbyTimeShift (int /* time_shift*/) ; void notifyCustomState (const std::string& /* peer_id */, const std::string& /* status_string */) ; diff --git a/libretroshare/src/retroshare/rsnotify.h b/libretroshare/src/retroshare/rsnotify.h index bfaafd55a..ef6239152 100644 --- a/libretroshare/src/retroshare/rsnotify.h +++ b/libretroshare/src/retroshare/rsnotify.h @@ -183,6 +183,7 @@ class NotifyClient virtual void notifyListChange (int /* list */, int /* type */) {} virtual void notifyErrorMsg (int /* list */, int /* sev */, std::string /* msg */) {} virtual void notifyChatStatus (const std::string& /* peer_id */, const std::string& /* status_string */ ,bool /* is_private */) {} + virtual void notifyChatShow (const std::string& /* peer_id */) {} virtual void notifyChatLobbyEvent (uint64_t /* lobby id */, uint32_t /* event type */ ,const std::string& /* nickname */,const std::string& /* any string */) {} virtual void notifyChatLobbyTimeShift (int /* time_shift*/) {} virtual void notifyCustomState (const std::string& /* peer_id */, const std::string& /* status_string */) {} diff --git a/libretroshare/src/services/p3chatservice.cc b/libretroshare/src/services/p3chatservice.cc index 036de7b87..5412694ad 100644 --- a/libretroshare/src/services/p3chatservice.cc +++ b/libretroshare/src/services/p3chatservice.cc @@ -3214,19 +3214,18 @@ void p3ChatService::addVirtualPeer(const TurtleFileHash& hash,const TurtleVirtua info.status = RS_DISTANT_CHAT_STATUS_WAITING_DH ; } - RsChatMsgItem *item = new RsChatMsgItem; - item->message = std::string("Tunnel is secured") ; - item->PeerId(virtual_peer_id) ; - item->chatFlags = RS_CHAT_FLAG_PRIVATE ; +// RsChatMsgItem *item = new RsChatMsgItem; +// item->message = std::string("Tunnel is secured") ; +// item->PeerId(virtual_peer_id) ; +// item->chatFlags = RS_CHAT_FLAG_PRIVATE ; +// +// privateIncomingList.push_back(item) ; - privateIncomingList.push_back(item) ; - - if(dir == RsTurtleGenericTunnelItem::DIRECTION_SERVER) - RsServer::notify()->AddPopupMessage(RS_POPUP_CHAT, virtual_peer_id.toStdString(), "Distant peer", "Conversation starts..."); + RsServer::notify()->AddPopupMessage(RS_POPUP_CHAT, virtual_peer_id.toStdString(), "Distant peer", "Conversation starts..."); // Notify the GUI that the tunnel is up. // - RsServer::notify()->notifyChatStatus(virtual_peer_id.toStdString(),"tunnel is up again!",true) ; + RsServer::notify()->notifyChatShow(virtual_peer_id.toStdString()) ; } void p3ChatService::removeVirtualPeer(const TurtleFileHash& hash,const TurtleVirtualPeerId& virtual_peer_id) diff --git a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp index d38fad8e7..c0bbd6ddc 100644 --- a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp @@ -149,13 +149,10 @@ QString PopupDistantChatDialog::getPeerName(const DistantChatPeerId &id) const { RsIdentityDetails details ; - for(int i=0;i<3;++i) - if(rsIdentity->getIdDetails(gxs_id,details)) - return QString::fromUtf8( details.mNickname.c_str() ) ; - else - usleep(500000) ; // sleep for 500 msec. - - return QString::fromStdString(id.toStdString()) ; + if(rsIdentity->getIdDetails(gxs_id,details)) + return QString::fromUtf8( details.mNickname.c_str() ) ; + else + return QString::fromStdString(gxs_id.toStdString()) ; } else return ChatDialog::getPeerName(id) ; diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index f7b1bc7ca..85f307fe7 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -136,6 +136,8 @@ NotifyQt::NotifyQt() : cDialog(NULL) QMutexLocker m(&_mutex) ; _enabled = false ; } + + connect(this,SIGNAL(raiseChatWindow(QString)),this,SLOT(raiseChatWindow_slot(QString)),Qt::QueuedConnection) ; } void NotifyQt::notifyErrorMsg(int list, int type, std::string msg) @@ -507,6 +509,11 @@ void NotifyQt::notifyChatLobbyEvent(uint64_t lobby_id,uint32_t event_type,const emit chatLobbyEvent(lobby_id,event_type,QString::fromUtf8(nickname.c_str()),QString::fromUtf8(str.c_str())) ; } +void NotifyQt::notifyChatShow(const std::string& peer_id) +{ + emit raiseChatWindow(RsPeerId(peer_id)) ; +} + void NotifyQt::notifyChatStatus(const std::string& peer_id,const std::string& status_string,bool is_private) { { @@ -521,6 +528,11 @@ void NotifyQt::notifyChatStatus(const std::string& peer_id,const std::string& st emit chatStatusChanged(QString::fromStdString(peer_id),QString::fromUtf8(status_string.c_str()),is_private) ; } +void NotifyQt::raiseChatWindow_slot(const RsPeerId& peer_str) +{ + ChatDialog::chatFriend(peer_str) ; +} + void NotifyQt::notifyTurtleSearchResult(uint32_t search_id,const std::list& files) { { @@ -1167,85 +1179,3 @@ void NotifyQt::runningTick() } } -//void NotifyQt::displaySearch() -//{ -// iface->lockData(); /* Lock Interface */ -// -//#ifdef NOTIFY_DEBUG -// std::ostringstream out; -// std::cerr << out.str(); -//#endif -// -// iface->unlockData(); /* UnLock Interface */ -//} - -// void NotifyQt::displayChat() -// { -// iface->lockData(); /* Lock Interface */ -// -// #ifdef NOTIFY_DEBUG -// std::ostringstream out; -// std::cerr << out.str(); -// #endif -// -// iface->unlockData(); /* UnLock Interface */ -// -// if (hDialog) -// hDialog -> insertChat(); -// } -// -// -//void NotifyQt::displayChannels() -//{ -// iface->lockData(); /* Lock Interface */ -// -//#ifdef NOTIFY_DEBUG -// std::ostringstream out; -// std::cerr << out.str(); -//#endif -// -// iface->unlockData(); /* UnLock Interface */ -// -// if (sDialog) -// sDialog -> insertChannels(); -//} -// -// -//void NotifyQt::displayTransfers() -//{ -// /* Do the GUI */ -// if (tDialog) -// tDialog->insertTransfers(); -//} -// -// -//void NotifyQt::preDisplayNeighbours() -//{ -// -//} -// -//void NotifyQt::preDisplayFriends() -//{ -// -//} - -//void NotifyQt::preDisplaySearch() -//{ -// -//} -// -//void NotifyQt::preDisplayMessages() -//{ -// -//} -// -//void NotifyQt::preDisplayChannels() -//{ -// -//} -// -//void NotifyQt::preDisplayTransfers() -//{ -// -// -//} diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index d501a51d6..690334728 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -42,6 +42,7 @@ class NotifyQt: public QObject, public NotifyClient virtual void notifyListChange(int list, int type); virtual void notifyErrorMsg(int list, int sev, std::string msg); virtual void notifyChatStatus(const std::string& peer_id,const std::string& status_string,bool is_private); + virtual void notifyChatShow(const std::string& peer_id) ; virtual void notifyCustomState(const std::string& peer_id, const std::string& status_string); virtual void notifyHashingInfo(uint32_t type, const std::string& fileinfo); virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list& found_files); @@ -117,6 +118,7 @@ class NotifyQt: public QObject, public NotifyClient void peerStatusChangedSummary() const; void publicChatChanged(int type) const ; void privateChatChanged(int list, int type) const ; + void raiseChatWindow(const RsPeerId&) const ; void groupsChanged(int type) const ; void discInfoChanged() const ; void downloadComplete(const QString& /* fileHash */); @@ -141,6 +143,7 @@ class NotifyQt: public QObject, public NotifyClient void runningTick(); void handleSignatureEvent() ; void handleChatLobbyTimeShift(int) ; + void raiseChatWindow_slot(const RsPeerId&) ; private: NotifyQt(); diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 0866ec7d2..f8375385b 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -373,10 +373,12 @@ int main(int argc, char *argv[]) // qRegisterMetaType("FileDetail") ; + qRegisterMetaType("RsPeerId") ; std::cerr << "connecting signals and slots" << std::endl ; QObject::connect(notify,SIGNAL(gotTurtleSearchResult(qulonglong,FileDetail)),w->transfersDialog->searchDialog ,SLOT(updateFiles(qulonglong,FileDetail))) ; QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ; + QObject::connect(notify,SIGNAL(raiseChatWindow(const RsPeerId&)),notify,SLOT(raiseChatWindow_slot(const RsPeerId&)),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) )) ;