00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
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 
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 
00076         virtual void OnNotification(MsgType ,
00077                                                                 const H225_EndpointIdentifier * , 
00078                                                                 const H460P_PresenceNotification & ) {}
00079         virtual void OnSubscription(MsgType ,
00080                                                                 const H225_EndpointIdentifier * , 
00081                                                                 const H460P_PresenceSubscription & ) {}
00082         virtual void OnInstructions(MsgType ,
00083                                                                 const H225_EndpointIdentifier * , 
00084                                                                 const H460P_ArrayOf_PresenceInstruction & ) {}
00085         virtual void OnIdentifiers(MsgType ,
00086                                                                 const H460P_ArrayOf_PresenceIdentifier & ) {}
00087 
00088 
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  
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  
00164         void MakeDecision(bool approve);
00165         bool IsDecisionMade();
00166         int IsApproved(); 
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