mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-12 16:09:37 -05: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
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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,44 +1168,52 @@ 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
|
||||
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); }");
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
if (stdPeerId == rsPeers->getOwnId()) {
|
||||
// my status has changed
|
||||
return;
|
||||
}
|
||||
|
||||
// ignore status change
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user