Index: apps/app_dial.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_dial.c,v
retrieving revision 1.140
diff -u -r1.140 app_dial.c
--- apps/app_dial.c	11 Feb 2005 06:53:18 -0000	1.140
+++ apps/app_dial.c	14 Feb 2005 12:59:50 -0000
@@ -77,8 +77,8 @@
 "      'r' -- indicate ringing to the calling party, pass no audio until answered.\n"
 "      'm[(class)]' -- provide hold music to the calling party until answered (optionally\n"
 "                      with the specified class.\n"
-"      'M(x[^arg]) -- Executes the macro (x with ^ delim arg list) upon connect of the call.\n"
-"                     Also, the macro can set the MACRO_RESULT variable to do the following:\n"
+"      'M(x[^arg])' -- Executes the macro (x with ^ delim arg list) upon connect of the call.\n"
+"                      Also, the macro can set the MACRO_RESULT variable to do the following:\n"
 "                     -- ABORT - Hangup both legs of the call.\n"
 "                     -- CONGESTION - Behave as if line congestion was encountered.\n"
 "                     -- BUSY - Behave as if a busy signal was encountered. (n+101)\n"
@@ -105,6 +105,13 @@
 "             * LIMIT_WARNING_FILE        File to play as warning if 'y' is defined.\n"
 "                        'timeleft' is a special sound macro to auto-say the time \n"
 "                        left and is the default.\n\n"
+"      'X(x)' -- Set Transfer (xfer) Capability x on PRI-Channels. Where x may be:\n"
+"             *  0 --> SPEECH\n"
+"             *  8 --> DIGITAL\n"
+"             *  9 --> RESTRICTED_DIGITAL\n"
+"             * 16 --> 3K1AUDIO\n"
+"             * 17 --> DIGITAL_W_TONES\n"
+"             * 24 --> VIDEO\n"
 "  In addition to transferring the call, a call may be parked and then picked\n"
 "up by another user.\n"
 "  The optional URL will be sent to the called party if the channel supports it.\n"
@@ -605,6 +612,7 @@
 	char *l;
 	char *url=NULL; /* JDG */
 	unsigned int calldurationlimit=0;
+	int transfercapability=-1;
 	char *cdl;
 	time_t now;
 	struct ast_bridge_config config;
@@ -684,6 +692,13 @@
 				ast_verbose(VERBOSE_PREFIX_3 "Setting call duration limit to %i seconds.\n",calldurationlimit);			
 		} 
 
+		/* Extract Transfer Capabilty */
+		if ((cdl = strstr(transfer, "X("))) {
+			transfercapability=(atoi(cdl+2) & 0x1f);
+			if (option_verbose > 2)
+				ast_verbose(VERBOSE_PREFIX_3 "Setting transfer capability to %i.\n", transfercapability);			
+		} 
+
 		/* DTMF SCRIPT*/
 		if ((sdtmfptr = strstr(transfer, "D("))) {
 			strncpy(sdtmfdata, sdtmfptr + 2, sizeof(sdtmfdata) - 1);
@@ -1006,8 +1021,15 @@
 		tmp->chan->cid.cid_tns = chan->cid.cid_tns;
 		/* Presense of ADSI CPE on outgoing channel follows ours */
 		tmp->chan->adsicpe = chan->adsicpe;
-		/* pass the digital flag */
+
+		/* Pass the digital flag */
 		ast_copy_flags(tmp->chan, chan, AST_FLAG_DIGITAL);
+		if (transfercapability >= 0)
+			/* Set the transfer capability */
+			tmp->chan->transfercapability = (unsigned short)transfercapability;
+		else
+			/* Pass the transfer capability */
+			tmp->chan->transfercapability = chan->transfercapability;
 
 		/* If we have an outbound group, set this peer channel to it */
 		if (outbound_group)
Index: channels/chan_zap.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v
retrieving revision 1.408
diff -u -r1.408 chan_zap.c
--- channels/chan_zap.c	10 Feb 2005 17:40:06 -0000	1.408
+++ channels/chan_zap.c	14 Feb 2005 12:59:55 -0000
@@ -1067,6 +1067,28 @@
 	}
 }
 
