|
reSIProcate/DialogUsageManager
9694
|
00001 #include "resip/dum/AppDialogSet.hxx" 00002 #include "resip/dum/NonDialogUsage.hxx" 00003 #include "resip/dum/DialogSet.hxx" 00004 #include "resip/dum/DialogUsageManager.hxx" 00005 #include "rutil/Logger.hxx" 00006 #include "rutil/Inserter.hxx" 00007 00008 #define RESIPROCATE_SUBSYSTEM Subsystem::DUM 00009 00010 using namespace resip; 00011 00012 NonDialogUsage::Exception::Exception(const Data& msg,const Data& file,int line) 00013 : BaseException(msg, file, line) 00014 { 00015 } 00016 00017 const char* 00018 NonDialogUsage::Exception::name() const 00019 { 00020 return "NonDialogUsage::Exception"; 00021 } 00022 00023 NonDialogUsage::NonDialogUsage(DialogUsageManager& dum, DialogSet& dialogSet) : 00024 BaseUsage(dum), 00025 mDialogSet(dialogSet) 00026 { 00027 } 00028 00029 NonDialogUsage::~NonDialogUsage() 00030 { 00031 mDialogSet.possiblyDie(); 00032 } 00033 00034 AppDialogSetHandle 00035 NonDialogUsage::getAppDialogSet() 00036 { 00037 return mDialogSet.mAppDialogSet->getHandle(); 00038 } 00039 00040 SharedPtr<UserProfile> 00041 NonDialogUsage::getUserProfile() 00042 { 00043 return mDialogSet.mUserProfile; 00044 } 00045 00046 void 00047 NonDialogUsage::send(SharedPtr<SipMessage> msg) 00048 { 00049 const NameAddrs& sRoute = getUserProfile()->getServiceRoute(); 00050 00051 // Clear the routes if there was previously a service_route. Otherwise 00052 // keep the route incase there exists custom routes 00053 00054 if (!sRoute.empty()) 00055 { 00056 if (msg->header(h_RequestLine).method() == REGISTER) 00057 { 00058 const NameAddrs emptyRoute; 00059 msg->remove(h_Routes); 00060 getUserProfile()->setServiceRoute(emptyRoute); 00061 } 00062 else 00063 { 00064 InfoLog(<< "Applying service route: " << Inserter(getUserProfile()->getServiceRoute()) << " to " << msg->brief()); 00065 msg->header(h_Routes) = sRoute; 00066 } 00067 } 00068 00069 mDum.send(msg); 00070 } 00071 00072 class NonDialogUsageSendCommand : public DumCommandAdapter 00073 { 00074 public: 00075 NonDialogUsageSendCommand(NonDialogUsage& usage, SharedPtr<SipMessage> msg) 00076 : mNonDialogUsage(usage), 00077 mMessage(msg) 00078 { 00079 } 00080 00081 virtual void executeCommand() 00082 { 00083 mNonDialogUsage.send(mMessage); 00084 } 00085 00086 virtual EncodeStream& encodeBrief(EncodeStream& strm) const 00087 { 00088 return strm << "NonDialogUsageSendCommand"; 00089 } 00090 private: 00091 NonDialogUsage& mNonDialogUsage; 00092 SharedPtr<SipMessage> mMessage; 00093 }; 00094 00095 void 00096 NonDialogUsage::sendCommand(SharedPtr<SipMessage> message) 00097 { 00098 mDum.post(new NonDialogUsageSendCommand(*this, message)); 00099 } 00100 00101 /* ==================================================================== 00102 * The Vovida Software License, Version 1.0 00103 * 00104 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00105 * 00106 * Redistribution and use in source and binary forms, with or without 00107 * modification, are permitted provided that the following conditions 00108 * are met: 00109 * 00110 * 1. Redistributions of source code must retain the above copyright 00111 * notice, this list of conditions and the following disclaimer. 00112 * 00113 * 2. Redistributions in binary form must reproduce the above copyright 00114 * notice, this list of conditions and the following disclaimer in 00115 * the documentation and/or other materials provided with the 00116 00117 * distribution. 00118 * 00119 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00120 * and "Vovida Open Communication Application Library (VOCAL)" must 00121 * not be used to endorse or promote products derived from this 00122 * software without prior written permission. For written 00123 * permission, please contact vocal@vovida.org. 00124 * 00125 * 4. Products derived from this software may not be called "VOCAL", nor 00126 * may "VOCAL" appear in their name, without prior written 00127 * permission of Vovida Networks, Inc. 00128 * 00129 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00130 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00131 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00132 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00133 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00134 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00135 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00136 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00137 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00138 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00139 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00140 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00141 * DAMAGE. 00142 * 00143 * ==================================================================== 00144 * 00145 * This software consists of voluntary contributions made by Vovida 00146 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00147 * Inc. For more information on Vovida Networks, Inc., please see 00148 * <http://www.vovida.org/>. 00149 * 00150 */
1.7.5.1