Added the peers custom state string to NotifyBase::notifyCustomState and to the signal NotifyQt::notifyCustomState.

Changed the display of the peers custom state string in PopupChatDialog from QTimer to signal.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3429 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-09-02 10:15:13 +00:00
parent 80764a1ff7
commit 48acd856af
9 changed files with 34 additions and 67 deletions

View file

@ -201,7 +201,7 @@ class NotifyBase
virtual void notifyErrorMsg(int list, int sev, std::string msg) { (void) list; (void) sev; (void) msg; return; } virtual void notifyErrorMsg(int list, int sev, std::string msg) { (void) list; (void) sev; (void) msg; return; }
virtual void notifyChat() { return; } virtual void notifyChat() { return; }
virtual void notifyChatStatus(const std::string& /* peer_id */, const std::string& /* status_string */ ,bool /* is_private */) {} virtual void notifyChatStatus(const std::string& /* peer_id */, const std::string& /* status_string */ ,bool /* is_private */) {}
virtual void notifyCustomState(const std::string& /* peer_id */) {} virtual void notifyCustomState(const std::string& /* peer_id */, const std::string& /* status_string */) {}
virtual void notifyHashingInfo(std::string fileinfo) { (void)fileinfo; return ; } virtual void notifyHashingInfo(std::string fileinfo) { (void)fileinfo; return ; }
virtual void notifyTurtleSearchResult(uint32_t /* search_id */ ,const std::list<TurtleFileInfo>& files) { (void)files; } virtual void notifyTurtleSearchResult(uint32_t /* search_id */ ,const std::list<TurtleFileInfo>& files) { (void)files; }
virtual void notifyPeerHasNewAvatar(std::string peer_id) { (void)peer_id; } virtual void notifyPeerHasNewAvatar(std::string peer_id) { (void)peer_id; }

View file

