mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 18:55:19 +00:00 
			
		
		
		
	Add atxfer fix (bug #3592)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5045 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		
							
								
								
									
										12
									
								
								app.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								app.c
									
									
									
									
									
								
							| @@ -37,11 +37,20 @@ | |||||||
| #define MAX_OTHER_FORMATS 10 | #define MAX_OTHER_FORMATS 10 | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /*  | ||||||
|  | This function presents a dialtone and reads an extension into 'collect'  | ||||||
|  | which must be a pointer to a **pre-initilized** array of char having a  | ||||||
|  | size of 'size' suitable for writing to.  It will collect no more than the smaller  | ||||||
|  | of 'maxlen' or 'size' minus the original strlen() of collect digits. | ||||||
|  | */ | ||||||
| int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect, size_t size, int maxlen, int timeout)  | int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect, size_t size, int maxlen, int timeout)  | ||||||
| { | { | ||||||
| 	struct tone_zone_sound *ts; | 	struct tone_zone_sound *ts; | ||||||
| 	int res=0, x=0; | 	int res=0, x=0; | ||||||
|  |  | ||||||
|  | 	if(maxlen > size) | ||||||
|  | 		maxlen = size; | ||||||
|  | 	 | ||||||
| 	if(!timeout && chan->pbx) | 	if(!timeout && chan->pbx) | ||||||
| 		timeout = chan->pbx->dtimeout; | 		timeout = chan->pbx->dtimeout; | ||||||
| 	else if(!timeout) | 	else if(!timeout) | ||||||
| @@ -53,8 +62,7 @@ int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect, | |||||||
| 	} else  | 	} else  | ||||||
| 		ast_log(LOG_NOTICE,"Huh....? no dial for indications?\n"); | 		ast_log(LOG_NOTICE,"Huh....? no dial for indications?\n"); | ||||||
| 	 | 	 | ||||||
| 	memset(collect, 0, size); | 	for (x = strlen(collect); strlen(collect) < maxlen; ) { | ||||||
| 	for (x=0; strlen(collect) < size; ) { |  | ||||||
| 		res = ast_waitfordigit(chan, timeout); | 		res = ast_waitfordigit(chan, timeout); | ||||||
| 		if (!ast_ignore_pattern(context, collect)) | 		if (!ast_ignore_pattern(context, collect)) | ||||||
| 			ast_playtones_stop(chan); | 			ast_playtones_stop(chan); | ||||||
|   | |||||||
| @@ -144,7 +144,7 @@ int ast_app_group_match_get_count(char *groupmatch, char *category); | |||||||
| /*! Create an argc argv type structure for app args */ | /*! Create an argc argv type structure for app args */ | ||||||
| int ast_separate_app_args(char *buf, char delim, char **array, int arraylen); | int ast_separate_app_args(char *buf, char delim, char **array, int arraylen); | ||||||
|  |  | ||||||
| /*! Present a dialtone and collect a certain length extension.  Returns 1 on valid extension entered, -1 on hangup, or 0 on invalid extension. */ | /*! Present a dialtone and collect a certain length extension.  Returns 1 on valid extension entered, -1 on hangup, or 0 on invalid extension. Note that if 'collect' holds digits already, new digits will be appended, so be sure it's initialized properly */ | ||||||
| int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect, size_t size, int maxlen, int timeout); | int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect, size_t size, int maxlen, int timeout); | ||||||
|  |  | ||||||
| /*! Allow to record message and have a review option */ | /*! Allow to record message and have a review option */ | ||||||
|   | |||||||
| @@ -458,9 +458,8 @@ static int builtin_blindtransfer(struct ast_channel *chan, struct ast_channel *p | |||||||
| 	struct ast_channel *transferer; | 	struct ast_channel *transferer; | ||||||
| 	struct ast_channel *transferee; | 	struct ast_channel *transferee; | ||||||
| 	char *transferer_real_context; | 	char *transferer_real_context; | ||||||
| 	char newext[256], *ptr; | 	char newext[256]; | ||||||
| 	int res; | 	int res; | ||||||
| 	int len; |  | ||||||
|  |  | ||||||
| 	if (sense == FEATURE_SENSE_PEER) { | 	if (sense == FEATURE_SENSE_PEER) { | ||||||
| 		transferer = peer; | 		transferer = peer; | ||||||
| @@ -484,7 +483,6 @@ static int builtin_blindtransfer(struct ast_channel *chan, struct ast_channel *p | |||||||
| 	ast_moh_start(transferee, NULL); | 	ast_moh_start(transferee, NULL); | ||||||
|  |  | ||||||
| 	memset(newext, 0, sizeof(newext)); | 	memset(newext, 0, sizeof(newext)); | ||||||
| 	ptr = newext; |  | ||||||
| 	 | 	 | ||||||
| 	/* Transfer */ | 	/* Transfer */ | ||||||
| 	if ((res=ast_streamfile(transferer, "pbx-transfer", transferer->language))) { | 	if ((res=ast_streamfile(transferer, "pbx-transfer", transferer->language))) { | ||||||
| @@ -498,15 +496,12 @@ static int builtin_blindtransfer(struct ast_channel *chan, struct ast_channel *p | |||||||
| 		ast_autoservice_stop(transferee); | 		ast_autoservice_stop(transferee); | ||||||
| 		ast_indicate(transferee, AST_CONTROL_UNHOLD); | 		ast_indicate(transferee, AST_CONTROL_UNHOLD); | ||||||
| 		return res; | 		return res; | ||||||
| 	} | 	} else if (res > 0) { | ||||||
| 	ast_stopstream(transferer); |  | ||||||
| 	if (res > 0) { |  | ||||||
| 		/* If they've typed a digit already, handle it */ | 		/* If they've typed a digit already, handle it */ | ||||||
| 		newext[0] = res; | 		newext[0] = (char) res; | ||||||
| 		ptr++; |  | ||||||
| 		len--; |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	ast_stopstream(transferer); | ||||||
| 	res = ast_app_dtget(transferer, transferer_real_context, newext, sizeof(newext), 100, transferdigittimeout); | 	res = ast_app_dtget(transferer, transferer_real_context, newext, sizeof(newext), 100, transferdigittimeout); | ||||||
| 	if (res < 0) { | 	if (res < 0) { | ||||||
| 		ast_moh_stop(transferee); | 		ast_moh_stop(transferee); | ||||||
| @@ -619,7 +614,7 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st | |||||||
| 	ast_indicate(transferee, AST_CONTROL_HOLD); | 	ast_indicate(transferee, AST_CONTROL_HOLD); | ||||||
| 	ast_autoservice_start(transferee); | 	ast_autoservice_start(transferee); | ||||||
| 	ast_moh_start(transferee, NULL); | 	ast_moh_start(transferee, NULL); | ||||||
|  | 	memset(xferto, 0, sizeof(xferto)); | ||||||
| 	/* Transfer */ | 	/* Transfer */ | ||||||
| 	if ((res=ast_streamfile(transferer, "pbx-transfer", transferer->language))) { | 	if ((res=ast_streamfile(transferer, "pbx-transfer", transferer->language))) { | ||||||
| 		ast_moh_stop(transferee); | 		ast_moh_stop(transferee); | ||||||
| @@ -632,6 +627,9 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st | |||||||
| 		ast_autoservice_stop(transferee); | 		ast_autoservice_stop(transferee); | ||||||
| 		ast_indicate(transferee, AST_CONTROL_UNHOLD); | 		ast_indicate(transferee, AST_CONTROL_UNHOLD); | ||||||
| 		return res; | 		return res; | ||||||
|  | 	} else if(res > 0) { | ||||||
|  | 		/* If they've typed a digit already, handle it */ | ||||||
|  | 		xferto[0] = (char) res; | ||||||
| 	} | 	} | ||||||
| 	if ((ast_app_dtget(transferer, transferer_real_context, xferto, sizeof(xferto), 100, transferdigittimeout))) { | 	if ((ast_app_dtget(transferer, transferer_real_context, xferto, sizeof(xferto), 100, transferdigittimeout))) { | ||||||
| 		cid_num = transferer->cid.cid_num; | 		cid_num = transferer->cid.cid_num; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user