/[resiprocate]/main/resip/dum/DialogEventInfo.cxx
ViewVC logotype

Contents of /main/resip/dum/DialogEventInfo.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8726 - (show annotations) (download)
Sun Jan 3 17:15:16 2010 UTC (9 years, 10 months ago) by sgodin
File size: 8557 byte(s)
-made DUM InviteSession offer answer logic to be Content type generic 
 (ie. able to handle offer/answer of non-SDP mime types)
 - now stores / manipulates offer/answer logic using base Contents class instead 
   of SdpContents
 - full backwards compatibility is possible
 - new setting on InviteSessionHandler constructor to indicate to InviteSession 
   if the onOffer/onAnswer (etc.) callbacks should return SDP or generic 
   Contents (see note in InviteSessionHandler.hxx)
1 #include "resip/dum/DialogEventInfo.hxx"
2 #include "resip/dum/InviteSession.hxx"
3
4 namespace resip
5 {
6
7 DialogEventInfo::DialogEventInfo()
8 : mState(DialogEventInfo::Trying),
9 mDialogId(Data::Empty, Data::Empty, Data::Empty),
10 mDirection(DialogEventInfo::Initiator),
11 mInviteSession(InviteSessionHandle::NotValid()),
12 mCreationTimeSeconds(0),
13 mReplaced(false)
14 {
15 }
16
17 DialogEventInfo::DialogEventInfo(const DialogEventInfo& rhs)
18 : mState(rhs.mState),
19 mDialogEventId(rhs.mDialogEventId),
20 mDialogId(rhs.mDialogId),
21 mDirection(rhs.mDirection),
22 mInviteSession(rhs.mInviteSession),
23 mReferredBy(rhs.mReferredBy.get() ? new NameAddr(*rhs.mReferredBy) : 0),
24 mRouteSet(rhs.mRouteSet),
25 mLocalIdentity(rhs.mLocalIdentity),
26 mRemoteIdentity(rhs.mRemoteIdentity),
27 mLocalTarget(rhs.mLocalTarget),
28 mRemoteTarget(rhs.mRemoteTarget.get() ? new Uri(*rhs.mRemoteTarget) : 0),
29 mCreationTimeSeconds(rhs.mCreationTimeSeconds),
30 mReplaced(rhs.mReplaced)
31 {
32 if (rhs.mReplacesId.get())
33 {
34 mReplacesId = std::auto_ptr<DialogId>(new DialogId(rhs.mReplacesId->getCallId(),
35 rhs.mReplacesId->getLocalTag(),
36 rhs.mReplacesId->getRemoteTag()));
37 }
38 if (rhs.mLocalOfferAnswer.get())
39 {
40 mLocalOfferAnswer = std::auto_ptr<Contents>(rhs.mLocalOfferAnswer->clone());
41 }
42 if (rhs.mRemoteOfferAnswer.get())
43 {
44 mRemoteOfferAnswer = std::auto_ptr<Contents>(rhs.mRemoteOfferAnswer->clone());
45 }
46 }
47
48 DialogEventInfo&
49 DialogEventInfo::operator=(const DialogEventInfo& dialogEventInfo)
50 {
51 if (this != &dialogEventInfo)
52 {
53 mDialogId = dialogEventInfo.mDialogId;
54 mState = dialogEventInfo.mState;
55 mCreationTimeSeconds = dialogEventInfo.mCreationTimeSeconds;
56 mDialogEventId = dialogEventInfo.mDialogEventId;
57 mDirection = dialogEventInfo.mDirection;
58 mInviteSession = dialogEventInfo.mInviteSession;
59 mLocalIdentity = dialogEventInfo.mLocalIdentity;
60
61 mLocalOfferAnswer.reset(0);
62 mReferredBy.reset(0);
63 mRemoteOfferAnswer.reset(0);
64 mRemoteTarget.reset(0);
65 mReplacesId.reset(0);
66
67 if(dialogEventInfo.mLocalOfferAnswer.get())
68 {
69 mLocalOfferAnswer.reset(dialogEventInfo.mLocalOfferAnswer->clone());
70 }
71
72 if(dialogEventInfo.mReferredBy.get())
73 {
74 mReferredBy.reset((NameAddr*)(dialogEventInfo.mReferredBy->clone()));
75 }
76
77 if(dialogEventInfo.mRemoteOfferAnswer.get())
78 {
79 mRemoteOfferAnswer.reset(dialogEventInfo.mRemoteOfferAnswer->clone());
80 }
81
82 if(dialogEventInfo.mRemoteTarget.get())
83 {
84 mRemoteTarget.reset((Uri*)dialogEventInfo.mRemoteTarget->clone());
85 }
86
87 if(dialogEventInfo.mReplacesId.get())
88 {
89 mReplacesId.reset(
90 new DialogId(dialogEventInfo.mReplacesId->getDialogSetId(),
91 dialogEventInfo.mReplacesId->getRemoteTag()));
92 }
93
94 mLocalTarget = dialogEventInfo.mLocalTarget;
95 mRemoteIdentity = dialogEventInfo.mRemoteIdentity;
96 mRouteSet = dialogEventInfo.mRouteSet;
97 mReplaced = dialogEventInfo.mReplaced;
98 }
99 return *this;
100 }
101
102 bool
103 DialogEventInfo::operator==(const DialogEventInfo& rhs) const
104 {
105 return (mDialogEventId == rhs.mDialogEventId);
106 }
107
108 bool
109 DialogEventInfo::operator!=(const DialogEventInfo& rhs) const
110 {
111 return (mDialogEventId != rhs.mDialogEventId);
112 }
113
114 bool
115 DialogEventInfo::operator<(const DialogEventInfo& rhs) const
116 {
117 return (mDialogEventId < rhs.mDialogEventId);
118 }
119
120 const DialogEventInfo::State&
121 DialogEventInfo::getState() const
122 {
123 return mState;
124 }
125
126 const Data&
127 DialogEventInfo::getDialogEventId() const
128 {
129 return mDialogEventId;
130 }
131
132 const Data&
133 DialogEventInfo::getCallId() const
134 {
135 return mDialogId.getCallId();
136 }
137
138 const Data&
139 DialogEventInfo::getLocalTag() const
140 {
141 return mDialogId.getLocalTag();
142 }
143
144 bool
145 DialogEventInfo::hasRemoteTag() const
146 {
147 return (mDialogId.getRemoteTag() != Data::Empty);
148 }
149
150 const Data&
151 DialogEventInfo::getRemoteTag() const
152 {
153 return mDialogId.getRemoteTag();
154 }
155
156 bool
157 DialogEventInfo::hasRefferedBy() const
158 {
159 return (mReferredBy.get() != NULL);
160 }
161
162 const NameAddr&
163 DialogEventInfo::getRefferredBy() const
164 {
165 return *mReferredBy;
166 }
167
168 const NameAddr&
169 DialogEventInfo::getLocalIdentity() const
170 {
171 return mLocalIdentity;
172 }
173
174 const NameAddr&
175 DialogEventInfo::getRemoteIdentity() const
176 {
177 return mRemoteIdentity;
178 }
179
180 const Uri&
181 DialogEventInfo::getLocalTarget() const
182 {
183 return mLocalTarget;
184 }
185
186 bool
187 DialogEventInfo::hasRouteSet() const
188 {
189 return false;
190 }
191
192 const NameAddrs&
193 DialogEventInfo::getRouteSet() const
194 {
195 return mRouteSet;
196 }
197
198 bool
199 DialogEventInfo::hasRemoteTarget() const
200 {
201 return (mRemoteTarget.get() != NULL);
202 }
203
204 const Uri&
205 DialogEventInfo::getRemoteTarget() const
206 {
207 return *mRemoteTarget;
208 }
209
210 const Contents&
211 DialogEventInfo::getLocalOfferAnswer() const
212 {
213 if (mInviteSession.isValid())
214 {
215 if (mInviteSession->hasLocalOfferAnswer())
216 {
217 return mInviteSession->getLocalOfferAnswer();
218 }
219 }
220 assert(mLocalOfferAnswer.get() != NULL);
221 return *mLocalOfferAnswer;
222 }
223
224 const Contents&
225 DialogEventInfo::getRemoteOfferAnswer() const
226 {
227 if (mInviteSession.isValid())
228 {
229 if (mInviteSession->hasRemoteOfferAnswer())
230 {
231 return mInviteSession->getRemoteOfferAnswer();
232 }
233 }
234 assert(mRemoteOfferAnswer.get() != NULL);
235 return *mRemoteOfferAnswer;
236 }
237
238 bool
239 DialogEventInfo::hasLocalOfferAnswer() const
240 {
241 return (mInviteSession.isValid() ? mInviteSession->hasLocalOfferAnswer() : mLocalOfferAnswer.get() != 0);
242 }
243
244 bool
245 DialogEventInfo::hasRemoteOfferAnswer() const
246 {
247 return (mInviteSession.isValid() ? mInviteSession->hasRemoteOfferAnswer() : mRemoteOfferAnswer.get() != 0);
248 }
249
250 UInt64
251 DialogEventInfo::getDurationSeconds() const
252 {
253 UInt64 delta = Timer::getTimeSecs() - mCreationTimeSeconds;
254 return delta;
255 }
256
257 bool
258 DialogEventInfo::hasReplacesId() const
259 {
260 return (mReplacesId.get() != 0);
261 }
262
263 const DialogId&
264 DialogEventInfo::getReplacesId() const
265 {
266 return *mReplacesId;
267 }
268
269 DialogEventInfo::Direction
270 DialogEventInfo::getDirection() const
271 {
272 return mDirection;
273 }
274
275 } // namespace resip
276
277 /* ====================================================================
278 * The Vovida Software License, Version 1.0
279 *
280 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
281 *
282 * Redistribution and use in source and binary forms, with or without
283 * modification, are permitted provided that the following conditions
284 * are met:
285 *
286 * 1. Redistributions of source code must retain the above copyright
287 * notice, this list of conditions and the following disclaimer.
288 *
289 * 2. Redistributions in binary form must reproduce the above copyright
290 * notice, this list of conditions and the following disclaimer in
291 * the documentation and/or other materials provided with the
292 * distribution.
293 *
294 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
295 * and "Vovida Open Communication Application Library (VOCAL)" must
296 * not be used to endorse or promote products derived from this
297 * software without prior written permission. For written
298 * permission, please contact vocal@vovida.org.
299 *
300 * 4. Products derived from this software may not be called "VOCAL", nor
301 * may "VOCAL" appear in their name, without prior written
302 * permission of Vovida Networks, Inc.
303 *
304 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
305 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
306 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
307 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
308 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
309 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
310 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
311 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
312 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
313 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
314 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
315 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
316 * DAMAGE.
317 *
318 * ====================================================================
319 *
320 * This software consists of voluntary contributions made by Vovida
321 * Networks, Inc. and many individuals on behalf of Vovida Networks,
322 * Inc. For more information on Vovida Networks, Inc., please see
323 * <http://www.vovida.org/>.
324 *
325 */

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27