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",
"," );
bool hasExtension(const QString &extension) const
Returns whether the specified extension exists in the LDAP url.
LdapUrl & operator=(const LdapUrl &other)
Overwrites the values of the LDAP url with values from an other url.
All levels below the url's level.
QString filter() const
Returns the filter part of the LDAP url.
void setScope(Scope scope)
Sets the scope part of the LDAP url.
QStringList attributes() const
Returns the attributes part of the LDAP url.
A special url class for LDAP.
void setDn(const LdapDN &dn)
Sets the dn part of the LDAP url.
A class holding the extension name and state whether the extension is critical.
void setAttributes(const QStringList &attributes)
Sets the attributes part of the LDAP url.
virtual ~LdapUrl()
Destroys the LDAP url.
Scope
Describes the scope of the LDAP url.
void setFilter(const QString &filter)
Sets the filter part of the LDAP url.
Scope scope() const
Returns the scope part of the LDAP url.
LdapUrl()
Constructs an empty LDAP url.
The level of the url and the one below.
void removeExtension(const QString &extension)
Removes the specified extension.
void updateQuery()
Updates the query component from the attributes, scope, filter and extensions.
void setExtension(const QString &key, const Extension &extension)
Sets the specified extension key with the value and criticality in extension.
void parseQuery()
Parses the query argument of the URL and makes it available via the attributes(), extension()...
Only the same level as the url.
LdapDN dn() const
Returns the dn part of the LDAP url.
Extension extension(const QString &extension) const
Returns the specified extension.