OPAL Version 3.10.4

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

h460p.h
Go to the documentation of this file.
1 /*
2 * h460p.h
3 *
4 * H460 Presence class.
5 *
6 * h323plus library
7 *
8 * Copyright (c) 2008 ISVO (Asia) Pte. Ltd.
9 *
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.1 (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/
14 *
15 * Alternatively, the contents of this file may be used under the terms
16 * of the General Public License (the "GNU License"), in which case the
17 * provisions of GNU License are applicable instead of those
18 * above. If you wish to allow use of your version of this file only
19 * under the terms of the GNU License and not to allow others to use
20 * your version of this file under the MPL, indicate your decision by
21 * deleting the provisions above and replace them with the notice and
22 * other provisions required by the GNU License. If you do not delete
23 * the provisions above, a recipient may use your version of this file
24 * under either the MPL or the GNU License."
25 *
26 * Software distributed under the License is distributed on an "AS IS"
27 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
28 * the License for the specific language governing rights and limitations
29 * under the License.
30 *
31 *
32 * The Initial Developer of the Original Code is ISVO (Asia) Pte. Ltd.
33 *
34 * Contributor(s): Many thanks to Simon Horne.
35 *
36 * $Revision: 21523 $
37 * $Author: csoutheren $
38 * $Date: 2008-11-13 23:50:45 -0600 (Thu, 13 Nov 2008) $
39 */
40
41 #ifndef OPAL_H460_H460P_H
42 #define OPAL_H460_H460P_H
43
44 #include <opal/buildopts.h>
45
46 #if OPAL_H460
47
48 #include <h460/h460pres.h>
49
50 // Derive you implementation from H323PresenceHandler.
51
52 class H323PresenceSubscriptions;
53 class H323PresenceNotifications;
54 class H323PresenceIdentifiers;
55 class H323PresenceInstructions;
56 class H323PresenceHandler : public PObject
57 {
58 PCLASSINFO(H323PresenceHandler, PObject);
59
60 public:
61 bool ReceivedPDU(const H225_EndpointIdentifier * id,const PASN_OctetString & pdu);
62
63 enum MsgType {
64 e_Status,
65 e_Instruct,
66 e_Authorize,
67 e_Notify,
68 e_Request,
69 e_Response,
70 e_Alive,
71 e_Remove,
72 e_Alert
73 };
74
75 // Callbacks
76 virtual void OnNotification(MsgType /*tag*/,
77 const H225_EndpointIdentifier * /*id*/,
78 const H460P_PresenceNotification & /*notify*/) {}
79 virtual void OnSubscription(MsgType /*tag*/,
80 const H225_EndpointIdentifier * /*id*/,
81 const H460P_PresenceSubscription & /*subscription*/) {}
82 virtual void OnInstructions(MsgType /*tag*/,
83 const H225_EndpointIdentifier * /*id*/,
84 const H460P_ArrayOf_PresenceInstruction & /*instruction*/) {}
85 virtual void OnIdentifiers(MsgType /*tag*/,
86 const H460P_ArrayOf_PresenceIdentifier & /*identifier*/) {}
87
88 // Build Messages
89 H460P_PresenceStatus & BuildStatus(H460P_PresenceMessage & msg,
90 const H323PresenceNotifications & notify,
91 const H323PresenceInstructions & inst);
92 H460P_PresenceInstruct & BuildInstruct(H460P_PresenceMessage & msg,
93 const H323PresenceInstructions & inst);
94 H460P_PresenceAuthorize & BuildAuthorize(H460P_PresenceMessage & msg,
95 const H323PresenceSubscriptions & subs);
96 H460P_PresenceNotify & BuildNotify(H460P_PresenceMessage & msg,
97 const H323PresenceNotifications & notify);
98 H460P_PresenceRequest & BuildRequest(H460P_PresenceMessage & msg,
99 const H323PresenceSubscriptions & subs);
100 H460P_PresenceResponse & BuildResponse(H460P_PresenceMessage & msg,
101 const H323PresenceSubscriptions & subs);
102 H460P_PresenceAlive & BuildAlive(H460P_PresenceMessage & msg,
103 const H323PresenceIdentifiers & id);
104 H460P_PresenceRemove & BuildRemove(H460P_PresenceMessage & msg,
105 const H323PresenceIdentifiers & id);
106 H460P_PresenceAlert & BuildAlert(H460P_PresenceMessage & msg,
107 const H323PresenceNotifications & notify);
108 };
109
110
111 class H323PresenceNotification : public H460P_PresenceNotification
112 {
113
114 public:
115
116 enum States {
117 e_hidden,
118 e_available,
119 e_online,
120 e_offline,
121 e_onCall,
122 e_voiceMail,
123 e_notAvailable,
124 e_generic
125 };
126
127 static PString GetStateString(unsigned state);
128
129 void SetPresenceState(States state, const PString & display = PString());
130 void SetGenericState(const PString & state);
131 void GetPresenceState(States & state, PString & display);
132
133 void AddSubscriber(const OpalGloballyUniqueID & guid);
134 OpalGloballyUniqueID GetSubscriber(PINDEX i);
135 void RemoveSubscribers();
136 void AddAlias(const PString & alias);
137 PString GetAlias();
138
139
140 };
141
142 class H323PresenceNotifications : public H460P_ArrayOf_PresenceNotification
143 {
144
145 public:
146 void Add(const H323PresenceNotification & notify);
147 };
148
149 class H323PresenceSubscription : public H460P_PresenceSubscription
150 {
151
152 public:
153 H323PresenceSubscription();
154
155 // Sending Gatekeeper
156 void SetSubscriptionDetails(const PString & subscribe, const PStringList & aliases);
157 void GetSubscriberDetails(PStringList & aliases);
158 PString GetSubscribed();
159
160 void SetGatekeeperRAS(const H323TransportAddress & address);
161 H323TransportAddress GetGatekeeperRAS();
162
163 // Receiving Gatekeeper/Endpoint
164 void MakeDecision(bool approve);
165 bool IsDecisionMade();
166 int IsApproved(); // -1 not decided; 0 - not approved; 1 - approved;
167 void SetTimeToLive(int t);
168 int GetTimeToLive();
169
170 void SetSubscription(const OpalGloballyUniqueID & guid);
171 OpalGloballyUniqueID GetSubscription();
172
173 protected:
174 void SetApproved(bool success);
175
176 };
177
178 class H323PresenceSubscriptions : public H460P_ArrayOf_PresenceSubscription
179 {
180 public:
181 void Add(const H323PresenceSubscription & sub);
182 };
183
184 class H323PresenceInstruction : public H460P_PresenceInstruction
185 {
186
187 public:
188 enum Instruction {
189 e_subscribe,
190 e_unsubscribe,
191 e_block,
192 e_unblock
193 };
194
195 static PString GetInstructionString(unsigned instruct);
196
197 H323PresenceInstruction(Instruction instruct, const PString & alias);
198 Instruction GetInstruction();
199 PString GetAlias();
200 };
201
202 class H323PresenceInstructions : public H460P_ArrayOf_PresenceInstruction
203 {
204 public:
205 void Add(const H323PresenceInstruction & instruct);
206 H323PresenceInstruction & operator[](PINDEX i) const;
207 };
208
209 class H323PresenceIdentifiers : public H460P_ArrayOf_PresenceIdentifier
210 {
211
212 public:
213 void Add(const OpalGloballyUniqueID & guid);
214 OpalGloballyUniqueID GetIdentifier(PINDEX i);
215 };
216
217 #endif
218
219 #endif // OPAL_H460_H460P_H
220