1// $OpenLDAP$
2/*
3 * Copyright 2000-2011 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5 */
6
7
8#ifndef LDAP_REQUEST_H
9#define LDAP_REQUEST_H
10
11#include <LDAPConstraints.h>
12#include <LDAPAsynConnection.h>
13#include <LDAPMessageQueue.h>
14
15class LDAPUrl;
16
17/**
18 * For internal use only
19 *
20 * Each request that is sent to a LDAP-server by this library is
21 * represented by a special object that contains the parameters and some
22 * other info of the request. This virtual class is the common base classe
23 * for these specialized request classes.
24 */
25class LDAPRequest{
26
27    public :
28        static const int BIND=0;
29        static const int UNBIND=2;
30        static const int SEARCH=3;
31        static const int MODIFY=7;
32        static const int ADD=8;
33		static const int DELETE=10;
34        static const int COMPARE=14;
35
36        LDAPRequest(const LDAPRequest& req);
37        LDAPRequest(LDAPAsynConnection* conn,
38                const LDAPConstraints* cons, bool isReferral=false,
39                const LDAPRequest* parent=0);
40        virtual ~LDAPRequest();
41
42        const LDAPConstraints* getConstraints() const;
43        const LDAPAsynConnection* getConnection() const;
44        virtual LDAPMsg *getNextMessage() const;
45        int getType()const;
46        int getMsgID() const;
47        int getHopCount() const;
48
49        /**
50         * @return The LDAPRequest that has created this object. Or 0 if
51         * this object was not created by another request.
52         */
53        const LDAPRequest* getParent() const;
54
55        /**
56         * @return true if this object was created during the automatic
57         * chasing of referrals. Otherwise false
58         */
59        bool isReferral() const;
60
61        void unbind() const;
62
63        /**
64         * This method encodes the request an calls the apprpriate
65         * functions of the C-API to send the Request to a LDAP-Server
66         */
67        virtual LDAPMessageQueue* sendRequest()=0;
68        virtual LDAPRequest* followReferral(LDAPMsg* ref);
69
70        /**
71         * Compare this request with another on. And returns true if they
72         * have the same parameters.
73         */
74        virtual bool equals(const LDAPRequest* req) const;
75
76        bool isCycle() const;
77
78    protected :
79        bool m_isReferral;
80        int m_requestType;
81        LDAPConstraints *m_cons;
82        LDAPAsynConnection *m_connection;
83        const LDAPRequest* m_parent;
84        int m_hopCount;
85        int m_msgID;  //the associated C-API Message ID
86        LDAPRequest();
87};
88#endif //LDAP_REQUEST_H
89
90