Fixed saving new message to draft.

When you write a new message and save it to draft more than once, a new message in draft is created everytime you save.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3466 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-09-11 10:39:40 +00:00
parent d85ec3acf2
commit 061cb2a6a8
3 changed files with 16 additions and 14 deletions

View file

@ -807,6 +807,11 @@ bool p3MsgService::MessageToDraft(MessageInfo &info)
} }
/* STORE MsgID */ /* STORE MsgID */
imsg[msg->msgId] = msg; imsg[msg->msgId] = msg;
// return new message id
std::ostringstream out;
out << msg->msgId;
info.msgId = out.str();
} }
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
@ -1267,8 +1272,6 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
mis.ts = msg->sendTime; mis.ts = msg->sendTime;
} }
RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, std::string to) RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, std::string to)
{ {
RsMsgItem *msg = new RsMsgItem(); RsMsgItem *msg = new RsMsgItem();
@ -1320,4 +1323,3 @@ RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, std::string to)
//msg->print(std::cerr); //msg->print(std::cerr);
return msg; return msg;
} }

View file

@ -52,8 +52,6 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags)
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
m_nBox = -1; // not defined
setupFileActions(); setupFileActions();
setupEditActions(); setupEditActions();
setupViewActions(); setupViewActions();
@ -495,7 +493,7 @@ void MessageComposer::newMsg(std::string msgId /*= ""*/)
insertSendList(); insertSendList();
m_sMsgId = msgId; m_sMsgId = msgId;
m_nBox = -1; // not defined m_sDraftMsgId.clear();
if (m_sMsgId.empty() == false) { if (m_sMsgId.empty() == false) {
// fill existing message // fill existing message
@ -506,7 +504,9 @@ void MessageComposer::newMsg(std::string msgId /*= ""*/)
return; return;
} }
m_nBox = msgInfo.msgflags & RS_MSG_BOXMASK; if (msgInfo.msgflags & RS_MSG_DRAFT) {
m_sDraftMsgId = msgId;
}
insertTitleText( QString::fromStdWString(msgInfo.title).toStdString()); insertTitleText( QString::fromStdWString(msgInfo.title).toStdString());
@ -621,11 +621,11 @@ void MessageComposer::sendMessage_internal(bool bDraftbox)
} }
if (bDraftbox) { if (bDraftbox) {
if (m_nBox != -1 && (m_nBox & RS_MSG_DRAFTBOX) == RS_MSG_DRAFTBOX) { mi.msgId = m_sDraftMsgId;
// only save draft box to draft box again, for all other message create a new one in draft box
mi.msgId = m_sMsgId;
}
rsMsgs->MessageToDraft(mi); rsMsgs->MessageToDraft(mi);
// use new message id
m_sDraftMsgId = mi.msgId;
} else { } else {
rsMsgs->MessageSend(mi); rsMsgs->MessageSend(mi);
} }

View file

@ -179,7 +179,7 @@ private:
QHash<QString, int> autoLinkTargetDictionary; QHash<QString, int> autoLinkTargetDictionary;
std::string m_sMsgId; // existing message id std::string m_sMsgId; // existing message id
int m_nBox; // box from the existing message std::string m_sDraftMsgId; // existing message id
/* maps of files */ /* maps of files */
std::list<AttachFileItem *> mAttachments; std::list<AttachFileItem *> mAttachments;