|
reSIProcate/DialogUsageManager
9680
|
00001 #include "resip/dum/BaseSubscription.hxx" 00002 #include "resip/dum/DialogUsageManager.hxx" 00003 #include "resip/dum/Dialog.hxx" 00004 #include "resip/stack/SipMessage.hxx" 00005 #include "rutil/WinLeakCheck.hxx" 00006 00007 using namespace resip; 00008 00009 BaseSubscription::BaseSubscription(DialogUsageManager& dum, Dialog& dialog, const SipMessage& request) : 00010 DialogUsage(dum, dialog), 00011 mSubDlgState(SubDlgInitial), 00012 mLastRequest(new SipMessage), 00013 mLastResponse(new SipMessage), 00014 mDocumentKey(request.header(h_RequestLine).uri().getAor()), 00015 mSubscriptionId(Data::Empty), 00016 mTimerSeq(0), 00017 mSubscriptionState(Invalid) 00018 00019 { 00020 if (request.exists(h_Event)) 00021 { 00022 mEventType = request.header(h_Event).value(); 00023 if (request.header(h_Event).exists(p_id)) 00024 { 00025 mSubscriptionId = request.header(h_Event).param(p_id); 00026 } 00027 mLastRequest->header(h_Event) = request.header(h_Event); 00028 } 00029 else if (request.header(h_RequestLine).method() == REFER 00030 || request.header(h_RequestLine).method() == NOTIFY) 00031 { 00032 mEventType = "refer"; 00033 mLastRequest->header(h_Event).value() = mEventType; 00034 } 00035 } 00036 00037 bool 00038 BaseSubscription::matches(const SipMessage& msg) 00039 { 00040 if (msg.isResponse() && msg.header(h_CSeq) == mLastRequest->header(h_CSeq)) 00041 { 00042 return true; 00043 } 00044 else 00045 { 00046 if (msg.exists(h_Event)) 00047 { 00048 return msg.header(h_Event).value() == mEventType 00049 && ( !msg.header(h_Event).exists(p_id) || 00050 msg.header(h_Event).param(p_id) == mSubscriptionId); 00051 00052 } 00053 else 00054 { 00055 return (mEventType == "refer" && 00056 Data(msg.header(h_CSeq).sequence()) == mSubscriptionId); 00057 } 00058 } 00059 } 00060 00061 00062 BaseSubscription::~BaseSubscription() 00063 { 00064 } 00065 00066 SubscriptionState 00067 BaseSubscription::getSubscriptionState() 00068 { 00069 return mSubscriptionState; 00070 } 00071 00072 00073 /* ==================================================================== 00074 * The Vovida Software License, Version 1.0 00075 * 00076 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00077 * 00078 * Redistribution and use in source and binary forms, with or without 00079 * modification, are permitted provided that the following conditions 00080 * are met: 00081 * 00082 * 1. Redistributions of source code must retain the above copyright 00083 * notice, this list of conditions and the following disclaimer. 00084 * 00085 * 2. Redistributions in binary form must reproduce the above copyright 00086 * notice, this list of conditions and the following disclaimer in 00087 * the documentation and/or other materials provided with the 00088 * distribution. 00089 * 00090 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00091 * and "Vovida Open Communication Application Library (VOCAL)" must 00092 * not be used to endorse or promote products derived from this 00093 * software without prior written permission. For written 00094 * permission, please contact vocal@vovida.org. 00095 * 00096 * 4. Products derived from this software may not be called "VOCAL", nor 00097 * may "VOCAL" appear in their name, without prior written 00098 * permission of Vovida Networks, Inc. 00099 * 00100 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00101 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00102 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00103 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00104 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00105 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00106 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00107 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00108 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00109 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00110 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00111 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00112 * DAMAGE. 00113 * 00114 * ==================================================================== 00115 * 00116 * This software consists of voluntary contributions made by Vovida 00117 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00118 * Inc. For more information on Vovida Networks, Inc., please see 00119 * <http://www.vovida.org/>. 00120 * 00121 */
1.7.5.1