moved peerStatusChanged() from notify to rsEvents

This commit is contained in:
csoler 2025-06-14 21:56:09 +02:00
parent 0ce2dd8486
commit e6cacc4d34
26 changed files with 281 additions and 187 deletions

View file

@ -168,7 +168,7 @@ public:
/* Color definitions (for standard see default.qss) */ /* Color definitions (for standard see default.qss) */
QColor mTextColorGroup; QColor mTextColorGroup;
QColor mTextColorStatus[RS_STATUS_COUNT]; QColor mTextColorStatus[(int)RsStatusValue::RS_STATUS_COUNT];
void setIdentities(const std::list<RsGroupMetaData>& identities_meta); void setIdentities(const std::list<RsGroupMetaData>& identities_meta);

View file

@ -1471,7 +1471,7 @@ MainWindow::retranslateUi()
} }
/* set status object to status value */ /* set status object to status value */
static void setStatusObject(QObject *pObject, int nStatus) static void setStatusObject(QObject *pObject, RsStatusValue nStatus)
{ {
QMenu *pMenu = dynamic_cast<QMenu*>(pObject); QMenu *pMenu = dynamic_cast<QMenu*>(pObject);
if (pMenu) { if (pMenu) {
@ -1482,7 +1482,7 @@ static void setStatusObject(QObject *pObject, int nStatus)
continue; continue;
} }
if (pAction->data().toInt() == nStatus) { if (pAction->data().toInt() == (int)nStatus) {
pAction->setChecked(true); pAction->setChecked(true);
break; break;
} }
@ -1492,7 +1492,7 @@ static void setStatusObject(QObject *pObject, int nStatus)
RSComboBox *pComboBox = dynamic_cast<RSComboBox*>(pObject); RSComboBox *pComboBox = dynamic_cast<RSComboBox*>(pObject);
if (pComboBox) { if (pComboBox) {
/* set index of combobox */ /* set index of combobox */
int nIndex = pComboBox->findData(nStatus, Qt::UserRole); int nIndex = pComboBox->findData((int)nStatus, Qt::UserRole);
if (nIndex != -1) { if (nIndex != -1) {
pComboBox->setCurrentIndex(nIndex); pComboBox->setCurrentIndex(nIndex);
} }
@ -1555,20 +1555,20 @@ void MainWindow::initializeStatusObject(QObject *pObject, bool bConnect)
/* initialize menu */ /* initialize menu */
QActionGroup *pGroup = new QActionGroup(pMenu); QActionGroup *pGroup = new QActionGroup(pMenu);
QAction *pAction = new QAction(QIcon(StatusDefs::imageStatus(RS_STATUS_ONLINE)), StatusDefs::name(RS_STATUS_ONLINE), pMenu); QAction *pAction = new QAction(QIcon(StatusDefs::imageStatus(RsStatusValue::RS_STATUS_ONLINE)), StatusDefs::name(RsStatusValue::RS_STATUS_ONLINE), pMenu);
pAction->setData(RS_STATUS_ONLINE); pAction->setData((int)RsStatusValue::RS_STATUS_ONLINE);
pAction->setCheckable(true); pAction->setCheckable(true);
pMenu->addAction(pAction); pMenu->addAction(pAction);
pGroup->addAction(pAction); pGroup->addAction(pAction);
pAction = new QAction(QIcon(StatusDefs::imageStatus(RS_STATUS_BUSY)), StatusDefs::name(RS_STATUS_BUSY), pMenu); pAction = new QAction(QIcon(StatusDefs::imageStatus(RsStatusValue::RS_STATUS_BUSY)), StatusDefs::name(RsStatusValue::RS_STATUS_BUSY), pMenu);
pAction->setData(RS_STATUS_BUSY); pAction->setData((int)RsStatusValue::RS_STATUS_BUSY);
pAction->setCheckable(true); pAction->setCheckable(true);
pMenu->addAction(pAction); pMenu->addAction(pAction);
pGroup->addAction(pAction); pGroup->addAction(pAction);
pAction = new QAction(QIcon(StatusDefs::imageStatus(RS_STATUS_AWAY)), StatusDefs::name(RS_STATUS_AWAY), pMenu); pAction = new QAction(QIcon(StatusDefs::imageStatus(RsStatusValue::RS_STATUS_AWAY)), StatusDefs::name(RsStatusValue::RS_STATUS_AWAY), pMenu);
pAction->setData(RS_STATUS_AWAY); pAction->setData((int)RsStatusValue::RS_STATUS_AWAY);
pAction->setCheckable(true); pAction->setCheckable(true);
pMenu->addAction(pAction); pMenu->addAction(pAction);
pGroup->addAction(pAction); pGroup->addAction(pAction);
@ -1580,9 +1580,9 @@ void MainWindow::initializeStatusObject(QObject *pObject, bool bConnect)
/* initialize combobox */ /* initialize combobox */
RSComboBox *pComboBox = dynamic_cast<RSComboBox*>(pObject); RSComboBox *pComboBox = dynamic_cast<RSComboBox*>(pObject);
if (pComboBox) { if (pComboBox) {
pComboBox->addItem(QIcon(StatusDefs::imageStatus(RS_STATUS_ONLINE)), StatusDefs::name(RS_STATUS_ONLINE), RS_STATUS_ONLINE); pComboBox->addItem(QIcon(StatusDefs::imageStatus(RsStatusValue::RS_STATUS_ONLINE)), StatusDefs::name(RsStatusValue::RS_STATUS_ONLINE), (int)RsStatusValue::RS_STATUS_ONLINE);
pComboBox->addItem(QIcon(StatusDefs::imageStatus(RS_STATUS_BUSY)), StatusDefs::name(RS_STATUS_BUSY), RS_STATUS_BUSY); pComboBox->addItem(QIcon(StatusDefs::imageStatus(RsStatusValue::RS_STATUS_BUSY)), StatusDefs::name(RsStatusValue::RS_STATUS_BUSY), (int)RsStatusValue::RS_STATUS_BUSY);
pComboBox->addItem(QIcon(StatusDefs::imageStatus(RS_STATUS_AWAY)), StatusDefs::name(RS_STATUS_AWAY), RS_STATUS_AWAY); pComboBox->addItem(QIcon(StatusDefs::imageStatus(RsStatusValue::RS_STATUS_AWAY)), StatusDefs::name(RsStatusValue::RS_STATUS_AWAY), (int)RsStatusValue::RS_STATUS_AWAY);
if (bConnect) { if (bConnect) {
connect(pComboBox, SIGNAL(activated(int)), this, SLOT(statusChangedComboBox(int))); connect(pComboBox, SIGNAL(activated(int)), this, SLOT(statusChangedComboBox(int)));
@ -1610,11 +1610,11 @@ void MainWindow::removeStatusObject(QObject *pObject)
} }
/** Save own status Online,Away,Busy **/ /** Save own status Online,Away,Busy **/
void MainWindow::setStatus(QObject *pObject, int nStatus) void MainWindow::setStatus(QObject *pObject, RsStatusValue nStatus)
{ {
if (isIdle && nStatus == (int) RS_STATUS_ONLINE) { if (isIdle && nStatus == RsStatusValue::RS_STATUS_ONLINE) {
/* set idle only when I am online */ /* set idle only when I am online */
nStatus = RS_STATUS_INACTIVE; nStatus = RsStatusValue::RS_STATUS_INACTIVE;
} }
rsStatus->sendStatus(RsPeerId(), nStatus); rsStatus->sendStatus(RsPeerId(), nStatus);
@ -1634,7 +1634,7 @@ void MainWindow::statusChangedMenu(QAction *pAction)
return; return;
} }
setStatus(pAction->parent(), pAction->data().toInt()); setStatus(pAction->parent(), RsStatusValue(pAction->data().toInt()));
} }
/* new status from combobox in statusbar */ /* new status from combobox in statusbar */
@ -1645,7 +1645,7 @@ void MainWindow::statusChangedComboBox(int index)
} }
/* no object known */ /* no object known */
setStatus(NULL, statusComboBox->itemData(index, Qt::UserRole).toInt()); setStatus(NULL, RsStatusValue(statusComboBox->itemData(index, Qt::UserRole).toInt()));
} }
/*new setting*/ /*new setting*/

View file

@ -26,6 +26,7 @@
#include <set> #include <set>
#include "retroshare/rsevents.h" #include "retroshare/rsevents.h"
#include "retroshare/rsstatus.h"
#include "gui/common/rwindow.h" #include "gui/common/rwindow.h"
#include "gui/common/RSComboBox.h" #include "gui/common/RSComboBox.h"
@ -185,7 +186,7 @@ public:
/* initialize widget with status informations, status constant stored in data or in Qt::UserRole */ /* initialize widget with status informations, status constant stored in data or in Qt::UserRole */
void initializeStatusObject(QObject *pObject, bool bConnect); void initializeStatusObject(QObject *pObject, bool bConnect);
void removeStatusObject(QObject *pObject); void removeStatusObject(QObject *pObject);
void setStatus(QObject *pObject, int nStatus); void setStatus(QObject *pObject, RsStatusValue nStatus);
RSComboBox *statusComboBoxInstance(); RSComboBox *statusComboBoxInstance();
PeerStatus *peerstatusInstance(); PeerStatus *peerstatusInstance();

View file

