Fixed crash opportunity under some conditions
[pwlib.git] / include / ptclib / pils.h
blobe028e2d95c96e152075cce1e93593f646e61be1d
1 /*
2 * pils.h
4 * Microsoft Internet Location Server Protocol interface class.
6 * Portable Windows Library
8 * Copyright (c) 1993-2003 Equivalence Pty. Ltd.
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
18 * under the License.
20 * The Original Code is Portable Windows Library.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Contributor(s): ______________________________________.
26 * $Log$
27 * Revision 1.4 2004/02/20 16:27:52 ykiryanov
28 * if'd LDAP code to enable non-LDAP builds
30 * Revision 1.3 2003/04/11 00:07:46 robertj
31 * More for Microsoft IP address specification wierdness (registration side).
33 * Revision 1.2 2003/04/07 13:05:09 robertj
34 * Workaround for Microsoft IP address specification wierdness.
36 * Revision 1.1 2003/03/31 03:35:20 robertj
37 * Major addition of LDAP functionality.
38 * Added ILS specialisation of LDAP.
42 #ifndef _PILS_H
43 #define _PILS_H
45 #ifdef P_USE_PRAGMA
46 #pragma interface
47 #endif
49 #if P_LDAP
51 #include <ptlib/sockets.h>
52 #include <ptclib/pldap.h>
55 /**This class will create an LDAP client to access a remote ILS server.
57 class PILSSession : public PLDAPSession
59 PCLASSINFO(PILSSession, PLDAPSession)
60 public:
61 /**Create an ILS client.
63 PILSSession();
65 /**Special IP address class. Microsoft in their infinite wisdom save the
66 IP address as an little endian integer in the LDAP fild, but this was
67 generated from a 32 bit integer that was in network byte order (big
68 endian) which causes immense confusion. Reading directly into a
69 PIPSocket::Address does not work as it assumes that any integer forms
70 would be in host order. So we need to override the standard read
71 function so the marchalling into the RTPerson structure works.
72 All very sad.
74 class MSIPAddress : public PIPSocket::Address
76 public:
77 MSIPAddress(DWORD a = 0) : Address(a) { }
78 MSIPAddress(const PIPSocket::Address & a) : Address(a) { }
79 MSIPAddress(const PString & dotNotation) : Address(dotNotation) { }
80 MSIPAddress(PINDEX len, const BYTE * bytes) : Address(len, bytes) { }
82 MSIPAddress & operator=(DWORD a) { Address::operator=(a); return *this; }
83 MSIPAddress & operator=(const PIPSocket::Address & a) { Address::operator=(a); return *this; }
84 MSIPAddress & operator=(const PString & dotNotation) { Address::operator=(dotNotation); return *this; }
86 friend istream & operator>>(istream & s, MSIPAddress & a);
87 friend ostream & operator<<(ostream & s, MSIPAddress & a);
90 PLDAP_STRUCT_BEGIN(RTPerson)
91 PLDAP_ATTR_SIMP(RTPerson, PString, cn); // Must be non-empty
92 PLDAP_ATTR_SIMP(RTPerson, PString, c);
93 PLDAP_ATTR_SIMP(RTPerson, PString, o);
94 PLDAP_ATTR_SIMP(RTPerson, PString, surname);
95 PLDAP_ATTR_SIMP(RTPerson, PString, givenName);
96 PLDAP_ATTR_SIMP(RTPerson, PString, rfc822Mailbox); // Must be non-empty
97 PLDAP_ATTR_SIMP(RTPerson, PString, location);
98 PLDAP_ATTR_SIMP(RTPerson, PString, comment);
99 PLDAP_ATTR_SIMP(RTPerson, MSIPAddress, sipAddress);
100 PLDAP_ATTR_SIMP(RTPerson, PWORDArray, sport);
101 PLDAP_ATTR_INIT(RTPerson, unsigned, sflags, 0);
102 PLDAP_ATTR_INIT(RTPerson, unsigned, ssecurity, 0);
103 PLDAP_ATTR_INIT(RTPerson, unsigned, smodop, 0);
104 PLDAP_ATTR_INIT(RTPerson, unsigned, sttl, 3600);
105 PLDAP_ATTR_SIMP(RTPerson, PStringList, sprotid);
106 PLDAP_ATTR_SIMP(RTPerson, PStringList, sprotmimetype);
107 PLDAP_ATTR_INIT(RTPerson, PString, sappid, PProcess::Current().GetName()); // Must be non-empty
108 PLDAP_ATTR_INIT(RTPerson, PString, sappguid, "none"); // Must be non-empty
109 PLDAP_ATTR_SIMP(RTPerson, PStringList, smimetype);
110 PLDAP_ATTR_INIT(RTPerson, BOOL, ilsa32833566, 0); // 1=audio capable
111 PLDAP_ATTR_INIT(RTPerson, BOOL, ilsa32964638, 0); // 1=video capable
112 PLDAP_ATTR_INIT(RTPerson, BOOL, ilsa26214430, 0); // 1=in a call
113 PLDAP_ATTR_INIT(RTPerson, unsigned, ilsa26279966, 0); // unknown
114 PLDAP_ATTR_INIT(RTPerson, unsigned, ilsa39321630, 0); // 1 personal; 2 business user; 4 adults-only
115 PLDAP_ATTR_INIT(RTPerson, time_t, timestamp, PTime().GetTimeInSeconds());
117 public:
118 PString GetDN() const;
120 PLDAP_STRUCT_END();
122 BOOL AddPerson(
123 const RTPerson & person
126 BOOL ModifyPerson(
127 const RTPerson & person
130 BOOL DeletePerson(
131 const RTPerson & person
134 BOOL SearchPerson(
135 const PString & canonicalName,
136 RTPerson & person
139 PList<RTPerson> SearchPeople(
140 const PString & filter
144 #endif // P_LDAP
146 #endif // _PILS_H
149 // End of file ////////////////////////////////////////////////////////////////