sipxtacklib  Version 3.3
SipSubscribeServer.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006 SIPez LLC
3 // Licensed to SIPfoundry under a Contributor Agreement.
4 //
5 // Copyright (C) 2005, 2006 SIPfoundry Inc.
6 // Licensed by SIPfoundry under the LGPL license.
7 //
8 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
9 // Licensed to SIPfoundry under a Contributor Agreement.
10 //
11 // $$
13 // Author: Dan Petrie (dpetrie AT SIPez DOT com)
14 
15 #ifndef _SipSubscribeServer_h_
16 #define _SipSubscribeServer_h_
17 
18 // SYSTEM INCLUDES
19 
20 // APPLICATION INCLUDES
21 #include <os/OsServerTask.h>
22 #include <os/OsDefs.h>
23 #include <os/OsRWMutex.h>
24 #include <utl/UtlString.h>
25 #include <utl/UtlHashMap.h>
26 #include <net/SipUserAgent.h>
27 
28 
29 // DEFINES
30 // MACROS
31 // EXTERNAL FUNCTIONS
32 // EXTERNAL VARIABLES
33 // CONSTANTS
34 // STRUCTS
35 // FORWARD DECLARATIONS
37 class SipUserAgent;
39 class SipSubscriptionMgr;
40 class OsMsg;
41 class SipMessage;
42 
43 
44 // TYPEDEFS
45 
46 
48 
102 class SipSubscribeServer : public OsServerTask
103 {
104 /* //////////////////////////// PUBLIC //////////////////////////////////// */
105 public:
106 
107 
108 /* ============================ CREATORS ================================== */
109 
112  const char* eventType = NULL);
113 
115  SipSubscribeServer(SipUserAgent& defaultUserAgent,
116  SipPublishContentMgr& defaultContentMgr,
117  SipSubscriptionMgr& defaultSubscriptionMgr,
118  SipSubscribeServerEventHandler& defaultPlugin);
119 
120 
122  virtual
124 
125 
126 /* ============================ MANIPULATORS ============================== */
127 
129 
132  static void contentChangeCallback(void* applicationData,
133  const char* resourceId,
134  const char* eventTypeKey,
135  const char* eventType,
136  UtlBoolean isDefaultContent);
137 
139  UtlBoolean notifySubscribers(const char* resourceId,
140  const char* eventTypeKey,
141  const char* eventType,
142  UtlBoolean isDefaultContent);
143 
145  UtlBoolean enableEventType(const char* eventType,
146  SipUserAgent* userAgent = NULL,
147  SipPublishContentMgr* contentMgr = NULL,
148  SipSubscribeServerEventHandler* eventPlugin = NULL,
149  SipSubscriptionMgr* subscriptionMgr = NULL);
150 
152  UtlBoolean disableEventType(const char* eventType,
153  SipUserAgent*& userAgent,
154  SipPublishContentMgr*& contentMgr,
155  SipSubscribeServerEventHandler*& eventPlugin,
156  SipSubscriptionMgr*& subscriptionMgr);
157 
159  UtlBoolean handleMessage(OsMsg &eventMessage);
160 
161 /* ============================ ACCESSORS ================================= */
162 
164 
172  getEventHandler(const UtlString& eventType);
173 
175 
182  SipPublishContentMgr* getPublishMgr(const UtlString& eventType);
183 
185 
193  SipSubscriptionMgr* getSubscriptionMgr(const UtlString& eventType);
194 
195 /* ============================ INQUIRY =================================== */
196 
197 
199  UtlBoolean isEventTypeEnabled(const UtlString& eventType);
200 
201 /* //////////////////////////// PROTECTED ///////////////////////////////// */
202 protected:
203 
204 
205 /* //////////////////////////// PRIVATE /////////////////////////////////// */
206 private:
208  SipSubscribeServer(const SipSubscribeServer& rSipSubscribeServer);
209 
211  SipSubscribeServer& operator=(const SipSubscribeServer& rhs);
212 
214  UtlBoolean handleSubscribe(const SipMessage& subscribeRequest);
215 
217  UtlBoolean handleNotifyResponse(const SipMessage& notifyResponse);
218 
220  UtlBoolean handleExpiration(UtlString* subscribeDialogHandle,
221  OsTimer* timer);
222 
224  void lockForWrite();
225 
227  void unlockForWrite();
228 
230  void lockForRead();
231 
233  void unlockForRead();
234 
235  SipUserAgent* mpDefaultUserAgent;
236  SipPublishContentMgr* mpDefaultContentMgr;
237  SipSubscriptionMgr* mpDefaultSubscriptionMgr;
238  SipSubscribeServerEventHandler* mpDefaultEventHandler;
239  UtlHashMap mEventDefinitions;
240  OsRWMutex mSubscribeServerMutex;
241 };
242 
243 /* ============================ INLINE METHODS ============================ */
244 
245 #endif // _SipSubscribeServer_h_
SipPublishContentMgr * getPublishMgr(const UtlString &eventType)
Get the content manager for the given event type.
Definition: SipSubscribeServer.cpp:439
Transaction and Transport manager for SIP stack.
Definition: SipUserAgent.h:157
SipSubscriptionMgr * getSubscriptionMgr(const UtlString &eventType)
Get the subscription manager for the given event type.
Definition: SipSubscribeServer.cpp:459
UtlBoolean isEventTypeEnabled(const UtlString &eventType)
Inquire if the given event type is enabled in the server.
Definition: SipSubscribeServer.cpp:481
static void contentChangeCallback(void *applicationData, const char *resourceId, const char *eventTypeKey, const char *eventType, UtlBoolean isDefaultContent)
Callback invoked by SipPublishContentMgr when content changes.
Definition: SipSubscribeServer.cpp:157
SipSubscribeServer(SipUserAgent &defaultUserAgent, SipPublishContentMgr &defaultContentMgr, SipSubscriptionMgr &defaultSubscriptionMgr, SipSubscribeServerEventHandler &defaultPlugin)
Default Dialog constructor.
Definition: SipSubscribeServer.cpp:102
Specialization of HttpMessage to contain and manipulate SIP messages.
Definition: SipMessage.h:343
UtlBoolean disableEventType(const char *eventType, SipUserAgent *&userAgent, SipPublishContentMgr *&contentMgr, SipSubscribeServerEventHandler *&eventPlugin, SipSubscriptionMgr *&subscriptionMgr)
Tell subscribe server to stop supporting given event type.
Definition: SipSubscribeServer.cpp:307
Top level class for accepting and processing SUBSCRIBE requests.
Definition: SipSubscribeServer.h:102
UtlBoolean enableEventType(const char *eventType, SipUserAgent *userAgent=NULL, SipPublishContentMgr *contentMgr=NULL, SipSubscribeServerEventHandler *eventPlugin=NULL, SipSubscriptionMgr *subscriptionMgr=NULL)
Tell subscribe server to support given event type.
Definition: SipSubscribeServer.cpp:252
SipSubscribeServerEventHandler * getEventHandler(const UtlString &eventType)
Get the event handler for the given eventType.
Definition: SipSubscribeServer.cpp:418
UtlBoolean handleMessage(OsMsg &eventMessage)
Handler for SUBSCRIBE requests, NOTIFY responses and timers.
Definition: SipSubscribeServer.cpp:352
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
static SipSubscribeServer * buildBasicServer(SipUserAgent &userAgent, const char *eventType=NULL)
Helper utility to build a basic server with default behavior.
Definition: SipSubscribeServer.cpp:69
virtual ~SipSubscribeServer()
Destructor.
Definition: SipSubscribeServer.cpp:124
Class for specializing the handling of SIP Events in SipSubscribeServer.
Definition: SipSubscribeServerEventHandler.h:46
UtlBoolean notifySubscribers(const char *resourceId, const char *eventTypeKey, const char *eventType, UtlBoolean isDefaultContent)
Send a NOTIFY to all subscribers to resource and event state.
Definition: SipSubscribeServer.cpp:170

sipXtackLib home page