aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/thread/SMTPSendMailThread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/thread/SMTPSendMailThread.cpp')
-rw-r--r--src/ui/thread/SMTPSendMailThread.cpp52
1 files changed, 27 insertions, 25 deletions
diff --git a/src/ui/thread/SMTPSendMailThread.cpp b/src/ui/thread/SMTPSendMailThread.cpp
index edfd3156..f1cb1626 100644
--- a/src/ui/thread/SMTPSendMailThread.cpp
+++ b/src/ui/thread/SMTPSendMailThread.cpp
@@ -1,4 +1,6 @@
/**
+ * Copyright (C) 2021 Saturneric
+ *
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
@@ -6,16 +8,16 @@
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * Foobar is distributed in the hope that it will be useful,
+ * GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
- * The initial version of the source code is inherited from gpg4usb-team.
- * Their source code version also complies with GNU General Public License.
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
*
* The source code version of this software was modified and released
* by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
@@ -26,9 +28,9 @@
#include <boost/format.hpp>
-#include "gpg/function/BasicOperator.h"
-#include "gpg/function/GpgKeyGetter.h"
-#include "gpg/function/GpgKeyImportExporter.h"
+#include "core/function/gpg/GpgBasicOperator.h"
+#include "core/function/gpg/GpgKeyGetter.h"
+#include "core/function/gpg/GpgKeyImportExporter.h"
namespace GpgFrontend::UI {
@@ -64,11 +66,11 @@ void SMTPSendMailThread::run() {
GpgEncrResult result;
auto in_buffer = std::make_unique<ByteArray>(plain_text);
auto keys = GpgKeyGetter::GetInstance().GetKeys(public_key_ids_);
- auto err = BasicOperator::GetInstance().Encrypt(
+ auto err = GpgBasicOperator::GetInstance().Encrypt(
std::move(keys), *in_buffer, out_buffer, result);
if (check_gpg_error_2_err_code(err) != GPG_ERR_NO_ERROR) {
- emit signalSMTPResult("Fail to encrypt with gpg keys");
+ emit SignalSMTPResult("Fail to encrypt with gpg keys");
return;
}
text->setText(out_buffer->c_str());
@@ -126,12 +128,12 @@ void SMTPSendMailThread::run() {
// The signature MUST be generated detached from the signed data
// so that the process does not alter the signed data in any way.
- auto err = BasicOperator::GetInstance().Sign(
+ auto err = GpgBasicOperator::GetInstance().Sign(
std::move(keys), *in_buffer, out_buffer, GPGME_SIG_MODE_DETACH,
result);
if (check_gpg_error_2_err_code(err) != GPG_ERR_NO_ERROR) {
- emit signalSMTPResult("Fail to sign with gpg keys");
+ emit SignalSMTPResult("Fail to sign with gpg keys");
return;
}
@@ -174,7 +176,7 @@ void SMTPSendMailThread::run() {
auto public_key_file_name =
boost::format("%1%_pubkey.asc") % attached_public_key_ids_;
- addFileContent(public_key_file_name.str().c_str(), out_buffer->c_str());
+ AddFileContent(public_key_file_name.str().c_str(), out_buffer->c_str());
auto& key_file = files_.back();
key_file->setEncoding(MimePart::_7Bit);
key_file->setContentType("application/pgp-keys");
@@ -190,70 +192,70 @@ void SMTPSendMailThread::run() {
// Now we can send the mail
if (!smtp.connectToHost()) {
- emit signalSMTPResult("Fail to connect SMTP server");
+ emit SignalSMTPResult("Fail to connect SMTP server");
return;
}
if (!smtp.login()) {
- emit signalSMTPResult("Fail to login");
+ emit SignalSMTPResult("Fail to login");
return;
}
if (!smtp.sendMail(message)) {
- emit signalSMTPResult("Fail to send mail");
+ emit SignalSMTPResult("Fail to send mail");
return;
}
smtp.quit();
- emit signalSMTPResult("Succeed in sending a test email");
+ emit SignalSMTPResult("Succeed in sending a test email");
}
-void SMTPSendMailThread::setBCC(const QString& bccs) {
+void SMTPSendMailThread::SetBCC(const QString& bccs) {
QStringList bcc_string_list = bccs.split(';');
for (const auto& bcc : bcc_string_list) {
if (!bcc.isEmpty()) message.addBcc(new EmailAddress(bcc.trimmed()));
}
}
-void SMTPSendMailThread::setCC(const QString& ccs) {
+void SMTPSendMailThread::SetCC(const QString& ccs) {
QStringList cc_string_list = ccs.split(';');
for (const auto& cc : cc_string_list) {
if (!cc.isEmpty()) message.addCc(new EmailAddress(cc.trimmed()));
}
}
-void SMTPSendMailThread::setRecipient(const QString& recipients) {
+void SMTPSendMailThread::SetRecipient(const QString& recipients) {
QStringList rcpt_string_list = recipients.split(';');
for (const auto& rcpt : rcpt_string_list) {
if (!rcpt.isEmpty()) message.addRecipient(new EmailAddress(rcpt.trimmed()));
}
}
-void SMTPSendMailThread::setSender(const QString& sender) {
+void SMTPSendMailThread::SetSender(const QString& sender) {
message.setSender(new EmailAddress(sender));
}
-void SMTPSendMailThread::addTextContent(const QString& content) {
+void SMTPSendMailThread::AddTextContent(const QString& content) {
auto text = std::make_unique<MimeText>(content.trimmed());
texts_.push_back(std::move(text));
}
-void SMTPSendMailThread::addFileContent(const QString& file_name,
+void SMTPSendMailThread::AddFileContent(const QString& file_name,
const QByteArray& content) {
auto file = std::make_unique<MimeFile>(content, file_name);
files_.push_back(std::move(file));
}
-void SMTPSendMailThread::setEncryptContent(
+void SMTPSendMailThread::SetEncryptContent(
bool encrypt_content, GpgFrontend::KeyIdArgsListPtr public_key_ids) {
this->encrypt_content_ = encrypt_content;
this->public_key_ids_ = std::move(public_key_ids);
}
-void SMTPSendMailThread::setAttachSignatureFile(
+void SMTPSendMailThread::SetAttachSignatureFile(
bool attach_signature_file, GpgFrontend::KeyId private_key_id) {
this->attach_signature_file_ = attach_signature_file;
this->private_key_id_ = std::move(private_key_id);
}
-void SMTPSendMailThread::setAttachPublicKey(
+void SMTPSendMailThread::SetAttachPublicKey(
bool attach_public_key_file, GpgFrontend::KeyId attached_public_key_ids) {
this->attach_public_key_file_ = attach_public_key_file;
this->attached_public_key_ids_ = std::move(attached_public_key_ids);