sipxtacklib  Version 3.3
SipPublishContentMgr.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 _SipPublishContentMgr_h_
13 #define _SipPublishContentMgr_h_
14 
15 // SYSTEM INCLUDES
16 
17 // APPLICATION INCLUDES
18 
19 #include <os/OsDefs.h>
20 #include <os/OsMutex.h>
21 #include <utl/UtlDefs.h>
22 #include <utl/UtlHashMap.h>
23 #include <utl/UtlContainableAtomic.h>
24 
25 // DEFINES
26 // MACROS
27 // EXTERNAL FUNCTIONS
28 // EXTERNAL VARIABLES
29 // CONSTANTS
30 // STRUCTS
31 // FORWARD DECLARATIONS
32 class HttpBody;
33 class UtlString;
35 
36 // TYPEDEFS
37 
94 {
95 /* //////////////////////////// PUBLIC //////////////////////////////////// */
96 public:
97 
110  typedef void (*SipPublisherContentChangeCallback) (void* applicationData,
111  const char* resourceId,
112  const char* eventTypeKey,
113  const char* eventType,
114  UtlBoolean isDefaultContent);
115 
116 /* ============================ CREATORS ================================== */
117 
120 
121 
123  virtual
125 
126 
127 /* ============================ MANIPULATORS ============================== */
128 
155  virtual void publishDefault(const char* eventTypeKey,
156  const char* eventType,
157  int numContentTypes,
158  HttpBody* eventContent[]);
159 
165  virtual void publishDefault(const char* eventTypeKey,
166  const char* eventType,
168  defaultConstructor);
169 
173  virtual void unpublishDefault(const char* eventTypeKey,
174  const char* eventType);
175 
214  virtual void publish(const char* resourceId,
215  const char* eventTypeKey,
216  const char* eventType,
217  int numContentTypes,
218  HttpBody* eventContent[],
219  UtlBoolean noNotify = FALSE);
220 
238  virtual void unpublish(const char* resourceId,
239  const char* eventTypeKey,
240  const char* eventType);
241 
261  virtual UtlBoolean getPublished(const char* resourceId,
262  const char* eventTypeKey,
263  int maxContentTypes,
264  int& numContentTypes,
265  HttpBody* eventContent[],
267  defaultConstructor);
268 
296  virtual UtlBoolean getContent(const char* resourceId,
297  const char* eventTypeKey,
298  const char* eventType,
299  const char* acceptHeaderValue,
300  HttpBody*& content,
301  UtlBoolean& isDefaultContent);
302 
319  virtual UtlBoolean setContentChangeObserver(const char* eventType,
320  void* applicationData,
321  SipPublisherContentChangeCallback callbackFunction);
322 
327  virtual UtlBoolean removeContentChangeObserver(const char* eventType,
328  void*& applicationData,
329  SipPublisherContentChangeCallback& callbackFunction);
330 
333  int dumpContents(UtlString& dumpString);
334 
335 /* ============================ ACCESSORS ================================= */
336 
338  void getStats(int& numDefaultContent,
339  int& numDefaultConstructor,
340  int& numResourceSpecificContent,
341  int& numCallbacksRegistered);
342 
343 /* ============================ INQUIRY =================================== */
344 
345 
346 /* //////////////////////////// PROTECTED ///////////////////////////////// */
347 protected:
348 
349 /* //////////////////////////// PRIVATE /////////////////////////////////// */
350 private:
352  UtlBoolean buildContentTypesContainer(const char* acceptHeaderValue,
353  UtlHashMap& contentTypes);
354 
356  SipPublishContentMgr(const SipPublishContentMgr& rSipPublishContentMgr);
357 
359  SipPublishContentMgr& operator=(const SipPublishContentMgr& rhs);
360 
362  void lock();
363 
365  void unlock();
366 
367  OsMutex mPublishMgrMutex;
368  // Indexed by strings "resourceId\001eventTypeKey".
369  UtlHashMap mContentEntries;
370  // Indexed by strings "\001eventTypeKey".
371  UtlHashMap mDefaultContentEntries;
372  UtlHashMap mDefaultContentConstructors;
373  // Indexed by strings "eventType".
374  UtlHashMap mEventContentCallbacks;
375 };
376 
388 class SipPublishContentMgrDefaultConstructor : public UtlContainableAtomic
389 {
390  public:
391 
401  void virtual generateDefaultContent(SipPublishContentMgr* contentMgr,
402  const char* resourceId,
403  const char* eventTypeKey,
404  const char* eventType) = 0;
405 
407  virtual SipPublishContentMgrDefaultConstructor* copy() = 0;
408 };
409 
410 /* ============================ INLINE METHODS ============================ */
411 
412 #endif // _SipPublishContentMgr_h_
virtual void unpublish(const char *resourceId, const char *eventTypeKey, const char *eventType)
Remove the content for the given resourceId and eventTypeKey The content bodies are given back so tha...
Definition: SipPublishContentMgr.cpp:273
virtual UtlBoolean getContent(const char *resourceId, const char *eventTypeKey, const char *eventType, const char *acceptHeaderValue, HttpBody *&content, UtlBoolean &isDefaultContent)
Get the content for the given resourceId, eventTypeKey and contentTypes Retrieves the content type id...
Definition: SipPublishContentMgr.cpp:436
virtual UtlBoolean removeContentChangeObserver(const char *eventType, void *&applicationData, SipPublisherContentChangeCallback &callbackFunction)
Remove the current observer for the eventTypeKey If the given callbackFunction does not match the exi...
Definition: SipPublishContentMgr.cpp:388
virtual UtlBoolean setContentChangeObserver(const char *eventType, void *applicationData, SipPublisherContentChangeCallback callbackFunction)
Set the callback which gets invoked whenever the content changes Currently only one observer is allow...
Definition: SipPublishContentMgr.cpp:342
virtual void publishDefault(const char *eventTypeKey, const char *eventType, int numContentTypes, HttpBody *eventContent[])
Provide the default content for the given event type key.
Definition: SipPublishContentMgr.cpp:216
int dumpContents(UtlString &dumpString)
Debug dump list of contents.
Definition: SipPublishContentMgr.cpp:635
void getStats(int &numDefaultContent, int &numDefaultConstructor, int &numResourceSpecificContent, int &numCallbacksRegistered)
Get some debug information.
Definition: SipPublishContentMgr.cpp:544
SipPublishContentMgr()
Default publish container constructor.
Definition: SipPublishContentMgr.cpp:90
Helper class for SipPublishContentMgr.
Definition: SipPublishContentMgr.h:388
virtual void unpublishDefault(const char *eventTypeKey, const char *eventType)
Remove the default content and default content constructor for eventTypeKey.
Definition: SipPublishContentMgr.cpp:334
virtual UtlBoolean getPublished(const char *resourceId, const char *eventTypeKey, int maxContentTypes, int &numContentTypes, HttpBody *eventContent[], SipPublishContentMgrDefaultConstructor **defaultConstructor)
Fetch the published content for a given resourceId/eventTypeKey.
Definition: SipPublishContentMgr.cpp:557
virtual void publish(const char *resourceId, const char *eventTypeKey, const char *eventType, int numContentTypes, HttpBody *eventContent[], UtlBoolean noNotify=FALSE)
Provide the given content for the resource and event type key An application provides content (i...
Definition: SipPublishContentMgr.cpp:125
Class for managing body content to be accepted via PUBLISH or provided in NOTIFY requests.
Definition: SipPublishContentMgr.h:93
class to contain an HTTP body
Definition: HttpBody.h:55
void(* SipPublisherContentChangeCallback)(void *applicationData, const char *resourceId, const char *eventTypeKey, const char *eventType, UtlBoolean isDefaultContent)
Callback used to notify interested applications when content has changed Well behaved applications th...
Definition: SipPublishContentMgr.h:110
virtual ~SipPublishContentMgr()
Destructor.
Definition: SipPublishContentMgr.cpp:104

sipXtackLib home page