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
323b7c60
Commit
323b7c60
authored
Dec 02, 2020
by
Laurent Montel
😁
Browse files
Use directly restoreldapsettingsjob.h
parent
88eee532
Pipeline
#42747
passed with stage
in 13 minutes and 46 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/autotests/CMakeLists.txt
View file @
323b7c60
...
...
@@ -2,7 +2,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. ${accountwizard_BINARY_DIR}
add_definitions
(
-DTEST_DATA_DIR=
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/data"
)
add_definitions
(
-DCURRENT_SOURCE_DIR=
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
)
add_executable
(
ldaptest ldaptest.cpp ../ldap.cpp ../setupobject.cpp
)
add_executable
(
ldaptest ldaptest.cpp ../ldap.cpp ../setupobject.cpp
../restoreldapsettingsjob.cpp
)
add_test
(
NAME ldaptest COMMAND ldaptest
)
ecm_mark_as_test
(
ldaptest
)
...
...
src/ldap.cpp
View file @
323b7c60
...
...
@@ -5,6 +5,7 @@
*/
#include "ldap.h"
#include "restoreldapsettingsjob.h"
#include <KLDAP/LdapClientSearchConfig>
#include <KLDAP/AddHostDialog>
#include <KLDAP/LdapClientSearchConfigWriteConfigJob>
...
...
@@ -135,54 +136,19 @@ void Ldap::destroy()
Q_EMIT
info
(
i18n
(
"LDAP not configuring."
));
if
(
m_entry
>=
0
)
{
KConfig
*
c
=
config
();
KConfigGroup
group
=
c
->
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
!=
m_entry
)
{
KLDAP
::
LdapServer
server
;
m_clientSearchConfig
->
readConfig
(
server
,
group
,
i
,
true
);
selHosts
.
append
(
server
);
}
}
hosts
.
reserve
(
cHosts
);
for
(
int
i
=
0
;
i
<
cHosts
;
++
i
)
{
KLDAP
::
LdapServer
server
;
m_clientSearchConfig
->
readConfig
(
server
,
group
,
i
,
false
);
hosts
.
append
(
server
);
}
c
->
deleteGroup
(
QStringLiteral
(
"LDAP"
));
group
=
KConfigGroup
(
c
,
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
);
c
->
sync
();
Q_EMIT
info
(
i18n
(
"Removed LDAP entry."
));
auto
job
=
new
RestoreLdapSettingsJob
(
this
);
job
->
setEntry
(
m_entry
);
job
->
setConfig
(
c
);
connect
(
job
,
&
RestoreLdapSettingsJob
::
restoreDone
,
this
,
&
Ldap
::
slotRestoreDone
);
job
->
start
();
}
}
void
Ldap
::
slotRestoreDone
()
{
Q_EMIT
info
(
i18n
(
"Removed LDAP entry."
));
}
void
Ldap
::
edit
()
{
if
(
m_entry
<
0
)
{
...
...
src/ldap.h
View file @
323b7c60
...
...
@@ -49,6 +49,7 @@ protected:
KLDAP
::
LdapClientSearchConfig
*
const
m_clientSearchConfig
;
private:
friend
class
LdapTest
;
void
slotRestoreDone
();
QString
securityString
();
QString
m_user
;
...
...
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