1
From 127efedd1668b546d0ac8c83655a2056d0439f29 Mon Sep 17 00:00:00 2001
2
From: Valentin Rusu <kde@rusu.info>
3
Date: Fri, 7 Aug 2015 18:59:04 +0200
4
Subject: [PATCH] Stop showing the migration wizard by default
8
If the migration wizard is needed, then add this to kwalletrc
10
showMigrationWizard=true
12
On systems having kwallet-pam the migration agent would also merge all the old
13
wallets into the default LocalWallet, as a side effect. This would avoid
14
wallet creation prompts, though.
16
src/runtime/kwalletd/main.cpp | 2 +-
17
src/runtime/kwalletd/migrationagent.cpp | 42 ++++++++++++++++++++++++++------
18
src/runtime/kwalletd/migrationagent.h | 5 ++--
19
src/runtime/kwalletd/migrationwizard.cpp | 2 +-
20
4 files changed, 39 insertions(+), 12 deletions(-)
22
diff --git a/src/runtime/kwalletd/main.cpp b/src/runtime/kwalletd/main.cpp
23
index c0fecaa..62fcd3a 100644
24
--- a/src/runtime/kwalletd/main.cpp
25
+++ b/src/runtime/kwalletd/main.cpp
26
@@ -186,7 +186,7 @@ int main(int argc, char **argv)
27
aboutdata.addAuthor(i18n("Thiago Maceira"), i18n("D-Bus Interface"), "thiago@kde.org");
30
- MigrationAgent migrationAgent(&walletd);
31
+ MigrationAgent migrationAgent(&walletd, hash);
32
KDBusService dbusUniqueInstance(KDBusService::Unique | KDBusService::NoExitOnFailure);
34
// NOTE: the command should be parsed only after KDBusService instantiation
35
diff --git a/src/runtime/kwalletd/migrationagent.cpp b/src/runtime/kwalletd/migrationagent.cpp
36
index 6eaeb12..192a871 100644
37
--- a/src/runtime/kwalletd/migrationagent.cpp
38
+++ b/src/runtime/kwalletd/migrationagent.cpp
41
#define SERVICE_KWALLETD4 "org.kde.kwalletd"
42
#define ENTRY_ALREADY_MIGRATED "alreadyMigrated"
43
+#define ENTRY_SHOW_MIGRATION_WIZARD "showMigrationWizard"
45
-MigrationAgent::MigrationAgent(KWalletD* kd) :
46
+MigrationAgent::MigrationAgent(KWalletD* kd, const char *hash) :
51
QTimer::singleShot(100, this, SLOT(migrateWallets()));
53
@@ -118,11 +120,27 @@ bool MigrationAgent::isMigrationWizardOk()
57
- MigrationWizard *wizard = new MigrationWizard(this);
58
- int result = wizard->exec();
59
- if (QDialog::Accepted == result) {
60
- // the user either migrated the wallets, or choose not to be prompted again
62
+ // The migration wizard would no longer been shown by default.
64
+ // NOTE if user wants to show the migration wizard, then he should add the
65
+ // following setting to the kwalletrc:
67
+ // showMigrationWizard=true
68
+ KConfig kwalletrc("kwalletrc");
69
+ KConfigGroup cfg(&kwalletrc, "Migration");
70
+ bool showMigrationWizard = cfg.readEntry<bool>(ENTRY_SHOW_MIGRATION_WIZARD, false);
72
+ if (showMigrationWizard) {
73
+ MigrationWizard *wizard = new MigrationWizard(this);
74
+ int result = wizard->exec();
75
+ if (QDialog::Accepted == result) {
76
+ // the user either migrated the wallets, or choose not to be prompted again
80
+ if (performMigration(0, true)) {
81
+ qDebug() << "Migration failed.";
86
@@ -162,7 +180,7 @@ bool MigrationAgent::isEmptyOldWallet() const {
87
return wallets.length() == 0;
90
-bool MigrationAgent::performMigration(WId wid)
91
+bool MigrationAgent::performMigration(WId wid, bool withoutWizard)
93
auto appId = i18n("KDE Wallet Migration Agent");
95
@@ -174,7 +192,15 @@ bool MigrationAgent::performMigration(WId wid)
96
emit progressMessage(i18n("Migrating wallet: %1", wallet));
97
emit progressMessage(i18n("* Creating KF5 wallet: %1", wallet));
99
- int handle5 = _kf5_daemon->internalOpen(appId, wallet, false, 0, true, QString());
101
+ if (withoutWizard && (_pam_hash != nullptr)) {
102
+ // see BUG 351056 for why this hacky code
103
+ // If the user has several wallets, all the values will be
104
+ // merged into the single LocalWallet
105
+ handle5 = _kf5_daemon->pamOpen(KWallet::Wallet::LocalWallet(), _pam_hash, 0);
107
+ handle5 = _kf5_daemon->internalOpen(appId, wallet, false, 0, true, QString());
110
emit progressMessage(i18n("ERROR when attempting new wallet creation. Aborting."));
112
diff --git a/src/runtime/kwalletd/migrationagent.h b/src/runtime/kwalletd/migrationagent.h
113
index 55a251d..c52509e 100644
114
--- a/src/runtime/kwalletd/migrationagent.h
115
+++ b/src/runtime/kwalletd/migrationagent.h
116
@@ -32,10 +32,10 @@ class KWalletD;
117
class MigrationAgent : public QObject {
120
- MigrationAgent(KWalletD* kd);
121
+ MigrationAgent(KWalletD* kd, const char* hash);
123
bool isEmptyOldWallet() const;
124
- bool performMigration(WId wid);
125
+ bool performMigration(WId wid, bool withoutWizard);
128
void migrateWallets();
129
@@ -52,6 +52,7 @@ Q_SIGNALS:
131
KWalletD *_kf5_daemon;
132
org::kde::KWallet *_kde4_daemon;
133
+ const char *_pam_hash;
136
#endif // _MIGRATIONAGENT_H_
137
diff --git a/src/runtime/kwalletd/migrationwizard.cpp b/src/runtime/kwalletd/migrationwizard.cpp
138
index b7d3f70..cdd2a92 100644
139
--- a/src/runtime/kwalletd/migrationwizard.cpp
140
+++ b/src/runtime/kwalletd/migrationwizard.cpp
141
@@ -58,7 +58,7 @@ public:
143
virtual void initializePage() {
144
connect(_agent, SIGNAL(progressMessage(QString)), _ui._report, SLOT(append(QString)));
145
- _migrationCompleted = _agent->performMigration(winId());
146
+ _migrationCompleted = _agent->performMigration(winId(), false);
147
emit completeChanged();