|
reSIProcate/DialogUsageManager
9680
|
00001 #include "DialogId.hxx" 00002 #include "resip/stack/SipMessage.hxx" 00003 #include "rutil/Logger.hxx" 00004 00005 #define RESIPROCATE_SUBSYSTEM Subsystem::DUM 00006 00007 using namespace resip; 00008 00009 DialogId::DialogId(const SipMessage& msg) : 00010 mDialogSetId(msg), 00011 mRemoteTag(Data::Empty) 00012 { 00013 //find remote tag, which may not exist 00014 if (msg.isExternal()) 00015 { 00016 if(msg.isResponse()) 00017 { 00018 if (msg.header(h_To).exists(p_tag)) 00019 { 00020 mRemoteTag = msg.header(h_To).param(p_tag); 00021 } 00022 } 00023 else 00024 { 00025 if (msg.header(h_From).exists(p_tag)) 00026 { 00027 mRemoteTag = msg.header(h_From).param(p_tag); 00028 } 00029 } 00030 } 00031 else 00032 { 00033 if(msg.isRequest()) 00034 { 00035 //?dcm? -- is this just for 2543? At this point, we will have to have 00036 //established a dialog(or else we would just have a dialogset) 00037 if (msg.header(h_To).exists(p_tag)) 00038 { 00039 mRemoteTag = msg.header(h_To).param(p_tag); 00040 } 00041 } 00042 else 00043 { 00044 if (msg.header(h_From).exists(p_tag)) 00045 { 00046 mRemoteTag = msg.header(h_From).param(p_tag); 00047 } 00048 } 00049 } 00050 DebugLog ( << "DialogId::DialogId: " << *this); 00051 } 00052 00053 DialogId::DialogId(const Data& callId, const Data& localTag, const Data& remoteTag) : 00054 mDialogSetId(callId, localTag), 00055 mRemoteTag(remoteTag) 00056 { 00057 } 00058 00059 DialogId::DialogId(const DialogSetId& id, const Data& remoteTag) : 00060 mDialogSetId(id), 00061 mRemoteTag(remoteTag) 00062 { 00063 DebugLog ( << "DialogId::DialogId: " << *this); 00064 } 00065 00066 bool 00067 DialogId::operator==(const DialogId& rhs) const 00068 { 00069 return mDialogSetId == rhs.mDialogSetId && mRemoteTag == rhs.mRemoteTag; 00070 } 00071 00072 bool 00073 DialogId::operator!=(const DialogId& rhs) const 00074 { 00075 return mDialogSetId != rhs.mDialogSetId || mRemoteTag != rhs.mRemoteTag; 00076 } 00077 00078 bool 00079 DialogId::operator<(const DialogId& rhs) const 00080 { 00081 if (mDialogSetId < rhs.mDialogSetId) 00082 { 00083 return true; 00084 } 00085 if (mDialogSetId > rhs.mDialogSetId) 00086 { 00087 return false; 00088 } 00089 return mRemoteTag < rhs.mRemoteTag; 00090 } 00091 00092 const DialogSetId& 00093 DialogId::getDialogSetId() const 00094 { 00095 return mDialogSetId; 00096 } 00097 00098 const Data& 00099 DialogId::getCallId() const 00100 { 00101 return getDialogSetId().getCallId(); 00102 } 00103 00104 const Data& 00105 DialogId::getLocalTag() const 00106 { 00107 return getDialogSetId().getLocalTag(); 00108 } 00109 00110 const Data& 00111 DialogId::getRemoteTag() const 00112 { 00113 return mRemoteTag; 00114 } 00115 00116 00117 EncodeStream& 00118 resip::operator<<(EncodeStream& os, const DialogId& id) 00119 { 00120 return os << id.mDialogSetId << "-" << id.mRemoteTag; 00121 } 00122 00123 00124 size_t DialogId::hash() const 00125 { 00126 return mDialogSetId.hash() ^ mRemoteTag.hash(); 00127 } 00128 00129 HashValueImp(resip::DialogId, data.hash()); 00130 00131 /* ==================================================================== 00132 * The Vovida Software License, Version 1.0 00133 * 00134 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00135 * 00136 * Redistribution and use in source and binary forms, with or without 00137 * modification, are permitted provided that the following conditions 00138 * are met: 00139 * 00140 * 1. Redistributions of source code must retain the above copyright 00141 * notice, this list of conditions and the following disclaimer. 00142 * 00143 * 2. Redistributions in binary form must reproduce the above copyright 00144 * notice, this list of conditions and the following disclaimer in 00145 * the documentation and/or other materials provided with the 00146 * distribution. 00147 * 00148 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00149 * and "Vovida Open Communication Application Library (VOCAL)" must 00150 * not be used to endorse or promote products derived from this 00151 * software without prior written permission. For written 00152 * permission, please contact vocal@vovida.org. 00153 * 00154 * 4. Products derived from this software may not be called "VOCAL", nor 00155 * may "VOCAL" appear in their name, without prior written 00156 * permission of Vovida Networks, Inc. 00157 * 00158 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00159 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00160 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00161 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00162 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00163 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00164 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00165 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00166 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00167 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00168 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00169 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00170 * DAMAGE. 00171 * 00172 * ==================================================================== 00173 * 00174 * This software consists of voluntary contributions made by Vovida 00175 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00176 * Inc. For more information on Vovida Networks, Inc., please see 00177 * <http://www.vovida.org/>. 00178 * 00179 */
1.7.5.1