@ -40,6 +40,7 @@
#include "notifyqt.h" #include "notifyqt.h"
#include "connect/ConnectFriendWizard.h" #include "connect/ConnectFriendWizard.h"
#include "util/PixmapMerging.h" #include "util/PixmapMerging.h"
#include "util/qtthreadsutils.h"
#include "LogoBar.h" #include "LogoBar.h"
#include "util/Widget.h" #include "util/Widget.h"
#include "util/misc.h" #include "util/misc.h"
@ -94,9 +95,23 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WindowFlags flags)
ui.avatar->setOwnId(); ui.avatar->setOwnId();
connect(ui.messagelineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(savestatusmessage())); connect(ui.messagelineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(savestatusmessage()));
connect(NotifyQt::getInstance(), SIGNAL(ownStatusMessageChanged()), this, SLOT(loadmystatusmessage())); connect(NotifyQt::getInstance(), SIGNAL(ownStatusMessageChanged()), this, SLOT(loadmystatusmessage()));
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateOwnStatus(QString,int)));
//connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateOwnStatus(QString,int)));
mEventHandlerId = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e)
{
RsQThreadUtils::postToObject([=](){
auto fe = dynamic_cast<const RsFriendListEvent*>(e.get());
if(!fe || fe->mEventCode != RsFriendListEventCode::NODE_STATUS_CHANGED)
return;
updateOwnStatus(QString::fromStdString(fe->mSslId.toStdString()),fe->mStatus);
}, this );
},mEventHandlerId,RsEventType::FRIEND_LIST);
for (std::set<RsPgpId>::iterator peerIt = expandedPeers.begin(); peerIt != expandedPeers.end(); ++peerIt) { for (std::set<RsPgpId>::iterator peerIt = expandedPeers.begin(); peerIt != expandedPeers.end(); ++peerIt) {
ui.friendList->addPeerToExpand(*peerIt); ui.friendList->addPeerToExpand(*peerIt);
@ -159,6 +174,7 @@ MessengerWindow::~MessengerWindow ()
{ {
// save settings // save settings
processSettings(false); processSettings(false);
rsEvents->unregisterEventsHandler(mEventHandlerId);
MainWindow *pMainWindow = MainWindow::getInstance(); MainWindow *pMainWindow = MainWindow::getInstance();
if (pMainWindow) { if (pMainWindow) {
@ -214,7 +230,7 @@ void MessengerWindow::savestatusmessage()
rsMsgs->setCustomStateString(ui.messagelineEdit->currentText().toUtf8().constData()); rsMsgs->setCustomStateString(ui.messagelineEdit->currentText().toUtf8().constData());
} }
void MessengerWindow::updateOwnStatus(const QString &peer_id, int status) void MessengerWindow::updateOwnStatus(const QString &peer_id, RsStatusValue status)
{ {
// add self nick + own status // add self nick + own status
if (peer_id == QString::fromStdString(rsPeers->getOwnId().toStdString())) if (peer_id == QString::fromStdString(rsPeers->getOwnId().toStdString()))

View file

@ -52,7 +52,7 @@ private slots:
/** Open Shared Manager **/ /** Open Shared Manager **/
void openShareManager(); void openShareManager();
void updateOwnStatus(const QString &peer_id, int status); void updateOwnStatus(const QString &peer_id, RsStatusValue status);
void savestatusmessage(); void savestatusmessage();
@ -68,6 +68,7 @@ private:
static std::set<RsPgpId> expandedPeers ; static std::set<RsPgpId> expandedPeers ;
static std::set<RsNodeGroupId> expandedGroups ; static std::set<RsNodeGroupId> expandedGroups ;
RsEventsHandlerId_t mEventHandlerId ;
}; };
#endif #endif

View file

@ -330,7 +330,7 @@ QString ChatDialog::getOwnName() const
return "ChatDialog::getOwnName(): invalid id type passed (RsPeerId is required). This is a bug."; return "ChatDialog::getOwnName(): invalid id type passed (RsPeerId is required). This is a bug.";
} }
void ChatDialog::setPeerStatus(uint32_t status) void ChatDialog::setPeerStatus(RsStatusValue status)
{ {
ChatWidget *cw = getChatWidget(); ChatWidget *cw = getChatWidget();
if (cw) if (cw)
@ -346,14 +346,14 @@ void ChatDialog::setPeerStatus(uint32_t status)
cw->updateStatus(QString::fromStdString(vpid.toStdString()), status); cw->updateStatus(QString::fromStdString(vpid.toStdString()), status);
} }
} }
int ChatDialog::getPeerStatus() RsStatusValue ChatDialog::getPeerStatus()
{ {
ChatWidget *cw = getChatWidget(); ChatWidget *cw = getChatWidget();
if (cw) { if (cw) {
return cw->getPeerStatus(); return cw->getPeerStatus();
} }
return 0; return RsStatusValue::RS_STATUS_UNKNOWN;
} }
QString ChatDialog::getTitle() QString ChatDialog::getTitle()

View file

@ -23,6 +23,8 @@
#ifndef CHATDIALOG_H #ifndef CHATDIALOG_H
#define CHATDIALOG_H #define CHATDIALOG_H
#include "retroshare/rsstatus.h"
#include <QWidget> #include <QWidget>
#include <retroshare/rsmsgs.h> #include <retroshare/rsmsgs.h>
@ -58,8 +60,8 @@ public:
bool setStyle(); bool setStyle();
const RSStyle *getStyle(); const RSStyle *getStyle();
int getPeerStatus(); RsStatusValue getPeerStatus();
void setPeerStatus(uint32_t state); void setPeerStatus(RsStatusValue state);
void focusDialog(); void focusDialog();

View file

