sipxtacklib  Version 3.3
SipRefreshManager.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 // Author: Dan Petrie (dpetrie AT SIPez DOT com)
11 
12 #ifndef _SipRefreshManager_h_
13 #define _SipRefreshManager_h_
14 
15 // SYSTEM INCLUDES
16 
17 // APPLICATION INCLUDES
18 
19 #include <os/OsDefs.h>
20 #include <os/OsServerTask.h>
21 #include <utl/UtlHashMap.h>
22 #include <net/SipDialog.h>
23 
24 // DEFINES
25 // MACROS
26 // EXTERNAL FUNCTIONS
27 // EXTERNAL VARIABLES
28 // CONSTANTS
29 // STRUCTS
30 // FORWARD DECLARATIONS
31 class SipMessage;
32 class SipUserAgent;
33 class SipDialogMgr;
34 class RefreshDialogState;
35 class OsTimer;
36 
37 // TYPEDEFS
38 
40 
45 class SipRefreshManager : public OsServerTask
46 {
47 /* //////////////////////////// PUBLIC //////////////////////////////////// */
48 public:
49 
51  {
56  };
57 
90  const char* earlyDialogHandle,
91  const char* dialogHandle,
92  void* applicationData,
93  int responseCode,
94  const char* responseText,
95  long expiration, // epoch seconds
96  const SipMessage* response);
97 
98 /* ============================ CREATORS ================================== */
99 
101  SipRefreshManager(SipUserAgent& userAgent,
102  SipDialogMgr& dialogMgr);
103 
104 
106  virtual
108 
109 
110 /* ============================ MANIPULATORS ============================== */
111 
113 
128  UtlBoolean initiateRefresh(SipMessage& subscribeOrRegisterRequest,
129  void* applicationData,
130  const RefreshStateCallback refreshStateCallback,
131  UtlString& earlyDialogHandle);
132 
134 
147  UtlBoolean stopRefresh(const char* dialogHandle);
148 
150  void stopAllRefreshes();
151 
153  UtlBoolean handleMessage(OsMsg &eventMessage);
154 
155 /* ============================ ACCESSORS ================================= */
156 
158  int dumpRefreshStates(UtlString& dumpString);
159 
161  static void refreshState2String(RefreshRequestState state, UtlString& stateString);
162 
163 /* ============================ INQUIRY =================================== */
164 
166  int countRefreshSessions() const;
167 
168 /* //////////////////////////// PROTECTED ///////////////////////////////// */
169 protected:
171  void lock();
173  void unlock();
174 
175 /* //////////////////////////// PRIVATE /////////////////////////////////// */
176 private:
178  SipRefreshManager(const SipRefreshManager& rSipRefreshManager);
179 
181  SipRefreshManager& operator=(const SipRefreshManager& rhs);
182 
184  RefreshDialogState* getAnyDialog(UtlString& messageDialogHandle);
185 
187  UtlBoolean stateExists(RefreshDialogState* statePtr);
188 
190  RefreshDialogState* createNewRefreshState(SipMessage& subscribeOrRegisterRequest,
191  UtlString& messageDialogHandle,
192  void* applicationData,
193  const RefreshStateCallback refreshStateCallback,
194  int& requestedExpiration);
195 
197  void setRefreshTimer(RefreshDialogState& state,
198  UtlBoolean isSuccessfulReschedule);
199 
201 
204  int calculateResendTime(int requestedExpiration,
205  UtlBoolean isSuccessfulResend);
206 
208  void stopTimerForFailureReschedule(OsTimer* timer);
209 
211  static void deleteTimerAndEvent(OsTimer* timer);
212 
214  void setForResend(RefreshDialogState& state,
215  UtlBoolean expireNow);
216 
218  static UtlBoolean getInitialExpiration(const SipMessage& sipRequest,
219  int& expirationPeriod);
220 
222  static UtlBoolean getAcceptedExpiration(RefreshDialogState* refreshState,
223  const SipMessage& sipResponse,
224  int& expirationPeriod);
225 
226  OsMutex mRefreshMgrMutex; // used to lock this
227  SipUserAgent* mpUserAgent;
228  SipDialogMgr* mpDialogMgr;
229  UtlHashMap mRefreshes; // state info. for each subscription and registration being maintained.
230  UtlHashMap mEventTypes; // SIP event types that we want SUBSCRIBE responses for
231  UtlBoolean mReceivingRegisterResponses;
232  int mDefaultExpiration;
233 };
234 
235 /* ============================ INLINE METHODS ============================ */
236 
237 #endif // _SipRefreshManager_h_
Definition: SipRefreshManager.h:55
Definition: SipRefreshManager.h:54
void unlock()
lock for single thread use
Definition: SipRefreshManager.cpp:870
Transaction and Transport manager for SIP stack.
Definition: SipUserAgent.h:157
void stopAllRefreshes()
Stop refreshing, unregister and unsubscribe all.
Definition: SipRefreshManager.cpp:459
UtlBoolean initiateRefresh(SipMessage &subscribeOrRegisterRequest, void *applicationData, const RefreshStateCallback refreshStateCallback, UtlString &earlyDialogHandle)
Send message and keep request refreshed (i.e. subscribed or registered)
Definition: SipRefreshManager.cpp:188
UtlBoolean handleMessage(OsMsg &eventMessage)
Handler for SUBSCRIBE and REGISTER responses.
Definition: SipRefreshManager.cpp:480
static void refreshState2String(RefreshRequestState state, UtlString &stateString)
Get a string representation of the refresh state enumeration.
Definition: SipRefreshManager.cpp:812
UtlBoolean stopRefresh(const char *dialogHandle)
End the SIP refresh (registration or subscription) indicated by.
Definition: SipRefreshManager.cpp:382
Specialization of HttpMessage to contain and manipulate SIP messages.
Definition: SipMessage.h:343
Definition: SipRefreshManager.h:52
RefreshRequestState
Definition: SipRefreshManager.h:50
virtual ~SipRefreshManager()
Destructor.
Definition: SipRefreshManager.cpp:155
int dumpRefreshStates(UtlString &dumpString)
Debugging method to get an dump of all refresh states.
Definition: SipRefreshManager.cpp:841
Class for refreshing SIP subscriptions and registrations.
Definition: SipDialogMgr.h:42
Class for refreshing SIP subscriptions and registrations.
Definition: SipRefreshManager.h:45
Definition: SipRefreshManager.h:53
Definition: SipRefreshManager.cpp:33
SipRefreshManager(SipUserAgent &userAgent, SipDialogMgr &dialogMgr)
Default Dialog constructor.
Definition: SipRefreshManager.cpp:135
void(* RefreshStateCallback)(SipRefreshManager::RefreshRequestState requestState, const char *earlyDialogHandle, const char *dialogHandle, void *applicationData, int responseCode, const char *responseText, long expiration, const SipMessage *response)
Definition: SipRefreshManager.h:89
int countRefreshSessions() const
Get a count of the subscriptions and registration which have been added.
void lock()
lock for single thread use
Definition: SipRefreshManager.cpp:865

sipXtackLib home page