[asterisk-commits] dvossel: branch dvossel/sip_resource_list_trunk r188018 - /team/dvossel/sip_r...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 10 17:36:22 CDT 2009


Author: dvossel
Date: Fri Apr 10 17:36:13 2009
New Revision: 188018

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=188018
Log:
The first NOTIFY is now sent immediatly after processing the rlmi SUBSCRIPTION.   dialog version number is incremented correctly.  locking has still not been addressed

Modified:
    team/dvossel/sip_resource_list_trunk/channels/chan_sip.c

Modified: team/dvossel/sip_resource_list_trunk/channels/chan_sip.c
URL: http://svn.digium.com/svn-view/asterisk/team/dvossel/sip_resource_list_trunk/channels/chan_sip.c?view=diff&rev=188018&r1=188017&r2=188018
==============================================================================
--- team/dvossel/sip_resource_list_trunk/channels/chan_sip.c (original)
+++ team/dvossel/sip_resource_list_trunk/channels/chan_sip.c Fri Apr 10 17:36:13 2009
@@ -10611,7 +10611,7 @@
 		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);
+		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) && sip_cfg.notifyringing) {
 			const char *local_display = exten;
 			char *local_target = mto;
@@ -10668,7 +10668,7 @@
 static int transmit_state_notify(struct sip_pvt *p, int state, int full, int timeout)
 {
 	struct ast_str *tmp = ast_str_alloca(4000);
-	struct ast_str *content_type = ast_str_alloca(256);
+	struct ast_str *tmp2 = ast_str_alloca(256);
 	char from[256], to[256];
 	char *c, *mfrom, *mto;
 	struct sip_request req;
@@ -10737,10 +10737,10 @@
 		if(rlist) {
 			add_header(&req, "Require", "eventlist");
 			/* since multipart/related is involved, boundary and start must be added to Content-Type */
-			ast_str_append(&content_type, 0, "multipart/related;type=\"%s\";", subscriptiontype->mediatype);
-			ast_str_append(&content_type, 0, "start=\"<%s@%s>\";", rlist->contentid, p->fromdomain);
-			ast_str_append(&content_type, 0, "boundary=\"%s\"", boundary); //todohere better boundary
-			add_header(&req, "Content-Type", ast_str_buffer(content_type));
+			ast_str_append(&tmp2, 0, "multipart/related;type=\"%s\";", subscriptiontype->mediatype);
+			ast_str_append(&tmp2, 0, "start=\"<%s@%s>\";", rlist->contentid, p->fromdomain);
+			ast_str_append(&tmp2, 0, "boundary=\"%s\"", boundary); //todohere better boundary
+			add_header(&req, "Content-Type", ast_str_buffer(tmp2));
 
 			/* most of the Content of this NOTIFY is created in state_notify_build, 
 	 		* but when multipart/related is involved, some over head must be done here */
@@ -10761,7 +10761,9 @@
 				ast_str_append(&tmp, 0, "Content-Type: %s\r\n\r\n", subscriptiontype->mediatype);
 
 				//todohere, if not full, then only transmit resources marked for update
-				state_notify_build(resource->laststate, full, resource->exten, rlist->context, &tmp, p, p->multipart_subscribed, mfrom, mto);
+				ast_str_reset(tmp2);
+				ast_str_append(&tmp2, 0, "sip:%s@%s", resource->exten, p->fromdomain);
+				state_notify_build(resource->laststate, full, resource->exten, rlist->context, &tmp, p, p->multipart_subscribed, mfrom, ast_str_buffer(tmp2));
 			}
 			ast_str_append(&tmp, 0, "\r\n--%s", boundary);
 
@@ -10771,21 +10773,25 @@
 			ast_log(LOG_WARNING, "transmit_state_notify() NOTIFY rlmi, but no resource list\n");
 			return -1;
 		}
+		p->dialogver++;
 		break;
 	case CPIM_PIDF_XML:
 		add_header(&req, "Event", subscriptiontype->event);
 		state_notify_build(state, full, p->exten, p->context, &tmp, p, p->subscribed, mfrom, mto);
 		add_header(&req, "Content-Type", subscriptiontype->mediatype);
+		p->dialogver++;
 		break;
 	case PIDF_XML: /* Eyebeam supports this format */
 		add_header(&req, "Event", subscriptiontype->event);
 		state_notify_build(state, full, p->exten, p->context, &tmp, p, p->subscribed, mfrom, mto);
 		add_header(&req, "Content-Type", subscriptiontype->mediatype);
+		p->dialogver++;
 		break;
 	case DIALOG_INFO_XML: /* SNOM subscribes in this format */
 		add_header(&req, "Event", subscriptiontype->event);
 		state_notify_build(state, full, p->exten, p->context, &tmp, p, p->subscribed, mfrom, mto);
 		add_header(&req, "Content-Type", subscriptiontype->mediatype);
+		p->dialogver++;
 		break;
 	case NONE:
 	default:
@@ -12355,7 +12361,6 @@
 		break;
 	}
 
-//todohere transmit notify to all rlist watchers, something like this transmit_rlist_state_notify(p, state, 1, FALSE);
 	AST_LIST_TRAVERSE(&rlist->watchers, pvt, rlist_entry) {
 		ast_log(LOG_NOTICE, "SENDING NOTIFY FOR pvt\n"); //todohere remove
 		transmit_state_notify(pvt, state, 1, FALSE);
@@ -21310,9 +21315,10 @@
 		} else if (p->subscribed == DIALOG_RLMI_XML) { /* resource lists extension states are handled differently */
 			if (rlist_add_watcher(p) > 0) {
 				ast_set_flag(&p->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED);
+				p->dialogver = 0;
+				ast_string_field_build(p, subscribeuri, "%s@%s", p->exten, p->context);
 				transmit_response(p, "200 OK", req);
-				ast_string_field_build(p, subscribeuri, "%s@%s", p->exten, p->context);
-				p->dialogver = 0;
+				transmit_state_notify(p, 0, 1, FALSE);
 				//todohere force first notify and delete any matching old subscriptions (they will time out, but why wait
 			} else {
 				transmit_response(p, "404 Not found", req);
@@ -23517,6 +23523,7 @@
 
 static int rlist_add_watcher(struct sip_pvt *p)
 {
+	int res = 0;
 	if (p) {
 		/* find and point p->rlist to match, rlist ref is incremented if found */
 		rlist_find(p->exten, p->context, p);
@@ -23526,12 +23533,14 @@
 			p->rlist->num_watchers++;
 			rlist_start_monitor(p->rlist);
 			return 1;
+		} else {
+			res = -1;
 		}
 	} else {
-		return -1;
-	}
-
-	return 0;
+		res = -1;
+	}
+
+	return res;
 }
 
 static int rlist_remove_watcher(struct sip_pvt *p)




More information about the asterisk-commits mailing list