@ -375,7 +375,7 @@ void p3ChatService::receiveChatQueue()
if(cs->flags & RS_CHAT_FLAG_CUSTOM_STATE){ if(cs->flags & RS_CHAT_FLAG_CUSTOM_STATE){
receiveStateString(cs->PeerId(),cs->status_string) ; // store it receiveStateString(cs->PeerId(),cs->status_string) ; // store it
rsicontrol->getNotify().notifyCustomState(cs->PeerId()) ; rsicontrol->getNotify().notifyCustomState(cs->PeerId(), cs->status_string) ;
}else }else
if(cs->flags & RS_CHAT_FLAG_CUSTOM_STATE_AVAILABLE){ if(cs->flags & RS_CHAT_FLAG_CUSTOM_STATE_AVAILABLE){

View file

@ -1049,18 +1049,6 @@ void PeersDialog::updateStatusString(const QString& peer_id, const QString& stat
QTimer::singleShot(5000,this,SLOT(resetStatusBar())) ; QTimer::singleShot(5000,this,SLOT(resetStatusBar())) ;
} }
void PeersDialog::updatePeersCustomStateString(const QString& peer_id)
{
#ifdef JUST_AN_EXAMPLE
// This is an example of how to retrieve the custom string.
//
std::cerr << "PeersDialog: Got notified that state string changed for peer " << peer_id.toStdString() << std::endl ;
std::cerr << "New state string for this peer is : " << rsMsgs->getCustomStateString(peer_id.toStdString()) << std::endl ;
QMessageBox::information(NULL,"Notification",peer_id+" has new custom string: " + QString::fromStdString(rsMsgs->getCustomStateString(peer_id.toStdString()))) ;
#endif
}
void PeersDialog::updatePeersAvatar(const QString& peer_id) void PeersDialog::updatePeersAvatar(const QString& peer_id)
{ {
#ifdef PEERS_DEBUG #ifdef PEERS_DEBUG

View file

@ -90,7 +90,6 @@ public slots:
// called by notifyQt when another peer is typing (in group chant and private chat) // called by notifyQt when another peer is typing (in group chant and private chat)
void updatePeerStatusString(const QString& peer_id,const QString& status_string,bool is_private_chat) ; void updatePeerStatusString(const QString& peer_id,const QString& status_string,bool is_private_chat) ;
void updatePeersCustomStateString(const QString& peer_id) ;
void updatePeersAvatar(const QString& peer_id); void updatePeersAvatar(const QString& peer_id);
void updateAvatar(); // called by notifyQt to update the avatar when it gets changed by another component void updateAvatar(); // called by notifyQt to update the avatar when it gets changed by another component

View file

@ -133,6 +133,7 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
connect(ui.textBrowser, SIGNAL(anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &))); connect(ui.textBrowser, SIGNAL(anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &)));
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&, int)), this, SLOT(updateStatus(const QString&, int))); 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&)));
std::cerr << "Connecting custom context menu" << std::endl; std::cerr << "Connecting custom context menu" << std::endl;
ui.chattextEdit->setContextMenuPolicy(Qt::CustomContextMenu) ; ui.chattextEdit->setContextMenuPolicy(Qt::CustomContextMenu) ;
@ -183,8 +184,6 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
updateAvatar() ; updateAvatar() ;
updatePeerAvatar(id) ; updatePeerAvatar(id) ;
updateStatusMessage();
// load settings // load settings
processSettings(true); processSettings(true);
@ -199,6 +198,10 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
if (rsStatus->getOwnStatus(ownStatusInfo)) { if (rsStatus->getOwnStatus(ownStatusInfo)) {
updateStatus(QString::fromStdString(ownStatusInfo.id), ownStatusInfo.status); updateStatus(QString::fromStdString(ownStatusInfo.id), ownStatusInfo.status);
} }
// initialize first custom state string
QString customStateString = QString::fromStdString(rsMsgs->getCustomStateString(dialogId));
updatePeersCustomStateString(QString::fromStdString(dialogId), customStateString);
} }
/** Destructor. */ /** Destructor. */
@ -1315,39 +1318,18 @@ void PopupChatDialog::updateStatus(const QString &peer_id, int status)
// ignore status change // ignore status change
} }
void PopupChatDialog::updateStatusMessage() void PopupChatDialog::updatePeersCustomStateString(const QString& peer_id, const QString& status_string)
{ {
if (!rsPeers) std::string stdPeerId = peer_id.toStdString();
return;
if (stdPeerId == dialogId) {
if(!RsAutoUpdatePage::eventsLocked()) { // the peers status string has changed
RsPeerDetails details; if (status_string.isEmpty()) {
if (!rsPeers->getPeerDetails(dialogId, details))
{
return;
}
QString sCustomString;
if (details.state & RS_PEER_STATE_CONNECTED) {
sCustomString = QString::fromStdString(rsMsgs->getCustomStateString(details.id));
}
if (sCustomString.isEmpty())
{
ui.statusmessagelabel->hide(); ui.statusmessagelabel->hide();
} } else {
else
{
ui.statusmessagelabel->show(); ui.statusmessagelabel->show();
ui.statusmessagelabel->setText(sCustomString); ui.statusmessagelabel->setText(status_string);
} }
} }
/* slow Tick */
int msec_rate = 10129;
QTimer::singleShot( msec_rate, this, SLOT(updateStatusMessage( void ) ));
return;
} }

View file

@ -86,7 +86,6 @@ protected:
void loadEmoticons2(); void loadEmoticons2();
void updateAvatar(); void updateAvatar();
void updateStatusMessage();
QString loadEmptyStyle(); QString loadEmptyStyle();
@ -105,6 +104,7 @@ private slots:
void checkChat(); void checkChat();
void sendChat(); void sendChat();
void updatePeersCustomStateString(const QString& peer_id, const QString& status_string) ;
void getAvatar(); void getAvatar();
void on_actionClear_Chat_triggered(); void on_actionClear_Chat_triggered();
@ -145,7 +145,6 @@ private:
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::PopupChatDialog ui; Ui::PopupChatDialog ui;
}; };
#endif #endif

View file

