25 #include <QtCore/QStringList>
27 using namespace KLDAP;
29 class LdapUrl::LdapUrlPrivate
37 QMap<QString, Extension> m_extensions;
38 QStringList m_attributes;
44 : d( new LdapUrlPrivate )
49 : KUrl( _url ), d( new LdapUrlPrivate )
52 if ( tmp.startsWith(
'/' ) ) {
60 : KUrl( that ), d( new LdapUrlPrivate )
67 if (
this == &that ) {
71 KUrl::operator=( that );
84 QString tmp = dn.toString();
85 if ( tmp.startsWith(
'/' ) ) {
94 if ( tmp.startsWith(
'/' ) ) {
103 return d->m_attributes;
136 return d->m_extensions.contains( key );
141 QMap<QString, Extension>::const_iterator it;
143 it = d->m_extensions.constFind( key );
144 if ( it != d->m_extensions.constEnd() ) {
149 ext.critical =
false;
159 critical = ext.critical;
165 d->m_extensions[ key ] = ext;
173 ext.critical = critical;
180 ext.value = QString::number( value );
181 ext.critical = critical;
187 d->m_extensions.remove( key );
194 QMap<QString, Extension>::const_iterator it;
198 if ( d->m_attributes.count() > 0 ) {
199 q += d->m_attributes.join(
"," );
204 switch ( d->m_scope ) {
218 if ( d->m_filter !=
"(objectClass=*)" && !d->m_filter.isEmpty() ) {
219 q += toPercentEncoding( d->m_filter );
224 for ( it = d->m_extensions.constBegin(); it != d->m_extensions.constEnd(); ++it ) {
225 if ( it.value().critical ) {
229 if ( !it.value().value.isEmpty() ) {
230 q +=
'=' + toPercentEncoding( it.value().value );
234 while ( q.endsWith(
'?' ) || q.endsWith(
',' ) ) {
235 q.remove( q.length() - 1, 1 );
239 kDebug() <<
"LDAP URL updateQuery():" << prettyUrl();
245 QStringList extensions;
248 if ( q.startsWith(
'?' ) ) {
253 QStringList url_items = q.split(
'?' );
255 d->m_attributes.clear();
257 d->m_filter =
"(objectClass=*)";
258 d->m_extensions.clear();
261 QStringList::const_iterator end( url_items.constEnd() );
262 for ( QStringList::const_iterator it=url_items.constBegin();
263 it != end; ++it, i++ ) {
266 d->m_attributes = ( *it ).split(
',', QString::SkipEmptyParts );
269 if ( ( *it ) == QLatin1String(
"sub" ) ) {
271 }
else if ( ( *it ) == QLatin1String(
"one" ) ) {
276 d->m_filter = fromPercentEncoding( ( *it ).toLatin1() );
279 extensions = ( *it ).split(
',', QString::SkipEmptyParts );
285 QStringList::const_iterator end2( extensions.constEnd() );
286 for ( QStringList::const_iterator it=extensions.constBegin();
288 ext.critical =
false;
289 name = fromPercentEncoding( ( *it ).section(
'=', 0, 0 ).toLatin1() ).toLower();
290 value = fromPercentEncoding( ( *it ).section(
'=', 1 ).toLatin1() );
291 if ( name.startsWith(
'!' ) ) {
295 kDebug() <<
"LdapUrl extensions name=" << name <<
"value:" << value;
296 ext.value = value.replace(
"%2",
"," );