@ -113,7 +113,7 @@ void ChatTabWidget::tabInfoChanged(ChatDialog *dialog)
} }
} else if (dialog->hasPeerStatus()) { } else if (dialog->hasPeerStatus()) {
setBlinking(tab, false); setBlinking(tab, false);
setTabIcon(tab, QIcon(StatusDefs::imageIM(dialog->getPeerStatus()))); setTabIcon(tab, QIcon(StatusDefs::imageIM((RsStatusValue)dialog->getPeerStatus())));
} else { } else {
setBlinking(tab, false); setBlinking(tab, false);
setTabIcon(tab, QIcon()); setTabIcon(tab, QIcon());
@ -155,7 +155,7 @@ void ChatTabWidget::getInfo(bool &isTyping, bool &hasNewMessage, QIcon *icon)
} else { } else {
cd = dynamic_cast<ChatDialog*>(currentWidget()); cd = dynamic_cast<ChatDialog*>(currentWidget());
if (cd && cd->hasPeerStatus()) { if (cd && cd->hasPeerStatus()) {
*icon = QIcon(StatusDefs::imageIM(cd->getPeerStatus())); *icon = QIcon(StatusDefs::imageIM((RsStatusValue)cd->getPeerStatus()));
} else { } else {
*icon = QIcon(); *icon = QIcon();
} }

View file

@ -38,6 +38,7 @@
#include "gui/chat/ChatUserNotify.h"//For BradCast #include "gui/chat/ChatUserNotify.h"//For BradCast
#include "util/DateTime.h" #include "util/DateTime.h"
#include "util/imageutil.h" #include "util/imageutil.h"
#include "util/qtthreadsutils.h"
#include "gui/im_history/ImHistoryBrowser.h" #include "gui/im_history/ImHistoryBrowser.h"
#include <retroshare/rsstatus.h> #include <retroshare/rsstatus.h>
@ -74,7 +75,7 @@
ChatWidget::ChatWidget(QWidget *parent) ChatWidget::ChatWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
, completionPosition(0), newMessages(false), typing(false), peerStatus(0) , completionPosition(0), newMessages(false), typing(false), peerStatus(RsStatusValue::RS_STATUS_UNKNOWN)
, sendingBlocked(false), useCMark(false) , sendingBlocked(false), useCMark(false)
, lastStatusSendTime(0) , lastStatusSendTime(0)
, firstShow(true), inChatCharFormatChanged(false), firstSearch(true) , firstShow(true), inChatCharFormatChanged(false), firstSearch(true)
@ -171,7 +172,22 @@ ChatWidget::ChatWidget(QWidget *parent)
connect(ui->hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>))); connect(ui->hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>)));
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)));
mEventHandlerId = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e)
{
RsQThreadUtils::postToObject([=](){
auto fe = dynamic_cast<const RsFriendListEvent*>(e.get());
if(!fe || fe->mEventCode != RsFriendListEventCode::NODE_STATUS_CHANGED)
return;
updateStatus(QString::fromStdString(fe->mSslId.toStdString()),fe->mStatus);
}, this );
},mEventHandlerId,RsEventType::FRIEND_LIST);
connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&))); connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&)));
connect(NotifyQt::getInstance(), SIGNAL(chatFontChanged()), this, SLOT(resetFonts())); connect(NotifyQt::getInstance(), SIGNAL(chatFontChanged()), this, SLOT(resetFonts()));
@ -254,6 +270,7 @@ ChatWidget::ChatWidget(QWidget *parent)
ChatWidget::~ChatWidget() ChatWidget::~ChatWidget()
{ {
processSettings(false); processSettings(false);
rsEvents->unregisterEventsHandler(mEventHandlerId);
/* Cleanup plugin functions */ /* Cleanup plugin functions */
foreach (ChatWidgetHolder *chatWidgetHolder, mChatWidgetHolder) { foreach (ChatWidgetHolder *chatWidgetHolder, mChatWidgetHolder) {
@ -1788,7 +1805,7 @@ void ChatWidget::setCurrentFileName(const QString &fileName)
setWindowModified(false); setWindowModified(false);
} }
void ChatWidget::updateStatus(const QString &peer_id, int status) void ChatWidget::updateStatus(const QString &peer_id, RsStatusValue status)
{ {
if (! (chatType() == CHATTYPE_PRIVATE || chatType() == CHATTYPE_DISTANT)) if (! (chatType() == CHATTYPE_PRIVATE || chatType() == CHATTYPE_DISTANT))
{ {
@ -1842,26 +1859,27 @@ void ChatWidget::updateStatus(const QString &peer_id, int status)
bool atEnd = (scrollbar->value() == scrollbar->maximum()); bool atEnd = (scrollbar->value() == scrollbar->maximum());
switch (status) { switch (status) {
case RS_STATUS_OFFLINE: default:
case RsStatusValue::RS_STATUS_OFFLINE:
ui->info_Frame->setVisible(true); ui->info_Frame->setVisible(true);
ui->infoLabel->setText(peerName + " " + tr("appears to be Offline.") +"\n" + tr("Messages you send will be delivered after Friend is again Online.")); ui->infoLabel->setText(peerName + " " + tr("appears to be Offline.") +"\n" + tr("Messages you send will be delivered after Friend is again Online."));
break; break;
case RS_STATUS_INACTIVE: case RsStatusValue::RS_STATUS_INACTIVE:
ui->info_Frame->setVisible(true); ui->info_Frame->setVisible(true);
ui->infoLabel->setText(peerName + " " + tr("is Idle and may not reply")); ui->infoLabel->setText(peerName + " " + tr("is Idle and may not reply"));
break; break;
case RS_STATUS_ONLINE: case RsStatusValue::RS_STATUS_ONLINE:
ui->info_Frame->setVisible(false); ui->info_Frame->setVisible(false);
break; break;
case RS_STATUS_AWAY: case RsStatusValue::RS_STATUS_AWAY:
ui->infoLabel->setText(peerName + " " + tr("is Away and may not reply")); ui->infoLabel->setText(peerName + " " + tr("is Away and may not reply"));
ui->info_Frame->setVisible(true); ui->info_Frame->setVisible(true);
break; break;
case RS_STATUS_BUSY: case RsStatusValue::RS_STATUS_BUSY:
ui->infoLabel->setText(peerName + " " + tr("is Busy and may not reply")); ui->infoLabel->setText(peerName + " " + tr("is Busy and may not reply"));
ui->info_Frame->setVisible(true); ui->info_Frame->setVisible(true);
break; break;
@ -1869,7 +1887,8 @@ void ChatWidget::updateStatus(const QString &peer_id, int status)
ui->titleLabel->setText(peerName); ui->titleLabel->setText(peerName);
ui->titleLabel->setToolTip(tooltip_info); ui->titleLabel->setToolTip(tooltip_info);
ui->statusLabel->setText(QString("(%1)").arg(StatusDefs::name(status))); #warning inconsistent conversion here
ui->statusLabel->setText(QString("(%1)").arg(StatusDefs::name((RsStatusValue)status)));
peerStatus = status; peerStatus = status;

View file

@ -31,6 +31,7 @@
#include <retroshare/rsmsgs.h> #include <retroshare/rsmsgs.h>
#include <retroshare/rsfiles.h> #include <retroshare/rsfiles.h>
#include <retroshare/rsstatus.h>
#include <QCompleter> #include <QCompleter>
#include <QTextCharFormat> #include <QTextCharFormat>
@ -62,7 +63,7 @@ public:
// status comes from notifyPeerStatusChanged // status comes from notifyPeerStatusChanged
// see rststaus.h for possible values // see rststaus.h for possible values
virtual void updateStatus(int /*status*/) {} virtual void updateStatus(RsStatusValue /*status*/) {}
protected: protected:
ChatWidget *mChatWidget; ChatWidget *mChatWidget;
@ -105,7 +106,7 @@ public:
void addToolsAction(QAction *action); void addToolsAction(QAction *action);
QString getTitle() { return title; } QString getTitle() { return title; }
int getPeerStatus() { return peerStatus; } RsStatusValue getPeerStatus() { return peerStatus; }
void setName(const QString &name); void setName(const QString &name);
bool setStyle(); bool setStyle();
@ -130,7 +131,7 @@ public:
const QList<ChatWidgetHolder*> &chatWidgetHolderList() { return mChatWidgetHolder; } const QList<ChatWidgetHolder*> &chatWidgetHolderList() { return mChatWidgetHolder; }
public slots: public slots:
void updateStatus(const QString &peer_id, int status); void updateStatus(const QString &peer_id, RsStatusValue status);
void setUseCMark(const bool bUseCMark); void setUseCMark(const bool bUseCMark);
void updateCMPreview(); void updateCMPreview();
@ -144,7 +145,7 @@ private slots:
signals: signals:
void infoChanged(ChatWidget*); void infoChanged(ChatWidget*);
void newMessage(ChatWidget*); void newMessage(ChatWidget*);
void statusChanged(int); void statusChanged(RsStatusValue);
void textBrowserAskContextMenu(QMenu* contextMnu, QString anchorForPosition, const QPoint point); void textBrowserAskContextMenu(QMenu* contextMnu, QString anchorForPosition, const QPoint point);
protected: protected:
@ -229,7 +230,7 @@ private:
bool newMessages; bool newMessages;
bool typing; bool typing;
int peerStatus; RsStatusValue peerStatus;
bool sendingBlocked; bool sendingBlocked;
bool useCMark; bool useCMark;
@ -272,6 +273,8 @@ private:
ChatLobbyUserNotify* notify; ChatLobbyUserNotify* notify;
Ui::ChatWidget *ui; Ui::ChatWidget *ui;
RsEventsHandlerId_t mEventHandlerId ;
}; };
#endif // CHATWIDGET_H #endif // CHATWIDGET_H

View file

@ -350,7 +350,7 @@ void PopupChatWindow::calculateTitle(ChatDialog *dialog)
} else { } else {
mBlinkIcon = QIcon(); mBlinkIcon = QIcon();
if (cd && cd->hasPeerStatus()) { if (cd && cd->hasPeerStatus()) {
icon = QIcon(StatusDefs::imageIM(cd->getPeerStatus())); icon = QIcon(StatusDefs::imageIM((RsStatusValue)cd->getPeerStatus()));
} else { } else {
icon = qApp->windowIcon(); icon = qApp->windowIcon();
} }
@ -361,7 +361,7 @@ void PopupChatWindow::calculateTitle(ChatDialog *dialog)
if (cd) { if (cd) {
QString title = cd->getTitle(); QString title = cd->getTitle();
if (cd->hasPeerStatus()) { if (cd->hasPeerStatus()) {
title += " (" + StatusDefs::name(cd->getPeerStatus()) + ")"; title += " (" + StatusDefs::name((RsStatusValue)cd->getPeerStatus()) + ")";
} }
setWindowTitle(title); setWindowTitle(title);
} else { } else {

View file

@ -121,7 +121,7 @@ void PopupDistantChatDialog::updateDisplay()
getChatWidget()->blockSending(tr( "Can't send message immediately, " getChatWidget()->blockSending(tr( "Can't send message immediately, "
"because there is no tunnel " "because there is no tunnel "
"available." )); "available." ));
setPeerStatus(RS_STATUS_OFFLINE); setPeerStatus(RsStatusValue::RS_STATUS_OFFLINE);
break ; break ;
case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED: case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED:
std::cerr << "Chat remotely closed. " << std::endl; std::cerr << "Chat remotely closed. " << std::endl;
@ -131,7 +131,7 @@ void PopupDistantChatDialog::updateDisplay()
getChatWidget()->updateStatusString("%1", tr( "Your partner closed the conversation." ), true ); getChatWidget()->updateStatusString("%1", tr( "Your partner closed the conversation." ), true );
getChatWidget()->blockSending(tr( "Your partner closed the conversation.")); getChatWidget()->blockSending(tr( "Your partner closed the conversation."));
setPeerStatus(RS_STATUS_OFFLINE) ; setPeerStatus(RsStatusValue::RS_STATUS_OFFLINE) ;
break ; break ;
case RS_DISTANT_CHAT_STATUS_TUNNEL_DN: case RS_DISTANT_CHAT_STATUS_TUNNEL_DN:
@ -145,7 +145,7 @@ void PopupDistantChatDialog::updateDisplay()
_status_label->setToolTip(msg); _status_label->setToolTip(msg);
getChatWidget()->updateStatusString("%1", msg, true); getChatWidget()->updateStatusString("%1", msg, true);
getChatWidget()->blockSending(msg); getChatWidget()->blockSending(msg);
setPeerStatus(RS_STATUS_OFFLINE); setPeerStatus(RsStatusValue::RS_STATUS_OFFLINE);
break; break;
case RS_DISTANT_CHAT_STATUS_CAN_TALK: case RS_DISTANT_CHAT_STATUS_CAN_TALK:
@ -153,7 +153,7 @@ void PopupDistantChatDialog::updateDisplay()
msg = QObject::tr( "End-to-end encrypted conversation established"); msg = QObject::tr( "End-to-end encrypted conversation established");
_status_label->setToolTip(msg); _status_label->setToolTip(msg);
getChatWidget()->unblockSending(); getChatWidget()->unblockSending();
setPeerStatus(RS_STATUS_ONLINE); setPeerStatus(RsStatusValue::RS_STATUS_ONLINE);
break; break;
} }
} }

View file

@ -27,6 +27,7 @@
#include "gui/notifyqt.h" #include "gui/notifyqt.h"
#include "util/misc.h" #include "util/misc.h"
#include "util/qtthreadsutils.h"
#include "gui/common/AvatarDefs.h" #include "gui/common/AvatarDefs.h"
#include "gui/common/AvatarDialog.h" #include "gui/common/AvatarDialog.h"
@ -43,17 +44,32 @@ AvatarWidget::AvatarWidget(QWidget *parent) : QLabel(parent), ui(new Ui::AvatarW
mFlag.isOwnId = false; mFlag.isOwnId = false;
defaultAvatar = ":/images/no_avatar_background.png"; defaultAvatar = ":/images/no_avatar_background.png";
mPeerState = RS_STATUS_OFFLINE ; mPeerState = RsStatusValue::RS_STATUS_OFFLINE ;
setFrameType(NO_FRAME); setFrameType(NO_FRAME);
/* connect signals */ /* connect signals */
connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&))); connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&)));
connect(NotifyQt::getInstance(), SIGNAL(ownAvatarChanged()), this, SLOT(updateOwnAvatar())); connect(NotifyQt::getInstance(), SIGNAL(ownAvatarChanged()), this, SLOT(updateOwnAvatar()));
mEventHandlerId = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event)
{
RsQThreadUtils::postToObject([=](){
const RsFriendListEvent *e = dynamic_cast<const RsFriendListEvent*>(event.get());
if(!e)
return;
updateStatus(QString::fromStdString(e->mSslId.toStdString()),e->mStatus);
}, this );
}, mEventHandlerId, RsEventType::FRIEND_LIST );
} }
AvatarWidget::~AvatarWidget() AvatarWidget::~AvatarWidget()
{ {
rsEvents->unregisterEventsHandler(mEventHandlerId);
delete ui; delete ui;
} }
@ -68,15 +84,15 @@ QString AvatarWidget::frameState()
case STATUS_FRAME: case STATUS_FRAME:
switch (mPeerState) switch (mPeerState)
{ {
case RS_STATUS_OFFLINE: case RsStatusValue::RS_STATUS_OFFLINE:
return "OFFLINE"; return "OFFLINE";
case RS_STATUS_INACTIVE: case RsStatusValue::RS_STATUS_INACTIVE:
return "INACTIVE"; return "INACTIVE";
case RS_STATUS_ONLINE: case RsStatusValue::RS_STATUS_ONLINE:
return "ONLINE"; return "ONLINE";
case RS_STATUS_AWAY: case RsStatusValue::RS_STATUS_AWAY:
return "AWAY"; return "AWAY";
case RS_STATUS_BUSY: case RsStatusValue::RS_STATUS_BUSY:
return "BUSY"; return "BUSY";
} }
} }
@ -107,6 +123,7 @@ void AvatarWidget::setFrameType(FrameType type)
{ {
mFrameType = type; mFrameType = type;
#ifdef TO_REMOVE
switch (mFrameType) { switch (mFrameType) {
case NO_FRAME: case NO_FRAME:
disconnect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateStatus(const QString&, int))); disconnect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateStatus(const QString&, int)));
@ -118,6 +135,9 @@ void AvatarWidget::setFrameType(FrameType type)
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateStatus(const QString&, int))); connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateStatus(const QString&, int)));
break; break;
} }
#endif
//refreshAvatarImage(); //refreshAvatarImage();
refreshStatus(); refreshStatus();
@ -179,7 +199,7 @@ void AvatarWidget::refreshStatus()
} }
case STATUS_FRAME: case STATUS_FRAME:
{ {
uint32_t status = 0; RsStatusValue status = RsStatusValue::RS_STATUS_UNKNOWN;
if (mId.isNotSet()) if (mId.isNotSet())
return; return;
@ -193,7 +213,7 @@ void AvatarWidget::refreshStatus()
status = statusInfo.status ; status = statusInfo.status ;
} }
else if(mId.isDistantChatId()) else if(mId.isDistantChatId())
status = RS_STATUS_ONLINE ; status = RsStatusValue::RS_STATUS_ONLINE ;
else else
{ {
std::cerr << "Unhandled chat id type in AvatarWidget::refreshStatus()" << std::endl; std::cerr << "Unhandled chat id type in AvatarWidget::refreshStatus()" << std::endl;
@ -217,10 +237,10 @@ void AvatarWidget::refreshStatus()
{ {
switch (dcpinfo.status) switch (dcpinfo.status)
{ {
case RS_DISTANT_CHAT_STATUS_CAN_TALK : status = RS_STATUS_ONLINE ; break; case RS_DISTANT_CHAT_STATUS_CAN_TALK : status = RsStatusValue::RS_STATUS_ONLINE ; break;
case RS_DISTANT_CHAT_STATUS_UNKNOWN : // Fall-through case RS_DISTANT_CHAT_STATUS_UNKNOWN : // Fall-through
case RS_DISTANT_CHAT_STATUS_TUNNEL_DN : // Fall-through case RS_DISTANT_CHAT_STATUS_TUNNEL_DN : // Fall-through
case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED : status = RS_STATUS_OFFLINE; case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED : status = RsStatusValue::RS_STATUS_OFFLINE;
} }
} }
else else
@ -238,20 +258,20 @@ void AvatarWidget::refreshStatus()
} }
} }
void AvatarWidget::updateStatus(const QString& peerId, int status) void AvatarWidget::updateStatus(const QString& peerId, RsStatusValue status)
{ {
if (mId.isPeerId() && mId.toPeerId() == RsPeerId(peerId.toStdString())) if (mId.isPeerId() && mId.toPeerId() == RsPeerId(peerId.toStdString()))
updateStatus(status) ; updateStatus(status) ;
} }
void AvatarWidget::updateStatus(int status) void AvatarWidget::updateStatus(RsStatusValue status)
{ {
if (mFrameType != STATUS_FRAME) if (mFrameType != STATUS_FRAME)
return; return;
mPeerState = status; mPeerState = status;
setEnabled(((uint32_t) status == RS_STATUS_OFFLINE) ? false : true); setEnabled((status == RsStatusValue::RS_STATUS_OFFLINE) ? false : true);
RsApplication::refreshStyleSheet(this, false); RsApplication::refreshStyleSheet(this, false);
} }

