Added new message flag for system messages like friend request.

Show "RetroShare" as sender of system messages to myself.
Added new quick view in MessagesDialog to filter system messages.
Changed RetroShare link in friend request message to certificate.
Added new subject image for the system messages (defnax).
Removed not used notify in message service.
Recompile needed.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5129 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-05-01 09:18:55 +00:00
parent 32ac7efb42
commit c331098203
20 changed files with 271 additions and 172 deletions

View file

@ -56,13 +56,13 @@ const int msgservicezone = 54319;
p3MsgService::p3MsgService(p3LinkMgr *lm)
:p3Service(RS_SERVICE_TYPE_MSG), p3Config(CONFIG_TYPE_MSGS),
mLinkMgr(lm), mMsgMtx("p3MsgService"), msgChanged(1), mMsgUniqueId(time(NULL))
mLinkMgr(lm), mMsgMtx("p3MsgService"), mMsgUniqueId(time(NULL))
{
addSerialType(new RsMsgSerialiser());
/* Initialize standard tag types */
if(lm)
initStandardTagTypes();
/* Initialize standard tag types */
if(lm)
initStandardTagTypes();
}
uint32_t p3MsgService::getNewUniqueMsgId()
@ -71,35 +71,6 @@ uint32_t p3MsgService::getNewUniqueMsgId()
return mMsgUniqueId++;
}
/****** Mods/Notifications ****/
bool p3MsgService::MsgsChanged()
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
bool m1 = msgChanged.Changed();
return (m1);
}
bool p3MsgService::MsgNotifications()
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
return (msgNotifications.size() > 0);
}
bool p3MsgService::getMessageNotifications(std::list<MsgInfoSummary> &noteList)
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
noteList = msgNotifications;
msgNotifications.clear();
return (noteList.size() > 0);
}
int p3MsgService::tick()
{
pqioutput(PQL_DEBUG_BASIC, msgservicezone,
@ -124,31 +95,21 @@ int p3MsgService::status()
return 1;
}
void p3MsgService::processMsg(RsMsgItem *mi)
void p3MsgService::processMsg(RsMsgItem *mi, bool incoming)
{
mi -> recvTime = time(NULL);
mi -> msgId = getNewUniqueMsgId();
std::string mesg;
{
RsStackMutex stack(mMsgMtx); /*** STACK LOCKED MTX ***/
// if (mi -> PeerId() == mLinkMgr->getOwnId())
if (mi->msgFlags & RS_MSG_FLAGS_OUTGOING)
if (incoming)
{
/* from the loopback device */
// mi -> msgFlags |= RS_MSG_FLAGS_OUTGOING;
}
else
{
mi -> msgFlags = RS_MSG_FLAGS_NEW;
/* from a peer */
MsgInfoSummary mis;
initRsMIS(mi, mis);
// msgNotifications.push_back(mis);
mi->msgFlags &= RS_MSG_FLAGS_SYSTEM; // remove flags
mi->msgFlags |= RS_MSG_FLAGS_NEW;
pqiNotify *notify = getPqiNotify();
if (notify)
{
@ -162,13 +123,16 @@ void p3MsgService::processMsg(RsMsgItem *mi)
notify->AddFeedItem(RS_FEED_ITEM_MESSAGE, out, "", "");
}
}
else
{
mi->msgFlags |= RS_MSG_OUTGOING;
}
imsg[mi->msgId] = mi;
RsMsgSrcId* msi = new RsMsgSrcId();
msi->msgId = mi->msgId;
msi->srcId = mi->PeerId();
mSrcIds.insert(std::pair<uint32_t, RsMsgSrcId*>(msi->msgId, msi));
msgChanged.IndicateChanged();
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
}
@ -232,8 +196,7 @@ int p3MsgService::incomingMsgs()
if(checkAndRebuildPartialMessage(mi)) // only returns true when a msg is complete.
{
mi->msgFlags = 0;
processMsg(mi);
processMsg(mi, true);
}
}
if(changed)
@ -360,9 +323,6 @@ int p3MsgService::checkOutgoingMessages()
return 0;
}
bool p3MsgService::saveList(bool& cleanup, std::list<RsItem*>& itemList)
{
@ -576,7 +536,6 @@ bool p3MsgService::loadList(std::list<RsItem*>& load)
return true;
}
void p3MsgService::loadWelcomeMsg()
{
/* Load Welcome Message */
@ -638,7 +597,6 @@ bool p3MsgService::getMessageSummaries(std::list<MsgInfoSummary> &msgList)
return true;
}
bool p3MsgService::getMessage(const std::string &mId, MessageInfo &msg)
{
std::map<uint32_t, RsMsgItem *>::iterator mit;
@ -935,18 +893,12 @@ int p3MsgService::sendMessage(RsMsgItem *item)
bool p3MsgService::MessageSend(MessageInfo &info)
{
std::string ownId = mLinkMgr->getOwnId();
std::list<std::string>::const_iterator pit;
for(pit = info.msgto.begin(); pit != info.msgto.end(); pit++)
{
RsMsgItem *msg = initMIRsMsg(info, *pit);
if (msg)
{
if (*pit == ownId) {
processMsg(msg);
continue;
}
sendMessage(msg);
}
}
@ -956,10 +908,6 @@ bool p3MsgService::MessageSend(MessageInfo &info)
RsMsgItem *msg = initMIRsMsg(info, *pit);
if (msg)
{
if (*pit == ownId) {
processMsg(msg);
continue;
}
sendMessage(msg);
}
}
@ -969,22 +917,17 @@ bool p3MsgService::MessageSend(MessageInfo &info)
RsMsgItem *msg = initMIRsMsg(info, *pit);
if (msg)
{
if (*pit == ownId) {
processMsg(msg);
continue;
}
sendMessage(msg);
}
}
/* send to ourselves as well */
RsMsgItem *msg = initMIRsMsg(info, ownId);
RsMsgItem *msg = initMIRsMsg(info, mLinkMgr->getOwnId());
if (msg)
{
/* use processMsg to get the new msgId */
// sendMessage(msg);
msg->msgFlags |= RS_MSG_FLAGS_OUTGOING;
processMsg(msg);
processMsg(msg, false);
// return new message id
rs_sprintf(info.msgId, "%lu", msg->msgId);
@ -993,6 +936,39 @@ bool p3MsgService::MessageSend(MessageInfo &info)
return true;
}
bool p3MsgService::SystemMessage(const std::wstring &title, const std::wstring &message, uint32_t systemFlag)
{
if ((systemFlag & RS_MSG_SYSTEM) == 0) {
/* no flag specified */
return false;
}
std::string ownId = mLinkMgr->getOwnId();
RsMsgItem *msg = new RsMsgItem();
msg->PeerId(ownId);
msg->msgFlags = 0;
if (systemFlag & RS_MSG_USER_REQUEST) {
msg->msgFlags |= RS_MSG_FLAGS_USER_REQUEST;
}
msg->msgId = 0;
msg->sendTime = time(NULL);
msg->recvTime = 0;
msg->subject = title;
msg->message = message;
msg->msgto.ids.push_back(ownId);
processMsg(msg, true);
return true;
}
bool p3MsgService::MessageToDraft(MessageInfo &info, const std::string &msgParentId)
{
RsMsgItem *msg = initMIRsMsg(info, mLinkMgr->getOwnId());
@ -1361,7 +1337,7 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
/* translate flags, if we sent it... outgoing */
if ((msg->msgFlags & RS_MSG_FLAGS_OUTGOING)
|| (msg->PeerId() == mLinkMgr->getOwnId()))
/*|| (msg->PeerId() == mLinkMgr->getOwnId())*/)
{
mi.msgflags |= RS_MSG_OUTGOING;
}
@ -1398,6 +1374,10 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
{
mi.msgflags |= RS_MSG_STAR;
}
if (msg->msgFlags & RS_MSG_FLAGS_USER_REQUEST)
{
mi.msgflags |= RS_MSG_USER_REQUEST;
}
mi.ts = msg->sendTime;
mi.srcId = msg->PeerId();
@ -1494,6 +1474,10 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
{
mis.msgflags |= RS_MSG_STAR;
}
if (msg->msgFlags & RS_MSG_FLAGS_USER_REQUEST)
{
mis.msgflags |= RS_MSG_USER_REQUEST;
}
mis.srcId = msg->PeerId();
{
@ -1506,7 +1490,7 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
mis.ts = msg->sendTime;
}
RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, std::string to)
RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, const std::string &to)
{
RsMsgItem *msg = new RsMsgItem();
@ -1553,6 +1537,12 @@ RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, std::string to)
msg -> attachment.items.push_back(mfi);
}
/* translate flags from outside */
if (info.msgflags & RS_MSG_USER_REQUEST)
{
msg->msgFlags |= RS_MSG_FLAGS_USER_REQUEST;
}
//std::cerr << "p3MsgService::initMIRsMsg()" << std::endl;
//msg->print(std::cerr);
return msg;

