diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4358fea3..e36f5dd8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,129 +1,128 @@ set(vcardparser_SRCS vcardparser/vcard.cpp vcardparser/vcardline.cpp vcardparser/vcardparser.cpp ) set(kcontacts_SRCS address.cpp addressee.cpp addresseehelper.cpp calendarurl.cpp contactgroup.cpp contactgrouptool.cpp email.cpp field.cpp geo.cpp gender.cpp impp.cpp key.cpp lang.cpp - ldapdn.cpp ldif.cpp phonenumber.cpp picture.cpp related.cpp resourcelocatorurl.cpp secrecy.cpp sound.cpp timezone.cpp vcarddrag.cpp vcardtool.cpp fieldgroup.cpp title.cpp nickname.cpp role.cpp note.cpp org.cpp clientpidmap.cpp ${vcardparser_SRCS} kcontacts.qrc ) set(kcontacts_converter_SRCS converter/vcardconverter.cpp converter/ldifconverter.cpp ) ecm_qt_declare_logging_category(kcontacts_converter_SRCS HEADER kcontacts_debug.h IDENTIFIER KCONTACTS_LOG CATEGORY_NAME org.kde.pim.kcontacts) add_library(KF5Contacts ${kcontacts_SRCS} ${kcontacts_converter_SRCS}) generate_export_header(KF5Contacts BASE_NAME kcontacts) add_library(KF5::Contacts ALIAS KF5Contacts) target_include_directories(KF5Contacts INTERFACE "$") target_include_directories(KF5Contacts PUBLIC "$") target_include_directories(KF5Contacts PUBLIC "$") target_link_libraries(KF5Contacts PUBLIC KF5::CoreAddons PRIVATE Qt5::Gui KF5::ConfigCore KF5::I18n KF5::Codecs # for the vcard parser ) set_target_properties(KF5Contacts PROPERTIES VERSION ${KContacts_VERSION_STRING} SOVERSION ${KContacts_SOVERSION} EXPORT_NAME Contacts ) install(TARGETS KF5Contacts EXPORT KF5ContactsTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) ecm_generate_headers(KContacts_CamelCase_HEADERS HEADER_NAMES Address Addressee AddresseeList CalendarUrl ContactGroup ContactGroupTool Email Field Geo Gender Key Lang Impp PhoneNumber Picture Related ResourceLocatorUrl Secrecy Sound TimeZone Title Role Note Org NickName VCardDrag FieldGroup ClientPidMap PREFIX KContacts REQUIRED_HEADERS KContacts_HEADERS ) add_subdirectory(converter) add_subdirectory(generator) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kcontacts_export.h ${KContacts_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KContacts/kcontacts COMPONENT Devel ) install(FILES ${KContacts_CamelCase_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KContacts/KContacts COMPONENT Devel ) ecm_generate_pri_file(BASE_NAME KContacts LIB_NAME KF5Contacts DEPS "CoreAddons" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/KContacts) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) diff --git a/src/ldapdn.cpp b/src/ldapdn.cpp deleted file mode 100644 index 90dd1047..00000000 --- a/src/ldapdn.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/* - A temporary copy to break dependency to KLDAP - - This file is part of libkldap. - Copyright (c) 2006 Sean Harmer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "ldapdn_p.h" - -#include - -#include "kcontacts_debug.h" - -class Q_DECL_HIDDEN LdapDN::LdapDNPrivate -{ -public: - LdapDNPrivate() : m_dn() - { - } - - ~LdapDNPrivate() - { - } - - bool isValidRDNString(const QString &rdn) const; - QStringList splitOnNonEscapedChar(const QString &rdn, QChar ch) const; - - QString m_dn; -}; - -bool LdapDN::LdapDNPrivate::isValidRDNString(const QString &rdn) const -{ - qCDebug(KCONTACTS_LOG) << "Testing rdn:" << rdn; - - // If it is a muli-valued rdn, split it into its constituent parts - QStringList rdnParts = splitOnNonEscapedChar(rdn, QLatin1Char('+')); - const int numberOfParts(rdnParts.size()); - if (numberOfParts > 1) { - for (int i = 0; i < numberOfParts; i++) { - if (!isValidRDNString(rdnParts.at(i))) { - return false; - } - } - return true; - } - - // Split the rdn into the attribute name and value parts - const QVector components = rdn.splitRef(QLatin1Char('=')); - - // We should have exactly two parts - if (components.size() != 2) { - return false; - } - - return true; -} - -QStringList LdapDN::LdapDNPrivate::splitOnNonEscapedChar(const QString &str, QChar ch) const -{ - QStringList strParts; - int index = 0; - int searchFrom = 0; - int strPartStartIndex = 0; - while ((index = str.indexOf(ch, searchFrom)) != -1) { - const QChar prev = str[std::max(0, index - 1)]; - if (prev != QLatin1Char('\\')) { - // Found a component of a multi-valued RDN - //qCDebug(KCONTACTS_LOG) << "Found" << ch << "at index" << index; - QString tmp = str.mid(strPartStartIndex, index - strPartStartIndex); - //qCDebug(KCONTACTS_LOG) << "Adding part:" << tmp; - strParts.append(tmp); - strPartStartIndex = index + 1; - } - - searchFrom = index + 1; - } - - // Add on the part after the last found delimeter - QString tmp = str.mid(strPartStartIndex); - //qCDebug(KCONTACTS_LOG) << "Adding part:" << tmp; - strParts.append(tmp); - - return strParts; -} - -LdapDN::LdapDN() - : d(new LdapDNPrivate) -{ -} - -LdapDN::LdapDN(const QString &dn) - : d(new LdapDNPrivate) -{ - d->m_dn = dn; -} - -LdapDN::LdapDN(const LdapDN &that) - : d(new LdapDNPrivate) -{ - *d = *that.d; -} - -LdapDN &LdapDN::operator=(const LdapDN &that) -{ - if (this == &that) { - return *this; - } - - *d = *that.d; - return *this; -} - -LdapDN::~LdapDN() -{ - delete d; -} - -void LdapDN::clear() -{ - d->m_dn.clear(); -} - -bool LdapDN::isEmpty() const -{ - return d->m_dn.isEmpty(); -} - -QString LdapDN::toString() const -{ - return d->m_dn; -} - -QString LdapDN::toString(int depth) const -{ - QStringList rdns = d->splitOnNonEscapedChar(d->m_dn, QLatin1Char(',')); - if (depth >= rdns.size()) { - return QString(); - } - - // Construct a DN down to the requested depth - QString dn; - for (int i = depth; i >= 0; i--) { - dn += rdns.at(rdns.size() - 1 - i) + QLatin1Char(','); - qCDebug(KCONTACTS_LOG) << "dn =" << dn; - } - dn = dn.left(dn.length() - 1); // Strip off the extraneous comma - - return dn; -} - -QString LdapDN::rdnString() const -{ - /** \TODO We should move this into the d pointer as we calculate rdns quite a lot */ - QStringList rdns = d->splitOnNonEscapedChar(d->m_dn, QLatin1Char(',')); - return rdns.at(0); -} - -QString LdapDN::rdnString(int depth) const -{ - QStringList rdns = d->splitOnNonEscapedChar(d->m_dn, QLatin1Char(',')); - const int numberOfRdns(rdns.size()); - if (depth >= numberOfRdns) { - return QString(); - } - return rdns.at(numberOfRdns - 1 - depth); -} - -bool LdapDN::isValid() const -{ - qCDebug(KCONTACTS_LOG) << "Testing dn:" << d->m_dn; - - // Break the string into rdn's - QStringList rdns = d->splitOnNonEscapedChar(d->m_dn, QLatin1Char(',')); - - // Test to see if each rdn is valid - for (int i = 0; i < rdns.size(); i++) { - if (!d->isValidRDNString(rdns.at(i))) { - return false; - } - } - - return true; -} - -int LdapDN::depth() const -{ - QStringList rdns = d->splitOnNonEscapedChar(d->m_dn, QLatin1Char(',')); - return rdns.size(); -} - -bool LdapDN::operator ==(const LdapDN &rhs) const -{ - return d->m_dn == rhs.d->m_dn; -} - -bool LdapDN::operator !=(const LdapDN &rhs) const -{ - return d->m_dn != rhs.d->m_dn; -} diff --git a/src/ldapdn_p.h b/src/ldapdn_p.h deleted file mode 100644 index 5ee5f5cf..00000000 --- a/src/ldapdn_p.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - A temporary copy to break dependency to KLDAP - - This file is part of libkldap. - Copyright (c) 2006 Sean Harmer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef LDAPDN_P_H -#define LDAPDN_P_H - -#include - -class LdapDN -{ -public: - explicit LdapDN(); - explicit LdapDN(const QString &dn); - - LdapDN(const LdapDN &that); - LdapDN &operator=(const LdapDN &that); - - ~LdapDN(); - - void clear(); - - bool isEmpty() const; - - /** - * \returns A QString representing the DN. - */ - QString toString() const; - - /** - * \param depth The depth of the DN to return using a zero-based index. - * \returns A QString representing the DN levels deep in the directory. - */ - QString toString(int depth) const; - - /** - * \returns A QString representing the RDN of this DN. - */ - QString rdnString() const; - - /** - * \param depth The depth of the RDN to return using a zero-based index. - * \returns A QString representing the RDN levels deep in the directory. - */ - QString rdnString(int depth) const; - - /** - * \returns True if this is a valid DN, false otherwise. - */ - bool isValid() const; - - /** - * \returns The depth of this DN in the directory. - */ - int depth() const; - - bool operator==(const LdapDN &rhs) const; - - bool operator!=(const LdapDN &rhs) const; - -private: - class LdapDNPrivate; - LdapDNPrivate *const d; -}; - -#endif diff --git a/src/ldif.cpp b/src/ldif.cpp index 72293d53..e38e1900 100644 --- a/src/ldif.cpp +++ b/src/ldif.cpp @@ -1,447 +1,441 @@ /* A temporary copy to break dependency to KLDAP This file is part of libkldap. Copyright (c) 2004-2006 Szombathelyi György This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "ldif_p.h" #include "kcontacts_debug.h" class Q_DECL_HIDDEN Ldif::LdifPrivate { public: int mModType; bool mDelOldRdn, mUrl; - LdapDN mDn; + QByteArray mDn; QString mAttr, mNewRdn, mNewSuperior, mOid; QByteArray mLdif, mValue; EntryType mEntryType; bool mIsNewLine, mIsComment, mCritical; ParseValue mLastParseValue; uint mPos, mLineNumber; QByteArray mLine; }; Ldif::Ldif() : d(new LdifPrivate) { startParsing(); } Ldif::Ldif(const Ldif &that) : d(new LdifPrivate) { *d = *that.d; startParsing(); } Ldif &Ldif::operator=(const Ldif &that) { if (this == &that) { return *this; } *d = *that.d; return *this; } Ldif::~Ldif() { delete d; } QByteArray Ldif::assembleLine(const QString &fieldname, const QByteArray &value, uint linelen, bool url) { QByteArray result; if (url) { result = fieldname.toUtf8() + ":< " + value; } else { bool safe = false; bool isDn = fieldname.toLower() == QLatin1String("dn"); //SAFE-INIT-CHAR if (value.size() > 0 && value[0] > 0 && value[0] != '\n' && value[0] != '\r' && value[0] != ':' && value[0] != '<') { safe = true; } //SAFE-CHAR if (safe) { for (int i = 1; i < value.size(); ++i) { //allow utf-8 in Distinguished Names if ((isDn && value[i] == 0) || (!isDn && value[i] <= 0) || value[i] == '\r' || value[i] == '\n') { safe = false; break; } } } if (value.isEmpty()) { safe = true; } if (safe) { result = fieldname.toUtf8() + ": " + value; } else { result = fieldname.toUtf8() + ":: " + value.toBase64(); } if (linelen > 0) { int i = (uint)(fieldname.length() + 2) > linelen ? fieldname.length() + 2 : linelen; while (i < result.length()) { result.insert(i, "\n "); i += linelen + 2; } } } return result; } QByteArray Ldif::assembleLine(const QString &fieldname, const QString &value, uint linelen, bool url) { return assembleLine(fieldname, value.toUtf8(), linelen, url); } bool Ldif::splitLine(const QByteArray &line, QString &fieldname, QByteArray &value) { int position; QByteArray tmp; int linelen; // qCDebug(KCONTACTS_LOG) << "line:" << QString::fromUtf8(line); position = line.indexOf(":"); if (position == -1) { // strange: we did not find a fieldname fieldname = QLatin1String(""); value = line.trimmed(); // qCDebug(KCONTACTS_LOG) << "value :" << value[0]; return false; } linelen = line.size(); fieldname = QString::fromUtf8(line.left(position).trimmed()); if (linelen > (position + 1) && line[ position + 1 ] == ':') { // String is BASE64 encoded -> decode it now. if (linelen <= (position + 3)) { value.resize(0); return false; } value = QByteArray::fromBase64(line.mid(position + 3)); return false; } if (linelen > (position + 1) && line[ position + 1 ] == '<') { // String is an URL. if (linelen <= (position + 3)) { value.resize(0); return false; } value = QByteArray::fromBase64(line.mid(position + 3)); return true; } if (linelen <= (position + 2)) { value.resize(0); return false; } value = line.mid(position + 2); return false; } bool Ldif::splitControl(const QByteArray &line, QString &oid, bool &critical, QByteArray &value) { QString tmp; critical = false; bool url = splitLine(line, tmp, value); qCDebug(KCONTACTS_LOG) << "value:" << QString::fromUtf8(value); if (tmp.isEmpty()) { tmp = QString::fromUtf8(value); value.resize(0); } if (tmp.endsWith(QLatin1String("true"))) { critical = true; tmp.truncate(tmp.length() - 5); } else if (tmp.endsWith(QLatin1String("false"))) { critical = false; tmp.truncate(tmp.length() - 6); } oid = tmp; return url; } Ldif::ParseValue Ldif::processLine() { if (d->mIsComment) { return None; } ParseValue retval = None; if (d->mLastParseValue == EndEntry) { d->mEntryType = Entry_None; } d->mUrl = splitLine(d->mLine, d->mAttr, d->mValue); QString attrLower = d->mAttr.toLower(); switch (d->mEntryType) { case Entry_None: if (attrLower == QLatin1String("version")) { if (!d->mDn.isEmpty()) { retval = Err; } } else if (attrLower == QLatin1String("dn")) { qCDebug(KCONTACTS_LOG) << "ldapentry dn:" << QString::fromUtf8(d->mValue); - d->mDn = LdapDN(QString::fromUtf8(d->mValue)); + d->mDn = d->mValue; d->mModType = Mod_None; retval = NewEntry; } else if (attrLower == QLatin1String("changetype")) { if (d->mDn.isEmpty()) { retval = Err; } else { QString tmpval = QString::fromUtf8(d->mValue); qCDebug(KCONTACTS_LOG) << "changetype:" << tmpval; if (tmpval == QLatin1String("add")) { d->mEntryType = Entry_Add; } else if (tmpval == QLatin1String("delete")) { d->mEntryType = Entry_Del; } else if (tmpval == QLatin1String("modrdn") || tmpval == QLatin1String("moddn")) { d->mNewRdn = QLatin1String(""); d->mNewSuperior = QLatin1String(""); d->mDelOldRdn = true; d->mEntryType = Entry_Modrdn; } else if (tmpval == QLatin1String("modify")) { d->mEntryType = Entry_Mod; } else { retval = Err; } } } else if (attrLower == QLatin1String("control")) { d->mUrl = splitControl(d->mValue, d->mOid, d->mCritical, d->mValue); retval = Control; } else if (!d->mAttr.isEmpty() && !d->mValue.isEmpty()) { d->mEntryType = Entry_Add; retval = Item; } break; case Entry_Add: if (d->mAttr.isEmpty() && d->mValue.isEmpty()) { retval = EndEntry; } else { retval = Item; } break; case Entry_Del: if (d->mAttr.isEmpty() && d->mValue.isEmpty()) { retval = EndEntry; } else { retval = Err; } break; case Entry_Mod: if (d->mModType == Mod_None) { qCDebug(KCONTACTS_LOG) << "new modtype" << d->mAttr; if (d->mAttr.isEmpty() && d->mValue.isEmpty()) { retval = EndEntry; } else if (attrLower == QLatin1String("add")) { d->mModType = Mod_Add; } else if (attrLower == QLatin1String("replace")) { d->mModType = Mod_Replace; d->mAttr = QString::fromUtf8(d->mValue); d->mValue = QByteArray(); retval = Item; } else if (attrLower == QLatin1String("delete")) { d->mModType = Mod_Del; d->mAttr = QString::fromUtf8(d->mValue); d->mValue = QByteArray(); retval = Item; } else { retval = Err; } } else { if (d->mAttr.isEmpty()) { if (QString::fromUtf8(d->mValue) == QLatin1String("-")) { d->mModType = Mod_None; } else if (d->mValue.isEmpty()) { retval = EndEntry; } else { retval = Err; } } else { retval = Item; } } break; case Entry_Modrdn: if (d->mAttr.isEmpty() && d->mValue.isEmpty()) { retval = EndEntry; } else if (attrLower == QLatin1String("newrdn")) { d->mNewRdn = QString::fromUtf8(d->mValue); } else if (attrLower == QLatin1String("newsuperior")) { d->mNewSuperior = QString::fromUtf8(d->mValue); } else if (attrLower == QLatin1String("deleteoldrdn")) { if (d->mValue.size() > 0 && d->mValue[0] == '0') { d->mDelOldRdn = false; } else if (d->mValue.size() > 0 && d->mValue[0] == '1') { d->mDelOldRdn = true; } else { retval = Err; } } else { retval = Err; } break; } return retval; } Ldif::ParseValue Ldif::nextItem() { ParseValue retval = None; char c = 0; while (retval == None) { if (d->mPos < (uint)d->mLdif.size()) { c = d->mLdif[d->mPos]; d->mPos++; if (d->mIsNewLine && c == '\r') { continue; //handle \n\r line end } if (d->mIsNewLine && (c == ' ' || c == '\t')) { //line folding d->mIsNewLine = false; continue; } if (d->mIsNewLine) { d->mIsNewLine = false; retval = processLine(); d->mLastParseValue = retval; d->mLine.resize(0); d->mIsComment = (c == '#'); } if (c == '\n' || c == '\r') { d->mLineNumber++; d->mIsNewLine = true; continue; } } else { retval = MoreData; break; } if (!d->mIsComment) { d->mLine += c; } } return retval; } void Ldif::endLdif() { QByteArray tmp(3, '\n'); d->mLdif = tmp; d->mPos = 0; } void Ldif::startParsing() { d->mPos = d->mLineNumber = 0; d->mDelOldRdn = false; d->mEntryType = Entry_None; d->mModType = Mod_None; - d->mDn = LdapDN(); d->mNewRdn.clear(); d->mNewSuperior.clear(); d->mLine = QByteArray(); d->mIsNewLine = false; d->mIsComment = false; d->mLastParseValue = None; } void Ldif::setLdif(const QByteArray &ldif) { d->mLdif = ldif; d->mPos = 0; } Ldif::EntryType Ldif::entryType() const { return d->mEntryType; } int Ldif::modType() const { return d->mModType; } -LdapDN Ldif::dn() const -{ - return d->mDn; -} - QString Ldif::newRdn() const { return d->mNewRdn; } QString Ldif::newSuperior() const { return d->mNewSuperior; } bool Ldif::delOldRdn() const { return d->mDelOldRdn; } QString Ldif::attr() const { return d->mAttr; } QByteArray Ldif::value() const { return d->mValue; } bool Ldif::isUrl() const { return d->mUrl; } bool Ldif::isCritical() const { return d->mCritical; } QString Ldif::oid() const { return d->mOid; } uint Ldif::lineNumber() const { return d->mLineNumber; } diff --git a/src/ldif_p.h b/src/ldif_p.h index fce895a7..1cd78175 100644 --- a/src/ldif_p.h +++ b/src/ldif_p.h @@ -1,191 +1,184 @@ /* A temporary copy to break dependency to KLDAP This file is part of libkldap. Copyright (c) 2004-2006 Szombathelyi György This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LDIF_P_H #define LDIF_P_H #include #include -#include "ldapdn_p.h" - /** * Ldif * * Ldif implements an RFC 2849 compliant Ldif parser. Ldif files are used to * represent directory information on LDAP-based servers, or to describe a set * of changes which are to be applied to a directory. */ class Ldif { public: typedef enum { None, NewEntry, EndEntry, Item, Control, Err, MoreData } ParseValue; typedef enum { Entry_None, Entry_Add, Entry_Del, Entry_Mod, Entry_Modrdn } EntryType; typedef enum { Mod_None, Mod_Add, Mod_Replace, Mod_Del } ModType; Ldif(); Ldif(const Ldif &that); Ldif &operator=(const Ldif &that); virtual ~Ldif(); /** * Assembles fieldname and value into a valid Ldif line, BASE64 encodes the * value if necessary and optionally splits into more lines. * @param fieldname The name of the entry. * @param value The value of the entry. * @param linelen Maximum length of the lines in the result. * @param url If true, encode value as url ( use :< ). */ static QByteArray assembleLine(const QString &fieldname, const QByteArray &value, uint linelen = 0, bool url = false); /** * This is the same as the above function, the only difference that * this accepts QString as the value. */ static QByteArray assembleLine(const QString &fieldname, const QString &value, uint linelen = 0, bool url = false); /** * Splits one line from an Ldif file to attribute and value components. * @return true if value is an URL, false otherwise */ static bool splitLine(const QByteArray &line, QString &fieldname, QByteArray &value); /** * Splits a control specification (without the "control:" directive) * @param line is the control directive * @param oid will contain the OID * @param critical will contain the criticality of control * @param value is the control value */ static bool splitControl(const QByteArray &line, QString &oid, bool &critical, QByteArray &value); /** * Starts the parsing of a new Ldif */ void startParsing(); /** * Process one Ldif line */ ParseValue processLine(); /** * Process the Ldif until a complete item can be returned * @return NewEntry if a new DN encountered, Item if a new item returned, * Err if the Ldif contains error, EndEntry if the parser reached the end * of the current entry and MoreData if the parser encountered the end of * the current chunk of the Ldif. * * If you want to finish the parsing after receiving MoreData, then call * endLdif(), so the parser can safely flush the current entry. */ ParseValue nextItem(); /** * Sets a chunk of Ldif. Call before startParsing(), or if nextItem() * returned MoreData. */ void setLdif(const QByteArray &ldif); /** * Indicates the end of the Ldif file/stream. Call if nextItem() returned * MoreData, but actually you don't have more data. */ void endLdif(); /** * Returns the requested LDAP operation extracted from the current entry. */ EntryType entryType() const; /** * Returns the LDAP modify request type if entryType() returned Entry_Mod. */ int modType() const; - /** - * Returns the Distinguished Name of the current entry. - */ - LdapDN dn() const; - /** * Returns the new Relative Distinguished Name if modType() returned * Entry_Modrdn. */ QString newRdn() const; /** * Returns the new parent of the entry if modType() returned Entry_Modrdn. */ QString newSuperior() const; /** * Returns if the delete of the old RDN is required. */ bool delOldRdn() const; /** * Returns the attribute name. */ QString attr() const; /** * Returns the attribute value. */ QByteArray value() const; /** * Returns if val() is an url */ bool isUrl() const; /** * Returns the criticality level when modType() returned Control. */ bool isCritical() const; /** * Returns the OID when modType() returned Control. */ QString oid() const; /** * Returns the line number which the parser processes. */ uint lineNumber() const; private: class LdifPrivate; LdifPrivate *const d; }; #endif