[svn-commits] seanbright: branch seanbright/issue5014 r143465 - /team/seanbright/issue5014/...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Wed Sep 17 19:59:20 CDT 2008
Author: seanbright
Date: Wed Sep 17 19:59:20 2008
New Revision: 143465
URL: http://svn.digium.com/view/asterisk?view=rev&rev=143465
Log:
First small batch of changes in reference to issue 5014. We generate a magic
call-id to send in our dialog-info messages, which the SNOM will turn around
and send back as the Replaces header of a fresh INVITE. That part works, now
we just need to actually pick up the extension.
As discussed with russellb and kpfleming on #asterisk-dev, some of the changes
made in pkempgen-pickup-60212.patch in reference to cid name/num I've left out,
since an extension could be in a ringing state for any number of reasons, and
we can't assume that information will even be useful to the user.
Thanks to russellb and kpfleming for talking me through this stuff.
Modified:
team/seanbright/issue5014/channels/chan_sip.c
Modified: team/seanbright/issue5014/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/issue5014/channels/chan_sip.c?view=diff&rev=143465&r1=143464&r2=143465
==============================================================================
--- team/seanbright/issue5014/channels/chan_sip.c (original)
+++ team/seanbright/issue5014/channels/chan_sip.c Wed Sep 17 19:59:20 2008
@@ -9367,11 +9367,25 @@
break;
case DIALOG_INFO_XML: /* SNOM subscribes in this format */
ast_str_append(&tmp, 0, "<?xml version=\"1.0\"?>\n");
- ast_str_append(&tmp, 0, "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"%d\" state=\"%s\" entity=\"%s\">\n", p->dialogver++, full ? "full":"partial", mto);
- if ((state & AST_EXTENSION_RINGING) && global_notifyringing)
- ast_str_append(&tmp, 0, "<dialog id=\"%s\" direction=\"recipient\">\n", p->exten);
- else
+ ast_str_append(&tmp, 0, "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"%d\" state=\"%s\" entity=\"%s\">\n", p->dialogver++, full ? "full" : "partial", mto);
+ if ((state & AST_EXTENSION_RINGING) && global_notifyringing) {
+ /* We create a fake call-id which the phone will send back in an INVITE
+ Replaces header which we can grab and do some magic with. */
+ ast_str_append(&tmp, 0, "<dialog id=\"%s\" call-id=\"pickup-%s\" direction=\"recipient\">\n", p->exten, p->callid);
+ ast_str_append(&tmp, 0, "<remote>\n");
+ /* Note that the identity and target elements for the local participant are currently
+ (and may forever be) incorrect since we have no reliable way to get at that information
+ at the moment. Luckily the phone seems to still live happily without it being correct */
+ ast_str_append(&tmp, 0, "<identity>%s</identity>\n", mto);
+ ast_str_append(&tmp, 0, "<target uri=\"%s\"/>\n", mto);
+ ast_str_append(&tmp, 0, "</remote>\n");
+ ast_str_append(&tmp, 0, "<local>\n");
+ ast_str_append(&tmp, 0, "<identity>%s</identity>\n", mto);
+ ast_str_append(&tmp, 0, "<target uri=\"%s\"/>\n", mto);
+ ast_str_append(&tmp, 0, "</local>\n");
+ } else {
ast_str_append(&tmp, 0, "<dialog id=\"%s\">\n", p->exten);
+ }
ast_str_append(&tmp, 0, "<state>%s</state>\n", statestring);
if (state == AST_EXTENSION_ONHOLD) {
ast_str_append(&tmp, 0, "<local>\n<target uri=\"%s\">\n"
@@ -17269,10 +17283,27 @@
ast_debug(4, "Invite/replaces: Will use Replace-Call-ID : %s Fromtag: %s Totag: %s\n", replace_id, fromtag ? fromtag : "<no from tag>", totag ? totag : "<no to tag>");
- /* Try to find call that we are replacing
- If we have a Replaces header, we need to cancel that call if we succeed with this call
+ /* Try to find call that we are replacing.
+ If we have a Replaces header, we need to cancel that call if we succeed with this call.
+ First we cheat a little and look for a magic call-id from phones that support
+ dialog-info+xml...
*/
- if ((p->refer->refer_call = get_sip_pvt_byid_locked(replace_id, totag, fromtag)) == NULL) {
+ if (strncmp(replace_id, "pickup-", 7) == 0) {
+ struct sip_pvt *subscription = NULL;
+ char *notify_call = &replace_id[7];
+
+ if ((subscription = get_sip_pvt_byid_locked(notify_call, NULL, NULL)) == NULL) {
+ ast_log(LOG_NOTICE, "Unable to find subscription with call-id: %s\n", notify_call);
+ transmit_response_reliable(p, "481 Call Leg Does Not Exist (Replaces)", req);
+ error = 1;
+ } else {
+ ast_log(LOG_NOTICE, "Found it, we're going to pick up %s@%s!\n", subscription->exten, subscription->context);
+ sip_pvt_unlock(subscription);
+ ast_channel_unlock(subscription->owner);
+ }
+ }
+
+ if (!error && (p->refer->refer_call = get_sip_pvt_byid_locked(replace_id, totag, fromtag)) == NULL) {
ast_log(LOG_NOTICE, "Supervised transfer attempted to replace non-existent call id (%s)!\n", replace_id);
transmit_response_reliable(p, "481 Call Leg Does Not Exist (Replaces)", req);
error = 1;
More information about the svn-commits
mailing list