aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Klöcker <[email protected]>2021-03-04 16:35:57 +0000
committerIngo Klöcker <[email protected]>2021-03-05 08:24:01 +0000
commitfe900a41bf809b263f05d5df21b6ed7fbfb2bbbc (patch)
tree77f45fcf75da2fdcf7ffabbd5695fd39a4328b5f
parentcore: Remove experimental feature GPGME_EXPORT_MODE_NOUID. (diff)
downloadgpgme-fe900a41bf809b263f05d5df21b6ed7fbfb2bbbc.tar.gz
gpgme-fe900a41bf809b263f05d5df21b6ed7fbfb2bbbc.zip
qt: Add method for getting config entries for components by entry name
* lang/qt/src/cryptoconfig.h, lang/qt/src/cryptoconfig.cpp (CryptoConfig::entry): Move implementation to cpp. Add overload not requiring a group name. -- The group name is not needed for identifying a config entry because the groups only provide a logical grouping of config entry for user interfaces. To improve usability entries are sometimes moved to a different group, but this shouldn't break existing applications trying to access those entries. The new group-agnostic overload makes applications robust against regrouping of config entries. GnuPG-bug-id: 5217
-rw-r--r--NEWS4
-rw-r--r--lang/qt/src/cryptoconfig.cpp20
-rw-r--r--lang/qt/src/cryptoconfig.h22
3 files changed, 39 insertions, 7 deletions
diff --git a/NEWS b/NEWS
index b6c994cd..3a4065f2 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ Noteworthy changes in version 1.15.2 (unreleased)
-------------------------------------------------
+ * Interface changes relative to the 1.15.1 release:
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ qt: CryptoConfig::entry CHANGED: Added overload; deprecated old
+
Noteworthy changes in version 1.15.1 (2021-01-08)
-------------------------------------------------
diff --git a/lang/qt/src/cryptoconfig.cpp b/lang/qt/src/cryptoconfig.cpp
index 71212200..d52dce73 100644
--- a/lang/qt/src/cryptoconfig.cpp
+++ b/lang/qt/src/cryptoconfig.cpp
@@ -43,3 +43,23 @@ QStringList CryptoConfigEntry::stringValueList() const
}
return entry->stringValueList();
}
+
+QGpgME::CryptoConfigEntry *CryptoConfig::entry(const QString &componentName, const QString &entryName) const
+{
+ const CryptoConfigComponent *comp = component(componentName);
+ const QStringList groupNames = comp->groupList();
+ for (const auto &groupName : groupNames) {
+ const CryptoConfigGroup *group = comp ? comp->group(groupName) : nullptr;
+ if (CryptoConfigEntry *entry = group->entry(entryName)) {
+ return entry;
+ }
+ }
+ return nullptr;
+}
+
+QGpgME::CryptoConfigEntry *CryptoConfig::entry(const QString &componentName, const QString &groupName, const QString &entryName) const
+{
+ const CryptoConfigComponent *comp = component(componentName);
+ const CryptoConfigGroup *group = comp ? comp->group(groupName) : nullptr;
+ return group ? group->entry(entryName) : nullptr;
+}
diff --git a/lang/qt/src/cryptoconfig.h b/lang/qt/src/cryptoconfig.h
index d7aae9d7..651e2af1 100644
--- a/lang/qt/src/cryptoconfig.h
+++ b/lang/qt/src/cryptoconfig.h
@@ -373,18 +373,26 @@ public:
/**
* Convenience method to get hold of a single configuration entry when
- * its component, group and name are known. This can be used to read
+ * its component and name are known. This can be used to read
* the value and/or to set a value to it.
*
* @return the configuration object for a single configuration entry, 0 if not found.
* The object is owned by CryptoConfig, don't delete it.
*/
- CryptoConfigEntry *entry(const QString &componentName, const QString &groupName, const QString &entryName) const
- {
- const QGpgME::CryptoConfigComponent *comp = component(componentName);
- const QGpgME::CryptoConfigGroup *group = comp ? comp->group(groupName) : nullptr;
- return group ? group->entry(entryName) : nullptr;
- }
+ CryptoConfigEntry *entry(const QString &componentName, const QString &entryName) const;
+
+ /**
+ * This function is obsolete. It is provided to keep old source code working.
+ * We strongly advise against using it in new code.
+ *
+ * This function overloads @ref entry().
+ *
+ * Use the entry overload that does not require a group name instead. The group name
+ * is not needed to identify a configuration entry because it only provides logical
+ * grouping for user interfaces. Sometimes configuration entries are moved to different
+ * groups to improve usability.
+ */
+ QGPGME_DEPRECATED CryptoConfigEntry *entry(const QString &componentName, const QString &groupName, const QString &entryName) const;
/**
* Write back changes