[Asterisk-cvs] asterisk/channels chan_zap.c,1.154,1.155

martinp at lists.digium.com martinp at lists.digium.com
Wed Dec 17 17:47:42 CST 2003


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

Modified Files:
	chan_zap.c 
Log Message:
Add 'useincomingcalleridonzaptransfer' keyword to chan_zap so that if there is incoming call on fxs port and you flashhook and transfer that call (or do a threeway call) the incoming callerid will be presented.


Index: chan_zap.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v
retrieving revision 1.154
retrieving revision 1.155
diff -u -d -r1.154 -r1.155
--- chan_zap.c	11 Dec 2003 20:55:26 -0000	1.154
+++ chan_zap.c	17 Dec 2003 23:39:16 -0000	1.155
@@ -136,7 +136,7 @@
 static char musicclass[MAX_LANGUAGE] = "";
 
 static int use_callerid = 1;
-
+static int useincomingcalleridonzaptransfer = 0;
 static int cur_signalling = -1;
 
 static unsigned int cur_group = 0;
@@ -372,6 +372,7 @@
 	char musicclass[MAX_LANGUAGE];
 	char callerid[AST_MAX_EXTENSION];
 	char lastcallerid[AST_MAX_EXTENSION];
+	char *origcallerid;			/* malloced original callerid */
 	char callwaitcid[AST_MAX_EXTENSION];
 	char rdnis[AST_MAX_EXTENSION];
 	char dnid[AST_MAX_EXTENSION];
@@ -455,6 +456,7 @@
 	int resetting;
 	int prioffset;
 	int alreadyhungup;
+	int useincomingcalleridonzaptransfer;
 #ifdef PRI_EVENT_PROCEEDING
 	int proceeding;
 #endif
@@ -1664,7 +1666,11 @@
 	x = 0;
 	zt_confmute(p, 0);
 	restore_gains(p);
-	
+	if (p->origcallerid) {
+		strncpy(p->callerid, p->origcallerid, sizeof(p->callerid) - 1);
+		free(p->origcallerid);
+		p->origcallerid = NULL;
+	}	
 	if (p->dsp)
 		ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_DTMF | p->dtmfrelax);
 
@@ -3016,7 +3022,10 @@
 						if (p->subs[SUB_REAL].owner->bridge)
 								ast_moh_stop(p->subs[SUB_REAL].owner->bridge);
 					} else if (!p->subs[SUB_THREEWAY].owner) {
+						char callerid[256];
 						if (p->threewaycalling && !check_for_conference(p)) {
+							if (p->useincomingcalleridonzaptransfer && p->owner)
+								strncpy(callerid, p->owner->callerid, sizeof(callerid) - 1);
 							/* XXX This section needs much more error checking!!! XXX */
 							/* Start a 3-way call if feasible */
 							if ((ast->pbx) ||
@@ -3025,6 +3034,13 @@
 								if (!alloc_sub(p, SUB_THREEWAY)) {
 									/* Make new channel */
 									chan = zt_new(p, AST_STATE_RESERVED, 0, SUB_THREEWAY, 0, 0);
+									if (p->useincomingcalleridonzaptransfer) {
+										if (!p->origcallerid) {
+											p->origcallerid = malloc(strlen(p->callerid) + 1);
+											strncpy(p->origcallerid, p->callerid, strlen(p->callerid) + 1);
+										}
+										strncpy(p->callerid, callerid, sizeof(p->callerid) -1);
+									}
 									/* Swap things around between the three-way and real call */
 									swap_subs(p, SUB_THREEWAY, SUB_REAL);
 									/* Disable echo canceller for better dialing */
@@ -5303,6 +5319,7 @@
 		tmp->channel = channel;
 		tmp->stripmsd = stripmsd;
 		tmp->use_callerid = use_callerid;
+		tmp->useincomingcalleridonzaptransfer = useincomingcalleridonzaptransfer;
 		tmp->restrictcid = restrictcid;
 		tmp->use_callingpres = use_callingpres;
 		strncpy(tmp->accountcode, accountcode, sizeof(tmp->accountcode)-1);
@@ -7143,6 +7160,8 @@
 				strcpy(callerid,"");
 			else
 				strncpy(callerid, v->value, sizeof(callerid)-1);
+		} else if (!strcasecmp(v->name, "useincomingcalleridonzaptransfer")) {
+			useincomingcalleridonzaptransfer = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "restrictcid")) {
 			restrictcid = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "usecallingpres")) {




More information about the svn-commits mailing list