sipxtacklib  Version 3.3
SipResourceList.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 _SipResourceList_h_
12 #define _SipResourceList_h_
13 
14 // SYSTEM INCLUDES
15 // APPLICATION INCLUDES
16 #include <utl/UtlHashMap.h>
17 #include <net/HttpBody.h>
18 #include <net/Url.h>
19 #include <net/SipDialogEvent.h>
20 #include <net/SipPresenceEvent.h>
21 #include <os/OsDateTime.h>
22 #include <os/OsBSem.h>
23 
24 // DEFINES
25 // MACROS
26 // EXTERNAL FUNCTIONS
27 // EXTERNAL VARIABLES
28 // CONSTANTS
29 #define RESOURCE_LIST_CONTENT_TYPE "application/rlmi+xml"
30 #define RESOURCE_LIST_XMLNS "urn:ietf:params:xml:ns:rlmi"
31 
32 #define BEGIN_LIST "<list xmlns=\"urn:ietf:params:xml:ns:rlmi\""
33 #define END_LIST "</list>\n"
34 
35 #define URI_EQUAL " uri="
36 #define FULL_STATE_EQUAL " fullState="
37 
38 #define BEGIN_RESOURCE "<resource uri="
39 #define END_RESOURCE "</resource>\n"
40 
41 #define BEGIN_NAME "<name>"
42 #define END_NAME "</name>\n"
43 
44 #define BEGIN_INSTANCE "<instance id="
45 
46 #define STATE_ACTIVE "active"
47 #define STATE_PENDIND "pending"
48 #define STATE_TERMINATED "terminated"
49 
50 // STRUCTS
51 // TYPEDEFS
52 // FORWARD DECLARATIONS
53 
55 
63 class Resource : public UtlContainable
64 {
65 /* //////////////////////////// PUBLIC //////////////////////////////////// */
66  public:
67 
72  Resource(const char* uri);
74 
76  Resource(const Resource& rResource);
77 
79  ~Resource();
80 
81  virtual UtlContainableType getContainableType() const;
82 
83  virtual unsigned int hash() const;
84 
85  int compareTo(const UtlContainable *b) const;
86 
88 
97  void getResourceUri(UtlString& uri) const;
98 
99  void setName(const char* name);
100 
101  void getName(UtlString& name) const;
102 
103  void setInstance(const char* id,
104  const char* state);
105 
106  void getInstance(UtlString& id,
107  UtlString& state) const;
108 
110 
111 /* //////////////////////////// PROTECTED ///////////////////////////////// */
112  protected:
113 
114 /* //////////////////////////// PRIVATE /////////////////////////////////// */
115  private:
116 
117  // Variables for resource element
118  UtlString mUri;
119 
120  // Variables for name element
121  UtlString mName;
122 
123  // Variables for instance element
124  UtlString mId;
125  UtlString mState;
126 
127  //Assignment operator
128  Resource& operator=(const Resource& rhs);
129 };
130 
131 
133 
139 class SipResourceList : public HttpBody
140 {
141 /* //////////////////////////// PUBLIC //////////////////////////////////// */
142  public:
143 
148  SipResourceList(const UtlBoolean state,
150  const char* uri,
151  const char* type);
152 
153 
155  SipResourceList(const char* bodyBytes, const char* type);
156 
158  virtual
159  ~SipResourceList();
160 
162 
169  void buildBody() const;
171 
173  void getEventType(UtlString& type) const;
174 
176  virtual int getLength() const;
177 
179  void getListUri(UtlString& uri) const;
180 
182 
187  virtual void getBytes(const char** bytes,
188  int* length) const;
189 
191 
196  virtual void getBytes(UtlString* bytes,
197  int* length) const;
198 
200 
209  void insertResource(Resource* resource);
211 
213  Resource* getResource(UtlString& resourceUri);
214 
216  Resource* removeResource(Resource* resource);
217 
219  void insertEvent(UtlContainable* event);
220 
222  UtlContainable* removeEvent(UtlContainable* event);
223 
225  UtlBoolean isEmpty();
226 
228 
229 /* //////////////////////////// PROTECTED ///////////////////////////////// */
230  protected:
231 
233  void parseBody(const char* bytes);
234 
235 
236 /* //////////////////////////// PRIVATE /////////////////////////////////// */
237  private:
238 
240  int mVersion;
241  UtlString mFullState;
242  UtlString mListUri;
243  UtlString mEventType;
244 
246  OsBSem mLock;
247 
249  UtlHashMap mResources;
250 
252  UtlHashMap mEvents;
253 
255  SipResourceList(const SipResourceList& rSipResourceList);
256 
258  SipResourceList& operator=(const SipResourceList& rhs);
259 
260 };
261 
262 /* ============================ INLINE METHODS ============================ */
263 
264 #endif // _SipResourceList_h_
void setName(const char *name)
Definition: SipResourceList.cpp:72
void getInstance(UtlString &id, UtlString &state) const
Definition: SipResourceList.cpp:92
void getResourceUri(UtlString &uri) const
Definition: SipResourceList.cpp:66
int compareTo(const UtlContainable *b) const
Definition: SipResourceList.cpp:100
Container for resource element in the resource list.
Definition: SipResourceList.h:63
void getName(UtlString &name) const
Definition: SipResourceList.cpp:78
~Resource()
Destructor.
Definition: SipResourceList.cpp:42
virtual UtlContainableType getContainableType() const
Definition: SipResourceList.cpp:112
class to contain an HTTP body
Definition: HttpBody.h:55
void setInstance(const char *id, const char *state)
Definition: SipResourceList.cpp:84
virtual unsigned int hash() const
Definition: SipResourceList.cpp:106
Resource(const char *uri)
Constructor.
Definition: SipResourceList.cpp:35
Container for MIME type application/rlmi+xml.
Definition: SipResourceList.h:139

sipXtackLib home page