From 4b846455b7c232b7db63f95c6a1943ccbc7ce15b Mon Sep 17 00:00:00 2001 From: saturneric Date: Wed, 27 Nov 2024 21:22:45 +0100 Subject: [PATCH] feat: support signing email --- include/GFModuleCommonUtils.hpp | 49 ++- src/m_email/AddressListEditorDialog.ui | 70 ++++ src/m_email/EMailHelper.h | 3 + src/m_email/EMailMetaDataDialog.cpp | 376 ++++++++++++++++++++ src/m_email/EMailMetaDataDialog.h | 79 ++++ src/m_email/EMailMetaDataDialog.ui | 373 +++++++++++++++++++ src/m_email/EMailModule.cpp | 48 ++- src/m_gpg_info/GnuPGInfoGatheringModule.cpp | 2 +- src/m_gpg_info/GnupgTab.cpp | 2 +- src/m_ver_check/UpdateTab.cpp | 2 +- src/m_ver_check/UpdateTab.h | 2 +- 11 files changed, 998 insertions(+), 8 deletions(-) create mode 100644 src/m_email/AddressListEditorDialog.ui create mode 100644 src/m_email/EMailMetaDataDialog.cpp create mode 100644 src/m_email/EMailMetaDataDialog.h create mode 100644 src/m_email/EMailMetaDataDialog.ui diff --git a/include/GFModuleCommonUtils.hpp b/include/GFModuleCommonUtils.hpp index 1811ffc..73de58a 100644 --- a/include/GFModuleCommonUtils.hpp +++ b/include/GFModuleCommonUtils.hpp @@ -32,10 +32,11 @@ #include #include #include -#include #include +#include #include +#include #include #define DUP(v) GFModuleStrDup(v) @@ -394,9 +395,51 @@ inline auto CharArrayToQStringList(char** pl_components, int size) -> QStringList { QStringList list; for (int i = 0; i < size; ++i) { - list.append(QString::fromUtf8(pl_components[i])); - GFFreeMemory(pl_components[i]); + list.append(UDUP(pl_components[i])); } GFFreeMemory(pl_components); return list; } + +inline auto QListToCharArray(const QStringList& list) -> char** { + char** char_array = + static_cast(GFAllocateMemory(list.size() * sizeof(char*))); + + int index = 0; + for (const QString& item : list) { + QByteArray value = item.toUtf8(); + char_array[index] = static_cast(GFAllocateMemory(value.size() + 1)); + std::strcpy(char_array[index], value.constData()); + index++; + } + + return char_array; +} + +inline auto ConvertQVariantToVoidPtr(const QVariant& variant) -> void* { + void* mem = GFAllocateMemory(sizeof(QVariant)); + auto* variant_ptr = new (mem) QVariant(variant); + return static_cast(variant_ptr); +} + +inline auto ConvertVoidPtrToQVariant(void* ptr) -> QVariant { + if (ptr == nullptr) return {}; + + auto* variant_ptr = static_cast(ptr); + QVariant variant = *variant_ptr; + + GFFreeMemory(variant_ptr); + return variant; +} + +#define Q_VARIANT_Q_OBJECT_FACTORY_DECLARE(name) \ + auto name(void* data_raw_ptr) -> void*; + +#define Q_VARIANT_Q_OBJECT_FACTORY_DEFINE(name, func) \ + auto name(void* data_raw_ptr) -> void* { \ + auto data = ConvertVoidPtrToQVariant(data_raw_ptr); \ + return func(data); \ + } + +#define GUI_OBJECT(factory, data) \ + GFUICreateGUIObject(factory, ConvertQVariantToVoidPtr(data)) diff --git a/src/m_email/AddressListEditorDialog.ui b/src/m_email/AddressListEditorDialog.ui new file mode 100644 index 0000000..c3d074f --- /dev/null +++ b/src/m_email/AddressListEditorDialog.ui @@ -0,0 +1,70 @@ + + + AddressListEditorDialog + + + + 0 + 0 + 606 + 368 + + + + Address List Editor + + + + + + + + Address List + + + + + + + QAbstractItemView::EditTrigger::DoubleClicked|QAbstractItemView::EditTrigger::EditKeyPressed + + + true + + + false + + + 6 + + + + + + + Add Address + + + + + + + Tips: You can double-click the email address in the edit list, or click the email to pop up the option menu. + + + true + + + + + + + + + Delete Selected Email Address + + + + + + diff --git a/src/m_email/EMailHelper.h b/src/m_email/EMailHelper.h index 3a70d0b..75cffe2 100644 --- a/src/m_email/EMailHelper.h +++ b/src/m_email/EMailHelper.h @@ -34,6 +34,9 @@ // vmime #define VMIME_STATIC #include +// vmime extra +#include +#include auto inline Q_SC(const std::string& s) -> QString { return QString::fromStdString(s); diff --git a/src/m_email/EMailMetaDataDialog.cpp b/src/m_email/EMailMetaDataDialog.cpp new file mode 100644 index 0000000..11583b9 --- /dev/null +++ b/src/m_email/EMailMetaDataDialog.cpp @@ -0,0 +1,376 @@ +/** + * Copyright (C) 2021-2024 Saturneric + * + * This file is part of GpgFrontend. + * + * GpgFrontend is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 GpgFrontend. If not, see . + * + * The initial version of the source code is inherited from + * the gpg4usb project, which is under GPL-3.0-or-later. + * + * All the source code of GpgFrontend was modified and released by + * Saturneric starting on May 12, 2021. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#include "EMailMetaDataDialog.h" + +#include + +#include +#include +#include +#include + +#include "EMailHelper.h" +#include "ui_EMailMetaDataDialog.h" + +static const QRegularExpression kNameEmailStringRegex{ + R"(^\s*(.*)\s*<\s*([^<>@\s]+@[^<>@\s]+)\s*>\s*$)"}; + +auto ParseEmailString(const QString& input, QString& name, + QString& email) -> bool { + QRegularExpressionMatch match = kNameEmailStringRegex.match(input); + + if (match.hasMatch()) { + name = match.captured(1).trimmed(); + email = match.captured(2).trimmed(); + return true; + } + + return false; +} + +class ParameterizedHeaderField : public vmime::parameterizedHeaderField { + public: + ParameterizedHeaderField() = default; +}; + +class HeaderField : public vmime::headerField { + public: + HeaderField() = default; +}; + +class ContentTypeField : public vmime::contentTypeField { + public: + ContentTypeField() = default; +}; + +EMailMetaDataDialog::EMailMetaDataDialog(QByteArray body_data, QWidget* parent) + : QDialog(parent), + ui_(QSharedPointer::create()), + body_data_(std::move(body_data)) { + ui_->setupUi(this); + + connect(ui_->exportMailButton, &QPushButton::clicked, this, + &EMailMetaDataDialog::slot_export_eml_data); + + setModal(true); + setAttribute(Qt::WA_DeleteOnClose); + setWindowFlags(Qt::Dialog | Qt::Window); +} + +Q_VARIANT_Q_OBJECT_FACTORY_DEFINE(CreateEMailMetaDataDialog, + [](QVariant data) -> void* { + return new EMailMetaDataDialog( + data.toByteArray(), nullptr); + }); + +void EMailMetaDataDialog::slot_export_eml_data() { + // sign key is a must + if (sign_key_.isEmpty()) emit SignalEMLDataGenerateFailed("No Sign Key"); + + auto from = ui_->fromEdit->text(); + auto to = ui_->toEdit->text(); + auto cc = ui_->ccEdit->text(); + auto bcc = ui_->bccEdit->text(); + auto subject = ui_->subjectEdit->text(); + + auto recipient_list = to.split(';', Qt::SkipEmptyParts); + auto cc_list = cc.split(';', Qt::SkipEmptyParts); + auto bcc_list = bcc.split(';', Qt::SkipEmptyParts); + + QString name; + QString email; + + try { + vmime::messageBuilder msg_builder; + + if (ParseEmailString(from, name, email)) { + msg_builder.setExpeditor( + vmime::mailbox(vmime::text(name.toStdString()), email.toStdString())); + } else { + msg_builder.setExpeditor(vmime::mailbox(email.toStdString())); + } + + for (const QString& recipient : recipient_list) { + auto trimmed_recipient = recipient.trimmed(); + + if (ParseEmailString(trimmed_recipient, name, email)) { + msg_builder.getRecipients().appendAddress( + vmime::make_shared(vmime::text(name.toStdString()), + email.toStdString())); + } else { + msg_builder.getRecipients().appendAddress( + vmime::make_shared( + trimmed_recipient.toStdString())); + } + } + + for (const QString& recipient : cc_list) { + auto trimmed_recipient = recipient.trimmed(); + if (ParseEmailString(trimmed_recipient, name, email)) { + msg_builder.getCopyRecipients().appendAddress( + vmime::make_shared(vmime::text(name.toStdString()), + email.toStdString())); + } else { + msg_builder.getCopyRecipients().appendAddress( + vmime::make_shared( + trimmed_recipient.toStdString())); + } + } + + for (const QString& recipient : bcc_list) { + auto trimmed_recipient = recipient.trimmed(); + if (ParseEmailString(trimmed_recipient, name, email)) { + msg_builder.getBlindCopyRecipients().appendAddress( + vmime::make_shared(vmime::text(name.toStdString()), + email.toStdString())); + } else { + msg_builder.getBlindCopyRecipients().appendAddress( + vmime::make_shared( + trimmed_recipient.toStdString())); + } + } + + msg_builder.setSubject(vmime::text(subject.toStdString())); + + vmime::shared_ptr msg = msg_builder.construct(); + + auto header = msg->getHeader(); + + // no Content-Transfer-Encoding + header->removeField( + header->getField(vmime::fields::CONTENT_TRANSFER_ENCODING)); + + auto content_type_header_field = + header->getField(vmime::fields::CONTENT_TYPE); + content_type_header_field->setValue("multipart/signed"); + auto body_boundary = vmime::body::generateRandomBoundaryString(); + content_type_header_field->appendParameter( + vmime::make_shared("protocol", + "application/pgp-signature")); + content_type_header_field->setBoundary(body_boundary); + + auto root_body_part = vmime::make_shared(); + auto container_part = vmime::make_shared(); + auto mime_part = vmime::make_shared(); + auto public_key_part = vmime::make_shared(); + auto signature_part = vmime::make_shared(); + + root_body_part->appendPart(container_part); + root_body_part->appendPart(signature_part); + msg->setBody(root_body_part); + + root_body_part->setPrologText( + "This is an OpenPGP/MIME signed message (RFC 4880 and 3156)"); + + auto container_boundary = vmime::body::generateRandomBoundaryString(); + auto container_part_header = container_part->getHeader(); + auto container_part_content_ttype_header_field = + container_part_header->getField( + vmime::fields::CONTENT_TYPE); + container_part_content_ttype_header_field->setValue("multipart/mixed"); + container_part_content_ttype_header_field->setBoundary(container_boundary); + + auto container_part_body = container_part->getBody(); + + container_part_body->appendPart(mime_part); + container_part_body->appendPart(public_key_part); + + auto public_key_part_header = public_key_part->getHeader(); + + auto public_key_name = QString("OpenPGP_0x%1.asc").arg(sign_key_.toUpper()); + auto public_key_part_content_type_header_field = + public_key_part_header->getField( + vmime::fields::CONTENT_TYPE); + public_key_part_content_type_header_field->setValue("application/pgp-keys"); + public_key_part_content_type_header_field->appendParameter( + vmime::make_shared("name", + public_key_name.toStdString())); + + auto public_key_part_content_desc_header_field = + public_key_part_header->getField(vmime::fields::CONTENT_DESCRIPTION); + public_key_part_content_desc_header_field->setValue("OpenPGP public key"); + + auto public_key_part_content_trans_encode_field = + public_key_part_header->getField( + vmime::fields::CONTENT_TRANSFER_ENCODING); + public_key_part_content_trans_encode_field->setValue("quoted-printable"); + + auto public_key_part_content_disp_header_field = + public_key_part_header->getField( + vmime::fields::CONTENT_DISPOSITION); + public_key_part_content_disp_header_field->setValue("attachment"); + public_key_part_content_disp_header_field->setFilename( + vmime::word(public_key_name.toStdString())); + + auto signature_part_header = signature_part->getHeader(); + + auto signature_part_content_type_header_field = + signature_part_header->getField( + vmime::fields::CONTENT_TYPE); + signature_part_content_type_header_field->setValue( + "application/pgp-signature"); + signature_part_content_type_header_field->appendParameter( + vmime::make_shared("name", "OpenPGP_signature.asc")); + + auto signature_part_content_desc_header_field = + signature_part_header->getField(vmime::fields::CONTENT_DESCRIPTION); + signature_part_content_desc_header_field->setValue( + "OpenPGP digital signature"); + + auto signature_part_content_disp_header_field = + signature_part_header->getField( + vmime::fields::CONTENT_DISPOSITION); + signature_part_content_disp_header_field->setValue("attachment"); + signature_part_content_disp_header_field->setFilename( + vmime::word({"OpenPGP_signature.asc"})); + + auto public_key = UDUP(GFGpgPublicKey(channel_, QDUP(sign_key_), 1)); + if (public_key.isEmpty()) { + emit SignalEMLDataGenerateFailed("Get Public Key of Sign Key Failed"); + return; + } + + auto public_key_part_part_body = public_key_part->getBody(); + auto public_key_part_body_content = + vmime::make_shared(); + public_key_part_body_content->setData( + public_key.toLatin1().replace('\n', "\r\n").toStdString(), + vmime::encoding(vmime::encodingTypes::QUOTED_PRINTABLE)); + public_key_part_part_body->setContents(public_key_part_body_content); + + auto mime_part_header = mime_part->getHeader(); + + auto mime_part_content_type_header_field = + mime_part_header->getField( + vmime::fields::CONTENT_TYPE); + mime_part_content_type_header_field->setValue("text/plain"); + mime_part_content_type_header_field->appendParameter( + vmime::make_shared("charset", "UTF-8")); + mime_part_content_type_header_field->appendParameter( + vmime::make_shared("format", "flowed")); + auto mime_part_content_trans_encode_field = + mime_part_header->getField(vmime::fields::CONTENT_TRANSFER_ENCODING); + mime_part_content_trans_encode_field->setValue("base64"); + + auto mime_part_part_body = mime_part->getBody(); + auto mime_part_body_content = + vmime::make_shared(); + mime_part_body_content->setData( + body_data_.toBase64().toStdString(), + vmime::encoding(vmime::encodingTypes::BASE64)); + mime_part_part_body->setContents(mime_part_body_content); + + auto container_raw_data = + container_part->generate(vmime::lineLengthLimits::infinite); + qDebug().noquote() << "\n" << container_raw_data; + + container_raw_data = + container_part->generate(vmime::lineLengthLimits::infinite); + qDebug().noquote() << "\n" << container_raw_data; + + auto container_raw_data_hash = + QCryptographicHash::hash(container_raw_data, QCryptographicHash::Sha1); + FLOG_DEBUG("raw content of signature hash: %1", + container_raw_data_hash.toHex()); + + FLOG_DEBUG("MIME Raw Data For Signature: %1", container_raw_data); + FLOG_DEBUG("Signature Channel: %1, Sign Key: %2", channel_, sign_key_); + + GFGpgSignResult* s; + auto ret = GFGpgSignData(channel_, QListToCharArray({sign_key_}), 1, + QDUP(Q_SC(container_raw_data)), 1, 1, &s); + + if (ret != 0) { + emit SignalEMLDataGenerateFailed("Sign Failed"); + return; + } + + auto signature = UDUP(s->signature); + auto hash_algo = UDUP(s->hash_algo); + + GFFreeMemory(s); + + FLOG_DEBUG("Hash Algo: %1 Signature Data: %2", hash_algo, signature); + content_type_header_field->appendParameter( + vmime::make_shared( + "micalg", + QString("pgp-%1").arg(hash_algo.toLower()).toStdString())); + + auto signature_part_body = signature_part->getBody(); + auto signature_part_body_content = + vmime::make_shared( + signature.toStdString()); + signature_part_body->setContents(signature_part_body_content); + + auto eml_data = Q_SC(msg->generate(vmime::lineLengthLimits::infinite)); + + FLOG_DEBUG("EML Data: %1", eml_data); + + emit SignalEMLDataGenerateSuccess(eml_data); + this->close(); + return; + + } catch (const vmime::exception& e) { + QMessageBox::critical(this, tr("Error"), + tr("Failed to export EML Data: %1").arg(e.what())); + emit SignalEMLDataGenerateFailed(e.what()); + this->close(); + return; + } + + emit SignalEMLDataGenerateFailed("Unknown Error"); + this->close(); +} + +void EMailMetaDataDialog::slot_export_encrypted_data() {} + +void EMailMetaDataDialog::SetSignKey(QString k) { + sign_key_ = std::move(k); + slot_set_from_field_by_sign_key(); +} + +void EMailMetaDataDialog::SetChannel(int c) { channel_ = c; } + +void EMailMetaDataDialog::slot_set_from_field_by_sign_key() { + GFGpgKeyUID* s; + auto ret = GFGpgKeyPrimaryUID(channel_, QDUP(sign_key_), &s); + if (ret != 0) { + FLOG_WARN("cannot get primary uid from sign key %1, ret: %2", sign_key_, + ret); + return; + } + + from_name_ = UDUP(s->name); + from_email_ = UDUP(s->email); + auto comment = UDUP(s->comment); + + GFFreeMemory(s); + + ui_->fromEdit->setText(QString("%1 <%2>").arg(from_name_).arg(from_email_)); +} diff --git a/src/m_email/EMailMetaDataDialog.h b/src/m_email/EMailMetaDataDialog.h new file mode 100644 index 0000000..983dc0a --- /dev/null +++ b/src/m_email/EMailMetaDataDialog.h @@ -0,0 +1,79 @@ +/** + * Copyright (C) 2021-2024 Saturneric + * + * This file is part of GpgFrontend. + * + * GpgFrontend is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 GpgFrontend. If not, see . + * + * The initial version of the source code is inherited from + * the gpg4usb project, which is under GPL-3.0-or-later. + * + * All the source code of GpgFrontend was modified and released by + * Saturneric starting on May 12, 2021. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#pragma once + +#include +#include + +#include "GFModuleCommonUtils.hpp" + +class QWidget; +class Ui_EMailMetaDataDialog; + +class EMailMetaDataDialog : public QDialog { + Q_OBJECT + public: + explicit EMailMetaDataDialog(QByteArray body_data, QWidget *parent); + + /** + * @brief Set the Channel object + * + */ + void SetChannel(int c); + + /** + * @brief Set the Sign Keys object + * + */ + void SetSignKey(QString k); + + signals: + + void SignalEMLDataGenerateSuccess(QString); + + void SignalEMLDataGenerateFailed(QString); + + private slots: + + void slot_export_eml_data(); + + void slot_export_encrypted_data(); + + void slot_set_from_field_by_sign_key(); + + private: + QSharedPointer ui_; + QByteArray body_data_; + int channel_; + QString sign_key_; + QString from_name_; + QString from_email_; +}; + +Q_VARIANT_Q_OBJECT_FACTORY_DECLARE(CreateEMailMetaDataDialog); \ No newline at end of file diff --git a/src/m_email/EMailMetaDataDialog.ui b/src/m_email/EMailMetaDataDialog.ui new file mode 100644 index 0000000..977a535 --- /dev/null +++ b/src/m_email/EMailMetaDataDialog.ui @@ -0,0 +1,373 @@ + + + EMailMetaDataDialog + + + + 0 + 0 + 599 + 522 + + + + ArrowCursor + + + Qt::ContextMenuPolicy::NoContextMenu + + + Message + + + false + + + false + + + + + + + + + 6 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + From + + + 5 + + + + + + + + + + 0 + + + false + + + 2 + + + Qt::Orientation::Vertical + + + + + + + CC + + + true + + + + + + + BCC + + + true + + + + + + + + + + + 6 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + To + + + 5 + + + + + + + + + + Edit Recipients(s) + + + + + + + + + + Qt::Orientation::Horizontal + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Subject + + + 5 + + + + + + + + + + + + + Qt::Orientation::Horizontal + + + + + + + + 6 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + CC + + + 5 + + + + + + + + + + Edit CC(s) + + + + + + + + + + + 6 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + BCC + + + 5 + + + + + + + + + + Edit BCC(s) + + + + + + + + + + Tips: You can fill in multiple email addresses, please separate them with ";". + + + + + + + Qt::Orientation::Horizontal + + + + + + + + + + + + GPG Keys: + + + + + + + + 0 + 0 + + + + + + + true + + + + + + + + + + + + + + + + + + + Qt::Orientation::Horizontal + + + + + + + + + Encrypt + + + true + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + Export + + + + + + + + + + + + diff --git a/src/m_email/EMailModule.cpp b/src/m_email/EMailModule.cpp index 582542a..1262c75 100644 --- a/src/m_email/EMailModule.cpp +++ b/src/m_email/EMailModule.cpp @@ -39,6 +39,8 @@ #include #include +#include "EMailMetaDataDialog.h" + // vmime #define VMIME_STATIC #include @@ -51,6 +53,7 @@ // #include "EMailHelper.h" +#include "EMailMetaDataDialog.h" GF_MODULE_API_DEFINE_V2("com.bktus.gpgfrontend.module.email", "Email", "1.0.0", "Everything related to E-Mails.", "Saturneric") @@ -62,7 +65,7 @@ auto GFRegisterModule() -> int { LISTEN("EMAIL_VERIFY_EML_DATA"); LISTEN("EMAIL_DECRYPT_EML_DATA"); - + LISTEN("EMAIL_EXPORT_EML_DATA"); return 0; } @@ -185,6 +188,9 @@ REGISTER_EVENT_HANDLER(EMAIL_VERIFY_EML_DATA, [](const MEvent& event) -> int { FLOG_DEBUG("mime part of raw content hash: %1", part_mime_content_hash.toHex()); + FLOG_DEBUG("mime part of raw content: %1", part_mime_content_text); + qDebug().noquote() << "\n" << part_mime_content_text; + if (part_mime_content_text.isEmpty()) CB_ERR(event, -2, "mime raw data part is empty"); @@ -399,6 +405,46 @@ REGISTER_EVENT_HANDLER(EMAIL_DECRYPT_EML_DATA, [](const MEvent& event) -> int { return 0; }); +REGISTER_EVENT_HANDLER(EMAIL_EXPORT_EML_DATA, [](const MEvent& event) -> int { + if (event["body_data"].isEmpty()) CB_ERR(event, -1, "body_data is empty"); + if (event["channel"].isEmpty()) CB_ERR(event, -1, "channel is empty"); + if (event["sign_key"].isEmpty()) CB_ERR(event, -1, "sign_key is empty"); + + auto channel = event.value("channel", "0").toInt(); + auto sign_key = event.value("sign_key", ""); + + FLOG_DEBUG("eml sign key: %1", sign_key); + + auto data = QByteArray::fromBase64(QString(event["body_data"]).toLatin1()); + + auto* dialog = GUI_OBJECT(CreateEMailMetaDataDialog, {data}); + auto* r_dialog = + qobject_cast(static_cast(dialog)); + if (r_dialog == nullptr) + CB_ERR(event, -1, "convert dialog to r_dialog failed"); + r_dialog->SetChannel(channel); + r_dialog->SetSignKey(sign_key); + + GFUIShowDialog(dialog, nullptr); + + QObject::connect(r_dialog, &EMailMetaDataDialog::SignalEMLDataGenerateSuccess, + r_dialog, [=](QString eml_data) { + // callback + CB(event, GFGetModuleID(), + { + {"ret", QString::number(0)}, + {"eml_data", eml_data}, + }); + }); + + QObject::connect(r_dialog, &EMailMetaDataDialog::SignalEMLDataGenerateFailed, + r_dialog, [=](QString error) { + // callback + CB_ERR(event, -1, "Generate EML Data Failed: " + error); + }); + + return 0; +}); auto GFDeactivateModule() -> int { return 0; } auto GFUnregisterModule() -> int { diff --git a/src/m_gpg_info/GnuPGInfoGatheringModule.cpp b/src/m_gpg_info/GnuPGInfoGatheringModule.cpp index e882d67..0d02df1 100644 --- a/src/m_gpg_info/GnuPGInfoGatheringModule.cpp +++ b/src/m_gpg_info/GnuPGInfoGatheringModule.cpp @@ -63,7 +63,7 @@ extern void GetGpgOptionInfos(void *, int, const char *, const char *); extern auto StartGatheringGnuPGInfo() -> int; -extern auto GnupgTabFactory(const char *id) -> void *; +extern auto GnupgTabFactory(void *id) -> void *; using Context = struct { QString gpgme_version; diff --git a/src/m_gpg_info/GnupgTab.cpp b/src/m_gpg_info/GnupgTab.cpp index 5123155..6548316 100644 --- a/src/m_gpg_info/GnupgTab.cpp +++ b/src/m_gpg_info/GnupgTab.cpp @@ -331,4 +331,4 @@ void GnupgTab::gather_gnupg_info() { } } -auto GnupgTabFactory(const char* id) -> void* { return new GnupgTab(); } \ No newline at end of file +auto GnupgTabFactory(void*) -> void* { return new GnupgTab(); } \ No newline at end of file diff --git a/src/m_ver_check/UpdateTab.cpp b/src/m_ver_check/UpdateTab.cpp index 9dd281e..9946f10 100644 --- a/src/m_ver_check/UpdateTab.cpp +++ b/src/m_ver_check/UpdateTab.cpp @@ -187,4 +187,4 @@ void UpdateTab::slot_show_version_status() { } } -auto UpdateTabFactory(const char* id) -> void* { return new UpdateTab(); } \ No newline at end of file +auto UpdateTabFactory(void*) -> void* { return new UpdateTab(); } \ No newline at end of file diff --git a/src/m_ver_check/UpdateTab.h b/src/m_ver_check/UpdateTab.h index 7616200..4003a23 100644 --- a/src/m_ver_check/UpdateTab.h +++ b/src/m_ver_check/UpdateTab.h @@ -72,4 +72,4 @@ class UpdateTab : public QWidget { void SignalReplyFromUpdateServer(QByteArray data); }; -auto UpdateTabFactory(const char* id) -> void*; \ No newline at end of file +auto UpdateTabFactory(void* id) -> void*; \ No newline at end of file