[Asterisk-cvs] asterisk/channels chan_vpb.c,1.60,1.61

bkramer at lists.digium.com bkramer at lists.digium.com
Mon Jan 17 21:21:26 CST 2005


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv31495

Modified Files:
	chan_vpb.c 
Log Message:
/ patched for bug 3350
/ also cleaned up the caller ID stuff a bit
/ should now also forward caller ID from a trunk


Index: chan_vpb.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_vpb.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- chan_vpb.c	17 Jan 2005 03:45:18 -0000	1.60
+++ chan_vpb.c	18 Jan 2005 03:24:41 -0000	1.61
@@ -240,6 +240,7 @@
 	char ext[AST_MAX_EXTENSION];		/* DTMF buffer for the ext[ens] */
 	char language[MAX_LANGUAGE];		/* language being used */
 	char callerid[AST_MAX_EXTENSION];	/* CallerId used for directly connected phone */
+	int  callerid_type;			/* Caller ID type: 0=>none 1=>vpb 2=>AstV23 3=>AstBell */
 
 	int dtmf_caller_pos;			/* DTMF CallerID detection (Brazil)*/
 
@@ -558,6 +559,7 @@
 				ast_set_callerid(owner, cli_struct->cldn, cli_struct->cn, cli_struct->cldn);
 				if (option_verbose>3) 
 					ast_verbose(VERBOSE_PREFIX_4 "CID record - got [%s] [%s]\n",owner->cid.cid_num,owner->cid.cid_name );
+				snprintf(p->callerid,sizeof(p->callerid)-1,"%s %s",cli_struct->cldn,cli_struct->cn);
 			}
 			else {
 				ast_log(LOG_ERROR,"CID record - No caller id avalable on %s \n", p->dev);
@@ -565,7 +567,7 @@
 
 		} else {
 			ast_log(LOG_ERROR, "CID record - Failed to decode caller id on %s - %s\n", p->dev, vpb_strerror(rc) );
-			strncpy(callerid,"unknown", sizeof(callerid) - 1);
+			strncpy(p->callerid,"unknown", sizeof(p->callerid) - 1);
 		}
 		delete cli_struct;
 
@@ -587,24 +589,23 @@
 	void * ws;
 	char * file="cidsams.wav";
 
-	if(!strcasecmp(p->callerid, "on")) {
+	if(p->callerid_type == 1) {
 	if (option_verbose>3) ast_verbose(VERBOSE_PREFIX_4 "Collected caller ID already\n");
 		return;
 	}
-	else if(!strcasecmp(p->callerid, "v23")) {
+	else if(p->callerid_type == 2 ) {
 		which_cid=CID_SIG_V23;
-	if (option_verbose>3) ast_verbose(VERBOSE_PREFIX_4 "Collecting Caller ID v23[%s/%d]...\n",p->callerid,which_cid);
+	if (option_verbose>3) ast_verbose(VERBOSE_PREFIX_4 "Collecting Caller ID v23...\n");
 	}
-	else if(!strcasecmp(p->callerid, "bell")) {
+	else if(p->callerid_type == 3) {
 		which_cid=CID_SIG_BELL;
-	if (option_verbose>3) ast_verbose(VERBOSE_PREFIX_4 "Collecting Caller ID bell[%s/%d]...\n",p->callerid,which_cid);
+	if (option_verbose>3) ast_verbose(VERBOSE_PREFIX_4 "Collecting Caller ID bell...\n");
 	}
 	else {
 		if (option_verbose>3) 
 			ast_verbose(VERBOSE_PREFIX_4 "Caller ID disabled\n");
 		return;
 	}
-	if (option_verbose>3) ast_verbose(VERBOSE_PREFIX_4 "Collecting Caller ID type[%s/%d]...\n",p->callerid,which_cid);
 /*	vpb_sleep(RING_SKIP); */
 /*	vpb_record_get_gain(p->handle, &old_gain); */
 	cs = callerid_new(which_cid);
@@ -657,9 +658,14 @@
 	if (number && !ast_strlen_zero(number)) {
 		owner->cid.cid_num = strdup(number);
 		owner->cid.cid_ani = strdup(number);
+		if (name && !ast_strlen_zero(name)){
+			owner->cid.cid_name = strdup(name);
+			snprintf(p->callerid,(sizeof(p->callerid)-1),"%s %s",number,name);
+		}
+		else {
+			snprintf(p->callerid,(sizeof(p->callerid)-1),"%s",number);
+		}
 	}
-	if (name && !ast_strlen_zero(name))
-		owner->cid.cid_name = strdup(name);
 														     
 	if (cs)
 		callerid_free(cs);
@@ -943,7 +949,7 @@
 		case VPB_RING:
 			if (p->mode == MODE_FXO) /* FXO port ring, start * */ {
 				vpb_new(p, AST_STATE_RING, p->context);
-				if(!strcasecmp(p->callerid, "on")) {
+				if(p->callerid_type == 1) {
 					if (option_verbose>3) 
 						ast_verbose(VERBOSE_PREFIX_4 "Using VPB Caller ID\n");
 					get_callerid(p);	/* Australian Caller ID only between 1st and 2nd ring  */
@@ -1320,9 +1326,23 @@
 	strncpy(tmp->language, language, sizeof(tmp->language) - 1);
 	strncpy(tmp->context, context, sizeof(tmp->context) - 1);
 
+	tmp->callerid_type=0;
 	if(callerid) { 
-		strncpy(tmp->callerid, callerid, sizeof(tmp->callerid) - 1);
-		free(callerid);
+		if (strcasecmp(callerid,"on")==0){
+			tmp->callerid_type =1;
+			strncpy(tmp->callerid, "unknown", sizeof(tmp->callerid) - 1);
+		}
+		else if (strcasecmp(callerid,"v23")==0){
+			tmp->callerid_type =2;
+			strncpy(tmp->callerid, "unknown", sizeof(tmp->callerid) - 1);
+		}
+		else if (strcasecmp(callerid,"bell")==0){
+			tmp->callerid_type =3;
+			strncpy(tmp->callerid, "unknown", sizeof(tmp->callerid) - 1);
+		}
+		else {
+			strncpy(tmp->callerid, callerid, sizeof(tmp->callerid) - 1);
+		}
 	} else {
 		strncpy(tmp->callerid, "unknown", sizeof(tmp->callerid) - 1);
 	}
@@ -2234,6 +2254,8 @@
 static struct ast_channel *vpb_new(struct vpb_pvt *me, int state, char *context)
 {
 	struct ast_channel *tmp; 
+	char cid_num[256];
+	char cid_name[256];
 
 	if (me->owner) {
 	    ast_log(LOG_WARNING, "Called vpb_new on owned channel (%s) ?!\n", me->dev);
@@ -2255,8 +2277,13 @@
 		tmp->pvt->rawreadformat = AST_FORMAT_SLINEAR;
 		tmp->pvt->rawwriteformat =  AST_FORMAT_SLINEAR;
 		ast_setstate(tmp, state);
-		if (state == AST_STATE_RING)
+		if (state == AST_STATE_RING) {
 			tmp->rings = 1;
+			cid_name[0] = '\0';
+			cid_num[0] = '\0';
+			ast_callerid_split(me->callerid, cid_name, sizeof(cid_name), cid_num, sizeof(cid_num));
+			ast_set_callerid(tmp, cid_num, cid_name, cid_num);
+		}
 		tmp->pvt->pvt = me;
 		/* set call backs */
 		tmp->pvt->send_digit = vpb_digit;




More information about the svn-commits mailing list