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
PIM Sieve Editor
Commits
f747d764
Commit
f747d764
authored
Jan 26, 2021
by
Laurent Montel
😁
Browse files
run git clang-format
parent
92d97892
Changes
59
Hide whitespace changes
Inline
Side-by-side
autotests/serversievesettingstest.cpp
View file @
f747d764
...
...
@@ -19,8 +19,8 @@
#include "serversievesettingstest.h"
#include "../src/serversievesettings.h"
#include <QTest>
#include <QSignalSpy>
#include <QTest>
ServerSieveSettingsTest
::
ServerSieveSettingsTest
(
QObject
*
parent
)
:
QObject
(
parent
)
{
...
...
@@ -83,19 +83,19 @@ void ServerSieveSettingsTest::shouldEmitSignalWithValueTrue()
QSignalSpy
spy
(
&
widget
,
&
ServerSieveSettings
::
enableOkButton
);
widget
.
setServerName
(
QStringLiteral
(
"foo"
));
QCOMPARE
(
spy
.
count
(),
1
);
//We need servername!=empty and username != empty
//
We need servername!=empty and username != empty
QCOMPARE
(
spy
.
at
(
0
).
at
(
0
).
toBool
(),
false
);
widget
.
setUserName
(
QStringLiteral
(
"foo"
));
QCOMPARE
(
spy
.
count
(),
2
);
QCOMPARE
(
spy
.
at
(
1
).
at
(
0
).
toBool
(),
true
);
//We don't want empty string
//
We don't want empty string
widget
.
setUserName
(
QStringLiteral
(
" "
));
QCOMPARE
(
spy
.
count
(),
3
);
QCOMPARE
(
spy
.
at
(
2
).
at
(
0
).
toBool
(),
false
);
//We don't want empty string
//
We don't want empty string
widget
.
setServerName
(
QStringLiteral
(
" "
));
QCOMPARE
(
spy
.
count
(),
4
);
QCOMPARE
(
spy
.
at
(
3
).
at
(
0
).
toBool
(),
false
);
...
...
autotests/sieveeditorconfigureserverpagetest.cpp
View file @
f747d764
...
...
@@ -20,8 +20,8 @@
#include "sieveeditorconfigureserverpagetest.h"
#include "../src/sieveeditorconfigureserverpage.h"
#include <QPushButton>
#include <QTest>
#include <QSignalSpy>
#include <QTest>
#include <qtestmouse.h>
SieveEditorConfigureServerPageTest
::
SieveEditorConfigureServerPageTest
(
QObject
*
parent
)
:
QObject
(
parent
)
...
...
autotests/sieveeditorutiltest.cpp
View file @
f747d764
...
...
@@ -18,8 +18,8 @@
*/
#include "sieveeditorutiltest.h"
#include <QTest>
#include "../src/sieveeditorutil.h"
#include <QTest>
SieveEditorUtilTest
::
SieveEditorUtilTest
(
QObject
*
parent
)
:
QObject
(
parent
)
...
...
src/importwizard/autotests/importimapsettingprogresspagetest.cpp
View file @
f747d764
...
...
@@ -19,10 +19,10 @@
#include "importimapsettingprogresspagetest.h"
#include "../importimapsettingprogresspage.h"
#include <QStandardPaths>
#include <QTest>
#include <QTextEdit>
#include <QVBoxLayout>
#include <QStandardPaths>
ImportImapSettingProgressPageTest
::
ImportImapSettingProgressPageTest
(
QObject
*
parent
)
:
QObject
(
parent
)
...
...
src/importwizard/autotests/importimapsettingsakonadicheckjobtest.cpp
View file @
f747d764
...
...
@@ -18,12 +18,12 @@
*/
#include "importimapsettingsakonadicheckjobtest.h"
#include "importimapsettingspasswordtest.h"
#include "../checks/importimapsettingsakonadicheckjob.h"
#include "importimapsettingspasswordtest.h"
#include <QTest>
#include <QStandardPaths>
#include <QSignalSpy>
#include <QStandardPaths>
#include <QTest>
Q_DECLARE_METATYPE
(
SieveEditorUtil
::
SieveServerConfig
)
ImportImapSettingsAkonadiCheckJobTest
::
ImportImapSettingsAkonadiCheckJobTest
(
QObject
*
parent
)
...
...
@@ -129,7 +129,7 @@ void ImportImapSettingsAkonadiCheckJobTest::shouldImportSieveSettings_data()
settings2
.
sieveImapAccountSettings
.
setPassword
(
QStringLiteral
(
"password_imap"
));
settings2
.
sieveImapAccountSettings
.
setEncryptionMode
(
KSieveUi
::
SieveImapAccountSettings
::
EncryptionMode
::
STARTTLS
);
settings2
.
sieveSettings
.
userName
=
QStringLiteral
(
"b"
);
settings2
.
sieveSettings
.
serverName
=
QStringLiteral
(
"bla.foo.com"
);
//TODO
settings2
.
sieveSettings
.
serverName
=
QStringLiteral
(
"bla.foo.com"
);
//
TODO
settings2
.
sieveSettings
.
password
=
QStringLiteral
(
"password_custom_sieve_imap"
);
settings2
.
sieveSettings
.
port
=
150
;
...
...
@@ -144,7 +144,7 @@ void ImportImapSettingsAkonadiCheckJobTest::shouldImportSieveSettings_data()
settings3
.
sieveImapAccountSettings
.
setPassword
(
QStringLiteral
(
"password_imap"
));
settings3
.
sieveSettings
.
userName
=
QStringLiteral
(
"b"
);
settings3
.
sieveSettings
.
password
=
QStringLiteral
(
"password_custom_sieve_imap"
);
settings3
.
sieveSettings
.
serverName
=
QStringLiteral
(
"bla.foo.com"
);
//TODO
settings3
.
sieveSettings
.
serverName
=
QStringLiteral
(
"bla.foo.com"
);
//
TODO
settings3
.
sieveSettings
.
port
=
150
;
QTest
::
newRow
(
"usecustomsieveconfig2"
)
<<
QStringLiteral
(
"/config/usecustomsieveconfig2"
)
<<
QStringLiteral
(
"akonadi_kolab_resource_0rc"
)
<<
settings3
;
...
...
@@ -158,7 +158,7 @@ void ImportImapSettingsAkonadiCheckJobTest::shouldImportSieveSettings_data()
settings4
.
sieveImapAccountSettings
.
setPassword
(
QStringLiteral
(
"password_imap"
));
settings4
.
sieveSettings
.
userName
=
QStringLiteral
(
"b"
);
settings4
.
sieveSettings
.
password
=
QStringLiteral
(
"password_custom_sieve_imap"
);
settings4
.
sieveSettings
.
serverName
=
QStringLiteral
(
"bla.foo.com"
);
//TODO
settings4
.
sieveSettings
.
serverName
=
QStringLiteral
(
"bla.foo.com"
);
//
TODO
settings4
.
sieveSettings
.
port
=
150
;
QTest
::
newRow
(
"usecustomsieveconfig3"
)
<<
QStringLiteral
(
"/config/usecustomsieveconfig3"
)
<<
QStringLiteral
(
"akonadi_kolab_resource_0rc"
)
<<
settings4
;
...
...
@@ -171,7 +171,7 @@ void ImportImapSettingsAkonadiCheckJobTest::shouldImportSieveSettings_data()
settings5
.
sieveImapAccountSettings
.
setEncryptionMode
(
KSieveUi
::
SieveImapAccountSettings
::
EncryptionMode
::
SSLorTLS
);
settings5
.
sieveImapAccountSettings
.
setPassword
(
QStringLiteral
(
"password_imap"
));
settings5
.
sieveSettings
.
userName
=
QStringLiteral
(
"b"
);
settings5
.
sieveSettings
.
serverName
=
QStringLiteral
(
"bla.foo.com"
);
//TODO
settings5
.
sieveSettings
.
serverName
=
QStringLiteral
(
"bla.foo.com"
);
//
TODO
settings5
.
sieveSettings
.
password
=
QStringLiteral
(
"password_custom_sieve_imap"
);
settings5
.
sieveSettings
.
port
=
150
;
...
...
src/importwizard/autotests/importimapsettingsearchpagetest.cpp
View file @
f747d764
...
...
@@ -21,9 +21,9 @@
#include "../importimapsettingsearchpage.h"
#include <QLabel>
#include <QListWidget>
#include <QStandardPaths>
#include <QTest>
#include <QVBoxLayout>
#include <QStandardPaths>
ImportImapSettingSearchPageTest
::
ImportImapSettingSearchPageTest
(
QObject
*
parent
)
:
QObject
(
parent
)
{
...
...
@@ -52,9 +52,7 @@ void ImportImapSettingSearchPageTest::shouldHaveDefaultValue()
void
ImportImapSettingSearchPageTest
::
shouldAddCheckPrograms
()
{
ImportImapSettingSearchPage
w
;
const
QStringList
lst
{
QStringLiteral
(
"foo"
),
QStringLiteral
(
"bla"
),
QStringLiteral
(
"do"
)
};
const
QStringList
lst
{
QStringLiteral
(
"foo"
),
QStringLiteral
(
"bla"
),
QStringLiteral
(
"do"
)};
w
.
setProgramList
(
lst
);
auto
mFoundProgramList
=
w
.
findChild
<
QListWidget
*>
(
QStringLiteral
(
"foundprogramlist"
));
...
...
src/importwizard/autotests/importimapsettingsthunderbirdcheckjobtest.cpp
View file @
f747d764
...
...
@@ -20,9 +20,9 @@
#include "importimapsettingsthunderbirdcheckjobtest.h"
#include "importwizard/checks/importimapsettingsthunderbirdcheckjob.h"
#include "libsieveeditor_export.h"
#include <QTest>
#include <QStandardPaths>
#include <QSignalSpy>
#include <QStandardPaths>
#include <QTest>
Q_DECLARE_METATYPE
(
SieveEditorUtil
::
SieveServerConfig
)
extern
LIBSIEVEEDITOR_EXPORT
QString
sieveeditor_thunderbird_default_toplevel_path
;
...
...
@@ -118,7 +118,8 @@ void ImportImapSettingsThunderbirdCheckJobTest::shouldImportSieveSettings_data()
settings
.
sieveSettings
.
serverName
=
QStringLiteral
(
"sever.foo.org"
);
settings
.
sieveSettings
.
port
=
4190
;
QTest
::
newRow
(
"thunderbirdencryptionnoneoneaccount"
)
<<
QStringLiteral
(
"/thunderbirdencryptionnoneoneaccount"
)
<<
QStringLiteral
(
"bla@kde.org"
)
<<
settings
;
QTest
::
newRow
(
"thunderbirdencryptionnoneoneaccount"
)
<<
QStringLiteral
(
"/thunderbirdencryptionnoneoneaccount"
)
<<
QStringLiteral
(
"bla@kde.org"
)
<<
settings
;
}
{
SieveEditorUtil
::
SieveServerConfig
settings
;
...
...
@@ -131,7 +132,8 @@ void ImportImapSettingsThunderbirdCheckJobTest::shouldImportSieveSettings_data()
settings
.
sieveSettings
.
serverName
=
QStringLiteral
(
"sever.foo.org"
);
settings
.
sieveSettings
.
port
=
4190
;
QTest
::
newRow
(
"thunderbirdencryptionssloneaccount"
)
<<
QStringLiteral
(
"/thunderbirdencryptionssloneaccount"
)
<<
QStringLiteral
(
"bla@kde.org"
)
<<
settings
;
QTest
::
newRow
(
"thunderbirdencryptionssloneaccount"
)
<<
QStringLiteral
(
"/thunderbirdencryptionssloneaccount"
)
<<
QStringLiteral
(
"bla@kde.org"
)
<<
settings
;
}
{
...
...
@@ -145,7 +147,8 @@ void ImportImapSettingsThunderbirdCheckJobTest::shouldImportSieveSettings_data()
settings
.
sieveSettings
.
serverName
=
QStringLiteral
(
"sever.foo.org"
);
settings
.
sieveSettings
.
port
=
4190
;
QTest
::
newRow
(
"thunderbirdencryptionstarttlsoneaccount"
)
<<
QStringLiteral
(
"/thunderbirdencryptionstarttlsoneaccount"
)
<<
QStringLiteral
(
"bla@kde.org"
)
<<
settings
;
QTest
::
newRow
(
"thunderbirdencryptionstarttlsoneaccount"
)
<<
QStringLiteral
(
"/thunderbirdencryptionstarttlsoneaccount"
)
<<
QStringLiteral
(
"bla@kde.org"
)
<<
settings
;
}
}
...
...
src/importwizard/checks/abstractimapsettingscheckjob.h
View file @
f747d764
...
...
@@ -20,9 +20,9 @@
#ifndef ABSTRACTIMAPSETTINGSCHECKJOB_H
#define ABSTRACTIMAPSETTINGSCHECKJOB_H
#include <QObject>
#include "../../sieveeditorutil.h"
#include "libsieveeditor_private_export.h"
#include <QObject>
class
AbstractImapSettingsPassword
;
class
LIBSIEVEEDITOR_TESTS_EXPORT
AbstractImapSettingsCheckJob
:
public
QObject
{
...
...
src/importwizard/checks/abstractimapsettingspassword.h
View file @
f747d764
...
...
@@ -32,6 +32,7 @@ public:
virtual
void
importPasswords
(
const
SieveEditorUtil
::
SieveServerConfig
&
config
,
const
QString
&
filename
,
bool
reuseImapSettings
);
Q_SIGNALS:
void
importPasswordDone
(
const
SieveEditorUtil
::
SieveServerConfig
&
config
,
const
QString
&
filename
);
protected:
QString
mFileName
;
};
...
...
src/importwizard/checks/importimapsettingsakonadicheckjob.cpp
View file @
f747d764
...
...
@@ -21,12 +21,12 @@
#include "importimapsettingsakonadipassword.h"
#include "libsieveeditor_export.h"
#include "sieveeditor_debug.h"
#include <KLocalizedString>
#include <KConfigGroup>
#include <KLocalizedString>
#include <KSharedConfig>
#include <QStandardPaths>
#include <QDir>
#include <QFile>
#include <QStandardPaths>
ImportImapSettingsAkonadiCheckJob
::
ImportImapSettingsAkonadiCheckJob
(
QObject
*
parent
)
:
AbstractImapSettingsCheckJob
(
parent
)
...
...
@@ -39,8 +39,7 @@ ImportImapSettingsAkonadiCheckJob::~ImportImapSettingsAkonadiCheckJob()
bool
ImportImapSettingsAkonadiCheckJob
::
resourceCanHaveSieveSupport
(
const
QString
&
filename
)
const
{
return
filename
.
startsWith
(
QLatin1String
(
"akonadi_kolab_resource"
))
||
filename
.
startsWith
(
QLatin1String
(
"akonadi_imap_resource"
));
return
filename
.
startsWith
(
QLatin1String
(
"akonadi_kolab_resource"
))
||
filename
.
startsWith
(
QLatin1String
(
"akonadi_imap_resource"
));
}
void
ImportImapSettingsAkonadiCheckJob
::
start
()
...
...
@@ -78,7 +77,7 @@ void ImportImapSettingsAkonadiCheckJob::loadSieveServerSettings()
void
ImportImapSettingsAkonadiCheckJob
::
importNextServerSieve
()
{
++
mSieveServerMapIterator
;
if
(
mSieveServerMapIterator
!=
mSieveServerLst
.
constEnd
())
{
if
(
mSieveServerMapIterator
!=
mSieveServerLst
.
constEnd
())
{
importSettings
(
mSieveServerMapIterator
.
key
(),
mSieveServerMapIterator
.
value
());
}
else
{
checkNoSettingsImported
();
...
...
@@ -87,8 +86,8 @@ void ImportImapSettingsAkonadiCheckJob::importNextServerSieve()
void
ImportImapSettingsAkonadiCheckJob
::
importSettings
(
const
QString
&
directory
,
const
QString
&
filename
)
{
const
QString
filePath
=
directory
+
QLatin1Char
(
'/'
)
+
filename
;
//qCDebug(SIEVEEDITOR_LOG) << "importSettings filename:" << filePath;
const
QString
filePath
=
directory
+
QLatin1Char
(
'/'
)
+
filename
;
//
qCDebug(SIEVEEDITOR_LOG) << "importSettings filename:" << filePath;
if
(
!
QFileInfo
::
exists
(
filePath
))
{
qCWarning
(
SIEVEEDITOR_LOG
)
<<
"Unable to open file "
<<
filePath
;
importNextServerSieve
();
...
...
@@ -109,10 +108,8 @@ void ImportImapSettingsAkonadiCheckJob::importSettings(const QString &directory,
config
.
sieveImapAccountSettings
.
setUserName
(
userName
);
config
.
sieveImapAccountSettings
.
setServerName
(
imapServerName
);
config
.
sieveImapAccountSettings
.
setPort
(
imapPort
);
config
.
sieveImapAccountSettings
.
setAuthenticationType
(
static_cast
<
KSieveUi
::
SieveImapAccountSettings
::
AuthenticationMode
>
(
networkGroup
.
readEntry
(
QStringLiteral
(
"Authentication"
),
static_cast
<
int
>
(
KSieveUi
::
SieveImapAccountSettings
::
Plain
))));
config
.
sieveImapAccountSettings
.
setAuthenticationType
(
static_cast
<
KSieveUi
::
SieveImapAccountSettings
::
AuthenticationMode
>
(
networkGroup
.
readEntry
(
QStringLiteral
(
"Authentication"
),
static_cast
<
int
>
(
KSieveUi
::
SieveImapAccountSettings
::
Plain
))));
const
QString
encryption
=
networkGroup
.
readEntry
(
QStringLiteral
(
"Safety"
));
if
(
encryption
==
QLatin1String
(
"SSL"
))
{
config
.
sieveImapAccountSettings
.
setEncryptionMode
(
KSieveUi
::
SieveImapAccountSettings
::
EncryptionMode
::
SSLorTLS
);
...
...
@@ -120,7 +117,7 @@ void ImportImapSettingsAkonadiCheckJob::importSettings(const QString &directory,
config
.
sieveImapAccountSettings
.
setEncryptionMode
(
KSieveUi
::
SieveImapAccountSettings
::
EncryptionMode
::
STARTTLS
);
}
else
if
(
encryption
==
QLatin1String
(
"None"
))
{
config
.
sieveImapAccountSettings
.
setEncryptionMode
(
KSieveUi
::
SieveImapAccountSettings
::
EncryptionMode
::
Unencrypted
);
}
else
if
(
encryption
.
isEmpty
())
{
//Default value
}
else
if
(
encryption
.
isEmpty
())
{
//
Default value
if
(
isKolabSettings
)
{
config
.
sieveImapAccountSettings
.
setEncryptionMode
(
KSieveUi
::
SieveImapAccountSettings
::
EncryptionMode
::
STARTTLS
);
}
else
{
...
...
@@ -136,14 +133,13 @@ void ImportImapSettingsAkonadiCheckJob::importSettings(const QString &directory,
if
(
reuseImapSettings
)
{
config
.
sieveSettings
.
serverName
=
imapServerName
;
config
.
sieveSettings
.
userName
=
userName
;
config
.
sieveSettings
.
authenticationType
=
static_cast
<
MailTransport
::
Transport
::
EnumAuthenticationType
::
type
>
(
sieveGroup
.
readEntry
(
QStringLiteral
(
"Authentication"
),
static_cast
<
int
>
(
MailTransport
::
Transport
::
EnumAuthenticationType
::
PLAIN
)));
config
.
sieveSettings
.
authenticationType
=
static_cast
<
MailTransport
::
Transport
::
EnumAuthenticationType
::
type
>
(
sieveGroup
.
readEntry
(
QStringLiteral
(
"Authentication"
),
static_cast
<
int
>
(
MailTransport
::
Transport
::
EnumAuthenticationType
::
PLAIN
)));
}
else
{
const
QString
sieveCustomUserName
=
sieveGroup
.
readEntry
(
QStringLiteral
(
"SieveCustomUsername"
));
config
.
sieveSettings
.
userName
=
sieveCustomUserName
;
config
.
sieveSettings
.
serverName
=
imapServerName
;
//FIXME
//TODO
config
.
sieveSettings
.
serverName
=
imapServerName
;
//
FIXME
//
TODO
}
Q_ASSERT_X
(
mPasswordImporter
,
"Missing mPasswordImporter"
,
"You must create a mPasswordImporter"
);
mPasswordImporter
->
importPasswords
(
config
,
filename
,
reuseImapSettings
);
...
...
@@ -174,6 +170,5 @@ QString ImportImapSettingsAkonadiCheckJob::name() const
void
ImportImapSettingsAkonadiCheckJob
::
setImapSettingsPassword
(
AbstractImapSettingsPassword
*
passwordImporter
)
{
mPasswordImporter
=
passwordImporter
;
connect
(
mPasswordImporter
,
&
AbstractImapSettingsPassword
::
importPasswordDone
,
this
,
&
ImportImapSettingsAkonadiCheckJob
::
slotImportNextServerSieveDone
);
connect
(
mPasswordImporter
,
&
AbstractImapSettingsPassword
::
importPasswordDone
,
this
,
&
ImportImapSettingsAkonadiCheckJob
::
slotImportNextServerSieveDone
);
}
src/importwizard/checks/importimapsettingsakonadicheckjob.h
View file @
f747d764
...
...
@@ -43,7 +43,6 @@ private:
void
importSettings
(
const
QString
&
directory
,
const
QString
&
filename
);
QMultiMap
<
QString
,
QString
>
mSieveServerLst
;
QMap
<
QString
,
QString
>::
const_iterator
mSieveServerMapIterator
;
};
#endif // IMPORTIMAPSETTINGSAKONADICHECKJOB_H
src/importwizard/checks/importimapsettingsakonadipassword.cpp
View file @
f747d764
...
...
@@ -18,8 +18,8 @@
*/
#include "importimapsettingsakonadipassword.h"
#include "sieveserversettings.h"
#include "sieveeditor_debug.h"
#include "sieveserversettings.h"
using
namespace
QKeychain
;
...
...
src/importwizard/checks/importimapsettingsakonadipassword.h
View file @
f747d764
...
...
@@ -31,6 +31,7 @@ public:
~
ImportImapSettingsAkonadiPassword
()
override
;
void
importPasswords
(
const
SieveEditorUtil
::
SieveServerConfig
&
config
,
const
QString
&
filename
,
bool
reuseImapSettings
)
override
;
private:
void
loadImapAccountSettings
();
void
readSieveServerPasswordFinished
(
QKeychain
::
Job
*
baseJob
);
...
...
src/importwizard/checks/importimapsettingsthunderbirdcheckjob.cpp
View file @
f747d764
...
...
@@ -19,9 +19,9 @@
#include "importimapsettingsthunderbirdcheckjob.h"
#include "sieveeditor_debug.h"
#include <KLocalizedString>
#include <KConfig>
#include <KConfigGroup>
#include <KLocalizedString>
#include <QDir>
#include <QFile>
#include <QRegularExpression>
...
...
@@ -37,13 +37,13 @@ ImportImapSettingsThunderbirdCheckJob::~ImportImapSettingsThunderbirdCheckJob()
{
}
//Copy from mailimporter
//
Copy from mailimporter
QMap
<
QString
,
QString
>
ImportImapSettingsThunderbirdCheckJob
::
listProfile
(
QString
&
currentProfile
,
const
QString
&
defaultSettingPath
)
{
const
QString
thunderbirdPath
=
defaultSettingPath
+
QLatin1String
(
"/profiles.ini"
);
QMap
<
QString
,
QString
>
lstProfile
;
if
(
QFileInfo
::
exists
(
thunderbirdPath
))
{
//ini file.
//
ini file.
KConfig
config
(
thunderbirdPath
);
const
QStringList
profileList
=
config
.
groupList
().
filter
(
QRegularExpression
(
QStringLiteral
(
"Profile
\\
d+"
)));
const
bool
uniqProfile
=
(
profileList
.
count
()
==
1
);
...
...
@@ -94,8 +94,8 @@ void ImportImapSettingsThunderbirdCheckJob::start()
bool
ImportImapSettingsThunderbirdCheckJob
::
importSettings
(
const
QString
&
directory
,
const
QString
&
defaultProfile
)
{
const
QString
filePath
=
directory
+
QLatin1Char
(
'/'
)
+
defaultProfile
+
QStringLiteral
(
"/prefs.js"
);
//qCDebug(SIEVEEDITOR_LOG) << "importSettings filename:" << filePath;
const
QString
filePath
=
directory
+
QLatin1Char
(
'/'
)
+
defaultProfile
+
QStringLiteral
(
"/prefs.js"
);
//
qCDebug(SIEVEEDITOR_LOG) << "importSettings filename:" << filePath;
QFile
file
(
filePath
);
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
qCWarning
(
SIEVEEDITOR_LOG
)
<<
"Unable to open file "
<<
filePath
;
...
...
@@ -105,17 +105,12 @@ bool ImportImapSettingsThunderbirdCheckJob::importSettings(const QString &direct
while
(
!
stream
.
atEnd
())
{
const
QString
line
=
stream
.
readLine
();
if
(
line
.
startsWith
(
QLatin1String
(
"user_pref"
)))
{
if
(
line
.
contains
(
QLatin1String
(
"mail.server."
))
||
line
.
contains
(
QLatin1String
(
"mail.account."
))
||
line
.
contains
(
QLatin1String
(
"mail.accountmanager."
))
||
line
.
contains
(
QLatin1String
(
"extensions.sieve.account."
)))
{
if
(
line
.
contains
(
QLatin1String
(
"mail.server."
))
||
line
.
contains
(
QLatin1String
(
"mail.account."
))
||
line
.
contains
(
QLatin1String
(
"mail.accountmanager."
))
||
line
.
contains
(
QLatin1String
(
"extensions.sieve.account."
)))
{
insertIntoMap
(
line
);
}
}
else
{
if
(
!
line
.
startsWith
(
QLatin1Char
(
'#'
))
&&
line
.
isEmpty
()
&&
line
.
startsWith
(
QLatin1String
(
"/*"
))
&&
line
.
startsWith
(
QLatin1String
(
" */"
))
if
(
!
line
.
startsWith
(
QLatin1Char
(
'#'
))
&&
line
.
isEmpty
()
&&
line
.
startsWith
(
QLatin1String
(
"/*"
))
&&
line
.
startsWith
(
QLatin1String
(
" */"
))
&&
line
.
startsWith
(
QLatin1String
(
" *"
)))
{
qCDebug
(
SIEVEEDITOR_LOG
)
<<
" unstored line :"
<<
line
;
}
...
...
@@ -134,32 +129,32 @@ bool ImportImapSettingsThunderbirdCheckJob::importSettings(const QString &direct
const
QString
accountName
=
QStringLiteral
(
"mail.server.%1"
).
arg
(
serverName
);
const
QString
type
=
mHashConfig
.
value
(
accountName
+
QStringLiteral
(
".type"
)).
toString
();
if
(
type
==
QLatin1String
(
"imap"
))
{
//Sieve settings == username@account
//
Sieve settings == username@account
const
QString
imapServerName
=
mHashConfig
.
value
(
accountName
+
QStringLiteral
(
".hostname"
)).
toString
();
QString
userName
=
mHashConfig
.
value
(
accountName
+
QStringLiteral
(
".userName"
)).
toString
();
//Convert @ in username in %40
//
Convert @ in username in %40
QString
userNameSieveConverted
=
userName
;
userNameSieveConverted
.
replace
(
QLatin1Char
(
'@'
),
QStringLiteral
(
"%40"
));
const
QString
sieveKeyServerUserName
=
QLatin1String
(
"extensions.sieve.account."
)
+
userNameSieveConverted
+
QLatin1Char
(
'@'
)
+
imapServerName
;
//user_pref("extensions.sieve.account.<username>@<server>.enabled", true);
//
user_pref("extensions.sieve.account.<username>@<server>.enabled", true);
if
(
mHashConfig
.
value
(
sieveKeyServerUserName
+
QStringLiteral
(
".enabled"
),
false
).
toBool
())
{
//TODO
//user_pref("extensions.sieve.account.<username>@<server>.TLS", true);
//user_pref("extensions.sieve.account.<username>@<server>.TLS.forced", true);
//user_pref("extensions.sieve.account.<username>@<server>.activeAuthorization", 1);
//user_pref("extensions.sieve.account.<username>@<server>.activeHost", 1);
//user_pref("extensions.sieve.account.<username>@<server>.activeLogin", 1);
//
TODO
//
user_pref("extensions.sieve.account.<username>@<server>.TLS", true);
//
user_pref("extensions.sieve.account.<username>@<server>.TLS.forced", true);
//
user_pref("extensions.sieve.account.<username>@<server>.activeAuthorization", 1);
//
user_pref("extensions.sieve.account.<username>@<server>.activeHost", 1);
//
user_pref("extensions.sieve.account.<username>@<server>.activeLogin", 1);
SieveEditorUtil
::
SieveServerConfig
config
;
//0 4190
//1 2000
//2 custom
//Default == 4190
//user_pref("extensions.sieve.account.<username>@<server>.port", 1255);
//
0 4190
//
1 2000
//
2 custom
//
Default == 4190
//
user_pref("extensions.sieve.account.<username>@<server>.port", 1255);
config
.
sieveSettings
.
port
=
mHashConfig
.
value
(
sieveKeyServerUserName
+
QStringLiteral
(
".port"
),
4190
).
toInt
();
//not necessary to import this one : user_pref("extensions.sieve.account.<username>@<server>.port.type", 1);
//
not necessary to import this one : user_pref("extensions.sieve.account.<username>@<server>.port.type", 1);
//user_pref("extensions.sieve.account.<username>@<server>.hostname", "sdfsfsqsdf");
//
user_pref("extensions.sieve.account.<username>@<server>.hostname", "sdfsfsqsdf");
const
QString
sieveHostName
=
mHashConfig
.
value
(
sieveKeyServerUserName
+
QStringLiteral
(
".hostname"
)).
toString
();
if
(
sieveHostName
.
isEmpty
())
{
config
.
sieveSettings
.
serverName
=
imapServerName
;
...
...
@@ -168,16 +163,16 @@ bool ImportImapSettingsThunderbirdCheckJob::importSettings(const QString &direct
}
const
QString
sieveUserName
=
mHashConfig
.
value
(
sieveKeyServerUserName
+
QStringLiteral
(
".login.username"
)).
toString
();
//user_pref("extensions.sieve.account.<username>@<server>.login.username", "newuser");
//
user_pref("extensions.sieve.account.<username>@<server>.login.username", "newuser");
if
(
sieveUserName
.
isEmpty
())
{
config
.
sieveSettings
.
userName
=
userName
;
}
else
{
config
.
sieveSettings
.
userName
=
sieveUserName
;
}
//not necessary to import this one : user_pref("extensions.sieve.account.<username>@<server>.proxy.type", 1);
//
not necessary to import this one : user_pref("extensions.sieve.account.<username>@<server>.proxy.type", 1);
//qCDebug(SIEVEEDITOR_LOG) << "imap account " << accountName;
//
qCDebug(SIEVEEDITOR_LOG) << "imap account " << accountName;
const
QString
name
=
mHashConfig
.
value
(
accountName
+
QStringLiteral
(
".name"
)).
toString
();
bool
found
;
const
int
sievePort
=
mHashConfig
.
value
(
accountName
+
QStringLiteral
(
".port"
)).
toInt
(
&
found
);
...
...
@@ -195,13 +190,13 @@ bool ImportImapSettingsThunderbirdCheckJob::importSettings(const QString &direct
}
}
}
else
{
//qCDebug(SIEVEEDITOR_LOG) << "Account " << accountName << " is not a imap account. Skip it.";
//
qCDebug(SIEVEEDITOR_LOG) << "Account " << accountName << " is not a imap account. Skip it.";
}
}
return
atLeastAnAccountFound
;
}
//Stolen from import-wizard
//
Stolen from import-wizard
void
ImportImapSettingsThunderbirdCheckJob
::
encryption
(
SieveEditorUtil
::
SieveServerConfig
&
config
,
const
QString
&
accountName
)
{
bool
found
;
...
...
@@ -209,15 +204,15 @@ void ImportImapSettingsThunderbirdCheckJob::encryption(SieveEditorUtil::SieveSer
if
(
found
)
{
switch
(
socketType
)
{
case
0
:
//None
//
None
config
.
sieveImapAccountSettings
.
setEncryptionMode
(
KSieveUi
::
SieveImapAccountSettings
::
EncryptionMode
::
Unencrypted
);
break
;
case
2
:
//STARTTLS
//
STARTTLS
config
.
sieveImapAccountSettings
.
setEncryptionMode
(
KSieveUi
::
SieveImapAccountSettings
::
EncryptionMode
::
STARTTLS
);
break
;
case
3
:
//SSL/TLS
//
SSL/TLS
config
.
sieveImapAccountSettings
.
setEncryptionMode
(
KSieveUi
::
SieveImapAccountSettings
::
EncryptionMode
::
SSLorTLS
);
break
;
default:
...
...
@@ -238,20 +233,20 @@ void ImportImapSettingsThunderbirdCheckJob::addAuth(SieveEditorUtil::SieveServer
case
0
:
config
.
sieveImapAccountSettings
.
setAuthenticationType
(
KSieveUi
::
SieveImapAccountSettings
::
Plain
);
break
;
case
4
:
//Encrypted password ???
case
4
:
//
Encrypted password ???
config
.
sieveImapAccountSettings
.
setAuthenticationType
(
KSieveUi
::
SieveImapAccountSettings
::
Login
);
qCDebug
(
SIEVEEDITOR_LOG
)
<<
" authmethod == encrypt password"
;
break
;
case
5
:
//GSSAPI
case
5
:
//
GSSAPI
config
.
sieveImapAccountSettings
.
setAuthenticationType
(
KSieveUi
::
SieveImapAccountSettings
::
GSSAPI
);
break
;
case
6
:
//NTLM
case
6
:
//
NTLM
config
.
sieveImapAccountSettings
.
setAuthenticationType
(
KSieveUi
::
SieveImapAccountSettings
::
NTLM
);
break
;
case
7
:
//TLS
case
7
:
//
TLS
qCDebug
(
SIEVEEDITOR_LOG
)
<<
" authmethod method == TLS"
;
//????
break
;
case
10
:
//OAuth2
case
10
:
//
OAuth2
config
.
sieveImapAccountSettings
.
setAuthenticationType
(
KSieveUi
::
SieveImapAccountSettings
::
XOAuth2
);
qCDebug
(
SIEVEEDITOR_LOG
)
<<
" authmethod method == OAuth2"
;
//????
break
;
...
...
@@ -280,7 +275,7 @@ void ImportImapSettingsThunderbirdCheckJob::insertIntoMap(const QString &line)
if
(
valueStr
.
at
(
pos
)
==
QLatin1Char
(
'"'
))
{
valueStr
.
remove
(
pos
,
1
);
}
//Store as String
//
Store as String
mHashConfig
.
insert
(
key
,
valueStr
);
}
else
{
if
(
valueStr
==
QLatin1String
(
"true"
))
{
...
...
@@ -288,7 +283,7 @@ void ImportImapSettingsThunderbirdCheckJob::insertIntoMap(const QString &line)
}
else
if
(
valueStr
==
QLatin1String
(
"false"
))
{
mHashConfig
.
insert
(
key
,
false
);
}
else
{
//Store as integer
//
Store as integer
const
int
value
=
valueStr
.
toInt
();
mHashConfig
.
insert
(
key
,
value
);
}
...
...
src/importwizard/checks/importimapsettingsthunderbirdcheckjob.h
View file @
f747d764
...
...
@@ -32,6 +32,7 @@ public:
void
start
()
override
;
Q_REQUIRED_RESULT
bool
settingsCanBeImported
()
const
override
;
Q_REQUIRED_RESULT
QString
name
()
const
override
;
private:
Q_REQUIRED_RESULT
bool
importSettings
(
const
QString
&
directory
,
const
QString
&
defaultProfile
);
Q_REQUIRED_RESULT
QMap
<
QString
,
QString
>
listProfile
(
QString
&
currentProfile
,
const
QString
&
defaultSettingPath
);
...
...
src/importwizard/importimapsettingfinishpage.cpp
View file @
f747d764
...
...
@@ -18,10 +18,10 @@
*/
#include "importimapsettingfinishpage.h"
#include <QVBoxLayout>
#include <KLocalizedString>
#include <QTextEdit>
#include <QLabel>
#include <QTextEdit>
#include <QVBoxLayout>
ImportImapSettingFinishPage
::
ImportImapSettingFinishPage
(
QWidget
*
parent
)
:
QWidget
(
parent
)
...
...
src/importwizard/importimapsettingnofoundpage.cpp
View file @
f747d764
...
...
@@ -18,9 +18,9 @@
*/
#include "importimapsettingnofoundpage.h"
#include <QVBoxLayout>
#include <QLabel>
#include <KLocalizedString>
#include <QLabel>
#include <QVBoxLayout>
ImportImapSettingNoFoundPage
::
ImportImapSettingNoFoundPage
(
QWidget
*
parent
)
:
QWidget
(
parent
)
...
...
src/importwizard/importimapsettingnofoundpage.h
View file @
f747d764
...
...
@@ -20,8 +20,8 @@
#ifndef IMPORTIMAPSETTINGNOFOUNDPAGE_H
#define IMPORTIMAPSETTINGNOFOUNDPAGE_H
#include <QWidget>
#include "libsieveeditor_private_export.h"
#include <QWidget>
class
LIBSIEVEEDITOR_TESTS_EXPORT
ImportImapSettingNoFoundPage
:
public
QWidget
{
...
...
src/importwizard/importimapsettingprogresspage.cpp
View file @
f747d764
...
...
@@ -18,11 +18,11 @@
*/
#include "importimapsettingprogresspage.h"
#include "sieveeditor_debug.h"
#include "checks/abstractimapsettingscheckjob.h"
#include
<QVBoxLayout>
#include
"sieveeditor_debug.h"
#include <KLocalizedString>