reSIProcate/DialogUsageManager  9694
basicClientCall.hxx
Go to the documentation of this file.
00001 #if !defined(basicClientCall_hxx)
00002 #define basicClientCall_hxx
00003 
00004 #include <resip/dum/AppDialogSet.hxx>
00005 
00006 #include <resip/dum/SubscriptionHandler.hxx>
00007 #include <resip/dum/RedirectHandler.hxx>
00008 #include <resip/dum/InviteSessionHandler.hxx>
00009 #include <resip/dum/DialogSetHandler.hxx>
00010 #include <resip/dum/DialogUsageManager.hxx>
00011 
00012 #include "basicClientUserAgent.hxx"
00013 
00014 namespace resip
00015 {
00016 
00017 class BasicClientCall : public AppDialogSet 
00018 {
00019 public:
00020    BasicClientCall(BasicClientUserAgent& userAgent);
00021    virtual ~BasicClientCall();
00022    
00023    virtual void initiateCall(const Uri& target, SharedPtr<UserProfile> profile);
00024    virtual void terminateCall();
00025    virtual void timerExpired();
00026 
00027 protected:
00028    friend class BasicClientUserAgent;
00029 
00030    // This API must return an appropriate user profile after inspecting the incoming INVITE
00031    virtual SharedPtr<UserProfile> selectUASUserProfile(const SipMessage&); 
00032 
00033    // Invite Session Handler /////////////////////////////////////////////////////
00034    virtual void onNewSession(resip::ClientInviteSessionHandle h, resip::InviteSession::OfferAnswerType oat, const resip::SipMessage& msg);
00035    virtual void onNewSession(resip::ServerInviteSessionHandle h, resip::InviteSession::OfferAnswerType oat, const resip::SipMessage& msg);
00036    virtual void onFailure(resip::ClientInviteSessionHandle h, const resip::SipMessage& msg);
00037    virtual void onEarlyMedia(resip::ClientInviteSessionHandle, const resip::SipMessage&, const resip::SdpContents&);
00038    virtual void onProvisional(resip::ClientInviteSessionHandle, const resip::SipMessage& msg);
00039    virtual void onConnected(resip::ClientInviteSessionHandle h, const resip::SipMessage& msg);
00040    virtual void onConnected(resip::InviteSessionHandle, const resip::SipMessage& msg);
00041    virtual void onStaleCallTimeout(resip::ClientInviteSessionHandle);
00042    virtual void onTerminated(resip::InviteSessionHandle h, resip::InviteSessionHandler::TerminatedReason reason, const resip::SipMessage* msg);
00043    virtual void onRedirected(resip::ClientInviteSessionHandle, const resip::SipMessage& msg);
00044    virtual void onAnswer(resip::InviteSessionHandle, const resip::SipMessage& msg, const resip::SdpContents&);
00045    virtual void onOffer(resip::InviteSessionHandle handle, const resip::SipMessage& msg, const resip::SdpContents& offer);
00046    virtual void onOfferRequired(resip::InviteSessionHandle, const resip::SipMessage& msg);
00047    virtual void onOfferRejected(resip::InviteSessionHandle, const resip::SipMessage* msg);
00048    virtual void onOfferRequestRejected(resip::InviteSessionHandle, const resip::SipMessage& msg);
00049    virtual void onRemoteSdpChanged(resip::InviteSessionHandle, const resip::SipMessage& msg, const resip::SdpContents& sdp);
00050    virtual void onInfo(resip::InviteSessionHandle, const resip::SipMessage& msg);
00051    virtual void onInfoSuccess(resip::InviteSessionHandle, const resip::SipMessage& msg);
00052    virtual void onInfoFailure(resip::InviteSessionHandle, const resip::SipMessage& msg);
00053    virtual void onRefer(resip::InviteSessionHandle, resip::ServerSubscriptionHandle, const resip::SipMessage& msg);
00054    virtual void onReferAccepted(resip::InviteSessionHandle, resip::ClientSubscriptionHandle, const resip::SipMessage& msg);
00055    virtual void onReferRejected(resip::InviteSessionHandle, const resip::SipMessage& msg);
00056    virtual void onReferNoSub(resip::InviteSessionHandle, const resip::SipMessage& msg);
00057    virtual void onMessage(resip::InviteSessionHandle, const resip::SipMessage& msg);
00058    virtual void onMessageSuccess(resip::InviteSessionHandle, const resip::SipMessage& msg);
00059    virtual void onMessageFailure(resip::InviteSessionHandle, const resip::SipMessage& msg);
00060    virtual void onForkDestroyed(resip::ClientInviteSessionHandle);
00061    virtual void onReadyToSend(InviteSessionHandle, SipMessage& msg);
00062    virtual void onFlowTerminated(InviteSessionHandle);
00063 
00064    // DialogSetHandler  //////////////////////////////////////////////
00065    virtual void onTrying(resip::AppDialogSetHandle, const resip::SipMessage& msg);
00066    virtual void onNonDialogCreatingProvisional(resip::AppDialogSetHandle, const resip::SipMessage& msg);
00067 
00068    // ClientSubscriptionHandler ///////////////////////////////////////////////////
00069    virtual void onUpdatePending(resip::ClientSubscriptionHandle h, const resip::SipMessage& notify, bool outOfOrder);
00070    virtual void onUpdateActive(resip::ClientSubscriptionHandle h, const resip::SipMessage& notify, bool outOfOrder);
00071    virtual void onUpdateExtension(resip::ClientSubscriptionHandle h, const resip::SipMessage& notify, bool outOfOrder);
00072    virtual void onNotifyNotReceived(resip::ClientSubscriptionHandle h);
00073    virtual void onTerminated(resip::ClientSubscriptionHandle h, const resip::SipMessage* notify);
00074    virtual void onNewSubscription(resip::ClientSubscriptionHandle h, const resip::SipMessage& notify);
00075    virtual int  onRequestRetry(resip::ClientSubscriptionHandle h, int retrySeconds, const resip::SipMessage& notify);
00076 
00077    // RedirectHandler /////////////////////////////////////////////////////////////
00078    virtual void onRedirectReceived(AppDialogSetHandle h, const SipMessage& msg);
00079 
00080 private:       
00081    BasicClientUserAgent &mUserAgent;
00082    resip::InviteSessionHandle mInviteSessionHandle;
00083    unsigned int mTimerExpiredCounter;
00084    bool mPlacedCall;
00085    resip::InviteSessionHandle mInviteSessionHandleReplaced;
00086 
00087    // UAC forked call handling helper members
00088    bool isUACConnected();
00089    bool isStaleFork(const resip::DialogId& dialogId);
00090    resip::DialogId mUACConnectedDialogId;
00091 
00092    void makeOffer(SdpContents& offer);
00093 };
00094  
00095 }
00096 
00097 #endif
00098 
00099 /* ====================================================================
00100 
00101  Copyright (c) 2011, SIP Spectrum, Inc.
00102  All rights reserved.
00103 
00104  Redistribution and use in source and binary forms, with or without
00105  modification, are permitted provided that the following conditions are 
00106  met:
00107 
00108  1. Redistributions of source code must retain the above copyright 
00109     notice, this list of conditions and the following disclaimer. 
00110 
00111  2. Redistributions in binary form must reproduce the above copyright
00112     notice, this list of conditions and the following disclaimer in the
00113     documentation and/or other materials provided with the distribution. 
00114 
00115  3. Neither the name of SIP Spectrum nor the names of its contributors 
00116     may be used to endorse or promote products derived from this 
00117     software without specific prior written permission. 
00118 
00119  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00120  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
00121  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
00122  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
00123  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
00124  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
00125  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
00126  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
00127  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00128  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00129  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00130 
00131  ==================================================================== */