mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 00:49:28 -05:00
changed Mail interface to use the generic MsgAddress type instead of the GxsId/RsPeerId combination
This commit is contained in:
parent
4e0bd19182
commit
ba4982f2ca
@ -229,7 +229,7 @@ void ChatMsgItem::sendMessage()
|
||||
|
||||
mi.title = tr("Quick Message").toUtf8().constData();
|
||||
mi.msg = quickmsgText->toHtml().toUtf8().constData();
|
||||
mi.rspeerid_msgto.insert(mPeerId);
|
||||
mi.to.insert(MsgAddress(mPeerId,MsgAddress::MSG_ADDRESS_MODE_TO));
|
||||
|
||||
rsMail->MessageSend(mi);
|
||||
|
||||
|
@ -146,39 +146,39 @@ void MsgItem::updateItemStatic()
|
||||
/* get peer Id */
|
||||
|
||||
if (mi.msgflags & RS_MSG_DISTANT)
|
||||
avatar->setGxsId(mi.rsgxsid_srcId) ;
|
||||
avatar->setGxsId(mi.from.toGxsId()) ;
|
||||
else
|
||||
avatar->setId(ChatId(mi.rspeerid_srcId)) ;
|
||||
avatar->setId(ChatId(mi.from.toRsPeerId())) ;
|
||||
|
||||
QString title;
|
||||
QString srcName;
|
||||
|
||||
if ((mi.msgflags & RS_MSG_SYSTEM) && mi.rspeerid_srcId == rsPeers->getOwnId())
|
||||
if ((mi.msgflags & RS_MSG_SYSTEM) && mi.from.toRsPeerId() == rsPeers->getOwnId())
|
||||
srcName = "RetroShare";
|
||||
else
|
||||
{
|
||||
if(mi.msgflags & RS_MSG_DISTANT)
|
||||
{
|
||||
RsIdentityDetails details ;
|
||||
rsIdentity->getIdDetails(mi.rsgxsid_srcId, details) ;
|
||||
rsIdentity->getIdDetails(mi.from.toGxsId(), details) ;
|
||||
|
||||
srcName = QString::fromUtf8(details.mNickname.c_str());
|
||||
}
|
||||
else
|
||||
srcName = QString::fromUtf8(rsPeers->getPeerName(mi.rspeerid_srcId).c_str());
|
||||
srcName = QString::fromUtf8(rsPeers->getPeerName(mi.from.toRsPeerId()).c_str());
|
||||
}
|
||||
|
||||
|
||||
if (!mIsHome)
|
||||
{
|
||||
if ((mi.msgflags & RS_MSG_USER_REQUEST) && (!mi.rsgxsid_srcId.isNull()))
|
||||
if ((mi.msgflags & RS_MSG_USER_REQUEST) && mi.from.type()==MsgAddress::MSG_ADDRESS_TYPE_RSGXSID) // !mi.rsgxsid_srcId.isNull()))
|
||||
{
|
||||
title = QString::fromUtf8(mi.title.c_str()) + " " + tr("from") + " " + srcName;
|
||||
replyButton->setText(tr("Reply to invite"));
|
||||
subjectLabel->hide();
|
||||
info_Frame_Invite->show();
|
||||
}
|
||||
else if ((mi.msgflags & RS_MSG_USER_REQUEST) && mi.rsgxsid_srcId.isNull())
|
||||
else if ((mi.msgflags & RS_MSG_USER_REQUEST) && mi.from.type()!=MsgAddress::MSG_ADDRESS_TYPE_RSGXSID) // mi.rsgxsid_srcId.isNull())
|
||||
{
|
||||
title = QString::fromUtf8(mi.title.c_str()) + " " + " " + srcName;
|
||||
subjectLabel->hide();
|
||||
@ -233,7 +233,11 @@ void MsgItem::updateItemStatic()
|
||||
for(it = mi.files.begin(); it != mi.files.end(); ++it)
|
||||
{
|
||||
/* add file */
|
||||
SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->path, it->size, SFI_STATE_REMOTE, mi.rspeerid_srcId);
|
||||
RsPeerId srcId ;
|
||||
if(mi.from.type()==MsgAddress::MSG_ADDRESS_TYPE_RSPEERID)
|
||||
srcId = mi.from.toRsPeerId();
|
||||
|
||||
SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->path, it->size, SFI_STATE_REMOTE, srcId);
|
||||
mFileItems.push_back(fi);
|
||||
|
||||
QLayout *layout = expandFrame->layout();
|
||||
@ -395,9 +399,12 @@ void MsgItem::sendInvite()
|
||||
if (!rsMail->getMessage(mMsgId, mi))
|
||||
return;
|
||||
|
||||
if(mi.from.type()!=MsgAddress::MSG_ADDRESS_TYPE_RSGXSID)
|
||||
return;
|
||||
|
||||
//if ((QMessageBox::question(this, tr("Send invite?"),tr("Do you really want send a invite with your Certificate?"),QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes)
|
||||
//{
|
||||
MessageComposer::sendInvite(mi.rsgxsid_srcId,false);
|
||||
MessageComposer::sendInvite(mi.from.toGxsId(),false);
|
||||
//}
|
||||
|
||||
}
|
||||
|
@ -122,6 +122,8 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
mAlreadySent = false;
|
||||
|
||||
m_msgType = NORMAL;
|
||||
// needed to send system flags with reply
|
||||
msgFlags = 0;
|
||||
@ -149,7 +151,7 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
|
||||
ui.hashBox->hide();
|
||||
|
||||
// connect up the buttons.
|
||||
connect( ui.actionSend, SIGNAL( triggered(bool)), this, SLOT( sendMessage() ) );
|
||||
connect( ui.actionSend, SIGNAL( triggered(bool)), this, SLOT( sendMessage() ), Qt::UniqueConnection );
|
||||
//connect( ui.actionReply, SIGNAL( triggered (bool)), this, SLOT( replyMessage( ) ) );
|
||||
connect(ui.boldbtn, SIGNAL(clicked()), this, SLOT(textBold()));
|
||||
connect(ui.underlinebtn, SIGNAL(clicked()), this, SLOT(textUnderline()));
|
||||
@ -930,6 +932,7 @@ void MessageComposer::addFile(const FileInfo &fileInfo)
|
||||
void MessageComposer::titleChanged()
|
||||
{
|
||||
calculateTitle();
|
||||
std::cerr << "Setting modified 004 = true" << std::endl;
|
||||
ui.msgText->document()->setModified(true);
|
||||
}
|
||||
|
||||
@ -1083,18 +1086,45 @@ MessageComposer *MessageComposer::newMsg(const std::string &msgId /* = ""*/)
|
||||
// msgComposer->addRecipient(MessageComposer::BCC, *groupIt, true) ;
|
||||
// }
|
||||
|
||||
for (std::set<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgto.begin(); it != msgInfo.rspeerid_msgto.end(); ++it ) msgComposer->addRecipient(MessageComposer::TO, *it) ;
|
||||
for (std::set<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgcc.begin(); it != msgInfo.rspeerid_msgcc.end(); ++it ) msgComposer->addRecipient(MessageComposer::CC, *it) ;
|
||||
for (std::set<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgbcc.begin(); it != msgInfo.rspeerid_msgbcc.end(); ++it ) msgComposer->addRecipient(MessageComposer::BCC, *it) ;
|
||||
for (std::set<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgto.begin(); it != msgInfo.rsgxsid_msgto.end(); ++it ) msgComposer->addRecipient(MessageComposer::TO, *it) ;
|
||||
for (std::set<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgcc.begin(); it != msgInfo.rsgxsid_msgcc.end(); ++it ) msgComposer->addRecipient(MessageComposer::CC, *it) ;
|
||||
for (std::set<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgbcc.begin(); it != msgInfo.rsgxsid_msgbcc.end(); ++it ) msgComposer->addRecipient(MessageComposer::BCC, *it) ;
|
||||
for(auto m:msgInfo.to)
|
||||
switch(m.mode())
|
||||
{
|
||||
case MsgAddress::MSG_ADDRESS_MODE_TO:
|
||||
if(m.type()==MsgAddress::MSG_ADDRESS_TYPE_RSGXSID)
|
||||
msgComposer->addRecipient(MessageComposer::TO,m.toGxsId());
|
||||
else if(m.type()==MsgAddress::MSG_ADDRESS_TYPE_RSPEERID)
|
||||
msgComposer->addRecipient(MessageComposer::TO,m.toRsPeerId());
|
||||
break;
|
||||
|
||||
case MsgAddress::MSG_ADDRESS_MODE_CC:
|
||||
if(m.type()==MsgAddress::MSG_ADDRESS_TYPE_RSGXSID)
|
||||
msgComposer->addRecipient(MessageComposer::CC,m.toGxsId());
|
||||
else if(m.type()==MsgAddress::MSG_ADDRESS_TYPE_RSPEERID)
|
||||
msgComposer->addRecipient(MessageComposer::CC,m.toRsPeerId());
|
||||
break;
|
||||
|
||||
case MsgAddress::MSG_ADDRESS_MODE_BCC:
|
||||
if(m.type()==MsgAddress::MSG_ADDRESS_TYPE_RSGXSID)
|
||||
msgComposer->addRecipient(MessageComposer::BCC,m.toGxsId());
|
||||
else if(m.type()==MsgAddress::MSG_ADDRESS_TYPE_RSPEERID)
|
||||
msgComposer->addRecipient(MessageComposer::BCC,m.toRsPeerId());
|
||||
break;
|
||||
default:break;
|
||||
}
|
||||
|
||||
// for (std::set<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgto.begin(); it != msgInfo.rspeerid_msgto.end(); ++it ) msgComposer->addRecipient(MessageComposer::TO, *it) ;
|
||||
// for (std::set<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgcc.begin(); it != msgInfo.rspeerid_msgcc.end(); ++it ) msgComposer->addRecipient(MessageComposer::CC, *it) ;
|
||||
// for (std::set<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgbcc.begin(); it != msgInfo.rspeerid_msgbcc.end(); ++it ) msgComposer->addRecipient(MessageComposer::BCC, *it) ;
|
||||
// for (std::set<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgto.begin(); it != msgInfo.rsgxsid_msgto.end(); ++it ) msgComposer->addRecipient(MessageComposer::TO, *it) ;
|
||||
// for (std::set<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgcc.begin(); it != msgInfo.rsgxsid_msgcc.end(); ++it ) msgComposer->addRecipient(MessageComposer::CC, *it) ;
|
||||
// for (std::set<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgbcc.begin(); it != msgInfo.rsgxsid_msgbcc.end(); ++it ) msgComposer->addRecipient(MessageComposer::BCC, *it) ;
|
||||
|
||||
MsgTagInfo tagInfo;
|
||||
rsMail->getMessageTag(msgId, tagInfo);
|
||||
|
||||
msgComposer->m_tagIds = tagInfo.tagIds;
|
||||
msgComposer->showTagLabels();
|
||||
std::cerr << "Setting modified 005 = false" << std::endl;
|
||||
msgComposer->ui.msgText->document()->setModified(false);
|
||||
}
|
||||
|
||||
@ -1110,7 +1140,7 @@ QString MessageComposer::buildReplyHeader(const MessageInfo &msgInfo)
|
||||
QString from;
|
||||
if(msgInfo.msgflags & RS_MSG_DISTANT)
|
||||
{
|
||||
link = RetroShareLink::createMessage(msgInfo.rsgxsid_srcId, "");
|
||||
link = RetroShareLink::createMessage(msgInfo.from.toGxsId(), "");
|
||||
if (link.valid())
|
||||
{
|
||||
from += link.toHtml();
|
||||
@ -1118,57 +1148,39 @@ QString MessageComposer::buildReplyHeader(const MessageInfo &msgInfo)
|
||||
}
|
||||
else
|
||||
{
|
||||
link = RetroShareLink::createMessage(msgInfo.rspeerid_srcId, "");
|
||||
link = RetroShareLink::createMessage(msgInfo.from.toRsPeerId(), "");
|
||||
if (link.valid())
|
||||
{
|
||||
from += link.toHtml();
|
||||
}
|
||||
}
|
||||
QString to,cc;
|
||||
|
||||
QString to;
|
||||
for ( std::set<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgto.begin(); it != msgInfo.rspeerid_msgto.end(); ++it)
|
||||
for(auto m:msgInfo.to)
|
||||
{
|
||||
link = RetroShareLink::createMessage(*it, "");
|
||||
RetroShareLink link;
|
||||
|
||||
if(m.type()==MsgAddress::MSG_ADDRESS_TYPE_RSGXSID)
|
||||
link = RetroShareLink::createMessage(m.toGxsId(), "");
|
||||
else
|
||||
link = RetroShareLink::createMessage(m.toRsPeerId(), "");
|
||||
|
||||
if (link.valid())
|
||||
{
|
||||
if (!to.isEmpty())
|
||||
to += ", ";
|
||||
if(m.mode()==MsgAddress::MSG_ADDRESS_MODE_TO)
|
||||
{
|
||||
if (!to.isEmpty())
|
||||
to += ", ";
|
||||
|
||||
to += link.toHtml();
|
||||
}
|
||||
}
|
||||
for ( std::set<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgto.begin(); it != msgInfo.rsgxsid_msgto.end(); ++it)
|
||||
{
|
||||
link = RetroShareLink::createMessage(*it, "");
|
||||
if (link.valid())
|
||||
{
|
||||
if (!to.isEmpty())
|
||||
to += ", ";
|
||||
|
||||
to += link.toHtml();
|
||||
}
|
||||
}
|
||||
|
||||
QString cc;
|
||||
for (std::set<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgcc.begin(); it != msgInfo.rspeerid_msgcc.end(); ++it) {
|
||||
link = RetroShareLink::createMessage(*it, "");
|
||||
if (link.valid()) {
|
||||
if (!cc.isEmpty()) {
|
||||
cc += ", ";
|
||||
to += link.toHtml();
|
||||
}
|
||||
cc += link.toHtml();
|
||||
}
|
||||
}
|
||||
for (std::set<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgcc.begin(); it != msgInfo.rsgxsid_msgcc.end(); ++it) {
|
||||
link = RetroShareLink::createMessage(*it, "");
|
||||
if (link.valid()) {
|
||||
if (!cc.isEmpty()) {
|
||||
cc += ", ";
|
||||
}
|
||||
cc += link.toHtml();
|
||||
}
|
||||
}
|
||||
else if(m.mode()==MsgAddress::MSG_ADDRESS_MODE_CC)
|
||||
{
|
||||
if (!cc.isEmpty())
|
||||
cc += ", ";
|
||||
|
||||
cc += link.toHtml();
|
||||
}
|
||||
}
|
||||
|
||||
QString header = QString("<span>-----%1-----").arg(tr("Original Message"));
|
||||
header += QString("<br><font size='3'><strong>%1: </strong>%2</font><br>").arg(tr("From"), from);
|
||||
@ -1220,6 +1232,7 @@ void MessageComposer::setQuotedMsg(const QString &msg, const QString &header)
|
||||
ui.msgText->moveCursor(QTextCursor::Start);
|
||||
|
||||
ui.msgText->setUndoRedoEnabled(true);
|
||||
std::cerr << "Setting modified 006 = true" << std::endl;
|
||||
ui.msgText->document()->setModified(true);
|
||||
|
||||
ui.msgText->setFocus( Qt::OtherFocusReason );
|
||||
@ -1241,14 +1254,18 @@ MessageComposer *MessageComposer::replyMsg(const std::string &msgId, bool all)
|
||||
msgComposer->setTitleText(QString::fromUtf8(msgInfo.title.c_str()), REPLY);
|
||||
msgComposer->setQuotedMsg(QString::fromUtf8(msgInfo.msg.c_str()), buildReplyHeader(msgInfo));
|
||||
|
||||
if(!msgInfo.rspeerid_srcId.isNull()) msgComposer->addRecipient(MessageComposer::TO, msgInfo.rspeerid_srcId);
|
||||
if(!msgInfo.rsgxsid_srcId.isNull()) msgComposer->addRecipient(MessageComposer::TO, msgInfo.rsgxsid_srcId);
|
||||
if(msgInfo.from.type()==MsgAddress::MSG_ADDRESS_TYPE_RSGXSID)
|
||||
msgComposer->addRecipient(MessageComposer::TO, msgInfo.from.toGxsId());
|
||||
else if(msgInfo.from.type()==MsgAddress::MSG_ADDRESS_TYPE_RSPEERID)
|
||||
msgComposer->addRecipient(MessageComposer::TO, msgInfo.from.toRsPeerId());
|
||||
|
||||
// make sure the current ID is among the ones the msg was actually sent to.
|
||||
for(auto it(msgInfo.rsgxsid_msgto.begin());it!=msgInfo.rsgxsid_msgto.end();++it)
|
||||
if(rsIdentity->isOwnId(*it))
|
||||
#warning: We do not know here what is the atual destination of the message, since it may have been sent to two of our IDs at once.
|
||||
|
||||
for(auto m:msgInfo.to)
|
||||
if(m.type()==MsgAddress::MSG_ADDRESS_TYPE_RSGXSID && rsIdentity->isOwnId(m.toGxsId()))
|
||||
{
|
||||
msgComposer->ui.respond_to_CB->setDefaultId(*it) ;
|
||||
msgComposer->ui.respond_to_CB->setDefaultId(m.toGxsId()) ;
|
||||
break ;
|
||||
}
|
||||
// Note: another solution is to do
|
||||
@ -1259,21 +1276,27 @@ MessageComposer *MessageComposer::replyMsg(const std::string &msgId, bool all)
|
||||
{
|
||||
RsPeerId ownId = rsPeers->getOwnId();
|
||||
|
||||
for (std::set<RsPeerId>::iterator tli = msgInfo.rspeerid_msgto.begin(); tli != msgInfo.rspeerid_msgto.end(); ++tli)
|
||||
if (ownId != *tli)
|
||||
msgComposer->addRecipient(MessageComposer::TO, *tli) ;
|
||||
for(auto m:msgInfo.to)
|
||||
if(m.type()==MsgAddress::MSG_ADDRESS_TYPE_RSGXSID)
|
||||
msgComposer->addRecipient(MessageComposer::TO,m.toGxsId());
|
||||
else if(m.type()==MsgAddress::MSG_ADDRESS_TYPE_RSPEERID)
|
||||
msgComposer->addRecipient(MessageComposer::TO,m.toRsPeerId());
|
||||
|
||||
for (std::set<RsPeerId>::iterator tli = msgInfo.rspeerid_msgcc.begin(); tli != msgInfo.rspeerid_msgcc.end(); ++tli)
|
||||
if (ownId != *tli)
|
||||
msgComposer->addRecipient(MessageComposer::TO, *tli) ;
|
||||
// for (std::set<RsPeerId>::iterator tli = msgInfo.rspeerid_msgto.begin(); tli != msgInfo.rspeerid_msgto.end(); ++tli)
|
||||
// if (ownId != *tli)
|
||||
// msgComposer->addRecipient(MessageComposer::TO, *tli) ;
|
||||
|
||||
for (std::set<RsGxsId>::iterator tli = msgInfo.rsgxsid_msgto.begin(); tli != msgInfo.rsgxsid_msgto.end(); ++tli)
|
||||
//if (ownId != *tli)
|
||||
msgComposer->addRecipient(MessageComposer::TO, *tli) ;
|
||||
// for (std::set<RsPeerId>::iterator tli = msgInfo.rspeerid_msgcc.begin(); tli != msgInfo.rspeerid_msgcc.end(); ++tli)
|
||||
// if (ownId != *tli)
|
||||
// msgComposer->addRecipient(MessageComposer::TO, *tli) ;
|
||||
|
||||
for (std::set<RsGxsId>::iterator tli = msgInfo.rsgxsid_msgcc.begin(); tli != msgInfo.rsgxsid_msgcc.end(); ++tli)
|
||||
//if (ownId != *tli)
|
||||
msgComposer->addRecipient(MessageComposer::TO, *tli) ;
|
||||
// for (std::set<RsGxsId>::iterator tli = msgInfo.rsgxsid_msgto.begin(); tli != msgInfo.rsgxsid_msgto.end(); ++tli)
|
||||
// //if (ownId != *tli)
|
||||
// msgComposer->addRecipient(MessageComposer::TO, *tli) ;
|
||||
|
||||
// for (std::set<RsGxsId>::iterator tli = msgInfo.rsgxsid_msgcc.begin(); tli != msgInfo.rsgxsid_msgcc.end(); ++tli)
|
||||
// //if (ownId != *tli)
|
||||
// msgComposer->addRecipient(MessageComposer::TO, *tli) ;
|
||||
}
|
||||
|
||||
// needed to send system flags with reply
|
||||
@ -1363,26 +1386,31 @@ void MessageComposer::setMsgText(const QString &msg, bool asHtml)
|
||||
c.movePosition(QTextCursor::End);
|
||||
ui.msgText->setTextCursor(c);
|
||||
|
||||
std::cerr << "Setting modified 007 = true" << std::endl;
|
||||
ui.msgText->document()->setModified(true);
|
||||
}
|
||||
|
||||
void MessageComposer::sendMessage()
|
||||
{
|
||||
if (sendMessage_internal(false)) {
|
||||
/* check for existing title */
|
||||
|
||||
if (ui.titleEdit->text().isNull())
|
||||
if (QMessageBox::warning(this, tr("RetroShare"), tr("Do you want to send the message without a subject ?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No) {
|
||||
ui.titleEdit->setFocus();
|
||||
return ; // Don't send with an empty subject
|
||||
}
|
||||
|
||||
if (sendMessage_internal(false))
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
bool MessageComposer::sendMessage_internal(bool bDraftbox)
|
||||
bool MessageComposer::buildMessage(MessageInfo& mi)
|
||||
{
|
||||
/* construct a message */
|
||||
MessageInfo mi;
|
||||
// add a GXS signer/from in case the message is to be sent to a distant peer
|
||||
|
||||
// add a GXS signer/from in case the message is to be sent to a distant peer
|
||||
mi.from = MsgAddress(RsGxsId(ui.respond_to_CB->itemData(ui.respond_to_CB->currentIndex()).toString().toStdString()),MsgAddress::MSG_ADDRESS_MODE_TO) ;
|
||||
|
||||
mi.rsgxsid_srcId = RsGxsId(ui.respond_to_CB->itemData(ui.respond_to_CB->currentIndex()).toString().toStdString()) ;
|
||||
|
||||
//std::cerr << "MessageSend: setting 'from' field to GXS id = " << mi.rsgxsid_srcId << std::endl;
|
||||
//std::cerr << "MessageSend: setting 'from' field to GXS id = " << mi.rsgxsid_srcId << std::endl;
|
||||
|
||||
mi.title = misc::removeNewLine(ui.titleEdit->text()).toUtf8().constData();
|
||||
// needed to send system flags with reply
|
||||
@ -1392,14 +1420,6 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
|
||||
RsHtml::optimizeHtml(ui.msgText, text);
|
||||
mi.msg = text.toUtf8().constData();
|
||||
|
||||
/* check for existing title */
|
||||
if (bDraftbox == false && mi.title.empty()) {
|
||||
if (QMessageBox::warning(this, tr("RetroShare"), tr("Do you want to send the message without a subject ?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No) {
|
||||
ui.titleEdit->setFocus();
|
||||
return false; // Don't send with an empty subject
|
||||
}
|
||||
}
|
||||
|
||||
int filesCount = ui.msgFileList->topLevelItemCount();
|
||||
for (int i = 0; i < filesCount; ++i) {
|
||||
QTreeWidgetItem *item = ui.msgFileList->topLevelItem(i);
|
||||
@ -1456,12 +1476,9 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case TO: mi.rspeerid_msgto.insert(*sslIt);
|
||||
break;
|
||||
case CC: mi.rspeerid_msgcc.insert(*sslIt);
|
||||
break;
|
||||
case BCC:mi.rspeerid_msgbcc.insert(*sslIt);
|
||||
break;
|
||||
case TO: mi.to.insert(MsgAddress(*sslIt,MsgAddress::MSG_ADDRESS_MODE_TO)); break;
|
||||
case CC: mi.to.insert(MsgAddress(*sslIt,MsgAddress::MSG_ADDRESS_MODE_CC)); break;
|
||||
case BCC: mi.to.insert(MsgAddress(*sslIt,MsgAddress::MSG_ADDRESS_MODE_BCC)); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1473,12 +1490,9 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case TO: mi.rspeerid_msgto.insert(pid);
|
||||
break ;
|
||||
case CC: mi.rspeerid_msgcc.insert(pid);
|
||||
break ;
|
||||
case BCC:mi.rspeerid_msgbcc.insert(pid);
|
||||
break ;
|
||||
case TO: mi.to.insert(MsgAddress(pid,MsgAddress::MSG_ADDRESS_MODE_TO)); break;
|
||||
case CC: mi.to.insert(MsgAddress(pid,MsgAddress::MSG_ADDRESS_MODE_CC)); break;
|
||||
case BCC: mi.to.insert(MsgAddress(pid,MsgAddress::MSG_ADDRESS_MODE_BCC)); break;
|
||||
}
|
||||
}
|
||||
break ;
|
||||
@ -1488,12 +1502,9 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case TO: mi.rsgxsid_msgto.insert(gid) ;
|
||||
break ;
|
||||
case CC: mi.rsgxsid_msgcc.insert(gid) ;
|
||||
break ;
|
||||
case BCC:mi.rsgxsid_msgbcc.insert(gid) ;
|
||||
break ;
|
||||
case TO: mi.to.insert(MsgAddress(gid,MsgAddress::MSG_ADDRESS_MODE_TO)); break;
|
||||
case CC: mi.to.insert(MsgAddress(gid,MsgAddress::MSG_ADDRESS_MODE_CC)); break;
|
||||
case BCC: mi.to.insert(MsgAddress(gid,MsgAddress::MSG_ADDRESS_MODE_BCC)); break;
|
||||
}
|
||||
}
|
||||
break ;
|
||||
@ -1503,6 +1514,26 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
|
||||
break ;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MessageComposer::sendMessage_internal(bool bDraftbox)
|
||||
{
|
||||
if(mAlreadySent)
|
||||
{
|
||||
std::cerr << "Already_sent is true. Giving up." << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* construct a message */
|
||||
MessageInfo mi;
|
||||
|
||||
if(!buildMessage(mi))
|
||||
return false;
|
||||
|
||||
std::cerr << "Setting already_sent=true" << std::endl;
|
||||
|
||||
mAlreadySent = true;
|
||||
|
||||
if (bDraftbox)
|
||||
{
|
||||
@ -1527,18 +1558,25 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
|
||||
else
|
||||
{
|
||||
/* check for the recipient */
|
||||
if (mi.rspeerid_msgto.empty() && mi.rspeerid_msgcc.empty() && mi.rspeerid_msgbcc.empty()
|
||||
&& mi.rsgxsid_msgto.empty() && mi.rsgxsid_msgcc.empty() && mi.rsgxsid_msgbcc.empty())
|
||||
if (mi.to.empty())
|
||||
{
|
||||
QMessageBox::warning(this, tr("RetroShare"), tr("Please insert at least one recipient."), QMessageBox::Ok);
|
||||
return false; // Don't send with no recipient
|
||||
}
|
||||
|
||||
if(mi.rsgxsid_srcId.isNull() && !(mi.rsgxsid_msgto.empty() && mi.rsgxsid_msgcc.empty() && mi.rsgxsid_msgbcc.empty()))
|
||||
{
|
||||
bool at_least_one_gxsid = false;
|
||||
for(auto m:mi.to)
|
||||
if(m.type() == MsgAddress::MSG_ADDRESS_TYPE_RSGXSID)
|
||||
{
|
||||
at_least_one_gxsid=true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(at_least_one_gxsid && mi.from.type() != MsgAddress::MSG_ADDRESS_TYPE_RSGXSID)
|
||||
{
|
||||
QMessageBox::warning(this, tr("RetroShare"), tr("Please create an identity to sign distant messages, or remove the distant peers from the destination list."), QMessageBox::Ok);
|
||||
return false; // Don't send if cannot sign.
|
||||
}
|
||||
}
|
||||
if (rsMail->MessageSend(mi) == false) {
|
||||
return false;
|
||||
}
|
||||
@ -1576,6 +1614,7 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
|
||||
rsMail->setMessageTag(mi.msgId, *tag, false);
|
||||
}
|
||||
}
|
||||
std::cerr << "Setting modified 001 = false" << std::endl;
|
||||
ui.msgText->document()->setModified(false);
|
||||
|
||||
return true;
|
||||
@ -2394,6 +2433,7 @@ bool MessageComposer::fileSave()
|
||||
QTextStream ts(&file);
|
||||
ts.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
ts << ui.msgText->document()->toHtml("UTF-8");
|
||||
std::cerr << "Setting modified 002 = false" << std::endl;
|
||||
ui.msgText->document()->setModified(false);
|
||||
return true;
|
||||
}
|
||||
@ -2448,6 +2488,7 @@ void MessageComposer::filePrintPdf()
|
||||
void MessageComposer::setCurrentFileName(const QString &fileName)
|
||||
{
|
||||
this->fileName = fileName;
|
||||
std::cerr << "Setting modified 003 = false" << std::endl;
|
||||
ui.msgText->document()->setModified(false);
|
||||
|
||||
setWindowModified(false);
|
||||
|
@ -172,6 +172,7 @@ private slots:
|
||||
|
||||
private:
|
||||
static QString buildReplyHeader(const MessageInfo &msgInfo);
|
||||
bool buildMessage(MessageInfo& mi);
|
||||
|
||||
void processSettings(bool bLoad);
|
||||
|
||||
@ -264,6 +265,7 @@ private:
|
||||
QLabel *lineLabel;
|
||||
|
||||
bool has_gxs;
|
||||
bool mAlreadySent; // prevents a Qt bug that calls the same action twice.
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::MessageComposer ui;
|
||||
|
@ -167,7 +167,8 @@ QVariant RsMessageModel::headerData(int section, Qt::Orientation /*orientation*/
|
||||
{
|
||||
case COLUMN_THREAD_DATE: return tr("Date");
|
||||
case COLUMN_THREAD_AUTHOR: return tr("From");
|
||||
case COLUMN_THREAD_SUBJECT: return tr("Subject");
|
||||
case COLUMN_THREAD_TO: return tr("To");
|
||||
case COLUMN_THREAD_SUBJECT: return tr("Subject");
|
||||
case COLUMN_THREAD_TAGS: return tr("Tags");
|
||||
default:
|
||||
return QVariant();
|
||||
@ -189,8 +190,9 @@ QVariant RsMessageModel::headerData(int section, Qt::Orientation /*orientation*/
|
||||
{
|
||||
case COLUMN_THREAD_ATTACHMENT: return tr("Click to sort by attachments");
|
||||
case COLUMN_THREAD_SUBJECT: return tr("Click to sort by subject");
|
||||
case COLUMN_THREAD_READ: return tr("Click to sort by read");
|
||||
case COLUMN_THREAD_AUTHOR: return tr("Click to sort by from");
|
||||
case COLUMN_THREAD_READ: return tr("Click to sort by read status");
|
||||
case COLUMN_THREAD_AUTHOR: return tr("Click to sort by author");
|
||||
case COLUMN_THREAD_TO: return tr("Click to sort by destination");
|
||||
case COLUMN_THREAD_DATE: return tr("Click to sort by date");
|
||||
case COLUMN_THREAD_TAGS: return tr("Click to sort by tags");
|
||||
case COLUMN_THREAD_STAR: return tr("Click to sort by star");
|
||||
@ -269,7 +271,7 @@ QVariant RsMessageModel::data(const QModelIndex &index, int role) const
|
||||
case MsgFlagsRole: return fmpe.msgflags ;
|
||||
case UnreadRole: return fmpe.msgflags & (RS_MSG_NEW | RS_MSG_UNREAD_BY_USER);
|
||||
case MsgIdRole: return QString::fromStdString(fmpe.msgId) ;
|
||||
case SrcIdRole: return QString::fromStdString(fmpe.srcId.toStdString()) ;
|
||||
case SrcIdRole: return QString::fromStdString(fmpe.from.toStdString()) ;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -312,6 +314,11 @@ bool RsMessageModel::passesFilter(const Rs::Msgs::MsgInfoSummary& fmpe,int /*col
|
||||
if(s.isNull())
|
||||
passes_strings = false;
|
||||
break;
|
||||
case FILTER_TYPE_TO: s = sortRole(fmpe,COLUMN_THREAD_TO).toString();
|
||||
if(s.isNull())
|
||||
passes_strings = false;
|
||||
break;
|
||||
|
||||
case FILTER_TYPE_DATE: s = displayRole(fmpe,COLUMN_THREAD_DATE).toString();
|
||||
break;
|
||||
case FILTER_TYPE_CONTENT: {
|
||||
@ -390,15 +397,18 @@ void RsMessageModel::setFilter(FilterType filter_type, const QStringList& string
|
||||
|
||||
QVariant RsMessageModel::toolTipRole(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
|
||||
{
|
||||
if(column == COLUMN_THREAD_AUTHOR)
|
||||
if(column == COLUMN_THREAD_AUTHOR || column == COLUMN_THREAD_TO)
|
||||
{
|
||||
QString str,comment ;
|
||||
QList<QIcon> icons;
|
||||
|
||||
if(!GxsIdDetails::MakeIdDesc(RsGxsId(fmpe.srcId.toStdString()), true, str, icons, comment,GxsIdDetails::ICON_TYPE_AVATAR))
|
||||
if(column == COLUMN_THREAD_AUTHOR && !GxsIdDetails::MakeIdDesc(RsGxsId(fmpe.from.toStdString()), true, str, icons, comment,GxsIdDetails::ICON_TYPE_AVATAR))
|
||||
return QVariant();
|
||||
|
||||
int S = QFontMetricsF(QApplication::font()).height();
|
||||
if(column == COLUMN_THREAD_TO && !GxsIdDetails::MakeIdDesc(RsGxsId(fmpe.to.begin()->toStdString()), true, str, icons, comment,GxsIdDetails::ICON_TYPE_AVATAR))
|
||||
return QVariant();
|
||||
|
||||
int S = QFontMetricsF(QApplication::font()).height();
|
||||
QImage pix( (*icons.begin()).pixmap(QSize(5*S,5*S)).toImage());
|
||||
|
||||
QString embeddedImage;
|
||||
@ -429,7 +439,8 @@ QVariant RsMessageModel::sizeHintRole(int col) const
|
||||
case COLUMN_THREAD_SUBJECT: return QVariant( QSize(factor * 170, factor*14 ));
|
||||
case COLUMN_THREAD_DATE: return QVariant( QSize(factor * 75 , factor*14 ));
|
||||
case COLUMN_THREAD_AUTHOR: return QVariant( QSize(factor * 75 , factor*14 ));
|
||||
}
|
||||
case COLUMN_THREAD_TO: return QVariant( QSize(factor * 75 , factor*14 ));
|
||||
}
|
||||
}
|
||||
|
||||
QVariant RsMessageModel::authorRole(const Rs::Msgs::MsgInfoSummary& /*fmpe*/,int /*column*/) const
|
||||
@ -449,10 +460,18 @@ QVariant RsMessageModel::sortRole(const Rs::Msgs::MsgInfoSummary& fmpe,int colum
|
||||
|
||||
case COLUMN_THREAD_SPAM: return QVariant((fmpe.msgflags & RS_MSG_SPAM)? 1:0);
|
||||
|
||||
case COLUMN_THREAD_AUTHOR:{
|
||||
case COLUMN_THREAD_TO: {
|
||||
QString name;
|
||||
|
||||
if(GxsIdTreeItemDelegate::computeName(RsGxsId(fmpe.to.begin()->toStdString()),name))
|
||||
return name;
|
||||
return ""; //Not Found
|
||||
}
|
||||
|
||||
case COLUMN_THREAD_AUTHOR:{
|
||||
QString name;
|
||||
|
||||
if(GxsIdTreeItemDelegate::computeName(RsGxsId(fmpe.srcId.toStdString()),name))
|
||||
if(GxsIdTreeItemDelegate::computeName(RsGxsId(fmpe.from.toStdString()),name))
|
||||
return name;
|
||||
return ""; //Not Found
|
||||
}
|
||||
@ -503,9 +522,20 @@ QVariant RsMessageModel::displayRole(const Rs::Msgs::MsgInfoSummary& fmpe,int co
|
||||
}
|
||||
return text;
|
||||
}
|
||||
case COLUMN_THREAD_AUTHOR:{
|
||||
case COLUMN_THREAD_TO: {
|
||||
QString name;
|
||||
RsGxsId id = RsGxsId(fmpe.to.begin()->toStdString()); // not sure of the type
|
||||
|
||||
if(id.isNull())
|
||||
return QVariant(tr("[Notification]"));
|
||||
if(GxsIdTreeItemDelegate::computeName(id,name))
|
||||
return name;
|
||||
return QVariant(tr("[Unknown]"));
|
||||
}
|
||||
|
||||
case COLUMN_THREAD_AUTHOR:{
|
||||
QString name;
|
||||
RsGxsId id = RsGxsId(fmpe.srcId.toStdString());
|
||||
RsGxsId id = RsGxsId(fmpe.from.toStdString());
|
||||
|
||||
if(id.isNull())
|
||||
return QVariant(tr("[Notification]"));
|
||||
@ -525,8 +555,8 @@ QVariant RsMessageModel::userRole(const Rs::Msgs::MsgInfoSummary& fmpe,int col)
|
||||
{
|
||||
switch(col)
|
||||
{
|
||||
case COLUMN_THREAD_AUTHOR: return QVariant(QString::fromStdString(fmpe.srcId.toStdString()));
|
||||
case COLUMN_THREAD_MSGID: return QVariant(QString::fromStdString(fmpe.msgId));
|
||||
case COLUMN_THREAD_AUTHOR: return QVariant(QString::fromStdString(fmpe.from.toStdString()));
|
||||
case COLUMN_THREAD_MSGID: return QVariant(QString::fromStdString(fmpe.msgId));
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -569,8 +599,10 @@ QVariant RsMessageModel::decorationRole(const Rs::Msgs::MsgInfoSummary& fmpe,int
|
||||
case COLUMN_THREAD_SPAM:
|
||||
return FilesDefs::getIconFromQtResourcePath((fmpe.msgflags & RS_MSG_SPAM) ? (IMAGE_SPAM_ON ): (IMAGE_SPAM_OFF));
|
||||
|
||||
case COLUMN_THREAD_AUTHOR://Return icon as place holder.
|
||||
return FilesDefs::getIconFromGxsIdCache(RsGxsId(fmpe.srcId.toStdString()),QIcon(), exist);
|
||||
case COLUMN_THREAD_TO://Return icon as place holder.
|
||||
return FilesDefs::getIconFromGxsIdCache(RsGxsId(fmpe.to.begin()->toStdString()),QIcon(), exist);
|
||||
case COLUMN_THREAD_AUTHOR://Return icon as place holder.
|
||||
return FilesDefs::getIconFromGxsIdCache(RsGxsId(fmpe.from.toStdString()),QIcon(), exist);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
@ -641,6 +673,8 @@ void RsMessageModel::getMessageSummaries(BoxName box,std::list<Rs::Msgs::MsgInfo
|
||||
{
|
||||
rsMsgs->getMessageSummaries(msgs);
|
||||
|
||||
std::cerr << "Get msg summaries. Box=" << box << ":" << std::endl;
|
||||
|
||||
// filter out messages that are not in the right box.
|
||||
|
||||
for(auto it(msgs.begin());it!=msgs.end();)
|
||||
@ -658,6 +692,7 @@ void RsMessageModel::getMessageSummaries(BoxName box,std::list<Rs::Msgs::MsgInfo
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
std::cerr << " msg id " << it->msgId << " flags=" << (it->msgflags & RS_MSG_BOXMASK) << " ok: " << ok << std::endl;
|
||||
|
||||
if(ok)
|
||||
++it;
|
||||
|
@ -58,12 +58,13 @@ public:
|
||||
COLUMN_THREAD_SUBJECT = 0x02,
|
||||
COLUMN_THREAD_READ = 0x03,
|
||||
COLUMN_THREAD_AUTHOR = 0x04,
|
||||
COLUMN_THREAD_SPAM = 0x05,
|
||||
COLUMN_THREAD_DATE = 0x06,
|
||||
COLUMN_THREAD_TAGS = 0x07,
|
||||
COLUMN_THREAD_MSGID = 0x08,
|
||||
COLUMN_THREAD_NB_COLUMNS = 0x09,
|
||||
COLUMN_THREAD_CONTENT = 0x09
|
||||
COLUMN_THREAD_TO = 0x05,
|
||||
COLUMN_THREAD_SPAM = 0x06,
|
||||
COLUMN_THREAD_DATE = 0x07,
|
||||
COLUMN_THREAD_TAGS = 0x08,
|
||||
COLUMN_THREAD_MSGID = 0x09,
|
||||
COLUMN_THREAD_NB_COLUMNS = 0x0a,
|
||||
COLUMN_THREAD_CONTENT = 0x0b
|
||||
};
|
||||
|
||||
enum QuickViewFilter {
|
||||
@ -84,10 +85,11 @@ public:
|
||||
FILTER_TYPE_NONE = 0x00,
|
||||
FILTER_TYPE_SUBJECT = 0x01, // These numbers have been carefuly chosen to match the ones in rsmsgs.h
|
||||
FILTER_TYPE_FROM = 0x02,
|
||||
FILTER_TYPE_DATE = 0x03,
|
||||
FILTER_TYPE_CONTENT = 0x04,
|
||||
FILTER_TYPE_TAGS = 0x05,
|
||||
FILTER_TYPE_ATTACHMENTS = 0x06,
|
||||
FILTER_TYPE_TO = 0x03,
|
||||
FILTER_TYPE_DATE = 0x04,
|
||||
FILTER_TYPE_CONTENT = 0x05,
|
||||
FILTER_TYPE_TAGS = 0x06,
|
||||
FILTER_TYPE_ATTACHMENTS = 0x07,
|
||||
};
|
||||
|
||||
enum Roles{ SortRole = Qt::UserRole+1,
|
||||
|
@ -391,7 +391,8 @@ void MessageWidget::getcurrentrecommended()
|
||||
}
|
||||
|
||||
std::list<RsPeerId> srcIds;
|
||||
srcIds.push_back(msgInfo.rspeerid_srcId);
|
||||
if(msgInfo.from.type()==MsgAddress::MSG_ADDRESS_TYPE_RSPEERID)
|
||||
srcIds.push_back(msgInfo.from.toRsPeerId());
|
||||
|
||||
QModelIndexList list = ui.msgList->selectionModel()->selectedIndexes();
|
||||
|
||||
@ -439,7 +440,10 @@ void MessageWidget::getallrecommended()
|
||||
for(it = recList.begin(); it != recList.end(); ++it) {
|
||||
std::cerr << "MessageWidget::getallrecommended() Calling File Request" << std::endl;
|
||||
std::list<RsPeerId> srcIds;
|
||||
srcIds.push_back(msgInfo.rspeerid_srcId);
|
||||
|
||||
if(msgInfo.from.type()==MsgAddress::MSG_ADDRESS_TYPE_RSPEERID)
|
||||
srcIds.push_back(msgInfo.from.toRsPeerId());
|
||||
|
||||
rsFiles->FileRequest(it->fname, it->hash, it->size, "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds);
|
||||
}
|
||||
}
|
||||
@ -565,17 +569,21 @@ void MessageWidget::fill(const std::string &msgId)
|
||||
return;
|
||||
}
|
||||
|
||||
if ((msgInfo.msgflags & RS_MSG_USER_REQUEST) && msgInfo.rsgxsid_srcId.isNull()){
|
||||
ui.info_Frame_Invite->show();
|
||||
ui.sendInviteButton->hide();
|
||||
ui.infoLabel_Invite->setText(tr("You got an invite to make friend! You may accept this request."));
|
||||
} else if ((msgInfo.msgflags & RS_MSG_USER_REQUEST) && (!msgInfo.rsgxsid_srcId.isNull())){
|
||||
ui.info_Frame_Invite->show();
|
||||
ui.sendInviteButton->show();
|
||||
ui.infoLabel_Invite->setText(tr("You got an invite to make friend! You may accept this request and send your own Certificate back"));
|
||||
} else {
|
||||
ui.info_Frame_Invite->hide();
|
||||
}
|
||||
if (msgInfo.msgflags & RS_MSG_USER_REQUEST)
|
||||
if(msgInfo.from.type() == MsgAddress::MSG_ADDRESS_TYPE_RSPEERID)
|
||||
{
|
||||
ui.info_Frame_Invite->show();
|
||||
ui.sendInviteButton->hide();
|
||||
ui.infoLabel_Invite->setText(tr("You got an invite to make friend! You may accept this request."));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.info_Frame_Invite->show();
|
||||
ui.sendInviteButton->show();
|
||||
ui.infoLabel_Invite->setText(tr("You got an invite to make friend! You may accept this request and send your own Certificate back"));
|
||||
}
|
||||
else
|
||||
ui.info_Frame_Invite->hide();
|
||||
|
||||
const std::list<FileInfo> &recList = msgInfo.files;
|
||||
std::list<FileInfo>::const_iterator it;
|
||||
@ -604,63 +612,44 @@ void MessageWidget::fill(const std::string &msgId)
|
||||
|
||||
/* iterate through the sources */
|
||||
RetroShareLink link;
|
||||
QString text;
|
||||
QString to_text,cc_text,bcc_text;
|
||||
|
||||
for(auto m:msgInfo.to)
|
||||
{
|
||||
if(m.type()==MsgAddress::MSG_ADDRESS_TYPE_RSGXSID)
|
||||
link = RetroShareLink::createMessage(m.toGxsId(), "");
|
||||
else
|
||||
link = RetroShareLink::createMessage(m.toRsPeerId(), "");
|
||||
|
||||
for(std::set<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgto.begin(); pit != msgInfo.rspeerid_msgto.end(); ++pit) {
|
||||
link = RetroShareLink::createMessage(*pit, "");
|
||||
if (link.valid())
|
||||
text += link.toHtml() + " ";
|
||||
}
|
||||
for(std::set<RsGxsId >::const_iterator pit = msgInfo.rsgxsid_msgto.begin(); pit != msgInfo.rsgxsid_msgto.end(); ++pit) {
|
||||
link = RetroShareLink::createMessage(*pit, "");
|
||||
if (link.valid())
|
||||
text += link.toHtml() + " ";
|
||||
}
|
||||
switch(m.mode())
|
||||
{
|
||||
case MsgAddress::MSG_ADDRESS_MODE_TO: to_text += link.toHtml() + " "; break;
|
||||
case MsgAddress::MSG_ADDRESS_MODE_CC: cc_text += link.toHtml() + " "; break;
|
||||
case MsgAddress::MSG_ADDRESS_MODE_BCC: bcc_text += link.toHtml() + " "; break;
|
||||
}
|
||||
}
|
||||
|
||||
ui.trans_ToText->setText(text);
|
||||
ui.trans_ToText->setText(to_text);
|
||||
|
||||
if (!msgInfo.rspeerid_msgcc.empty() || !msgInfo.rsgxsid_msgcc.empty())
|
||||
if (!cc_text.isNull())
|
||||
{
|
||||
ui.ccLabel->setVisible(true);
|
||||
ui.trans_CCText->setVisible(true);
|
||||
|
||||
text.clear();
|
||||
for(std::set<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgcc.begin(); pit != msgInfo.rspeerid_msgcc.end(); ++pit) {
|
||||
link = RetroShareLink::createMessage(*pit, "");
|
||||
if (link.valid())
|
||||
text += link.toHtml() + " ";
|
||||
}
|
||||
for(std::set<RsGxsId>::const_iterator pit = msgInfo.rsgxsid_msgcc.begin(); pit != msgInfo.rsgxsid_msgcc.end(); ++pit) {
|
||||
link = RetroShareLink::createMessage(*pit, "");
|
||||
if (link.valid())
|
||||
text += link.toHtml() + " ";
|
||||
}
|
||||
|
||||
ui.trans_CCText->setText(text);
|
||||
ui.trans_CCText->setText(cc_text);
|
||||
} else {
|
||||
ui.ccLabel->setVisible(false);
|
||||
ui.trans_CCText->setVisible(false);
|
||||
ui.trans_CCText->clear();
|
||||
}
|
||||
|
||||
if (!msgInfo.rspeerid_msgbcc.empty() || !msgInfo.rsgxsid_msgbcc.empty())
|
||||
if (!bcc_text.isNull())
|
||||
{
|
||||
ui.bccLabel->setVisible(true);
|
||||
ui.trans_BCCText->setVisible(true);
|
||||
|
||||
text.clear();
|
||||
for(std::set<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgbcc.begin(); pit != msgInfo.rspeerid_msgbcc.end(); ++pit) {
|
||||
link = RetroShareLink::createMessage(*pit, "");
|
||||
if (link.valid())
|
||||
text += link.toHtml() + " ";
|
||||
}
|
||||
for(std::set<RsGxsId>::const_iterator pit = msgInfo.rsgxsid_msgbcc.begin(); pit != msgInfo.rsgxsid_msgbcc.end(); ++pit) {
|
||||
link = RetroShareLink::createMessage(*pit, "");
|
||||
if (link.valid())
|
||||
text += link.toHtml() + " ";
|
||||
}
|
||||
|
||||
ui.trans_BCCText->setText(text);
|
||||
ui.trans_BCCText->setText(bcc_text);
|
||||
} else {
|
||||
ui.bccLabel->setVisible(false);
|
||||
ui.trans_BCCText->setVisible(false);
|
||||
@ -680,16 +669,16 @@ void MessageWidget::fill(const std::string &msgId)
|
||||
|
||||
if(msgInfo.msgflags & RS_MSG_DISTANT) // distant message
|
||||
{
|
||||
tooltip_string = PeerDefs::rsidFromId(msgInfo.rsgxsid_srcId) ;
|
||||
link = RetroShareLink::createMessage(msgInfo.rsgxsid_srcId, "");
|
||||
tooltip_string = PeerDefs::rsidFromId(msgInfo.from.toGxsId()) ;
|
||||
link = RetroShareLink::createMessage(msgInfo.from.toGxsId(), "");
|
||||
}
|
||||
else
|
||||
{
|
||||
tooltip_string = PeerDefs::rsidFromId(msgInfo.rspeerid_srcId) ;
|
||||
link = RetroShareLink::createMessage(msgInfo.rspeerid_srcId, "");
|
||||
tooltip_string = PeerDefs::rsidFromId(msgInfo.from.toRsPeerId()) ;
|
||||
link = RetroShareLink::createMessage(msgInfo.from.toRsPeerId(), "");
|
||||
}
|
||||
|
||||
if (((msgInfo.msgflags & RS_MSG_SYSTEM) && msgInfo.rspeerid_srcId == ownId) || msgInfo.rspeerid_srcId.isNull()) {
|
||||
if (((msgInfo.msgflags & RS_MSG_SYSTEM) && msgInfo.from.toRsPeerId() == ownId) || msgInfo.from.type()!=MsgAddress::MSG_ADDRESS_TYPE_RSPEERID) {
|
||||
ui.fromText->setText("[Notification]");
|
||||
if (toolButtonReply) toolButtonReply->setEnabled(false);
|
||||
} else {
|
||||
@ -706,7 +695,7 @@ void MessageWidget::fill(const std::string &msgId)
|
||||
if (Settings->valueFromGroup(QString("Messages"), QString::fromUtf8("Emoticons"), true).toBool()) {
|
||||
formatTextFlag |= RSHTML_FORMATTEXT_EMBED_SMILEYS ;
|
||||
}
|
||||
text = RsHtmlMsg(msgInfo.msgflags).formatText(ui.msgText->document(), QString::fromUtf8(msgInfo.msg.c_str()), formatTextFlag);
|
||||
QString text = RsHtmlMsg(msgInfo.msgflags).formatText(ui.msgText->document(), QString::fromUtf8(msgInfo.msg.c_str()), formatTextFlag);
|
||||
ui.msgText->resetImagesStatus(Settings->getMsgLoadEmbeddedImages() || (msgInfo.msgflags & RS_MSG_LOAD_EMBEDDED_IMAGES));
|
||||
ui.msgText->setHtml(text);
|
||||
|
||||
@ -883,19 +872,21 @@ void MessageWidget::loadImagesAlways()
|
||||
|
||||
void MessageWidget::sendInvite()
|
||||
{
|
||||
MessageInfo mi;
|
||||
MessageInfo mi;
|
||||
|
||||
if (!rsMail)
|
||||
return;
|
||||
if (!rsMail)
|
||||
return;
|
||||
|
||||
if (!rsMail->getMessage(currMsgId, mi))
|
||||
return;
|
||||
if (!rsMail->getMessage(currMsgId, mi))
|
||||
return;
|
||||
|
||||
//if ((QMessageBox::question(this, tr("Send invite?"),tr("Do you really want send a invite with your Certificate?"),QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes)
|
||||
//{
|
||||
MessageComposer::sendInvite(mi.rsgxsid_srcId,false);
|
||||
//}
|
||||
if(!mi.from.type()==MsgAddress::MSG_ADDRESS_TYPE_RSGXSID)
|
||||
return;
|
||||
|
||||
if ((QMessageBox::question(this, tr("Send invite?"),tr("Do you really want send a invite with your Certificate?"),QMessageBox::Yes|QMessageBox::No, QMessageBox::Cancel))== QMessageBox::Yes)
|
||||
{
|
||||
MessageComposer::sendInvite(mi.from.toGxsId(),false);
|
||||
}
|
||||
}
|
||||
|
||||
void MessageWidget::setToolbarButtonStyle(Qt::ToolButtonStyle style)
|
||||
|
@ -166,6 +166,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
||||
ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_SUBJECT,itemDelegate);
|
||||
|
||||
ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_AUTHOR,new GxsIdTreeItemDelegate()) ;
|
||||
ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_TO,new GxsIdTreeItemDelegate()) ;
|
||||
|
||||
// workaround for Qt bug, should be solved in next Qt release 4.7.0
|
||||
// http://bugreports.qt.nokia.com/browse/QTBUG-8270
|
||||
@ -190,6 +191,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
||||
/* add filter actions */
|
||||
ui.filterLineEdit->addFilter(QIcon(), tr("Subject"), RsMessageModel::COLUMN_THREAD_SUBJECT, tr("Search Subject"));
|
||||
ui.filterLineEdit->addFilter(QIcon(), tr("From"), RsMessageModel::COLUMN_THREAD_AUTHOR, tr("Search From"));
|
||||
ui.filterLineEdit->addFilter(QIcon(), tr("To"), RsMessageModel::COLUMN_THREAD_TO, tr("Search To"));
|
||||
ui.filterLineEdit->addFilter(QIcon(), tr("Date"), RsMessageModel::COLUMN_THREAD_DATE, tr("Search Date"));
|
||||
ui.filterLineEdit->addFilter(QIcon(), tr("Content"), RsMessageModel::COLUMN_THREAD_CONTENT, tr("Search Content"));
|
||||
ui.filterLineEdit->addFilter(QIcon(), tr("Tags"), RsMessageModel::COLUMN_THREAD_TAGS, tr("Search Tags"));
|
||||
@ -212,10 +214,12 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
||||
|
||||
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_SUBJECT, fm.width("You have a message")*3.0);
|
||||
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_AUTHOR, fm.width("[Retroshare]")*1.1);
|
||||
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_TO, fm.width("[Retroshare]")*1.1);
|
||||
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_DATE, fm.width("01/01/1970")*1.1);
|
||||
|
||||
QHeaderView_setSectionResizeModeColumn(msgwheader, RsMessageModel::COLUMN_THREAD_SUBJECT, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(msgwheader, RsMessageModel::COLUMN_THREAD_AUTHOR, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(msgwheader, RsMessageModel::COLUMN_THREAD_TO, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeModeColumn(msgwheader, RsMessageModel::COLUMN_THREAD_DATE, QHeaderView::Interactive);
|
||||
|
||||
QHeaderView_setSectionResizeModeColumn(msgwheader, RsMessageModel::COLUMN_THREAD_STAR, QHeaderView::Fixed);
|
||||
@ -749,12 +753,12 @@ void MessagesDialog::messageTreeWidgetCustomPopupMenu(QPoint /*point*/)
|
||||
// test if identity is known. If not, no need to call the people tab. Also some mails come from nodes and we wont show that node in the people tab either.
|
||||
// The problem here is that the field rsgxsid_srcId is always populated with either the GxsId or the node of the source, which is inconsistent.
|
||||
|
||||
if(nCount==1 && rsIdentity->getIdDetails(msgInfo.rsgxsid_srcId,details))
|
||||
if(nCount==1 && msgInfo.from.type() == MsgAddress::MSG_ADDRESS_TYPE_RSGXSID)
|
||||
{
|
||||
std::cerr << "Src ID = " << msgInfo.rsgxsid_srcId << std::endl;
|
||||
std::cerr << "Src ID = " << msgInfo.from.toGxsId() << std::endl;
|
||||
|
||||
contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_AUTHOR_INFO),tr("Show author in People"),this,SLOT(showAuthorInPeopleTab()));
|
||||
contextMnu.addSeparator();
|
||||
contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_AUTHOR_INFO),tr("Show in People"),this,SLOT(showAuthorInPeopleTab()));
|
||||
contextMnu.addSeparator();
|
||||
}
|
||||
|
||||
contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MESSAGE), tr("New Message"), this, SLOT(newmessage()));
|
||||
@ -774,7 +778,7 @@ void MessagesDialog::showAuthorInPeopleTab()
|
||||
if (!rsMail->getMessage(mid, msgInfo))
|
||||
return;
|
||||
|
||||
if(msgInfo.rsgxsid_srcId.isNull())
|
||||
if(msgInfo.from.type() != MsgAddress::MSG_ADDRESS_TYPE_RSGXSID)
|
||||
return ;
|
||||
|
||||
/* window will destroy itself! */
|
||||
@ -784,7 +788,7 @@ void MessagesDialog::showAuthorInPeopleTab()
|
||||
return ;
|
||||
|
||||
MainWindow::showWindow(MainWindow::People);
|
||||
idDialog->navigate(RsGxsId(msgInfo.rsgxsid_srcId)) ;
|
||||
idDialog->navigate(RsGxsId(msgInfo.from.toGxsId())) ;
|
||||
}
|
||||
|
||||
void MessagesDialog::folderlistWidgetCustomPopupMenu(QPoint /*point*/)
|
||||
@ -1201,6 +1205,7 @@ void MessagesDialog::filterChanged(const QString& text)
|
||||
{
|
||||
case RsMessageModel::COLUMN_THREAD_SUBJECT: f = RsMessageModel::FILTER_TYPE_SUBJECT ; break;
|
||||
case RsMessageModel::COLUMN_THREAD_AUTHOR: f = RsMessageModel::FILTER_TYPE_FROM ; break;
|
||||
case RsMessageModel::COLUMN_THREAD_TO: f = RsMessageModel::FILTER_TYPE_TO ; break;
|
||||
case RsMessageModel::COLUMN_THREAD_DATE: f = RsMessageModel::FILTER_TYPE_DATE ; break;
|
||||
case RsMessageModel::COLUMN_THREAD_CONTENT: f = RsMessageModel::FILTER_TYPE_CONTENT ; break;
|
||||
case RsMessageModel::COLUMN_THREAD_TAGS: f = RsMessageModel::FILTER_TYPE_TAGS ; break;
|
||||
@ -1225,6 +1230,7 @@ void MessagesDialog::filterColumnChanged(int column)
|
||||
{
|
||||
case RsMessageModel::COLUMN_THREAD_SUBJECT: f = RsMessageModel::FILTER_TYPE_SUBJECT ; break;
|
||||
case RsMessageModel::COLUMN_THREAD_AUTHOR: f = RsMessageModel::FILTER_TYPE_FROM ; break;
|
||||
case RsMessageModel::COLUMN_THREAD_TO: f = RsMessageModel::FILTER_TYPE_TO ; break;
|
||||
case RsMessageModel::COLUMN_THREAD_DATE: f = RsMessageModel::FILTER_TYPE_DATE ; break;
|
||||
case RsMessageModel::COLUMN_THREAD_CONTENT: f = RsMessageModel::FILTER_TYPE_CONTENT ; break;
|
||||
case RsMessageModel::COLUMN_THREAD_TAGS: f = RsMessageModel::FILTER_TYPE_TAGS ; break;
|
||||
|
Loading…
Reference in New Issue
Block a user