@ -114,12 +114,12 @@ void NotifyQt::notifyPeerHasNewAvatar(std::string peer_id)
emit peerHasNewAvatar(QString::fromStdString(peer_id)) ; emit peerHasNewAvatar(QString::fromStdString(peer_id)) ;
} }
void NotifyQt::notifyCustomState(const std::string& peer_id) void NotifyQt::notifyCustomState(const std::string& peer_id, const std::string& status_string)
{ {
#ifdef NOTIFY_DEBUG #ifdef NOTIFY_DEBUG
std::cerr << "notifyQt: Received custom status string notification" << std::endl ; std::cerr << "notifyQt: Received custom status string notification" << std::endl ;
#endif #endif
emit peerHasNewCustomStateString(QString::fromStdString(peer_id)) ; emit peerHasNewCustomStateString(QString::fromStdString(peer_id), QString::fromStdString(status_string)) ;
} }
void NotifyQt::notifyChatStatus(const std::string& peer_id,const std::string& status_string,bool is_private) void NotifyQt::notifyChatStatus(const std::string& peer_id,const std::string& status_string,bool is_private)

View file

@ -33,7 +33,7 @@ class NotifyQt: public QObject, public NotifyBase
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 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 notifyChatStatus(const std::string& peer_id,const std::string& status_string,bool is_private);
virtual void notifyCustomState(const std::string& peer_id); virtual void notifyCustomState(const std::string& peer_id, const std::string& status_string);
virtual void notifyHashingInfo(std::string fileinfo); virtual void notifyHashingInfo(std::string fileinfo);
virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list<TurtleFileInfo>& found_files); virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list<TurtleFileInfo>& found_files);
virtual void notifyPeerHasNewAvatar(std::string peer_id) ; virtual void notifyPeerHasNewAvatar(std::string peer_id) ;
@ -63,7 +63,7 @@ class NotifyQt: public QObject, public NotifyBase
void configChanged() const ; void configChanged() const ;
void logInfoChanged(const QString&) const ; void logInfoChanged(const QString&) const ;
void chatStatusChanged(const QString&,const QString&,bool) const ; void chatStatusChanged(const QString&,const QString&,bool) const ;
void peerHasNewCustomStateString(const QString&) const ; void peerHasNewCustomStateString(const QString& /* peer_id */, const QString& /* status_string */) const ;
void gotTurtleSearchResult(qulonglong search_id,FileDetail file) const ; void gotTurtleSearchResult(qulonglong search_id,FileDetail file) const ;
void peerHasNewAvatar(const QString& peer_id) const ; void peerHasNewAvatar(const QString& peer_id) const ;
void ownAvatarChanged() const ; void ownAvatarChanged() const ;

View file

@ -190,7 +190,6 @@ int main(int argc, char *argv[])
QObject::connect(notify,SIGNAL(forumsChanged()) ,w ,SLOT(updateForums() ), Qt::QueuedConnection); QObject::connect(notify,SIGNAL(forumsChanged()) ,w ,SLOT(updateForums() ), Qt::QueuedConnection);
QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->peersDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool))); QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->peersDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool)));
QObject::connect(notify,SIGNAL(peerHasNewCustomStateString(const QString&)),w->peersDialog,SLOT(updatePeersCustomStateString(const QString&)));
QObject::connect(notify,SIGNAL(peerHasNewAvatar(const QString&)),w->peersDialog,SLOT(updatePeersAvatar(const QString&))); QObject::connect(notify,SIGNAL(peerHasNewAvatar(const QString&)),w->peersDialog,SLOT(updatePeersAvatar(const QString&)));
QObject::connect(notify,SIGNAL(ownAvatarChanged()),w->peersDialog,SLOT(updateAvatar())); QObject::connect(notify,SIGNAL(ownAvatarChanged()),w->peersDialog,SLOT(updateAvatar()));
QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->peersDialog,SLOT(loadmypersonalstatus())); QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->peersDialog,SLOT(loadmypersonalstatus()));