~ubuntu-branches/ubuntu/wily/kwallet-kf5/wily

« back to all changes in this revision

Viewing changes to debian/patches/upstream_Stop-showing-the-migration-wizard-by-default.patch

  • Committer: Package Import Robot
  • Author(s): Harald Sitter
  • Date: 2015-08-24 13:00:08 UTC
  • Revision ID: package-import@ubuntu.com-20150824130008-b3ry0fndlo2iqnbq
Tags: 5.13.0-0ubuntu2
Add upstream_Stop-showing-the-migration-wizard-by-default.patch to disable
the migration wizard dialog. Migration is in fact a non-destructive
import, so it can savely be run without any user input. This prevents
contextless kwallet dialogs on first login as well as first kwallet5
enabled logins (prequisite for pam unlocking experience)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
5
 
 
6
BUG:351056
 
7
 
 
8
If the migration wizard is needed, then add this to kwalletrc
 
9
[Migration]
 
10
showMigrationWizard=true
 
11
 
 
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.
 
15
---
 
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(-)
 
21
 
 
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");
 
28
 
 
29
     KWalletD walletd;
 
30
-    MigrationAgent migrationAgent(&walletd);
 
31
+    MigrationAgent migrationAgent(&walletd, hash);
 
32
     KDBusService dbusUniqueInstance(KDBusService::Unique | KDBusService::NoExitOnFailure);
 
33
 
 
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
 
39
@@ -34,10 +34,12 @@
 
40
 
 
41
 #define SERVICE_KWALLETD4 "org.kde.kwalletd"
 
42
 #define ENTRY_ALREADY_MIGRATED "alreadyMigrated"
 
43
+#define ENTRY_SHOW_MIGRATION_WIZARD "showMigrationWizard"
 
44
 
 
45
-MigrationAgent::MigrationAgent(KWalletD* kd) :
 
46
+MigrationAgent::MigrationAgent(KWalletD* kd, const char *hash) :
 
47
   _kf5_daemon(kd)
 
48
   , _kde4_daemon(0)
 
49
+  , _pam_hash(hash)
 
50
 {
 
51
   QTimer::singleShot(100, this, SLOT(migrateWallets()));
 
52
 }
 
53
@@ -118,11 +120,27 @@ bool MigrationAgent::isMigrationWizardOk()
 
54
 {
 
55
     bool ok = false;
 
56
 
 
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
 
61
-        ok = true;
 
62
+    // The migration wizard would no longer been shown by default.
 
63
+    // see BUG 351056
 
64
+    // NOTE if user wants to show the migration wizard, then he should add the
 
65
+    // following setting to the kwalletrc:
 
66
+    // [Migration]
 
67
+    // showMigrationWizard=true
 
68
+    KConfig kwalletrc("kwalletrc");
 
69
+    KConfigGroup cfg(&kwalletrc, "Migration");
 
70
+    bool showMigrationWizard = cfg.readEntry<bool>(ENTRY_SHOW_MIGRATION_WIZARD, false);
 
71
+
 
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
 
77
+            ok = true;
 
78
+        }
 
79
+    } else {
 
80
+        if (performMigration(0, true)) {
 
81
+            qDebug() << "Migration failed.";
 
82
+        }
 
83
     }
 
84
 
 
85
     return ok;
 
86
@@ -162,7 +180,7 @@ bool MigrationAgent::isEmptyOldWallet() const {
 
87
     return wallets.length() == 0;
 
88
 }
 
89
 
 
90
-bool MigrationAgent::performMigration(WId wid)
 
91
+bool MigrationAgent::performMigration(WId wid, bool withoutWizard)
 
92
 {
 
93
     auto appId = i18n("KDE Wallet Migration Agent");
 
94
     try {
 
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));
 
98
 
 
99
-            int handle5 = _kf5_daemon->internalOpen(appId, wallet, false, 0, true, QString());
 
100
+            int handle5 = -1;
 
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);
 
106
+            } else {
 
107
+                handle5 = _kf5_daemon->internalOpen(appId, wallet, false, 0, true, QString());
 
108
+            }
 
109
             if (handle5 <0) {
 
110
                 emit progressMessage(i18n("ERROR when attempting new wallet creation. Aborting."));
 
111
                 return false;
 
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 {
 
118
     Q_OBJECT
 
119
 public:
 
120
-    MigrationAgent(KWalletD* kd);
 
121
+    MigrationAgent(KWalletD* kd, const char* hash);
 
122
 
 
123
     bool isEmptyOldWallet() const;
 
124
-    bool performMigration(WId wid);
 
125
+    bool performMigration(WId wid, bool withoutWizard);
 
126
 
 
127
 private Q_SLOTS:
 
128
     void migrateWallets();
 
129
@@ -52,6 +52,7 @@ Q_SIGNALS:
 
130
 private:
 
131
     KWalletD           *_kf5_daemon;
 
132
     org::kde::KWallet  *_kde4_daemon;
 
133
+    const char  *_pam_hash;
 
134
 };
 
135
 
 
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:
 
142
 
 
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();
 
148
     }
 
149
 
 
150
-- 
 
151
2.1.4
 
152