Changeset View
Changeset View
Standalone View
Standalone View
src/ui/cryptoconfigmodule.cpp
| Show First 20 Lines • Show All 222 Lines • ▼ Show 20 Line(s) | 218 | const QString msg = i18n("The gpgconf tool used to provide the information " | |||
|---|---|---|---|---|---|
| 223 | components.empty() ? QLatin1String("gpgconf --list-components") : QLatin1String("gpgconf --list-options gpg")); | 223 | components.empty() ? QLatin1String("gpgconf --list-components") : QLatin1String("gpgconf --list-options gpg")); | ||
| 224 | QLabel *label = new QLabel(msg, vbox); | 224 | QLabel *label = new QLabel(msg, vbox); | ||
| 225 | label->setWordWrap(true); | 225 | label->setWordWrap(true); | ||
| 226 | label->setMinimumHeight(fontMetrics().lineSpacing() * 5); | 226 | label->setMinimumHeight(fontMetrics().lineSpacing() * 5); | ||
| 227 | vlay->addWidget(label); | 227 | vlay->addWidget(label); | ||
| 228 | } | 228 | } | ||
| 229 | } | 229 | } | ||
| 230 | 230 | | |||
| 231 | QStringList Kleo::CryptoConfigModule::sortComponentList(const QStringList &components) | 231 | QStringList Kleo::CryptoConfigModule::sortConfigEntries(const QString *orderBegin, const QString *orderEnd, const QStringList &entries) | ||
| 232 | { | 232 | { | ||
| 233 | // components sorting algorithm: | 233 | // components sorting algorithm: | ||
| 234 | // 1. components with hardcoded order - see below | 234 | // 1. components with predefined order (provided via orderBegin / orderEnd) | ||
| 235 | // 2. other components sorted alphabetically | 235 | // 2. other components sorted alphabetically | ||
| 236 | static const std::array<QString, 6> order = { | | |||
| 237 | QStringLiteral("gpg"), | | |||
| 238 | QStringLiteral("gpgsm"), | | |||
| 239 | QStringLiteral("gpg-agent"), | | |||
| 240 | QStringLiteral("dirmngr"), | | |||
| 241 | QStringLiteral("pinentry"), | | |||
| 242 | QStringLiteral("scdaemon") | | |||
| 243 | }; | | |||
| 244 | | ||||
| 245 | QStringList result, others; | 236 | QStringList result, others; | ||
| 246 | for (const auto &item : order) { | 237 | for (auto it = orderBegin; it != orderEnd; ++it) { | ||
| 247 | if (components.contains(item)) { | 238 | if (entries.contains(*it)) { | ||
| 248 | result.append(item); | 239 | result.append(*it); | ||
| 249 | } | 240 | } | ||
| 250 | } | 241 | } | ||
| 251 | for (const auto &item : components) { | 242 | for (const auto &item : entries) { | ||
| 252 | if (!result.contains(item)) { | 243 | if (!result.contains(item)) { | ||
| 253 | others.append(item); | 244 | others.append(item); | ||
| 254 | } | 245 | } | ||
| 255 | } | 246 | } | ||
| 256 | others.sort(); | 247 | others.sort(); | ||
| 257 | result.append(others); | 248 | result.append(others); | ||
| 258 | return result; | 249 | return result; | ||
| 259 | } | 250 | } | ||
| 260 | 251 | | |||
| 252 | QStringList Kleo::CryptoConfigModule::sortComponentList(const QStringList &components) | ||||
| 253 | { | ||||
| 254 | static const std::array<QString, 6> order = { | ||||
| 255 | QStringLiteral("gpg"), | ||||
| 256 | QStringLiteral("gpgsm"), | ||||
| 257 | QStringLiteral("gpg-agent"), | ||||
| 258 | QStringLiteral("dirmngr"), | ||||
| 259 | QStringLiteral("pinentry"), | ||||
| 260 | QStringLiteral("scdaemon") | ||||
| 261 | }; | ||||
| 262 | return sortConfigEntries(order.begin(), order.end(), components); | ||||
| 263 | } | ||||
| 264 | | ||||
| 265 | QStringList Kleo::CryptoConfigModule::sortGroupList(const QString &moduleName, const QStringList &groups) | ||||
| 266 | { | ||||
| 267 | if (moduleName == QStringLiteral("gpg")) { | ||||
| 268 | static const std::array<QString, 4> order = { | ||||
| 269 | QStringLiteral("Keyserver"), | ||||
| 270 | QStringLiteral("Configuration"), | ||||
| 271 | QStringLiteral("Monitor"), | ||||
| 272 | QStringLiteral("Debug"), | ||||
| 273 | }; | ||||
| 274 | return sortConfigEntries(order.begin(), order.end(), groups); | ||||
| 275 | } else if (moduleName == QStringLiteral("gpgsm")) { | ||||
| 276 | static const std::array<QString, 4> order = { | ||||
| 277 | QStringLiteral("Security"), | ||||
| 278 | QStringLiteral("Configuration"), | ||||
| 279 | QStringLiteral("Monitor"), | ||||
| 280 | QStringLiteral("Debug"), | ||||
| 281 | }; | ||||
| 282 | return sortConfigEntries(order.begin(), order.end(), groups); | ||||
| 283 | } else if (moduleName == QStringLiteral("gpg-agent")) { | ||||
| 284 | static const std::array<QString, 5> order = { | ||||
| 285 | QStringLiteral("Security"), | ||||
| 286 | QStringLiteral("Passphrase policy"), | ||||
| 287 | QStringLiteral("Configuration"), | ||||
| 288 | QStringLiteral("Monitor"), | ||||
| 289 | QStringLiteral("Debug"), | ||||
| 290 | }; | ||||
| 291 | return sortConfigEntries(order.begin(), order.end(), groups); | ||||
| 292 | } else if (moduleName == QStringLiteral("dirmngr")) { | ||||
| 293 | static const std::array<QString, 10> order = { | ||||
| 294 | QStringLiteral("Keyserver"), | ||||
| 295 | QStringLiteral("HTTP"), | ||||
| 296 | QStringLiteral("LDAP"), | ||||
| 297 | QStringLiteral("OCSP"), | ||||
| 298 | QStringLiteral("Tor"), | ||||
| 299 | QStringLiteral("Enforcement"), | ||||
| 300 | QStringLiteral("Configuration"), | ||||
| 301 | QStringLiteral("Format"), | ||||
| 302 | QStringLiteral("Monitor"), | ||||
| 303 | QStringLiteral("Debug"), | ||||
| 304 | }; | ||||
| 305 | return sortConfigEntries(order.begin(), order.end(), groups); | ||||
| 306 | } else if (moduleName == QStringLiteral("scdaemon")) { | ||||
| 307 | static const std::array<QString, 4> order = { | ||||
| 308 | QStringLiteral("Monitor"), | ||||
| 309 | QStringLiteral("Configuration"), | ||||
| 310 | QStringLiteral("Security"), | ||||
| 311 | QStringLiteral("Debug"), | ||||
| 312 | }; | ||||
| 313 | return sortConfigEntries(order.begin(), order.end(), groups); | ||||
| 314 | } else { | ||||
| 315 | qCDebug(KLEO_UI_LOG) << "Configuration groups order is not defined for " << moduleName; | ||||
| 316 | QStringList result(groups); | ||||
| 317 | result.sort(); | ||||
| 318 | return result; | ||||
| 319 | } | ||||
| 320 | } | ||||
| 321 | | ||||
| 261 | bool Kleo::CryptoConfigModule::hasError() const | 322 | bool Kleo::CryptoConfigModule::hasError() const | ||
| 262 | { | 323 | { | ||
| 263 | return mComponentGUIs.empty(); | 324 | return mComponentGUIs.empty(); | ||
| 264 | } | 325 | } | ||
| 265 | 326 | | |||
| 266 | void Kleo::CryptoConfigModule::save() | 327 | void Kleo::CryptoConfigModule::save() | ||
| 267 | { | 328 | { | ||
| 268 | bool changed = false; | 329 | bool changed = false; | ||
| Show All 33 Lines | |||||
| 302 | 363 | | |||
| 303 | Kleo::CryptoConfigComponentGUI::CryptoConfigComponentGUI( | 364 | Kleo::CryptoConfigComponentGUI::CryptoConfigComponentGUI( | ||
| 304 | CryptoConfigModule *module, QGpgME::CryptoConfigComponent *component, | 365 | CryptoConfigModule *module, QGpgME::CryptoConfigComponent *component, | ||
| 305 | QWidget *parent) | 366 | QWidget *parent) | ||
| 306 | : QWidget(parent), | 367 | : QWidget(parent), | ||
| 307 | mComponent(component) | 368 | mComponent(component) | ||
| 308 | { | 369 | { | ||
| 309 | QGridLayout *glay = new QGridLayout(this); | 370 | QGridLayout *glay = new QGridLayout(this); | ||
| 310 | const QStringList groups = mComponent->groupList(); | 371 | const QStringList groups = module->sortGroupList(mComponent->name(), mComponent->groupList()); | ||
| 311 | if (groups.size() > 1) { | 372 | if (groups.size() > 1) { | ||
| 312 | glay->setColumnMinimumWidth(0, KDHorizontalLine::indentHint()); | 373 | glay->setColumnMinimumWidth(0, KDHorizontalLine::indentHint()); | ||
| 313 | for (QStringList::const_iterator it = groups.begin(), end = groups.end(); it != end; ++it) { | 374 | for (QStringList::const_iterator it = groups.begin(), end = groups.end(); it != end; ++it) { | ||
| 314 | QGpgME::CryptoConfigGroup *group = mComponent->group(*it); | 375 | QGpgME::CryptoConfigGroup *group = mComponent->group(*it); | ||
| 315 | Q_ASSERT(group); | 376 | Q_ASSERT(group); | ||
| 316 | if (!group) { | 377 | if (!group) { | ||
| 317 | continue; | 378 | continue; | ||
| 318 | } | 379 | } | ||
| ▲ Show 20 Lines • Show All 691 Lines • Show Last 20 Lines | |||||