mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-18 19:39:30 -04:00
added trash in msgservice and trash folder in MessagesDialog
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3020 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
a3a75b7aea
commit
c8a805b8e7
13 changed files with 217 additions and 47 deletions
|
@ -47,7 +47,8 @@
|
|||
#define RS_MSG_OUTBOX 0x03 /* Outbox */
|
||||
#define RS_MSG_DRAFTBOX 0x05 /* Draftbox */
|
||||
|
||||
#define RS_MSG_NEW 0x0010
|
||||
#define RS_MSG_NEW 0x0010 /* New */
|
||||
#define RS_MSG_TRASH 0x0020 /* Trash */
|
||||
|
||||
class MessageInfo
|
||||
{
|
||||
|
@ -121,10 +122,11 @@ virtual ~RsMsgs() { return; }
|
|||
|
||||
virtual bool getMessageSummaries(std::list<MsgInfoSummary> &msgList) = 0;
|
||||
virtual bool getMessage(std::string mId, MessageInfo &msg) = 0;
|
||||
virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox) = 0;
|
||||
virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox) = 0;
|
||||
|
||||
virtual bool MessageSend(MessageInfo &info) = 0;
|
||||
virtual bool MessageToDraft(MessageInfo &info) = 0;
|
||||
virtual bool MessageToTrash(std::string mid, bool bTrash) = 0;
|
||||
|
||||
virtual bool MessageDelete(std::string mid) = 0;
|
||||
virtual bool MessageRead(std::string mid) = 0;
|
||||
|
|
|
@ -62,9 +62,9 @@ bool p3Msgs::getMessage(std::string mid, MessageInfo &msg)
|
|||
return mMsgSrv->getMessage(mid, msg);
|
||||
}
|
||||
|
||||
void p3Msgs::getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox)
|
||||
void p3Msgs::getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox)
|
||||
{
|
||||
mMsgSrv->getMessageCount(pnInbox, pnInboxNew, pnOutbox, pnDraftbox, pnSentbox);
|
||||
mMsgSrv->getMessageCount(pnInbox, pnInboxNew, pnOutbox, pnDraftbox, pnSentbox, pnTrashbox);
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
|
@ -80,6 +80,11 @@ bool p3Msgs::MessageToDraft(MessageInfo &info)
|
|||
return mMsgSrv->MessageToDraft(info);
|
||||
}
|
||||
|
||||
bool p3Msgs::MessageToTrash(std::string mid, bool bTrash)
|
||||
{
|
||||
return mMsgSrv->MessageToTrash(mid, bTrash);
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
/****************************************/
|
||||
bool p3Msgs::MessageDelete(std::string mid)
|
||||
|
|
|
@ -55,10 +55,11 @@ class p3Msgs: public RsMsgs
|
|||
*/
|
||||
virtual bool getMessageSummaries(std::list<MsgInfoSummary> &msgList);
|
||||
virtual bool getMessage(std::string mId, MessageInfo &msg);
|
||||
virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox);
|
||||
virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox);
|
||||
|
||||
virtual bool MessageSend(MessageInfo &info);
|
||||
virtual bool MessageToDraft(MessageInfo &info);
|
||||
virtual bool MessageToTrash(std::string mid, bool bTrash);
|
||||
virtual bool MessageDelete(std::string mid);
|
||||
virtual bool MessageRead(std::string mid);
|
||||
|
||||
|
|
|
@ -141,6 +141,7 @@ const uint32_t RS_MSG_FLAGS_OUTGOING = 0x0001;
|
|||
const uint32_t RS_MSG_FLAGS_PENDING = 0x0002;
|
||||
const uint32_t RS_MSG_FLAGS_DRAFT = 0x0004;
|
||||
const uint32_t RS_MSG_FLAGS_NEW = 0x0010;
|
||||
const uint32_t RS_MSG_FLAGS_TRASH = 0x0020;
|
||||
|
||||
class RsMsgItem: public RsItem
|
||||
{
|
||||
|
|
|
@ -199,6 +199,9 @@ int p3MsgService::checkOutgoingMessages()
|
|||
std::map<uint32_t, RsMsgItem *>::iterator mit;
|
||||
for(mit = msgOutgoing.begin(); mit != msgOutgoing.end(); mit++)
|
||||
{
|
||||
if (mit->second->msgFlags & RS_MSG_FLAGS_TRASH) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* find the certificate */
|
||||
std::string pid = mit->second->PeerId();
|
||||
|
@ -476,7 +479,7 @@ bool p3MsgService::getMessage(std::string mId, MessageInfo &msg)
|
|||
return true;
|
||||
}
|
||||
|
||||
void p3MsgService::getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox)
|
||||
void p3MsgService::getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox)
|
||||
{
|
||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
|
@ -485,6 +488,7 @@ void p3MsgService::getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxN
|
|||
if (pnOutbox) *pnOutbox = 0;
|
||||
if (pnDraftbox) *pnDraftbox = 0;
|
||||
if (pnSentbox) *pnSentbox = 0;
|
||||
if (pnTrashbox) *pnTrashbox = 0;
|
||||
|
||||
std::map<uint32_t, RsMsgItem *>::iterator mit;
|
||||
std::map<uint32_t, RsMsgItem *> *apMsg [2] = { &imsg, &msgOutgoing };
|
||||
|
@ -494,6 +498,10 @@ void p3MsgService::getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxN
|
|||
MsgInfoSummary mis;
|
||||
initRsMIS(mit->second, mis);
|
||||
|
||||
if (mis.msgflags & RS_MSG_TRASH) {
|
||||
if (pnTrashbox) (*pnTrashbox)++;
|
||||
continue;
|
||||
}
|
||||
switch (mis.msgflags & RS_MSG_BOXMASK) {
|
||||
case RS_MSG_INBOX:
|
||||
if (pnInbox) (*pnInbox)++;
|
||||
|
@ -661,8 +669,7 @@ bool p3MsgService::MessageToDraft(MessageInfo &info)
|
|||
{
|
||||
uint32_t msgId = 0;
|
||||
if (info.msgId.empty() == false) {
|
||||
std::istringstream instream(info.msgId);
|
||||
instream >> msgId;
|
||||
msgId = atoi(info.msgId.c_str());
|
||||
}
|
||||
|
||||
if (msgId) {
|
||||
|
@ -679,11 +686,13 @@ bool p3MsgService::MessageToDraft(MessageInfo &info)
|
|||
|
||||
if (msgId) {
|
||||
// remove existing message
|
||||
RsMsgItem *existingMsg = imsg[msgId];
|
||||
if (existingMsg) {
|
||||
delete (existingMsg);
|
||||
std::map<uint32_t, RsMsgItem *>::iterator mit;
|
||||
mit = imsg.find(msgId);
|
||||
if (mit != imsg.end()) {
|
||||
RsMsgItem *mi = mit->second;
|
||||
imsg.erase(mit);
|
||||
delete mi;
|
||||
}
|
||||
imsg.erase(msgId);
|
||||
}
|
||||
/* STORE MsgID */
|
||||
imsg[msg->msgId] = msg;
|
||||
|
@ -699,6 +708,58 @@ bool p3MsgService::MessageToDraft(MessageInfo &info)
|
|||
return false;
|
||||
}
|
||||
|
||||
/* move message to trash based on the unique mid */
|
||||
bool p3MsgService::MessageToTrash(std::string mid, bool bTrash)
|
||||
{
|
||||
std::map<uint32_t, RsMsgItem *>::iterator mit;
|
||||
uint32_t msgId = atoi(mid.c_str());
|
||||
|
||||
bool bChanged = false;
|
||||
bool bFound = false;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
RsMsgItem *mi = NULL;
|
||||
|
||||
mit = imsg.find(msgId);
|
||||
if (mit != imsg.end()) {
|
||||
mi = mit->second;
|
||||
} else {
|
||||
mit = msgOutgoing.find(msgId);
|
||||
if (mit != msgOutgoing.end()) {
|
||||
mi = mit->second;
|
||||
}
|
||||
}
|
||||
|
||||
if (mi) {
|
||||
bFound = true;
|
||||
|
||||
if (bTrash) {
|
||||
if ((mi->msgFlags & RS_MSG_FLAGS_TRASH) == 0) {
|
||||
mi->msgFlags |= RS_MSG_FLAGS_TRASH;
|
||||
bChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (mi->msgFlags & RS_MSG_FLAGS_TRASH) {
|
||||
mi->msgFlags &= ~RS_MSG_FLAGS_TRASH;
|
||||
bChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bChanged) {
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
|
||||
checkOutgoingMessages();
|
||||
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
|
||||
}
|
||||
|
||||
return bFound;
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
/****************************************/
|
||||
|
||||
|
@ -813,6 +874,10 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
|
|||
{
|
||||
mis.msgflags |= RS_MSG_NEW;
|
||||
}
|
||||
if (msg->msgFlags & RS_MSG_FLAGS_TRASH)
|
||||
{
|
||||
mis.msgflags |= RS_MSG_TRASH;
|
||||
}
|
||||
|
||||
mis.srcId = msg->PeerId();
|
||||
{
|
||||
|
|
|
@ -57,14 +57,14 @@ bool getMessageNotifications(std::list<MsgInfoSummary> ¬eList);
|
|||
|
||||
bool getMessageSummaries(std::list<MsgInfoSummary> &msgList);
|
||||
bool getMessage(std::string mid, MessageInfo &msg);
|
||||
void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox);
|
||||
void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox);
|
||||
|
||||
bool removeMsgId(std::string mid);
|
||||
bool markMsgIdRead(std::string mid);
|
||||
|
||||
bool MessageSend(MessageInfo &info);
|
||||
bool MessageToDraft(MessageInfo &info);
|
||||
|
||||
bool MessageToTrash(std::string mid, bool bTrash);
|
||||
|
||||
|
||||
void loadWelcomeMsg(); /* startup message */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue