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
KMailTransport
Commits
366358a1
Commit
366358a1
authored
Nov 20, 2020
by
Laurent Montel
😁
Browse files
Continue to port to qtr5keychain
parent
e348ebb6
Pipeline
#41693
passed with stage
in 10 minutes and 55 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/kmailtransport/transport.cpp
View file @
366358a1
...
...
@@ -18,7 +18,8 @@
#include <KMessageBox>
#include <KStringHandler>
#include <KWallet/KWallet>
#include <qt5keychain/keychain.h>
using
namespace
QKeychain
;
using
namespace
MailTransport
;
using
namespace
KWallet
;
...
...
@@ -31,7 +32,6 @@ Transport::Transport(const QString &cfgGroup)
d
->
passwordDirty
=
false
;
d
->
storePasswordInFile
=
false
;
d
->
needsWalletMigration
=
false
;
d
->
passwordNeedsUpdateFromWallet
=
false
;
load
();
}
...
...
@@ -169,20 +169,6 @@ void Transport::usrRead()
}
if
(
d
->
passwordLoaded
)
{
if
(
d
->
passwordNeedsUpdateFromWallet
)
{
d
->
passwordNeedsUpdateFromWallet
=
false
;
// read password if wallet is open, defer otherwise
if
(
Wallet
::
isOpen
(
Wallet
::
NetworkWallet
()))
{
// Don't read the password right away because this can lead
// to reentrancy problems in KDBusServiceStarter when an application
// run in Kontact creates the transports (due to a QEventLoop in the
// synchronous KWallet openWallet call).
QTimer
::
singleShot
(
0
,
this
,
&
Transport
::
readPassword
);
}
else
{
d
->
passwordLoaded
=
false
;
}
}
return
;
}
...
...
@@ -253,17 +239,24 @@ void Transport::readPassword()
}
d
->
passwordLoaded
=
true
;
// finally try to open the wallet and read the password
KWallet
::
Wallet
*
wallet
=
TransportManager
::
self
()
->
wallet
();
if
(
wallet
)
{
QString
pwd
;
if
(
wallet
->
readPassword
(
QString
::
number
(
id
()),
pwd
)
==
0
)
{
setPassword
(
pwd
);
}
else
{
d
->
password
.
clear
();
d
->
passwordLoaded
=
false
;
}
auto
readJob
=
new
ReadPasswordJob
(
WALLET_FOLDER
,
this
);
connect
(
readJob
,
&
Job
::
finished
,
this
,
&
Transport
::
readTransportPasswordFinished
);
readJob
->
setKey
(
QString
::
number
(
id
()));
readJob
->
start
();
}
void
Transport
::
readTransportPasswordFinished
(
QKeychain
::
Job
*
baseJob
)
{
auto
*
job
=
qobject_cast
<
ReadPasswordJob
*>
(
baseJob
);
Q_ASSERT
(
job
);
if
(
job
->
error
())
{
d
->
password
.
clear
();
d
->
passwordLoaded
=
false
;
qWarning
()
<<
"We have an error during reading password "
<<
job
->
errorString
();
}
else
{
setPassword
(
job
->
textData
());
}
}
bool
Transport
::
needsWalletMigration
()
const
...
...
src/kmailtransport/transport.h
View file @
366358a1
...
...
@@ -12,7 +12,9 @@
#include <transporttype.h>
class
TransportPrivate
;
namespace
QKeychain
{
class
Job
;
}
namespace
MailTransport
{
class
TransportType
;
...
...
@@ -137,6 +139,7 @@ private Q_SLOTS:
void
readPassword
();
private:
void
readTransportPasswordFinished
(
QKeychain
::
Job
*
baseJob
);
TransportPrivate
*
const
d
;
};
}
// namespace MailTransport
...
...
src/kmailtransport/transport_p.h
View file @
366358a1
...
...
@@ -23,7 +23,6 @@ public:
bool
passwordDirty
;
bool
storePasswordInFile
;
bool
needsWalletMigration
;
bool
passwordNeedsUpdateFromWallet
;
};
#endif
src/kmailtransport/transportmanager.cpp
View file @
366358a1
...
...
@@ -405,42 +405,6 @@ void TransportManager::removeTransport(int id)
void
TransportManagerPrivate
::
readConfig
()
{
QList
<
Transport
*>
oldTransports
=
transports
;
transports
.
clear
();
QRegularExpression
re
(
QStringLiteral
(
"^Transport (.+)$"
));
const
QStringList
groups
=
config
->
groupList
().
filter
(
re
);
for
(
const
QString
&
s
:
groups
)
{
QRegularExpressionMatch
match
=
re
.
match
(
s
);
if
(
!
match
.
hasMatch
())
{
continue
;
}
Transport
*
t
=
nullptr
;
// see if we happen to have that one already
for
(
Transport
*
old
:
oldTransports
)
{
if
(
old
->
currentGroup
()
==
QLatin1String
(
"Transport "
)
+
match
.
captured
(
1
))
{
qCDebug
(
MAILTRANSPORT_LOG
)
<<
"reloading existing transport:"
<<
s
;
t
=
old
;
t
->
d
->
passwordNeedsUpdateFromWallet
=
true
;
t
->
load
();
oldTransports
.
removeAll
(
old
);
break
;
}
}
if
(
!
t
)
{
t
=
new
Transport
(
match
.
captured
(
1
));
}
if
(
t
->
id
()
<=
0
)
{
t
->
setId
(
createId
());
t
->
save
();
}
transports
.
append
(
t
);
}
qDeleteAll
(
oldTransports
);
oldTransports
.
clear
();
// read default transport
KConfigGroup
group
(
config
,
"General"
);
defaultTransportId
=
group
.
readEntry
(
"default-transport"
,
0
);
...
...
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