reSIProcate/DialogUsageManager  9694
RegEventClient.hxx
Go to the documentation of this file.
00001 #if !defined(RESIP_RegEventClient_hxx)
00002 #define RESIP_RegEventClient_hxx
00003 
00004 #ifdef HAVE_CONFIG_H
00005 #include "config.h"
00006 #endif
00007 
00008 #include "resip/dum/SubscriptionHandler.hxx"
00009 #include "resip/dum/RegistrationHandler.hxx"
00010 #include "resip/dum/Handles.hxx"
00011 #include "resip/dum/DialogUsageManager.hxx"
00012 #include "resip/dum/DumThread.hxx"
00013 #include "resip/stack/SipStack.hxx"
00014 #include "resip/stack/StackThread.hxx"
00015 #include "rutil/SharedPtr.hxx"
00016 
00017 namespace resip
00018 {
00019 class NameAddr;
00020 class SipMessage;
00021 class Security;
00022 class MasterProfile;
00023 }
00024 
00025 class RegEventClient  : public resip::ClientSubscriptionHandler,
00026                         public resip::ClientRegistrationHandler
00027 {
00028    public:
00029       RegEventClient(resip::SharedPtr<resip::MasterProfile> profile);
00030       virtual ~RegEventClient();
00031       
00032       void run();
00033 
00034       void watchAor(const resip::Uri& aor);
00035       //void unwatchAor(const resip::Uri& aor);
00036 
00037       virtual void onRegEvent(const resip::Data& aor, const resip::Data& reg)=0;
00038       virtual void onRegEventError(const resip::Data& aor, const resip::Data& reg)=0;
00039       
00040    protected:
00041       virtual void onUpdatePending(resip::ClientSubscriptionHandle, 
00042                                    const resip::SipMessage& notify, 
00043                                    bool outOfOrder);
00044       virtual void onUpdateActive(resip::ClientSubscriptionHandle, 
00045                                   const resip::SipMessage& notify, 
00046                                   bool outOfOrder);
00047       virtual void onUpdateExtension(resip::ClientSubscriptionHandle,
00048                                      const resip::SipMessage& notify, 
00049                                      bool outOfOrder);
00050       virtual int onRequestRetry(resip::ClientSubscriptionHandle, 
00051                                  int retrySeconds, 
00052                                  const resip::SipMessage& notify);
00053       virtual void onTerminated(resip::ClientSubscriptionHandle, 
00054                                 const resip::SipMessage* msg);   
00055       virtual void onNewSubscription(resip::ClientSubscriptionHandle, 
00056                                      const resip::SipMessage& notify);
00057 
00058 
00059       virtual void onSuccess(resip::ClientRegistrationHandle, 
00060                              const resip::SipMessage& response)
00061       {
00062       }
00063       
00064       virtual void onRemoved(resip::ClientRegistrationHandle, 
00065                              const resip::SipMessage& response)
00066       {
00067       }
00068       
00069       virtual int onRequestRetry(resip::ClientRegistrationHandle, 
00070                                  int retrySeconds, 
00071                                  const resip::SipMessage& response)
00072       {
00073          return -1;
00074       }
00075       
00076       virtual void onFailure(resip::ClientRegistrationHandle, 
00077                              const resip::SipMessage& response)
00078       {
00079       }
00080       
00081 
00082    protected:
00083       resip::Security* mSecurity;
00084       resip::SipStack mStack;
00085       resip::StackThread mStackThread;
00086       resip::DialogUsageManager mDum;
00087       resip::DumThread mDumThread;
00088       
00089       resip::SharedPtr<resip::MasterProfile> mProfile;
00090       friend class AddAor;
00091 };
00092 
00093 class AddAor : public resip::DumCommand
00094 {
00095    public:
00096       AddAor(RegEventClient& client, const resip::Uri& aor);
00097       virtual void executeCommand();
00098 
00099       virtual resip::Message* clone() const;
00100 #ifdef RESIP_USE_STL_STREAMS
00101       virtual std::ostream& encode(std::ostream&) const;
00102       virtual std::ostream& encodeBrief(std::ostream&) const;
00103 #else
00104       virtual resip::ResipFastOStream& encode(resip::ResipFastOStream&) const;
00105       virtual resip::ResipFastOStream& encodeBrief(resip::ResipFastOStream&) const;
00106 #endif
00107       
00108    private:
00109       RegEventClient& mClient;
00110       const resip::Uri mAor;
00111 };
00112 
00113 #endif