View file

@ -24,7 +24,9 @@
#include <QLabel> #include <QLabel>
#include <stdint.h> #include <stdint.h>
#include <retroshare/rstypes.h> #include <retroshare/rstypes.h>
#include <retroshare/rsevents.h>
#include <retroshare/rsmsgs.h> #include <retroshare/rsmsgs.h>
#include <retroshare/rsstatus.h>
namespace Ui { namespace Ui {
class AvatarWidget; class AvatarWidget;
@ -57,14 +59,14 @@ protected:
void mouseReleaseEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event);
private slots: private slots:
void updateStatus(const QString& peerId, int status); void updateStatus(const QString& peerId, RsStatusValue status);
void updateAvatar(const QString& peerId); void updateAvatar(const QString& peerId);
void updateOwnAvatar(); void updateOwnAvatar();
private: private:
void refreshAvatarImage() ; void refreshAvatarImage() ;
void refreshStatus(); void refreshStatus();
void updateStatus(int status); void updateStatus(RsStatusValue status);
QString defaultAvatar; QString defaultAvatar;
Ui::AvatarWidget *ui; Ui::AvatarWidget *ui;
@ -77,7 +79,9 @@ private:
// bool isGpg : 1; // bool isGpg : 1;
} mFlag; } mFlag;
FrameType mFrameType; FrameType mFrameType;
uint32_t mPeerState; RsStatusValue mPeerState;
RsEventsHandlerId_t mEventHandlerId;
}; };
#endif // AVATARWIDGET_H #endif // AVATARWIDGET_H

View file

