mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-27 16:35:21 -04:00
Removed old RsNotify code (NOTIFY_LIST_MESSAGELIST) from message service
This commit is contained in:
parent
ae0c993b6b
commit
f59ede23e1
11 changed files with 173 additions and 101 deletions
|
@ -31,6 +31,7 @@
|
|||
#include "gui/common/AvatarDefs.h"
|
||||
#include "gui/common/FilesDefs.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
|
@ -59,12 +60,13 @@ MsgItem::MsgItem(FeedHolder *parent, uint32_t feedId, const std::string &msgId,
|
|||
//connect( gotoButton, SIGNAL( clicked( void ) ), this, SLOT( gotoHome ( void ) ) );
|
||||
|
||||
/* specific ones */
|
||||
connect(NotifyQt::getInstance(), SIGNAL(messagesChanged()), this, SLOT(checkMessageReadStatus()));
|
||||
connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( playMedia ( void ) ) );
|
||||
connect( deleteButton, SIGNAL( clicked( void ) ), this, SLOT( deleteMsg ( void ) ) );
|
||||
connect( replyButton, SIGNAL( clicked( void ) ), this, SLOT( replyMsg ( void ) ) );
|
||||
connect( sendinviteButton, SIGNAL( clicked( void ) ), this, SLOT( sendInvite ( void ) ) );
|
||||
|
||||
mEventHandlerId = 0;
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }); }, mEventHandlerId, RsEventType::MAIL_STATUS );
|
||||
|
||||
expandFrame->hide();
|
||||
info_Frame_Invite->hide();
|
||||
|
@ -73,6 +75,57 @@ MsgItem::MsgItem(FeedHolder *parent, uint32_t feedId, const std::string &msgId,
|
|||
updateItem();
|
||||
}
|
||||
|
||||
MsgItem::~MsgItem()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
}
|
||||
|
||||
void MsgItem::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
if(event->mType != RsEventType::MAIL_STATUS) {
|
||||
return;
|
||||
}
|
||||
|
||||
const RsMailStatusEvent *fe = dynamic_cast<const RsMailStatusEvent*>(event.get());
|
||||
if (!fe) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (fe->mMailStatusEventCode) {
|
||||
case RsMailStatusEventCode::MESSAGE_CHANGED:
|
||||
if (fe->mChangedMsgIds.find(mMsgId) != fe->mChangedMsgIds.end()) {
|
||||
MessageInfo msgInfo;
|
||||
|
||||
if (!rsMail->getMessage(mMsgId, msgInfo)) {
|
||||
removeItem();
|
||||
break;
|
||||
}
|
||||
|
||||
if (!mCloseOnRead) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (msgInfo.msgflags & RS_MSG_NEW) {
|
||||
/* Message status is still "new" */
|
||||
break;
|
||||
}
|
||||
|
||||
removeItem();
|
||||
}
|
||||
break;
|
||||
case RsMailStatusEventCode::MESSAGE_REMOVED:
|
||||
if (fe->mChangedMsgIds.find(mMsgId) != fe->mChangedMsgIds.end()) {
|
||||
removeItem();
|
||||
}
|
||||
break;
|
||||
case RsMailStatusEventCode::MESSAGE_SENT:
|
||||
case RsMailStatusEventCode::NEW_MESSAGE:
|
||||
case RsMailStatusEventCode::MESSAGE_RECEIVED_ACK:
|
||||
case RsMailStatusEventCode::SIGNATURE_FAILED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MsgItem::updateItemStatic()
|
||||
{
|
||||
/* fill in */
|
||||
|
@ -246,7 +299,6 @@ void MsgItem::doExpand(bool open)
|
|||
|
||||
mCloseOnRead = false;
|
||||
rsMail->MessageRead(mMsgId, false);
|
||||
mCloseOnRead = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -332,26 +384,6 @@ void MsgItem::toggle()
|
|||
expand(expandFrame->isHidden());
|
||||
}
|
||||
|
||||
void MsgItem::checkMessageReadStatus()
|
||||
{
|
||||
if (!mCloseOnRead) {
|
||||
return;
|
||||
}
|
||||
|
||||
MessageInfo msgInfo;
|
||||
if (!rsMail->getMessage(mMsgId, msgInfo)) {
|
||||
std::cerr << "MsgItem::checkMessageReadStatus() Couldn't find Msg" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (msgInfo.msgflags & RS_MSG_NEW) {
|
||||
/* Message status is still "new" */
|
||||
return;
|
||||
}
|
||||
|
||||
removeItem();
|
||||
}
|
||||
|
||||
void MsgItem::sendInvite()
|
||||
{
|
||||
MessageInfo mi;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "ui_MsgItem.h"
|
||||
#include "FeedItem.h"
|
||||
#include <stdint.h>
|
||||
#include <retroshare/rsevents.h>
|
||||
|
||||
class FeedHolder;
|
||||
class SubFileItem;
|
||||
|
@ -35,6 +36,7 @@ class MsgItem : public FeedItem, private Ui::MsgItem
|
|||
public:
|
||||
/** Default Constructor */
|
||||
MsgItem(FeedHolder *parent, uint32_t feedId, const std::string &msgId, bool isHome);
|
||||
virtual ~MsgItem();
|
||||
|
||||
void updateItemStatic();
|
||||
|
||||
|
@ -46,6 +48,7 @@ protected:
|
|||
|
||||
private:
|
||||
void fillExpandFrame();
|
||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||
|
||||
private slots:
|
||||
/* default stuff */
|
||||
|
@ -56,7 +59,6 @@ private slots:
|
|||
void deleteMsg();
|
||||
void replyMsg();
|
||||
void sendInvite();
|
||||
void checkMessageReadStatus();
|
||||
|
||||
void updateItem();
|
||||
|
||||
|
@ -66,6 +68,7 @@ private:
|
|||
|
||||
bool mIsHome;
|
||||
bool mCloseOnRead;
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
|
||||
std::list<SubFileItem *> mFileItems;
|
||||
};
|
||||
|
|
|
@ -22,13 +22,20 @@
|
|||
#include "MessageUserNotify.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/MainWindow.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
|
||||
#include "gui/msgs/MessageInterface.h"
|
||||
|
||||
MessageUserNotify::MessageUserNotify(QObject *parent) :
|
||||
UserNotify(parent)
|
||||
{
|
||||
connect(NotifyQt::getInstance(), SIGNAL(messagesChanged()), this, SLOT(updateIcon()));
|
||||
mEventHandlerId = 0;
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }); }, mEventHandlerId, RsEventType::MAIL_STATUS );
|
||||
}
|
||||
|
||||
MessageUserNotify::~MessageUserNotify()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
}
|
||||
|
||||
bool MessageUserNotify::hasSetting(QString *name, QString *group)
|
||||
|
@ -72,3 +79,27 @@ void MessageUserNotify::iconClicked()
|
|||
{
|
||||
MainWindow::showWindow(MainWindow::Messages);
|
||||
}
|
||||
|
||||
void MessageUserNotify::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
if(event->mType != RsEventType::MAIL_STATUS) {
|
||||
return;
|
||||
}
|
||||
|
||||
const RsMailStatusEvent *fe = dynamic_cast<const RsMailStatusEvent*>(event.get());
|
||||
if (!fe) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (fe->mMailStatusEventCode) {
|
||||
case RsMailStatusEventCode::NEW_MESSAGE:
|
||||
case RsMailStatusEventCode::MESSAGE_CHANGED:
|
||||
case RsMailStatusEventCode::MESSAGE_REMOVED:
|
||||
updateIcon();
|
||||
break;
|
||||
case RsMailStatusEventCode::MESSAGE_SENT:
|
||||
case RsMailStatusEventCode::MESSAGE_RECEIVED_ACK:
|
||||
case RsMailStatusEventCode::SIGNATURE_FAILED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#ifndef MESSAGEUSERNOTIFY_H
|
||||
#define MESSAGEUSERNOTIFY_H
|
||||
|
||||
#include <retroshare/rsevents.h>
|
||||
#include "gui/common/UserNotify.h"
|
||||
|
||||
class MessageUserNotify : public UserNotify
|
||||
|
@ -29,6 +30,7 @@ class MessageUserNotify : public UserNotify
|
|||
|
||||
public:
|
||||
MessageUserNotify(QObject *parent = 0);
|
||||
virtual ~MessageUserNotify();
|
||||
|
||||
virtual bool hasSetting(QString *name, QString *group) override;
|
||||
|
||||
|
@ -41,6 +43,11 @@ private:
|
|||
virtual QString getNotifyMessage(bool plural) override;
|
||||
|
||||
virtual void iconClicked() override;
|
||||
|
||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||
|
||||
private:
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
};
|
||||
|
||||
#endif // MESSAGEUSERNOTIFY_H
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "util/HandleRichText.h"
|
||||
#include "util/DateTime.h"
|
||||
#include "util/QtVersion.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
|
@ -160,7 +161,6 @@ MessageWidget::MessageWidget(bool controlled, QWidget *parent, Qt::WindowFlags f
|
|||
connect(viewsource, SIGNAL(triggered()), this, SLOT(viewSource()));
|
||||
|
||||
connect(NotifyQt::getInstance(), SIGNAL(messagesTagsChanged()), this, SLOT(messagesTagsChanged()));
|
||||
connect(NotifyQt::getInstance(), SIGNAL(messagesChanged()), this, SLOT(messagesChanged()));
|
||||
|
||||
ui.imageBlockWidget->addButtonAction(tr("Load images always for this message"), this, SLOT(loadImagesAlways()), true);
|
||||
ui.msgText->setImageBlockWidget(ui.imageBlockWidget);
|
||||
|
@ -211,6 +211,9 @@ MessageWidget::MessageWidget(bool controlled, QWidget *parent, Qt::WindowFlags f
|
|||
ui.dateText-> setText("");
|
||||
|
||||
ui.info_Frame_Invite->hide();
|
||||
|
||||
mEventHandlerId = 0;
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }); }, mEventHandlerId, RsEventType::MAIL_STATUS );
|
||||
}
|
||||
|
||||
MessageWidget::~MessageWidget()
|
||||
|
@ -218,6 +221,44 @@ MessageWidget::~MessageWidget()
|
|||
if (isControlled == false) {
|
||||
processSettings("MessageWidget", false);
|
||||
}
|
||||
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
}
|
||||
|
||||
void MessageWidget::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
if(event->mType != RsEventType::MAIL_STATUS) {
|
||||
return;
|
||||
}
|
||||
|
||||
const RsMailStatusEvent *fe = dynamic_cast<const RsMailStatusEvent*>(event.get());
|
||||
if (!fe) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (fe->mMailStatusEventCode) {
|
||||
case RsMailStatusEventCode::MESSAGE_REMOVED:
|
||||
if (fe->mChangedMsgIds.find(currMsgId) != fe->mChangedMsgIds.end()) {
|
||||
if (isControlled) {
|
||||
/* processed by MessagesDialog */
|
||||
return;
|
||||
}
|
||||
|
||||
/* messages was removed */
|
||||
if (isWindow) {
|
||||
window()->close();
|
||||
} else {
|
||||
deleteLater();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RsMailStatusEventCode::MESSAGE_SENT:
|
||||
case RsMailStatusEventCode::MESSAGE_CHANGED:
|
||||
case RsMailStatusEventCode::NEW_MESSAGE:
|
||||
case RsMailStatusEventCode::MESSAGE_RECEIVED_ACK:
|
||||
case RsMailStatusEventCode::SIGNATURE_FAILED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MessageWidget::connectAction(enumActionType actionType, QToolButton* button)
|
||||
|
@ -407,25 +448,6 @@ void MessageWidget::messagesTagsChanged()
|
|||
showTagLabels();
|
||||
}
|
||||
|
||||
void MessageWidget::messagesChanged()
|
||||
{
|
||||
if (isControlled) {
|
||||
/* processed by MessagesDialog */
|
||||
return;
|
||||
}
|
||||
|
||||
/* test Message */
|
||||
MessageInfo msgInfo;
|
||||
if (rsMail->getMessage(currMsgId, msgInfo) == false) {
|
||||
/* messages was removed */
|
||||
if (isWindow) {
|
||||
window()->close();
|
||||
} else {
|
||||
deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MessageWidget::clearTagLabels()
|
||||
{
|
||||
/* clear all tags */
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#define _MESSAGEWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <retroshare/rsevents.h>
|
||||
#include "ui_MessageWidget.h"
|
||||
|
||||
class QToolButton;
|
||||
|
@ -75,7 +76,6 @@ private slots:
|
|||
|
||||
void msgfilelistWidgetCostumPopupMenu(QPoint);
|
||||
void messagesTagsChanged();
|
||||
void messagesChanged();
|
||||
|
||||
void togglefileview(bool noUpdate = false);
|
||||
void getcurrentrecommended();
|
||||
|
@ -93,11 +93,14 @@ private:
|
|||
void showTagLabels();
|
||||
void setToolbarButtonStyle(Qt::ToolButtonStyle style);
|
||||
|
||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||
|
||||
bool isControlled;
|
||||
bool isWindow;
|
||||
std::string currMsgId;
|
||||
unsigned int currMsgFlags;
|
||||
bool expandFiles;
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
|
||||
QList<QLabel*> tagLabels;
|
||||
|
||||
|
|
|
@ -268,7 +268,6 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
|||
|
||||
registerHelpButton(ui.helpButton,help_str,"MessagesDialog") ;
|
||||
|
||||
connect(NotifyQt::getInstance(), SIGNAL(messagesChanged()), mMessageModel, SLOT(updateMessages()));
|
||||
connect(NotifyQt::getInstance(), SIGNAL(messagesTagsChanged()), this, SLOT(messagesTagsChanged()));
|
||||
|
||||
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
|
||||
|
@ -310,10 +309,12 @@ void MessagesDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> even
|
|||
case RsMailStatusEventCode::MESSAGE_SENT:
|
||||
case RsMailStatusEventCode::MESSAGE_REMOVED:
|
||||
case RsMailStatusEventCode::NEW_MESSAGE:
|
||||
case RsMailStatusEventCode::MESSAGE_CHANGED:
|
||||
mMessageModel->updateMessages();
|
||||
updateMessageSummaryList();
|
||||
break;
|
||||
default:
|
||||
case RsMailStatusEventCode::MESSAGE_RECEIVED_ACK:
|
||||
case RsMailStatusEventCode::SIGNATURE_FAILED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -563,12 +563,6 @@ void NotifyQt::notifyListChange(int list, int type)
|
|||
break;
|
||||
case NOTIFY_LIST_SEARCHLIST:
|
||||
break;
|
||||
case NOTIFY_LIST_MESSAGELIST:
|
||||
#ifdef NOTIFY_DEBUG
|
||||
std::cerr << "received msg changed" << std::endl ;
|
||||
#endif
|
||||
emit messagesChanged() ;
|
||||
break;
|
||||
case NOTIFY_LIST_MESSAGE_TAGS:
|
||||
#ifdef NOTIFY_DEBUG
|
||||
std::cerr << "received msg tags changed" << std::endl ;
|
||||
|
@ -663,8 +657,6 @@ void NotifyQt::notifyListPreChange(int list, int /*type*/)
|
|||
break;
|
||||
case NOTIFY_LIST_SEARCHLIST:
|
||||
break;
|
||||
case NOTIFY_LIST_MESSAGELIST:
|
||||
break;
|
||||
case NOTIFY_LIST_CHANNELLIST:
|
||||
break;
|
||||
case NOTIFY_LIST_TRANSFERLIST:
|
||||
|
@ -697,7 +689,6 @@ void NotifyQt::UpdateGUI()
|
|||
// the gui is running, then they get updated by callbacks.
|
||||
if(!already_updated)
|
||||
{
|
||||
emit messagesChanged() ;
|
||||
emit neighboursChanged();
|
||||
emit configChanged();
|
||||
|
||||
|
|
|
@ -109,7 +109,6 @@ class NotifyQt: public QObject, public NotifyClient
|
|||
void lobbyListChanged() const ;
|
||||
void chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&) ;
|
||||
void neighboursChanged() const ;
|
||||
void messagesChanged() const ;
|
||||
void messagesTagsChanged() const;
|
||||
void configChanged() const ;
|
||||
void logInfoChanged(const QString&) const ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue