sipxtacklib  Version 3.3
SipDialogEvent.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 _SipDialogEvent_h_
12 #define _SipDialogEvent_h_
13 
14 // SYSTEM INCLUDES
15 // APPLICATION INCLUDES
16 #include <utl/UtlSList.h>
17 #include <utl/UtlSListIterator.h>
18 #include <net/HttpBody.h>
19 #include <net/Url.h>
20 #include <os/OsDateTime.h>
21 #include <os/OsBSem.h>
22 
23 // DEFINES
24 // MACROS
25 // EXTERNAL FUNCTIONS
26 // EXTERNAL VARIABLES
27 // CONSTANTS
28 
29 
30 #define DIALOG_EVENT_TYPE "dialog"
31 
32 #define BEGIN_DIALOG_INFO "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\""
33 #define END_DIALOG_INFO "</dialog-info>\n"
34 
35 #define VERSION_EQUAL " version="
36 #define STATE_EQUAL " state="
37 #define ENTITY_EQUAL " entity="
38 
39 #define DOUBLE_QUOTE "\""
40 #define END_BRACKET ">"
41 #define END_LINE ">\n"
42 
43 #define BEGIN_DIALOG "<dialog id="
44 #define CALL_ID_EQUAL " call-id="
45 #define LOCAL_TAG_EQUAL " local-tag="
46 #define REMOTE_TAG_EQUAL " remote-tag="
47 #define DIRECTION_EQUAL " direction="
48 #define END_DIALOG "</dialog>\n"
49 
50 #define BEGIN_STATE "<state"
51 #define EVENT_EQUAL " event="
52 #define CODE_EQUAL " code="
53 #define END_STATE "</state>\n"
54 
55 #define BEGIN_DURATION "<duration>"
56 #define END_DURATION "</duration>\n"
57 
58 #define BEGIN_LOCAL "<local>\n"
59 #define END_LOCAL "</local>\n"
60 
61 #define BEGIN_REMOTE "<remote>\n"
62 #define END_REMOTE "</remote>\n"
63 
64 #define BEGIN_IDENTITY "<identity"
65 #define DISPLAY_EQUAL " display="
66 #define END_IDENTITY "</identity>\n"
67 
68 #define BEGIN_TARTGET "<target uri=\""
69 #define END_TARGET "\"/>\n"
70 
71 
72 #define STATE_TRYING "trying"
73 #define STATE_PROCEEDING "proceeding"
74 #define STATE_EARLY "early"
75 #define STATE_CONFIRMED "confirmed"
76 #define STATE_TERMINATED "terminated"
77 
78 // STRUCTS
79 // TYPEDEFS
80 // FORWARD DECLARATIONS
81 
83 
90 class Dialog : public UtlContainable
91 {
92 /* //////////////////////////// PUBLIC //////////////////////////////////// */
93  public:
94 
99  Dialog(const char* dialogId,
101  const char* callId,
102  const char* localTag,
103  const char* remoteTag,
104  const char* direction);
105 
107  ~Dialog();
108 
109  virtual UtlContainableType getContainableType() const;
110 
111  static const UtlContainableType TYPE;
112 
113  virtual unsigned int hash() const;
114 
115  int compareTo(const UtlContainable *b) const;
116 
118 
127  void getDialog(UtlString& dialogId,
128  UtlString& callId,
129  UtlString& localTag,
130  UtlString& remoteTag,
131  UtlString& direction) const;
132 
133  void getCallId(UtlString& callId) const;
134 
135  void setDialogId(const char* dialogId);
136 
137  void getDialogId(UtlString& dialogId) const;
138 
139  void setState(const char* state, const char* event, const char* code);
140 
141  void setTags(const char* local, const char* remote);
142 
143  void getState(UtlString& state, UtlString& event, UtlString& code) const;
144 
145  void setDuration(const unsigned long duration);
146 
147  unsigned long getDuration() const;
148 
149  void setReplaces(const char* callId,
150  const char* localTag,
151  const char* remoteTag);
152 
153  void getReplaces(UtlString& callId,
154  UtlString& localTag,
155  UtlString& remoteTag) const;
156 
157  void setReferredBy(const char* url,
158  const char* display);
159 
160  void getReferredBy(UtlString& url,
161  UtlString& display) const;
162 
163  void setLocalIdentity(const char* identity,
164  const char* display);
165 
166  void getLocalIdentity(UtlString& identity,
167  UtlString& display) const;
168 
169  void setRemoteIdentity(const char* identity,
170  const char* display);
171 
172  void getRemoteIdentity(UtlString& identity,
173  UtlString& display) const;
174 
175  void setLocalTarget(const char* url);
176 
177  void getLocalTarget(UtlString& url) const;
178 
179  void setRemoteTarget(const char* url);
180 
181  void getRemoteTarget(UtlString& url) const;
182 
184 
185 /* //////////////////////////// PROTECTED ///////////////////////////////// */
186  protected:
187 
188  // Set the unique identifier member by concatenating the call-id,
189  // to-tag, and from-tag.
190  void setIdentifier();
191 
192 /* //////////////////////////// PRIVATE /////////////////////////////////// */
193  private:
194 
195  // Variables for dialog element
196  UtlString mId;
197  UtlString mCallId;
198  UtlString mLocalTag;
199  UtlString mRemoteTag;
200  UtlString mDirection;
201  // Unique identifier of the dialog
202  UtlString mIdentifier;
203 
204  // Variables for state element
205  UtlString mState;
206  UtlString mEvent;
207  UtlString mCode;
208 
209  // Variables for duration element
210  long mDuration;
211 
212  // Variables for replaces element
213  UtlString mNewCallId;
214  UtlString mNewLocalTag;
215  UtlString mNewRemoteTag;
216 
217  // Variables for referred-by element
218  UtlString mReferredBy;
219  UtlString mDisplay;
220 
221  // Variables for local element
222  UtlString mLocalIdentity;
223  UtlString mLocalDisplay;
224  UtlString mLocalTarget;
225  UtlString mLocalSessionDescription;
226 
227  // Variables for remote element
228  UtlString mRemoteIdentity;
229  UtlString mRemoteDisplay;
230  UtlString mRemoteTarget;
231  UtlString mRemoteSessionDescription;
232 
233  // Disabled copy constructor
234  Dialog(const Dialog& rDialog);
235 
236  // Disabled assignment operator
237  Dialog& operator=(const Dialog& rhs);
238 };
239 
240 
242 
248 class SipDialogEvent : public HttpBody
249 {
250 /* //////////////////////////// PUBLIC //////////////////////////////////// */
251  public:
252 
257  SipDialogEvent(const char* state,
259  const char* entity);
260 
262  SipDialogEvent(const char* bodyBytes);
263 
265  virtual
266  ~SipDialogEvent();
267 
269 
276  void buildBody() const;
278 
280  virtual int getLength() const;
281 
283 
288  virtual void getBytes(const char** bytes,
289  int* length) const;
290 
292 
296  virtual void getBytes(UtlString* bytes,
297  int* length) const;
298  // Import HttpBody's getBytes methods, except as overridden here.
299  using HttpBody::getBytes;
300 
301  void setEntity(const char* entity);
302 
303  void getEntity(UtlString& entity) const;
304 
305  void setState(const char* state);
306 
307  void getState(UtlString& state) const;
308 
310 
319  void insertDialog(Dialog* dialog);
321 
323  //and tags. If the mRemoteTag of a Dialog object in the hash table
324  //is empty, then testing for match is only done on callId and
325  //localTag. Otherwise, all three fields are used.
326  Dialog* getDialog(UtlString& callId,
327  UtlString& localTag,
328  UtlString& remoteTag);
329 
331  //DialogEventPublisher in handling a DISCONNECTED or FAILED message
332  //the publisher still needs to find the dialog, even if it is just
333  //by the callId. Work-around for XCL-98.
334  Dialog* getDialogByCallId(UtlString& callId);
335 
337  Dialog* removeDialog(Dialog* dialog);
338 
340  UtlBoolean isEmpty();
341 
343  // This iterator is only valid as long as the SipDialogEvent is not
344  // modified, and must be deleted by the caller before the SipDialogEvent
345  // is deleted.
346  UtlSListIterator* getDialogIterator();
347 
349 
350 /* //////////////////////////// PROTECTED ///////////////////////////////// */
351  protected:
352 
354  void parseBody(const char* bytes);
355 
356 
357 /* //////////////////////////// PRIVATE /////////////////////////////////// */
358  private:
359 
361  int mVersion;
362  UtlString mDialogState;
363  UtlString mEntity;
364 
366  UtlSList mDialogs;
367 
369  OsBSem mLock;
370 
372  SipDialogEvent(const SipDialogEvent& rSipDialogEvent);
373 
375  SipDialogEvent& operator=(const SipDialogEvent& rhs);
376 
377 };
378 
379 /* ============================ INLINE METHODS ============================ */
380 
381 #endif // _SipDialogEvent_h_
virtual unsigned int hash() const
Definition: SipDialogEvent.cpp:242
void setTags(const char *local, const char *remote)
Definition: SipDialogEvent.cpp:113
void getReferredBy(UtlString &url, UtlString &display) const
Definition: SipDialogEvent.cpp:172
virtual UtlContainableType getContainableType() const
Definition: SipDialogEvent.cpp:248
void setDialogId(const char *dialogId)
Definition: SipDialogEvent.cpp:90
~Dialog()
Destructor.
Definition: SipDialogEvent.cpp:51
void setRemoteTarget(const char *url)
Definition: SipDialogEvent.cpp:224
void getCallId(UtlString &callId) const
Definition: SipDialogEvent.cpp:84
virtual const char * getBytes() const
Definition: HttpBody.cpp:476
void setRemoteIdentity(const char *identity, const char *display)
Definition: SipDialogEvent.cpp:196
Container for MIME type application/dialog-info+xml.
Definition: SipDialogEvent.h:248
void getRemoteTarget(UtlString &url) const
Definition: SipDialogEvent.cpp:230
void setState(const char *state, const char *event, const char *code)
Definition: SipDialogEvent.cpp:103
void getDialog(UtlString &dialogId, UtlString &callId, UtlString &localTag, UtlString &remoteTag, UtlString &direction) const
Definition: SipDialogEvent.cpp:70
Container for dialog element in the dialog event package.
Definition: SipDialogEvent.h:90
void setLocalTarget(const char *url)
Definition: SipDialogEvent.cpp:212
void getLocalTarget(UtlString &url) const
Definition: SipDialogEvent.cpp:218
void setReplaces(const char *callId, const char *localTag, const char *remoteTag)
Definition: SipDialogEvent.cpp:144
void getDialogId(UtlString &dialogId) const
Definition: SipDialogEvent.cpp:97
void getReplaces(UtlString &callId, UtlString &localTag, UtlString &remoteTag) const
Definition: SipDialogEvent.cpp:154
int compareTo(const UtlContainable *b) const
Definition: SipDialogEvent.cpp:236
void setIdentifier()
Definition: SipDialogEvent.cpp:57
void getLocalIdentity(UtlString &identity, UtlString &display) const
Definition: SipDialogEvent.cpp:188
static const UtlContainableType TYPE
Definition: SipDialogEvent.h:111
void setDuration(const unsigned long duration)
Definition: SipDialogEvent.cpp:132
unsigned long getDuration() const
Definition: SipDialogEvent.cpp:138
void getRemoteIdentity(UtlString &identity, UtlString &display) const
Definition: SipDialogEvent.cpp:204
void setReferredBy(const char *url, const char *display)
Definition: SipDialogEvent.cpp:164
Dialog(const char *dialogId, const char *callId, const char *localTag, const char *remoteTag, const char *direction)
Constructor.
Definition: SipDialogEvent.cpp:35
class to contain an HTTP body
Definition: HttpBody.h:55
void setLocalIdentity(const char *identity, const char *display)
Definition: SipDialogEvent.cpp:180
void getState(UtlString &state, UtlString &event, UtlString &code) const
Definition: SipDialogEvent.cpp:122

sipXtackLib home page