--- /usr/src/asterisk-1.4.28/channels/chan_sip.c 	2009-12-07 19:07:38.000000000 +0100
+++ /usr/src/asterisk-1.4.28/channels/chan_sip.c 	2011-01-28 10:59:17.000000000 +0100
@@ -7841,11 +7841,33 @@ static int transmit_state_notify(struct
 	case DIALOG_INFO_XML: /* SNOM subscribes in this format */
 		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);
-		else
+	 	struct sip_pvt *np = NULL;
+	        int found=0;
+		if ((state & AST_EXTENSION_RINGING) && global_notifyringing) {
+	        char *extenno;
+			if ((extenno=strstr(hint,"/")))
+				extenno++;
+				if (!ast_strlen_zero(extenno)) {
+					for (np = iflist; np; np = np->next) {
+						if  ((np) && (!strncasecmp(np->username, extenno, strlen(extenno)))) {
+							ast_build_string(&t, &maxbytes, "<dialog id=\"%s\" direction=\"recipient\">\n", p->exten);
+							ast_build_string(&t, &maxbytes, "<state>%s</state>\n", statestring);
+							if (!strstr(p->useragent, "Aastra")) {
+							ast_build_string(&t, &maxbytes, "<local><identity display=\"%s\">%s</identity><target uri=\"%s\"/></local>\n", p->exten, p->exten, mfrom);
+							ast_build_string(&t, &maxbytes, "<remote><identity display=\"%s\">sip:%s@%s</identity><target uri=\"sip:%s@%s\"/></remote>\n", np->fromname, np->fromuser, p->fromdomain, p->exten, p->fromdomain);
+							}
+							found=1;
+							break;
+							}
+						}
+						if (!found)
+							ast_build_string(&t, &maxbytes, "<dialog id=\"%s\" direction=\"recipient\">\n", p->exten);
+					} else 
+						ast_build_string(&t, &maxbytes, "<dialog id=\"%s\" direction=\"recipient\">\n", p->exten);
+		} else
 			ast_build_string(&t, &maxbytes, "<dialog id=\"%s\">\n", p->exten);
-		ast_build_string(&t, &maxbytes, "<state>%s</state>\n", statestring);
+		if (!found)
+			ast_build_string(&t, &maxbytes, "<state>%s</state>\n", statestring);
 		if (state == AST_EXTENSION_ONHOLD) {
 			ast_build_string(&t, &maxbytes, "<local>\n<target uri=\"%s\">\n"
 			                                "<param pname=\"+sip.rendering\" pvalue=\"no\"/>\n"

