mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-27 15:47:30 -04:00
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:
parent
005cf957f8
commit
d9744ea979
2 changed files with 56 additions and 40 deletions
|
@ -170,6 +170,9 @@ bool p3StatusService::sendStatus(const std::string &id, uint32_t status)
|
||||||
sendItem(statusItem);
|
sendItem(statusItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* send notify of own status change */
|
||||||
|
rsicontrol->getNotify().notifyPeerStatusChanged(statusInfo.id, statusInfo.status);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,6 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
||||||
//toolmenu->addAction(ui.action_Disable_Emoticons);
|
//toolmenu->addAction(ui.action_Disable_Emoticons);
|
||||||
ui.pushtoolsButton->setMenu(toolmenu);
|
ui.pushtoolsButton->setMenu(toolmenu);
|
||||||
|
|
||||||
|
|
||||||
mCurrentColor = Qt::black;
|
mCurrentColor = Qt::black;
|
||||||
mCurrentFont = QFont("Comic Sans MS", 10);
|
mCurrentFont = QFont("Comic Sans MS", 10);
|
||||||
|
|
||||||
|
@ -166,9 +165,15 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
||||||
processSettings(true);
|
processSettings(true);
|
||||||
|
|
||||||
// initialize first status
|
// initialize first status
|
||||||
StatusInfo statusInfo;
|
StatusInfo peerStatusInfo;
|
||||||
rsStatus->getStatus(dialogId, statusInfo);
|
// No check of return value. Non existing status info is handled as offline.
|
||||||
updateStatus(QString::fromStdString(dialogId), statusInfo.status);
|
rsStatus->getStatus(dialogId, peerStatusInfo);
|
||||||
|
updateStatus(QString::fromStdString(dialogId), peerStatusInfo.status);
|
||||||
|
|
||||||
|
StatusInfo ownStatusInfo;
|
||||||
|
if (rsStatus->getOwnStatus(ownStatusInfo)) {
|
||||||
|
updateStatus(QString::fromStdString(ownStatusInfo.id), ownStatusInfo.status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Destructor. */
|
/** Destructor. */
|
||||||
|
@ -1163,44 +1168,52 @@ void PopupChatDialog::setCurrentFileName(const QString &fileName)
|
||||||
|
|
||||||
void PopupChatDialog::updateStatus(const QString &peer_id, int status)
|
void PopupChatDialog::updateStatus(const QString &peer_id, int status)
|
||||||
{
|
{
|
||||||
if (peer_id != QString::fromStdString(dialogId)) {
|
std::string stdPeerId = peer_id.toStdString();
|
||||||
// it's not me
|
|
||||||
|
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); }");
|
||||||
|
ui.avatarlabel->setEnabled(false);
|
||||||
|
ui.infoframe->setVisible(true);
|
||||||
|
ui.infolabel->setText( QString::fromStdString(dialogName) + " " + tr("apears to be Offline.") +"\n" + tr("Messages you send will be lost and not delivered, rs-Mail this contact instead."));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RS_STATUS_INACTIVE:
|
||||||
|
ui.avatarlabel->setStyleSheet("QLabel#avatarlabel{ border-image:url(:/images/avatarstatus_bg_away.png); }");
|
||||||
|
ui.avatarlabel->setEnabled(true);
|
||||||
|
ui.infoframe->setVisible(true);
|
||||||
|
ui.infolabel->setText( QString::fromStdString(dialogName) + " " + tr("is Idle and may not reply"));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RS_STATUS_ONLINE:
|
||||||
|
ui.avatarlabel->setStyleSheet("QLabel#avatarlabel{ border-image:url(:/images/avatarstatus_bg_online.png); }");
|
||||||
|
ui.avatarlabel->setEnabled(true);
|
||||||
|
ui.infoframe->setVisible(false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RS_STATUS_AWAY:
|
||||||
|
ui.avatarlabel->setStyleSheet("QLabel#avatarlabel{ border-image:url(:/images/avatarstatus_bg_away.png); }");
|
||||||
|
ui.avatarlabel->setEnabled(true);
|
||||||
|
ui.infolabel->setText( QString::fromStdString(dialogName) + " " + tr("is Away and may not reply"));
|
||||||
|
ui.infoframe->setVisible(true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RS_STATUS_BUSY:
|
||||||
|
ui.avatarlabel->setStyleSheet("QLabel#avatarlabel{ border-image:url(:/images/avatarstatus_bg_busy.png); }");
|
||||||
|
ui.avatarlabel->setEnabled(true);
|
||||||
|
ui.infolabel->setText( QString::fromStdString(dialogName) + " " + tr("is Busy and may not reply"));
|
||||||
|
ui.infoframe->setVisible(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (status) {
|
if (stdPeerId == rsPeers->getOwnId()) {
|
||||||
case RS_STATUS_OFFLINE:
|
// my status has changed
|
||||||
ui.avatarlabel->setStyleSheet("QLabel#avatarlabel{ border-image:url(:/images/avatarstatus_bg_offline.png); }");
|
return;
|
||||||
ui.avatarlabel->setEnabled(false);
|
|
||||||
ui.infoframe->setVisible(true);
|
|
||||||
ui.infolabel->setText( QString::fromStdString(dialogName) + " " + tr("apears to be Offline.") +"\n" + tr("Messages you send will be lost and not delivered, rs-Mail this contact instead."));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RS_STATUS_INACTIVE:
|
|
||||||
ui.avatarlabel->setStyleSheet("QLabel#avatarlabel{ border-image:url(:/images/avatarstatus_bg_away.png); }");
|
|
||||||
ui.avatarlabel->setEnabled(true);
|
|
||||||
ui.infoframe->setVisible(true);
|
|
||||||
ui.infolabel->setText( QString::fromStdString(dialogName) + " " + tr("is Idle and may not reply"));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RS_STATUS_ONLINE:
|
|
||||||
ui.avatarlabel->setStyleSheet("QLabel#avatarlabel{ border-image:url(:/images/avatarstatus_bg_online.png); }");
|
|
||||||
ui.avatarlabel->setEnabled(true);
|
|
||||||
ui.infoframe->setVisible(false);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RS_STATUS_AWAY:
|
|
||||||
ui.avatarlabel->setStyleSheet("QLabel#avatarlabel{ border-image:url(:/images/avatarstatus_bg_away.png); }");
|
|
||||||
ui.avatarlabel->setEnabled(true);
|
|
||||||
ui.infolabel->setText( QString::fromStdString(dialogName) + " " + tr("is Away and may not reply"));
|
|
||||||
ui.infoframe->setVisible(true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RS_STATUS_BUSY:
|
|
||||||
ui.avatarlabel->setStyleSheet("QLabel#avatarlabel{ border-image:url(:/images/avatarstatus_bg_busy.png); }");
|
|
||||||
ui.avatarlabel->setEnabled(true);
|
|
||||||
ui.infolabel->setText( QString::fromStdString(dialogName) + " " + tr("is Busy and may not reply"));
|
|
||||||
ui.infoframe->setVisible(true);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ignore status change
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue