Extend the status service to notify on own status change.

Prepared PopupChatDialog for receive this notify event.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3410 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-08-30 20:14:58 +00:00
parent 005cf957f8
commit d9744ea979
2 changed files with 56 additions and 40 deletions

View File

@ -170,6 +170,9 @@ bool p3StatusService::sendStatus(const std::string &id, uint32_t status)
sendItem(statusItem);
}
/* send notify of own status change */
rsicontrol->getNotify().notifyPeerStatusChanged(statusInfo.id, statusInfo.status);
return true;
}

View File

@ -149,7 +149,6 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
//toolmenu->addAction(ui.action_Disable_Emoticons);
ui.pushtoolsButton->setMenu(toolmenu);
mCurrentColor = Qt::black;
mCurrentFont = QFont("Comic Sans MS", 10);
@ -166,9 +165,15 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
processSettings(true);
// initialize first status
StatusInfo statusInfo;
rsStatus->getStatus(dialogId, statusInfo);
updateStatus(QString::fromStdString(dialogId), statusInfo.status);
StatusInfo peerStatusInfo;
// No check of return value. Non existing status info is handled as offline.
rsStatus->getStatus(dialogId, peerStatusInfo);
updateStatus(QString::fromStdString(dialogId), peerStatusInfo.status);
StatusInfo ownStatusInfo;
if (rsStatus->getOwnStatus(ownStatusInfo)) {
updateStatus(QString::fromStdString(ownStatusInfo.id), ownStatusInfo.status);
}
}
/** Destructor. */
@ -1163,11 +1168,10 @@ void PopupChatDialog::setCurrentFileName(const QString &fileName)
void PopupChatDialog::updateStatus(const QString &peer_id, int status)
{
if (peer_id != QString::fromStdString(dialogId)) {
// it's not me
return;
}
std::string stdPeerId = peer_id.toStdString();
if (stdPeerId == dialogId) {
// the peers status has changed
switch (status) {
case RS_STATUS_OFFLINE:
ui.avatarlabel->setStyleSheet("QLabel#avatarlabel{ border-image:url(:/images/avatarstatus_bg_offline.png); }");
@ -1203,4 +1207,13 @@ void PopupChatDialog::updateStatus(const QString &peer_id, int status)
ui.infoframe->setVisible(true);
break;
}
return;
}
if (stdPeerId == rsPeers->getOwnId()) {
// my status has changed
return;
}
// ignore status change
}