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
Akonadi Data Import Wizard
Commits
23137281
Commit
23137281
authored
Nov 13, 2020
by
Laurent Montel
😁
Browse files
Replace kwallet by qt5keychain
parent
cb65b23e
Pipeline
#40695
failed with stage
in 6 minutes and 19 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
23137281
...
...
@@ -56,7 +56,6 @@ set(IDENTITYMANAGEMENT_LIB_VERSION "5.15.80")
set
(
GRANTLEETHEME_LIB_VERSION
"5.15.80"
)
# Find KF5 package
find_package
(
KF5Wallet
${
KF5_MIN_VERSION
}
CONFIG REQUIRED
)
find_package
(
KF5Config
${
KF5_MIN_VERSION
}
CONFIG REQUIRED
)
find_package
(
KF5DBusAddons
${
KF5_MIN_VERSION
}
CONFIG REQUIRED
)
find_package
(
KF5Auth
${
KF5_MIN_VERSION
}
CONFIG REQUIRED
)
...
...
@@ -77,12 +76,11 @@ find_package(KF5MessageViewer ${MESSAGELIB_LIB_VERSION} CONFIG REQUIRED)
find_package
(
KF5PimCommonAkonadi
${
PIMCOMMON_LIB_VERSION
}
CONFIG REQUIRED
)
include_directories
(
${
importwizard_SOURCE_DIR
}
${
importwizard_BINARY_DIR
}
)
#it will replace kwallet support
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
)
add_definitions
(
-DQT_NO_URL_CAST_FROM_STRING
)
...
...
src/libimportwizard/CMakeLists.txt
View file @
23137281
...
...
@@ -46,6 +46,9 @@ set(libimportwizard_abstract_SRCS
set
(
libimportwizard_utils_SRCS
importwizardutil.cpp
)
set
(
libimportwizard_wallet_SRCS
importwizardsavepasswordjob.cpp
)
ecm_qt_declare_logging_category
(
libimportwizard_abstract_SRCS HEADER libimportwizard_debug.h IDENTIFIER LIBIMPORTWIZARD_LOG CATEGORY_NAME org.kde.pim.importwizard.lib
DESCRIPTION
"importwizard (libimportwizard)"
...
...
@@ -54,7 +57,7 @@ ecm_qt_declare_logging_category(libimportwizard_abstract_SRCS HEADER libimportwi
add_library
(
KPimImportWizard
${
libimportwizard_abstract_SRCS
}
${
libimportwizard_utils_SRCS
}
)
add_library
(
KPimImportWizard
${
libimportwizard_abstract_SRCS
}
${
libimportwizard_utils_SRCS
}
${
libimportwizard_wallet_SRCS
}
)
add_library
(
KPim::ImportWizard ALIAS KPimImportWizard
)
...
...
@@ -73,6 +76,7 @@ target_link_libraries(KPimImportWizard
KF5::MailCommon
KF5::MailImporter
KF5::I18n
qt5keychain
)
set_target_properties
(
KPimImportWizard PROPERTIES
...
...
src/libimportwizard/importwizardsavepasswordjob.cpp
0 → 100644
View file @
23137281
/*
SPDX-FileCopyrightText: 2012-2020 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "importwizardsavepasswordjob.h"
#include "libimportwizard_debug.h"
using
namespace
QKeychain
;
ImportWizardSavePasswordJob
::
ImportWizardSavePasswordJob
(
QObject
*
parent
)
:
QObject
(
parent
)
{
}
ImportWizardSavePasswordJob
::~
ImportWizardSavePasswordJob
()
{
}
bool
ImportWizardSavePasswordJob
::
canStart
()
const
{
return
!
mName
.
isEmpty
()
&&
!
mPassword
.
isEmpty
()
&&
!
mKey
.
isEmpty
();
}
void
ImportWizardSavePasswordJob
::
start
()
{
if
(
!
canStart
())
{
if
(
mName
.
isEmpty
())
{
qCWarning
(
LIBIMPORTWIZARD_LOG
)
<<
"Error missing mName"
;
}
if
(
mKey
.
isEmpty
())
{
qCWarning
(
LIBIMPORTWIZARD_LOG
)
<<
"Error missing mKey"
;
}
if
(
mPassword
.
isEmpty
())
{
qCWarning
(
LIBIMPORTWIZARD_LOG
)
<<
"Error missing mName"
;
}
deleteLater
();
return
;
}
auto
writeJob
=
new
WritePasswordJob
(
mName
,
this
);
connect
(
writeJob
,
&
Job
::
finished
,
this
,
&
ImportWizardSavePasswordJob
::
slotPasswordWritten
);
writeJob
->
setKey
(
mKey
);
writeJob
->
setTextData
(
mPassword
);
writeJob
->
start
();
}
void
ImportWizardSavePasswordJob
::
slotPasswordWritten
(
QKeychain
::
Job
*
baseJob
)
{
if
(
baseJob
->
error
())
{
qCWarning
(
LIBIMPORTWIZARD_LOG
)
<<
"Error writing password using QKeychain:"
<<
baseJob
->
errorString
();
}
deleteLater
();
}
QString
ImportWizardSavePasswordJob
::
name
()
const
{
return
mName
;
}
void
ImportWizardSavePasswordJob
::
setName
(
const
QString
&
name
)
{
mName
=
name
;
}
QString
ImportWizardSavePasswordJob
::
key
()
const
{
return
mKey
;
}
void
ImportWizardSavePasswordJob
::
setKey
(
const
QString
&
key
)
{
mKey
=
key
;
}
QString
ImportWizardSavePasswordJob
::
password
()
const
{
return
mPassword
;
}
void
ImportWizardSavePasswordJob
::
setPassword
(
const
QString
&
password
)
{
mPassword
=
password
;
}
src/libimportwizard/importwizardsavepasswordjob.h
0 → 100644
View file @
23137281
/*
SPDX-FileCopyrightText: 2012-2020 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef IMPORTWIZARDSAVEPASSWORDJOB_H
#define IMPORTWIZARDSAVEPASSWORDJOB_H
#include <QObject>
#include "libimportwizard_export.h"
#include <qt5keychain/keychain.h>
class
LIBIMPORTWIZARD_EXPORT
ImportWizardSavePasswordJob
:
public
QObject
{
Q_OBJECT
public:
explicit
ImportWizardSavePasswordJob
(
QObject
*
parent
=
nullptr
);
~
ImportWizardSavePasswordJob
();
Q_REQUIRED_RESULT
bool
canStart
()
const
;
void
start
();
Q_REQUIRED_RESULT
QString
password
()
const
;
void
setPassword
(
const
QString
&
password
);
Q_REQUIRED_RESULT
QString
key
()
const
;
void
setKey
(
const
QString
&
key
);
Q_REQUIRED_RESULT
QString
name
()
const
;
void
setName
(
const
QString
&
name
);
private:
void
slotPasswordWritten
(
QKeychain
::
Job
*
baseJob
);
QString
mPassword
;
QString
mKey
;
QString
mName
;
};
#endif // IMPORTWIZARDSAVEPASSWORDJOB_H
src/libimportwizard/importwizardutil.cpp
View file @
23137281
...
...
@@ -8,7 +8,7 @@
#include <KSharedConfig>
#include <KConfigGroup>
#include "libimportwizard_debug.h"
#include
<KWallet>
#include
"importwizardsavepasswordjob.h"
#include <AkonadiCore/Tag>
#include <AkonadiCore/TagAttribute>
#include <AkonadiCore/TagCreateJob>
...
...
@@ -80,30 +80,22 @@ void ImportWizardUtil::addAkonadiTag(const QVector<tagStruct> &tagList)
void
ImportWizardUtil
::
storePassword
(
const
QString
&
name
,
ImportWizardUtil
::
ResourceType
type
,
const
QString
&
password
)
{
KWallet
::
Wallet
*
wallet
=
KWallet
::
Wallet
::
openWallet
(
KWallet
::
Wallet
::
NetworkWallet
(),
0
);
if
(
wallet
&&
wallet
->
isOpen
())
{
switch
(
type
)
{
case
Imap
:
if
(
!
wallet
->
hasFolder
(
QStringLiteral
(
"imap"
)))
{
wallet
->
createFolder
(
QStringLiteral
(
"imap"
));
}
wallet
->
setFolder
(
QStringLiteral
(
"imap"
));
wallet
->
writePassword
(
name
+
QLatin1String
(
"rc"
),
password
);
break
;
case
Pop3
:
if
(
!
wallet
->
hasFolder
(
QStringLiteral
(
"pop3"
)))
{
wallet
->
createFolder
(
QStringLiteral
(
"pop3"
));
}
wallet
->
setFolder
(
QStringLiteral
(
"pop3"
));
wallet
->
writePassword
(
name
,
password
);
break
;
case
Ldap
:
if
(
!
wallet
->
hasFolder
(
QStringLiteral
(
"ldapclient"
)))
{
wallet
->
createFolder
(
QStringLiteral
(
"ldapclient"
));
}
wallet
->
setFolder
(
QStringLiteral
(
"ldapclient"
));
wallet
->
writePassword
(
name
,
password
);
}
delete
wallet
;
auto
*
job
=
new
ImportWizardSavePasswordJob
;
switch
(
type
)
{
case
Imap
:
job
->
setName
(
QStringLiteral
(
"imap"
));
job
->
setPassword
(
password
);
job
->
setKey
(
name
+
QLatin1String
(
"rc"
));
break
;
case
Pop3
:
job
->
setName
(
QStringLiteral
(
"pop3"
));
job
->
setPassword
(
password
);
job
->
setKey
(
name
);
break
;
case
Ldap
:
job
->
setName
(
QStringLiteral
(
"ldapclient"
));
job
->
setPassword
(
password
);
job
->
setKey
(
name
);
}
job
->
start
();
}
src/libimportwizard/importwizardutil.h
View file @
23137281
...
...
@@ -13,12 +13,6 @@
struct
LIBIMPORTWIZARD_EXPORT
ldapStruct
{
ldapStruct
()
:
maxHint
(
-
1
)
,
port
(
-
1
)
,
limit
(
-
1
)
,
timeout
(
-
1
)
,
useSSL
(
false
)
,
useTLS
(
false
)
{
}
...
...
@@ -28,12 +22,12 @@ struct LIBIMPORTWIZARD_EXPORT ldapStruct {
QString
fileName
;
QString
description
;
QString
password
;
int
maxHint
;
int
port
;
int
limit
;
int
timeout
;
bool
useSSL
;
bool
useTLS
;
int
maxHint
=
-
1
;
int
port
=
-
1
;
int
limit
=
-
1
;
int
timeout
=
-
1
;
bool
useSSL
=
false
;
bool
useTLS
=
false
;
};
struct
tagStruct
{
...
...
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