@ -458,7 +458,7 @@ QVariant RsFriendListModel::statusRole(const EntryIndex& fmpe,int /*column*/) co
StatusInfo status; StatusInfo status;
rsStatus->getStatus(node->node_info.id, status); rsStatus->getStatus(node->node_info.id, status);
return QVariant(status.status); return QVariant((int)status.status);
} }
return QVariant(); return QVariant();
} }
@ -603,7 +603,7 @@ QVariant RsFriendListModel::onlineRole(const EntryIndex& e, int /*col*/) const
for(uint32_t i=0;i<prof.child_node_indices.size();++i) for(uint32_t i=0;i<prof.child_node_indices.size();++i)
if(mLocations[prof.child_node_indices[i]].node_info.state & RS_PEER_STATE_CONNECTED) if(mLocations[prof.child_node_indices[i]].node_info.state & RS_PEER_STATE_CONNECTED)
return QVariant(RS_STATUS_ONLINE); return QVariant((int)RsStatusValue::RS_STATUS_ONLINE);
} }
break; break;
} }
@ -616,7 +616,7 @@ QVariant RsFriendListModel::onlineRole(const EntryIndex& e, int /*col*/) const
{ {
for(uint32_t i=0;i<prof->child_node_indices.size();++i) for(uint32_t i=0;i<prof->child_node_indices.size();++i)
if(mLocations[prof->child_node_indices[i]].node_info.state & RS_PEER_STATE_CONNECTED) if(mLocations[prof->child_node_indices[i]].node_info.state & RS_PEER_STATE_CONNECTED)
return QVariant(RS_STATUS_ONLINE); return QVariant((int)RsStatusValue::RS_STATUS_ONLINE);
} }
} }
break; break;
@ -626,12 +626,12 @@ QVariant RsFriendListModel::onlineRole(const EntryIndex& e, int /*col*/) const
const HierarchicalNodeInformation *node = getNodeInfo(e); const HierarchicalNodeInformation *node = getNodeInfo(e);
if(node && bool(node->node_info.state & RS_PEER_STATE_CONNECTED)) if(node && bool(node->node_info.state & RS_PEER_STATE_CONNECTED))
return QVariant(RS_STATUS_ONLINE); return QVariant((int)RsStatusValue::RS_STATUS_ONLINE);
else else
return QVariant(RS_STATUS_OFFLINE); return QVariant((int)RsStatusValue::RS_STATUS_OFFLINE);
} }
} }
return QVariant(RS_STATUS_OFFLINE); return QVariant((int)RsStatusValue::RS_STATUS_OFFLINE);
} }
QVariant RsFriendListModel::fontRole(const EntryIndex& e, int col) const QVariant RsFriendListModel::fontRole(const EntryIndex& e, int col) const
@ -640,14 +640,14 @@ QVariant RsFriendListModel::fontRole(const EntryIndex& e, int col) const
std::cerr << " font role " << e.type << ", (" << (int)e.group_index << ","<< (int)e.profile_index << ","<< (int)e.node_index << ") col="<< col<<": " << std::endl; std::cerr << " font role " << e.type << ", (" << (int)e.group_index << ","<< (int)e.profile_index << ","<< (int)e.node_index << ") col="<< col<<": " << std::endl;
#endif #endif
int status = onlineRole(e,col).toInt(); auto status = RsStatusValue(onlineRole(e,col).toInt());
switch (status) switch (status)
{ {
case RS_STATUS_AWAY: case RsStatusValue::RS_STATUS_AWAY:
case RS_STATUS_BUSY: case RsStatusValue::RS_STATUS_BUSY:
case RS_STATUS_ONLINE: case RsStatusValue::RS_STATUS_ONLINE:
case RS_STATUS_INACTIVE: case RsStatusValue::RS_STATUS_INACTIVE:
{ {
QFont font ; QFont font ;
QTreeView* myParent = dynamic_cast<QTreeView*>(QAbstractItemModel::parent()); QTreeView* myParent = dynamic_cast<QTreeView*>(QAbstractItemModel::parent());
@ -781,7 +781,7 @@ QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const
else else
{ {
return QVariant(QString::fromUtf8(node->node_info.location.c_str())+"\n" return QVariant(QString::fromUtf8(node->node_info.location.c_str())+"\n"
+ "(" + StatusDefs::name(statusRole(e,col).toInt()) + ")"); + "(" + StatusDefs::name(RsStatusValue(statusRole(e,col).toInt())) + ")");
} }
else else
return QVariant(QString::fromUtf8(node->node_info.location.c_str())); return QVariant(QString::fromUtf8(node->node_info.location.c_str()));
@ -900,10 +900,10 @@ bool RsFriendListModel::getPeerOnlineStatus(const EntryIndex& e) const
return (noded && (noded->node_info.state & RS_PEER_STATE_CONNECTED)); return (noded && (noded->node_info.state & RS_PEER_STATE_CONNECTED));
} }
const RsFriendListModel::HierarchicalNodeInformation *RsFriendListModel::getBestNodeInformation(const HierarchicalProfileInformation *profileInfo, uint32_t *status) const const RsFriendListModel::HierarchicalNodeInformation *RsFriendListModel::getBestNodeInformation(const HierarchicalProfileInformation *profileInfo, RsStatusValue *status) const
{ {
if (status) { if (status) {
*status = RS_STATUS_OFFLINE; *status = RsStatusValue::RS_STATUS_OFFLINE;
} }
if (!profileInfo) { if (!profileInfo) {
@ -921,28 +921,28 @@ const RsFriendListModel::HierarchicalNodeInformation *RsFriendListModel::getBest
int statusIndex = 0; int statusIndex = 0;
switch (statusInfo.status) { switch (statusInfo.status) {
case RS_STATUS_OFFLINE: case RsStatusValue::RS_STATUS_OFFLINE:
statusIndex = 1; statusIndex = 1;
break; break;
case RS_STATUS_INACTIVE: case RsStatusValue::RS_STATUS_INACTIVE:
statusIndex = 2; statusIndex = 2;
break; break;
case RS_STATUS_AWAY: case RsStatusValue::RS_STATUS_AWAY:
statusIndex = 3; statusIndex = 3;
break; break;
case RS_STATUS_BUSY: case RsStatusValue::RS_STATUS_BUSY:
statusIndex = 4; statusIndex = 4;
break; break;
case RS_STATUS_ONLINE: case RsStatusValue::RS_STATUS_ONLINE:
statusIndex = 5; statusIndex = 5;
break; break;
default: default:
std::cerr << "FriendListModel: Unknown status " << statusInfo.status << std::endl; std::cerr << "FriendListModel: Unknown status " << (int)statusInfo.status << std::endl;
} }
if (bestStatusIndex == 0 || statusIndex > bestStatusIndex) { if (bestStatusIndex == 0 || statusIndex > bestStatusIndex) {
@ -999,7 +999,7 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons
QPixmap sslAvatar; QPixmap sslAvatar;
bool foundAvatar = false; bool foundAvatar = false;
const HierarchicalProfileInformation *hn = getProfileInfo(entry); const HierarchicalProfileInformation *hn = getProfileInfo(entry);
uint32_t status = RS_STATUS_OFFLINE; RsStatusValue status = RsStatusValue::RS_STATUS_OFFLINE;
const HierarchicalNodeInformation *bestNodeInformation = NULL; const HierarchicalNodeInformation *bestNodeInformation = NULL;
if (mDisplayStatusIcon) { if (mDisplayStatusIcon) {
@ -1049,7 +1049,7 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons
QPixmap sslAvatar; QPixmap sslAvatar;
AvatarDefs::getAvatarFromSslId(RsPeerId(hn->node_info.id.toStdString()), sslAvatar); AvatarDefs::getAvatarFromSslId(RsPeerId(hn->node_info.id.toStdString()), sslAvatar);
if (mDisplayStatusIcon) { if (mDisplayStatusIcon) {
QPixmap sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(statusRole(entry, col).toInt())); QPixmap sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(RsStatusValue(statusRole(entry, col).toInt())));
return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon))); return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon)));
} }

View file

@ -162,7 +162,7 @@ public:
/* Color definitions (for standard see default.qss) */ /* Color definitions (for standard see default.qss) */
QColor mTextColorGroup; QColor mTextColorGroup;
QColor mTextColorStatus[RS_STATUS_COUNT]; QColor mTextColorStatus[(int)RsStatusValue::RS_STATUS_COUNT];
private: private:
const HierarchicalGroupInformation *getGroupInfo (const EntryIndex&) const; const HierarchicalGroupInformation *getGroupInfo (const EntryIndex&) const;
@ -223,7 +223,7 @@ private:
uint32_t updateFilterStatus(ForumModelIndex i,int column,const QStringList& strings); uint32_t updateFilterStatus(ForumModelIndex i,int column,const QStringList& strings);
const HierarchicalNodeInformation *getBestNodeInformation(const HierarchicalProfileInformation *profileInfo, uint32_t *status = NULL) const; const HierarchicalNodeInformation *getBestNodeInformation(const HierarchicalProfileInformation *profileInfo, RsStatusValue *status = NULL) const;
QStringList mFilterStrings; QStringList mFilterStrings;
FilterType mFilterType; FilterType mFilterType;

View file

@ -255,7 +255,7 @@ static void initSslItem(QTreeWidgetItem *item, const RsPeerDetails &detail, cons
QString name = PeerDefs::nameWithLocation(detail); QString name = PeerDefs::nameWithLocation(detail);
item->setText(COLUMN_NAME, name); item->setText(COLUMN_NAME, name);
int state = RS_STATUS_OFFLINE; RsStatusValue state = RsStatusValue::RS_STATUS_OFFLINE;
if (detail.state & RS_PEER_STATE_CONNECTED) { if (detail.state & RS_PEER_STATE_CONNECTED) {
std::list<StatusInfo>::const_iterator it; std::list<StatusInfo>::const_iterator it;
for (it = statusInfo.begin(); it != statusInfo.end() ; ++it) { for (it = statusInfo.begin(); it != statusInfo.end() ; ++it) {
@ -266,7 +266,7 @@ static void initSslItem(QTreeWidgetItem *item, const RsPeerDetails &detail, cons
} }
} }
if (state != (int) RS_STATUS_OFFLINE) { if (state != RsStatusValue::RS_STATUS_OFFLINE) {
item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline); item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline);
} }
@ -276,7 +276,7 @@ static void initSslItem(QTreeWidgetItem *item, const RsPeerDetails &detail, cons
item->setData(COLUMN_NAME, ROLE_SORT_GROUP, 1); item->setData(COLUMN_NAME, ROLE_SORT_GROUP, 1);
item->setData(COLUMN_NAME, ROLE_SORT_STANDARD_GROUP, 0); item->setData(COLUMN_NAME, ROLE_SORT_STANDARD_GROUP, 0);
item->setData(COLUMN_NAME, ROLE_SORT_NAME, name); item->setData(COLUMN_NAME, ROLE_SORT_NAME, name);
item->setData(COLUMN_NAME, ROLE_SORT_STATE, state); item->setData(COLUMN_NAME, ROLE_SORT_STATE, (int)state);
} }
void FriendSelectionWidget::fillList() void FriendSelectionWidget::fillList()
@ -515,17 +515,17 @@ void FriendSelectionWidget::secured_fillList()
sslIds.clear(); sslIds.clear();
rsPeers->getAssociatedSSLIds(*gpgIt, sslIds); rsPeers->getAssociatedSSLIds(*gpgIt, sslIds);
int state = RS_STATUS_OFFLINE; RsStatusValue state = RsStatusValue::RS_STATUS_OFFLINE;
for (statusIt = statusInfo.begin(); statusIt != statusInfo.end() ; ++statusIt) { for (statusIt = statusInfo.begin(); statusIt != statusInfo.end() ; ++statusIt) {
if (std::find(sslIds.begin(), sslIds.end(), statusIt->id) != sslIds.end()) { if (std::find(sslIds.begin(), sslIds.end(), statusIt->id) != sslIds.end()) {
if (statusIt->status != RS_STATUS_OFFLINE) { if (statusIt->status != RsStatusValue::RS_STATUS_OFFLINE) {
state = RS_STATUS_ONLINE; state = RsStatusValue::RS_STATUS_ONLINE;
break; break;
} }
} }
} }
if (state != (int) RS_STATUS_OFFLINE) { if (state != RsStatusValue::RS_STATUS_OFFLINE) {
gpgItem->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline()); gpgItem->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline());
} }
@ -536,7 +536,7 @@ void FriendSelectionWidget::secured_fillList()
gpgItem->setData(COLUMN_NAME, ROLE_SORT_GROUP, 1); gpgItem->setData(COLUMN_NAME, ROLE_SORT_GROUP, 1);
gpgItem->setData(COLUMN_NAME, ROLE_SORT_STANDARD_GROUP, 0); gpgItem->setData(COLUMN_NAME, ROLE_SORT_STANDARD_GROUP, 0);
gpgItem->setData(COLUMN_NAME, ROLE_SORT_NAME, name); gpgItem->setData(COLUMN_NAME, ROLE_SORT_NAME, name);
gpgItem->setData(COLUMN_NAME, ROLE_SORT_STATE, state); gpgItem->setData(COLUMN_NAME, ROLE_SORT_STATE, (int)state);
if (mListModus == MODUS_CHECK) { if (mListModus == MODUS_CHECK) {
gpgItem->setCheckState(0, Qt::Unchecked); gpgItem->setCheckState(0, Qt::Unchecked);
@ -791,13 +791,13 @@ void FriendSelectionWidget::groupsChanged()
} }
} }
void FriendSelectionWidget::peerStatusChanged(const RsPeerId& peerid, int status) void FriendSelectionWidget::peerStatusChanged(const RsPeerId& peerid, RsStatusValue status)
{ {
if(!isVisible()) if(!isVisible())
return ; return ;
QString gpgId; QString gpgId;
int gpgStatus = RS_STATUS_OFFLINE; RsStatusValue gpgStatus = RsStatusValue::RS_STATUS_OFFLINE;
if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG)) { if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG)) {
/* need gpg id and online state */ /* need gpg id and online state */
@ -806,7 +806,7 @@ void FriendSelectionWidget::peerStatusChanged(const RsPeerId& peerid, int status
{ {
gpgId = QString::fromStdString(detail.gpg_id.toStdString()); gpgId = QString::fromStdString(detail.gpg_id.toStdString());
if (status == (int) RS_STATUS_OFFLINE) { if (status == RsStatusValue::RS_STATUS_OFFLINE) {
/* try other nodes */ /* try other nodes */
std::list<RsPeerId> sslIds; std::list<RsPeerId> sslIds;
rsPeers->getAssociatedSSLIds(detail.gpg_id, sslIds); rsPeers->getAssociatedSSLIds(detail.gpg_id, sslIds);
@ -817,15 +817,15 @@ void FriendSelectionWidget::peerStatusChanged(const RsPeerId& peerid, int status
for (statusIt = statusInfo.begin(); statusIt != statusInfo.end() ; ++statusIt) { for (statusIt = statusInfo.begin(); statusIt != statusInfo.end() ; ++statusIt) {
if (std::find(sslIds.begin(), sslIds.end(), statusIt->id) != sslIds.end()) { if (std::find(sslIds.begin(), sslIds.end(), statusIt->id) != sslIds.end()) {
if (statusIt->status != RS_STATUS_OFFLINE) { if (statusIt->status != RsStatusValue::RS_STATUS_OFFLINE) {
gpgStatus = RS_STATUS_ONLINE; gpgStatus = RsStatusValue::RS_STATUS_ONLINE;
break; break;
} }
} }
} }
} else { } else {
/* one node is online */ /* one node is online */
gpgStatus = RS_STATUS_ONLINE; gpgStatus = RsStatusValue::RS_STATUS_ONLINE;
} }
} }
} }
@ -845,7 +845,7 @@ void FriendSelectionWidget::peerStatusChanged(const RsPeerId& peerid, int status
case IDTYPE_GPG: case IDTYPE_GPG:
{ {
if (item->data(COLUMN_DATA, ROLE_ID).toString() == gpgId) { if (item->data(COLUMN_DATA, ROLE_ID).toString() == gpgId) {
if (status != (int) RS_STATUS_OFFLINE) { if (status != RsStatusValue::RS_STATUS_OFFLINE) {
item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline()); item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline());
} else { } else {
item->setData(COLUMN_NAME, Qt::ForegroundRole, QVariant()); item->setData(COLUMN_NAME, Qt::ForegroundRole, QVariant());
@ -853,7 +853,7 @@ void FriendSelectionWidget::peerStatusChanged(const RsPeerId& peerid, int status
item->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(gpgStatus))); item->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(gpgStatus)));
item->setData(COLUMN_NAME, ROLE_SORT_STATE, gpgStatus); item->setData(COLUMN_NAME, ROLE_SORT_STATE, (int)gpgStatus);
bFoundGPG = true; bFoundGPG = true;
} }
@ -863,7 +863,7 @@ void FriendSelectionWidget::peerStatusChanged(const RsPeerId& peerid, int status
{ {
if (RsPeerId(item->data(COLUMN_DATA, ROLE_ID).toString().toStdString()) == peerid) if (RsPeerId(item->data(COLUMN_DATA, ROLE_ID).toString().toStdString()) == peerid)
{ {
if (status != (int) RS_STATUS_OFFLINE) { if (status != RsStatusValue::RS_STATUS_OFFLINE) {
item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline()); item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline());
} else { } else {
item->setData(COLUMN_NAME, Qt::ForegroundRole, QVariant()); item->setData(COLUMN_NAME, Qt::ForegroundRole, QVariant());
@ -871,7 +871,7 @@ void FriendSelectionWidget::peerStatusChanged(const RsPeerId& peerid, int status
item->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(status))); item->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(status)));
item->setData(COLUMN_NAME, ROLE_SORT_STATE, status); item->setData(COLUMN_NAME, ROLE_SORT_STATE, (int)status);
bFoundSSL = true; bFoundSSL = true;
} }
@ -1274,7 +1274,7 @@ bool FriendSelectionWidget::isSortByState()
void FriendSelectionWidget::filterConnected(bool filter) void FriendSelectionWidget::filterConnected(bool filter)
{ {
ui->friendList->filterMinValItems(COLUMN_NAME, filter ? RS_STATUS_AWAY : RS_STATUS_OFFLINE, ROLE_SORT_STATE); ui->friendList->filterMinValItems(COLUMN_NAME, filter ? double(RsStatusValue::RS_STATUS_AWAY) : double(RsStatusValue::RS_STATUS_OFFLINE), ROLE_SORT_STATE);
mActionFilterConnected->setChecked(filter); mActionFilterConnected->setChecked(filter);

View file

@ -25,6 +25,7 @@
#include <QDialog> #include <QDialog>
#include "retroshare/rsevents.h" #include "retroshare/rsevents.h"
#include "retroshare/rsstatus.h"
#include <gui/gxs/RsGxsUpdateBroadcastPage.h> #include <gui/gxs/RsGxsUpdateBroadcastPage.h>
#include "util/FontSizeHandler.h" #include "util/FontSizeHandler.h"
@ -137,7 +138,7 @@ public slots:
void filterConnected(bool filter); void filterConnected(bool filter);
private slots: private slots:
void peerStatusChanged(const RsPeerId &peerid, int status); void peerStatusChanged(const RsPeerId &peerid, RsStatusValue status);
void filterItems(const QString &text); void filterItems(const QString &text);
void contextMenuRequested(const QPoint &pos); void contextMenuRequested(const QPoint &pos);
void itemDoubleClicked(QTreeWidgetItem *item, int column); void itemDoubleClicked(QTreeWidgetItem *item, int column);

View file

@ -132,8 +132,8 @@ public:
if(is_group_1 ^ is_group_2) // if the two are different, put the group first. if(is_group_1 ^ is_group_2) // if the two are different, put the group first.
return is_group_1 ; return is_group_1 ;
bool online1 = (left .data(RsFriendListModel::OnlineRole).toInt() != RS_STATUS_OFFLINE); bool online1 = (left .data(RsFriendListModel::OnlineRole).toInt() != (int)RsStatusValue::RS_STATUS_OFFLINE);
bool online2 = (right.data(RsFriendListModel::OnlineRole).toInt() != RS_STATUS_OFFLINE); bool online2 = (right.data(RsFriendListModel::OnlineRole).toInt() != (int)RsStatusValue::RS_STATUS_OFFLINE);
if((online1 != online2) && m_sortByState) if((online1 != online2) && m_sortByState)
return (m_header->sortIndicatorOrder()==Qt::AscendingOrder)?online1:online2 ; // always put online nodes first return (m_header->sortIndicatorOrder()==Qt::AscendingOrder)?online1:online2 ; // always put online nodes first
@ -155,7 +155,7 @@ public:
// Filter offline friends // Filter offline friends
if(!m_showOfflineNodes && (index.data(RsFriendListModel::OnlineRole).toInt() == RS_STATUS_OFFLINE)) if(!m_showOfflineNodes && (RsStatusValue(index.data(RsFriendListModel::OnlineRole).toInt()) == RsStatusValue::RS_STATUS_OFFLINE))
return false; return false;
return index.data(RsFriendListModel::FilterRole).toString() == RsFriendListModel::FilterString ; return index.data(RsFriendListModel::FilterRole).toString() == RsFriendListModel::FilterString ;
@ -204,7 +204,7 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e) { handleEvent(e); }, mEventHandlerId_gssp, RsEventType::GOSSIP_DISCOVERY ); rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e) { handleEvent(e); }, mEventHandlerId_gssp, RsEventType::GOSSIP_DISCOVERY );
connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(QString)), this, SLOT(forceUpdateDisplay())); connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(QString)), this, SLOT(forceUpdateDisplay()));
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(forceUpdateDisplay())); // connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(forceUpdateDisplay()));
mModel = new RsFriendListModel(ui->peerTreeWidget); mModel = new RsFriendListModel(ui->peerTreeWidget);
mProxyModel = new FriendListSortFilterProxyModel(ui->peerTreeWidget->header(),this); mProxyModel = new FriendListSortFilterProxyModel(ui->peerTreeWidget->header(),this);