+#ifdef ZAPATA_PRI
+static char *transfercapability2str(int transfercapability)
+{
+	switch(transfercapability) {
+	case PRI_TRANS_CAP_SPEECH:
+		return "SPEECH";
+	case PRI_TRANS_CAP_DIGITAL:
+		return "DIGITAL";
+	case PRI_TRANS_CAP_RESTRICTED_DIGITAL:
+		return "RESTRICTED_DIGITAL";
+	case PRI_TRANS_CAP_3_1K_AUDIO:
+		return "3K1AUDIO";
+	case PRI_TRANS_CAP_DIGITAL_W_TONES:
+		return "DIGITAL_W_TONES";
+	case PRI_TRANS_CAP_VIDEO:
+		return "VIDEO";
+	default:
+		return "UNKNOWN";
+	}
+}
+#endif
+
 static int conf_add(struct zt_pvt *p, struct zt_subchannel *c, int index, int slavechannel)
 {
 	/* If the conference already exists, and we're already in it
@@ -1816,12 +1838,14 @@
 				ast_log(LOG_DEBUG, "I'm being setup with no bearer right now...\n");
 			pri_set_crv(p->pri->pri, p->call, p->channel, 0);
 		}
-		p->digital = ast_test_flag(ast,AST_FLAG_DIGITAL);
 		pri_sr_set_channel(sr, p->bearer ? PVT_TO_CHANNEL(p->bearer) : PVT_TO_CHANNEL(p), 
 								p->pri->nodetype == PRI_NETWORK ? 0 : 1, 1);
-		pri_sr_set_bearer(sr, p->digital ? PRI_TRANS_CAP_DIGITAL : PRI_TRANS_CAP_SPEECH, 
+		p->digital = ast_test_flag(ast,AST_FLAG_DIGITAL);
+		pri_sr_set_bearer(sr, p->digital ? PRI_TRANS_CAP_DIGITAL : ast->transfercapability, 
 					(p->digital ? -1 : 
 						((p->law == ZT_LAW_ALAW) ? PRI_LAYER_1_ALAW : PRI_LAYER_1_ULAW)));
+		if (option_verbose > 2)
+			ast_verbose(VERBOSE_PREFIX_3 "Requested transfer capability: 0x%.2x - %s\n", ast->transfercapability, transfercapability2str(ast->transfercapability));
 		pri_sr_set_called(sr, c + p->stripmsd, p->pri->dialplan - 1,  s ? 1 : 0);
 		pri_sr_set_caller(sr, l, n, p->pri->localdialplan - 1, 
 					l ? (p->use_callingpres ? ast->cid.cid_pres : PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN) : 
@@ -3909,7 +3933,7 @@
 	return f;
 }
 
-struct ast_frame  *zt_read(struct ast_channel *ast)
+struct ast_frame *zt_read(struct ast_channel *ast)
 {
 	struct zt_pvt *p = ast->pvt->pvt;
 	int res;
@@ -4508,34 +4532,6 @@
 	return res;
 }
 
-#ifdef ZAPATA_PRI
-static void set_calltype(struct ast_channel *chan, int ctype)
-{
-	char *s = "UNKNOWN";
-	switch(ctype) {
-	case PRI_TRANS_CAP_SPEECH:
-		s = "SPEECH";
-		break;
-	case PRI_TRANS_CAP_DIGITAL:
-		s = "DIGITAL";
-		break;
-	case PRI_TRANS_CAP_RESTRICTED_DIGITAL:
-		s = "RESTRICTED_DIGITAL";
-		break;
-	case PRI_TRANS_CAP_3_1K_AUDIO:
-		s = "31KAUDIO";
-		break;
-	case PRI_TRANS_CAP_7K_AUDIO:
-		s = "7KAUDIO";
-		break;
-	case PRI_TRANS_CAP_VIDEO:
-		s = "VIDEO";
-		break;
-	}
-	pbx_builtin_setvar_helper(chan, "CALLTYPE", s);
-}
-#endif
-
 static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int index, int law, int ctype)
 {
 	struct ast_channel *tmp;
@@ -4543,6 +4539,9 @@
 	int res;
 	int x,y;
 	int features;
+#ifdef ZAPATA_PRI
+	char transfercapabilitynumstr[5];
+#endif
 	ZT_PARAMS ps;
 	if (i->subs[index].owner) {
 		ast_log(LOG_WARNING, "Channel %d already has a %s call\n", i->channel,subnames[index]);
@@ -4679,14 +4678,17 @@
 		tmp->cid.cid_pres = i->callingpres;
 		tmp->cid.cid_ton = i->cid_ton;
 #ifdef ZAPATA_PRI
-		set_calltype(tmp, ctype);
-		/* Assume calls are not idle calls unless we're told differently */
-		i->isidlecall = 0;
-		i->alreadyhungup = 0;
+		tmp->transfercapability = ctype;
+		pbx_builtin_setvar_helper(tmp, "CALLTYPE", transfercapability2str(ctype));
+		snprintf(transfercapabilitynumstr, sizeof(transfercapabilitynumstr)-1, "%d", ctype);
+		pbx_builtin_setvar_helper(tmp, "TRANSFERCAPABILITY", transfercapabilitynumstr);
 		if (ctype & PRI_TRANS_CAP_DIGITAL) {
 			i->digital = 1;
 			ast_set_flag(tmp, AST_FLAG_DIGITAL);
 		}
+		/* Assume calls are not idle calls unless we're told differently */
+		i->isidlecall = 0;
+		i->alreadyhungup = 0;
 #endif
 		/* clear the fake event in case we posted one before we had ast_chanenl */
 		i->fake_event = 0;
@@ -10101,7 +10103,7 @@
 	ast_manager_register( "ZapDialOffhook", 0, action_zapdialoffhook, "Dial over Zap channel while offhook" );
     ast_manager_register( "ZapDNDon", 0, action_zapdndon, "Toggle Zap channel Do Not Disturb status ON" );
     ast_manager_register( "ZapDNDoff", 0, action_zapdndoff, "Toggle Zap channel Do Not Disturb status OFF" );
-	ast_manager_register("ZapShowChannels", 0, action_zapshowchannels, "Show status zapata channels");
+	ast_manager_register( "ZapShowChannels", 0, action_zapshowchannels, "Show status zapata channels");
 
 	return res;
 }
Index: include/asterisk/channel.h
===================================================================
RCS file: /usr/cvsroot/asterisk/include/asterisk/channel.h,v
retrieving revision 1.74
diff -u -r1.74 channel.h
--- include/asterisk/channel.h	21 Jan 2005 07:06:25 -0000	1.74
+++ include/asterisk/channel.h	14 Feb 2005 12:59:55 -0000
@@ -219,6 +219,9 @@
 	/*! channel flags of AST_FLAG_ type */
 	unsigned int flags;
 	
+	/* ISDN Transfer Capability - AST_FLAG_DIGITAL is simply not enough */
+	unsigned short transfercapability;
+	
 	/*! For easy linking */
 	struct ast_channel *next;
 