Compare commits
No commits in common. "024df3ab4316143b02c742f3acc67320972b83d9" and "36eab07eb0429b9204d41532ca6f838c722ec4fe" have entirely different histories.
024df3ab43
...
36eab07eb0
@ -54,17 +54,18 @@ auto EncryptPlainText(int channel, const QStringList& keys,
|
||||
auto ret = GFGpgEncryptData(channel, QListToCharArray(keys), keys.size(),
|
||||
QDUP(body_data), 1, &s);
|
||||
|
||||
auto encrypted_data = UDUP(s->encrypted_data);
|
||||
auto gpg_error_string = UDUP(s->error_string);
|
||||
capsule_id = UDUP(s->capsule_id);
|
||||
|
||||
GFFreeMemory(s);
|
||||
|
||||
if (ret != 0) {
|
||||
eml_data = "Encryption Failed: " + gpg_error_string;
|
||||
eml_data = "Encryption Failed";
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto encrypted_data = UDUP(s->encrypted_data);
|
||||
|
||||
capsule_id = UDUP(s->capsule_id);
|
||||
FLOG_DEBUG("got capsule id: %1", capsule_id);
|
||||
|
||||
GFFreeMemory(s);
|
||||
|
||||
vmime::messageBuilder msg_builder;
|
||||
|
||||
if (ParseEmailString(from, name, email)) {
|
||||
@ -190,7 +191,7 @@ auto EncryptPlainText(int channel, const QStringList& keys,
|
||||
|
||||
} catch (const vmime::exception& e) {
|
||||
eml_data = QString("VMIME Error: %1").arg(e.what());
|
||||
return -2;
|
||||
return -1;
|
||||
}
|
||||
|
||||
eml_data = QString("Unknown Error: %1");
|
||||
@ -233,10 +234,8 @@ auto EncryptEMLData(int channel, const QStringList& keys,
|
||||
std::static_pointer_cast<vmime::headerField>(backup_to_field_component);
|
||||
|
||||
auto backup_message_id_field_component =
|
||||
header->hasField(vmime::fields::MESSAGE_ID)
|
||||
? header->getField<vmime::headerField>(vmime::fields::MESSAGE_ID)
|
||||
->clone()
|
||||
: nullptr;
|
||||
header->getField<vmime::headerField>(vmime::fields::MESSAGE_ID)
|
||||
->clone();
|
||||
|
||||
std::shared_ptr<vmime::headerField> backup_message_id_field =
|
||||
std::static_pointer_cast<vmime::headerField>(
|
||||
@ -255,9 +254,7 @@ auto EncryptEMLData(int channel, const QStringList& keys,
|
||||
plain_part_header->appendField(backup_subject_field);
|
||||
plain_part_header->appendField(backup_from_field);
|
||||
plain_part_header->appendField(backup_to_field);
|
||||
if (backup_message_id_field != nullptr) {
|
||||
plain_part_header->appendField(backup_message_id_field);
|
||||
}
|
||||
plain_part_header->appendField(backup_message_id_field);
|
||||
|
||||
auto plain_header_raw_data =
|
||||
Q_SC(plain_part_header->generate(vmime::lineLengthLimits::convenient));
|
||||
@ -268,21 +265,22 @@ auto EncryptEMLData(int channel, const QStringList& keys,
|
||||
plain_raw_data.replace("\r\n", "\n");
|
||||
plain_raw_data.replace("\n", "\r\n");
|
||||
|
||||
GFGpgEncryptionResult* s = nullptr;
|
||||
GFGpgEncryptionResult* enc_result = nullptr;
|
||||
auto ret = GFGpgEncryptData(channel, QListToCharArray(keys), keys.size(),
|
||||
QDUP(plain_raw_data), 1, &s);
|
||||
|
||||
auto encrypted_data = UDUP(s->encrypted_data);
|
||||
capsule_id = UDUP(s->capsule_id);
|
||||
auto gpg_error_string = UDUP(s->error_string);
|
||||
|
||||
GFFreeMemory(s);
|
||||
QDUP(plain_raw_data), 1, &enc_result);
|
||||
|
||||
if (ret != 0) {
|
||||
eml_data = "Encryption Failed: " + gpg_error_string;
|
||||
eml_data = "Encryption Failed";
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto encrypted_data = UDUP(enc_result->encrypted_data);
|
||||
|
||||
capsule_id = UDUP(enc_result->capsule_id);
|
||||
FLOG_DEBUG("got capsule id: %1", capsule_id);
|
||||
|
||||
GFFreeMemory(enc_result);
|
||||
|
||||
// no Content-Transfer-Encoding
|
||||
header->removeField(
|
||||
header->getField(vmime::fields::CONTENT_TRANSFER_ENCODING));
|
||||
@ -361,7 +359,7 @@ auto EncryptEMLData(int channel, const QStringList& keys,
|
||||
|
||||
} catch (const vmime::exception& e) {
|
||||
eml_data = QString("VMIME Error: %1").arg(e.what());
|
||||
return -2;
|
||||
return -1;
|
||||
}
|
||||
|
||||
eml_data = QString("Unknown Error: %1");
|
||||
@ -557,7 +555,7 @@ auto SignPlainText(int channel, const QString& key,
|
||||
auto mime_part_part_body = mime_part->getBody();
|
||||
auto mime_part_body_content =
|
||||
vmime::make_shared<vmime::stringContentHandler>();
|
||||
mime_part_body_content->setData(body_data.toStdString());
|
||||
mime_part_body_content->setData(body_data.toBase64().toStdString());
|
||||
mime_part_part_body->setContents(mime_part_body_content);
|
||||
|
||||
auto container_raw_data =
|
||||
@ -575,18 +573,19 @@ auto SignPlainText(int channel, const QString& key,
|
||||
auto ret = GFGpgSignData(channel, QListToCharArray({key}), 1,
|
||||
QDUP(container_raw_data), 1, 1, &s);
|
||||
|
||||
auto signature = UDUP(s->signature);
|
||||
auto hash_algo = UDUP(s->hash_algo);
|
||||
capsule_id = UDUP(s->capsule_id);
|
||||
auto gpg_error_string = UDUP(s->error_string);
|
||||
|
||||
GFFreeMemory(s);
|
||||
|
||||
if (ret != 0) {
|
||||
eml_data = "Sign Failed: " + gpg_error_string;
|
||||
eml_data = "Sign Failed";
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto signature = UDUP(s->signature);
|
||||
auto hash_algo = UDUP(s->hash_algo);
|
||||
|
||||
capsule_id = UDUP(s->capsule_id);
|
||||
FLOG_DEBUG("got capsule id: %1", capsule_id);
|
||||
|
||||
GFFreeMemory(s);
|
||||
|
||||
FLOG_DEBUG("Hash Algo: %1 Signature Data: %2", hash_algo, signature);
|
||||
content_type_header_field->appendParameter(
|
||||
vmime::make_shared<vmime::parameter>(
|
||||
@ -607,7 +606,7 @@ auto SignPlainText(int channel, const QString& key,
|
||||
|
||||
} catch (const vmime::exception& e) {
|
||||
eml_data = QString("VMIME Error: %1").arg(e.what());
|
||||
return -2;
|
||||
return -1;
|
||||
}
|
||||
|
||||
eml_data = QString("Unknown Error: %1");
|
||||
@ -665,10 +664,6 @@ auto SignEMLData(int channel, const QString& key,
|
||||
"application/pgp-signature"));
|
||||
content_type_header_field->setBoundary(body_boundary);
|
||||
|
||||
// update date field
|
||||
auto datetime_header_field = header->Date();
|
||||
datetime_header_field->setValue(vmime::datetime::now());
|
||||
|
||||
auto root_body_part = vmime::make_shared<vmime::body>();
|
||||
auto container_part = vmime::make_shared<vmime::bodyPart>();
|
||||
auto mime_part = vmime::make_shared<vmime::bodyPart>();
|
||||
@ -792,18 +787,19 @@ auto SignEMLData(int channel, const QString& key,
|
||||
auto ret = GFGpgSignData(channel, QListToCharArray({key}), 1,
|
||||
QDUP(container_raw_data), 1, 1, &s);
|
||||
|
||||
capsule_id = UDUP(s->capsule_id);
|
||||
auto signature = UDUP(s->signature);
|
||||
auto hash_algo = UDUP(s->hash_algo);
|
||||
auto gpg_error_string = UDUP(s->error_string);
|
||||
|
||||
GFFreeMemory(s);
|
||||
|
||||
if (ret != 0) {
|
||||
eml_data = "Sign Failed: " + gpg_error_string;
|
||||
eml_data = "Sign Failed";
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto signature = UDUP(s->signature);
|
||||
auto hash_algo = UDUP(s->hash_algo);
|
||||
|
||||
capsule_id = UDUP(s->capsule_id);
|
||||
FLOG_DEBUG("got capsule id: %1", capsule_id);
|
||||
|
||||
GFFreeMemory(s);
|
||||
|
||||
FLOG_DEBUG("Hash Algo: %1 Signature Data: %2", hash_algo, signature);
|
||||
content_type_header_field->appendParameter(
|
||||
vmime::make_shared<vmime::parameter>(
|
||||
@ -824,7 +820,7 @@ auto SignEMLData(int channel, const QString& key,
|
||||
|
||||
} catch (const vmime::exception& e) {
|
||||
eml_data = QString("VMIME Error: %1").arg(e.what());
|
||||
return -2;
|
||||
return -1;
|
||||
}
|
||||
|
||||
eml_data = QString("Unknown Error: %1");
|
||||
@ -1018,16 +1014,16 @@ auto VerifyEMLData(int channel, const QByteArray& data,
|
||||
auto ret = GFGpgVerifyData(channel, QDUP(part_mime_content_text),
|
||||
QDUP(part_sign_body_content), &s);
|
||||
|
||||
capsule_id = UDUP(s->capsule_id);
|
||||
auto gpg_error_string = UDUP(s->error_string);
|
||||
|
||||
GFFreeMemory(s);
|
||||
|
||||
if (ret != 0) {
|
||||
error_string = "Verify Failed: " + gpg_error_string;
|
||||
error_string = "Verify Failed";
|
||||
return -1;
|
||||
}
|
||||
|
||||
capsule_id = UDUP(s->capsule_id);
|
||||
FLOG_DEBUG("got capsule id: %1", capsule_id);
|
||||
|
||||
GFFreeMemory(s);
|
||||
|
||||
meta_data.from = from_field_value_text;
|
||||
meta_data.to = to_field_value_text.split(',');
|
||||
meta_data.cc = cc_field_value_text.split(',');
|
||||
@ -1189,17 +1185,18 @@ auto DecryptEMLData(int channel, const QByteArray& data,
|
||||
GFGpgDecryptResult* s;
|
||||
auto ret = GFGpgDecryptData(channel, QDUP(part_encr_body_content), &s);
|
||||
|
||||
eml_data = UDUP(s->decrypted_data);
|
||||
capsule_id = UDUP(s->capsule_id);
|
||||
auto gpg_error_string = UDUP(s->error_string);
|
||||
|
||||
GFFreeMemory(s);
|
||||
|
||||
if (ret != 0) {
|
||||
eml_data = "Decrypt Failed: " + gpg_error_string;
|
||||
eml_data = "Ddecrypt Failed";
|
||||
return -1;
|
||||
}
|
||||
|
||||
eml_data = UDUP(s->decrypted_data);
|
||||
|
||||
capsule_id = UDUP(s->capsule_id);
|
||||
FLOG_DEBUG("got capsule id: %1", capsule_id);
|
||||
|
||||
GFFreeMemory(s);
|
||||
|
||||
// callback
|
||||
meta_data.from = from_field_value_text;
|
||||
meta_data.to = to_field_value_text.split(',');
|
||||
|
@ -48,11 +48,11 @@
|
||||
|
||||
GF_MODULE_API_DEFINE("com.bktus.gpgfrontend.module.gnupg_info_gathering",
|
||||
"GatherGnupgInfo", "1.0.1",
|
||||
"Try gathering gnupg information.", "Saturneric")
|
||||
"Try gathering gnupg informations.", "Saturneric")
|
||||
|
||||
DEFINE_TRANSLATIONS_STRUCTURE(ModuleGnuPGInfoGathering);
|
||||
|
||||
extern auto CalculateBinaryChecksum(const QString &path)
|
||||
extern auto CalculateBinaryChacksum(const QString &path)
|
||||
-> std::optional<QString>;
|
||||
|
||||
extern void GetGpgComponentInfos(void *, int, const char *, const char *);
|
||||
@ -186,7 +186,7 @@ auto StartGatheringGnuPGInfo() -> int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto CalculateBinaryChecksum(const QString &path) -> std::optional<QString> {
|
||||
auto CalculateBinaryChacksum(const QString &path) -> std::optional<QString> {
|
||||
// check file info and access rights
|
||||
QFileInfo const info(path);
|
||||
if (!info.exists() || !info.isFile() || !info.isReadable()) {
|
||||
@ -258,7 +258,7 @@ void GetGpgComponentInfos(void *data, int exit_code, const char *out,
|
||||
c_i_gpgconf.desc = "GPG Configure";
|
||||
c_i_gpgconf.version = "/";
|
||||
c_i_gpgconf.path = context->gpgconf_path;
|
||||
auto gpgconf_binary_checksum = CalculateBinaryChecksum(context->gpgconf_path);
|
||||
auto gpgconf_binary_checksum = CalculateBinaryChacksum(context->gpgconf_path);
|
||||
c_i_gpgconf.binary_checksum =
|
||||
(gpgconf_binary_checksum.has_value() ? gpgconf_binary_checksum.value()
|
||||
: QString("/"));
|
||||
@ -292,7 +292,7 @@ void GetGpgComponentInfos(void *data, int exit_code, const char *out,
|
||||
component_path.replace("%3a", ":");
|
||||
#endif
|
||||
|
||||
auto binary_checksum = CalculateBinaryChecksum(component_path);
|
||||
auto binary_checksum = CalculateBinaryChacksum(component_path);
|
||||
|
||||
MLogDebug(
|
||||
QString("gnupg component name: %1 desc: %2 checksum: %3 path: %4")
|
||||
|
Loading…
x
Reference in New Issue
Block a user