00001 #ifndef REGPROCESSOR_H 00002 #define REGPROCESSOR_H 00003 00004 #ifndef _PTLIB_H 00005 #include <ptlib.h> 00006 #endif 00007 00008 #include <ptclib/random.h> 00009 #include <opal/connection.h> 00010 00011 #include <iax2/frame.h> 00012 #include <iax2/processor.h> 00013 #include <iax2/iedata.h> 00014 #include <iax2/remote.h> 00015 #include <iax2/safestrings.h> 00016 #include <iax2/sound.h> 00017 00018 class IAX2EndPoint; 00019 class IAX2Connection; 00020 00021 class IAX2RegProcessor : public IAX2Processor 00022 { 00023 PCLASSINFO(IAX2RegProcessor, IAX2Processor); 00024 00025 public: 00027 IAX2RegProcessor( IAX2EndPoint & ep, 00028 const PString & host, 00029 const PString & username, 00030 const PString & password, 00031 PINDEX inRegistrationRefreshTime 00032 ); 00033 00035 virtual ~IAX2RegProcessor(); 00036 00040 void Unregister(); 00041 00042 PString GetHost() const { return host; }; 00043 PString GetUserName() const { return userName; }; 00044 PString GetPassword() const { return password; }; 00045 00046 protected: 00047 PString host; 00048 PString userName; 00049 PString password; 00050 00051 INT registrationRefreshTime; 00052 00054 enum RegistrationState { 00055 registrationStart = 1, 00056 registrationHappening, 00057 registrationUnregisterStart, 00058 registrationUnregistering, 00059 registrationUnregistered, 00061 registrationWait 00062 }; 00063 00065 BOOL registrationState; 00066 00069 PMutex stateMutex; 00070 00071 #ifdef DOC_PLUS_PLUS 00072 00073 void OnDoRegistration(PTimer &, INT); 00074 #else 00075 PDECLARE_NOTIFIER(PTimer, IAX2RegProcessor, OnDoRegistration); 00076 #endif 00077 00079 PTimer registrationTimer; 00080 00082 void ProcessIaxCmdRegAuth(IAX2FullFrameProtocol * src); 00083 00085 void ProcessIaxCmdRegAck(IAX2FullFrameProtocol * src); 00086 00088 void ProcessIaxCmdRegRej(IAX2FullFrameProtocol * src); 00089 00092 void ProcessIaxCmdUnRegAuth(IAX2FullFrameProtocol * src); 00093 00095 void ProcessIaxCmdUnRegAck(IAX2FullFrameProtocol * src); 00096 00098 void ProcessIaxCmdUnRegRej(IAX2FullFrameProtocol * src); 00099 00102 void OnNoResponseTimeout(); 00103 00106 void PrintOn(ostream & strm) const; 00107 00109 virtual void ProcessLists(); 00110 00113 virtual void ProcessFullFrame(IAX2FullFrame & fullFrame); 00114 00116 virtual void ProcessNetworkFrame(IAX2MiniFrame * src); 00117 00120 virtual BOOL ProcessNetworkFrame(IAX2FullFrameProtocol * src); 00121 00127 void ResetCall(); 00128 00131 PRandom regRandom; 00132 }; 00133 00134 #endif // REGPROCESSOR_H