View file

@ -66,18 +66,18 @@ public:
//void updateDisplay() override; //void updateDisplay() override;
QColor textColorGroup() const { return mModel->mTextColorGroup; } QColor textColorGroup() const { return mModel->mTextColorGroup; }
QColor textColorStatusOffline() const { return mModel->mTextColorStatus[RS_STATUS_OFFLINE ]; } QColor textColorStatusOffline() const { return mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_OFFLINE ]; }
QColor textColorStatusAway() const { return mModel->mTextColorStatus[RS_STATUS_AWAY ]; } QColor textColorStatusAway() const { return mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_AWAY ]; }
QColor textColorStatusBusy() const { return mModel->mTextColorStatus[RS_STATUS_BUSY ]; } QColor textColorStatusBusy() const { return mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_BUSY ]; }
QColor textColorStatusOnline() const { return mModel->mTextColorStatus[RS_STATUS_ONLINE ]; } QColor textColorStatusOnline() const { return mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_ONLINE ]; }
QColor textColorStatusInactive() const { return mModel->mTextColorStatus[RS_STATUS_INACTIVE]; } QColor textColorStatusInactive() const { return mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_INACTIVE]; }
void setTextColorGroup(QColor color) { mModel->mTextColorGroup = color; } void setTextColorGroup(QColor color) { mModel->mTextColorGroup = color; }
void setTextColorStatusOffline(QColor color) { mModel->mTextColorStatus[RS_STATUS_OFFLINE ] = color; } void setTextColorStatusOffline(QColor color) { mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_OFFLINE ] = color; }
void setTextColorStatusAway(QColor color) { mModel->mTextColorStatus[RS_STATUS_AWAY ] = color; } void setTextColorStatusAway(QColor color) { mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_AWAY ] = color; }
void setTextColorStatusBusy(QColor color) { mModel->mTextColorStatus[RS_STATUS_BUSY ] = color; } void setTextColorStatusBusy(QColor color) { mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_BUSY ] = color; }
void setTextColorStatusOnline(QColor color) { mModel->mTextColorStatus[RS_STATUS_ONLINE ] = color; } void setTextColorStatusOnline(QColor color) { mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_ONLINE ] = color; }
void setTextColorStatusInactive(QColor color) { mModel->mTextColorStatus[RS_STATUS_INACTIVE] = color; } void setTextColorStatusInactive(QColor color) { mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_INACTIVE] = color; }
public slots: public slots:
void filterItems(const QString &text); void filterItems(const QString &text);

