sipxtacklib  Version 3.3
SipPresenceEvent.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 _SipPresenceEvent_h_
12 #define _SipPresenceEvent_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 <os/OsDateTime.h>
20 #include <os/OsBSem.h>
21 
22 // DEFINES
23 // MACROS
24 // EXTERNAL FUNCTIONS
25 // EXTERNAL VARIABLES
26 // CONSTANTS
27 
28 #define PRESENCE_EVENT_CONTENT_TYPE "application/pidf+xml"
29 #define PRESENCE_EVENT_TYPE "presence"
30 
31 #define BEGIN_PRESENCE "<presence xmlns=\"urn:ietf:params:xml:ns:pidf\""
32 #define END_PRESENCE "</presence>\n"
33 
34 #define PRESENTITY_EQUAL " entity="
35 
36 #define BEGIN_TUPLE "<tuple id="
37 #define END_TUPLE "</tuple>\n"
38 
39 #define BEGIN_STATUS "<status>\n"
40 #define END_STATUS "</status>\n"
41 
42 #define BEGIN_BASIC "<basic>"
43 #define END_BASIC "</basic>\n"
44 
45 #define BEGIN_CONTACT "<contact>"
46 #define END_CONTACT "</contact>\n"
47 
48 
49 #define STATUS_OPEN "open"
50 #define STATUS_CLOSED "closed"
51 
52 // STRUCTS
53 // TYPEDEFS
54 // FORWARD DECLARATIONS
55 
57 
63 class Tuple : public UtlContainable
64 {
65 /* //////////////////////////// PUBLIC //////////////////////////////////// */
66  public:
67 
72  Tuple(const char* tupleId);
74 
76  Tuple(const Tuple& rTuple);
77 
79  ~Tuple();
80 
81  virtual UtlContainableType getContainableType() const;
82 
83  static const UtlContainableType TYPE;
84 
85  virtual unsigned int hash() const;
86 
87  int compareTo(const UtlContainable *b) const;
88 
90 
99  void setTupleId(const char* tupleId);
100 
101  void getTupleId(UtlString& tupleId) const;
102 
103  void setStatus(const char* status);
104 
105  void getStatus(UtlString& state) const;
106 
107  void setContact(const char* url, const float priority);
108 
109  void getContact(UtlString& url, float& priority) const;
110 
112 
113 /* //////////////////////////// PROTECTED ///////////////////////////////// */
114  protected:
115 
116 /* //////////////////////////// PRIVATE /////////////////////////////////// */
117  private:
118 
119  // Variables for tuple element
120  UtlString mId;
121 
122  // Variables for status element
123  UtlString mStatus;
124 
125  // Variables for contact element
126  UtlString mContactUrl;
127  float mPriority;
128 
129  //Assignment operator
130  Tuple& operator=(const Tuple& rhs);
131 };
132 
133 
135 
141 {
142 /* //////////////////////////// PUBLIC //////////////////////////////////// */
143  public:
144 
149  SipPresenceEvent(const char* entity, const char* bodyBytes = NULL);
151 
153  virtual
154  ~SipPresenceEvent();
155 
157 
164  void buildBody() const;
166 
168  virtual int getLength() const;
169 
171 
176  virtual void getBytes(const char** bytes,
177  int* length) const;
178 
180 
185  virtual void getBytes(UtlString* bytes,
186  int* length) const;
187 
189 
198  void insertTuple(Tuple* tuple);
200 
202  Tuple* getTuple(UtlString& tupleId);
203 
205  Tuple* removeTuple(Tuple* tuple);
206 
208  UtlBoolean isEmpty();
209 
211 
212 /* //////////////////////////// PROTECTED ///////////////////////////////// */
213  protected:
214 
216  void parseBody(const char* bytes);
217 
218 
219 /* //////////////////////////// PRIVATE /////////////////////////////////// */
220  private:
221 
223  UtlString mEntity;
224 
226  UtlHashMap mTuples;
227 
229  OsBSem mLock;
230 
232  SipPresenceEvent(const SipPresenceEvent& rSipPresenceEvent);
233 
235  SipPresenceEvent& operator=(const SipPresenceEvent& rhs);
236 
237 };
238 
239 /* ============================ INLINE METHODS ============================ */
240 
241 #endif // _SipPresenceEvent_h_
Container for tuple element in the presence event package.
Definition: SipPresenceEvent.h:63
void setStatus(const char *status)
Definition: SipPresenceEvent.cpp:81
Tuple(const char *tupleId)
Constructor.
Definition: SipPresenceEvent.cpp:39
int compareTo(const UtlContainable *b) const
Definition: SipPresenceEvent.cpp:109
Container for MIME type application/pidf+xml.
Definition: SipPresenceEvent.h:140
static const UtlContainableType TYPE
Definition: SipPresenceEvent.h:83
~Tuple()
Destructor.
Definition: SipPresenceEvent.cpp:46
void getTupleId(UtlString &tupleId) const
Definition: SipPresenceEvent.cpp:75
void getContact(UtlString &url, float &priority) const
Definition: SipPresenceEvent.cpp:101
virtual UtlContainableType getContainableType() const
Definition: SipPresenceEvent.cpp:121
void setContact(const char *url, const float priority)
Definition: SipPresenceEvent.cpp:93
virtual unsigned int hash() const
Definition: SipPresenceEvent.cpp:115
class to contain an HTTP body
Definition: HttpBody.h:55
void getStatus(UtlString &state) const
Definition: SipPresenceEvent.cpp:87
void setTupleId(const char *tupleId)
Definition: SipPresenceEvent.cpp:69

sipXtackLib home page