aboutsummaryrefslogtreecommitdiffstats
path: root/src/m_email/EMAilHelper.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-11-28 08:25:22 +0000
committersaturneric <[email protected]>2024-11-28 08:25:22 +0000
commit22558e2948065c771023e90b4adf86b31a959e50 (patch)
tree77678968f50756a2a2a6ae7d85621ffe1e868f49 /src/m_email/EMAilHelper.cpp
parentfeat: support email encryption (diff)
downloadModules-22558e2948065c771023e90b4adf86b31a959e50.tar.gz
Modules-22558e2948065c771023e90b4adf86b31a959e50.zip
refactor: improve code structure
Diffstat (limited to 'src/m_email/EMAilHelper.cpp')
-rw-r--r--src/m_email/EMAilHelper.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/m_email/EMAilHelper.cpp b/src/m_email/EMAilHelper.cpp
index ff544ab..7d19dad 100644
--- a/src/m_email/EMAilHelper.cpp
+++ b/src/m_email/EMAilHelper.cpp
@@ -32,6 +32,9 @@
#include "GFModuleCommonUtils.hpp"
+static const QRegularExpression kNameEmailStringRegex{
+ R"(^\s*(.*)\s*<\s*([^<>@\s]+@[^<>@\s]+)\s*>\s*$)"};
+
auto IsValidMicalgFormat(const QString& prm_micalg_value) -> bool {
QRegularExpression regex("^pgp-(\\w+)$");
QRegularExpressionMatch match = regex.match(prm_micalg_value);
@@ -152,3 +155,16 @@ auto ExtractFieldValueDateTime(const vmime::shared_ptr<vmime::header>& header,
return datetime;
}
+
+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;
+} \ No newline at end of file