View file

@ -24,118 +24,124 @@
#include "StatusDefs.h" #include "StatusDefs.h"
QString StatusDefs::name(unsigned int status) QString StatusDefs::name(RsStatusValue status)
{ {
switch (status) { switch (status) {
case RS_STATUS_OFFLINE: default:
case RsStatusValue::RS_STATUS_OFFLINE:
return qApp->translate("StatusDefs", "Offline"); return qApp->translate("StatusDefs", "Offline");
case RS_STATUS_AWAY: case RsStatusValue::RS_STATUS_AWAY:
return qApp->translate("StatusDefs", "Away"); return qApp->translate("StatusDefs", "Away");
case RS_STATUS_BUSY: case RsStatusValue::RS_STATUS_BUSY:
return qApp->translate("StatusDefs", "Busy"); return qApp->translate("StatusDefs", "Busy");
case RS_STATUS_ONLINE: case RsStatusValue::RS_STATUS_ONLINE:
return qApp->translate("StatusDefs", "Online"); return qApp->translate("StatusDefs", "Online");
case RS_STATUS_INACTIVE: case RsStatusValue::RS_STATUS_INACTIVE:
return qApp->translate("StatusDefs", "Idle"); return qApp->translate("StatusDefs", "Idle");
} }
std::cerr << "StatusDefs::name: Unknown status requested " << status; RsErr() << "StatusDefs::name: Unknown status requested " << (int)status;
return ""; return "";
} }
const char *StatusDefs::imageIM(unsigned int status) const char *StatusDefs::imageIM(RsStatusValue status)
{ {
switch (status) { switch (status) {
case RS_STATUS_OFFLINE: default:
case RsStatusValue::RS_STATUS_OFFLINE:
return ":/images/im-user-offline.png"; return ":/images/im-user-offline.png";
case RS_STATUS_AWAY: case RsStatusValue::RS_STATUS_AWAY:
return ":/images/im-user-away.png"; return ":/images/im-user-away.png";
case RS_STATUS_BUSY: case RsStatusValue::RS_STATUS_BUSY:
return ":/images/im-user-busy.png"; return ":/images/im-user-busy.png";
case RS_STATUS_ONLINE: case RsStatusValue::RS_STATUS_ONLINE:
return ":/images/im-user.png"; return ":/images/im-user.png";
case RS_STATUS_INACTIVE: case RsStatusValue::RS_STATUS_INACTIVE:
return ":/images/im-user-inactive.png"; return ":/images/im-user-inactive.png";
} }
std::cerr << "StatusDefs::imageIM: Unknown status requested " << status; RsErr() << "StatusDefs::imageIM: Unknown status requested " << (int)status;
return ""; return "";
} }
const char *StatusDefs::imageUser(unsigned int status) const char *StatusDefs::imageUser(RsStatusValue status)
{ {
switch (status) { switch (status) {
case RS_STATUS_OFFLINE: default:
case RsStatusValue::RS_STATUS_OFFLINE:
return ":/images/user/identityoffline24.png"; return ":/images/user/identityoffline24.png";
case RS_STATUS_AWAY: case RsStatusValue::RS_STATUS_AWAY:
return ":/images/user/identity24away.png"; return ":/images/user/identity24away.png";
case RS_STATUS_BUSY: case RsStatusValue::RS_STATUS_BUSY:
return ":/images/user/identity24busy.png"; return ":/images/user/identity24busy.png";
case RS_STATUS_ONLINE: case RsStatusValue::RS_STATUS_ONLINE:
return ":/images/user/identity24.png"; return ":/images/user/identity24.png";
case RS_STATUS_INACTIVE: case RsStatusValue::RS_STATUS_INACTIVE:
return ":/images/user/identity24idle.png"; return ":/images/user/identity24idle.png";
} }
std::cerr << "StatusDefs::imageUser: Unknown status requested " << status; RsErr() << "StatusDefs::imageUser: Unknown status requested " << (int)status;
return ""; return "";
} }
const char *StatusDefs::imageStatus(unsigned int status) const char *StatusDefs::imageStatus(RsStatusValue status)
{ {
switch (status) { switch (status) {
case RS_STATUS_OFFLINE: default:
case RsStatusValue::RS_STATUS_OFFLINE:
return ":/icons/user-offline_64.png"; return ":/icons/user-offline_64.png";
case RS_STATUS_AWAY: case RsStatusValue::RS_STATUS_AWAY:
return ":/icons/user-away_64.png"; return ":/icons/user-away_64.png";
case RS_STATUS_BUSY: case RsStatusValue::RS_STATUS_BUSY:
return ":/icons/user-busy_64.png"; return ":/icons/user-busy_64.png";
case RS_STATUS_ONLINE: case RsStatusValue::RS_STATUS_ONLINE:
return ":/icons/user-online_64.png"; return ":/icons/user-online_64.png";
case RS_STATUS_INACTIVE: case RsStatusValue::RS_STATUS_INACTIVE:
return ":/icons/user-away-extended_64.png"; return ":/icons/user-away-extended_64.png";
} }
std::cerr << "StatusDefs::imageUser: Unknown status requested " << status; RsErr() << "StatusDefs::imageUser: Unknown status requested " << (int)status;
return ""; return "";
} }
QString StatusDefs::tooltip(unsigned int status) QString StatusDefs::tooltip(RsStatusValue status)
{ {
switch (status) { switch (status) {
case RS_STATUS_OFFLINE: default:
case RsStatusValue::RS_STATUS_OFFLINE:
return qApp->translate("StatusDefs", "Friend is offline"); return qApp->translate("StatusDefs", "Friend is offline");
case RS_STATUS_AWAY: case RsStatusValue::RS_STATUS_AWAY:
return qApp->translate("StatusDefs", "Friend is away"); return qApp->translate("StatusDefs", "Friend is away");
case RS_STATUS_BUSY: case RsStatusValue::RS_STATUS_BUSY:
return qApp->translate("StatusDefs", "Friend is busy"); return qApp->translate("StatusDefs", "Friend is busy");
case RS_STATUS_ONLINE: case RsStatusValue::RS_STATUS_ONLINE:
return qApp->translate("StatusDefs", "Friend is online"); return qApp->translate("StatusDefs", "Friend is online");
case RS_STATUS_INACTIVE: case RsStatusValue::RS_STATUS_INACTIVE:
return qApp->translate("StatusDefs", "Friend is idle"); return qApp->translate("StatusDefs", "Friend is idle");
} }
std::cerr << "StatusDefs::tooltip: Unknown status requested " << status; RsErr() << "StatusDefs::tooltip: Unknown status requested " << (int)status;
return ""; return "";
} }
QFont StatusDefs::font(unsigned int status) QFont StatusDefs::font(RsStatusValue status)
{ {
QFont font; QFont font;
switch (status) { switch (status) {
case RS_STATUS_AWAY: default:
case RS_STATUS_BUSY: case RsStatusValue::RS_STATUS_AWAY:
case RS_STATUS_ONLINE: case RsStatusValue::RS_STATUS_BUSY:
case RS_STATUS_INACTIVE: case RsStatusValue::RS_STATUS_ONLINE:
case RsStatusValue::RS_STATUS_INACTIVE:
font.setBold(true); font.setBold(true);
return font; return font;
case RS_STATUS_OFFLINE: case RsStatusValue::RS_STATUS_OFFLINE:
font.setBold(false); font.setBold(false);
return font; return font;
} }
std::cerr << "StatusDefs::font: Unknown status requested " << status; RsErr() << "StatusDefs::font: Unknown status requested " << (int)status;
return font; return font;
} }

