mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-14 16:18:48 -05: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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue