[asterisk-commits] rmudgett: branch group/issue8824 r143886 - in /team/group/issue8824/channels:...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 22 10:20:16 CDT 2008


Author: rmudgett
Date: Mon Sep 22 10:20:15 2008
New Revision: 143886

URL: http://svn.digium.com/view/asterisk?view=rev&rev=143886
Log:
*  Added preliminary name support for displaying a connected line
name with the CONNECT message display ie.

channels/chan_misdn.c
*  Fixed misdn_call() to now get the caller id information from the
connected line.
*  Made cb_events(EVENT_CONNECT) always queue the connected line
 update information.  The private connected line transfer is
no longer necessary or a good thing.
*  Some optimizations dealing with the chan_list channel origination
flag.
*  Made misdn_update_connected_line() update the correct endpoint id
information.


Modified:
    team/group/issue8824/channels/chan_misdn.c
    team/group/issue8824/channels/misdn/isdn_lib.c
    team/group/issue8824/channels/misdn/isdn_lib.h

Modified: team/group/issue8824/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/chan_misdn.c?view=diff&rev=143886&r1=143885&r2=143886
==============================================================================
--- team/group/issue8824/channels/chan_misdn.c (original)
+++ team/group/issue8824/channels/chan_misdn.c Mon Sep 22 10:20:15 2008
@@ -2522,7 +2522,7 @@
 };
 
 /*! \brief Updates caller ID information from config */
-static int update_config(struct chan_list *ch, int orig) 
+static void update_config(struct chan_list *ch)
 {
 	struct ast_channel *ast;
 	struct misdn_bchannel *bc;
@@ -2531,14 +2531,14 @@
 
 	if (!ch) {
 		ast_log(LOG_WARNING, "Cannot configure without chanlist\n");
-		return -1;
+		return;
 	}
 
 	ast = ch->ast;
 	bc = ch->bc;
 	if (! ast || ! bc) {
 		ast_log(LOG_WARNING, "Cannot configure without ast || bc\n");
-		return -1;
+		return;
 	}
 
 	port = bc->port;
@@ -2574,8 +2574,6 @@
 		bc->caller.screening = screen;
 		bc->caller.presentation = pres;
 	}
-
-	return 0;
 }
 
 
@@ -2680,7 +2678,7 @@
 #endif
 
 
-static int read_config(struct chan_list *ch, int orig)
+static int read_config(struct chan_list *ch)
 {
 	struct ast_channel *ast;
 	struct misdn_bchannel *bc;
@@ -2771,7 +2769,7 @@
 	ast->pickupgroup = pg;
 	ast->callgroup = cg;
 	
-	if (orig == ORG_AST) {
+	if (ch->originator == ORG_AST) {
 		char callerid[BUFFERSIZE + 1];
 
 		/* ORIGINATOR Asterisk (outgoing call) */
@@ -2861,18 +2859,18 @@
 		ast_set_callerid(ast, bc->caller.number, NULL, bc->caller.number);
 
 		if (!ast_strlen_zero(bc->redirecting.from.number)) {
-			if (ast->cid.cid_rdnis) {
-				ast_free(ast->cid.cid_rdnis);
-			}
-			ast->cid.cid_rdnis = ast_strdup(bc->redirecting.from.number);
-
-			ast->redirecting.from.number_type =
+			struct ast_party_redirecting redirecting;
+
+			ast_party_redirecting_set_init(&redirecting, &ast->redirecting);
+			redirecting.from.number = bc->redirecting.from.number;
+			redirecting.from.number_type =
 				misdn_to_ast_ton(bc->redirecting.from.number_type)
 				| misdn_to_ast_plan(bc->redirecting.from.number_plan);
-			ast->redirecting.from.number_presentation =
+			redirecting.from.number_presentation =
 				misdn_to_ast_pres(bc->redirecting.from.presentation)
 				| misdn_to_ast_screen(bc->redirecting.from.screening);
-			ast->redirecting.reason = misdn_to_ast_reason(bc->redirecting.reason);
+			redirecting.reason = misdn_to_ast_reason(bc->redirecting.reason);
+			ast_set_redirecting(ast, &redirecting);
 		}
 	
 		misdn_cfg_get(bc->port, MISDN_CFG_OVERLAP_DIAL, &ch->overlap_dial, sizeof(ch->overlap_dial));
@@ -2911,17 +2909,30 @@
  *
  * \param ast Current Asterisk channel
  * \param bc Associated B channel
+ * \param originator Who originally created this channel. ORG_AST or ORG_MISDN
  *
  * \return Nothing
  */
-static void misdn_update_connectedline(struct ast_channel *ast, struct misdn_bchannel *bc)
-{
-	ast_copy_string(bc->connected.number, S_OR(ast->connected.id.number, ""), sizeof(bc->connected.number));
-	bc->connected.presentation = ast_to_misdn_pres(ast->connected.id.number_presentation);
-	bc->connected.screening = ast_to_misdn_screen(ast->connected.id.number_presentation);
-	bc->connected.number_type = ast_to_misdn_ton(ast->connected.id.number_type);
-	bc->connected.number_plan = ast_to_misdn_plan(ast->connected.id.number_type);
-}	/* end misdn_update_connectedline() */
+static void misdn_update_connected_line(struct ast_channel *ast, struct misdn_bchannel *bc, int originator)
+{
+	if (originator == ORG_MISDN) {
+		/* ORIGINATOR MISDN (incoming call) */
+		ast_copy_string(bc->connected.name, S_OR(ast->connected.id.name, ""), sizeof(bc->connected.name));
+		ast_copy_string(bc->connected.number, S_OR(ast->connected.id.number, ""), sizeof(bc->connected.number));
+		bc->connected.presentation = ast_to_misdn_pres(ast->connected.id.number_presentation);
+		bc->connected.screening = ast_to_misdn_screen(ast->connected.id.number_presentation);
+		bc->connected.number_type = ast_to_misdn_ton(ast->connected.id.number_type);
+		bc->connected.number_plan = ast_to_misdn_plan(ast->connected.id.number_type);
+	} else {
+		/* ORIGINATOR Asterisk (outgoing call) */
+		ast_copy_string(bc->caller.name, S_OR(ast->connected.id.name, ""), sizeof(bc->caller.name));
+		ast_copy_string(bc->caller.number, S_OR(ast->connected.id.number, ""), sizeof(bc->caller.number));
+		bc->caller.presentation = ast_to_misdn_pres(ast->connected.id.number_presentation);
+		bc->caller.screening = ast_to_misdn_screen(ast->connected.id.number_presentation);
+		bc->caller.number_type = ast_to_misdn_ton(ast->connected.id.number_type);
+		bc->caller.number_plan = ast_to_misdn_plan(ast->connected.id.number_type);
+	}
+}	/* end misdn_update_connected_line() */
 
 
 
@@ -2938,6 +2949,7 @@
  */
 static void misdn_copy_redirecting_from_ast(struct misdn_bchannel *bc, struct ast_channel *ast)
 {
+	ast_copy_string(bc->redirecting.from.name, S_OR(ast->redirecting.from.name, ""), sizeof(bc->redirecting.from.name));
 	ast_copy_string(bc->redirecting.from.number, S_OR(ast->cid.cid_rdnis, ""), sizeof(bc->redirecting.from.number));
 	bc->redirecting.from.presentation = ast_to_misdn_pres(ast->redirecting.from.number_presentation);
 	bc->redirecting.from.screening = ast_to_misdn_screen(ast->redirecting.from.number_presentation);
@@ -3016,14 +3028,13 @@
 	chan_misdn_log(2, port, " --> * dad:%s tech:%s ctx:%s\n", ast->exten, ast->name, ast->context);
 	
 	chan_misdn_log(3, port, " --> * adding2newbc ext %s\n", ast->exten);
-	if (ast->exten) {
-		ast_copy_string(ast->exten, ext, sizeof(ast->exten));
-		ast_copy_string(newbc->dialed.number, ext, sizeof(newbc->dialed.number));
-	}
-
-	chan_misdn_log(3, port, " --> * adding2newbc callerid %s\n", ast->cid.cid_num);
-	if (ast_strlen_zero(newbc->caller.number) && !ast_strlen_zero(ast->cid.cid_num)) {
-		ast_copy_string(newbc->caller.number, ast->cid.cid_num, sizeof(newbc->caller.number));
+	ast_copy_string(ast->exten, ext, sizeof(ast->exten));
+	ast_copy_string(newbc->dialed.number, ext, sizeof(newbc->dialed.number));
+
+	if (ast_strlen_zero(newbc->caller.number) && !ast_strlen_zero(ast->connected.id.number)) {
+		chan_misdn_log(3, port, " --> * adding2newbc callerid %s\n", ast->connected.id.number);
+		ast_copy_string(newbc->caller.number, ast->connected.id.number, sizeof(newbc->caller.number));
+		ast_copy_string(newbc->caller.name, S_OR(ast->connected.id.name, ""), sizeof(newbc->caller.name));
 	}
 
 	newbc->capability = ast->transfercapability;
@@ -3033,7 +3044,7 @@
 	}
 
 	/* update screening and presentation */ 
-	update_config(ch, ORG_AST);
+	update_config(ch);
 		
 	/* fill in some ies from channel dialplan variables */
 	import_ch(ast, newbc, ch);
@@ -3328,7 +3339,7 @@
 		break;
 	case AST_CONTROL_CONNECTED_LINE:
 		chan_misdn_log(1, p->bc->port, "* IND :\tconnected line update pid:%d\n", p->bc->pid);
-		misdn_update_connectedline(ast, p->bc);
+		misdn_update_connected_line(ast, p->bc, p->originator);
 		break;
 	case AST_CONTROL_REDIRECTING:
 		chan_misdn_log(1, p->bc->port, "* IND :\tredirecting info update pid:%d\n", p->bc->pid);
@@ -4151,7 +4162,7 @@
 	cl_queue_chan(&cl_te, cl) ;
 	
 	/* fill in the config into the objects */
-	read_config(cl, ORG_AST);
+	read_config(cl);
 
 	/* important */
 	cl->need_hangup = 0;
@@ -5058,7 +5069,6 @@
 		ch->bc = bc;
 		ch->l3id = bc->l3_id;
 		ch->addr = bc->addr;
-		ch->originator = ORG_MISDN;
 
 		chan = misdn_new(ch, AST_STATE_RESERVED, bc->dialed.number, bc->caller.number, AST_FORMAT_ALAW, bc->port, bc->channel);
 
@@ -5076,7 +5086,7 @@
 			pbx_builtin_setvar_helper(chan, "MAX_OVERFLOW", tmp);
 		}
 
-		read_config(ch, ORG_MISDN);
+		read_config(ch);
 
 		export_ch(chan, bc, ch);
 
@@ -5349,7 +5359,7 @@
 	break;
 	case EVENT_CONNECT:
 	{
-		struct ast_channel *bridged;
+		struct ast_party_connected_line connected;
 
 		/*we answer when we've got our very new L3 ID from the NT stack */
 		misdn_lib_send_event(bc, EVENT_CONNECT_ACKNOWLEDGE);
@@ -5357,28 +5367,17 @@
 		if (!ch->ast)
 			break;
 
-		bridged = ast_bridged_channel(ch->ast);
 		stop_indicate(ch);
 
-		if (bridged && !strcasecmp(bridged->tech->type, "mISDN")) {
-			struct chan_list *bridged_ch = MISDN_ASTERISK_TECH_PVT(bridged);
-
-			if (bridged_ch) {
-				chan_misdn_log(1, bc->port, " --> copying cpndialplan:%d and cad:%s to the A-Channel\n", bc->connected.number_type, bc->connected.number);
-				bridged_ch->bc->connected = bc->connected;
-			}
-		} else {
-			struct ast_party_connected_line connected;
-
-			ast_party_connected_line_init(&connected);
-			connected.id.number = bc->connected.number;
-			connected.id.number_type = misdn_to_ast_ton(bc->connected.number_type)
-				| misdn_to_ast_plan(bc->connected.number_plan);
-			connected.id.number_presentation = misdn_to_ast_pres(bc->connected.presentation)
-				| misdn_to_ast_screen(bc->connected.screening);
-			connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
-			ast_queue_connected_line_update(ch->ast, &connected);
-		}
+		/* Update the connected line information on the other channel */
+		ast_party_connected_line_init(&connected);
+		connected.id.number = bc->connected.number;
+		connected.id.number_type = misdn_to_ast_ton(bc->connected.number_type)
+			| misdn_to_ast_plan(bc->connected.number_plan);
+		connected.id.number_presentation = misdn_to_ast_pres(bc->connected.presentation)
+			| misdn_to_ast_screen(bc->connected.screening);
+		connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
+		ast_queue_connected_line_update(ch->ast, &connected);
 	
 		ch->l3id=bc->l3_id;
 		ch->addr=bc->addr;

Modified: team/group/issue8824/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/misdn/isdn_lib.c?view=diff&rev=143886&r1=143885&r2=143886
==============================================================================
--- team/group/issue8824/channels/misdn/isdn_lib.c (original)
+++ team/group/issue8824/channels/misdn/isdn_lib.c Mon Sep 22 10:20:15 2008
@@ -639,18 +639,21 @@
 	bc->caller.presentation = 0;	/* allowed */
 	bc->caller.number_plan = NUMPLAN_ISDN;
 	bc->caller.number_type = NUMTYPE_UNKNOWN;
+	bc->caller.name[0] = 0;
 	bc->caller.number[0] = 0;
 	bc->caller.subaddress[0] = 0;
 
 	bc->connected.presentation = 0;	/* allowed */
 	bc->connected.number_plan = NUMPLAN_ISDN;
 	bc->connected.number_type = NUMTYPE_UNKNOWN;
+	bc->connected.name[0] = 0;
 	bc->connected.number[0] = 0;
 	bc->connected.subaddress[0] = 0;
 
 	bc->redirecting.from.presentation = 0;	/* allowed */
 	bc->redirecting.from.number_plan = NUMPLAN_ISDN;
 	bc->redirecting.from.number_type = NUMTYPE_UNKNOWN;
+	bc->redirecting.from.name[0] = 0;
 	bc->redirecting.from.number[0] = 0;
 	bc->redirecting.from.subaddress[0] = 0;
 

Modified: team/group/issue8824/channels/misdn/isdn_lib.h
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/misdn/isdn_lib.h?view=diff&rev=143886&r1=143885&r2=143886
==============================================================================
--- team/group/issue8824/channels/misdn/isdn_lib.h (original)
+++ team/group/issue8824/channels/misdn/isdn_lib.h Mon Sep 22 10:20:15 2008
@@ -226,6 +226,9 @@
 /* Maximum phone number (address) length plus null terminator */
 #define MISDN_MAX_NUMBER_LEN		(31 + 1)
 
+/* Maximum name length plus null terminator (From ECMA-164) */
+#define MISDN_MAX_NAME_LEN			(50 + 1)
+
 /* Maximum subaddress length plus null terminator */
 #define MISDN_MAX_SUBADDRESS_LEN	(23 + 1)
 
@@ -249,6 +252,13 @@
 
 	/*! \brief Type-of-number numbering plan. */
 	enum mISDN_NUMBER_PLAN number_plan;
+
+	/*! \brief Subscriber Name
+	 * \note The name is currently obtained from Asterisk for
+	 * potential use in display ie's since basic ISDN does
+	 * not support names directly.
+	 */
+	char name[MISDN_MAX_NAME_LEN];
 
 	/*! \brief Phone number (Address) */
 	char number[MISDN_MAX_NUMBER_LEN];




More information about the asterisk-commits mailing list