sipxtacklib  Version 3.3
SipDialogMonitor.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 
11 #ifndef _SIPDIALOGMONITOR_H_
12 #define _SIPDIALOGMONITOR_H_
13 
14 // SYSTEM INCLUDES
15 //#include <...>
16 
17 // APPLICATION INCLUDES
18 #include <os/OsBSem.h>
20 #include <net/SipUserAgent.h>
21 #include <net/SipDialogMgr.h>
22 #include <net/SipSubscriptionMgr.h>
24 #include <net/SipSubscribeServer.h>
25 #include <net/SipRefreshManager.h>
26 #include <net/SipSubscribeClient.h>
28 #include <net/SipDialogEvent.h>
29 #include <utl/UtlSList.h>
30 #include <utl/UtlHashMap.h>
31 
32 // DEFINES
33 // EXTERNAL FUNCTIONS
34 // EXTERNAL VARIABLES
35 // CONSTANTS
36 // STRUCTS
37 // TYPEDEFS
38 // FORWARD DECLARATIONS
39 
59 {
60  public:
61 
62  SipDialogMonitor(SipUserAgent* userAgent,
66  UtlString& domainName,
67  int hostPort,
68  int refreshTimeout,
69  bool toBePublished);
70 
71  virtual ~SipDialogMonitor();
72 
86  // Return true if successful, false if not.
88  bool addExtension(UtlString& groupName, Url& contactUrl);
89 
91  // Note: Only removes the URI from the group specified.
92  // Return true if successful, false if not.
93  bool removeExtension(UtlString& groupName, Url& contactUrl);
94 
96  // notifier() will be called for every change in status of any URI that
97  // has been added with addExtension().
98  // Only one notifier is allowed per listUri.
99  void addStateChangeNotifier(const char* listUri,
100  StateChangeNotifier* notifier);
101 
103  void removeStateChangeNotifier(const char* listUri);
104 
105  protected:
106  friend class SipDialogMonitorTest;
107 
109  void addDialogEvent(UtlString& contact,
110  SipDialogEvent* dialogEvent,
111  const char* earlyDialogHandle,
112  const char* dialogHandle);
113 
115  void publishContent(UtlString& contact, SipDialogEvent* dialogEvent);
116 
118  void notifyStateChange(UtlString& contact, StateChangeNotifier::Status);
119 
122  const char* earlyDialogHandle,
123  const char* dialogHandle,
124  void* applicationData,
125  int responseCode,
126  const char* responseText,
127  long expiration,
128  const SipMessage* subscribeResponse);
129 
131  static void notifyEventCallback(const char* earlyDialogHandle,
132  const char* dialogHandle,
133  void* applicationData,
134  const SipMessage* notifyRequest);
135 
137  void handleNotifyMessage(const SipMessage* notifyMessage,
138  const char* earlyDialogHandle,
139  const char* dialogHandle);
140 
142  // Return StateChangeNotifier::ON_HOOK/OFF_HOOK depending on whether there
143  // are any active dialogs for the subscription.
144  // If the earlyDialogHandle is not in mDialogState, ignore the event, as
145  // this is a NOTIFY due to an un-SUBSCRIBE.
147  const char* earlyDialogHandle,
148  const char* dialogHandle);
149 
151  void createDialogState(UtlString* earlyDialogHandle);
152 
154  void destroyDialogState(UtlString* earlyDialogHandle);
155 
156  private:
157 
158  // User agent to send SUBSCRIBEs and receive NOTIFYs.
159  SipUserAgent* mpUserAgent;
160  // The SIP domain used to construct the identity URI for the user agent.
161  UtlString mDomainName;
162  // The Contact URI for the user agent.
163  UtlString mContact;
164  // The (maximum) subscription refresh time for our subscriptions.
165  int mRefreshTimeout;
166  bool mToBePublished;
167 
168  OsBSem mLock;
169 
170  SipDialogMgr mDialogManager;
171  SipRefreshManager* mpRefreshMgr;
172  SipSubscribeClient* mpSipSubscribeClient;
173 
174  SipDialogMgr mDialogMgr;
175  SipSubscriptionMgr* mpSubscriptionMgr;
176  SipSubscribeServerEventHandler mPolicyHolder;
177  SipPublishContentMgr mSipPublishContentMgr;
178  SipSubscribeServer* mpSubscribeServer;
179 
180  // UtlHashMap mapping group names to SipResourceList's of URIs in
181  // the groups.
182  UtlHashMap mMonitoredLists;
183  // The last dialogEvent received for each AOR that we are watching.
184  UtlHashMap mDialogEventList;
185  UtlHashMap mDialogHandleList;
186  UtlHashMap mStateChangeNotifiers;
187  // UtlHashMap mapping SUBSCRIBEs (via early dialog handles) to
188  // UtlHashBag's that list the identifiers of all non-terminated dialogs
189  // on the UAs for the subscribed-to URI.
190  // Dialogs are identified by the string
191  // "<dialog id (as given in the dialog event)><ctrl-A><dialog handle>".
192  UtlHashMap mDialogState;
193 
195  SipDialogMonitor(const SipDialogMonitor& rSipDialogMonitor);
196 
198  SipDialogMonitor& operator=(const SipDialogMonitor& rhs);
199 };
200 
201 #endif // _SIPDIALOGMONITOR_H_
StateChangeNotifier::Status mergeEventInformation(SipDialogEvent *dialogEvent, const char *earlyDialogHandle, const char *dialogHandle)
Merge information from a dialogEvent into mDialogState.
Definition: SipDialogMonitor.cpp:513
friend class SipDialogMonitorTest
Definition: SipDialogMonitor.h:106
Transaction and Transport manager for SIP stack.
Definition: SipUserAgent.h:157
void handleNotifyMessage(const SipMessage *notifyMessage, const char *earlyDialogHandle, const char *dialogHandle)
Non-static callback to handle incoming NOTIFYs.
Definition: SipDialogMonitor.cpp:430
void publishContent(UtlString &contact, SipDialogEvent *dialogEvent)
Publish the dialog event package to the resource list.
Definition: SipDialogMonitor.cpp:343
void addDialogEvent(UtlString &contact, SipDialogEvent *dialogEvent, const char *earlyDialogHandle, const char *dialogHandle)
Add &#39;dialogEvent&#39; as the last dialog event for AOR &#39;contact&#39;.
Definition: SipDialogMonitor.cpp:284
void destroyDialogState(UtlString *earlyDialogHandle)
Delete the dialog event state record for the SUBSCRIBE earlyDialogHandle.
Definition: SipDialogMonitor.cpp:645
void addStateChangeNotifier(const char *listUri, StateChangeNotifier *notifier)
Register a StateChangeNotifier.
Definition: SipDialogMonitor.cpp:465
SubscriptionState
Definition: SipSubscribeClient.h:69
Container for MIME type application/dialog-info+xml.
Definition: SipDialogEvent.h:248
Specialization of HttpMessage to contain and manipulate SIP messages.
Definition: SipMessage.h:343
A StateChangeNotifier is used in the dialog monitor when the dialog state is changed from one state t...
Definition: StateChangeNotifier.h:40
Class for containing SIP dialog state information.
Definition: SipSubscribeClient.h:64
static void subscriptionStateCallback(SipSubscribeClient::SubscriptionState newState, const char *earlyDialogHandle, const char *dialogHandle, void *applicationData, int responseCode, const char *responseText, long expiration, const SipMessage *subscribeResponse)
Callback to handle notification of changes in the states of subscriptions.
Definition: SipDialogMonitor.cpp:401
Top level class for accepting and processing SUBSCRIBE requests.
Definition: SipSubscribeServer.h:102
Class for refreshing SIP subscriptions and registrations.
Definition: SipDialogMgr.h:42
Class for refreshing SIP subscriptions and registrations.
Definition: SipRefreshManager.h:45
static void notifyEventCallback(const char *earlyDialogHandle, const char *dialogHandle, void *applicationData, const SipMessage *notifyRequest)
Callback to handle incoming NOTIFYs.
Definition: SipDialogMonitor.cpp:416
virtual ~SipDialogMonitor()
Definition: SipDialogMonitor.cpp:88
void notifyStateChange(UtlString &contact, StateChangeNotifier::Status)
Send the state change to the notifier.
Definition: SipDialogMonitor.cpp:484
SipDialogMonitor(SipUserAgent *userAgent, UtlString &domainName, int hostPort, int refreshTimeout, bool toBePublished)
option to publish for other subscriptions
Definition: SipDialogMonitor.cpp:43
A SipDialogMonitor object monitors the on/off hook status of all the SIP user agents for a set of URI...
Definition: SipDialogMonitor.h:58
Class for managing body content to be accepted via PUBLISH or provided in NOTIFY requests.
Definition: SipPublishContentMgr.h:93
Class for maintaining SUBSCRIBE dialog information in subscription server.
Definition: SipSubscriptionMgr.h:48
void removeStateChangeNotifier(const char *listUri)
Unregister a StateChangeNotifier.
Definition: SipDialogMonitor.cpp:474
URL parser and constructor.
Definition: Url.h:90
Status
Definition: StateChangeNotifier.h:45
void createDialogState(UtlString *earlyDialogHandle)
Create the dialog event state record for the SUBSCRIBE earlyDialogHandle.
Definition: SipDialogMonitor.cpp:639
bool removeExtension(UtlString &groupName, Url &contactUrl)
Remove a URI from a group to be monitored.
Definition: SipDialogMonitor.cpp:211
Class for specializing the handling of SIP Events in SipSubscribeServer.
Definition: SipSubscribeServerEventHandler.h:46
bool addExtension(UtlString &groupName, Url &contactUrl)
URIs are added and deleted from groups, which are identified by names.
Definition: SipDialogMonitor.cpp:119

sipXtackLib home page