reSIProcate/DialogUsageManager  9694
UserAgent.hxx
Go to the documentation of this file.
00001 #if !defined(DUM_UserAgent_hxx)
00002 #define DUM_UserAgent_hxx
00003 
00004 #ifdef HAVE_CONFIG_H
00005 #include "config.h"
00006 #endif
00007 
00008 #include "CommandLineParser.hxx"
00009 
00010 #include "resip/stack/StackThread.hxx"
00011 #include "resip/dum/MasterProfile.hxx"
00012 #include "resip/dum/RegistrationHandler.hxx"
00013 #include "resip/dum/SubscriptionHandler.hxx"
00014 #include "resip/dum/PublicationHandler.hxx"
00015 #include "resip/dum/OutOfDialogHandler.hxx"
00016 #include "resip/dum/InviteSessionHandler.hxx"
00017 #include "resip/dum/DialogUsageManager.hxx"
00018 
00019 namespace resip
00020 {
00021 
00022 class UserAgent : public CommandLineParser, 
00023                   public ClientRegistrationHandler, 
00024                   public ClientSubscriptionHandler, 
00025                   public ClientPublicationHandler,
00026                   public OutOfDialogHandler, 
00027                   public InviteSessionHandler
00028 {
00029    public:
00030       UserAgent(int argc, char** argv);
00031       virtual ~UserAgent();
00032 
00033       virtual void startup();
00034       virtual void shutdown();
00035 
00036       void process();
00037       
00038    public:
00039       // Invite Session Handler /////////////////////////////////////////////////////
00040       virtual void onNewSession(ClientInviteSessionHandle h, InviteSession::OfferAnswerType oat, const SipMessage& msg);
00041       virtual void onNewSession(ServerInviteSessionHandle h, InviteSession::OfferAnswerType oat, const SipMessage& msg);
00042       virtual void onFailure(ClientInviteSessionHandle h, const SipMessage& msg);
00043       virtual void onEarlyMedia(ClientInviteSessionHandle, const SipMessage&, const SdpContents&);
00044       virtual void onProvisional(ClientInviteSessionHandle, const SipMessage& msg);
00045       virtual void onConnected(ClientInviteSessionHandle h, const SipMessage& msg);
00046       virtual void onConnected(InviteSessionHandle, const SipMessage& msg);
00047       virtual void onStaleCallTimeout(ClientInviteSessionHandle);
00048       virtual void onTerminated(InviteSessionHandle h, InviteSessionHandler::TerminatedReason reason, const SipMessage* msg);
00049       virtual void onRedirected(ClientInviteSessionHandle, const SipMessage& msg);
00050       virtual void onAnswer(InviteSessionHandle, const SipMessage& msg, const SdpContents&);
00051       virtual void onOffer(InviteSessionHandle handle, const SipMessage& msg, const SdpContents& offer);
00052       virtual void onOfferRequired(InviteSessionHandle, const SipMessage& msg);
00053       virtual void onOfferRejected(InviteSessionHandle, const SipMessage* msg);
00054       virtual void onDialogModified(InviteSessionHandle, InviteSession::OfferAnswerType oat, const SipMessage& msg);
00055       virtual void onInfo(InviteSessionHandle, const SipMessage& msg);
00056       virtual void onInfoSuccess(InviteSessionHandle, const SipMessage& msg);
00057       virtual void onInfoFailure(InviteSessionHandle, const SipMessage& msg);
00058       virtual void onRefer(InviteSessionHandle, ServerSubscriptionHandle, const SipMessage& msg);
00059       virtual void onReferAccepted(InviteSessionHandle, ClientSubscriptionHandle, const SipMessage& msg);
00060       virtual void onReferRejected(InviteSessionHandle, const SipMessage& msg);
00061       virtual void onReferNoSub(InviteSessionHandle, const SipMessage& msg);
00062 
00063       virtual void onMessage(InviteSessionHandle, const SipMessage& msg);
00064       virtual void onMessageSuccess(InviteSessionHandle, const SipMessage& msg);
00065       virtual void onMessageFailure(InviteSessionHandle, const SipMessage& msg);
00066       
00067       // Registration Handler ////////////////////////////////////////////////////////
00068       virtual void onSuccess(ClientRegistrationHandle h, const SipMessage& response);
00069       virtual void onFailure(ClientRegistrationHandle h, const SipMessage& response);
00070       virtual void onRemoved(ClientRegistrationHandle h, const SipMessage& response);
00071       virtual int onRequestRetry(ClientRegistrationHandle h, int retryMinimum, const SipMessage& msg);
00072 
00073       // ClientSubscriptionHandler ///////////////////////////////////////////////////
00074       virtual void onUpdatePending(ClientSubscriptionHandle h, const SipMessage& notify, bool outOfOrder);
00075       virtual void onUpdateActive(ClientSubscriptionHandle h, const SipMessage& notify, bool outOfOrder);
00076       virtual void onUpdateExtension(ClientSubscriptionHandle, const SipMessage& notify, bool outOfOrder);
00077       virtual void onTerminated(ClientSubscriptionHandle h, const SipMessage* notify);
00078       virtual void onNewSubscription(ClientSubscriptionHandle h, const SipMessage& notify);
00079       virtual int onRequestRetry(ClientSubscriptionHandle h, int retryMinimum, const SipMessage& notify);
00080 
00081       // ClientPublicationHandler ////////////////////////////////////////////////////
00082       virtual void onSuccess(ClientPublicationHandle h, const SipMessage& status);
00083       virtual void onRemove(ClientPublicationHandle h, const SipMessage& status);
00084       virtual void onFailure(ClientPublicationHandle h, const SipMessage& response);
00085       virtual int onRequestRetry(ClientPublicationHandle h, int retryMinimum, const SipMessage& response);
00086       
00087       // OutOfDialogHandler //////////////////////////////////////////////////////////
00088       virtual void onSuccess(ClientOutOfDialogReqHandle, const SipMessage& response);
00089       virtual void onFailure(ClientOutOfDialogReqHandle, const SipMessage& response);
00090       virtual void onReceivedRequest(ServerOutOfDialogReqHandle, const SipMessage& request);
00091       virtual void onForkDestroyed(ClientInviteSessionHandle);
00092 
00093       class EndInviteSessionCommand : public DumCommand
00094       {
00095          public:
00096             EndInviteSessionCommand(InviteSessionHandle h) : mHandle(h)
00097             {}
00098 
00099             virtual void executeCommand()
00100             {
00101                if(mHandle.isValid() && !mHandle->isTerminated())
00102                {
00103                   mHandle->end();
00104                }
00105             }
00106 
00107             virtual Message* clone() const
00108             {
00109                return new EndInviteSessionCommand(mHandle);
00110             }
00111 
00112 #ifdef RESIP_USE_STL_STREAMS
00113             virtual std::ostream& encode(std::ostream& str) const
00114 #else
00115             virtual EncodeStream& encode(EncodeStream& str) const
00116 #endif
00117             {
00118                return str << "EndInviteSessionCommand";
00119             }
00120 
00121 #ifdef RESIP_USE_STL_STREAMS
00122             virtual std::ostream& encodeBrief(std::ostream& str) const
00123 #else
00124             virtual EncodeStream& encodeBrief(EncodeStream& str) const
00125 #endif
00126             {
00127                return encode(str);
00128             }
00129          
00130          private:
00131             InviteSessionHandle mHandle;
00132       };
00133 
00134    protected:
00135       void addTransport(TransportType type, int port);
00136 
00137       SharedPtr<MasterProfile> mProfile;
00138       Security* mSecurity;
00139       SipStack mStack;
00140       DialogUsageManager mDum;
00141       StackThread mStackThread;
00142 };
00143  
00144 }
00145 
00146 #endif
00147 
00148 /* ====================================================================
00149  * The Vovida Software License, Version 1.0 
00150  * 
00151  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00152  * 
00153  * Redistribution and use in source and binary forms, with or without
00154  * modification, are permitted provided that the following conditions
00155  * are met:
00156  * 
00157  * 1. Redistributions of source code must retain the above copyright
00158  *    notice, this list of conditions and the following disclaimer.
00159  * 
00160  * 2. Redistributions in binary form must reproduce the above copyright
00161  *    notice, this list of conditions and the following disclaimer in
00162  *    the documentation and/or other materials provided with the
00163  *    distribution.
00164  * 
00165  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00166  *    and "Vovida Open Communication Application Library (VOCAL)" must
00167  *    not be used to endorse or promote products derived from this
00168  *    software without prior written permission. For written
00169  *    permission, please contact vocal@vovida.org.
00170  *
00171  * 4. Products derived from this software may not be called "VOCAL", nor
00172  *    may "VOCAL" appear in their name, without prior written
00173  *    permission of Vovida Networks, Inc.
00174  * 
00175  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00176  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00177  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00178  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00179  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00180  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00181  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00182  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00183  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00184  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00185  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00186  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00187  * DAMAGE.
00188  * 
00189  * ====================================================================
00190  * 
00191  * This software consists of voluntary contributions made by Vovida
00192  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00193  * Inc.  For more information on Vovida Networks, Inc., please see
00194  * <http://www.vovida.org/>.
00195  *
00196  */