mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-23 08:19:57 -05:00
Removed old RsNotify code (NOTIFY_LIST_MESSAGELIST) from message service
This commit is contained in:
parent
ae0c993b6b
commit
f59ede23e1
@ -128,7 +128,6 @@ const uint32_t RS_MESSAGE_CONNECT_ATTEMPT = 0x0001;
|
|||||||
const int NOTIFY_LIST_NEIGHBOURS = 1;
|
const int NOTIFY_LIST_NEIGHBOURS = 1;
|
||||||
const int NOTIFY_LIST_FRIENDS = 2;
|
const int NOTIFY_LIST_FRIENDS = 2;
|
||||||
const int NOTIFY_LIST_SEARCHLIST = 4;
|
const int NOTIFY_LIST_SEARCHLIST = 4;
|
||||||
const int NOTIFY_LIST_MESSAGELIST = 5;
|
|
||||||
const int NOTIFY_LIST_CHANNELLIST = 6;
|
const int NOTIFY_LIST_CHANNELLIST = 6;
|
||||||
const int NOTIFY_LIST_TRANSFERLIST = 7;
|
const int NOTIFY_LIST_TRANSFERLIST = 7;
|
||||||
const int NOTIFY_LIST_CONFIG = 8;
|
const int NOTIFY_LIST_CONFIG = 8;
|
||||||
|
@ -220,8 +220,6 @@ void p3MsgService::processIncomingMsg(RsMsgItem *mi)
|
|||||||
for(std::list<RsTlvFileItem>::const_iterator it(mi->attachment.items.begin());it!=mi->attachment.items.end();++it)
|
for(std::list<RsTlvFileItem>::const_iterator it(mi->attachment.items.begin());it!=mi->attachment.items.end();++it)
|
||||||
rsFiles->FileRequest((*it).name,(*it).hash,(*it).filesize,std::string(),RS_FILE_REQ_ANONYMOUS_ROUTING,srcIds) ;
|
rsFiles->FileRequest((*it).name,(*it).hash,(*it).filesize,std::string(),RS_FILE_REQ_ANONYMOUS_ROUTING,srcIds) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3MsgService::checkAndRebuildPartialMessage(RsMsgItem *ci)
|
bool p3MsgService::checkAndRebuildPartialMessage(RsMsgItem *ci)
|
||||||
@ -283,16 +281,11 @@ int p3MsgService::incomingMsgs()
|
|||||||
|
|
||||||
void p3MsgService::handleIncomingItem(RsMsgItem *mi)
|
void p3MsgService::handleIncomingItem(RsMsgItem *mi)
|
||||||
{
|
{
|
||||||
bool changed = false ;
|
|
||||||
|
|
||||||
// only returns true when a msg is complete.
|
// only returns true when a msg is complete.
|
||||||
if(checkAndRebuildPartialMessage(mi))
|
if(checkAndRebuildPartialMessage(mi))
|
||||||
{
|
{
|
||||||
processIncomingMsg(mi);
|
processIncomingMsg(mi);
|
||||||
changed = true ;
|
|
||||||
}
|
}
|
||||||
if(changed)
|
|
||||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3MsgService::statusChange(const std::list<pqiServicePeer> &plist)
|
void p3MsgService::statusChange(const std::list<pqiServicePeer> &plist)
|
||||||
@ -350,7 +343,6 @@ void p3MsgService::checkSizeAndSendMessage(RsMsgItem *msg)
|
|||||||
|
|
||||||
int p3MsgService::checkOutgoingMessages()
|
int p3MsgService::checkOutgoingMessages()
|
||||||
{
|
{
|
||||||
bool changed = false;
|
|
||||||
std::list<RsMsgItem*> output_queue;
|
std::list<RsMsgItem*> output_queue;
|
||||||
|
|
||||||
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
||||||
@ -400,7 +392,6 @@ int p3MsgService::checkOutgoingMessages()
|
|||||||
{
|
{
|
||||||
(mit->second)->msgFlags &= ~RS_MSG_FLAGS_PENDING;
|
(mit->second)->msgFlags &= ~RS_MSG_FLAGS_PENDING;
|
||||||
toErase.push_back(mit->first);
|
toErase.push_back(mit->first);
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -442,9 +433,6 @@ int p3MsgService::checkOutgoingMessages()
|
|||||||
else
|
else
|
||||||
checkSizeAndSendMessage(*it);
|
checkSizeAndSendMessage(*it);
|
||||||
|
|
||||||
if(changed)
|
|
||||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
|
|
||||||
|
|
||||||
if(rsEvents && !pEvent->mChangedMsgIds.empty())
|
if(rsEvents && !pEvent->mChangedMsgIds.empty())
|
||||||
rsEvents->postEvent(pEvent);
|
rsEvents->postEvent(pEvent);
|
||||||
|
|
||||||
@ -954,8 +942,6 @@ bool p3MsgService::removeMsgId(const std::string &mid)
|
|||||||
|
|
||||||
setMessageTag(mid, 0, false);
|
setMessageTag(mid, 0, false);
|
||||||
setMsgParentId(msgId, 0);
|
setMsgParentId(msgId, 0);
|
||||||
|
|
||||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rsEvents && !pEvent->mChangedMsgIds.empty())
|
if(rsEvents && !pEvent->mChangedMsgIds.empty())
|
||||||
@ -968,7 +954,6 @@ bool p3MsgService::markMsgIdRead(const std::string &mid, bool unreadByUser)
|
|||||||
{
|
{
|
||||||
std::map<uint32_t, RsMsgItem *>::iterator mit;
|
std::map<uint32_t, RsMsgItem *>::iterator mit;
|
||||||
uint32_t msgId = atoi(mid.c_str());
|
uint32_t msgId = atoi(mid.c_str());
|
||||||
bool changed = false;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||||
@ -992,18 +977,18 @@ bool p3MsgService::markMsgIdRead(const std::string &mid, bool unreadByUser)
|
|||||||
|
|
||||||
if (mi->msgFlags != msgFlags)
|
if (mi->msgFlags != msgFlags)
|
||||||
{
|
{
|
||||||
changed = true;
|
|
||||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||||
|
|
||||||
|
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
||||||
|
pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_CHANGED;
|
||||||
|
pEvent->mChangedMsgIds.insert(mid);
|
||||||
|
rsEvents->postEvent(pEvent);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} /* UNLOCKED */
|
} /* UNLOCKED */
|
||||||
|
|
||||||
if (changed) {
|
|
||||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1012,8 +997,6 @@ bool p3MsgService::setMsgFlag(const std::string &mid, uint32_t flag, uint32_t
|
|||||||
std::map<uint32_t, RsMsgItem *>::iterator mit;
|
std::map<uint32_t, RsMsgItem *>::iterator mit;
|
||||||
uint32_t msgId = atoi(mid.c_str());
|
uint32_t msgId = atoi(mid.c_str());
|
||||||
|
|
||||||
bool changed = false;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
@ -1033,15 +1016,15 @@ bool p3MsgService::setMsgFlag(const std::string &mid, uint32_t flag, uint32_t
|
|||||||
mit->second->msgFlags |= flag;
|
mit->second->msgFlags |= flag;
|
||||||
|
|
||||||
if (mit->second->msgFlags != oldFlag) {
|
if (mit->second->msgFlags != oldFlag) {
|
||||||
changed = true;
|
|
||||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||||
|
|
||||||
|
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
||||||
|
pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_CHANGED;
|
||||||
|
pEvent->mChangedMsgIds.insert(mid);
|
||||||
|
rsEvents->postEvent(pEvent);
|
||||||
}
|
}
|
||||||
} /* UNLOCKED */
|
} /* UNLOCKED */
|
||||||
|
|
||||||
if (changed) {
|
|
||||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1137,7 +1120,10 @@ uint32_t p3MsgService::sendMessage(RsMsgItem* item)
|
|||||||
|
|
||||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||||
|
|
||||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST, NOTIFY_TYPE_ADD); // deprecated
|
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
||||||
|
pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_SENT;
|
||||||
|
pEvent->mChangedMsgIds.insert(std::to_string(item->msgId));
|
||||||
|
rsEvents->postEvent(pEvent);
|
||||||
|
|
||||||
return item->msgId;
|
return item->msgId;
|
||||||
}
|
}
|
||||||
@ -1175,8 +1161,11 @@ uint32_t p3MsgService::sendDistantMessage(RsMsgItem *item, const RsGxsId& from)
|
|||||||
|
|
||||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||||
|
|
||||||
RsServer::notify()->notifyListChange( NOTIFY_LIST_MESSAGELIST,
|
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
||||||
NOTIFY_TYPE_ADD );
|
pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_SENT;
|
||||||
|
pEvent->mChangedMsgIds.insert(std::to_string(item->msgId));
|
||||||
|
rsEvents->postEvent(pEvent);
|
||||||
|
|
||||||
return item->msgId;
|
return item->msgId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1210,8 +1199,6 @@ bool p3MsgService::MessageSend(MessageInfo &info)
|
|||||||
// Update info for caller
|
// Update info for caller
|
||||||
info.msgId = std::to_string(msg->msgId);
|
info.msgId = std::to_string(msg->msgId);
|
||||||
info .msgflags = msg->msgFlags;
|
info .msgflags = msg->msgFlags;
|
||||||
|
|
||||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD);// deprecated. Should be removed. Oct. 28, 2020
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
||||||
@ -1418,8 +1405,6 @@ bool p3MsgService::MessageToDraft(MessageInfo &info, const std::string &msgParen
|
|||||||
|
|
||||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||||
|
|
||||||
// RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
|
|
||||||
|
|
||||||
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
||||||
pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_SENT;
|
pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_SENT;
|
||||||
pEvent->mChangedMsgIds.insert(std::to_string(msg->msgId));
|
pEvent->mChangedMsgIds.insert(std::to_string(msg->msgId));
|
||||||
@ -1688,8 +1673,9 @@ bool p3MsgService::MessageToTrash(const std::string &mid, bool bTrash)
|
|||||||
std::map<uint32_t, RsMsgItem *>::iterator mit;
|
std::map<uint32_t, RsMsgItem *>::iterator mit;
|
||||||
uint32_t msgId = atoi(mid.c_str());
|
uint32_t msgId = atoi(mid.c_str());
|
||||||
|
|
||||||
bool bChanged = false;
|
|
||||||
bool bFound = false;
|
bool bFound = false;
|
||||||
|
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
||||||
|
pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_CHANGED;
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||||
@ -1712,23 +1698,25 @@ bool p3MsgService::MessageToTrash(const std::string &mid, bool bTrash)
|
|||||||
if (bTrash) {
|
if (bTrash) {
|
||||||
if ((mi->msgFlags & RS_MSG_FLAGS_TRASH) == 0) {
|
if ((mi->msgFlags & RS_MSG_FLAGS_TRASH) == 0) {
|
||||||
mi->msgFlags |= RS_MSG_FLAGS_TRASH;
|
mi->msgFlags |= RS_MSG_FLAGS_TRASH;
|
||||||
bChanged = true;
|
pEvent->mChangedMsgIds.insert(std::to_string(mi->msgId));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mi->msgFlags & RS_MSG_FLAGS_TRASH) {
|
if (mi->msgFlags & RS_MSG_FLAGS_TRASH) {
|
||||||
mi->msgFlags &= ~RS_MSG_FLAGS_TRASH;
|
mi->msgFlags &= ~RS_MSG_FLAGS_TRASH;
|
||||||
bChanged = true;
|
pEvent->mChangedMsgIds.insert(std::to_string(mi->msgId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bChanged) {
|
if (!pEvent->mChangedMsgIds.empty()) {
|
||||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||||
|
|
||||||
checkOutgoingMessages();
|
checkOutgoingMessages();
|
||||||
|
|
||||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
|
if(rsEvents) {
|
||||||
|
rsEvents->postEvent(pEvent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return bFound;
|
return bFound;
|
||||||
@ -2112,8 +2100,6 @@ void p3MsgService::notifyDataStatus( const GRouterMsgPropagationId& id,
|
|||||||
msgOutgoing.erase(it2);
|
msgOutgoing.erase(it2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RsServer::notify()->notifyListChange( NOTIFY_LIST_MESSAGELIST,
|
|
||||||
NOTIFY_TYPE_ADD );
|
|
||||||
IndicateConfigChanged();
|
IndicateConfigChanged();
|
||||||
|
|
||||||
if(rsEvents)
|
if(rsEvents)
|
||||||
@ -2268,8 +2254,6 @@ bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RsServer::notify()->notifyListChange( NOTIFY_LIST_MESSAGELIST,
|
|
||||||
NOTIFY_TYPE_ADD );
|
|
||||||
IndicateConfigChanged();
|
IndicateConfigChanged();
|
||||||
}
|
}
|
||||||
else if( status >= GxsTransSendStatus::FAILED_RECEIPT_SIGNATURE )
|
else if( status >= GxsTransSendStatus::FAILED_RECEIPT_SIGNATURE )
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "gui/common/AvatarDefs.h"
|
#include "gui/common/AvatarDefs.h"
|
||||||
#include "gui/common/FilesDefs.h"
|
#include "gui/common/FilesDefs.h"
|
||||||
#include "gui/notifyqt.h"
|
#include "gui/notifyqt.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
|
|
||||||
#include <retroshare/rsmsgs.h>
|
#include <retroshare/rsmsgs.h>
|
||||||
#include <retroshare/rspeers.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 ) ) );
|
//connect( gotoButton, SIGNAL( clicked( void ) ), this, SLOT( gotoHome ( void ) ) );
|
||||||
|
|
||||||
/* specific ones */
|
/* specific ones */
|
||||||
connect(NotifyQt::getInstance(), SIGNAL(messagesChanged()), this, SLOT(checkMessageReadStatus()));
|
|
||||||
connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( playMedia ( void ) ) );
|
connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( playMedia ( void ) ) );
|
||||||
connect( deleteButton, SIGNAL( clicked( void ) ), this, SLOT( deleteMsg ( void ) ) );
|
connect( deleteButton, SIGNAL( clicked( void ) ), this, SLOT( deleteMsg ( void ) ) );
|
||||||
connect( replyButton, SIGNAL( clicked( void ) ), this, SLOT( replyMsg ( void ) ) );
|
connect( replyButton, SIGNAL( clicked( void ) ), this, SLOT( replyMsg ( void ) ) );
|
||||||
connect( sendinviteButton, SIGNAL( clicked( void ) ), this, SLOT( sendInvite ( 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();
|
expandFrame->hide();
|
||||||
info_Frame_Invite->hide();
|
info_Frame_Invite->hide();
|
||||||
@ -73,6 +75,57 @@ MsgItem::MsgItem(FeedHolder *parent, uint32_t feedId, const std::string &msgId,
|
|||||||
updateItem();
|
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()
|
void MsgItem::updateItemStatic()
|
||||||
{
|
{
|
||||||
/* fill in */
|
/* fill in */
|
||||||
@ -246,7 +299,6 @@ void MsgItem::doExpand(bool open)
|
|||||||
|
|
||||||
mCloseOnRead = false;
|
mCloseOnRead = false;
|
||||||
rsMail->MessageRead(mMsgId, false);
|
rsMail->MessageRead(mMsgId, false);
|
||||||
mCloseOnRead = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -332,26 +384,6 @@ void MsgItem::toggle()
|
|||||||
expand(expandFrame->isHidden());
|
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()
|
void MsgItem::sendInvite()
|
||||||
{
|
{
|
||||||
MessageInfo mi;
|
MessageInfo mi;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "ui_MsgItem.h"
|
#include "ui_MsgItem.h"
|
||||||
#include "FeedItem.h"
|
#include "FeedItem.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <retroshare/rsevents.h>
|
||||||
|
|
||||||
class FeedHolder;
|
class FeedHolder;
|
||||||
class SubFileItem;
|
class SubFileItem;
|
||||||
@ -35,6 +36,7 @@ class MsgItem : public FeedItem, private Ui::MsgItem
|
|||||||
public:
|
public:
|
||||||
/** Default Constructor */
|
/** Default Constructor */
|
||||||
MsgItem(FeedHolder *parent, uint32_t feedId, const std::string &msgId, bool isHome);
|
MsgItem(FeedHolder *parent, uint32_t feedId, const std::string &msgId, bool isHome);
|
||||||
|
virtual ~MsgItem();
|
||||||
|
|
||||||
void updateItemStatic();
|
void updateItemStatic();
|
||||||
|
|
||||||
@ -46,6 +48,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void fillExpandFrame();
|
void fillExpandFrame();
|
||||||
|
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/* default stuff */
|
/* default stuff */
|
||||||
@ -56,7 +59,6 @@ private slots:
|
|||||||
void deleteMsg();
|
void deleteMsg();
|
||||||
void replyMsg();
|
void replyMsg();
|
||||||
void sendInvite();
|
void sendInvite();
|
||||||
void checkMessageReadStatus();
|
|
||||||
|
|
||||||
void updateItem();
|
void updateItem();
|
||||||
|
|
||||||
@ -66,6 +68,7 @@ private:
|
|||||||
|
|
||||||
bool mIsHome;
|
bool mIsHome;
|
||||||
bool mCloseOnRead;
|
bool mCloseOnRead;
|
||||||
|
RsEventsHandlerId_t mEventHandlerId;
|
||||||
|
|
||||||
std::list<SubFileItem *> mFileItems;
|
std::list<SubFileItem *> mFileItems;
|
||||||
};
|
};
|
||||||
|
@ -22,13 +22,20 @@
|
|||||||
#include "MessageUserNotify.h"
|
#include "MessageUserNotify.h"
|
||||||
#include "gui/notifyqt.h"
|
#include "gui/notifyqt.h"
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
|
|
||||||
#include "gui/msgs/MessageInterface.h"
|
#include "gui/msgs/MessageInterface.h"
|
||||||
|
|
||||||
MessageUserNotify::MessageUserNotify(QObject *parent) :
|
MessageUserNotify::MessageUserNotify(QObject *parent) :
|
||||||
UserNotify(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)
|
bool MessageUserNotify::hasSetting(QString *name, QString *group)
|
||||||
@ -72,3 +79,27 @@ void MessageUserNotify::iconClicked()
|
|||||||
{
|
{
|
||||||
MainWindow::showWindow(MainWindow::Messages);
|
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
|
#ifndef MESSAGEUSERNOTIFY_H
|
||||||
#define MESSAGEUSERNOTIFY_H
|
#define MESSAGEUSERNOTIFY_H
|
||||||
|
|
||||||
|
#include <retroshare/rsevents.h>
|
||||||
#include "gui/common/UserNotify.h"
|
#include "gui/common/UserNotify.h"
|
||||||
|
|
||||||
class MessageUserNotify : public UserNotify
|
class MessageUserNotify : public UserNotify
|
||||||
@ -29,6 +30,7 @@ class MessageUserNotify : public UserNotify
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
MessageUserNotify(QObject *parent = 0);
|
MessageUserNotify(QObject *parent = 0);
|
||||||
|
virtual ~MessageUserNotify();
|
||||||
|
|
||||||
virtual bool hasSetting(QString *name, QString *group) override;
|
virtual bool hasSetting(QString *name, QString *group) override;
|
||||||
|
|
||||||
@ -41,6 +43,11 @@ private:
|
|||||||
virtual QString getNotifyMessage(bool plural) override;
|
virtual QString getNotifyMessage(bool plural) override;
|
||||||
|
|
||||||
virtual void iconClicked() override;
|
virtual void iconClicked() override;
|
||||||
|
|
||||||
|
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
RsEventsHandlerId_t mEventHandlerId;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MESSAGEUSERNOTIFY_H
|
#endif // MESSAGEUSERNOTIFY_H
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "util/HandleRichText.h"
|
#include "util/HandleRichText.h"
|
||||||
#include "util/DateTime.h"
|
#include "util/DateTime.h"
|
||||||
#include "util/QtVersion.h"
|
#include "util/QtVersion.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
|
|
||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
#include <retroshare/rsfiles.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(viewsource, SIGNAL(triggered()), this, SLOT(viewSource()));
|
||||||
|
|
||||||
connect(NotifyQt::getInstance(), SIGNAL(messagesTagsChanged()), this, SLOT(messagesTagsChanged()));
|
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.imageBlockWidget->addButtonAction(tr("Load images always for this message"), this, SLOT(loadImagesAlways()), true);
|
||||||
ui.msgText->setImageBlockWidget(ui.imageBlockWidget);
|
ui.msgText->setImageBlockWidget(ui.imageBlockWidget);
|
||||||
@ -211,6 +211,9 @@ MessageWidget::MessageWidget(bool controlled, QWidget *parent, Qt::WindowFlags f
|
|||||||
ui.dateText-> setText("");
|
ui.dateText-> setText("");
|
||||||
|
|
||||||
ui.info_Frame_Invite->hide();
|
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()
|
MessageWidget::~MessageWidget()
|
||||||
@ -218,6 +221,44 @@ MessageWidget::~MessageWidget()
|
|||||||
if (isControlled == false) {
|
if (isControlled == false) {
|
||||||
processSettings("MessageWidget", 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)
|
void MessageWidget::connectAction(enumActionType actionType, QToolButton* button)
|
||||||
@ -407,25 +448,6 @@ void MessageWidget::messagesTagsChanged()
|
|||||||
showTagLabels();
|
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()
|
void MessageWidget::clearTagLabels()
|
||||||
{
|
{
|
||||||
/* clear all tags */
|
/* clear all tags */
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#define _MESSAGEWIDGET_H
|
#define _MESSAGEWIDGET_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <retroshare/rsevents.h>
|
||||||
#include "ui_MessageWidget.h"
|
#include "ui_MessageWidget.h"
|
||||||
|
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
@ -75,7 +76,6 @@ private slots:
|
|||||||
|
|
||||||
void msgfilelistWidgetCostumPopupMenu(QPoint);
|
void msgfilelistWidgetCostumPopupMenu(QPoint);
|
||||||
void messagesTagsChanged();
|
void messagesTagsChanged();
|
||||||
void messagesChanged();
|
|
||||||
|
|
||||||
void togglefileview(bool noUpdate = false);
|
void togglefileview(bool noUpdate = false);
|
||||||
void getcurrentrecommended();
|
void getcurrentrecommended();
|
||||||
@ -93,11 +93,14 @@ private:
|
|||||||
void showTagLabels();
|
void showTagLabels();
|
||||||
void setToolbarButtonStyle(Qt::ToolButtonStyle style);
|
void setToolbarButtonStyle(Qt::ToolButtonStyle style);
|
||||||
|
|
||||||
|
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||||
|
|
||||||
bool isControlled;
|
bool isControlled;
|
||||||
bool isWindow;
|
bool isWindow;
|
||||||
std::string currMsgId;
|
std::string currMsgId;
|
||||||
unsigned int currMsgFlags;
|
unsigned int currMsgFlags;
|
||||||
bool expandFiles;
|
bool expandFiles;
|
||||||
|
RsEventsHandlerId_t mEventHandlerId;
|
||||||
|
|
||||||
QList<QLabel*> tagLabels;
|
QList<QLabel*> tagLabels;
|
||||||
|
|
||||||
|
@ -268,7 +268,6 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
|||||||
|
|
||||||
registerHelpButton(ui.helpButton,help_str,"MessagesDialog") ;
|
registerHelpButton(ui.helpButton,help_str,"MessagesDialog") ;
|
||||||
|
|
||||||
connect(NotifyQt::getInstance(), SIGNAL(messagesChanged()), mMessageModel, SLOT(updateMessages()));
|
|
||||||
connect(NotifyQt::getInstance(), SIGNAL(messagesTagsChanged()), this, SLOT(messagesTagsChanged()));
|
connect(NotifyQt::getInstance(), SIGNAL(messagesTagsChanged()), this, SLOT(messagesTagsChanged()));
|
||||||
|
|
||||||
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
|
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_SENT:
|
||||||
case RsMailStatusEventCode::MESSAGE_REMOVED:
|
case RsMailStatusEventCode::MESSAGE_REMOVED:
|
||||||
case RsMailStatusEventCode::NEW_MESSAGE:
|
case RsMailStatusEventCode::NEW_MESSAGE:
|
||||||
|
case RsMailStatusEventCode::MESSAGE_CHANGED:
|
||||||
mMessageModel->updateMessages();
|
mMessageModel->updateMessages();
|
||||||
updateMessageSummaryList();
|
updateMessageSummaryList();
|
||||||
break;
|
break;
|
||||||
default:
|
case RsMailStatusEventCode::MESSAGE_RECEIVED_ACK:
|
||||||
|
case RsMailStatusEventCode::SIGNATURE_FAILED:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -563,12 +563,6 @@ void NotifyQt::notifyListChange(int list, int type)
|
|||||||
break;
|
break;
|
||||||
case NOTIFY_LIST_SEARCHLIST:
|
case NOTIFY_LIST_SEARCHLIST:
|
||||||
break;
|
break;
|
||||||
case NOTIFY_LIST_MESSAGELIST:
|
|
||||||
#ifdef NOTIFY_DEBUG
|
|
||||||
std::cerr << "received msg changed" << std::endl ;
|
|
||||||
#endif
|
|
||||||
emit messagesChanged() ;
|
|
||||||
break;
|
|
||||||
case NOTIFY_LIST_MESSAGE_TAGS:
|
case NOTIFY_LIST_MESSAGE_TAGS:
|
||||||
#ifdef NOTIFY_DEBUG
|
#ifdef NOTIFY_DEBUG
|
||||||
std::cerr << "received msg tags changed" << std::endl ;
|
std::cerr << "received msg tags changed" << std::endl ;
|
||||||
@ -663,8 +657,6 @@ void NotifyQt::notifyListPreChange(int list, int /*type*/)
|
|||||||
break;
|
break;
|
||||||
case NOTIFY_LIST_SEARCHLIST:
|
case NOTIFY_LIST_SEARCHLIST:
|
||||||
break;
|
break;
|
||||||
case NOTIFY_LIST_MESSAGELIST:
|
|
||||||
break;
|
|
||||||
case NOTIFY_LIST_CHANNELLIST:
|
case NOTIFY_LIST_CHANNELLIST:
|
||||||
break;
|
break;
|
||||||
case NOTIFY_LIST_TRANSFERLIST:
|
case NOTIFY_LIST_TRANSFERLIST:
|
||||||
@ -697,7 +689,6 @@ void NotifyQt::UpdateGUI()
|
|||||||
// the gui is running, then they get updated by callbacks.
|
// the gui is running, then they get updated by callbacks.
|
||||||
if(!already_updated)
|
if(!already_updated)
|
||||||
{
|
{
|
||||||
emit messagesChanged() ;
|
|
||||||
emit neighboursChanged();
|
emit neighboursChanged();
|
||||||
emit configChanged();
|
emit configChanged();
|
||||||
|
|
||||||
|
@ -109,7 +109,6 @@ class NotifyQt: public QObject, public NotifyClient
|
|||||||
void lobbyListChanged() const ;
|
void lobbyListChanged() const ;
|
||||||
void chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&) ;
|
void chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&) ;
|
||||||
void neighboursChanged() const ;
|
void neighboursChanged() const ;
|
||||||
void messagesChanged() const ;
|
|
||||||
void messagesTagsChanged() const;
|
void messagesTagsChanged() const;
|
||||||
void configChanged() const ;
|
void configChanged() const ;
|
||||||
void logInfoChanged(const QString&) const ;
|
void logInfoChanged(const QString&) const ;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user