reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
UserAgentRegistration.cxx
Go to the documentation of this file.
1#include "UserAgent.hxx"
2#include "ReconSubsystem.hxx"
4
5#include <rutil/Log.hxx>
6#include <rutil/Logger.hxx>
9
10using namespace recon;
11using namespace resip;
12using namespace std;
13
14#define RESIPROCATE_SUBSYSTEM ReconSubsystem::RECON
15
17: AppDialogSet(dum),
18 mUserAgent(userAgent),
19 mConversationProfileHandle(handle),
20 mEnded(false)
21{
22 mUserAgent.registerRegistration(this);
23}
24
29
32{
33 return mConversationProfileHandle;
34}
35
36void
38{
39 if(!mEnded)
40 {
41 mEnded = true;
42 if(mRegistrationHandle.isValid())
43 {
44 try
45 {
46 // If ended - then just shutdown registration - likely due to shutdown
47 mRegistrationHandle->end();
48 }
49 catch(BaseException&)
50 {
51 // If end() call is nested - it will throw - catch here so that processing continues normally
52 }
53 }
54 }
55}
56
57bool
59{
60 if (mRegistrationHandle.isValid())
61 {
62 mRegistrationHandle->requestRefresh();
63 return true;
64 }
65 return false;
66}
67
68const NameAddrs&
70{
71 static NameAddrs empty;
72 if(mRegistrationHandle.isValid())
73 {
74 return mRegistrationHandle->allContacts(); // .slg. note: myContacts is not sufficient, since they do not contain the stack populated transport address
75 }
76 else
77 {
78 return empty;
79 }
80}
81
82const Tuple&
84{
85 return mLastServerTuple;
86}
87
88
90// Registration Handler ////////////////////////////////////////////////////////
92void
94{
95 InfoLog(<< "onSuccess(ClientRegistrationHandle): " << msg.brief());
96 mLastServerTuple = msg.getSource();
97 if(!mEnded)
98 {
99 mRegistrationHandle = h;
100 }
101 else
102 {
103 try
104 {
105 // If ended - then just shutdown registration - likely due to shutdown
106 h->end();
107 }
108 catch(BaseException&)
109 {
110 // If end() call is nested - it will throw - catch here so that processing continues normally
111 }
112 }
113}
114
115void
117{
118 WarningLog(<< "onFailure(ClientRegistrationHandle): " << msg.brief());
119 mLastServerTuple = msg.getSource();
120 if (!mEnded)
121 {
122 mRegistrationHandle = h;
123 }
124 else
125 {
126 try
127 {
128 // If we don't have a handle - then just shutdown registration - likely due to shutdown
129 h->end();
130 }
131 catch(BaseException&)
132 {
133 // If end() call is nested - it will throw - catch here so that processing continues normally
134 }
135 }
136}
137
138void
140{
141 InfoLog(<< "onRemoved(ClientRegistrationHandle): " << msg.brief());
142 mLastServerTuple = msg.getSource();
143}
144
145int
147{
148 InfoLog(<< "onRequestRetry(ClientRegistrationHandle): " << msg.brief());
149 mLastServerTuple = msg.getSource();
150 return -1; // Let Profile retry setting take effect
151}
152
153
154/* ====================================================================
155
156 Copyright (c) 2016-2023, SIP Spectrum, Inc. http://www.sipspectrum.com
157 Copyright (c) 2007-2008, Plantronics, Inc.
158 All rights reserved.
159
160 Redistribution and use in source and binary forms, with or without
161 modification, are permitted provided that the following conditions are
162 met:
163
164 1. Redistributions of source code must retain the above copyright
165 notice, this list of conditions and the following disclaimer.
166
167 2. Redistributions in binary form must reproduce the above copyright
168 notice, this list of conditions and the following disclaimer in the
169 documentation and/or other materials provided with the distribution.
170
171 3. Neither the name of Plantronics nor the names of its contributors
172 may be used to endorse or promote products derived from this
173 software without specific prior written permission.
174
175 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
177 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
178 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
179 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
180 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
181 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
182 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
183 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
184 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
185 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
186
187 ==================================================================== */
#define InfoLog(args_)
Definition Logger.hxx:131
#define WarningLog(args_)
Definition Logger.hxx:134
static Mimes empty
virtual int onRequestRetry(resip::ClientRegistrationHandle h, int retryMinimum, const resip::SipMessage &msg)
const resip::Tuple & getLastServerTuple()
virtual void onRemoved(resip::ClientRegistrationHandle h, const resip::SipMessage &response)
virtual void onFailure(resip::ClientRegistrationHandle h, const resip::SipMessage &response)
virtual void onSuccess(resip::ClientRegistrationHandle h, const resip::SipMessage &response)
const resip::NameAddrs & getContactAddresses()
ConversationProfileHandle getConversationProfileHandle()
UserAgentRegistration(UserAgent &userAgent, resip::DialogUsageManager &dum, unsigned int handle)
This class is one of two main classes of concern to an application using the UserAgent library.
Definition UserAgent.hxx:56
void registerRegistration(UserAgentRegistration *)
void unregisterRegistration(UserAgentRegistration *)
The abstract base-class for all exceptions thrown by resip code.
bool isValid() const
Definition Handle.hxx:25
virtual Brief brief() const
return a facet for brief encoding of message
Definition Message.cxx:16
Represents a SIP message.
const Tuple & getSource() const
Returns the source tuple that the message was received from only makes sense for messages received fr...
Represents a network address.
Definition Tuple.hxx:59
unsigned int ConversationProfileHandle
dcm! – add UnusedChecking(_enum) below;