View file

@ -51,10 +51,6 @@ class p3MsgService: public p3Service, public p3Config, public pqiMonitor
p3MsgService(p3LinkMgr *lm);
/* External Interface */
bool MsgsChanged(); /* should update display */
bool MsgNotifications(); /* popup - messages */
bool getMessageNotifications(std::list<MsgInfoSummary> &noteList);
bool getMessageSummaries(std::list<MsgInfoSummary> &msgList);
bool getMessage(const std::string &mid, MessageInfo &msg);
void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox);
@ -67,6 +63,7 @@ bool getMsgParentId(const std::string &msgId, std::string &msgParentId);
bool setMsgParentId(uint32_t msgId, uint32_t msgParentId);
bool MessageSend(MessageInfo &info);
bool SystemMessage(const std::wstring &title, const std::wstring &message, uint32_t systemFlag);
bool MessageToDraft(MessageInfo &info, const std::string &msgParentId);
bool MessageToTrash(const std::string &mid, bool bTrash);
@ -107,12 +104,12 @@ int sendMessage(RsMsgItem *item);
void checkSizeAndSendMessage(RsMsgItem *msg);
int incomingMsgs();
void processMsg(RsMsgItem *mi);
void processMsg(RsMsgItem *mi, bool incoming);
bool checkAndRebuildPartialMessage(RsMsgItem*) ;
void initRsMI(RsMsgItem *msg, MessageInfo &mi);
void initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis);
RsMsgItem *initMIRsMsg(MessageInfo &info, std::string to);
RsMsgItem *initMIRsMsg(MessageInfo &info, const std::string &to);
void initStandardTagTypes();
@ -129,16 +126,11 @@ void initStandardTagTypes();
std::map<std::string, RsMsgItem *> _pendingPartialMessages ;
/* List of notifications to post via Toaster */
std::list<MsgInfoSummary> msgNotifications;
/* maps for tags types and msg tags */
std::map<uint32_t, RsMsgTagType*> mTags;
std::map<uint32_t, RsMsgTags*> mMsgTags;
Indicator msgChanged;
uint32_t mMsgUniqueId;
// used delete msgSrcIds after config save