[asterisk-commits] mmichelson: branch group/issue8824 r147636 - in /team/group/issue8824: apps/ ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Oct 8 15:10:20 CDT 2008


Author: mmichelson
Date: Wed Oct  8 15:10:20 2008
New Revision: 147636

URL: http://svn.digium.com/view/asterisk?view=rev&rev=147636
Log:
After seeing gareth's latest patch on issue 8824, I decided
that I really liked the formatting he used for the add_rpid
function, so I have adapted it to fit what is already in the
branch.

He also included a patch for app_directed_pickup.c, which is
being added here as well.

Thanks for the great work, gareth!


Modified:
    team/group/issue8824/apps/app_directed_pickup.c
    team/group/issue8824/channels/chan_sip.c

Modified: team/group/issue8824/apps/app_directed_pickup.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/apps/app_directed_pickup.c?view=diff&rev=147636&r1=147635&r2=147636
==============================================================================
--- team/group/issue8824/apps/app_directed_pickup.c (original)
+++ team/group/issue8824/apps/app_directed_pickup.c Wed Oct  8 15:10:20 2008
@@ -40,6 +40,7 @@
 #include "asterisk/lock.h"
 #include "asterisk/app.h"
 #include "asterisk/features.h"
+#include "asterisk/callerid.h"
 
 #define PICKUPMARK "PICKUPMARK"
 
@@ -66,8 +67,17 @@
 static int pickup_do(struct ast_channel *chan, struct ast_channel *target)
 {
 	int res = 0;
+	struct ast_party_connected_line connected_caller;
 
 	ast_debug(1, "Call pickup on '%s' by '%s'\n", target->name, chan->name);
+
+	connected_caller = target->connected;
+	connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
+	ast_connected_line_update(chan, &connected_caller);
+
+	ast_party_connected_line_collect_caller(&connected_caller, &chan->cid);
+	connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
+	ast_queue_connected_line_update(chan, &connected_caller);
 
 	if ((res = ast_answer(chan))) {
 		ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan->name);

Modified: team/group/issue8824/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/chan_sip.c?view=diff&rev=147636&r1=147635&r2=147636
==============================================================================
--- team/group/issue8824/channels/chan_sip.c (original)
+++ team/group/issue8824/channels/chan_sip.c Wed Oct  8 15:10:20 2008
@@ -8126,7 +8126,11 @@
 	const char *fromdomain;
 	const char *privacy = NULL;
 	const char *screen = NULL;
-	int private = 0;
+	const char *anonymous_string = "\"Anonymous\" <anonymous at anonymous.invalid>"; 
+
+	if (!ast_test_flag(&p->flags[0], SIP_SENDRPID)) {
+		return 0;
+	}
 
 	if (p->owner && p->owner->connected.id.number)
 		lid_num = p->owner->connected.id.number;
@@ -8140,56 +8144,53 @@
 		lid_name = lid_num;
 	fromdomain = S_OR(p->fromdomain, ast_inet_ntoa(p->ourip.sin_addr));
 
-	snprintf(tmp, sizeof(tmp), "\"%s\" <sip:%s@%s>", lid_name, lid_num, fromdomain);
-	if (ast_test_flag(&p->flags[1], SIP_SENDRPID_RPID)) {
-		snprintf(tmp + strlen(tmp), sizeof(tmp) - strlen(tmp), ";party=%s", ast_test_flag(&p->flags[0], SIP_OUTGOING) ? "calling" : "called");
-	}
-
-	switch (lid_pres) {
-	case AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED:
-	case AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN:
-		privacy = "off";
-		screen = "no";
-		break;
-	case AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN:
-	case AST_PRES_ALLOWED_NETWORK_NUMBER:
-		privacy = "off";
-		screen = "yes";
-		break;
-	case AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED:
-	case AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN:
-		privacy = "full";
-		screen = "no";
-		private = 1;
-		break;
-	case AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN:
-	case AST_PRES_PROHIB_NETWORK_NUMBER:
-		privacy = "full";
-		screen = "yes";
-		private = 1;
-		break;
-	case AST_PRES_NUMBER_NOT_AVAILABLE:
-		break;
-	default:
+	if (ast_test_flag(&p->flags[0], SIP_SENDRPID_PAI)) {
 		if ((lid_pres & AST_PRES_RESTRICTION) != AST_PRES_ALLOWED) {
-			privacy = "full";
-			private = 1;
-		}
-		else
-			privacy = "off";
-		screen = "no";
-		break;
-	}
-
-	if (ast_test_flag(&p->flags[1], SIP_SENDRPID_RPID) && !ast_strlen_zero(privacy) && !ast_strlen_zero(screen))
-		snprintf(tmp + strlen(tmp), sizeof(tmp) - strlen(tmp), ";privacy=%s;screen=%s", privacy, screen);
-
-	if (ast_test_flag(&p->flags[0], SIP_SENDRPID_RPID)) {
-		add_header(req, "Remote-Party-ID", tmp);
-	} else if (!private) {
+			snprintf(tmp, sizeof(tmp), "%s", anonymous_string); 
+		} else {
+			snprintf(tmp, sizeof(tmp), "\"%s\" <sip:%s@%s>", lid_name, lid_num, fromdomain);
+		}
 		add_header(req, "P-Asserted-Identity", tmp);
 	} else {
-		add_header(req, "P-Asserted-Identity", "<anonymous at anonymous.invalid>");
+		snprintf(tmp, sizeof(tmp), "\"%s\" <sip:%s@%s>;party=%s", lid_name, lid_num, fromdomain, ast_test_flag(&p->flags[0], SIP_OUTGOING) ? "calling" : "called");
+
+		switch (lid_pres) {
+		case AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED:
+		case AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN:
+			privacy = "off";
+			screen = "no";
+			break;
+		case AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN:
+		case AST_PRES_ALLOWED_NETWORK_NUMBER:
+			privacy = "off";
+			screen = "yes";
+			break;
+		case AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED:
+		case AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN:
+			privacy = "full";
+			screen = "no";
+			break;
+		case AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN:
+		case AST_PRES_PROHIB_NETWORK_NUMBER:
+			privacy = "full";
+			screen = "yes";
+			break;
+		case AST_PRES_NUMBER_NOT_AVAILABLE:
+			break;
+		default:
+			if ((lid_pres & AST_PRES_RESTRICTION) != AST_PRES_ALLOWED) {
+				privacy = "full";
+			}
+			else
+				privacy = "off";
+			screen = "no";
+			break;
+		}
+
+		if (!ast_strlen_zero(privacy) && !ast_strlen_zero(screen))
+			snprintf(tmp + strlen(tmp), sizeof(tmp) - strlen(tmp), ";privacy=%s;screen=%s", privacy, screen);
+
+		add_header(req, "Remote-Party-ID", tmp);
 	}
 	return 0;
 }




More information about the asterisk-commits mailing list