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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 14 18:28:55 CDT 2009


Author: dvossel
Date: Tue Apr 14 18:28:51 2009
New Revision: 188472

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=188472
Log:
cleaned up a few areas involving xml creation for RLMI

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=188472&r1=188471&r2=188472
==============================================================================
--- team/dvossel/sip_resource_list_trunk/channels/chan_sip.c (original)
+++ team/dvossel/sip_resource_list_trunk/channels/chan_sip.c Tue Apr 14 18:28:51 2009
@@ -10567,14 +10567,14 @@
 	//todohere finish progress made in creating rlmi NOTIFY
 		//todohere add name attributes for list and elements within list
 		ast_str_append(tmp, 0, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
-		ast_str_append(tmp, 0, "<list xmlns=\"urn:ietf:params:xml:ns:rlmi\" uri=\"%s\" version=\"%d\" fullState=\"true\">\n", mto, p->dialogver); //is mto correct?
+		ast_str_append(tmp, 0, "<list xmlns=\"urn:ietf:params:xml:ns:rlmi\" uri=\"%s\" version=\"%d\" fullState=\"true\">\r\n", mto, p->dialogver); //is mto correct?
 		AST_LIST_TRAVERSE(&p->rlist->resources, resource, entry) {
-			ast_str_append(tmp, 0, "<resource uri=\"sip:%s@%s\">\n", resource->exten, p->fromdomain);
-			ast_str_append(tmp, 0, "<name>%s</name>\n", resource->exten); //todohere name? username? add to conf?
-			ast_str_append(tmp, 0, "<instance id=\"%08lx\" state=\"active\" cid=\"%s@%s\"/>\n", ast_random(), resource->contentid, p->fromdomain); //todohere random has to go away
-			ast_str_append(tmp, 0, "</resource>\n");
-		}
-		ast_str_append(tmp, 0, "</list>\n");
+			ast_str_append(tmp, 0, "<resource uri=\"sip:%s@%s\">", resource->exten, p->fromdomain);
+			ast_str_append(tmp, 0, "<name>%s</name>", resource->exten); //todohere name? username? add to conf?
+			ast_str_append(tmp, 0, "<instance id=\"%08lx\" state=\"active\" cid=\"%s@%s\"/>", ast_random(), resource->contentid, p->fromdomain); //todohere random has to go away
+			ast_str_append(tmp, 0, "</resource>\r\n");
+		}
+		ast_str_append(tmp, 0, "</list>\r\n");
 		ast_log(LOG_NOTICE, "IN NOTIFY RLMI, mfrom:%s, mto:%s p->domain:%s \n", mfrom, mto, p->fromdomain);
 		break;
 	case CPIM_PIDF_XML:
@@ -10607,8 +10607,8 @@
 		ast_str_append(tmp, 0, "</tuple>\n</presence>\n");
 		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, "<?xml version=\"1.0\"?>");
+		ast_str_append(tmp, 0, "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"%d\" state=\"%s\" entity=\"%s\">", p->dialogver, full ? "full" : "partial", mto);
 		if ((state & AST_EXTENSION_RINGING) && sip_cfg.notifyringing) {
 			const char *local_display = exten;
 			char *local_target = mto;
@@ -10645,15 +10645,17 @@
 					"</local>\n",
 					exten, p->callid, local_display, local_target, local_target, mto, mto);
 		} else {
-			ast_str_append(tmp, 0, "<dialog id=\"%s\">\n", 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"
-			                                "<param pname=\"+sip.rendering\" pvalue=\"no\"/>\n"
-			                                "</target>\n</local>\n", mto);
-		}
-		ast_str_append(tmp, 0, "</dialog>\n</dialog-info>\n");
+			ast_str_append(tmp, 0, "<dialog id=\"%s\">", exten);
+		}
+		ast_str_append(tmp, 0, "<state>%s</state>\r\n", statestring);
+		if (state == AST_EXTENSION_ONHOLD) { //todohere, this seems weird
+				ast_str_append(tmp, 0, "<local>\n<target uri=\"%s\">\n"
+			                                    "<param pname=\"+sip.rendering\" pvalue=\"no\"/>\n"
+			                                    "</target>\n</local>\n", mto);
+		} else {
+			ast_str_append(tmp, 0, "<local><identity display=\"%s\">sip:%s</identity></local>\r\n\r\n", mto, mto);
+		}
+		ast_str_append(tmp, 0, "</dialog>\r\n</dialog-info>\r\n");
 		break;
 	case NONE:
 	default:
