diff options
-rw-r--r-- | accounts/maildir/package/metadata.desktop | 1 | ||||
-rw-r--r-- | components/kube/contents/ui/Kube.qml | 55 | ||||
-rw-r--r-- | framework/src/accounts/accountfactory.cpp | 2 | ||||
-rw-r--r-- | framework/src/accounts/accountfactory.h | 2 | ||||
-rw-r--r-- | framework/src/keyring.h | 2 |
5 files changed, 40 insertions, 22 deletions
diff --git a/accounts/maildir/package/metadata.desktop b/accounts/maildir/package/metadata.desktop index 1e127fe1..ce922455 100644 --- a/accounts/maildir/package/metadata.desktop +++ b/accounts/maildir/package/metadata.desktop | |||
@@ -6,3 +6,4 @@ X-Plasma-MainScript=ui/MaildirAccountSettings.qml | |||
6 | X-KDE-ServiceTypes=KPackage/GenericQML | 6 | X-KDE-ServiceTypes=KPackage/GenericQML |
7 | Icon=folder | 7 | Icon=folder |
8 | Type=Service | 8 | Type=Service |
9 | X-KDE-Kube-RequiresKeyring=False | ||
diff --git a/components/kube/contents/ui/Kube.qml b/components/kube/contents/ui/Kube.qml index ccbec2da..c5726eff 100644 --- a/components/kube/contents/ui/Kube.qml +++ b/components/kube/contents/ui/Kube.qml | |||
@@ -50,6 +50,11 @@ Controls2.ApplicationWindow { | |||
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | Kube.AccountFactory { | ||
54 | id: accountFactory | ||
55 | accountId: app.currentAccount | ||
56 | } | ||
57 | |||
53 | //Interval sync | 58 | //Interval sync |
54 | Timer { | 59 | Timer { |
55 | id: intervalSync | 60 | id: intervalSync |
@@ -251,12 +256,39 @@ Controls2.ApplicationWindow { | |||
251 | } | 256 | } |
252 | Layout.fillWidth: true | 257 | Layout.fillWidth: true |
253 | 258 | ||
259 | function loginIfNecessary() | ||
260 | { | ||
261 | if (!!app.currentAccount && !Kube.Keyring.isUnlocked(app.currentAccount)) { | ||
262 | if (accountFactory.requiresKeyring) { | ||
263 | setLoginView() | ||
264 | } else { | ||
265 | Kube.Keyring.unlock(app.currentAccount) | ||
266 | } | ||
267 | } | ||
268 | } | ||
269 | |||
254 | Kube.Listener { | 270 | Kube.Listener { |
255 | filter: Kube.Messages.componentDone | 271 | filter: Kube.Messages.componentDone |
256 | onMessageReceived: { | 272 | onMessageReceived: { |
257 | kubeViews.pop(Controls2.StackView.Immediate) | 273 | kubeViews.pop(Controls2.StackView.Immediate) |
258 | if (!!app.currentAccount && !Kube.Keyring.isUnlocked(app.currentAccount)) { | 274 | loginIfNecessary() |
259 | kubeViews.setLoginView() | 275 | } |
276 | } | ||
277 | |||
278 | onCurrentItemChanged: { | ||
279 | if (currentItem) { | ||
280 | currentItem.forceActiveFocus() | ||
281 | } | ||
282 | } | ||
283 | |||
284 | Component.onCompleted: { | ||
285 | //Setup the initial item stack | ||
286 | if (!currentItem) { | ||
287 | setMailView() | ||
288 | if (startupCheck.noAccount) { | ||
289 | setAccountsView() | ||
290 | } else { | ||
291 | loginIfNecessary() | ||
260 | } | 292 | } |
261 | } | 293 | } |
262 | } | 294 | } |
@@ -304,25 +336,6 @@ Controls2.ApplicationWindow { | |||
304 | pushView(composerView, {message: mail, loadAsDraft: openAsDraft}) | 336 | pushView(composerView, {message: mail, loadAsDraft: openAsDraft}) |
305 | } | 337 | } |
306 | 338 | ||
307 | onCurrentItemChanged: { | ||
308 | if (currentItem) { | ||
309 | currentItem.forceActiveFocus() | ||
310 | } | ||
311 | } | ||
312 | |||
313 | Component.onCompleted: { | ||
314 | //Setup the initial item stack | ||
315 | if (!currentItem) { | ||
316 | setMailView(); | ||
317 | if (startupCheck.noAccount) { | ||
318 | setAccountsView() | ||
319 | } else { | ||
320 | if (!!app.currentAccount && !Kube.Keyring.isUnlocked(app.currentAccount)) { | ||
321 | setLoginView() | ||
322 | } | ||
323 | } | ||
324 | } | ||
325 | } | ||
326 | 339 | ||
327 | //These items are not visible until pushed onto the stack, so we keep them in resources instead of items | 340 | //These items are not visible until pushed onto the stack, so we keep them in resources instead of items |
328 | resources: [ | 341 | resources: [ |
diff --git a/framework/src/accounts/accountfactory.cpp b/framework/src/accounts/accountfactory.cpp index 9726a2e0..1af07ac6 100644 --- a/framework/src/accounts/accountfactory.cpp +++ b/framework/src/accounts/accountfactory.cpp | |||
@@ -67,6 +67,7 @@ void AccountFactory::loadPackage() | |||
67 | mLoginUi.clear(); | 67 | mLoginUi.clear(); |
68 | mName.clear(); | 68 | mName.clear(); |
69 | mIcon.clear(); | 69 | mIcon.clear(); |
70 | mRequiresKeyring = true; | ||
70 | emit accountLoaded(); | 71 | emit accountLoaded(); |
71 | return; | 72 | return; |
72 | } | 73 | } |
@@ -75,5 +76,6 @@ void AccountFactory::loadPackage() | |||
75 | mLoginUi = package.filePath("ui", "Login.qml"); | 76 | mLoginUi = package.filePath("ui", "Login.qml"); |
76 | mName = package.metadata().name(); | 77 | mName = package.metadata().name(); |
77 | mIcon = package.metadata().iconName(); | 78 | mIcon = package.metadata().iconName(); |
79 | mRequiresKeyring = package.metadata().value("X-KDE-Kube-RequiresKeyring", "True").toLower() == "true"; | ||
78 | emit accountLoaded(); | 80 | emit accountLoaded(); |
79 | } | 81 | } |
diff --git a/framework/src/accounts/accountfactory.h b/framework/src/accounts/accountfactory.h index 21747df5..f49d475c 100644 --- a/framework/src/accounts/accountfactory.h +++ b/framework/src/accounts/accountfactory.h | |||
@@ -34,6 +34,7 @@ class AccountFactory : public QObject | |||
34 | Q_PROPERTY(QString icon MEMBER mIcon NOTIFY accountLoaded); | 34 | Q_PROPERTY(QString icon MEMBER mIcon NOTIFY accountLoaded); |
35 | Q_PROPERTY(QString uiPath MEMBER mUiPath NOTIFY accountLoaded); | 35 | Q_PROPERTY(QString uiPath MEMBER mUiPath NOTIFY accountLoaded); |
36 | Q_PROPERTY(QString loginUi MEMBER mLoginUi NOTIFY accountLoaded); | 36 | Q_PROPERTY(QString loginUi MEMBER mLoginUi NOTIFY accountLoaded); |
37 | Q_PROPERTY(bool requiresKeyring MEMBER mRequiresKeyring NOTIFY accountLoaded); | ||
37 | public: | 38 | public: |
38 | explicit AccountFactory(QObject *parent = Q_NULLPTR); | 39 | explicit AccountFactory(QObject *parent = Q_NULLPTR); |
39 | 40 | ||
@@ -52,4 +53,5 @@ private: | |||
52 | QString mUiPath; | 53 | QString mUiPath; |
53 | QString mLoginUi; | 54 | QString mLoginUi; |
54 | QByteArray mAccountType; | 55 | QByteArray mAccountType; |
56 | bool mRequiresKeyring = true; | ||
55 | }; | 57 | }; |
diff --git a/framework/src/keyring.h b/framework/src/keyring.h index df25dbff..5d2c7544 100644 --- a/framework/src/keyring.h +++ b/framework/src/keyring.h | |||
@@ -28,7 +28,7 @@ public: | |||
28 | Keyring(); | 28 | Keyring(); |
29 | static Keyring *instance(); | 29 | static Keyring *instance(); |
30 | Q_INVOKABLE bool isUnlocked(const QByteArray &accountId); | 30 | Q_INVOKABLE bool isUnlocked(const QByteArray &accountId); |
31 | void unlock(const QByteArray &accountId); | 31 | Q_INVOKABLE void unlock(const QByteArray &accountId); |
32 | 32 | ||
33 | private: | 33 | private: |
34 | Q_DISABLE_COPY(Keyring); | 34 | Q_DISABLE_COPY(Keyring); |