[asterisk-commits] branch oej/00-labarea r18434 - /team/oej/00-labarea/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Apr 7 14:55:15 MST 2006


Author: oej
Date: Fri Apr  7 16:55:13 2006
New Revision: 18434

URL: http://svn.digium.com/view/asterisk?rev=18434&view=rev
Log:
Fake call id for pickup

Modified:
    team/oej/00-labarea/channels/chan_sip.c

Modified: team/oej/00-labarea/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/00-labarea/channels/chan_sip.c?rev=18434&r1=18433&r2=18434&view=diff
==============================================================================
--- team/oej/00-labarea/channels/chan_sip.c (original)
+++ team/oej/00-labarea/channels/chan_sip.c Fri Apr  7 16:55:13 2006
@@ -1,3 +1,7 @@
+/* \todo - Fix handle_request_invite from siptransfer (with replaces) and make sure we pick up the fake
+   call id. Let's walk the walk at pickup, not at notification. ugly patch, I know.
+*/
+
 /*
  * Asterisk -- An open source telephony toolkit.
  *
@@ -963,7 +967,7 @@
 static int determine_firstline_parts(struct sip_request *req);
 static void sip_dump_history(struct sip_pvt *dialog);	/* Dump history to LOG_DEBUG at end of dialog, before destroying data */
 static const struct cfsubscription_types *find_subscription_type(enum subscriptiontype subtype);
-static int transmit_state_notify(struct sip_pvt *p, int state, int full);
+static int transmit_state_notify(struct sip_pvt *p, int state, int full, char *channel);
 static char *gettag(struct sip_request *req, char *header, char *tagbuf, int tagbufsize);
 static int find_sip_method(char *msg);
 static unsigned int parse_sip_options(struct sip_pvt *pvt, char *supported);
@@ -1354,7 +1358,7 @@
 	/* If this is a subscription, tell the phone that we got a timeout */
 	if (p->subscribed) {
 		p->subscribed = TIMEOUT;
-		transmit_state_notify(p, AST_EXTENSION_DEACTIVATED, 1);	/* Send last notification */
+		transmit_state_notify(p, AST_EXTENSION_DEACTIVATED, 1, NULL);	/* Send last notification */
 		p->subscribed = NONE;
 		append_history(p, "Subscribestatus", "timeout");
 		if (option_debug > 2)
@@ -5085,7 +5089,7 @@
 }
 
 /*! \brief Used in the SUBSCRIBE notification subsystem */
-static int transmit_state_notify(struct sip_pvt *p, int state, int full)
+static int transmit_state_notify(struct sip_pvt *p, int state, int full, char *channel)
 {
 	char tmp[4000], from[256], to[256];
 	char *t = tmp, *c, *a, *mfrom, *mto;
@@ -5097,6 +5101,7 @@
 	enum state { NOTIFY_OPEN, NOTIFY_INUSE, NOTIFY_CLOSED } local_state = NOTIFY_OPEN;
 	char *pidfstate = "--";
 	char *pidfnote= "Ready";
+	char pickupcallid[128] = "";
 
 	memset(from, 0, sizeof(from));
 	memset(to, 0, sizeof(to));
@@ -5197,6 +5202,7 @@
 		else	/* Expired */
 			add_header(&req, "Subscription-State", "terminated;reason=timeout");
 	}
+
 	switch (p->subscribed) {
 	case XPIDF_XML:
 	case CPIM_PIDF_XML:
@@ -5226,13 +5232,18 @@
 			ast_build_string(&t, &maxbytes, "<status><basic>%s</basic></status>\n", (local_state != NOTIFY_CLOSED) ? "open" : "closed");
 		ast_build_string(&t, &maxbytes, "</tuple>\n</presence>\n");
 		break;
-	case DIALOG_INFO_XML: /* SNOM subscribes in this format */
+	case DIALOG_INFO_XML: /* Aastra & SNOM subscribes in this format */
+		/* If we have a channel, fake a unique call ID that we can use for call pickups. */
+		if (channel)
+			snprintf(pickupcallid, sizeof(pickupcallid), "call-id=\"astpickup--%s--%s--%s\" local-tag=\"%s\" remote-tag=\"%s\"", global_realm, p->exten, channel, "ltag", "rtag");
+
 		ast_build_string(&t, &maxbytes, "<?xml version=\"1.0\"?>\n");
 		ast_build_string(&t, &maxbytes, "<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_build_string(&t, &maxbytes, "<dialog id=\"%s\" direction=\"recipient\">\n", p->exten);
+			ast_build_string(&t, &maxbytes, "<dialog id=\"%s\" direction=\"recipient\" %s>\n", p->exten, pickupcallid);
 		else
 			ast_build_string(&t, &maxbytes, "<dialog id=\"%s\">\n", p->exten);
+
 		ast_build_string(&t, &maxbytes, "<state>%s</state>\n", statestring);
 		ast_build_string(&t, &maxbytes, "</dialog>\n</dialog-info>\n");
 		break;
@@ -6408,7 +6419,7 @@
 		p->laststate = state;
 		break;
 	}
-	transmit_state_notify(p, state, 1);
+	transmit_state_notify(p, state, 1, channel);
 
 	if (option_debug > 1)
 		ast_verbose(VERBOSE_PREFIX_1 "Extension Changed %s new state %s for Notify User %s Caused by %s\n", exten, ast_extension_state2str(state), p->username, S_OR(channel, "<device state change>"));
@@ -11248,7 +11259,7 @@
 				struct sip_pvt *p_old;
 	
 				transmit_response(p, "200 OK", req);
-				transmit_state_notify(p, firststate, 1);	/* Send first notification */
+				transmit_state_notify(p, firststate, 1, NULL);	/* Send first notification */
 				append_history(p, "Subscribestatus", "%s", ast_extension_state2str(firststate));
 				/* hide the 'complete' exten/context in the refer_to field for later display */
 				ast_string_field_build(p, refer_to, "%s@%s", p->exten, p->context);



More information about the asterisk-commits mailing list