@@ -10665,7 +10667,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 *tmp2 = ast_str_alloca(256);
+	struct ast_str *tmp2 = ast_str_alloca(1500);
 	char from[256], to[256];
 	char *c, *mfrom, *mto;
 	struct sip_request req;
@@ -10732,35 +10734,38 @@
 	case DIALOG_RLMI_XML:
 		rlist = p->rlist;
 		if(rlist) {
+			struct ast_str *new_mto = ast_str_alloca(256);
 			add_header(&req, "Require", "eventlist");
 			/* since multipart/related is involved, boundary and start must be added to 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
+			ast_str_append(&tmp2, 0, "multipart/related;boundary=%s;type=%s", boundary, subscriptiontype->mediatype);
 			add_header(&req, "Content-Type", ast_str_buffer(tmp2));
+
+			/* building the RLMI portion */
+			ast_str_reset(tmp2);
+			state_notify_build(state, full, p->exten, p->context, &tmp2, p, p->subscribed, mfrom, mto);
 
 			/* 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 */
 			ast_str_append(&tmp, 0, "--%s\r\n", boundary);
-			ast_str_append(&tmp, 0, "Content-Transfer-Encoding: binary\r\n");
-			ast_str_append(&tmp, 0, "Content-ID: <%s@%s>\r\n", rlist->contentid, p->fromdomain);
-			ast_str_append(&tmp, 0, "Content-Type: %s; charset=\"UTF-8\"\r\n\r\n", subscriptiontype->mediatype);
-
-			/* building the RLMI portion */
-			state_notify_build(state, full, p->exten, p->context, &tmp, p, p->subscribed, mfrom, mto);
+			ast_str_append(&tmp, 0, "Content-Type: %s;\r\n", subscriptiontype->mediatype);
+			ast_str_append(&tmp, 0, "Content-Length:%d\r\n", (int)tmp2->used);
+			ast_str_append(&tmp, 0, "Content-ID: <%s@%s>\r\n\r\n", rlist->contentid, p->fromdomain);
+			ast_str_append(&tmp, 0, "%s", ast_str_buffer(tmp2));
 
 			/* building the other part of the multipart/related RLMI */
 			subscriptiontype = find_subscription_type(p->multipart_subscribed);
 			AST_LIST_TRAVERSE(&rlist->resources, resource, entry) {
-				ast_str_append(&tmp, 0, "\r\n--%s\r\n", boundary);
-				ast_str_append(&tmp, 0, "Content-Transfer-Encoding: binary\r\n");
-				ast_str_append(&tmp, 0, "Content-ID: <%s@%s>\r\n", resource->contentid, p->fromdomain);
-				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
 				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_reset(new_mto);
+				ast_str_append(&new_mto, 0, "%s@%s", resource->exten, p->fromdomain);
+				state_notify_build(resource->laststate, full, resource->exten, rlist->context, &tmp2, p, p->multipart_subscribed, mfrom, ast_str_buffer(new_mto));
+
+				ast_str_append(&tmp, 0, "--%s\r\n", boundary);
+				ast_str_append(&tmp, 0, "Content-Type: %s\r\n", subscriptiontype->mediatype);
+				ast_str_append(&tmp, 0, "Content-Length:%d\r\n", (int)tmp2->used);
+				ast_str_append(&tmp, 0, "Content-ID: <%s@%s>\r\n\r\n", resource->contentid, p->fromdomain);
+				ast_str_append(&tmp, 0, "%s", ast_str_buffer(tmp2));
 			}
 			ast_str_append(&tmp, 0, "\r\n--%s", boundary);
 




More information about the asterisk-commits mailing list