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
88eee532
Commit
88eee532
authored
Dec 01, 2020
by
Laurent Montel
😁
Browse files
Continue to implement it
parent
274ab848
Pipeline
#42639
passed with stage
in 13 minutes and 21 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/restoreldapsettingsjob.cpp
View file @
88eee532
...
...
@@ -6,6 +6,7 @@
#include
"restoreldapsettingsjob.h"
#include
<KLDAP/LdapClientSearchConfigWriteConfigJob>
#include
<KLDAP/LdapClientSearchConfig>
#include
<KConfigGroup>
#include
<KConfig>
#include
<QDebug>
...
...
@@ -29,10 +30,82 @@ void RestoreLdapSettingsJob::start()
Q_EMIT
restoreDone
();
return
;
}
restore
();
}
void
RestoreLdapSettingsJob
::
restore
()
{
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
);
QVector
<
KLDAP
::
LdapServer
>
selHosts
;
QVector
<
KLDAP
::
LdapServer
>
hosts
;
for
(
int
i
=
0
;
i
<
cSelHosts
;
++
i
)
{
if
(
i
!=
mEntry
)
{
KLDAP
::
LdapServer
server
;
mClientSearchConfig
->
readConfig
(
server
,
group
,
i
,
true
);
selHosts
.
append
(
server
);
}
}
hosts
.
reserve
(
cHosts
);
for
(
int
i
=
0
;
i
<
cHosts
;
++
i
)
{
KLDAP
::
LdapServer
server
;
mClientSearchConfig
->
readConfig
(
server
,
group
,
i
,
false
);
hosts
.
append
(
server
);
}
mConfig
->
deleteGroup
(
QStringLiteral
(
"LDAP"
));
group
=
KConfigGroup
(
mConfig
,
QStringLiteral
(
"LDAP"
));
for
(
int
i
=
0
;
i
<
cSelHosts
-
1
;
++
i
)
{
auto
job
=
new
KLDAP
::
LdapClientSearchConfigWriteConfigJob
;
job
->
setActive
(
true
);
job
->
setConfig
(
group
);
job
->
setServer
(
selHosts
.
at
(
i
));
job
->
setServerIndex
(
i
);
job
->
start
();
}
for
(
int
i
=
0
;
i
<
cHosts
;
++
i
)
{
auto
job
=
new
KLDAP
::
LdapClientSearchConfigWriteConfigJob
;
job
->
setActive
(
false
);
job
->
setConfig
(
group
);
job
->
setServer
(
hosts
.
at
(
i
));
job
->
setServerIndex
(
i
);
job
->
start
();
}
group
.
writeEntry
(
QStringLiteral
(
"NumSelectedHosts"
),
cSelHosts
-
1
);
group
.
writeEntry
(
QStringLiteral
(
"NumHosts"
),
cHosts
);
mConfig
->
sync
();
Q_EMIT
restoreDone
();
}
//TODO
deleteLater
();
}
KLDAP
::
LdapClientSearchConfig
*
RestoreLdapSettingsJob
::
clientSearchConfig
()
const
{
return
mClientSearchConfig
;
}
void
RestoreLdapSettingsJob
::
setClientSearchConfig
(
KLDAP
::
LdapClientSearchConfig
*
clientSearchConfig
)
{
mClientSearchConfig
=
clientSearchConfig
;
}
int
RestoreLdapSettingsJob
::
entry
()
const
{
return
mEntry
;
}
void
RestoreLdapSettingsJob
::
setEntry
(
int
entry
)
{
mEntry
=
entry
;
}
KConfig
*
RestoreLdapSettingsJob
::
config
()
const
{
return
mConfig
;
...
...
@@ -45,5 +118,5 @@ void RestoreLdapSettingsJob::setConfig(KConfig *config)
bool
RestoreLdapSettingsJob
::
canStart
()
const
{
return
(
mConfig
!=
nullptr
);
return
(
mConfig
!=
nullptr
)
&&
(
mEntry
!=
-
1
)
&&
mClientSearchConfig
;
}
src/restoreldapsettingsjob.h
View file @
88eee532
...
...
@@ -10,6 +10,9 @@
#include
<QObject>
#include
<KLDAP/LdapServer>
class
KConfig
;
namespace
KLDAP
{
class
LdapClientSearchConfig
;
}
class
RestoreLdapSettingsJob
:
public
QObject
{
Q_OBJECT
...
...
@@ -21,12 +24,21 @@ public:
KConfig
*
config
()
const
;
void
setConfig
(
KConfig
*
config
);
Q_REQUIRED_RESULT
bool
canStart
()
const
;
Q_REQUIRED_RESULT
int
entry
()
const
;
void
setEntry
(
int
entry
);
KLDAP
::
LdapClientSearchConfig
*
clientSearchConfig
()
const
;
void
setClientSearchConfig
(
KLDAP
::
LdapClientSearchConfig
*
clientSearchConfig
);
Q_SIGNALS:
void
restoreDone
();
private:
void
restore
();
QVector
<
KLDAP
::
LdapServer
>
mSelHosts
;
QVector
<
KLDAP
::
LdapServer
>
mHosts
;
int
mEntry
=
-
1
;
KConfig
*
mConfig
=
nullptr
;
KLDAP
::
LdapClientSearchConfig
*
mClientSearchConfig
=
nullptr
;
};
#endif // RESTORELDAPSETTINGSJOB_H
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