|
reSIProcate/DialogUsageManager
9680
|
00001 #include "resip/dum/DialogEventInfo.hxx" 00002 #include "resip/dum/InviteSession.hxx" 00003 00004 namespace resip 00005 { 00006 00007 DialogEventInfo::DialogEventInfo() 00008 : mState(DialogEventInfo::Trying), 00009 mDialogId(Data::Empty, Data::Empty, Data::Empty), 00010 mDirection(DialogEventInfo::Initiator), 00011 mInviteSession(InviteSessionHandle::NotValid()), 00012 mCreationTimeSeconds(0), 00013 mReplaced(false) 00014 { 00015 } 00016 00017 DialogEventInfo::DialogEventInfo(const DialogEventInfo& rhs) 00018 : mState(rhs.mState), 00019 mDialogEventId(rhs.mDialogEventId), 00020 mDialogId(rhs.mDialogId), 00021 mDirection(rhs.mDirection), 00022 mInviteSession(rhs.mInviteSession), 00023 mReferredBy(rhs.mReferredBy.get() ? new NameAddr(*rhs.mReferredBy) : 0), 00024 mRouteSet(rhs.mRouteSet), 00025 mLocalIdentity(rhs.mLocalIdentity), 00026 mRemoteIdentity(rhs.mRemoteIdentity), 00027 mLocalTarget(rhs.mLocalTarget), 00028 mRemoteTarget(rhs.mRemoteTarget.get() ? new Uri(*rhs.mRemoteTarget) : 0), 00029 mCreationTimeSeconds(rhs.mCreationTimeSeconds), 00030 mReplaced(rhs.mReplaced) 00031 { 00032 if (rhs.mReplacesId.get()) 00033 { 00034 mReplacesId = std::auto_ptr<DialogId>(new DialogId(rhs.mReplacesId->getCallId(), 00035 rhs.mReplacesId->getLocalTag(), 00036 rhs.mReplacesId->getRemoteTag())); 00037 } 00038 if (rhs.mLocalOfferAnswer.get()) 00039 { 00040 mLocalOfferAnswer = std::auto_ptr<Contents>(rhs.mLocalOfferAnswer->clone()); 00041 } 00042 if (rhs.mRemoteOfferAnswer.get()) 00043 { 00044 mRemoteOfferAnswer = std::auto_ptr<Contents>(rhs.mRemoteOfferAnswer->clone()); 00045 } 00046 } 00047 00048 DialogEventInfo& 00049 DialogEventInfo::operator=(const DialogEventInfo& dialogEventInfo) 00050 { 00051 if (this != &dialogEventInfo) 00052 { 00053 mDialogId = dialogEventInfo.mDialogId; 00054 mState = dialogEventInfo.mState; 00055 mCreationTimeSeconds = dialogEventInfo.mCreationTimeSeconds; 00056 mDialogEventId = dialogEventInfo.mDialogEventId; 00057 mDirection = dialogEventInfo.mDirection; 00058 mInviteSession = dialogEventInfo.mInviteSession; 00059 mLocalIdentity = dialogEventInfo.mLocalIdentity; 00060 00061 mLocalOfferAnswer.reset(0); 00062 mReferredBy.reset(0); 00063 mRemoteOfferAnswer.reset(0); 00064 mRemoteTarget.reset(0); 00065 mReplacesId.reset(0); 00066 00067 if(dialogEventInfo.mLocalOfferAnswer.get()) 00068 { 00069 mLocalOfferAnswer.reset(dialogEventInfo.mLocalOfferAnswer->clone()); 00070 } 00071 00072 if(dialogEventInfo.mReferredBy.get()) 00073 { 00074 mReferredBy.reset((NameAddr*)(dialogEventInfo.mReferredBy->clone())); 00075 } 00076 00077 if(dialogEventInfo.mRemoteOfferAnswer.get()) 00078 { 00079 mRemoteOfferAnswer.reset(dialogEventInfo.mRemoteOfferAnswer->clone()); 00080 } 00081 00082 if(dialogEventInfo.mRemoteTarget.get()) 00083 { 00084 mRemoteTarget.reset((Uri*)dialogEventInfo.mRemoteTarget->clone()); 00085 } 00086 00087 if(dialogEventInfo.mReplacesId.get()) 00088 { 00089 mReplacesId.reset( 00090 new DialogId(dialogEventInfo.mReplacesId->getDialogSetId(), 00091 dialogEventInfo.mReplacesId->getRemoteTag())); 00092 } 00093 00094 mLocalTarget = dialogEventInfo.mLocalTarget; 00095 mRemoteIdentity = dialogEventInfo.mRemoteIdentity; 00096 mRouteSet = dialogEventInfo.mRouteSet; 00097 mReplaced = dialogEventInfo.mReplaced; 00098 } 00099 return *this; 00100 } 00101 00102 bool 00103 DialogEventInfo::operator==(const DialogEventInfo& rhs) const 00104 { 00105 return (mDialogEventId == rhs.mDialogEventId); 00106 } 00107 00108 bool 00109 DialogEventInfo::operator!=(const DialogEventInfo& rhs) const 00110 { 00111 return (mDialogEventId != rhs.mDialogEventId); 00112 } 00113 00114 bool 00115 DialogEventInfo::operator<(const DialogEventInfo& rhs) const 00116 { 00117 return (mDialogEventId < rhs.mDialogEventId); 00118 } 00119 00120 const DialogEventInfo::State& 00121 DialogEventInfo::getState() const 00122 { 00123 return mState; 00124 } 00125 00126 const Data& 00127 DialogEventInfo::getDialogEventId() const 00128 { 00129 return mDialogEventId; 00130 } 00131 00132 const Data& 00133 DialogEventInfo::getCallId() const 00134 { 00135 return mDialogId.getCallId(); 00136 } 00137 00138 const Data& 00139 DialogEventInfo::getLocalTag() const 00140 { 00141 return mDialogId.getLocalTag(); 00142 } 00143 00144 bool 00145 DialogEventInfo::hasRemoteTag() const 00146 { 00147 return (mDialogId.getRemoteTag() != Data::Empty); 00148 } 00149 00150 const Data& 00151 DialogEventInfo::getRemoteTag() const 00152 { 00153 return mDialogId.getRemoteTag(); 00154 } 00155 00156 bool 00157 DialogEventInfo::hasRefferedBy() const 00158 { 00159 return (mReferredBy.get() != NULL); 00160 } 00161 00162 const NameAddr& 00163 DialogEventInfo::getRefferredBy() const 00164 { 00165 return *mReferredBy; 00166 } 00167 00168 const NameAddr& 00169 DialogEventInfo::getLocalIdentity() const 00170 { 00171 return mLocalIdentity; 00172 } 00173 00174 const NameAddr& 00175 DialogEventInfo::getRemoteIdentity() const 00176 { 00177 return mRemoteIdentity; 00178 } 00179 00180 const Uri& 00181 DialogEventInfo::getLocalTarget() const 00182 { 00183 return mLocalTarget; 00184 } 00185 00186 bool 00187 DialogEventInfo::hasRouteSet() const 00188 { 00189 return false; 00190 } 00191 00192 const NameAddrs& 00193 DialogEventInfo::getRouteSet() const 00194 { 00195 return mRouteSet; 00196 } 00197 00198 bool 00199 DialogEventInfo::hasRemoteTarget() const 00200 { 00201 return (mRemoteTarget.get() != NULL); 00202 } 00203 00204 const Uri& 00205 DialogEventInfo::getRemoteTarget() const 00206 { 00207 return *mRemoteTarget; 00208 } 00209 00210 const Contents& 00211 DialogEventInfo::getLocalOfferAnswer() const 00212 { 00213 if (mInviteSession.isValid()) 00214 { 00215 if (mInviteSession->hasLocalOfferAnswer()) 00216 { 00217 return mInviteSession->getLocalOfferAnswer(); 00218 } 00219 } 00220 assert(mLocalOfferAnswer.get() != NULL); 00221 return *mLocalOfferAnswer; 00222 } 00223 00224 const Contents& 00225 DialogEventInfo::getRemoteOfferAnswer() const 00226 { 00227 if (mInviteSession.isValid()) 00228 { 00229 if (mInviteSession->hasRemoteOfferAnswer()) 00230 { 00231 return mInviteSession->getRemoteOfferAnswer(); 00232 } 00233 } 00234 assert(mRemoteOfferAnswer.get() != NULL); 00235 return *mRemoteOfferAnswer; 00236 } 00237 00238 bool 00239 DialogEventInfo::hasLocalOfferAnswer() const 00240 { 00241 return (mInviteSession.isValid() ? mInviteSession->hasLocalOfferAnswer() : mLocalOfferAnswer.get() != 0); 00242 } 00243 00244 bool 00245 DialogEventInfo::hasRemoteOfferAnswer() const 00246 { 00247 return (mInviteSession.isValid() ? mInviteSession->hasRemoteOfferAnswer() : mRemoteOfferAnswer.get() != 0); 00248 } 00249 00250 UInt64 00251 DialogEventInfo::getDurationSeconds() const 00252 { 00253 UInt64 delta = Timer::getTimeSecs() - mCreationTimeSeconds; 00254 return delta; 00255 } 00256 00257 bool 00258 DialogEventInfo::hasReplacesId() const 00259 { 00260 return (mReplacesId.get() != 0); 00261 } 00262 00263 const DialogId& 00264 DialogEventInfo::getReplacesId() const 00265 { 00266 return *mReplacesId; 00267 } 00268 00269 DialogEventInfo::Direction 00270 DialogEventInfo::getDirection() const 00271 { 00272 return mDirection; 00273 } 00274 00275 } // namespace resip 00276 00277 /* ==================================================================== 00278 * The Vovida Software License, Version 1.0 00279 * 00280 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00281 * 00282 * Redistribution and use in source and binary forms, with or without 00283 * modification, are permitted provided that the following conditions 00284 * are met: 00285 * 00286 * 1. Redistributions of source code must retain the above copyright 00287 * notice, this list of conditions and the following disclaimer. 00288 * 00289 * 2. Redistributions in binary form must reproduce the above copyright 00290 * notice, this list of conditions and the following disclaimer in 00291 * the documentation and/or other materials provided with the 00292 * distribution. 00293 * 00294 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00295 * and "Vovida Open Communication Application Library (VOCAL)" must 00296 * not be used to endorse or promote products derived from this 00297 * software without prior written permission. For written 00298 * permission, please contact vocal@vovida.org. 00299 * 00300 * 4. Products derived from this software may not be called "VOCAL", nor 00301 * may "VOCAL" appear in their name, without prior written 00302 * permission of Vovida Networks, Inc. 00303 * 00304 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00305 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00306 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00307 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00308 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00309 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00310 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00311 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00312 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00313 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00314 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00315 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00316 * DAMAGE. 00317 * 00318 * ==================================================================== 00319 * 00320 * This software consists of voluntary contributions made by Vovida 00321 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00322 * Inc. For more information on Vovida Networks, Inc., please see 00323 * <http://www.vovida.org/>. 00324 * 00325 */
1.7.5.1