51#define RESIPROCATE_SUBSYSTEM ReconSubsystem::RECON
54 mCurrentSubscriptionHandle(1),
55 mCurrentConversationProfileHandle(1),
56 mDefaultOutgoingConversationProfileHandle(0),
57 mConversationManager(conversationManager),
63 mSecurity(new
Security(mProfile->certPath())),
70 mStack(mSecurity, mProfile->getAdditionalDnsServers(), mEventInterruptor, false , socketFunc, 0, mPollGrp),
72 mStackThread(mStack, *mEventInterruptor, *mPollGrp),
74 mUserAgentShutdown(false)
77 const std::vector<Data>& rootCertDirectories =
mProfile->rootCertDirectories();
78 std::vector<Data>::const_iterator ci = rootCertDirectories.begin();
79 for(;ci != rootCertDirectories.end();ci++)
83 const std::vector<Data>& rootCertBundles =
mProfile->rootCertBundles();
84 ci = rootCertBundles.begin();
85 for(;ci != rootCertBundles.end();ci++)
129 if (profile->serverAuthManagerEnabled())
219 InfoLog(<<
"UserAgent::shutdown: posted UserAgentShutdownCmd, waiting for DUM to shutdown...");
227 InfoLog(<<
"UserAgent::shutdown: DUM shutdown, shutting down StackThread...");
232 InfoLog(<<
"UserAgent::shutdown: StackThread shutdown.");
252 if(duration > std::chrono::milliseconds::zero())
362std::shared_ptr<ConversationProfile>
372 ErrLog( <<
"getDefaultOutgoingConversationProfile: something is wrong - no profiles to return");
377std::shared_ptr<ConversationProfile>
382 ConversationProfileMap::iterator conIt;
385 auto cp = conIt->second;
386 if(cp->sessionCaps().session().origin().getAddress() == mediaAddress)
394std::shared_ptr<ConversationProfile>
403 RegistrationMap::iterator regIt;
406 const NameAddrs& contacts = regIt->second->getContactAddresses();
407 NameAddrs::const_iterator naIt;
408 for(naIt = contacts.
begin(); naIt != contacts.
end(); naIt++)
410 if ((*naIt).uri() == requestUri &&
411 (!requestUri.
exists(p_rinstance) ||
412 ((*naIt).uri().exists(p_rinstance) && requestUri.
param(p_rinstance) == (*naIt).uri().param(p_rinstance))))
417 InfoLog(<<
"getIncomingConversationProfile: comparing requestUri=" << requestUri <<
" to contactUri=" << (*naIt).uri() <<
" - MATCHED!");
418 return conIt->second;
422 InfoLog(<<
"getIncomingConversationProfile: comparing requestUri=" << requestUri <<
" to contactUri=" << (*naIt).uri() <<
" - matched, but conversation profile not found");
427 InfoLog(<<
"getIncomingConversationProfile: comparing requestUri=" << requestUri <<
" to contactUri=" << (*naIt).uri() <<
" - no match");
434 ConversationProfileMap::iterator conIt;
437 if(
isEqualNoCase(toAor, conIt->second->getDefaultFrom().uri().getAor()))
439 InfoLog(<<
"getIncomingConversationProfile: comparing toAor=" << toAor <<
" to defaultFromAor=" << conIt->second->getDefaultFrom().uri().getAor() <<
" - MATCHED!");
440 return conIt->second;
444 InfoLog(<<
"getIncomingConversationProfile: comparing toAor=" << toAor <<
" to defaultFromAor=" << conIt->second->getDefaultFrom().uri().getAor() <<
" - no match");
449 InfoLog( <<
"getIncomingConversationProfile: no matching profile found, falling back to default outgoing profile");
453std::shared_ptr<UserAgentMasterProfile>
474 InfoLog(<<
"UserAgent::onDumCanBeDeleted called.");
485 InfoLog(<<
"ConnectionTerminated seen for " << pTerminated->
getFlow() <<
" refreshing registrations");
489 RegistrationMap::iterator regIt;
492 if (regIt->second->getLastServerTuple().getFlowKey() == pTerminated->
getFlow().
getFlowKey())
494 regIt->second->forceRefresh();
504 std::vector<UserAgentMasterProfile::TransportInfo>& transports =
mProfile->getTransports();
505 std::vector<UserAgentMasterProfile::TransportInfo>::iterator i;
506 int lastActualPort = 0;
507 for(i = transports.begin(); i != transports.end(); i++)
546#if defined(RESIP_SIPSTACK_HAVE_FDPOLL)
597 InfoLog(<<
"UserAgent::shutdownImpl shutting down DUM...");
603 SubscriptionMap::iterator i;
604 for(i = tempSubs.begin(); i != tempSubs.end(); i++)
612 RegistrationMap::iterator j;
613 for(j = tempRegs.begin(); j != tempRegs.end(); j++)
626 conversationProfile->setHandle(handle);
645 if(conversationProfile->getDefaultRegistrationTime() != 0)
695 if(!
mProfile->isMimeTypeSupported(NOTIFY, mimeType))
697 mProfile->addSupportedMimeType(NOTIFY, mimeType);
726 note =
Data(
"Busy (DND)");
728 else if(status ==
"available")
730 note =
Data(
"Online");
732 else if(status ==
"away")
748 rpid->
mTag =
"activities";
751 if(status !=
"available")
760 rootNodes.push_back(dm);
767 DebugLog( <<
"generated final gPidf : " << endl << gPidf );
#define WarningLog(args_)
#define resip_assert(x)
This file needs to work for both C and C++ code.
static FlowManagerSubsystem FLOWMANAGER
static ReTurnSubsystem RETURN
static ReconSubsystem RECON
This class is one of two main classes of concern to an application using the UserAgent library.
virtual void setUserAgent(UserAgent *userAgent)
MediaStackAdapter & getMediaStackAdapter()
This class is used to manage active client publications.
PublicationHandle getPublicationHandle()
This class is used to manage active client subscriptions.
SubscriptionHandle getSubscriptionHandle()
This class is used to manage the creation of RemoteParticipant objects.
resip::Data mTlsPrivateKeyPassPhrase
resip::IpVersion mIPVersion
resip::SecurityTypes::TlsClientVerificationMode mCvm
resip::Data mTlsCertificate
resip::Data mSipDomainname
resip::Data mTlsPrivateKey
resip::SecurityTypes::SSLType mSslType
resip::TransportType mProtocol
This class is used to manage active SIP registrations.
ConversationProfileHandle getConversationProfileHandle()
The classes defined here are used to pass commands from the application thread to the UserAgent threa...
virtual void onSubscriptionNotify(SubscriptionHandle handle, const resip::Data ¬ifyData)
Callback used when a subscription has received an event notification from the server.
void unregisterSubscription(UserAgentClientSubscription *)
volatile bool mDumShutdown
std::shared_ptr< UserAgentMasterProfile > mProfile
friend class UserAgentClientSubscription
std::map< ConversationProfileHandle, UserAgentRegistration * > RegistrationMap
friend class DestroyConversationProfileCmd
friend class CreatePublicationCmd
std::map< SubscriptionHandle, UserAgentClientSubscription * > SubscriptionMap
friend class DestroySubscriptionCmd
virtual void onApplicationTimer(unsigned int timerId, std::chrono::duration< double > duration, unsigned int seqNumber)
Callback used when an application timer expires.
std::shared_ptr< ConversationProfile > getDefaultOutgoingConversationProfile()
virtual void process(int timeoutMs)
This should be called in a loop to give process cycles to the UserAgent.
void shutdown()
Used to initiate a shutdown of the useragent.
virtual void onUpdateExtension(resip::ClientSubscriptionHandle, const resip::SipMessage ¬ify, bool outOfOrder)
resip::DialogUsageManager & getDialogUsageManager()
virtual std::shared_ptr< ConversationProfile > getIncomingConversationProfile(const resip::SipMessage &msg)
void setDefaultOutgoingConversationProfile(ConversationProfileHandle handle)
Sets an existing Conversation Profile to the default profile to use for outbound calls.
static void setLogLevel(resip::Log::Level level, LoggingSubsystem subsystem=SubsystemAll)
Static method that sets the logging level for a particular subsystem, or all subsystems.
resip::Mutex mSubscriptionHandleMutex
std::shared_ptr< UserAgentMasterProfile > getUserAgentMasterProfile() const noexcept
ConversationManager * mConversationManager
SubscriptionMap mSubscriptions
void destroyPublication(PublicationHandle handle)
resip::EventStackThread mStackThread
void registerRegistration(UserAgentRegistration *)
void startup()
Starts the SIP stack thread.
resip::Mutex mPublicationHandleMutex
virtual void onSuccess(resip::ClientRegistrationHandle h, const resip::SipMessage &response)
Called when registration succeeds or each time it is successfully refreshed (manual refreshes only).
void destroyConversationProfile(ConversationProfileHandle handle)
Destroys an existing Conversation Profile.
void logDnsCache()
Used to initiate a snapshot of the existing DNS entries in the cache to the logging subsystem.
RegistrationMap mRegistrations
PublicationHandle mCurrentPublicationHandle
UserAgent(ConversationManager *conversationManager, std::shared_ptr< UserAgentMasterProfile > masterProfile, resip::AfterSocketCreationFuncPtr socketFunc=0)
Constructor.
ConversationProfileHandle addConversationProfile(std::shared_ptr< ConversationProfile > conversationProfile, bool defaultOutgoing=true)
Adds a Conversation Profile to be managed, by the user agent.
void destroySubscription(SubscriptionHandle handle)
Destroys an existing subscriptions.
resip::Mutex mConversationProfileHandleMutex
friend class DestroyPublicationCmd
friend class UserAgentRegistration
PublicationHandle createPublication(const resip::Data &eventType, const resip::NameAddr &target, const resip::Data &status, unsigned int publicationTime, const resip::Mime &mimeType)
void unregisterPublication(UserAgentClientPublication *)
virtual void onUpdatePending(resip::ClientSubscriptionHandle h, const resip::SipMessage ¬ify, bool outOfOrder)
ConversationProfileHandle getNewConversationProfileHandle()
void registerSubscription(UserAgentClientSubscription *)
SubscriptionHandle createSubscription(const resip::Data &eventType, const resip::NameAddr &target, unsigned int subscriptionTime, const resip::Mime &mimeType)
Requests that the user agent create and manage an event subscription.
void unregisterRegistration(UserAgentRegistration *)
resip::DialogUsageManager mDum
virtual void onNewSubscription(resip::ClientSubscriptionHandle h, const resip::SipMessage ¬ify)
friend class AddConversationProfileCmd
ConversationProfileMap mConversationProfiles
void clearDnsCache()
Used to clear the existing DNS entries in the cache.
friend class UserAgentShutdownCmd
friend class CreateSubscriptionCmd
friend class UserAgentClientPublication
void addConversationProfileImpl(ConversationProfileHandle handle, std::shared_ptr< ConversationProfile > conversationProfile, bool defaultOutgoing=true)
std::shared_ptr< ConversationProfile > getConversationProfileByMediaAddress(const resip::Data &mediaAddress)
virtual void post(resip::Message *msg)
volatile bool mUserAgentShutdown
ConversationManager * getConversationManager()
Retrieves the ConversationManager passed in the constructor.
virtual void startApplicationTimer(unsigned int timerId, std::chrono::duration< double > duration, unsigned int seqNumber)
Used by an application to start a timer that is managed by the useragent.
PublicationMap mPublications
virtual void onRemove(resip::ClientPublicationHandle h, const resip::SipMessage &status)
PublicationHandle getNewPublicationHandle()
void destroySubscriptionImpl(SubscriptionHandle handle)
virtual void onTerminated(resip::ClientSubscriptionHandle h, const resip::SipMessage *notify)
SubscriptionHandle mCurrentSubscriptionHandle
ConversationProfileHandle mCurrentConversationProfileHandle
SubscriptionHandle getNewSubscriptionHandle()
void setDefaultOutgoingConversationProfileImpl(ConversationProfileHandle handle)
friend class SetDefaultOutgoingConversationProfileCmd
void registerPublication(UserAgentClientPublication *)
void createPublicationImpl(PublicationHandle handle, const resip::Data &status, const resip::Data &eventType, const resip::NameAddr &target, unsigned int publicationTime, const resip::Mime &mimeType)
resip::Security * mSecurity
ConversationProfileHandle mDefaultOutgoingConversationProfileHandle
virtual int onRequestRetry(resip::ClientRegistrationHandle h, int retryMinimum, const resip::SipMessage &msg)
call on Retry-After failure.
virtual void onRemoved(resip::ClientRegistrationHandle h, const resip::SipMessage &response)
virtual void onUpdateActive(resip::ClientSubscriptionHandle h, const resip::SipMessage ¬ify, bool outOfOrder)
virtual void onSubscriptionTerminated(SubscriptionHandle handle, unsigned int statusCode)
Callback used when a subscription is terminated.
void destroyPublicationImpl(PublicationHandle handle)
void createSubscriptionImpl(SubscriptionHandle handle, const resip::Data &eventType, const resip::NameAddr &target, unsigned int subscriptionTime, const resip::Mime &mimeType)
virtual void onFailure(resip::ClientRegistrationHandle h, const resip::SipMessage &response)
Called if registration fails, usage will be destroyed (unless a Registration retry interval is enable...
void destroyConversationProfileImpl(ConversationProfileHandle handle)
A base-class for messages used by applications.
The abstract base-class for all exceptions thrown by resip code.
void addDomainPrivateKeyPEM(const Data &domainName, const Data &privateKeyPEM, const Data &privateKeyPassPhrase=Data::Empty)
void addDomainCertPEM(const Data &domainName, const Data &certPEM)
const Tuple & getFlow() const
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
static const Data Empty
Constant that represents a zero-length data.
static Data fromFile(const Data &filename)
bool empty() const noexcept
Checks whether the Data is empty.
void setClientRegistrationHandler(ClientRegistrationHandler *)
If there is no such handler, calling makeRegistration will throw.
void addOutOfDialogHandler(MethodTypes, OutOfDialogHandler *)
void send(std::shared_ptr< SipMessage > request)
void shutdown(DumShutdownHandler *)
void setInviteSessionHandler(InviteSessionHandler *)
If there is no such handler, calling makeInviteSession will throw and receiving an INVITE as a UAS wi...
void setClientAuthManager(std::unique_ptr< ClientAuthManager > client) noexcept
If there is no ClientAuthManager, when the client receives a 401/407, pass it up through the normal B...
void setServerPagerMessageHandler(ServerPagerMessageHandler *) noexcept
void addClientPublicationHandler(const Data &eventType, ClientPublicationHandler *)
If there is no such handler, calling makePublication will throw.
std::shared_ptr< SipMessage > makePublication(const NameAddr &target, const std::shared_ptr< UserProfile > &userProfile, const Contents &body, const Data &eventType, uint32_t expiresSeconds, AppDialogSet *=nullptr)
bool process(Mutex *mutex=NULL)
void setServerAuthManager(std::shared_ptr< ServerAuthManager > server)
If there is no ServerAuthManager, the server does not authenticate requests.
void setDialogSetHandler(DialogSetHandler *handler) noexcept
ClientPublicationHandler * getClientPublicationHandler(const Data &eventType)
ClientSubscriptionHandler * getClientSubscriptionHandler(const Data &eventType)
void registerForConnectionTermination(Postable *)
Note: Implementations of Postable must delete the message passed via post.
void setMasterProfile(const std::shared_ptr< MasterProfile > &masterProfile)
void setClientPagerMessageHandler(ClientPagerMessageHandler *) noexcept
void setAppDialogSetFactory(std::unique_ptr< AppDialogSetFactory >) noexcept
void addServerSubscriptionHandler(const Data &eventType, ServerSubscriptionHandler *)
void setKeepAliveManager(std::unique_ptr< KeepAliveManager > keepAlive) noexcept
void setRedirectHandler(RedirectHandler *handler) noexcept
std::shared_ptr< SipMessage > makeRegistration(const NameAddr &target, const std::shared_ptr< UserProfile > &userProfile, AppDialogSet *=nullptr)
void addClientSubscriptionHandler(const Data &eventType, ClientSubscriptionHandler *)
If there is no such handler, calling makeSubscription will throw.
std::shared_ptr< SipMessage > makeSubscription(const NameAddr &target, const std::shared_ptr< UserProfile > &userProfile, const Data &eventType, AppDialogSet *=nullptr)
SIP body type for holding PIDF contents (MIME content-type application/pidf+xml).
void setRootNodes(const NodeList &nodeList)
std::list< Node * > NodeList
void setSimplePresenceTupleNode(const Data &id, bool online, const Data ×tamp=Data::Empty, const Data ¬e=Data::Empty, const Data &contact=Data::Empty, const Data &contactPriority=Data::Empty)
const NodeList & getRootNodes() const
void addNamespace(const Data &uri, const Data &prefix)
void setEntity(const Uri &entity)
static void setLevel(Level level)
Set logging level for current thread.
The base-class used for message-passing.
Represents the "media-type" element in the RFC 3261 grammar.
Represents the "name-addr" and the "addr-spec" elements in the RFC 3261 grammar.
iterator end()
Returns an iterator pointing to the last header field value.
iterator begin()
Returns an iterator pointing to the first header field value.
bool find(const T &rhs) const
Finds the first header field value that matches rhs.
static Data getRandomHex(unsigned int numBytes)
void loadCAFile(const Data &fileName)
void loadCADirectory(const Data &directoryName)
Represents a SIP message.
bool isRequest() const
Returns true if message is a request, false otherwise.
const RequestLine & header(const RequestLineType &l) const
Returns the RequestLine. This is only valid for request messages.
void clearDnsCache()
Clear the DNS Cache.
Transport * addTransport(TransportType protocol, int port, IpVersion version=V4, StunSetting stun=StunDisabled, const Data &ipInterface=Data::Empty, const Data &sipDomainname=Data::Empty, const Data &privateKeyPassPhrase=Data::Empty, SecurityTypes::SSLType sslType=SecurityTypes::DynamicTLS, unsigned transportFlags=0, const Data &certificateFilename="", const Data &privateKeyFilename="", SecurityTypes::TlsClientVerificationMode cvm=SecurityTypes::None, bool useEmailAsSIP=false, std::shared_ptr< WsConnectionValidator >=nullptr, std::shared_ptr< WsCookieContextFactory >=nullptr, const Data &netNs=Data::Empty)
Used by the application to add in a new built-in transport.
void logDnsCache()
Log the DNS Cache to WarningLog for Debugging.
void post(std::unique_ptr< ApplicationMessage > message, unsigned int secondsLater, TransactionUser *tu=0)
Makes the message available to the TU at some later time, specified in seconds.
void setTransportSipMessageLoggingHandler(std::shared_ptr< Transport::SipMessageLoggingHandler > handler)
Used by the application to provide a handler that will get called for all inbound and outbound SIP me...
static Subsystem TRANSPORT
static Subsystem CONTENTS
static Subsystem TRANSACTION
void post(Message *msg)
Posts a Message to this TransactionUser's fifo.
The base class for Transport classes.
const Tuple & getTuple() const
virtual void setRcvBufLen(int buflen)
static const Data & toData(TransportType)
Converts the TransportType to a string representation of the transport type, e.g.
FlowKey getFlowKey() const
Represents the "SIP-URI" and "SIPS-URI" elements in the RFC 3261 grammar.
bool exists(const Param< Uri > ¶mType) const
Data getAorNoReally() const
const Data & param(const ExtensionParameter ¶m) const
Const accessor for non-natively-supported parameter types.
WARNING - This class is only appropriate for client TLS connections, as it only loads root certs.
volatile bool & statisticsManagerEnabled()
Enable Statistics Manager.
void setEnumSuffixes(const std::vector< Data > &suffixes)
Specify which enum domains will be searched when sending.
unsigned int ConversationProfileHandle
unsigned int SubscriptionHandle
unsigned int PublicationHandle
dcm! – add UnusedChecking(_enum) below;
void(* AfterSocketCreationFuncPtr)(Socket s, int transportType, const char *file, int line)
bool isEqualNoCase(const Data &left, const Data &right)
std::unique_lock< Mutex > Lock
A convenience class to lock a Lockable (such as a Mutex) on object creation, and unlock on destructio...
bool isSecure(TransportType type)
Returns true if passed in transport type is a secure transport protocol.
RequestLineType h_RequestLine