1/*
2 This file is part of libkldap.
3 Copyright (c) 2006 Sean Harmer <sh@theharmers.co.uk>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KLDAP_LDAPMODELPRIVATE_H
22#define KLDAP_LDAPMODELPRIVATE_H
23
24#include "ldapconnection.h"
25#include "ldapdn.h"
26#include "ldapmodel.h"
27#include "ldapobject.h"
28
29namespace KLDAP {
30
31class LdapModelDNNode;
32class LdapSearch;
33
34/**
35 * @internal
36 */
37class LdapModel::LdapModelPrivate
38{
39 public:
40 enum SearchType {
41 NotSearching = 0,
42 NamingContexts,
43 BaseDN,
44 ChildObjects
45 };
46
47 explicit LdapModelPrivate( LdapModel *parent );
48 explicit LdapModelPrivate( LdapModel *parent, LdapConnection &connection );
49
50 ~LdapModelPrivate();
51
52 void setConnection( LdapConnection &connection );
53
54 bool search( const LdapDN &searchBase,
55 LdapUrl::Scope scope = LdapUrl::Sub,
56 const QString &filter = QString(),
57 const QStringList &attributes = QStringList(),
58 int pagesize = 0 );
59
60 LdapModelDNNode *rootNode() { return m_root; }
61 LdapSearch *search() { return m_search; }
62
63 LdapObjects &searchResults() { return m_searchResultObjects; }
64 const LdapObjects &searchResults() const { return m_searchResultObjects; }
65
66 void recreateRootItem();
67
68 void setBaseDN( const LdapDN &baseDN ) { m_baseDN = baseDN; }
69 LdapDN &baseDN() { return m_baseDN; }
70 const LdapDN &baseDN() const { return m_baseDN; }
71
72 void setSearchType( SearchType t, LdapModelDNNode *item = 0 );
73
74 SearchType searchType() { return m_searchType; }
75 LdapModelDNNode *searchItem() { return m_searchItem; }
76
77 void createConnections();
78 void populateRootToBaseDN();
79 void gotSearchResult( KLDAP::LdapSearch *search );
80 void gotSearchData( KLDAP::LdapSearch *search, const KLDAP::LdapObject &obj );
81
82 private:
83 LdapModel *m_parent;
84 LdapModelDNNode *m_root;
85 LdapSearch *m_search;
86 LdapObjects m_searchResultObjects;
87 LdapDN m_baseDN;
88 SearchType m_searchType;
89 LdapModelDNNode *m_searchItem;
90};
91
92}
93#endif
94