|
reSIProcate/DialogUsageManager
9680
|
00001 #if !defined(RESIP_CLIENTDIALOG_HXX) 00002 #define RESIP_CLIENTDIALOG_HXX 00003 00004 #include <iosfwd> 00005 #include <vector> 00006 #include <list> 00007 #include <map> 00008 00009 #include "resip/dum/DialogId.hxx" 00010 #include "resip/dum/Handles.hxx" 00011 #include "resip/stack/MethodTypes.hxx" 00012 #include "resip/stack/NameAddr.hxx" 00013 #include "resip/stack/CallId.hxx" 00014 #include "resip/stack/SipMessage.hxx" 00015 #include "resip/dum/NetworkAssociation.hxx" 00016 #include "resip/dum/DialogUsageManager.hxx" 00017 00018 namespace resip 00019 { 00020 class BaseUsage; 00021 class SipMessage; 00022 class DialogUsageManager; 00023 class DialogSet; 00024 class AppDialog; 00025 00027 00028 class Dialog 00029 { 00030 public: 00031 class Exception : public BaseException 00032 { 00033 public: 00034 Exception(const Data& msg, const Data& file, int line); 00035 virtual const char* name() const {return "Dialog::Exception";} 00036 }; 00037 00038 // different behavior from request vs. response 00039 // (request creates to tag) 00040 Dialog(DialogUsageManager& dum, const SipMessage& msg, DialogSet& ds); 00041 00042 const DialogId& getId() const; 00043 const NameAddr& getLocalNameAddr() const; 00044 const NameAddr& getLocalContact() const; 00045 const NameAddr& getRemoteNameAddr() const; 00046 const NameAddr& getRemoteTarget() const; 00047 const NameAddrs& getRouteSet() const; 00048 00049 // pass dialog sip messages through dialog so we can cache the requests on 00050 // the way out to be able to respond to digest authenticate requests 00051 void send(SharedPtr<SipMessage> msg); 00052 //void send(SipMessage& msg); 00053 00054 void makeRequest(SipMessage& request, MethodTypes method); 00055 void makeResponse(SipMessage& response, const SipMessage& request, int responseCode); 00056 00057 //void setLocalContact(const NameAddr& localContact); 00058 //void setRemoteTarget(const NameAddr& remoteTarget); 00059 00060 std::vector<ClientSubscriptionHandle> getClientSubscriptions(); 00061 std::vector<ClientSubscriptionHandle> findClientSubscriptions(const Data& event); 00062 00063 std::vector<ServerSubscriptionHandle> getServerSubscriptions(); 00064 std::vector<ServerSubscriptionHandle> findServerSubscriptions(const Data& event); 00065 00066 //returns an invalid handle if there is no session 00067 InviteSessionHandle getInviteSession(); 00068 00069 void end(); 00070 void dispatch(const SipMessage& msg); 00071 void processNotify(const SipMessage& notify); 00072 00073 //will end this dialog(if it makes sense) 00074 void redirected(const SipMessage& msg); 00075 00076 void onForkAccepted(); 00077 void cancel(); 00078 00079 bool isDestroying() { return mDestroying; }; 00080 00081 private: 00082 virtual ~Dialog(); 00083 friend class DialogUsage; 00084 friend class DialogSet; 00085 friend class DialogUsageManager; 00086 friend class DestroyUsage; 00087 00088 friend class ClientSubscription; 00089 friend class InviteSession; 00090 friend class ClientInviteSession; 00091 friend class ServerInviteSession; 00092 friend class ServerSubscription; 00093 friend class ClientRegistration; 00094 friend class ServerRegistration; 00095 friend class ClientPublication; 00096 friend class ServerPublication; 00097 friend class ClientOutOfDialogReq; 00098 friend class ServerOutOfDialogReq; 00099 00100 friend class AppDialog; 00101 void possiblyDie(); 00102 00103 ClientSubscription* findMatchingClientSub(const SipMessage& msg); 00104 ServerSubscription* findMatchingServerSub(const SipMessage& msg); 00105 00106 void addUsage(BaseUsage* usage); 00107 ClientInviteSession* makeClientInviteSession(const SipMessage& msg); 00108 ClientSubscription* makeClientSubscription(const SipMessage& msg); 00109 00110 ServerInviteSession* makeServerInviteSession(const SipMessage& msg); 00111 ServerSubscription* makeServerSubscription(const SipMessage& msg); 00112 00113 //matches using tid of response 00114 bool matches(const SipMessage& msg); 00115 void handleTargetRefresh(const SipMessage& msg); 00116 00117 void flowTerminated(); 00118 00119 DialogUsageManager& mDum; 00120 DialogSet& mDialogSet; 00121 DialogId mId; 00122 00123 std::list<ClientSubscription*> mClientSubscriptions; 00124 std::list<ServerSubscription*> mServerSubscriptions; 00125 InviteSession* mInviteSession; 00126 00127 NetworkAssociation mNetworkAssociation; 00128 00129 //invariants 00130 typedef enum // need to add 00131 { 00132 Invitation, // INVITE dialog 00133 Subscription, // Created by a SUBSCRIBE / NOTIFY / REFER 00134 Fake // Not really a dialog (e.g. created by a REGISTER) 00135 } DialogType; 00136 00137 DialogType mType; // !jf! is this necessary? 00138 NameAddrs mRouteSet; 00139 00140 //variants 00141 NameAddr mLocalContact; 00142 unsigned int mLocalCSeq; 00143 unsigned int mRemoteCSeq; 00144 NameAddr mRemoteTarget; 00145 NameAddr mLocalNameAddr; 00146 NameAddr mRemoteNameAddr; 00147 CallID mCallId; 00148 00149 // used to capture the 2xx expiration value for the initial subscription response 00150 UInt32 mDefaultSubExpiration; 00151 00152 // store until we get a response (non-401/407) 00153 // !jf! this shouldn't be necessary 00154 // !dcm! -- no longer used for subscriptions, INVITE will take more thought/work 00155 typedef std::map<int, SharedPtr<SipMessage> > RequestMap; 00156 RequestMap mRequests; 00157 00158 AppDialog* mAppDialog; 00159 00160 bool mDestroying; 00161 bool mReUseDialogSet; 00162 00163 friend EncodeStream& operator<<(EncodeStream& strm, const Dialog& dialog); 00164 }; 00165 00166 EncodeStream& operator<<(EncodeStream& strm, const Dialog& dialog); 00167 00168 } 00169 00170 #endif 00171 00172 /* ==================================================================== 00173 * The Vovida Software License, Version 1.0 00174 * 00175 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00176 * 00177 * Redistribution and use in source and binary forms, with or without 00178 * modification, are permitted provided that the following conditions 00179 * are met: 00180 * 00181 * 1. Redistributions of source code must retain the above copyright 00182 * notice, this list of conditions and the following disclaimer. 00183 * 00184 * 2. Redistributions in binary form must reproduce the above copyright 00185 * notice, this list of conditions and the following disclaimer in 00186 * the documentation and/or other materials provided with the 00187 * distribution. 00188 * 00189 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00190 * and "Vovida Open Communication Application Library (VOCAL)" must 00191 * not be used to endorse or promote products derived from this 00192 * software without prior written permission. For written 00193 * permission, please contact vocal@vovida.org. 00194 * 00195 * 4. Products derived from this software may not be called "VOCAL", nor 00196 * may "VOCAL" appear in their name, without prior written 00197 * permission of Vovida Networks, Inc. 00198 * 00199 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00200 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00201 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00202 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00203 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00204 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00205 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00206 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00207 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00208 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00209 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00210 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00211 * DAMAGE. 00212 * 00213 * ==================================================================== 00214 * 00215 * This software consists of voluntary contributions made by Vovida 00216 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00217 * Inc. For more information on Vovida Networks, Inc., please see 00218 * <http://www.vovida.org/>. 00219 * 00220 */
1.7.5.1