Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KDE PIM Runtime
Commits
662c4ffb
Commit
662c4ffb
authored
Nov 16, 2020
by
Laurent Montel
😁
Browse files
Start to port it to qt5keychain
parent
1578ff30
Pipeline
#41276
failed with stage
in 18 minutes and 15 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
662c4ffb
...
...
@@ -148,7 +148,7 @@ find_package(Qt5Keychain CONFIG)
set_package_properties
(
Qt5Keychain PROPERTIES
DESCRIPTION
"Provides support for secure credentials storage"
URL
"https://github.com/frankosterfeld/qtkeychain"
TYPE
OPTIONAL
)
TYPE
REQUIRED
)
option
(
KDEPIM_RUN_ISOLATED_TESTS
"Run the isolated tests."
FALSE
)
...
...
resources/pop3/CMakeLists.txt
View file @
662c4ffb
...
...
@@ -47,6 +47,7 @@ target_link_libraries( akonadi_pop3_resource
KF5::Notifications
Qt5::DBus
KF5::PimCommon
qt5keychain
)
if
(
BUILD_TESTING
)
...
...
@@ -84,4 +85,5 @@ target_link_libraries(pop3config
KF5::AkonadiAgentBase
KF5::AkonadiMime
KF5::Libkdepim
qt5keychain
)
resources/pop3/accountwidget.cpp
View file @
662c4ffb
...
...
@@ -22,11 +22,11 @@
#include <resourcesettings.h>
#include <MailTransport/ServerTest>
// KDELIBS includes
#include <KEMailSettings>
#include <KMessageBox>
#include <KUser>
#include <KWallet>
#include "pop3resource_debug.h"
#include <QButtonGroup>
...
...
@@ -35,8 +35,7 @@
using
namespace
MailTransport
;
using
namespace
Akonadi
;
using
namespace
KWallet
;
using
namespace
QKeychain
;
namespace
{
class
BusyCursorHelper
:
public
QObject
{
...
...
@@ -70,8 +69,6 @@ AccountWidget::AccountWidget(Settings &settings, const QString &identifier, QWid
AccountWidget
::~
AccountWidget
()
{
delete
mWallet
;
mWallet
=
nullptr
;
delete
mServerTest
;
mServerTest
=
nullptr
;
}
...
...
@@ -204,45 +201,33 @@ void AccountWidget::loadSettings()
connect
(
requestJob
,
&
SpecialMailCollectionsRequestJob
::
result
,
this
,
&
AccountWidget
::
localFolderRequestJobFinished
);
}
mWallet
=
Wallet
::
openWallet
(
Wallet
::
NetworkWallet
(),
winId
(),
Wallet
::
Asynchronous
);
if
(
mWallet
)
{
connect
(
mWallet
,
&
KWallet
::
Wallet
::
walletOpened
,
this
,
&
AccountWidget
::
walletOpenedForLoading
);
}
else
{
passwordEdit
->
lineEdit
()
->
setPlaceholderText
(
i18n
(
"Wallet disabled in system settings"
));
}
passwordEdit
->
setEnabled
(
false
);
passwordLabel
->
setEnabled
(
false
);
auto
readJob
=
new
ReadPasswordJob
(
QStringLiteral
(
"pop3"
),
this
);
connect
(
readJob
,
&
QKeychain
::
Job
::
finished
,
this
,
&
AccountWidget
::
walletOpenedForLoading
);
readJob
->
setKey
(
mIdentifier
);
readJob
->
start
();
}
void
AccountWidget
::
walletOpenedForLoading
(
bool
success
)
void
AccountWidget
::
walletOpenedForLoading
(
QKeychain
::
Job
*
baseJob
)
{
if
(
success
)
{
if
(
mWallet
->
isOpen
())
{
passwordEdit
->
setEnabled
(
true
);
passwordLabel
->
setEnabled
(
true
);
}
if
(
mWallet
->
isOpen
()
&&
mWallet
->
hasFolder
(
QStringLiteral
(
"pop3"
)))
{
QString
password
;
mWallet
->
setFolder
(
QStringLiteral
(
"pop3"
));
mWallet
->
readPassword
(
mIdentifier
,
password
);
passwordEdit
->
setPassword
(
password
);
mInitalPassword
=
password
;
}
else
{
qCWarning
(
POP3RESOURCE_LOG
)
<<
"Wallet not open or doesn't have pop3 folder."
;
}
}
else
{
qCWarning
(
POP3RESOURCE_LOG
)
<<
"Failed to open wallet for loading the password."
;
}
auto
*
job
=
qobject_cast
<
ReadPasswordJob
*>
(
baseJob
);
Q_ASSERT
(
job
);
if
(
!
job
->
error
())
{
passwordEdit
->
setPassword
(
job
->
textData
());
passwordEdit
->
setEnabled
(
true
);
passwordLabel
->
setEnabled
(
true
);
const
bool
walletError
=
!
success
||
!
mWallet
->
isOpen
();
if
(
walletError
)
{
}
else
{
qCWarning
(
POP3RESOURCE_LOG
)
<<
"Failed to open wallet for loading the password."
<<
job
->
errorString
();
passwordEdit
->
lineEdit
()
->
setPlaceholderText
(
i18n
(
"Unable to open wallet"
));
}
}
void
AccountWidget
::
walletOpenedForSaving
(
bool
success
)
{
#if 0
//Move as async
if (success) {
if (mWallet && mWallet->isOpen()) {
// Remove the password from the wallet if the user doesn't want to store it
...
...
@@ -268,6 +253,7 @@ void AccountWidget::walletOpenedForSaving(bool success)
delete mWallet;
mWallet = nullptr;
#endif
}
void
AccountWidget
::
slotLeaveOnServerClicked
()
...
...
@@ -570,7 +556,8 @@ void AccountWidget::saveSettings()
const
bool
userChangedPassword
=
mInitalPassword
!=
passwordEdit
->
password
();
const
bool
userWantsToDeletePassword
=
passwordEdit
->
password
().
isEmpty
()
&&
userChangedPassword
;
//Move to async
#if 0
if ((!passwordEdit->password().isEmpty() && userChangedPassword)
|| userWantsToDeletePassword) {
qCDebug(POP3RESOURCE_LOG) << mWallet << mWallet->isOpen();
...
...
@@ -587,6 +574,7 @@ void AccountWidget::saveSettings()
}
}
}
#endif
}
void
AccountWidget
::
slotEnableLeaveOnServerDays
(
bool
state
)
...
...
resources/pop3/accountwidget.h
View file @
662c4ffb
...
...
@@ -12,7 +12,7 @@
#define ACCOUNT_WIDGET_H
#include "ui_popsettings.h"
#include <qt5keychain/keychain.h>
class
Settings
;
namespace
MailTransport
{
...
...
@@ -55,7 +55,7 @@ private Q_SLOTS:
void
targetCollectionReceived
(
Akonadi
::
Collection
::
List
collections
);
void
localFolderRequestJobFinished
(
KJob
*
job
);
void
walletOpenedForLoading
(
bool
success
);
void
walletOpenedForLoading
(
QKeychain
::
Job
*
baseJob
);
void
walletOpenedForSaving
(
bool
success
);
void
slotAccepted
();
private:
...
...
@@ -69,7 +69,6 @@ private:
MailTransport
::
ServerTest
*
mServerTest
=
nullptr
;
QRegularExpressionValidator
mValidator
;
bool
mServerTestFailed
=
false
;
KWallet
::
Wallet
*
mWallet
=
nullptr
;
QString
mInitalPassword
;
const
QString
mIdentifier
;
Settings
&
mSettings
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment