void MailEditorMainWindow::transformRecipientList(const TRecipientPublicKey& senderId, const TRecipientPublicKeys& sourceToList, const TRecipientPublicKeys& sourceCCList) { TPublicKeyIndex allRecipients, myIdentities; TRecipientPublicKeys toRecipients, ccRecipients, empty; toRecipients.reserve(sourceToList.size() + 1); ccRecipients.reserve(sourceCCList.size()); /** First fill allRecipient index with own identities public keys, to avoid sending replied message to myself */ for(const auto& id : bts::get_profile()->identities()) { const auto& pk = id.public_key; assert(pk.valid()); TInsertInfo ii = allRecipients.insert(pk); assert(ii.second && "Redundant identity public keys"); } myIdentities = allRecipients; TRecipientPublicKey newSenderId; toRecipients.push_back(senderId); for(const auto& recipient : sourceToList) { TInsertInfo ii = allRecipients.insert(recipient); if(ii.second) toRecipients.push_back(recipient); if(newSenderId.valid() == false && myIdentities.find(recipient) != myIdentities.end()) newSenderId = recipient; } for(const auto& recipient : sourceCCList) { TInsertInfo ii = allRecipients.insert(recipient); if(ii.second) ccRecipients.push_back(recipient); } MailFields->SetRecipientList(newSenderId, toRecipients, ccRecipients, empty); }
void MailFieldsWidget::LoadContents(const TRecipientPublicKey& senderPK, const TPhysicalMailMessage& srcMsg) { if(senderPK.valid()) { selectSenderIdentity(senderPK); showFromControls(true); } SetRecipientList(srcMsg.to_list, srcMsg.cc_list, srcMsg.bcc_list); ui->subjectEdit->setText(QString(srcMsg.subject.c_str())); }
void MailFieldsWidget::selectSenderIdentity(const TRecipientPublicKey& senderPK) { assert(senderPK.valid()); for(const auto& it : Action2Identity) { const IMailProcessor::TIdentity& id = it.second; assert(id.public_key.valid()); if(id.public_key == senderPK) { onFromBtnTriggered(it.first); return; } } assert(EditMode == false && "When editing an email only one of profile identities could be used" "as sender."); setChosenSender(senderPK); }