View file

@ -24,18 +24,20 @@
#include <QColor> #include <QColor>
#include <QFont> #include <QFont>
#include "retroshare/rsstatus.h"
struct RsPeerDetails; struct RsPeerDetails;
class StatusDefs class StatusDefs
{ {
public: public:
static QString name(unsigned int status); static QString name(RsStatusValue status);
static const char* imageIM(unsigned int status); static const char* imageIM(RsStatusValue status);
static const char* imageUser(unsigned int status); static const char* imageUser(RsStatusValue status);
static const char* imageStatus(unsigned int status); static const char* imageStatus(RsStatusValue status);
static QString tooltip(unsigned int status); static QString tooltip(RsStatusValue status);
static QFont font(unsigned int status); static QFont font(RsStatusValue status);
static QString peerStateString(int peerState); static QString peerStateString(int peerState);
static QString connectStateString(RsPeerDetails &details); static QString connectStateString(RsPeerDetails &details);

View file

@ -65,6 +65,7 @@
#include "util/misc.h" #include "util/misc.h"
#include "util/DateTime.h" #include "util/DateTime.h"
#include "util/HandleRichText.h" #include "util/HandleRichText.h"
#include "util/qtthreadsutils.h"
#include "util/QtVersion.h" #include "util/QtVersion.h"
#include "textformat.h" #include "textformat.h"
#include "TagsMenu.h" #include "TagsMenu.h"
@ -214,7 +215,21 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
connect(ui.addBccButton, SIGNAL(clicked()), this, SLOT(addBcc())); connect(ui.addBccButton, SIGNAL(clicked()), this, SLOT(addBcc()));
connect(ui.addRecommendButton, SIGNAL(clicked()), this, SLOT(addRecommend())); connect(ui.addRecommendButton, SIGNAL(clicked()), this, SLOT(addRecommend()));
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(peerStatusChanged(QString,int))); //connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(peerStatusChanged(QString,int)));
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e)
{
RsQThreadUtils::postToObject([=](){
auto fe = dynamic_cast<const RsFriendListEvent*>(e.get());
if(!fe || fe->mEventCode != RsFriendListEventCode::NODE_STATUS_CHANGED)
return;
peerStatusChanged(QString::fromStdString(fe->mSslId.toStdString()),fe->mStatus);
}, this );
},mEventHandlerId,RsEventType::FRIEND_LIST);
connect(ui.friendSelectionWidget, SIGNAL(contentChanged()), this, SLOT(buildCompleter())); connect(ui.friendSelectionWidget, SIGNAL(contentChanged()), this, SLOT(buildCompleter()));
connect(ui.friendSelectionWidget, SIGNAL(doubleClicked(int,QString)), this, SLOT(addTo())); connect(ui.friendSelectionWidget, SIGNAL(doubleClicked(int,QString)), this, SLOT(addTo()));
connect(ui.friendSelectionWidget, SIGNAL(itemSelectionChanged()), this, SLOT(friendSelectionChanged())); connect(ui.friendSelectionWidget, SIGNAL(itemSelectionChanged()), this, SLOT(friendSelectionChanged()));
@ -420,6 +435,7 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
MessageComposer::~MessageComposer() MessageComposer::~MessageComposer()
{ {
rsEvents->unregisterEventsHandler(mEventHandlerId);
delete(m_compareRole); delete(m_compareRole);
} }
@ -811,7 +827,7 @@ void MessageComposer::buildCompleter()
setNewCompleter(ui.recipientWidget, m_completer); setNewCompleter(ui.recipientWidget, m_completer);
} }
void MessageComposer::peerStatusChanged(const QString& peer_id, int status) void MessageComposer::peerStatusChanged(const QString& peer_id, RsStatusValue status)
{ {
int rowCount = ui.recipientWidget->rowCount(); int rowCount = ui.recipientWidget->rowCount();
int row; int row;

View file

@ -157,7 +157,7 @@ private slots:
void editingRecipientFinished(); void editingRecipientFinished();
void contactDetails(); void contactDetails();
void peerStatusChanged(const QString& peer_id, int status); void peerStatusChanged(const QString& peer_id, RsStatusValue status);
void friendSelectionChanged(); void friendSelectionChanged();
void tagAboutToShow(); void tagAboutToShow();
@ -274,6 +274,7 @@ private:
Ui::MessageComposer ui; Ui::MessageComposer ui;
std::list<FileInfo> _recList ; std::list<FileInfo> _recList ;
RsEventsHandlerId_t mEventHandlerId;
}; };
#endif #endif

View file

@ -333,6 +333,7 @@ void NotifyQt::notifyDiskFull(uint32_t loc,uint32_t size_in_mb)
emit diskFull(loc,size_in_mb) ; emit diskFull(loc,size_in_mb) ;
} }
#ifdef TO_REMOVE
/* peer has changed the state */ /* peer has changed the state */
void NotifyQt::notifyPeerStatusChanged(const std::string& peer_id, uint32_t state) void NotifyQt::notifyPeerStatusChanged(const std::string& peer_id, uint32_t state)
{ {
@ -364,6 +365,7 @@ void NotifyQt::notifyPeerStatusChangedSummary()
emit peerStatusChangedSummary(); emit peerStatusChangedSummary();
} }
#endif
void NotifyQt::notifyOwnStatusMessageChanged() void NotifyQt::notifyOwnStatusMessageChanged()
{ {

View file

@ -79,9 +79,9 @@ class NotifyQt: public QObject, public NotifyClient
virtual void notifyOwnStatusMessageChanged() ; virtual void notifyOwnStatusMessageChanged() ;
virtual void notifyDiskFull(uint32_t loc,uint32_t size_in_mb) ; virtual void notifyDiskFull(uint32_t loc,uint32_t size_in_mb) ;
/* peer has changed the state */ /* peer has changed the state */
virtual void notifyPeerStatusChanged(const std::string& peer_id, uint32_t state); // virtual void notifyPeerStatusChanged(const std::string& peer_id, uint32_t state);
/* one or more peers has changed the states */ /* one or more peers has changed the states */
virtual void notifyPeerStatusChangedSummary(); // virtual void notifyPeerStatusChangedSummary();
virtual void notifyHistoryChanged(uint32_t msgId, int type); virtual void notifyHistoryChanged(uint32_t msgId, int type);
@ -122,8 +122,8 @@ class NotifyQt: public QObject, public NotifyClient
void ownStatusMessageChanged() const ; void ownStatusMessageChanged() const ;
void errorOccurred(int,int,const QString&) const ; void errorOccurred(int,int,const QString&) const ;
void diskFull(int,int) const ; void diskFull(int,int) const ;
void peerStatusChanged(const QString& /* peer_id */, int /* status */); // void peerStatusChanged(const QString& /* peer_id */, int /* status */);
void peerStatusChangedSummary() const; // void peerStatusChangedSummary() const;
void gxsChange(const RsGxsChanges& /* changes */); void gxsChange(const RsGxsChanges& /* changes */);
void chatMessageReceived(ChatMessage msg); void chatMessageReceived(ChatMessage msg);
// void groupsChanged(int type) const ; // void groupsChanged(int type) const ;