|
reSIProcate/DialogUsageManager
9694
|
00001 00002 #include "resip/dum/Profile.hxx" 00003 #include "resip/dum/MasterProfile.hxx" 00004 #include "resip/stack/HeaderTypes.hxx" 00005 00006 using namespace resip; 00007 #define RESIPROCATE_SUBSYSTEM Subsystem::DUM 00008 00009 00010 // Be sure to look at the documentation of the accessors for 00011 // the members being set by this constructor in the .hxx file 00012 // for the implications of these default values. 00013 00014 MasterProfile::MasterProfile() : 00015 mValidateContentEnabled(true), 00016 mValidateContentLanguageEnabled(false), 00017 mValidateAcceptEnabled(false), 00018 mAllowBadRegistrationEnabled(false), 00019 mHasServerRegistrationMinExpires(false), 00020 mCheckReqUriInMergeDetectionEnabled(false), 00021 mUacReliableProvisionalMode(Never), 00022 mUasReliableProvisionalMode(Never), 00023 mServerRegistrationMinExpires(0), 00024 mServerRegistrationMaxExpires(UINT_MAX), 00025 mServerRegistrationDefaultExpires(3600) 00026 { 00027 // Default settings 00028 addSupportedMimeType(INVITE, Mime("application", "sdp")); 00029 addSupportedMimeType(OPTIONS, Mime("application", "sdp")); 00030 addSupportedMimeType(PRACK, Mime("application", "sdp")); 00031 addSupportedMimeType(UPDATE, Mime("application", "sdp")); 00032 addSupportedLanguage(Token("en")); 00033 addSupportedMethod(INVITE); 00034 addSupportedMethod(ACK); 00035 addSupportedMethod(CANCEL); 00036 addSupportedMethod(OPTIONS); 00037 addSupportedMethod(BYE); 00038 addSupportedMethod(UPDATE); 00039 addSupportedScheme(Symbols::Sip); 00040 } 00041 00042 void 00043 MasterProfile::addSupportedScheme(const Data& scheme) 00044 { 00045 mSupportedSchemes.insert(scheme); 00046 } 00047 00048 bool 00049 MasterProfile::isSchemeSupported(const Data& scheme) const 00050 { 00051 return mSupportedSchemes.count(scheme) != 0; 00052 } 00053 00054 void 00055 MasterProfile::clearSupportedSchemes() 00056 { 00057 mSupportedSchemes.clear(); 00058 } 00059 00060 void 00061 MasterProfile::addSupportedMethod(const MethodTypes& method) 00062 { 00063 mSupportedMethodTypes.insert(method); 00064 mSupportedMethods.push_back(Token(getMethodName(method))); 00065 } 00066 00067 bool 00068 MasterProfile::isMethodSupported(MethodTypes method) const 00069 { 00070 return mSupportedMethodTypes.count(method) != 0; 00071 } 00072 00073 Tokens 00074 MasterProfile::getAllowedMethods() const 00075 { 00076 return mSupportedMethods; 00077 } 00078 00079 Data 00080 MasterProfile::getAllowedMethodsData() const 00081 { 00082 Data result; 00083 00084 for (Tokens::const_iterator i = mSupportedMethods.begin(); 00085 i != mSupportedMethods.end(); ++i) 00086 { 00087 if (i != mSupportedMethods.begin()) 00088 { 00089 result += Symbols::COMMA[0]; 00090 } 00091 result += i->value(); 00092 } 00093 00094 return result; 00095 } 00096 00097 void 00098 MasterProfile::clearSupportedMethods() 00099 { 00100 mSupportedMethodTypes.clear(); 00101 mSupportedMethods.clear(); 00102 } 00103 00104 void 00105 MasterProfile::addSupportedOptionTag(const Token& tag) 00106 { 00107 if (tag == Token(Symbols::C100rel)) 00108 { 00109 //use enablePrackUas and enablePrackUac 00110 assert(0); 00111 } 00112 mSupportedOptionTags.push_back(tag); 00113 } 00114 00115 Tokens 00116 MasterProfile::getUnsupportedOptionsTags(const Tokens& requiresOptionTags) 00117 { 00118 Tokens tokens; 00119 for (Tokens::const_iterator i=requiresOptionTags.begin(); i != requiresOptionTags.end(); ++i) 00120 { 00121 if (!i->isWellFormed()) 00122 { 00123 tokens.push_back(Token("malformedTag")); 00124 } 00125 else if (*i == Token(Symbols::C100rel) && mUasReliableProvisionalMode == Never) 00126 { 00127 tokens.push_back(*i); 00128 } 00129 // if this option is not supported 00130 else if (!mSupportedOptionTags.find(*i)) 00131 { 00132 tokens.push_back(*i); 00133 } 00134 } 00135 00136 return tokens; 00137 } 00138 00139 Tokens 00140 MasterProfile::getSupportedOptionTags() const 00141 { 00142 return mSupportedOptionTags; 00143 } 00144 00145 void 00146 MasterProfile::clearSupportedOptionTags() 00147 { 00148 mSupportedOptionTags.clear(); 00149 } 00150 00151 void 00152 MasterProfile::setUacReliableProvisionalMode(ReliableProvisionalMode mode) 00153 { 00154 mUacReliableProvisionalMode = mode; 00155 } 00156 00157 void 00158 MasterProfile::setUasReliableProvisionalMode(ReliableProvisionalMode mode) 00159 { 00160 //.dcm. not supported yet 00161 assert(0); 00162 mUasReliableProvisionalMode = mode; 00163 } 00164 00165 MasterProfile::ReliableProvisionalMode 00166 MasterProfile::getUacReliableProvisionalMode() const 00167 { 00168 return mUacReliableProvisionalMode; 00169 } 00170 00171 MasterProfile::ReliableProvisionalMode 00172 MasterProfile::getUasReliableProvisionalMode() const 00173 { 00174 return mUasReliableProvisionalMode; 00175 } 00176 00177 void 00178 MasterProfile::addSupportedMimeType(const MethodTypes& method, const Mime& mimeType) 00179 { 00180 mSupportedMimeTypes[method].push_back(mimeType); 00181 } 00182 00183 bool 00184 MasterProfile::removeSupportedMimeType(const MethodTypes& method, const Mime& mimeType) 00185 { 00186 std::map<MethodTypes, Mimes>::iterator foundMethod = mSupportedMimeTypes.find(method); 00187 if (foundMethod != mSupportedMimeTypes.end()) 00188 { 00189 for (Mimes::iterator i = foundMethod->second.begin(); 00190 i != foundMethod->second.end(); ++i) 00191 { 00192 if (mimeType.isEqual(*i)) 00193 { 00194 foundMethod->second.erase(i); 00195 return true; 00196 } 00197 } 00198 } 00199 return false; 00200 } 00201 00202 bool 00203 MasterProfile::isMimeTypeSupported(const MethodTypes& method, const Mime& mimeType) 00204 { 00205 if(!mimeType.isWellFormed()) 00206 { 00207 return false; 00208 } 00209 00210 std::map<MethodTypes, Mimes>::iterator found = mSupportedMimeTypes.find(method); 00211 if (found != mSupportedMimeTypes.end()) 00212 { 00213 return found->second.find(mimeType); 00214 } 00215 return false; 00216 } 00217 00218 Mimes 00219 MasterProfile::getSupportedMimeTypes(const MethodTypes& method) 00220 { 00221 std::map<MethodTypes, Mimes>::iterator found = mSupportedMimeTypes.find(method); 00222 if (found != mSupportedMimeTypes.end()) 00223 { 00224 return found->second; 00225 } 00226 return Mimes(); 00227 } 00228 00229 void 00230 MasterProfile::clearSupportedMimeTypes(const MethodTypes& method) 00231 { 00232 std::map<MethodTypes, Mimes>::iterator found = mSupportedMimeTypes.find(method); 00233 if (found != mSupportedMimeTypes.end()) 00234 { 00235 found->second.clear(); 00236 } 00237 } 00238 00239 void 00240 MasterProfile::clearSupportedMimeTypes() 00241 { 00242 mSupportedMimeTypes.clear(); 00243 } 00244 00245 void 00246 MasterProfile::addSupportedEncoding(const Token& encoding) 00247 { 00248 mSupportedEncodings.push_back(encoding); 00249 } 00250 00251 bool 00252 MasterProfile::isContentEncodingSupported(const Token& encoding) const 00253 { 00254 return encoding.isWellFormed() && mSupportedEncodings.find(encoding); 00255 } 00256 00257 Tokens 00258 MasterProfile::getSupportedEncodings() const 00259 { 00260 return mSupportedEncodings; 00261 } 00262 00263 void 00264 MasterProfile::clearSupportedEncodings() 00265 { 00266 mSupportedEncodings.clear(); 00267 } 00268 00269 void 00270 MasterProfile::addSupportedLanguage(const Token& lang) 00271 { 00272 mSupportedLanguages.push_back(lang); 00273 } 00274 00275 bool 00276 MasterProfile::isLanguageSupported(const Tokens& langs) const 00277 { 00278 for (Tokens::const_iterator i=langs.begin(); i != langs.end(); ++i) 00279 { 00280 if (!i->isWellFormed() || mSupportedLanguages.find(*i) == false) 00281 { 00282 return false; 00283 } 00284 } 00285 return true; 00286 } 00287 00288 Tokens 00289 MasterProfile::getSupportedLanguages() const 00290 { 00291 return mSupportedLanguages; 00292 } 00293 00294 void 00295 MasterProfile::clearSupportedLanguages() 00296 { 00297 mSupportedLanguages.clear(); 00298 } 00299 00300 void 00301 MasterProfile::addAllowedEvent(const Token& event) 00302 { 00303 mAllowedEvents.push_back(event); 00304 } 00305 00306 bool 00307 MasterProfile::isEventAllowed(const Tokens& events) const 00308 { 00309 for (Tokens::const_iterator i=events.begin(); i != events.end(); ++i) 00310 { 00311 if (!i->isWellFormed() || mAllowedEvents.find(*i) == false) 00312 { 00313 return false; 00314 } 00315 } 00316 return true; 00317 } 00318 00319 Tokens 00320 MasterProfile::getAllowedEvents() const 00321 { 00322 return mAllowedEvents; 00323 } 00324 00325 void 00326 MasterProfile::clearAllowedEvents() 00327 { 00328 mAllowedEvents.clear(); 00329 } 00330 00331 bool& 00332 MasterProfile::validateContentEnabled() 00333 { 00334 return mValidateContentEnabled; 00335 } 00336 00337 bool 00338 MasterProfile::validateContentEnabled() const 00339 { 00340 return mValidateContentEnabled; 00341 } 00342 00343 bool& 00344 MasterProfile::validateContentLanguageEnabled() 00345 { 00346 return mValidateContentLanguageEnabled; 00347 } 00348 00349 bool 00350 MasterProfile::validateContentLanguageEnabled() const 00351 { 00352 return mValidateContentLanguageEnabled; 00353 } 00354 00355 bool& 00356 MasterProfile::validateAcceptEnabled() 00357 { 00358 return mValidateAcceptEnabled; 00359 } 00360 00361 bool 00362 MasterProfile::validateAcceptEnabled() const 00363 { 00364 return mValidateAcceptEnabled; 00365 } 00366 00367 bool 00368 MasterProfile::allowBadRegistrationEnabled() const 00369 { 00370 return mAllowBadRegistrationEnabled; 00371 } 00372 00373 bool& 00374 MasterProfile::allowBadRegistrationEnabled() 00375 { 00376 return mAllowBadRegistrationEnabled; 00377 } 00378 00379 00380 UInt32 & 00381 MasterProfile::serverRegistrationMinExpiresTime(void) 00382 { 00383 return mServerRegistrationMinExpires; 00384 } 00385 00386 const UInt32 00387 MasterProfile::serverRegistrationMinExpiresTime(void) const 00388 { 00389 return mServerRegistrationMinExpires; 00390 } 00391 00392 UInt32 & 00393 MasterProfile::serverRegistrationMaxExpiresTime(void) 00394 { 00395 return mServerRegistrationMaxExpires; 00396 } 00397 00398 const UInt32 00399 MasterProfile::serverRegistrationMaxExpiresTime(void) const 00400 { 00401 return mServerRegistrationMaxExpires; 00402 } 00403 00404 UInt32 & 00405 MasterProfile::serverRegistrationDefaultExpiresTime(void) 00406 { 00407 return mServerRegistrationDefaultExpires; 00408 } 00409 00410 const UInt32 00411 MasterProfile::serverRegistrationDefaultExpiresTime(void) const 00412 { 00413 return mServerRegistrationDefaultExpires; 00414 } 00415 00416 bool 00417 MasterProfile::checkReqUriInMergeDetectionEnabled() const 00418 { 00419 return mCheckReqUriInMergeDetectionEnabled; 00420 } 00421 00422 bool& 00423 MasterProfile::checkReqUriInMergeDetectionEnabled() 00424 { 00425 return mCheckReqUriInMergeDetectionEnabled; 00426 } 00427 00428 UserProfile* 00429 MasterProfile::clone() const 00430 { 00431 return new MasterProfile(*this); 00432 } 00433 00434 /* ==================================================================== 00435 * The Vovida Software License, Version 1.0 00436 * 00437 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00438 * 00439 * Redistribution and use in source and binary forms, with or without 00440 * modification, are permitted provided that the following conditions 00441 * are met: 00442 * 00443 * 1. Redistributions of source code must retain the above copyright 00444 * notice, this list of conditions and the following disclaimer. 00445 * 00446 * 2. Redistributions in binary form must reproduce the above copyright 00447 * notice, this list of conditions and the following disclaimer in 00448 * the documentation and/or other materials provided with the 00449 * distribution. 00450 * 00451 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00452 * and "Vovida Open Communication Application Library (VOCAL)" must 00453 * not be used to endorse or promote products derived from this 00454 * software without prior written permission. For written 00455 * permission, please contact vocal@vovida.org. 00456 * 00457 * 4. Products derived from this software may not be called "VOCAL", nor 00458 * may "VOCAL" appear in their name, without prior written 00459 * permission of Vovida Networks, Inc. 00460 * 00461 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00462 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00463 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00464 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00465 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00466 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00467 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00468 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00469 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00470 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00471 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00472 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00473 * DAMAGE. 00474 * 00475 * ==================================================================== 00476 * 00477 * This software consists of voluntary contributions made by Vovida 00478 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00479 * Inc. For more information on Vovida Networks, Inc., please see 00480 * <http://www.vovida.org/>. 00481 * 00482 */ 00483
1.7.5.1