mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-25 07:25:36 -04:00
Removed old RsNotify code (NOTIFY_LIST_MESSAGE_TAGS) from message service
This commit is contained in:
parent
f59ede23e1
commit
3eb910a25f
15 changed files with 160 additions and 37 deletions
|
@ -103,6 +103,9 @@ enum class RsEventType : uint32_t
|
|||
/// @see rspeers.h
|
||||
NETWORK = 16,
|
||||
|
||||
/// @see RsMailTagEvent
|
||||
MAIL_TAG = 17,
|
||||
|
||||
/** Emitted to update library clients about file hashing being completed */
|
||||
FILE_HASHING_COMPLETED = 20,
|
||||
|
||||
|
|
|
@ -310,6 +310,7 @@ enum class RsMailStatusEventCode: uint8_t
|
|||
SIGNATURE_FAILED = 0x04,
|
||||
|
||||
MESSAGE_CHANGED = 0x05,
|
||||
TAG_CHANGED = 0x06,
|
||||
};
|
||||
|
||||
struct RsMailStatusEvent : RsEvent
|
||||
|
@ -331,6 +332,32 @@ struct RsMailStatusEvent : RsEvent
|
|||
~RsMailStatusEvent() override = default;
|
||||
};
|
||||
|
||||
enum class RsMailTagEventCode: uint8_t
|
||||
{
|
||||
TAG_ADDED = 0x00,
|
||||
TAG_CHANGED = 0x01,
|
||||
TAG_REMOVED = 0x02,
|
||||
};
|
||||
|
||||
struct RsMailTagEvent : RsEvent
|
||||
{
|
||||
RsMailTagEvent() : RsEvent(RsEventType::MAIL_TAG) {}
|
||||
|
||||
RsMailTagEventCode mMailTagEventCode;
|
||||
std::set<std::string> mChangedMsgTagIds;
|
||||
|
||||
/// @see RsEvent
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx) override
|
||||
{
|
||||
RsEvent::serial_process(j, ctx);
|
||||
RS_SERIAL_PROCESS(mChangedMsgTagIds);
|
||||
RS_SERIAL_PROCESS(mMailTagEventCode);
|
||||
}
|
||||
|
||||
~RsMailTagEvent() override = default;
|
||||
};
|
||||
|
||||
#define RS_CHAT_PUBLIC 0x0001
|
||||
#define RS_CHAT_PRIVATE 0x0002
|
||||
#define RS_CHAT_AVATAR_AVAILABLE 0x0004
|
||||
|
|
|
@ -134,7 +134,6 @@ const int NOTIFY_LIST_CONFIG = 8;
|
|||
const int NOTIFY_LIST_DIRLIST_LOCAL = 9;
|
||||
const int NOTIFY_LIST_DIRLIST_FRIENDS = 10;
|
||||
const int NOTIFY_LIST_FORUMLIST_LOCKED = 11; // use connect with Qt::QueuedConnection
|
||||
const int NOTIFY_LIST_MESSAGE_TAGS = 12;
|
||||
const int NOTIFY_LIST_PUBLIC_CHAT = 13;
|
||||
const int NOTIFY_LIST_PRIVATE_INCOMING_CHAT = 14;
|
||||
const int NOTIFY_LIST_PRIVATE_OUTGOING_CHAT = 15;
|
||||
|
|
|
@ -1438,7 +1438,7 @@ bool p3MsgService::getMessageTagTypes(MsgTagType& tags)
|
|||
|
||||
bool p3MsgService::setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color)
|
||||
{
|
||||
int nNotifyType = 0;
|
||||
auto ev = std::make_shared<RsMailTagEvent>();
|
||||
|
||||
{
|
||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||
|
@ -1461,7 +1461,8 @@ bool p3MsgService::setMessageTagType(uint32_t tagId, std::string& text, uint32
|
|||
|
||||
mTags.insert(std::pair<uint32_t, RsMsgTagType*>(tagId, tagType));
|
||||
|
||||
nNotifyType = NOTIFY_TYPE_ADD;
|
||||
ev->mMailTagEventCode = RsMailTagEventCode::TAG_ADDED;
|
||||
ev->mChangedMsgTagIds.insert(std::to_string(tagId));
|
||||
} else {
|
||||
if (mit->second->text != text || mit->second->rgb_color != rgb_color) {
|
||||
/* modify existing tag */
|
||||
|
@ -1475,17 +1476,18 @@ bool p3MsgService::setMessageTagType(uint32_t tagId, std::string& text, uint32
|
|||
}
|
||||
mit->second->rgb_color = rgb_color;
|
||||
|
||||
nNotifyType = NOTIFY_TYPE_MOD;
|
||||
ev->mMailTagEventCode = RsMailTagEventCode::TAG_CHANGED;
|
||||
ev->mChangedMsgTagIds.insert(std::to_string(tagId));
|
||||
}
|
||||
}
|
||||
|
||||
} /* UNLOCKED */
|
||||
|
||||
if (nNotifyType) {
|
||||
if (!ev->mChangedMsgTagIds.empty()) {
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGE_TAGS, nNotifyType);
|
||||
|
||||
rsEvents->postEvent(ev);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1499,6 +1501,9 @@ bool p3MsgService::removeMessageTagType(uint32_t tagId)
|
|||
return false;
|
||||
}
|
||||
|
||||
auto msgEvent = std::make_shared<RsMailStatusEvent>();
|
||||
msgEvent->mMailStatusEventCode = RsMailStatusEventCode::TAG_CHANGED;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
|
@ -1526,7 +1531,10 @@ bool p3MsgService::removeMessageTagType(uint32_t tagId)
|
|||
delete(tag);
|
||||
|
||||
mMsgTags.erase(mit1++);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (msgEvent->mChangedMsgIds.find(std::to_string(mit1->first)) == msgEvent->mChangedMsgIds.end()) {
|
||||
msgEvent->mChangedMsgIds.insert(std::to_string(mit1->first));
|
||||
}
|
||||
}
|
||||
++mit1;
|
||||
|
@ -1540,7 +1548,14 @@ bool p3MsgService::removeMessageTagType(uint32_t tagId)
|
|||
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGE_TAGS, NOTIFY_TYPE_DEL);
|
||||
auto ev = std::make_shared<RsMailTagEvent>();
|
||||
ev->mMailTagEventCode = RsMailTagEventCode::TAG_REMOVED;
|
||||
ev->mChangedMsgTagIds.insert(std::to_string(tagId));
|
||||
rsEvents->postEvent(ev);
|
||||
|
||||
if (!msgEvent->mChangedMsgIds.empty()) {
|
||||
rsEvents->postEvent(msgEvent);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1581,7 +1596,8 @@ bool p3MsgService::setMessageTag(const std::string &msgId, uint32_t tagId, bool
|
|||
}
|
||||
}
|
||||
|
||||
int nNotifyType = 0;
|
||||
auto ev = std::make_shared<RsMailStatusEvent>();
|
||||
ev->mMailStatusEventCode = RsMailStatusEventCode::TAG_CHANGED;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||
|
@ -1600,7 +1616,7 @@ bool p3MsgService::setMessageTag(const std::string &msgId, uint32_t tagId, bool
|
|||
|
||||
mMsgTags.insert(std::pair<uint32_t, RsMsgTags*>(tag->msgId, tag));
|
||||
|
||||
nNotifyType = NOTIFY_TYPE_ADD;
|
||||
ev->mChangedMsgIds.insert(msgId);
|
||||
}
|
||||
} else {
|
||||
RsMsgTags* tag = mit->second;
|
||||
|
@ -1618,18 +1634,18 @@ bool p3MsgService::setMessageTag(const std::string &msgId, uint32_t tagId, bool
|
|||
tag->tagIds.push_back(tagId);
|
||||
/* keep the list sorted */
|
||||
tag->tagIds.sort();
|
||||
nNotifyType = NOTIFY_TYPE_ADD;
|
||||
ev->mChangedMsgIds.insert(msgId);
|
||||
}
|
||||
} else {
|
||||
if (tagId == 0) {
|
||||
/* remove all */
|
||||
delete(tag);
|
||||
mMsgTags.erase(mit);
|
||||
nNotifyType = NOTIFY_TYPE_DEL;
|
||||
ev->mChangedMsgIds.insert(msgId);
|
||||
} else {
|
||||
if (lit != tag->tagIds.end()) {
|
||||
tag->tagIds.erase(lit);
|
||||
nNotifyType = NOTIFY_TYPE_DEL;
|
||||
ev->mChangedMsgIds.insert(msgId);
|
||||
|
||||
if (tag->tagIds.empty()) {
|
||||
/* remove empty tag */
|
||||
|
@ -1643,10 +1659,10 @@ bool p3MsgService::setMessageTag(const std::string &msgId, uint32_t tagId, bool
|
|||
|
||||
} /* UNLOCKED */
|
||||
|
||||
if (nNotifyType) {
|
||||
if (!ev->mChangedMsgIds.empty()) {
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGE_TAGS, nNotifyType);
|
||||
rsEvents->postEvent(ev);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue