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
KMail Account Wizard
Commits
d7561188
Commit
d7561188
authored
Dec 03, 2020
by
Laurent Montel
😁
Browse files
Continue to implement async method
parent
dc980e4f
Pipeline
#42859
passed with stage
in 13 minutes and 8 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/restoreldapsettingsjob.cpp
View file @
d7561188
...
...
@@ -33,27 +33,46 @@ void RestoreLdapSettingsJob::start()
restore
();
}
void
RestoreLdapSettingsJob
::
restore
()
void
RestoreLdapSettingsJob
::
loadNextSelectHostSettings
()
{
if
(
mEntry
>=
0
)
{
KConfigGroup
group
=
mConfig
->
group
(
QStringLiteral
(
"LDAP"
));
const
int
cSelHosts
=
group
.
readEntry
(
QStringLiteral
(
"NumSelectedHosts"
),
0
);
const
int
cHosts
=
group
.
readEntry
(
QStringLiteral
(
"NumHosts"
),
0
);
for
(
int
i
=
0
;
i
<
cSelHosts
;
++
i
)
{
if
(
i
!=
mEntry
)
{
KLDAP
::
LdapServer
server
;
mClientSearchConfig
->
readConfig
(
server
,
group
,
i
,
true
);
mSelHosts
.
append
(
server
);
}
}
mHosts
.
reserve
(
cHosts
);
for
(
int
i
=
0
;
i
<
cHosts
;
++
i
)
{
if
(
mCurrentIndex
<
mNumSelHosts
)
{
if
(
mCurrentIndex
!=
mEntry
)
{
KLDAP
::
LdapServer
server
;
mClientSearchConfig
->
readConfig
(
server
,
group
,
i
,
false
);
mHosts
.
append
(
server
);
mClientSearchConfig
->
readConfig
(
server
,
mCurrentGroup
,
mCurrentIndex
,
true
);
mSelHosts
.
append
(
server
);
mCurrentIndex
++
;
loadNextSelectHostSettings
();
//Move async
}
else
{
mCurrentIndex
++
;
loadNextSelectHostSettings
();
}
}
else
{
//Reset index;
mCurrentIndex
=
0
;
loadNextHostSettings
();
}
}
void
RestoreLdapSettingsJob
::
loadNextHostSettings
()
{
if
(
mCurrentIndex
<
mNumHosts
)
{
KLDAP
::
LdapServer
server
;
mClientSearchConfig
->
readConfig
(
server
,
mCurrentGroup
,
mCurrentIndex
,
false
);
mHosts
.
append
(
server
);
mCurrentIndex
++
;
loadNextHostSettings
();
//Move async
}
else
{
saveLdapSettings
();
}
}
saveLdapSettings
(
cSelHosts
,
cHosts
);
void
RestoreLdapSettingsJob
::
restore
()
{
if
(
mEntry
>=
0
)
{
mCurrentGroup
=
mConfig
->
group
(
QStringLiteral
(
"LDAP"
));
mNumSelHosts
=
mCurrentGroup
.
readEntry
(
QStringLiteral
(
"NumSelectedHosts"
),
0
);
mNumHosts
=
mCurrentGroup
.
readEntry
(
QStringLiteral
(
"NumHosts"
),
0
);
loadNextSelectHostSettings
();
}
else
{
restoreSettingsDone
();
}
...
...
@@ -65,31 +84,32 @@ void RestoreLdapSettingsJob::restoreSettingsDone()
deleteLater
();
}
void
RestoreLdapSettingsJob
::
saveLdapSettings
(
int
cSelHosts
,
int
cHosts
)
void
RestoreLdapSettingsJob
::
saveLdapSettings
()
{
mConfig
->
deleteGroup
(
QStringLiteral
(
"LDAP"
));
KConfigGroup
g
roup
=
KConfigGroup
(
mConfig
,
QStringLiteral
(
"LDAP"
));
mCurrentG
roup
=
KConfigGroup
(
mConfig
,
QStringLiteral
(
"LDAP"
));
for
(
int
i
=
0
;
i
<
cSelHosts
-
1
;
++
i
)
{
//Move async
for
(
int
i
=
0
;
i
<
mNumSelHosts
-
1
;
++
i
)
{
auto
job
=
new
KLDAP
::
LdapClientSearchConfigWriteConfigJob
;
job
->
setActive
(
true
);
job
->
setConfig
(
g
roup
);
job
->
setConfig
(
mCurrentG
roup
);
job
->
setServer
(
mSelHosts
.
at
(
i
));
job
->
setServerIndex
(
i
);
job
->
start
();
}
for
(
int
i
=
0
;
i
<
c
Hosts
;
++
i
)
{
for
(
int
i
=
0
;
i
<
mNum
Hosts
;
++
i
)
{
auto
job
=
new
KLDAP
::
LdapClientSearchConfigWriteConfigJob
;
job
->
setActive
(
false
);
job
->
setConfig
(
g
roup
);
job
->
setConfig
(
mCurrentG
roup
);
job
->
setServer
(
mHosts
.
at
(
i
));
job
->
setServerIndex
(
i
);
job
->
start
();
}
g
roup
.
writeEntry
(
QStringLiteral
(
"NumSelectedHosts"
),
c
SelHosts
-
1
);
g
roup
.
writeEntry
(
QStringLiteral
(
"NumHosts"
),
c
Hosts
);
mCurrentG
roup
.
writeEntry
(
QStringLiteral
(
"NumSelectedHosts"
),
mNum
SelHosts
-
1
);
mCurrentG
roup
.
writeEntry
(
QStringLiteral
(
"NumHosts"
),
mNum
Hosts
);
mConfig
->
sync
();
restoreSettingsDone
();
}
...
...
src/restoreldapsettingsjob.h
View file @
d7561188
...
...
@@ -9,6 +9,7 @@
#include <QObject>
#include <KLDAP/LdapServer>
#include <KConfigGroup>
class
KConfig
;
namespace
KLDAP
{
class
LdapClientSearchConfig
;
...
...
@@ -34,12 +35,18 @@ Q_SIGNALS:
void
restoreDone
();
private:
void
restore
();
void
saveLdapSettings
(
int
cSelHosts
,
int
cHosts
);
void
saveLdapSettings
();
void
restoreSettingsDone
();
void
loadNextSelectHostSettings
();
void
loadNextHostSettings
();
QVector
<
KLDAP
::
LdapServer
>
mSelHosts
;
QVector
<
KLDAP
::
LdapServer
>
mHosts
;
int
mEntry
=
-
1
;
int
mNumSelHosts
=
-
1
;
int
mNumHosts
=
-
1
;
int
mCurrentIndex
=
0
;
KConfig
*
mConfig
=
nullptr
;
KConfigGroup
mCurrentGroup
;
KLDAP
::
LdapClientSearchConfig
*
mClientSearchConfig
=
nullptr
;
};
...
...
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