diff --git a/libretroshare/src/rsiface/rsiface.h b/libretroshare/src/rsiface/rsiface.h index aa582e280..e7fc4d1f1 100644 --- a/libretroshare/src/rsiface/rsiface.h +++ b/libretroshare/src/rsiface/rsiface.h @@ -204,6 +204,7 @@ class NotifyBase virtual void notifyCustomState(const std::string& peer_id,const std::string& status_string) {} virtual void notifyHashingInfo(std::string fileinfo) { (void)fileinfo; return ; } virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list& files) { (void)files; } + virtual void notifyPeerHasNewAvatar(std::string peer_id) { (void)peer_id; } }; const int NOTIFY_LIST_NEIGHBOURS = 1; diff --git a/libretroshare/src/rsserver/p3msgs.cc b/libretroshare/src/rsserver/p3msgs.cc index e25f9082d..7b6b5e253 100644 --- a/libretroshare/src/rsserver/p3msgs.cc +++ b/libretroshare/src/rsserver/p3msgs.cc @@ -168,13 +168,6 @@ void p3Msgs::initRsChatInfo(RsChatMsgItem *c, ChatInfo &i) i.chatflags |= RS_CHAT_PUBLIC; //std::cerr << "RsServer::initRsChatInfo() Chat Public!!!"; } - //std::cerr << std::endl; - - if(c->chatFlags & RS_CHAT_FLAG_AVATAR_AVAILABLE) - { - std::cerr << "p3msgs::initRsChatInfo(): new avatar available for peer " << i.rsid << ". Sending above." << std::endl ; - i.chatflags |= RS_CHAT_AVATAR_AVAILABLE; - } } void p3Msgs::getOwnAvatarData(unsigned char *& data,int& size) diff --git a/libretroshare/src/services/p3chatservice.cc b/libretroshare/src/services/p3chatservice.cc index e86f41af5..5ac4db244 100644 --- a/libretroshare/src/services/p3chatservice.cc +++ b/libretroshare/src/services/p3chatservice.cc @@ -399,6 +399,12 @@ std::list p3ChatService::getChatQueue() if(ca != NULL) { receiveAvatarJpegData(ca) ; + +#ifdef CHAT_DEBUG + std::cerr << "Received avatar data for peer " << ca->PeerId() << ". Notifying." << std::endl ; +#endif + rsicontrol->getNotify().notifyPeerHasNewAvatar(ca->PeerId()) ; + delete item ; continue ; } @@ -490,7 +496,7 @@ void p3ChatService::getAvatarJpegData(const std::string& peer_id,unsigned char * std::map::const_iterator it = _avatars.find(peer_id) ; - std::cerr << "p3chatservice:: avatar requested from above. " << std::endl ; + std::cerr << "p3chatservice:: avatar for peer " << peer_id << " requested from above. " << std::endl ; // has avatar. Return it strait away. // if(it!=_avatars.end()) diff --git a/retroshare-gui/src/gui/PeersDialog.cpp b/retroshare-gui/src/gui/PeersDialog.cpp index 561e28ae0..de5678a9e 100644 --- a/retroshare-gui/src/gui/PeersDialog.cpp +++ b/retroshare-gui/src/gui/PeersDialog.cpp @@ -178,16 +178,7 @@ PeersDialog::PeersDialog(QWidget *parent) menu->addAction(ui.actionCreate_new_Profile); ui.menupushButton->setMenu(menu); - QTimer *timerAvatar = new QTimer(this); - connect(timerAvatar, SIGNAL(timeout()), this, SLOT(updateAvatar())); - timerAvatar->start(1000); - - QTimer *timerstatus= new QTimer(this); - connect(timerstatus, SIGNAL(timeout()), this, SLOT(loadmypersonalstatus())); - timerstatus->start(1000); - updateAvatar(); - loadmypersonalstatus(); @@ -695,6 +686,14 @@ void PeersDialog::configurefriend() ConfCertDialog::show(getPeerRsCertId(getCurrentPeer())); } +void PeersDialog::updatePeersAvatar(const QString& peer_id) +{ + std::cerr << "PeersDialog: Got notified of new avatar for peer " << peer_id.toStdString() << std::endl ; + + PopupChatDialog *pcd = getPrivateChat(peer_id.toStdString(),rsPeers->getPeerName(peer_id.toStdString()), 0); + pcd->updatePeerAvatar(peer_id.toStdString()); +} + void PeersDialog::updatePeerStatusString(const QString& peer_id,const QString& status_string,bool is_private_chat) { if(is_private_chat) diff --git a/retroshare-gui/src/gui/PeersDialog.h b/retroshare-gui/src/gui/PeersDialog.h index ca6e362f3..e280b1515 100644 --- a/retroshare-gui/src/gui/PeersDialog.h +++ b/retroshare-gui/src/gui/PeersDialog.h @@ -70,6 +70,7 @@ public slots: void displayInfoChatMenu(const QPoint& pos); void updatePeerStatusString(const QString& peer_id,const QString& status_string,bool is_private_chat) ; + void updatePeersAvatar(const QString& peer_id); private slots: diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index d58db6978..90c92d5e6 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -304,11 +304,6 @@ std::cout << "PopupChatDialog:addChatMsg message : " << message.toStdString() << qsb -> setValue(oldQsbValue); } - if(ci->chatflags & RS_CHAT_AVATAR_AVAILABLE) - { - std::cerr << "received msg saying an avatar for peer " << ci->rsid << " is available." << std::endl ; - updatePeerAvatar(ci->rsid) ; - } /*else { ui.avatarlabel->setPixmap(QPixmap(":/images/user/personal128.png")); @@ -648,6 +643,8 @@ void PopupChatDialog::changeStyle() void PopupChatDialog::updatePeerAvatar(const std::string& peer_id) { + std::cerr << "popupchatDialog: updating avatar for peer " << peer_id << std::endl ; + unsigned char *data = NULL; int size = 0 ; @@ -665,7 +662,7 @@ void PopupChatDialog::updatePeerAvatar(const std::string& peer_id) // set the image QPixmap pix ; - pix.loadFromData(data,size,"JPG") ; + pix.loadFromData(data,size,"PNG") ; ui.avatarlabel->setPixmap(pix); // writes image into ba in JPG format delete[] data ; diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.h b/retroshare-gui/src/gui/chat/PopupChatDialog.h index 9a85eb706..ef8a3fc32 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.h +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.h @@ -52,6 +52,7 @@ public: ~PopupChatDialog(); void updateChat(); + void updatePeerAvatar(const std::string&); void addChatMsg(ChatInfo *ci); void loadEmoticons(); @@ -106,7 +107,6 @@ private slots: private: void colorChanged(const QColor &c); - void updatePeerAvatar(const std::string&); void updateAvatar(); void addAttachment(std::string); diff --git a/retroshare-gui/src/gui/toaster/MessageToaster.cpp b/retroshare-gui/src/gui/toaster/MessageToaster.cpp index ff75d9535..f8b237d9b 100644 --- a/retroshare-gui/src/gui/toaster/MessageToaster.cpp +++ b/retroshare-gui/src/gui/toaster/MessageToaster.cpp @@ -19,8 +19,6 @@ #include "MessageToaster.h" -#include "tools.h" - MessageToaster::MessageToaster( QWidget * parent, Qt::WFlags f) : QWidget(parent, f) { diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 4aaf2bed3..d67230fce 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -145,12 +145,11 @@ int main(int argc, char *argv[]) QObject::connect(notify,SIGNAL(configChanged()) ,w->messagesDialog ,SLOT(displayConfig() )) ; QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->peersDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool))); + QObject::connect(notify,SIGNAL(peerHasNewAvatar(const QString&)),w->peersDialog,SLOT(updatePeersAvatar(const QString&))); QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)),w->networkDialog,SLOT(setLogInfo(QString))) ; QObject::connect(ConfCertDialog::instance(),SIGNAL(configChanged()),w->networkDialog,SLOT(insertConnect())) ; QObject::connect(w->peersDialog,SIGNAL(friendsUpdated()),w->networkDialog,SLOT(insertConnect())) ; - - QObject::connect(w->peersDialog,SIGNAL(notifyGroupChat(const QString&,const QString&)),w,SLOT(displaySystrayMsg(const QString&,const QString&))) ; /* only show window, if not startMinimized */ diff --git a/retroshare-gui/src/rsiface/notifyqt.cpp b/retroshare-gui/src/rsiface/notifyqt.cpp index 140f665a6..dd79b85dd 100644 --- a/retroshare-gui/src/rsiface/notifyqt.cpp +++ b/retroshare-gui/src/rsiface/notifyqt.cpp @@ -39,6 +39,12 @@ void NotifyQt::notifyErrorMsg(int list, int type, std::string msg) return; } +void NotifyQt::notifyPeerHasNewAvatar(std::string peer_id) +{ + std::cerr << "notifyQt: notification of new avatar." << std::endl ; + emit peerHasNewAvatar(QString::fromStdString(peer_id)) ; +} + void NotifyQt::notifyCustomState(const std::string& peer_id,const std::string& custom_state_string) { std::cerr << "notifyQt: Received custom status string: " << custom_state_string << std::endl ; diff --git a/retroshare-gui/src/rsiface/notifyqt.h b/retroshare-gui/src/rsiface/notifyqt.h index 90cae0056..01371d141 100644 --- a/retroshare-gui/src/rsiface/notifyqt.h +++ b/retroshare-gui/src/rsiface/notifyqt.h @@ -37,6 +37,7 @@ class NotifyQt: public QObject, public NotifyBase virtual void notifyCustomState(const std::string& peer_id,const std::string& status_string); virtual void notifyHashingInfo(std::string fileinfo); virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list& found_files); + virtual void notifyPeerHasNewAvatar(std::string peer_id) ; signals: // It's beneficial to send info to the GUI using signals, because signals are thread-safe @@ -54,6 +55,7 @@ class NotifyQt: public QObject, public NotifyBase void chatStatusChanged(const QString&,const QString&,bool) const ; void peerCustomStateStringChanged(const QString&,const QString&) const ; void gotTurtleSearchResult(qulonglong search_id,FileDetail file) const ; + void peerHasNewAvatar(const QString& peer_id) const ; public slots: diff --git a/retroshare-gui/src/rsiface/rsiface.h b/retroshare-gui/src/rsiface/rsiface.h index aa582e280..e7fc4d1f1 100644 --- a/retroshare-gui/src/rsiface/rsiface.h +++ b/retroshare-gui/src/rsiface/rsiface.h @@ -204,6 +204,7 @@ class NotifyBase virtual void notifyCustomState(const std::string& peer_id,const std::string& status_string) {} virtual void notifyHashingInfo(std::string fileinfo) { (void)fileinfo; return ; } virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list& files) { (void)files; } + virtual void notifyPeerHasNewAvatar(std::string peer_id) { (void)peer_id; } }; const int NOTIFY_LIST_NEIGHBOURS = 1;