|
reSIProcate/DialogUsageManager
9680
|
00001 #include "resip/stack/Helper.hxx" 00002 #include "rutil/Logger.hxx" 00003 #include "resip/dum/DialogUsageManager.hxx" 00004 #include "resip/dum/MasterProfile.hxx" 00005 #include "resip/dum/BaseCreator.hxx" 00006 #include "resip/dum/DumHelper.hxx" 00007 #include "rutil/WinLeakCheck.hxx" 00008 00009 #define RESIPROCATE_SUBSYSTEM Subsystem::DUM 00010 00011 using namespace resip; 00012 00013 BaseCreator::BaseCreator(DialogUsageManager& dum, 00014 const SharedPtr<UserProfile>& userProfile) 00015 : mLastRequest(new SipMessage), 00016 mDum(dum), 00017 mUserProfile(userProfile) 00018 {} 00019 00020 BaseCreator::~BaseCreator() 00021 {} 00022 00023 SharedPtr<SipMessage> 00024 BaseCreator::getLastRequest() 00025 { 00026 return mLastRequest; 00027 } 00028 00029 /* 00030 const SipMessage& 00031 BaseCreator::getLastRequest() const 00032 { 00033 return mLastRequest; 00034 } 00035 */ 00036 00037 SharedPtr<UserProfile> 00038 BaseCreator::getUserProfile() 00039 { 00040 return mUserProfile; 00041 } 00042 00043 void 00044 BaseCreator::makeInitialRequest(const NameAddr& target, MethodTypes method) 00045 { 00046 assert(mUserProfile.get()); 00047 makeInitialRequest(target, mUserProfile->getDefaultFrom(), method); 00048 } 00049 00050 00051 void 00052 BaseCreator::makeInitialRequest(const NameAddr& target, const NameAddr& from, MethodTypes method) 00053 { 00054 RequestLine rLine(method); 00055 rLine.uri() = target.uri(); 00056 mLastRequest->header(h_RequestLine) = rLine; 00057 00058 mLastRequest->header(h_To) = target; 00059 mLastRequest->header(h_MaxForwards).value() = 70; 00060 mLastRequest->header(h_CSeq).method() = method; 00061 mLastRequest->header(h_CSeq).sequence() = 1; 00062 mLastRequest->header(h_From) = from; 00063 mLastRequest->header(h_From).param(p_tag) = Helper::computeTag(Helper::tagSize); 00064 mLastRequest->header(h_CallId).value() = Helper::computeCallId(); 00065 00066 assert(mUserProfile.get()); 00067 if (!mUserProfile->getImsAuthUserName().empty()) 00068 { 00069 Auth auth; 00070 auth.scheme() = Symbols::Digest; 00071 auth.param(p_username) = mUserProfile->getImsAuthUserName(); 00072 auth.param(p_realm) = mUserProfile->getImsAuthHost(); 00073 auth.param(p_uri) = "sip:" + mUserProfile->getImsAuthHost(); 00074 auth.param(p_nonce) = Data::Empty; 00075 auth.param(p_response) = Data::Empty; 00076 mLastRequest->header(h_Authorizations).push_back(auth); 00077 DebugLog ( << "Adding auth header to inital reg for IMS: " << auth); 00078 } 00079 00080 NameAddr contact; // if no GRUU, let the stack fill in the contact 00081 00082 if(mUserProfile->hasUserAgentCapabilities()) 00083 { 00084 contact = mUserProfile->getUserAgentCapabilities(); 00085 } 00086 00087 //.dcm. If we want to use userprofiles oacross multiple registration we will 00088 //need the lookup-rtype hasGruu methods 00089 //if (mUserProfile->hasGruu(target.uri().getAor())) 00090 //?dcm? handle selction of anon vs pub gruu in profile? 00091 //if (mUserProfile->hasGruu(target.uri().getAor())) 00093 if (!mUserProfile->isAnonymous() && mUserProfile->hasPublicGruu() && method != REGISTER) //why not use GRUU for publish/etc? 00094 { 00095 contact.uri() = mUserProfile->getPublicGruu(); 00096 mLastRequest->header(h_Contacts).push_front(contact); 00097 } 00098 else if(mUserProfile->isAnonymous() && mUserProfile->hasTempGruu() && method != REGISTER) 00099 { 00100 contact.uri() = mUserProfile->getTempGruu(); 00101 mLastRequest->header(h_Contacts).push_front(contact); 00102 } 00103 else 00104 { 00105 if (mUserProfile->hasOverrideHostAndPort()) 00106 { 00107 contact.uri() = mUserProfile->getOverrideHostAndPort(); 00108 } 00109 contact.uri().user() = from.uri().user(); 00110 00111 // .jjg. there isn't anything in the outbound [11] draft that says we 00112 // aren't allowed to include p_Instance in this case... 00113 // odds are it will be useful (or necessary) for some implementations 00114 const Data& instanceId = mUserProfile->getInstanceId(); 00115 if (!contact.uri().exists(p_gr) && !instanceId.empty()) 00116 { 00117 contact.param(p_Instance) = instanceId; 00118 } 00119 mLastRequest->header(h_Contacts).push_front(contact); 00120 00121 if (method != REGISTER) 00122 { 00123 const NameAddrs& sRoute = mUserProfile->getServiceRoute(); 00124 if (!sRoute.empty()) 00125 { 00126 mLastRequest->header(h_Routes) = sRoute; 00127 } 00128 } 00129 } 00130 00131 if(mUserProfile->clientOutboundEnabled() && method != REGISTER) 00132 { 00133 // Add ;ob parm to non-register requests - RFC5626 pg17 00134 mLastRequest->header(h_Contacts).front().uri().param(p_ob); 00135 } 00136 00137 Via via; 00138 mLastRequest->header(h_Vias).push_front(via); 00139 00140 if(mUserProfile->isAdvertisedCapability(Headers::Allow)) 00141 { 00142 mLastRequest->header(h_Allows) = mDum.getMasterProfile()->getAllowedMethods(); 00143 } 00144 if(mUserProfile->isAdvertisedCapability(Headers::AcceptEncoding)) 00145 { 00146 mLastRequest->header(h_AcceptEncodings) = mDum.getMasterProfile()->getSupportedEncodings(); 00147 } 00148 if(mUserProfile->isAdvertisedCapability(Headers::AcceptLanguage)) 00149 { 00150 mLastRequest->header(h_AcceptLanguages) = mDum.getMasterProfile()->getSupportedLanguages(); 00151 } 00152 if(mUserProfile->isAdvertisedCapability(Headers::AllowEvents)) 00153 { 00154 mLastRequest->header(h_AllowEvents) = mDum.getMasterProfile()->getAllowedEvents(); 00155 } 00156 if(mUserProfile->isAdvertisedCapability(Headers::Supported)) 00157 { 00158 mLastRequest->header(h_Supporteds) = mDum.getMasterProfile()->getSupportedOptionTags(); 00159 } 00160 00161 // Merge Embedded parameters 00162 mLastRequest->mergeUri(target.uri()); 00163 00164 //DumHelper::setOutgoingEncryptionLevel(mLastRequest, mEncryptionLevel); 00165 00166 DebugLog ( << "BaseCreator::makeInitialRequest: " << std::endl << std::endl << mLastRequest); 00167 } 00168 00169 00170 /* ==================================================================== 00171 * The Vovida Software License, Version 1.0 00172 * 00173 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00174 * 00175 * Redistribution and use in source and binary forms, with or without 00176 * modification, are permitted provided that the following conditions 00177 * are met: 00178 * 00179 * 1. Redistributions of source code must retain the above copyright 00180 * notice, this list of conditions and the following disclaimer. 00181 * 00182 * 2. Redistributions in binary form must reproduce the above copyright 00183 * notice, this list of conditions and the following disclaimer in 00184 * the documentation and/or other materials provided with the 00185 * distribution. 00186 * 00187 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00188 * and "Vovida Open Communication Application Library (VOCAL)" must 00189 * not be used to endorse or promote products derived from this 00190 * software without prior written permission. For written 00191 * permission, please contact vocal@vovida.org. 00192 * 00193 * 4. Products derived from this software may not be called "VOCAL", nor 00194 * may "VOCAL" appear in their name, without prior written 00195 * permission of Vovida Networks, Inc. 00196 * 00197 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00198 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00199 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00200 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00201 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00202 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00203 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00204 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00205 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00206 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00207 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00208 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00209 * DAMAGE. 00210 * 00211 * ==================================================================== 00212 * 00213 * This software consists of voluntary contributions made by Vovida 00214 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00215 * Inc. For more information on Vovida Networks, Inc., please see 00216 * <http://www.vovida.org/>. 00217 * 00218 */ 00219
1.7.5.1