📄 dialogusagemanager.hxx
字号:
#if !defined(RESIP_DIALOGUSAGEMANAGER_HXX)#define RESIP_DIALOGUSAGEMANAGER_HXX#include <vector>#include <set>#include <map>#include "resip/stack/Headers.hxx"#include "resip/dum/EventDispatcher.hxx"#include "resip/dum/DialogSet.hxx"#include "resip/dum/DumTimeout.hxx"#include "resip/dum/HandleManager.hxx"#include "resip/dum/Handles.hxx"#include "resip/dum/MergedRequestKey.hxx"#include "resip/dum/RegistrationPersistenceManager.hxx"#include "resip/dum/EncryptionManager.hxx"#include "resip/dum/ServerSubscription.hxx"#include "rutil/BaseException.hxx"#include "rutil/SharedPtr.hxx"#include "resip/stack/SipStack.hxx"#include "resip/stack/TransactionUser.hxx"#include "resip/dum/DumFeature.hxx"#include "resip/dum/DumFeatureChain.hxx"#include "resip/dum/DumFeatureMessage.hxx"#include "resip/dum/TargetCommand.hxx"#include "resip/dum/ClientSubscriptionFunctor.hxx"#include "resip/dum/ServerSubscriptionFunctor.hxx"namespace resip {class Security;class SipStack;class FdSet;class MasterProfile;class RedirectManager;class ClientAuthManager;class ServerAuthManager;class Uri;class SdpContents;class ClientRegistrationHandler;class ServerRegistrationHandler;class InviteSessionHandler;class ClientSubscriptionHandler;class ServerSubscriptionHandler;class ClientPublicationHandler;class ServerPublicationHandler;class ClientPagerMessageHandler;class ServerPagerMessageHandler;class OutOfDialogHandler;class RedirectHandler;class DialogSetHandler;class Dialog;class InviteSessionCreator;class AppDialogSetFactory;class DumShutdownHandler;class KeepAliveManager;class HttpGetMessage;class ConnectionTerminated;class RWMutex;class ExternalMessageBase;class ExternalMessageHandler;class DialogUsageManager : public HandleManager, public TransactionUser{ public: class Exception : public BaseException { public: Exception(const Data& msg, const Data& file, int line) : BaseException(msg, file, line) {} virtual const char* name() const {return "DialogUsageManager::Exception";} }; typedef enum { None = 0, Sign, Encrypt, SignAndEncrypt } EncryptionLevel; // If createDefaultFeatures is true dum will construct a // IdentityHandler->EncryptionManager chain. DialogUsageManager(SipStack& stack, bool createDefaultFeatures=false); virtual ~DialogUsageManager(); // !bwc! Maybe add a giveUpSeconds param to these. void shutdown(DumShutdownHandler*); // !bwc! This is not properly implemented (has an assert(0) in it). // I am removing this declaration. // void shutdownIfNoUsages(DumShutdownHandler*); void forceShutdown(DumShutdownHandler*); void addTransport( TransportType protocol, int port=0, IpVersion version=V4, const Data& ipInterface = Data::Empty, const Data& sipDomainname = Data::Empty, // only used // for TLS // based stuff const Data& privateKeyPassPhrase = Data::Empty, SecurityTypes::SSLType sslType = SecurityTypes::TLSv1 ); SipStack& getSipStack(); Security* getSecurity(); Data getHostAddress(); void setAppDialogSetFactory(std::auto_ptr<AppDialogSetFactory>); void setMasterProfile(const SharedPtr<MasterProfile>& masterProfile); SharedPtr<MasterProfile>& getMasterProfile(); SharedPtr<UserProfile>& getMasterUserProfile(); //optional handler to track the progress of DialogSets void setDialogSetHandler(DialogSetHandler* handler); void setKeepAliveManager(std::auto_ptr<KeepAliveManager> keepAlive); //There is a default RedirectManager. Setting one may cause the old one //to be deleted. void setRedirectManager(std::auto_ptr<RedirectManager> redirect); //informational, so a RedirectHandler is not required void setRedirectHandler(RedirectHandler* handler); RedirectHandler* getRedirectHandler(); /// If there is no ClientAuthManager, when the client receives a 401/407, /// pass it up through the normal BaseUsageHandler void setClientAuthManager(std::auto_ptr<ClientAuthManager> client); /// If there is no ServerAuthManager, the server does not authenticate requests void setServerAuthManager(resip::SharedPtr<ServerAuthManager> server); /// If there is no such handler, calling makeInviteSession will throw and /// receiving an INVITE as a UAS will respond with 405 Method Not Allowed void setInviteSessionHandler(InviteSessionHandler*); /// If there is no such handler, calling makeRegistration will throw void setClientRegistrationHandler(ClientRegistrationHandler*); /// If no such handler, UAS will respond to REGISTER with 405 Method Not Allowed void setServerRegistrationHandler(ServerRegistrationHandler*); /// If there is no such handler, calling makeSubscription will throw void addClientSubscriptionHandler(const Data& eventType, ClientSubscriptionHandler*); /// If there is no such handler, calling makePublication will throw void addClientPublicationHandler(const Data& eventType, ClientPublicationHandler*); void addServerSubscriptionHandler(const Data& eventType, ServerSubscriptionHandler*); void addServerPublicationHandler(const Data& eventType, ServerPublicationHandler*); void addOutOfDialogHandler(MethodTypes, OutOfDialogHandler*); void setClientPagerMessageHandler(ClientPagerMessageHandler*); void setServerPagerMessageHandler(ServerPagerMessageHandler*); /// Add/Remove External Message Handler /// do following op when processing thread in not running void addExternalMessageHandler(ExternalMessageHandler* handler); void removeExternalMessageHandler(ExternalMessageHandler* handler); void clearExternalMessageHandler(); /// Sets a manager to handle storage of registration state void setRegistrationPersistenceManager(RegistrationPersistenceManager*); void setRemoteCertStore(std::auto_ptr<RemoteCertStore> store); // The message is owned by the underlying datastructure and may go away in // the future. If the caller wants to keep it, it should make a copy. The // memory will exist at least up until the point where the application // calls DialogUsageManager::send(msg); SharedPtr<SipMessage> makeInviteSession(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, const SdpContents* initialOffer, AppDialogSet* ads = 0); SharedPtr<SipMessage> makeInviteSession(const NameAddr& target, const SdpContents* initialOffer, AppDialogSet* ads = 0); SharedPtr<SipMessage> makeInviteSession(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, const SdpContents* initialOffer, EncryptionLevel level, const SdpContents* alternative = 0, AppDialogSet* ads = 0); SharedPtr<SipMessage> makeInviteSession(const NameAddr& target, const SdpContents* initialOffer, EncryptionLevel level, const SdpContents* alternative = 0, AppDialogSet* ads = 0); //will send a Notify(100)...currently can be decorated through the //OnReadyToSend callback. Probably will change it's own callback/handler soon SharedPtr<SipMessage> makeInviteSessionFromRefer(const SipMessage& refer, ServerSubscriptionHandle, const SdpContents* initialOffer, AppDialogSet* = 0); SharedPtr<SipMessage> makeInviteSessionFromRefer(const SipMessage& refer, const SharedPtr<UserProfile>& userProfile, const SdpContents* initialOffer, AppDialogSet* appDs = 0); SharedPtr<SipMessage> makeInviteSessionFromRefer(const SipMessage& refer, ServerSubscriptionHandle, const SdpContents* initialOffer, EncryptionLevel level, const SdpContents* alternative, AppDialogSet* = 0); SharedPtr<SipMessage> makeInviteSessionFromRefer(const SipMessage& refer, const SharedPtr<UserProfile>& userProfile, ServerSubscriptionHandle, const SdpContents* initialOffer, EncryptionLevel level, const SdpContents* alternative, AppDialogSet* = 0); SharedPtr<SipMessage> makeSubscription(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, const Data& eventType, AppDialogSet* = 0); SharedPtr<SipMessage> makeSubscription(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, const Data& eventType, UInt32 subscriptionTime, AppDialogSet* = 0); SharedPtr<SipMessage> makeSubscription(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, const Data& eventType, UInt32 subscriptionTime, int refreshInterval, AppDialogSet* = 0); SharedPtr<SipMessage> makeSubscription(const NameAddr& target, const Data& eventType, AppDialogSet* = 0); SharedPtr<SipMessage> makeSubscription(const NameAddr& target, const Data& eventType, UInt32 subscriptionTime, AppDialogSet* = 0); SharedPtr<SipMessage> makeSubscription(const NameAddr& target, const Data& eventType, UInt32 subscriptionTime, int refreshInterval, AppDialogSet* = 0); //unsolicited refer SharedPtr<SipMessage> makeRefer(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, const H_ReferTo::Type& referTo, AppDialogSet* = 0); SharedPtr<SipMessage> makeRefer(const NameAddr& target, const H_ReferTo::Type& referTo, AppDialogSet* = 0); SharedPtr<SipMessage> makePublication(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, const Contents& body, const Data& eventType, UInt32 expiresSeconds, AppDialogSet* = 0); SharedPtr<SipMessage> makePublication(const NameAddr& target, const Contents& body, const Data& eventType, UInt32 expiresSeconds, AppDialogSet* = 0); SharedPtr<SipMessage> makeRegistration(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, AppDialogSet* = 0); SharedPtr<SipMessage> makeRegistration(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, UInt32 registrationTime, AppDialogSet* = 0); SharedPtr<SipMessage> makeRegistration(const NameAddr& target, AppDialogSet* = 0); SharedPtr<SipMessage> makeRegistration(const NameAddr& target, UInt32 registrationTime, AppDialogSet* = 0); SharedPtr<SipMessage> makeOutOfDialogRequest(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, const MethodTypes meth, AppDialogSet* = 0); SharedPtr<SipMessage> makeOutOfDialogRequest(const NameAddr& target, const MethodTypes meth, AppDialogSet* = 0); ClientPagerMessageHandle makePagerMessage(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, AppDialogSet* = 0); ClientPagerMessageHandle makePagerMessage(const NameAddr& target, AppDialogSet* = 0); void end(DialogSetId invSessionId); void send(SharedPtr<SipMessage> request); //void send(SipMessage& request, EncryptionLevel level); // give dum an opportunity to handle its events. If process() returns true // there are more events to process. bool hasEvents() const; bool process(RWMutex* mutex = NULL); // non-blocking bool process(int timeoutMs, RWMutex* mutex = NULL); // Specify -1 for infinte timeout InviteSessionHandle findInviteSession(DialogId id); //if the handle is inValid, int represents the errorcode std::pair<InviteSessionHandle, int> findInviteSession(CallId replaces); std::vector<ClientSubscriptionHandle> findClientSubscriptions(DialogId id); std::vector<ClientSubscriptionHandle> findClientSubscriptions(DialogSetId id); std::vector<ClientSubscriptionHandle> findClientSubscriptions(DialogSetId id, const Data& eventType, const Data& subId); ServerSubscriptionHandle findServerSubscription(DialogId id); ClientPublicationHandle findClientPublication(DialogId id); ServerPublicationHandle findServerPublication(DialogId id); std::vector<ClientOutOfDialogReqHandle> findClientOutOfDialog(DialogId id); ServerOutOfDialogReqHandle findServerOutOfDialog(DialogId id); ClientPublicationHandler* getClientPublicationHandler(const Data& eventType); ServerPublicationHandler* getServerPublicationHandler(const Data& eventType); ClientSubscriptionHandler* getClientSubscriptionHandler(const Data& eventType); ServerSubscriptionHandler* getServerSubscriptionHandler(const Data& eventType); // will apply the specified functor(which takes a //ServerSubscriptionHandle) to each matching ServerSubscription. //Returns the functor after the last application. template<typename UnaryFunction> UnaryFunction applyToServerSubscriptions(const Data& aor, const Data& eventType, UnaryFunction applyFn) { Data key = eventType + aor; std::pair<ServerSubscriptions::iterator,ServerSubscriptions::iterator> range = mServerSubscriptions.equal_range(key); for (ServerSubscriptions::iterator i=range.first; i!=range.second; ++i)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -