[svn-commits] branch bweschke/findme_followme r31689 - /team/bweschke/findme_followme/apps/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Fri Jun 2 17:37:44 MST 2006


Author: bweschke
Date: Fri Jun  2 19:37:44 2006
New Revision: 31689

URL: http://svn.digium.com/view/asterisk?rev=31689&view=rev
Log:
 Formatting / indent cleanups. 


Modified:
    team/bweschke/findme_followme/apps/app_followme.c

Modified: team/bweschke/findme_followme/apps/app_followme.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_followme.c?rev=31689&r1=31688&r2=31689&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_followme.c (original)
+++ team/bweschke/findme_followme/apps/app_followme.c Fri Jun  2 19:37:44 2006
@@ -198,17 +198,15 @@
    
 static void profile_set_param(struct ast_call_followme *f, const char *param, const char *val, int linenum, int failunknown)
 {
-	if (!strcasecmp(param, "musicclass") || !strcasecmp(param, "musiconhold") || !strcasecmp(param, "music")) {
+	if (!strcasecmp(param, "musicclass") || !strcasecmp(param, "musiconhold") || !strcasecmp(param, "music")) 
 		ast_copy_string(f->moh, val, sizeof(f->moh));
-	} else if (!strcasecmp(param, "context")) {
+	else if (!strcasecmp(param, "context")) {
 		ast_copy_string(f->context, val, sizeof(f->context));
-	} else if(failunknown) {
-		if (linenum >= 0) {
-			ast_log(LOG_WARNING, "Unknown keyword in profile '%s': %s at line %d of followme.conf\n",
-				f->name, param, linenum);
-		} else {
+	} else if (failunknown) {
+		if (linenum >= 0)
+			ast_log(LOG_WARNING, "Unknown keyword in profile '%s': %s at line %d of followme.conf\n", f->name, param, linenum);
+		else
 			ast_log(LOG_WARNING, "Unknown keyword in profile '%s': %s\n", f->name, param);
-		}
 	}
 }
 
@@ -264,10 +262,9 @@
 	}
 	featuredigittostr = ast_variable_retrieve(cfg, "general", "featuredigittimeout");
 	
-	if (!ast_strlen_zero(featuredigittostr)) {
+	if (!ast_strlen_zero(featuredigittostr)) 
 		if (!scanf("%d", &featuredigittimeout))
 			featuredigittimeout = 5000;
-	}
 	
 	
 	/* Chug through config file */
@@ -386,272 +383,272 @@
 
 static struct ast_channel *wait_for_winner(struct findme_user *headuser, struct number *nm, struct ast_channel *caller, char *namerecloc, int *status) 
 {
-		struct ast_channel *watchers[256];
-		int pos;
-		struct ast_channel *winner;
-		struct ast_frame *f;
-		int ctstatus;
-		int dg;
-		struct findme_user *tmpuser = NULL;
-		int *to = ast_calloc(1, sizeof(*to));
-		int livechannels = 0;
-		int tmpto;
-		long totalwait = 0;
-		char *callfromname;
-		char *pressbuttonname;
-
-		/* ------------ wait_for_winner_channel start --------------- */ 
-
-		callfromname = ast_strdupa("call-from");
-		pressbuttonname = ast_strdupa("press-1-to-be-connected-or");	
-	
-		if (headuser->ochan)
-		{
-			if (!caller) {
-				ast_log(LOG_NOTICE, "Original caller hungup. Cleanup.\n");
+	struct ast_channel *watchers[256];
+	int pos;
+	struct ast_channel *winner;
+	struct ast_frame *f;
+	int ctstatus;
+	int dg;
+	struct findme_user *tmpuser = NULL;
+	int *to = ast_calloc(1, sizeof(*to));
+	int livechannels = 0;
+	int tmpto;
+	long totalwait = 0;
+	char *callfromname;
+	char *pressbuttonname;
+
+	/* ------------ wait_for_winner_channel start --------------- */ 
+
+	callfromname = ast_strdupa("call-from");
+	pressbuttonname = ast_strdupa("press-1-to-be-connected-or");	
+
+	if (headuser->ochan)
+	{
+		if (!caller) {
+			ast_log(LOG_NOTICE, "Original caller hungup. Cleanup.\n");
+			clear_calling_tree(headuser,1);
+			free(to);
+			return 0;
+		}
+		ctstatus = 0;
+		totalwait = nm->timeout * 1000;
+		while (!ctstatus) {
+			*to = 1000;
+			pos = 1;
+			livechannels = 0;
+			watchers[0] = caller;
+		
+			dg = 0;	
+			winner = NULL;	
+			tmpuser = headuser;
+			while (tmpuser) {
+				if (tmpuser->state >= 0 && tmpuser->ochan) {
+					if (tmpuser->digts && (tmpuser->digts - totalwait) > featuredigittimeout) {
+						ast_log(LOG_NOTICE, "We've been waiting for digits longer than we should have.\n");
+						tmpuser->state = 1;
+						tmpuser->digts = 0;
+						if (!ast_streamfile(tmpuser->ochan, callfromname, tmpuser->ochan->language)) {
+							ast_sched_runq(tmpuser->ochan->sched);
+						} else {
+							ast_log(LOG_WARNING, "Unable to playback %s.\n", callfromname);
+							free(to);
+							return NULL;
+						}							
+					}
+					if (tmpuser->ochan->stream) {
+						ast_sched_runq(tmpuser->ochan->sched);
+						tmpto = ast_sched_wait(tmpuser->ochan->sched);
+						if (tmpto > 0 && tmpto < *to)
+							*to = tmpto;
+						else if (tmpto < 0) {
+							ast_stopstream(tmpuser->ochan);
+							if (tmpuser->state == 1) {
+								ast_log(LOG_NOTICE, "Playback of the file appears to be done.\n");
+								if (!ast_streamfile(tmpuser->ochan, namerecloc, tmpuser->ochan->language)) {
+									tmpuser->state = 2;
+								} else {
+									ast_log(LOG_WARNING, "Unable to playback %s.\n", namerecloc);
+									free(to);
+									return NULL;
+								}
+							} else if (tmpuser->state == 2) {
+								ast_log(LOG_NOTICE, "Playback of name file appears to be done.\n");
+								memset(tmpuser->yn, 0, sizeof(tmpuser->yn));
+								tmpuser->ynidx = 0;
+								tmpuser->digts = 0;
+								if (!ast_streamfile(tmpuser->ochan, pressbuttonname, tmpuser->ochan->language)) {
+									tmpuser->state = 3;
+									
+								} else {
+									ast_log(LOG_WARNING, "Unable to playback %s.\n", pressbuttonname);										  free(to);
+									return NULL;
+								} 
+							} else if (tmpuser->state == 3) {
+								ast_log(LOG_NOTICE, "Playback of the next step file appears to be done.\n");
+							}
+						}
+					}
+					watchers[pos++] = tmpuser->ochan;
+					livechannels++;
+				}
+				tmpuser = tmpuser->next;
+			}
+			tmpto = *to;
+			winner = ast_waitfor_n(watchers, pos, to);
+			tmpto -= *to;
+			totalwait -= tmpto;
+			if (totalwait <= 0) {
+				ast_log(LOG_NOTICE, "We've hit our timeout for this step. Drop everyone and move on to the next one. %ld\n", totalwait);
 				clear_calling_tree(headuser,1);
 				free(to);
 				return 0;
 			}
-			ctstatus = 0;
-			totalwait = nm->timeout * 1000;
-			while (!ctstatus) {
-				*to = 1000;
-				pos = 1;
-				livechannels = 0;
-				watchers[0] = caller;
-			
-				dg = 0;	
-				winner = NULL;	
+			if (winner) {
+				/* Need to find out which channel this is */
+				dg = 0;
+				while ((winner != watchers[dg]) && (dg < 256))
+					dg++;
 				tmpuser = headuser;
-				while (tmpuser) {
-					if (tmpuser->state >= 0 && tmpuser->ochan) {
-						if (tmpuser->digts && (tmpuser->digts - totalwait) > featuredigittimeout) {
-							ast_log(LOG_NOTICE, "We've been waiting for digits longer than we should have.\n");
-							tmpuser->state = 1;
-							tmpuser->digts = 0;
-							if (!ast_streamfile(tmpuser->ochan, callfromname, tmpuser->ochan->language)) {
-								ast_sched_runq(tmpuser->ochan->sched);
-							} else {
-								ast_log(LOG_WARNING, "Unable to playback %s.\n", callfromname);
+				while ((tmpuser) && (tmpuser->ochan != winner)) {
+					tmpuser = tmpuser->next;
+				}
+				f = ast_read(winner);
+				if (f) {
+					if (f->frametype == AST_FRAME_CONTROL) {
+						switch(f->subclass) {
+						case AST_CONTROL_HANGUP:
+							if (option_verbose > 2)
+								ast_verbose( VERBOSE_PREFIX_3 "%s received a hangup frame.\n", winner->name);
+							if (dg == 0) {
+								if (option_verbose > 2)
+									ast_verbose( VERBOSE_PREFIX_3 "The calling channel hungup. Need to drop everyone else.\n");
+								clear_calling_tree(headuser,1);
+								ctstatus = -1;
+							}
+							break;
+						case AST_CONTROL_ANSWER:
+							/* This is our guy if someone answered. */
+							if (option_verbose > 2)
+								ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", winner->name, caller->name);
+							/* If call has been answered, then the eventual hangup is likely to be normal hangup */ 
+							winner->hangupcause = AST_CAUSE_NORMAL_CLEARING;
+							caller->hangupcause = AST_CAUSE_NORMAL_CLEARING;
+							if (dg > 0) {
+								if (!ast_streamfile(winner, callfromname, winner->language)) {
+									ast_sched_runq(winner->sched);
+									tmpuser->state = 1;
+								} else {
+									ast_log(LOG_WARNING, "Unable to playback %s.\n", callfromname);
+									free(to);
+									return NULL;
+								}							
+							}
+							break;
+						case AST_CONTROL_BUSY:
+							if (option_verbose > 2)
+								ast_verbose( VERBOSE_PREFIX_3 "%s is busy\n", winner->name);
+							break;
+						case AST_CONTROL_CONGESTION:
+							if (option_verbose > 2)
+								ast_verbose( VERBOSE_PREFIX_3 "%s is circuit-busy\n", winner->name);
+							break;
+						case AST_CONTROL_RINGING:
+							if (option_verbose > 2)
+								ast_verbose( VERBOSE_PREFIX_3 "%s is ringing\n", winner->name);
+							break;
+						case AST_CONTROL_PROGRESS:
+							if (option_verbose > 2)
+								ast_verbose ( VERBOSE_PREFIX_3 "%s is making progress passing it to %s\n", winner->name,caller->name);
+							break;
+						case AST_CONTROL_VIDUPDATE:
+							if (option_verbose > 2)
+								ast_verbose ( VERBOSE_PREFIX_3 "%s requested a video update, passing it to %s\n", winner->name,caller->name);
+							break;
+						case AST_CONTROL_PROCEEDING:
+							if (option_verbose > 2)
+								ast_verbose ( VERBOSE_PREFIX_3 "%s is proceeding passing it to %s\n", winner->name,caller->name);
+							break;
+						case AST_CONTROL_HOLD:
+							if (option_verbose > 2)
+								ast_verbose(VERBOSE_PREFIX_3 "Call on %s placed on hold\n", winner->name);
+							break;
+						case AST_CONTROL_UNHOLD:
+							if (option_verbose > 2)
+								ast_verbose(VERBOSE_PREFIX_3 "Call on %s left from hold\n", winner->name);
+							break;
+						case AST_CONTROL_OFFHOOK:
+						case AST_CONTROL_FLASH:
+							/* Ignore going off hook and flash */
+							break;
+						case -1:
+							if (option_verbose > 2)
+								ast_verbose( VERBOSE_PREFIX_3 "%s stopped sounds\n", winner->name);
+							break;
+						default:
+							if (option_debug > 2)
+								ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass);
+							break;
+						}
+					} 
+					if (tmpuser && tmpuser->state == 3 && f->frametype == AST_FRAME_DTMF) {
+						if (winner->stream)
+							ast_stopstream(winner);
+						if (!tmpuser->digts)
+							tmpuser->digts = totalwait;
+						ast_log(LOG_NOTICE, "DTMF received: %c\n",(char) f->subclass);
+						tmpuser->yn[tmpuser->ynidx] = (char) f->subclass;
+						tmpuser->ynidx++;
+						ast_log(LOG_NOTICE, "DTMF string: %s\n", tmpuser->yn);
+						if (tmpuser->ynidx >= ynlongest) {
+							ast_log(LOG_NOTICE, "reached longest possible match\n");
+							if (!strcmp(tmpuser->yn, takecall)) {
+								ast_log(LOG_NOTICE, "Match to take the call!\n");
 								free(to);
-								return NULL;
-							}							
+								return tmpuser->ochan;	
+							}
+							if (!strcmp(tmpuser->yn, nextindp)) {
+								ast_log(LOG_NOTICE, "Next in dial plan step requested.\n");
+								*status = 1;
+								free(to);
+								return 0;
+							}	
+							if (!strcmp(tmpuser->yn, nextinfmfm)) {
+								ast_log(LOG_NOTICE, "Next in find me/follow me step requested.\n");
+								*status = 2;
+								free(to);
+								return 0;
+							}	
+							if (!strcmp(tmpuser->yn, blindxferexten)) {
+								ast_log(LOG_NOTICE, "Blind Transfer requested.\n");
+								*status = 3;
+								free(to);
+								return 0;
+							}	
+							if (!strcmp(tmpuser->yn, atxferexten)) {
+								ast_log(LOG_NOTICE, "Attended Transfer requested.\n");
+								*status = 4;
+								free(to);
+								return 0;
+							}	
+
 						}
-						if (tmpuser->ochan->stream) {
-							ast_sched_runq(tmpuser->ochan->sched);
-							tmpto = ast_sched_wait(tmpuser->ochan->sched);
-							if (tmpto > 0 && tmpto < *to)
-								*to = tmpto;
-							else if (tmpto < 0) {
-								ast_stopstream(tmpuser->ochan);
-								if (tmpuser->state == 1) {
-									ast_log(LOG_NOTICE, "Playback of the file appears to be done.\n");
-									if (!ast_streamfile(tmpuser->ochan, namerecloc, tmpuser->ochan->language)) {
-										tmpuser->state = 2;
-									} else {
-										ast_log(LOG_WARNING, "Unable to playback %s.\n", namerecloc);
-										free(to);
-										return NULL;
-									}
-								} else if (tmpuser->state == 2) {
-									ast_log(LOG_NOTICE, "Playback of name file appears to be done.\n");
-									memset(tmpuser->yn, 0, sizeof(tmpuser->yn));
-									tmpuser->ynidx = 0;
-									tmpuser->digts = 0;
-									if (!ast_streamfile(tmpuser->ochan, pressbuttonname, tmpuser->ochan->language)) {
-										tmpuser->state = 3;
-										
-									} else {
-										ast_log(LOG_WARNING, "Unable to playback %s.\n", pressbuttonname);										  free(to);
-										return NULL;
-									} 
-								} else if (tmpuser->state == 3) {
-									ast_log(LOG_NOTICE, "Playback of the next step file appears to be done.\n");
-								}
+					}
+					
+					ast_frfree(f);
+				} else {
+					if (winner) {
+
+						ast_log(LOG_NOTICE, "we didn't get a frame. hanging up. dg is %d\n",dg);					      
+						if (!dg) {
+							clear_calling_tree(headuser,1);
+							free(to);
+							return 0;
+						} else {
+							tmpuser->state = -1;
+						 	ast_hangup(winner);  
+							livechannels--;
+							ast_log(LOG_NOTICE, "live channels left %d\n", livechannels);
+							if (!livechannels) {
+								ast_log(LOG_NOTICE, "no live channels left. exiting.\n");
+								free(to);
+								return 0;
 							}
 						}
-						watchers[pos++] = tmpuser->ochan;
-						livechannels++;
 					}
-					tmpuser = tmpuser->next;
-				}
-				tmpto = *to;
-				winner = ast_waitfor_n(watchers, pos, to);
-				tmpto -= *to;
-				totalwait -= tmpto;
-				if (totalwait <= 0) {
-					ast_log(LOG_NOTICE, "We've hit our timeout for this step. Drop everyone and move on to the next one. %ld\n", totalwait);
-					clear_calling_tree(headuser,1);
-					free(to);
-					return 0;
-				}
-				if (winner) {
-					/* Need to find out which channel this is */
-					dg = 0;
-					while ((winner != watchers[dg]) && (dg < 256))
-						dg++;
-					tmpuser = headuser;
-					while ((tmpuser) && (tmpuser->ochan != winner)) {
-						tmpuser = tmpuser->next;
-					}
-					f = ast_read(winner);
-					if (f) {
-						if (f->frametype == AST_FRAME_CONTROL) {
-							switch(f->subclass) {
-							case AST_CONTROL_HANGUP:
-								if (option_verbose > 2)
-									ast_verbose( VERBOSE_PREFIX_3 "%s received a hangup frame.\n", winner->name);
-								if (dg == 0) {
-									if (option_verbose > 2)
-										ast_verbose( VERBOSE_PREFIX_3 "The calling channel hungup. Need to drop everyone else.\n");
-									clear_calling_tree(headuser,1);
-									ctstatus = -1;
-								}
-								break;
-							case AST_CONTROL_ANSWER:
-								/* This is our guy if someone answered. */
-								if (option_verbose > 2)
-									ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", winner->name, caller->name);
-								/* If call has been answered, then the eventual hangup is likely to be normal hangup */ 
-								winner->hangupcause = AST_CAUSE_NORMAL_CLEARING;
-								caller->hangupcause = AST_CAUSE_NORMAL_CLEARING;
-								if (dg > 0) {
-									if (!ast_streamfile(winner, callfromname, winner->language)) {
-										ast_sched_runq(winner->sched);
-										tmpuser->state = 1;
-									} else {
-										ast_log(LOG_WARNING, "Unable to playback %s.\n", callfromname);
-										free(to);
-										return NULL;
-									}							
-								}
-								break;
-							case AST_CONTROL_BUSY:
-								if (option_verbose > 2)
-									ast_verbose( VERBOSE_PREFIX_3 "%s is busy\n", winner->name);
-								break;
-							case AST_CONTROL_CONGESTION:
-								if (option_verbose > 2)
-									ast_verbose( VERBOSE_PREFIX_3 "%s is circuit-busy\n", winner->name);
-								break;
-							case AST_CONTROL_RINGING:
-								if (option_verbose > 2)
-									ast_verbose( VERBOSE_PREFIX_3 "%s is ringing\n", winner->name);
-								break;
-							case AST_CONTROL_PROGRESS:
-								if (option_verbose > 2)
-									ast_verbose ( VERBOSE_PREFIX_3 "%s is making progress passing it to %s\n", winner->name,caller->name);
-								break;
-							case AST_CONTROL_VIDUPDATE:
-								if (option_verbose > 2)
-									ast_verbose ( VERBOSE_PREFIX_3 "%s requested a video update, passing it to %s\n", winner->name,caller->name);
-								break;
-							case AST_CONTROL_PROCEEDING:
-								if (option_verbose > 2)
-									ast_verbose ( VERBOSE_PREFIX_3 "%s is proceeding passing it to %s\n", winner->name,caller->name);
-								break;
-							case AST_CONTROL_HOLD:
-								if (option_verbose > 2)
-									ast_verbose(VERBOSE_PREFIX_3 "Call on %s placed on hold\n", winner->name);
-								break;
-							case AST_CONTROL_UNHOLD:
-								if (option_verbose > 2)
-									ast_verbose(VERBOSE_PREFIX_3 "Call on %s left from hold\n", winner->name);
-								break;
-							case AST_CONTROL_OFFHOOK:
-							case AST_CONTROL_FLASH:
-								/* Ignore going off hook and flash */
-								break;
-							case -1:
-								if (option_verbose > 2)
-									ast_verbose( VERBOSE_PREFIX_3 "%s stopped sounds\n", winner->name);
-								break;
-							default:
-								if (option_debug > 2)
-									ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass);
-								break;
-							}
-						} 
-						if (tmpuser && tmpuser->state == 3 && f->frametype == AST_FRAME_DTMF) {
-							if (winner->stream)
-								ast_stopstream(winner);
-							if (!tmpuser->digts)
-								tmpuser->digts = totalwait;
-							ast_log(LOG_NOTICE, "DTMF received: %c\n",(char) f->subclass);
-							tmpuser->yn[tmpuser->ynidx] = (char) f->subclass;
-							tmpuser->ynidx++;
-							ast_log(LOG_NOTICE, "DTMF string: %s\n", tmpuser->yn);
-							if (tmpuser->ynidx >= ynlongest) {
-								ast_log(LOG_NOTICE, "reached longest possible match\n");
-								if (!strcmp(tmpuser->yn, takecall)) {
-									ast_log(LOG_NOTICE, "Match to take the call!\n");
-									free(to);
-									return tmpuser->ochan;	
-								}
-								if (!strcmp(tmpuser->yn, nextindp)) {
-									ast_log(LOG_NOTICE, "Next in dial plan step requested.\n");
-									*status = 1;
-									free(to);
-									return 0;
-								}	
-								if (!strcmp(tmpuser->yn, nextinfmfm)) {
-									ast_log(LOG_NOTICE, "Next in find me/follow me step requested.\n");
-									*status = 2;
-									free(to);
-									return 0;
-								}	
-								if (!strcmp(tmpuser->yn, blindxferexten)) {
-									ast_log(LOG_NOTICE, "Blind Transfer requested.\n");
-									*status = 3;
-									free(to);
-									return 0;
-								}	
-								if (!strcmp(tmpuser->yn, atxferexten)) {
-									ast_log(LOG_NOTICE, "Attended Transfer requested.\n");
-									*status = 4;
-									free(to);
-									return 0;
-								}	
-
-							}
-						}
-						
-						ast_frfree(f);
-					} else {
-						if (winner) {
-
-							ast_log(LOG_NOTICE, "we didn't get a frame. hanging up. dg is %d\n",dg);					      
-							if (!dg) {
-								clear_calling_tree(headuser,1);
-								free(to);
-								return 0;
-							} else {
-								tmpuser->state = -1;
-							 	ast_hangup(winner);  
-								livechannels--;
-								ast_log(LOG_NOTICE, "live channels left %d\n", livechannels);
-								if (!livechannels) {
-									ast_log(LOG_NOTICE, "no live channels left. exiting.\n");
-									free(to);
-									return 0;
-								}
-							}
-						}
-					}					
-					
-				} 
-			}
-			
-		}
-		else
-		{
-			ast_log(LOG_NOTICE, "couldn't reach at this number.\n");
+				}					
+				
+			} 
 		}
 		
-		/* --- WAIT FOR WINNER NUMBER END! -----------*/
-		free(to);
-		return NULL;
+	}
+	else
+	{
+		ast_log(LOG_NOTICE, "couldn't reach at this number.\n");
+	}
+	
+	/* --- WAIT FOR WINNER NUMBER END! -----------*/
+	free(to);
+	return NULL;
 }
 
 static void findmeexec(void *args)
@@ -882,35 +879,35 @@
 				else
 				{
 							
-							caller = chan;
-							outbound = targs.outbound;
-							/* Bridge the two channels. */
-
-							memset(&config,0,sizeof(struct ast_bridge_config));
-								ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT);
-								ast_set_flag(&(config.features_callee), AST_FEATURE_AUTOMON);
-								ast_set_flag(&(config.features_caller), AST_FEATURE_AUTOMON);
+					caller = chan;
+					outbound = targs.outbound;
+					/* Bridge the two channels. */
+
+					memset(&config,0,sizeof(struct ast_bridge_config));
+					ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT);
+					ast_set_flag(&(config.features_callee), AST_FEATURE_AUTOMON);
+					ast_set_flag(&(config.features_caller), AST_FEATURE_AUTOMON);
 				
-							ast_moh_stop(caller);
-							/* Be sure no generators are left on it */
-							ast_deactivate_generator(caller);
-							/* Make sure channels are compatible */
-							res = ast_channel_make_compatible(caller, outbound);
-							if (res < 0) {
-								ast_log(LOG_WARNING, "Had to drop call because I couldn't make %s compatible with %s\n", caller->name, outbound->name);
-								ast_hangup(outbound);
-								goto outrun;
-							}
-							time(&answer_time);
-							res = ast_bridge_call(caller,outbound,&config);
-							time(&end_time);
-							snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time));
-							pbx_builtin_setvar_helper(caller, "DIALEDTIME", toast);
-							snprintf(toast, sizeof(toast), "%ld", (long)(end_time - answer_time));
-							pbx_builtin_setvar_helper(caller, "ANSWEREDTIME", toast);
-							if (outbound)
-								ast_hangup(outbound);
-							res = 1;
+					ast_moh_stop(caller);
+					/* Be sure no generators are left on it */
+					ast_deactivate_generator(caller);
+					/* Make sure channels are compatible */
+					res = ast_channel_make_compatible(caller, outbound);
+					if (res < 0) {
+						ast_log(LOG_WARNING, "Had to drop call because I couldn't make %s compatible with %s\n", caller->name, outbound->name);
+						ast_hangup(outbound);
+						goto outrun;
+					}
+					time(&answer_time);
+					res = ast_bridge_call(caller,outbound,&config);
+					time(&end_time);
+					snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time));
+					pbx_builtin_setvar_helper(caller, "DIALEDTIME", toast);
+					snprintf(toast, sizeof(toast), "%ld", (long)(end_time - answer_time));
+					pbx_builtin_setvar_helper(caller, "ANSWEREDTIME", toast);
+					if (outbound)
+						ast_hangup(outbound);
+					res = 1;
 					
 				}
 				



More information about the svn-commits mailing list