9#include "addhostdialog.h"
11#include "kldapcore/ldapserver.h"
12#include "kldapwidgets/ldapactivitiesabstractplugin.h"
13#include "kldapwidgets/ldapconfigwidget.h"
14#include <KAcceleratorManager>
15#include <KConfigGroup>
16#include <KLocalizedString>
17#include <KPluginFactory>
18#include <KPluginMetaData>
19#include <KSharedConfig>
20#include <KWindowConfig>
21#include <QDialogButtonBox>
29using namespace KLDAPWidgets;
32static const char myAddHostDialogPrivateGroupName[] =
"AddHostDialog";
34class KLDAPWidgets::AddHostDialogPrivate
42 ~AddHostDialogPrivate()
51 KLDAPWidgets::LdapActivitiesAbstractPlugin *mActivitiesPlugin =
nullptr;
54void AddHostDialog::readConfig()
63void AddHostDialog::writeConfig()
72 , d(new KLDAPWidgets::AddHostDialogPrivate(this))
74 setWindowTitle(
i18nc(
"@title:window",
"Add Host"));
78 d->mOkButton->setDefault(
true);
87 mainLayout->addWidget(d->mTabWidget);
88 d->mTabWidget->tabBar()->setExpanding(
true);
89 d->mTabWidget->setDocumentMode(
true);
90 d->mTabWidget->setTabBarAutoHide(
true);
93 d->mTabWidget->addTab(page,
i18n(
"Configure"));
95 const KPluginMetaData editWidgetPlugin(QStringLiteral(
"pim6/ldapactivities/kldapactivitiesplugin"));
97 const auto result = KPluginFactory::instantiatePlugin<KLDAPWidgets::LdapActivitiesAbstractPlugin>(editWidgetPlugin);
99 d->mActivitiesPlugin = result.plugin;
101 if (d->mActivitiesPlugin) {
102 d->mTabWidget->addTab(d->mActivitiesPlugin,
i18n(
"Activities"));
103 KLDAPWidgets::LdapActivitiesAbstractPlugin::ActivitySettings settings{
104 d->mServer->activities(),
105 d->mServer->enablePlasmaActivities(),
107 d->mActivitiesPlugin->setActivitiesSettings(settings);
110 mainLayout->addWidget(buttonBox);
112 layout->setContentsMargins({});
115 KLDAPWidgets::LdapConfigWidget::W_USER | KLDAPWidgets::LdapConfigWidget::W_PASS | KLDAPWidgets::LdapConfigWidget::W_BINDDN
116 | KLDAPWidgets::LdapConfigWidget::W_REALM | KLDAPWidgets::LdapConfigWidget::W_HOST | KLDAPWidgets::LdapConfigWidget::W_PORT
117 | KLDAPWidgets::LdapConfigWidget::W_VER | KLDAPWidgets::LdapConfigWidget::W_TIMELIMIT | KLDAPWidgets::LdapConfigWidget::W_SIZELIMIT
118 | KLDAPWidgets::LdapConfigWidget::W_PAGESIZE | KLDAPWidgets::LdapConfigWidget::W_DN | KLDAPWidgets::LdapConfigWidget::W_FILTER
119 | KLDAPWidgets::LdapConfigWidget::W_SECBOX | KLDAPWidgets::LdapConfigWidget::W_AUTHBOX,
122 layout->addWidget(d->mCfg);
123 d->mCfg->setHost(d->mServer->host());
124 d->mCfg->setPort(d->mServer->port());
125 d->mCfg->setDn(d->mServer->baseDn());
126 d->mCfg->setUser(d->mServer->user());
127 d->mCfg->setBindDn(d->mServer->bindDn());
128 d->mCfg->setPassword(d->mServer->password());
129 d->mCfg->setTimeLimit(d->mServer->timeLimit());
130 d->mCfg->setSizeLimit(d->mServer->sizeLimit());
131 d->mCfg->setPageSize(d->mServer->pageSize());
132 d->mCfg->setVersion(d->mServer->version());
133 d->mCfg->setFilter(d->mServer->filter());
134 switch (d->mServer->security()) {
135 case KLDAPCore::LdapServer::TLS:
136 d->mCfg->setSecurity(KLDAPWidgets::LdapConfigWidget::TLS);
138 case KLDAPCore::LdapServer::SSL:
139 d->mCfg->setSecurity(KLDAPWidgets::LdapConfigWidget::SSL);
142 d->mCfg->setSecurity(KLDAPWidgets::LdapConfigWidget::None);
145 switch (d->mServer->auth()) {
146 case KLDAPCore::LdapServer::Simple:
147 d->mCfg->setAuth(KLDAPWidgets::LdapConfigWidget::Simple);
149 case KLDAPCore::LdapServer::SASL:
150 d->mCfg->setAuth(KLDAPWidgets::LdapConfigWidget::SASL);
153 d->mCfg->setAuth(KLDAPWidgets::LdapConfigWidget::Anonymous);
155 d->mCfg->setMech(d->mServer->mech());
160 d->mOkButton->setEnabled(!d->mServer->host().isEmpty());
164AddHostDialog::~AddHostDialog()
169void AddHostDialog::slotHostEditChanged(
const QString &text)
171 d->mOkButton->setEnabled(!text.
isEmpty());
174void AddHostDialog::slotOk()
176 d->mServer->setHost(d->mCfg->host());
177 d->mServer->setPort(d->mCfg->port());
178 d->mServer->setBaseDn(d->mCfg->dn());
179 d->mServer->setUser(d->mCfg->user());
180 d->mServer->setBindDn(d->mCfg->bindDn());
181 d->mServer->setPassword(d->mCfg->password());
182 d->mServer->setTimeLimit(d->mCfg->timeLimit());
183 d->mServer->setSizeLimit(d->mCfg->sizeLimit());
184 d->mServer->setPageSize(d->mCfg->pageSize());
185 d->mServer->setVersion(d->mCfg->version());
186 d->mServer->setFilter(d->mCfg->filter());
187 switch (d->mCfg->security()) {
188 case KLDAPWidgets::LdapConfigWidget::TLS:
189 d->mServer->setSecurity(KLDAPCore::LdapServer::TLS);
191 case KLDAPWidgets::LdapConfigWidget::SSL:
192 d->mServer->setSecurity(KLDAPCore::LdapServer::SSL);
195 d->mServer->setSecurity(KLDAPCore::LdapServer::None);
197 switch (d->mCfg->auth()) {
198 case KLDAPWidgets::LdapConfigWidget::Simple:
199 d->mServer->setAuth(KLDAPCore::LdapServer::Simple);
201 case KLDAPWidgets::LdapConfigWidget::SASL:
202 d->mServer->setAuth(KLDAPCore::LdapServer::SASL);
205 d->mServer->setAuth(KLDAPCore::LdapServer::Anonymous);
207 d->mServer->setMech(d->mCfg->mech());
208 if (d->mActivitiesPlugin) {
209 const KLDAPWidgets::LdapActivitiesAbstractPlugin::ActivitySettings settings = d->mActivitiesPlugin->activitiesSettings();
210 d->mServer->setActivities(settings.activities);
211 d->mServer->setEnablePlasmaActivities(settings.enabled);
216#include "moc_addhostdialog.cpp"
static void manage(QWidget *widget, bool programmers_mode=false)
A class that contains LDAP server connection settings.
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
KCONFIGGUI_EXPORT void saveWindowSize(const QWindow *window, KConfigGroup &config, KConfigGroup::WriteConfigFlags options=KConfigGroup::Normal)
KCONFIGGUI_EXPORT void restoreWindowSize(QWindow *window, const KConfigGroup &config)
bool isEmpty() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void resize(const QSize &newSize)