OPAL
Version 3.10.4
|
00001 /* 00002 * h460p.h 00003 * 00004 * H460 Presence class. 00005 * 00006 * h323plus library 00007 * 00008 * Copyright (c) 2008 ISVO (Asia) Pte. Ltd. 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.1 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Alternatively, the contents of this file may be used under the terms 00016 * of the General Public License (the "GNU License"), in which case the 00017 * provisions of GNU License are applicable instead of those 00018 * above. If you wish to allow use of your version of this file only 00019 * under the terms of the GNU License and not to allow others to use 00020 * your version of this file under the MPL, indicate your decision by 00021 * deleting the provisions above and replace them with the notice and 00022 * other provisions required by the GNU License. If you do not delete 00023 * the provisions above, a recipient may use your version of this file 00024 * under either the MPL or the GNU License." 00025 * 00026 * Software distributed under the License is distributed on an "AS IS" 00027 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00028 * the License for the specific language governing rights and limitations 00029 * under the License. 00030 * 00031 * 00032 * The Initial Developer of the Original Code is ISVO (Asia) Pte. Ltd. 00033 * 00034 * Contributor(s): Many thanks to Simon Horne. 00035 * 00036 * $Revision: 21523 $ 00037 * $Author: csoutheren $ 00038 * $Date: 2008-11-13 23:50:45 -0600 (Thu, 13 Nov 2008) $ 00039 */ 00040 00041 #ifndef OPAL_H460_H460P_H 00042 #define OPAL_H460_H460P_H 00043 00044 #include <opal/buildopts.h> 00045 00046 #if OPAL_H460 00047 00048 #include <h460/h460pres.h> 00049 00050 // Derive you implementation from H323PresenceHandler. 00051 00052 class H323PresenceSubscriptions; 00053 class H323PresenceNotifications; 00054 class H323PresenceIdentifiers; 00055 class H323PresenceInstructions; 00056 class H323PresenceHandler : public PObject 00057 { 00058 PCLASSINFO(H323PresenceHandler, PObject); 00059 00060 public: 00061 bool ReceivedPDU(const H225_EndpointIdentifier * id,const PASN_OctetString & pdu); 00062 00063 enum MsgType { 00064 e_Status, 00065 e_Instruct, 00066 e_Authorize, 00067 e_Notify, 00068 e_Request, 00069 e_Response, 00070 e_Alive, 00071 e_Remove, 00072 e_Alert 00073 }; 00074 00075 // Callbacks 00076 virtual void OnNotification(MsgType /*tag*/, 00077 const H225_EndpointIdentifier * /*id*/, 00078 const H460P_PresenceNotification & /*notify*/) {} 00079 virtual void OnSubscription(MsgType /*tag*/, 00080 const H225_EndpointIdentifier * /*id*/, 00081 const H460P_PresenceSubscription & /*subscription*/) {} 00082 virtual void OnInstructions(MsgType /*tag*/, 00083 const H225_EndpointIdentifier * /*id*/, 00084 const H460P_ArrayOf_PresenceInstruction & /*instruction*/) {} 00085 virtual void OnIdentifiers(MsgType /*tag*/, 00086 const H460P_ArrayOf_PresenceIdentifier & /*identifier*/) {} 00087 00088 // Build Messages 00089 H460P_PresenceStatus & BuildStatus(H460P_PresenceMessage & msg, 00090 const H323PresenceNotifications & notify, 00091 const H323PresenceInstructions & inst); 00092 H460P_PresenceInstruct & BuildInstruct(H460P_PresenceMessage & msg, 00093 const H323PresenceInstructions & inst); 00094 H460P_PresenceAuthorize & BuildAuthorize(H460P_PresenceMessage & msg, 00095 const H323PresenceSubscriptions & subs); 00096 H460P_PresenceNotify & BuildNotify(H460P_PresenceMessage & msg, 00097 const H323PresenceNotifications & notify); 00098 H460P_PresenceRequest & BuildRequest(H460P_PresenceMessage & msg, 00099 const H323PresenceSubscriptions & subs); 00100 H460P_PresenceResponse & BuildResponse(H460P_PresenceMessage & msg, 00101 const H323PresenceSubscriptions & subs); 00102 H460P_PresenceAlive & BuildAlive(H460P_PresenceMessage & msg, 00103 const H323PresenceIdentifiers & id); 00104 H460P_PresenceRemove & BuildRemove(H460P_PresenceMessage & msg, 00105 const H323PresenceIdentifiers & id); 00106 H460P_PresenceAlert & BuildAlert(H460P_PresenceMessage & msg, 00107 const H323PresenceNotifications & notify); 00108 }; 00109 00110 00111 class H323PresenceNotification : public H460P_PresenceNotification 00112 { 00113 00114 public: 00115 00116 enum States { 00117 e_hidden, 00118 e_available, 00119 e_online, 00120 e_offline, 00121 e_onCall, 00122 e_voiceMail, 00123 e_notAvailable, 00124 e_generic 00125 }; 00126 00127 static PString GetStateString(unsigned state); 00128 00129 void SetPresenceState(States state, const PString & display = PString()); 00130 void SetGenericState(const PString & state); 00131 void GetPresenceState(States & state, PString & display); 00132 00133 void AddSubscriber(const OpalGloballyUniqueID & guid); 00134 OpalGloballyUniqueID GetSubscriber(PINDEX i); 00135 void RemoveSubscribers(); 00136 void AddAlias(const PString & alias); 00137 PString GetAlias(); 00138 00139 00140 }; 00141 00142 class H323PresenceNotifications : public H460P_ArrayOf_PresenceNotification 00143 { 00144 00145 public: 00146 void Add(const H323PresenceNotification & notify); 00147 }; 00148 00149 class H323PresenceSubscription : public H460P_PresenceSubscription 00150 { 00151 00152 public: 00153 H323PresenceSubscription(); 00154 00155 // Sending Gatekeeper 00156 void SetSubscriptionDetails(const PString & subscribe, const PStringList & aliases); 00157 void GetSubscriberDetails(PStringList & aliases); 00158 PString GetSubscribed(); 00159 00160 void SetGatekeeperRAS(const H323TransportAddress & address); 00161 H323TransportAddress GetGatekeeperRAS(); 00162 00163 // Receiving Gatekeeper/Endpoint 00164 void MakeDecision(bool approve); 00165 bool IsDecisionMade(); 00166 int IsApproved(); // -1 not decided; 0 - not approved; 1 - approved; 00167 void SetTimeToLive(int t); 00168 int GetTimeToLive(); 00169 00170 void SetSubscription(const OpalGloballyUniqueID & guid); 00171 OpalGloballyUniqueID GetSubscription(); 00172 00173 protected: 00174 void SetApproved(bool success); 00175 00176 }; 00177 00178 class H323PresenceSubscriptions : public H460P_ArrayOf_PresenceSubscription 00179 { 00180 public: 00181 void Add(const H323PresenceSubscription & sub); 00182 }; 00183 00184 class H323PresenceInstruction : public H460P_PresenceInstruction 00185 { 00186 00187 public: 00188 enum Instruction { 00189 e_subscribe, 00190 e_unsubscribe, 00191 e_block, 00192 e_unblock 00193 }; 00194 00195 static PString GetInstructionString(unsigned instruct); 00196 00197 H323PresenceInstruction(Instruction instruct, const PString & alias); 00198 Instruction GetInstruction(); 00199 PString GetAlias(); 00200 }; 00201 00202 class H323PresenceInstructions : public H460P_ArrayOf_PresenceInstruction 00203 { 00204 public: 00205 void Add(const H323PresenceInstruction & instruct); 00206 H323PresenceInstruction & operator[](PINDEX i) const; 00207 }; 00208 00209 class H323PresenceIdentifiers : public H460P_ArrayOf_PresenceIdentifier 00210 { 00211 00212 public: 00213 void Add(const OpalGloballyUniqueID & guid); 00214 OpalGloballyUniqueID GetIdentifier(PINDEX i); 00215 }; 00216 00217 #endif 00218 00219 #endif // OPAL_H460_H460P_H 00220