[reSIProcate] DUM reject() should have minExpires, warning, where appropriate
We have found it useful to make the reject() method take optional
parameters for a warning header and a minExpires header where appropriate.
In an hxx file:
void reject(int statusCode, int minExpiry = -1, const WarningCategory *
warning = NULL);
Then in the cxx file:
ServerRegistration::reject(int statusCode, int minExpiry, const
WarningCategory * warning)
{
InfoLog( << "rejected a registration " << mAor << " with
statusCode=" << statusCode );
@@ -167,6 +167,16 @@
SharedPtr<SipMessage> failure(new SipMessage);
mDum.makeResponse(*failure, mRequest, statusCode);
failure->remove(h_Contacts);
+ if (minExpiry != -1)
+ {
+ failure->header(h_MinExpires).value() = minExpiry;
+ }
+
+ if (warning)
+ {
+ failure->header(h_Warnings).push_back(*warning);
+ }
+
mDum.send(failure);
delete(this);
}
Of course, not all reject() methods want both new arguments. Diff files
from 1.9.6 attached.
regards,
-John Gregg
Index: ServerOutOfDialogReq.cxx
===================================================================
--- ServerOutOfDialogReq.cxx (revision 27529)
+++ ServerOutOfDialogReq.cxx (working copy)
@@ -111,10 +111,14 @@
}
SharedPtr<SipMessage>
-ServerOutOfDialogReq::reject(int statusCode)
+ServerOutOfDialogReq::reject(int statusCode, WarningCategory* warning)
{
//!dcm! -- should any responses should include a contact?
mDum.makeResponse(*mResponse, mRequest, statusCode);
+ if (warning)
+ {
+ mResponse->header(h_Warnings).push_back(*warning);
+ }
return mResponse;
}
Index: ServerOutOfDialogReq.hxx
===================================================================
--- ServerOutOfDialogReq.hxx (revision 27529)
+++ ServerOutOfDialogReq.hxx (working copy)
@@ -14,7 +14,7 @@
ServerOutOfDialogReqHandle getHandle();
SharedPtr<SipMessage> accept(int statusCode = 200);
- SharedPtr<SipMessage> reject(int statusCode);
+ SharedPtr<SipMessage> reject(int statusCode, WarningCategory* warning = NULL); // AYLUS_CHANGE
virtual void end();
virtual void dispatch(const SipMessage& msg);
Index: ServerPagerMessage.cxx
===================================================================
--- ServerPagerMessage.cxx (revision 27529)
+++ ServerPagerMessage.cxx (working copy)
@@ -141,10 +141,15 @@
}
SharedPtr<SipMessage>
-ServerPagerMessage::reject(int statusCode)
+ServerPagerMessage::reject(int statusCode, WarningCategory * warning)
{
//!dcm! -- should any responses include a contact?
mDum.makeResponse(*mResponse, mRequest, statusCode);
+ if (warning)
+ {
+ mResponse->header(h_Warnings).push_back(*warning);
+ }
+
return mResponse;
}
Index: ServerPagerMessage.hxx
===================================================================
--- ServerPagerMessage.hxx (revision 27529)
+++ ServerPagerMessage.hxx (working copy)
@@ -14,7 +14,7 @@
ServerPagerMessageHandle getHandle();
SharedPtr<SipMessage> accept(int statusCode = 200);
- SharedPtr<SipMessage> reject(int statusCode);
+ SharedPtr<SipMessage> reject(int statusCode, WarningCategory* warning = NULL); // AYLUS_CHANGE
virtual void end();
Index: ServerPublication.cxx
===================================================================
--- ServerPublication.cxx (revision 27529)
+++ ServerPublication.cxx (working copy)
@@ -81,10 +81,14 @@
}
SharedPtr<SipMessage>
-ServerPublication::reject(int statusCode)
+ServerPublication::reject(int statusCode, int minExpiry)
{
Helper::makeResponse(*mLastResponse, mLastRequest, statusCode);
mLastResponse->header(h_Expires).value() = mExpires;
+ if (minExpiry != -1)
+ {
+ mLastResponse->header(h_MinExpires).value() = minExpiry;
+ }
return mLastResponse;
}
Index: ServerPublication.hxx
===================================================================
--- ServerPublication.hxx (revision 27529)
+++ ServerPublication.hxx (working copy)
@@ -19,7 +19,7 @@
const Data& getDocumentKey() const;
SharedPtr<SipMessage> accept(int statusCode = 200);
- SharedPtr<SipMessage> reject(int responseCode);
+ SharedPtr<SipMessage> reject(int responseCode, int minExpiry = -1);
virtual void end();
Index: ServerRegistration.cxx
===================================================================
--- ServerRegistration.cxx (revision 27529)
+++ ServerRegistration.cxx (working copy)
@@ -144,7 +144,7 @@
}
void
-ServerRegistration::reject(int statusCode)
+ServerRegistration::reject(int statusCode, int minExpiry, const WarningCategory * warning)
{
InfoLog( << "rejected a registration " << mAor << " with statusCode=" << statusCode );
@@ -167,6 +167,16 @@
SharedPtr<SipMessage> failure(new SipMessage);
mDum.makeResponse(*failure, mRequest, statusCode);
failure->remove(h_Contacts);
+ if (minExpiry != -1)
+ {
+ failure->header(h_MinExpires).value() = minExpiry;
+ }
+
+ if (warning)
+ {
+ failure->header(h_Warnings).push_back(*warning);
+ }
+
mDum.send(failure);
delete(this);
}
Index: ServerRegistration.hxx
===================================================================
--- ServerRegistration.hxx (revision 27529)
+++ ServerRegistration.hxx (working copy)
@@ -32,7 +32,7 @@
!Warning! After calling this function from a ServerRegistrationHandle, do not access the handle as this function
may delete this object. Use ServerRegistrationHandle::isValidHandle() to test if it's deleted.
*/
- void reject(int statusCode);
+ void reject(int statusCode, int minExpiry = -1, const WarningCategory * warning = NULL);
virtual void end();
virtual void dispatch(const SipMessage& msg);
Index: ServerSubscription.cxx
===================================================================
--- ServerSubscription.cxx (revision 27529)
+++ ServerSubscription.cxx (working copy)
@@ -79,13 +79,19 @@
}
SharedPtr<SipMessage>
-ServerSubscription::reject(int statusCode)
+ServerSubscription::reject(int statusCode, int minExpiry)
{
if (statusCode < 300)
{
throw UsageUseException("Must reject with a code greater than or equal to 300", __FILE__, __LINE__);
}
mDialog.makeResponse(*mLastResponse, mLastSubscribe, statusCode);
+
+ if (minExpiry != -1)
+ {
+ mLastResponse->header(h_MinExpires).value() = minExpiry;
+ }
+
return mLastResponse;
}
Index: ServerSubscription.hxx
===================================================================
--- ServerSubscription.hxx (revision 27529)
+++ ServerSubscription.hxx (working copy)
@@ -21,7 +21,7 @@
//only 200 and 202 are permissable. SubscriptionState is not affected.
//currently must be called for a refresh as well as initial creation.
SharedPtr<SipMessage> accept(int statusCode = 202);
- SharedPtr<SipMessage> reject(int responseCode);
+ SharedPtr<SipMessage> reject(int responseCode, int minExpiry = -1);
//used to accept a reresh when there is no useful state to convey to the
//client