jsonapi: convert and add getMessageCount

This commit is contained in:
sehraf 2018-10-03 21:52:54 +02:00
parent 285158db5f
commit 150af40e09
No known key found for this signature in database
GPG Key ID: DF09F6EAE356B2C6
6 changed files with 34 additions and 24 deletions

View File

@ -490,7 +490,7 @@ public:
/** /**
* @brief getMessageSummaries * @brief getMessageSummaries
* @jsonapi{de22velopment} * @jsonapi{development}
* @param[out] msgList * @param[out] msgList
* @return always true * @return always true
*/ */
@ -498,13 +498,23 @@ public:
/** /**
* @brief getMessage * @brief getMessage
* @jsonapi{dev22elopment} * @jsonapi{development}
* @param[in] mId message ID to lookup * @param[in] mId message ID to lookup
* @param[out] msg * @param[out] msg
* @return true on success * @return true on success
*/ */
virtual bool getMessage(const std::string &mId, Rs::Msgs::MessageInfo &msg) = 0; virtual bool getMessage(const std::string &mId, Rs::Msgs::MessageInfo &msg) = 0;
virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox) = 0; /**
* @brief getMessageCount
* @jsonapi{development}
* @param[out] nInbox
* @param[out] nInboxNew
* @param[out] nOutbox
* @param[out] nDraftbox
* @param[out] nSentbox
* @param[out] nTrashbox
*/
virtual void getMessageCount(uint32_t &nInbox, uint32_t &nInboxNew, uint32_t &nOutbox, uint32_t &nDraftbox, uint32_t &nSentbox, uint32_t &nTrashbox) = 0;
virtual bool MessageSend(Rs::Msgs::MessageInfo &info) = 0; virtual bool MessageSend(Rs::Msgs::MessageInfo &info) = 0;
virtual bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag) = 0; virtual bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag) = 0;

View File

@ -287,9 +287,9 @@ bool p3Msgs::getMessage(const std::string &mid, MessageInfo &msg)
return mMsgSrv->getMessage(mid, msg); return mMsgSrv->getMessage(mid, msg);
} }
void p3Msgs::getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox) void p3Msgs::getMessageCount(uint32_t &nInbox, uint32_t &nInboxNew, uint32_t &nOutbox, uint32_t &nDraftbox, uint32_t &nSentbox, uint32_t &nTrashbox)
{ {
mMsgSrv->getMessageCount(pnInbox, pnInboxNew, pnOutbox, pnDraftbox, pnSentbox, pnTrashbox); mMsgSrv->getMessageCount(nInbox, nInboxNew, nOutbox, nDraftbox, nSentbox, nTrashbox);
} }
/****************************************/ /****************************************/

View File

@ -52,7 +52,7 @@ class p3Msgs: public RsMsgs
*/ */
virtual bool getMessageSummaries(std::list<Rs::Msgs::MsgInfoSummary> &msgList); virtual bool getMessageSummaries(std::list<Rs::Msgs::MsgInfoSummary> &msgList);
virtual bool getMessage(const std::string &mId, Rs::Msgs::MessageInfo &msg); virtual bool getMessage(const std::string &mId, Rs::Msgs::MessageInfo &msg);
virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox); virtual void getMessageCount(uint32_t &nInbox, uint32_t &nInboxNew, uint32_t &nOutbox, uint32_t &nDraftbox, uint32_t &nSentbox, uint32_t &nTrashbox);
virtual bool MessageSend(Rs::Msgs::MessageInfo &info); virtual bool MessageSend(Rs::Msgs::MessageInfo &info);
virtual bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag); virtual bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag);

View File

