diff --git a/GpgMEWorker.cpp b/GpgMEWorker.cpp index 20f4aa9..038970d 100644 --- a/GpgMEWorker.cpp +++ b/GpgMEWorker.cpp @@ -17,9 +17,11 @@ using namespace std; -#define SPACE " " -#define LESSTHAN "<" -#define MORETHAN ">" +#define SPACE string(" ") +#define LESSTHAN string("<") +#define MORETHAN string(">") +#define LEFT_PARENTHESIS string("(") +#define RIGHT_PARENTHESIS string(")") // From gpgme.h (C API), don't want to include it here for one const. #define _CREATE_NOEXPIRE (1 << 13) @@ -187,10 +189,7 @@ const Error GpgMEWorker::CreateKeyWithEngineDefaultAlgo(GpgME::Key& k, ctx->setPinentryMode(Context::PinentryMode::PinentryLoopback); ctx->setPassphraseProvider(ppp); - string uid = name + SPACE - + LESSTHAN + email + MORETHAN; - if (!comment.empty()) - uid += SPACE + comment; + const string uid =MakeUidString(name, email, comment); uint flags = expires ? 0 : _CREATE_NOEXPIRE; @@ -218,10 +217,7 @@ const Error GpgMEWorker::CreateKey(GpgME::Key& k, ctx->setPinentryMode(Context::PinentryMode::PinentryLoopback); ctx->setPassphraseProvider(ppp); - string uid = name + SPACE - + LESSTHAN + email + MORETHAN; - if (!comment.empty()) - uid += SPACE + comment; + const string uid = MakeUidString(name, email, comment); uint flags = expires ? 0 : _CREATE_NOEXPIRE; @@ -295,3 +291,12 @@ const Error GpgMEWorker::ExportPublicKey(const char* pattern, string& buffer) return e; } + +string GpgMEWorker::MakeUidString(const string& name, const string& email, const string& comment) +{ + string uid = name + SPACE + + LESSTHAN + email + MORETHAN; + if (!comment.empty()) + uid += SPACE + LEFT_PARENTHESIS + comment + RIGHT_PARENTHESIS; + return uid; +} diff --git a/GpgMEWorker.h b/GpgMEWorker.h index 31b6535..3778dc2 100644 --- a/GpgMEWorker.h +++ b/GpgMEWorker.h @@ -159,6 +159,9 @@ private: Context * m_ctx; // GPG will fetch a password here. LoopbackPassphraseProvider * m_ppp; + + string MakeUidString(const string& name, const string& email, + const string& comment); }; /** diff --git a/K7Main.cpp b/K7Main.cpp index e0ef1e1..ec892b5 100644 --- a/K7Main.cpp +++ b/K7Main.cpp @@ -332,7 +332,7 @@ void K7Main::DisplayUids(const WString& fullKeyID, bool secret) if (m_ttbUids->columnCount() == 1) { m_ttbUids->addColumn(TR("Email"), 200); - m_ttbUids->addColumn(TR("Trust"), 100); + m_ttbUids->addColumn(TR("Trust"), 110); m_ttbUids->addColumn(TR("Comment"), 300); } WTreeTableNode * rootNode = new WTreeTableNode(fullKeyID);