@ -857,16 +857,16 @@ bool p3MsgService::getMessage(const std::string &mId, MessageInfo &msg)
return true; return true;
} }
void p3MsgService::getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox) void p3MsgService::getMessageCount(uint32_t &nInbox, uint32_t &nInboxNew, uint32_t &nOutbox, uint32_t &nDraftbox, uint32_t &nSentbox, uint32_t &nTrashbox)
{ {
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/ RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
if (pnInbox) *pnInbox = 0; nInbox = 0;
if (pnInboxNew) *pnInboxNew = 0; nInboxNew = 0;
if (pnOutbox) *pnOutbox = 0; nOutbox = 0;
if (pnDraftbox) *pnDraftbox = 0; nDraftbox = 0;
if (pnSentbox) *pnSentbox = 0; nSentbox = 0;
if (pnTrashbox) *pnTrashbox = 0; nTrashbox = 0;
std::map<uint32_t, RsMsgItem *>::iterator mit; std::map<uint32_t, RsMsgItem *>::iterator mit;
std::map<uint32_t, RsMsgItem *> *apMsg [2] = { &imsg, &msgOutgoing }; std::map<uint32_t, RsMsgItem *> *apMsg [2] = { &imsg, &msgOutgoing };
@ -877,24 +877,23 @@ void p3MsgService::getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxN
initRsMIS(mit->second, mis); initRsMIS(mit->second, mis);
if (mis.msgflags & RS_MSG_TRASH) { if (mis.msgflags & RS_MSG_TRASH) {
if (pnTrashbox) ++(*pnTrashbox); ++nTrashbox;
continue; continue;
} }
switch (mis.msgflags & RS_MSG_BOXMASK) { switch (mis.msgflags & RS_MSG_BOXMASK) {
case RS_MSG_INBOX: case RS_MSG_INBOX:
if (pnInbox) ++(*pnInbox); ++nInbox;
if ((mis.msgflags & RS_MSG_NEW) == RS_MSG_NEW) { if ((mis.msgflags & RS_MSG_NEW) == RS_MSG_NEW)
if (pnInboxNew) ++(*pnInboxNew); ++nInboxNew;
}
break; break;
case RS_MSG_OUTBOX: case RS_MSG_OUTBOX:
if (pnOutbox) ++(*pnOutbox); ++nOutbox;
break; break;
case RS_MSG_DRAFTBOX: case RS_MSG_DRAFTBOX:
if (pnDraftbox) ++(*pnDraftbox); ++nDraftbox;
break; break;
case RS_MSG_SENTBOX: case RS_MSG_SENTBOX:
if (pnSentbox) ++(*pnSentbox); ++nSentbox;
break; break;
} }
} }

View File

@ -62,7 +62,7 @@ public:
/* External Interface */ /* External Interface */
bool getMessageSummaries(std::list<Rs::Msgs::MsgInfoSummary> &msgList); bool getMessageSummaries(std::list<Rs::Msgs::MsgInfoSummary> &msgList);
bool getMessage(const std::string &mid, Rs::Msgs::MessageInfo &msg); bool getMessage(const std::string &mid, Rs::Msgs::MessageInfo &msg);
void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox); void getMessageCount(uint32_t &nInbox, uint32_t &nInboxNew, uint32_t &nOutbox, uint32_t &nDraftbox, uint32_t &nSentbox, uint32_t &nTrashbox);
bool decryptMessage(const std::string& mid) ; bool decryptMessage(const std::string& mid) ;
bool removeMsgId(const std::string &mid); bool removeMsgId(const std::string &mid);

View File

@ -51,8 +51,9 @@ QIcon MessageUserNotify::getMainIcon(bool hasNew)
unsigned int MessageUserNotify::getNewCount() unsigned int MessageUserNotify::getNewCount()
{ {
unsigned int newInboxCount = 0; uint32_t newInboxCount = 0;
rsMail->getMessageCount(NULL, &newInboxCount, NULL, NULL, NULL, NULL); uint32_t a, b, c, d, e; // dummies
rsMail->getMessageCount(a, newInboxCount, b, c, d, e);
return newInboxCount; return newInboxCount;
} }