[asterisk-commits] oej: branch oej/jitterbuffer-1.2 r64192 - in /team/oej/jitterbuffer-1.2: ./ a...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon May 14 06:55:00 MST 2007


Author: oej
Date: Mon May 14 08:55:00 2007
New Revision: 64192

URL: http://svn.digium.com/view/asterisk?view=rev&rev=64192
Log:
Reset automerge

Modified:
    team/oej/jitterbuffer-1.2/   (props changed)
    team/oej/jitterbuffer-1.2/Makefile
    team/oej/jitterbuffer-1.2/app.c
    team/oej/jitterbuffer-1.2/apps/app_directory.c
    team/oej/jitterbuffer-1.2/apps/app_groupcount.c
    team/oej/jitterbuffer-1.2/apps/app_macro.c
    team/oej/jitterbuffer-1.2/apps/app_voicemail.c
    team/oej/jitterbuffer-1.2/asterisk.c
    team/oej/jitterbuffer-1.2/cdr.c
    team/oej/jitterbuffer-1.2/channel.c
    team/oej/jitterbuffer-1.2/channels/chan_iax2.c
    team/oej/jitterbuffer-1.2/channels/chan_misdn.c
    team/oej/jitterbuffer-1.2/channels/chan_modem.c
    team/oej/jitterbuffer-1.2/channels/chan_phone.c
    team/oej/jitterbuffer-1.2/channels/chan_sip.c
    team/oej/jitterbuffer-1.2/channels/chan_zap.c
    team/oej/jitterbuffer-1.2/channels/misdn/isdn_lib.c
    team/oej/jitterbuffer-1.2/channels/misdn/isdn_lib.h
    team/oej/jitterbuffer-1.2/channels/misdn/isdn_lib_intern.h
    team/oej/jitterbuffer-1.2/channels/misdn/isdn_msg_parser.c
    team/oej/jitterbuffer-1.2/codecs/codec_zap.c
    team/oej/jitterbuffer-1.2/config.c
    team/oej/jitterbuffer-1.2/configs/indications.conf.sample
    team/oej/jitterbuffer-1.2/contrib/scripts/safe_asterisk
    team/oej/jitterbuffer-1.2/funcs/func_groupcount.c
    team/oej/jitterbuffer-1.2/include/asterisk/app.h
    team/oej/jitterbuffer-1.2/manager.c
    team/oej/jitterbuffer-1.2/pbx.c
    team/oej/jitterbuffer-1.2/res/res_config_odbc.c
    team/oej/jitterbuffer-1.2/res/res_features.c

Propchange: team/oej/jitterbuffer-1.2/
------------------------------------------------------------------------------
    automerge = http://edvina.net/training/

Propchange: team/oej/jitterbuffer-1.2/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon May 14 08:55:00 2007
@@ -1,1 +1,1 @@
-/branches/1.2:1-61739
+/branches/1.2:1-64189

Modified: team/oej/jitterbuffer-1.2/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/Makefile?view=diff&rev=64192&r1=64191&r2=64192
==============================================================================
--- team/oej/jitterbuffer-1.2/Makefile (original)
+++ team/oej/jitterbuffer-1.2/Makefile Mon May 14 08:55:00 2007
@@ -662,7 +662,7 @@
 	$(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
 	$(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/	
 	if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
-		cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
+		cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
 		chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
 	fi
 	$(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)

Modified: team/oej/jitterbuffer-1.2/app.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/app.c?view=diff&rev=64192&r1=64191&r2=64192
==============================================================================
--- team/oej/jitterbuffer-1.2/app.c (original)
+++ team/oej/jitterbuffer-1.2/app.c Mon May 14 08:55:00 2007
@@ -48,9 +48,11 @@
 #include "asterisk/utils.h"
 #include "asterisk/lock.h"
 #include "asterisk/indications.h"
+#include "asterisk/linkedlists.h"
 
 #define MAX_OTHER_FORMATS 10
 
+static AST_LIST_HEAD_STATIC(groups, ast_group_info);
 
 /* !
 This function presents a dialtone and reads an extension into 'collect' 
@@ -1023,61 +1025,74 @@
 	else
 		res = -1;
 
-	if (cat)
-		snprintf(category, category_max, "%s_%s", GROUP_CATEGORY_PREFIX, cat);
-	else
-		ast_copy_string(category, GROUP_CATEGORY_PREFIX, category_max);
+	if (!ast_strlen_zero(cat))
+		ast_copy_string(category, cat, category_max);
 
 	return res;
 }
 
 int ast_app_group_set_channel(struct ast_channel *chan, char *data)
 {
-	int res=0;
-	char group[80] = "";
-	char category[80] = "";
-
-	if (!ast_app_group_split_group(data, group, sizeof(group), category, sizeof(category))) {
-		pbx_builtin_setvar_helper(chan, category, group);
-	} else
+	int res = 0;
+	char group[80] = "", category[80] = "";
+	struct ast_group_info *gi = NULL;
+	size_t len = 0;
+
+	if (ast_app_group_split_group(data, group, sizeof(group), category, sizeof(category)))
+		return -1;
+
+	/* Calculate memory we will need if this is new */
+	len = sizeof(*gi) + strlen(group) + 1;
+	if (!ast_strlen_zero(category))
+		len += strlen(category) + 1;
+
+	AST_LIST_LOCK(&groups);
+	AST_LIST_TRAVERSE(&groups, gi, list) {
+		if (gi->chan == chan && !strcasecmp(gi->group, group) && (ast_strlen_zero(category) || (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, category))))
+			break;
+	}
+
+	if (!gi && (gi = calloc(1, len))) {
+		gi->chan = chan;
+		gi->group = (char *) gi + sizeof(*gi);
+		strcpy(gi->group, group);
+		if (!ast_strlen_zero(category)) {
+			gi->category = (char *) gi + sizeof(*gi) + strlen(group) + 1;
+			strcpy(gi->category, category);
+		}
+		AST_LIST_INSERT_TAIL(&groups, gi, list);
+	} else {
 		res = -1;
+	}
+
+	AST_LIST_UNLOCK(&groups);
 
 	return res;
 }
 
 int ast_app_group_get_count(char *group, char *category)
 {
-	struct ast_channel *chan;
+	struct ast_group_info *gi = NULL;
 	int count = 0;
-	char *test;
-	char cat[80];
-	char *s;
 
 	if (ast_strlen_zero(group))
 		return 0;
 
- 	s = (!ast_strlen_zero(category)) ? category : GROUP_CATEGORY_PREFIX;
-	ast_copy_string(cat, s, sizeof(cat));
-
-	chan = NULL;
-	while ((chan = ast_channel_walk_locked(chan)) != NULL) {
- 		test = pbx_builtin_getvar_helper(chan, cat);
-		if (test && !strcasecmp(test, group))
- 			count++;
-		ast_mutex_unlock(&chan->lock);
-	}
+	AST_LIST_LOCK(&groups);
+	AST_LIST_TRAVERSE(&groups, gi, list) {
+		if (!strcasecmp(gi->group, group) && (ast_strlen_zero(category) || !strcasecmp(gi->category, category)))
+			count++;
+	}
+	AST_LIST_UNLOCK(&groups);
 
 	return count;
 }
 
 int ast_app_group_match_get_count(char *groupmatch, char *category)
 {
+	struct ast_group_info *gi = NULL;
 	regex_t regexbuf;
-	struct ast_channel *chan;
 	int count = 0;
-	char *test;
-	char cat[80];
-	char *s;
 
 	if (ast_strlen_zero(groupmatch))
 		return 0;
@@ -1086,20 +1101,62 @@
 	if (regcomp(&regexbuf, groupmatch, REG_EXTENDED | REG_NOSUB))
 		return 0;
 
-	s = (!ast_strlen_zero(category)) ? category : GROUP_CATEGORY_PREFIX;
-	ast_copy_string(cat, s, sizeof(cat));
-
-	chan = NULL;
-	while ((chan = ast_channel_walk_locked(chan)) != NULL) {
-		test = pbx_builtin_getvar_helper(chan, cat);
-		if (test && !regexec(&regexbuf, test, 0, NULL, 0))
+	AST_LIST_LOCK(&groups);
+	AST_LIST_TRAVERSE(&groups, gi, list) {
+		if (!regexec(&regexbuf, gi->group, 0, NULL, 0) && (ast_strlen_zero(category) || !strcasecmp(gi->category, category)))
 			count++;
-		ast_mutex_unlock(&chan->lock);
-	}
+	}
+	AST_LIST_UNLOCK(&groups);
 
 	regfree(&regexbuf);
 
 	return count;
+}
+
+int ast_app_group_update(struct ast_channel *old, struct ast_channel *new)
+{
+	struct ast_group_info *gi = NULL;
+
+	AST_LIST_LOCK(&groups);
+	AST_LIST_TRAVERSE(&groups, gi, list) {
+		if (gi->chan == old)
+			gi->chan = new;
+	}
+	AST_LIST_UNLOCK(&groups);
+
+	return 0;
+}
+
+int ast_app_group_discard(struct ast_channel *chan)
+{
+	struct ast_group_info *gi = NULL;
+
+	AST_LIST_LOCK(&groups);
+	AST_LIST_TRAVERSE_SAFE_BEGIN(&groups, gi, list) {
+		if (gi->chan == chan) {
+			AST_LIST_REMOVE_CURRENT(&groups, list);
+			free(gi);
+		}
+	}
+        AST_LIST_TRAVERSE_SAFE_END
+	AST_LIST_UNLOCK(&groups);
+
+	return 0;
+}
+
+int ast_app_group_list_lock(void)
+{
+	return AST_LIST_LOCK(&groups);
+}
+
+struct ast_group_info *ast_app_group_list_head(void)
+{
+	return AST_LIST_FIRST(&groups);
+}
+
+int ast_app_group_list_unlock(void)
+{
+	return AST_LIST_UNLOCK(&groups);
 }
 
 unsigned int ast_app_separate_args(char *buf, char delim, char **array, int arraylen)

Modified: team/oej/jitterbuffer-1.2/apps/app_directory.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/apps/app_directory.c?view=diff&rev=64192&r1=64191&r2=64192
==============================================================================
--- team/oej/jitterbuffer-1.2/apps/app_directory.c (original)
+++ team/oej/jitterbuffer-1.2/apps/app_directory.c Mon May 14 08:55:00 2007
@@ -97,7 +97,7 @@
 	void *fdm = MAP_FAILED;
 	SQLHSTMT stmt;
 	char sql[256];
-	char fmt[80]="";
+	char fmt[80]="", empty[10] = "";
 	char *c;
 	SQLLEN colsize;
 	char full_fn[256];
@@ -148,7 +148,7 @@
 				break;
 			}
 
-			res = SQLGetData(stmt, 1, SQL_BINARY, NULL, 0, &colsize);
+			res = SQLGetData(stmt, 1, SQL_BINARY, empty, 0, &colsize);
 			fdlen = colsize;
 			if (fd > -1) {
 				char tmp[1]="";

Modified: team/oej/jitterbuffer-1.2/apps/app_groupcount.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/apps/app_groupcount.c?view=diff&rev=64192&r1=64191&r2=64192
==============================================================================
--- team/oej/jitterbuffer-1.2/apps/app_groupcount.c (original)
+++ team/oej/jitterbuffer-1.2/apps/app_groupcount.c Mon May 14 08:55:00 2007
@@ -201,10 +201,8 @@
 {
 #define FORMAT_STRING  "%-25s  %-20s  %-20s\n"
 
-	struct ast_channel *c = NULL;
 	int numchans = 0;
-	struct ast_var_t *current;
-	struct varshead *headp;
+	struct ast_group_info *gi = NULL;
 	regex_t regexbuf;
 	int havepattern = 0;
 
@@ -218,25 +216,19 @@
 	}
 
 	ast_cli(fd, FORMAT_STRING, "Channel", "Group", "Category");
-	while ( (c = ast_channel_walk_locked(c)) != NULL) {
-		headp=&c->varshead;
-		AST_LIST_TRAVERSE(headp,current,entries) {
-			if (!strncmp(ast_var_name(current), GROUP_CATEGORY_PREFIX "_", strlen(GROUP_CATEGORY_PREFIX) + 1)) {
-				if (!havepattern || !regexec(&regexbuf, ast_var_value(current), 0, NULL, 0)) {
-					ast_cli(fd, FORMAT_STRING, c->name, ast_var_value(current),
-						(ast_var_name(current) + strlen(GROUP_CATEGORY_PREFIX) + 1));
-					numchans++;
-				}
-			} else if (!strcmp(ast_var_name(current), GROUP_CATEGORY_PREFIX)) {
-				if (!havepattern || !regexec(&regexbuf, ast_var_value(current), 0, NULL, 0)) {
-					ast_cli(fd, FORMAT_STRING, c->name, ast_var_value(current), "(default)");
-					numchans++;
-				}
-			}
+
+	ast_app_group_list_lock();
+
+	gi = ast_app_group_list_head();
+	while (gi) {
+		if (!havepattern || !regexec(&regexbuf, gi->group, 0, NULL, 0)) {
+			ast_cli(fd, FORMAT_STRING, gi->chan->name, gi->group, (ast_strlen_zero(gi->category) ? "(default)" : gi->category));
+			numchans++;
 		}
-		numchans++;
-		ast_mutex_unlock(&c->lock);
-	}
+		gi = AST_LIST_NEXT(gi, list);
+	}
+
+	ast_app_group_list_unlock();
 
 	if (havepattern)
 		regfree(&regexbuf);

Modified: team/oej/jitterbuffer-1.2/apps/app_macro.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/apps/app_macro.c?view=diff&rev=64192&r1=64191&r2=64192
==============================================================================
--- team/oej/jitterbuffer-1.2/apps/app_macro.c (original)
+++ team/oej/jitterbuffer-1.2/apps/app_macro.c Mon May 14 08:55:00 2007
@@ -140,6 +140,7 @@
 	char *macro;
 	char fullmacro[80];
 	char varname[80];
+	char runningapp[80], runningdata[1024];
 	char *oldargs[MAX_ARGS + 1] = { NULL, };
 	int argc, x;
 	int res=0;
@@ -158,9 +159,6 @@
 	char *save_macro_offset;
 	struct localuser *u;
  
-	struct ast_context *c;
-	struct ast_exten *e;
-
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "Macro() requires arguments. See \"show application macro\" for help.\n");
 		return -1;
@@ -266,13 +264,31 @@
 	autoloopflag = ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP);
 	ast_set_flag(chan, AST_FLAG_IN_AUTOLOOP);
 	while(ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num)) {
+		struct ast_context *c;
+		struct ast_exten *e;
+
 		/* What application will execute? */
-		for (c = ast_walk_contexts(NULL), e = NULL; c; c = ast_walk_contexts(c)) {
-			if (!strcmp(ast_get_context_name(c), chan->context)) {
-				e = find_matching_priority(c, chan->exten, chan->priority, chan->cid.cid_num);
-				break;
-			}
-		}
+		if (ast_lock_contexts()) {
+			ast_log(LOG_WARNING, "Failed to lock contexts list\n");
+			e = NULL;
+		} else {
+			for (c = ast_walk_contexts(NULL), e = NULL; c; c = ast_walk_contexts(c)) {
+				if (!strcmp(ast_get_context_name(c), chan->context)) {
+					if (ast_lock_context(c)) {
+						ast_log(LOG_WARNING, "Unable to lock context?\n");
+						runningapp[0] = '\0';
+						runningdata[0] = '\0';
+					} else {
+						e = find_matching_priority(c, chan->exten, chan->priority, chan->cid.cid_num);
+						ast_copy_string(runningapp, ast_get_extension_app(e), sizeof(runningapp));
+						ast_copy_string(runningdata, ast_get_extension_app_data(e), sizeof(runningdata));
+						ast_unlock_context(c);
+					}
+					break;
+				}
+			}
+		}
+		ast_unlock_contexts();
 
 		/* Reset the macro depth, if it was changed in the last iteration */
 		pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc);
@@ -306,15 +322,14 @@
 			}
 		}
 
-		ast_log(LOG_DEBUG, "Executed application: %s\n", ast_get_extension_app(e));
-
-		if (e && !strcasecmp(ast_get_extension_app(e), "GOSUB")) {
+		ast_log(LOG_DEBUG, "Executed application: %s\n", runningapp);
+
+		if (!strcasecmp(runningapp, "GOSUB")) {
 			gosub_level++;
 			ast_log(LOG_DEBUG, "Incrementing gosub_level\n");
-		} else if (e && !strcasecmp(ast_get_extension_app(e), "GOSUBIF")) {
-			const char *tmp = ast_get_extension_app_data(e);
+		} else if (!strcasecmp(runningapp, "GOSUBIF")) {
 			char tmp2[1024] = "", *cond, *app, *app2 = tmp2;
-			pbx_substitute_variables_helper(chan, tmp, tmp2, sizeof(tmp2) - 1);
+			pbx_substitute_variables_helper(chan, runningdata, tmp2, sizeof(tmp2) - 1);
 			cond = strsep(&app2, "?");
 			app = strsep(&app2, ":");
 			if (pbx_checkcondition(cond)) {
@@ -328,18 +343,17 @@
 					ast_log(LOG_DEBUG, "Incrementing gosub_level\n");
 				}
 			}
-		} else if (e && !strcasecmp(ast_get_extension_app(e), "RETURN")) {
+		} else if (!strcasecmp(runningapp, "RETURN")) {
 			gosub_level--;
 			ast_log(LOG_DEBUG, "Decrementing gosub_level\n");
-		} else if (e && !strcasecmp(ast_get_extension_app(e), "STACKPOP")) {
+		} else if (!strcasecmp(runningapp, "STACKPOP")) {
 			gosub_level--;
 			ast_log(LOG_DEBUG, "Decrementing gosub_level\n");
-		} else if (e && !strncasecmp(ast_get_extension_app(e), "EXEC", 4)) {
+		} else if (!strncasecmp(runningapp, "EXEC", 4)) {
 			/* Must evaluate args to find actual app */
-			const char *tmp = ast_get_extension_app_data(e);
 			char tmp2[1024] = "", *tmp3 = NULL;
-			pbx_substitute_variables_helper(chan, tmp, tmp2, sizeof(tmp2) - 1);
-			if (!strcasecmp(ast_get_extension_app(e), "EXECIF")) {
+			pbx_substitute_variables_helper(chan, runningdata, tmp2, sizeof(tmp2) - 1);
+			if (!strcasecmp(runningapp, "EXECIF")) {
 				tmp3 = strchr(tmp2, '|');
 				if (tmp3)
 					*tmp3++ = '\0';

Modified: team/oej/jitterbuffer-1.2/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/apps/app_voicemail.c?view=diff&rev=64192&r1=64191&r2=64192
==============================================================================
--- team/oej/jitterbuffer-1.2/apps/app_voicemail.c (original)
+++ team/oej/jitterbuffer-1.2/apps/app_voicemail.c Mon May 14 08:55:00 2007
@@ -5443,21 +5443,24 @@
 			}
 			break;
 		case '7':
-			vms.deleted[vms.curmsg] = !vms.deleted[vms.curmsg];
-			if (useadsi)
-				adsi_delete(chan, &vms);
-			if (vms.deleted[vms.curmsg]) 
-				cmd = ast_play_and_wait(chan, "vm-deleted");
-			else
-				cmd = ast_play_and_wait(chan, "vm-undeleted");
-			if (ast_test_flag((&globalflags), VM_SKIPAFTERCMD)) {
-				if (vms.curmsg < vms.lastmsg) {
-					vms.curmsg++;
-					cmd = play_message(chan, vmu, &vms);
-				} else {
-					cmd = ast_play_and_wait(chan, "vm-nomore");
+			if (vms.curmsg >= 0 && vms.curmsg <= vms.lastmsg) {
+				vms.deleted[vms.curmsg] = !vms.deleted[vms.curmsg];
+				if (useadsi)
+					adsi_delete(chan, &vms);
+				if (vms.deleted[vms.curmsg]) 
+					cmd = ast_play_and_wait(chan, "vm-deleted");
+				else
+					cmd = ast_play_and_wait(chan, "vm-undeleted");
+				if (ast_test_flag((&globalflags), VM_SKIPAFTERCMD)) {
+					if (vms.curmsg < vms.lastmsg) {
+						vms.curmsg++;
+						cmd = play_message(chan, vmu, &vms);
+					} else {
+						cmd = ast_play_and_wait(chan, "vm-nomore");
+					}
 				}
-			}
+			} else /* Delete not valid if we haven't selected a message */
+				cmd = 0;
 			break;
 	
 		case '8':

Modified: team/oej/jitterbuffer-1.2/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/asterisk.c?view=diff&rev=64192&r1=64191&r2=64192
==============================================================================
--- team/oej/jitterbuffer-1.2/asterisk.c (original)
+++ team/oej/jitterbuffer-1.2/asterisk.c Mon May 14 08:55:00 2007
@@ -135,7 +135,7 @@
 
 /*! \brief Welcome message when starting a CLI interface */
 #define WELCOME_MESSAGE \
-	ast_verbose("Asterisk " ASTERISK_VERSION ", Copyright (C) 1999 - 2006 Digium, Inc. and others.\n"); \
+	ast_verbose("Asterisk " ASTERISK_VERSION ", Copyright (C) 1999 - 2007 Digium, Inc. and others.\n"); \
 	ast_verbose("Created by Mark Spencer <markster at digium.com>\n"); \
 	ast_verbose("Asterisk comes with ABSOLUTELY NO WARRANTY; type 'show warranty' for details.\n"); \
 	ast_verbose("This is free software, with components licensed under the GNU General Public\n"); \

Modified: team/oej/jitterbuffer-1.2/cdr.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/cdr.c?view=diff&rev=64192&r1=64191&r2=64192
==============================================================================
--- team/oej/jitterbuffer-1.2/cdr.c (original)
+++ team/oej/jitterbuffer-1.2/cdr.c Mon May 14 08:55:00 2007
@@ -775,16 +775,18 @@
 
 			/* Copy account code et-al */	
 			ast_copy_string(cdr->accountcode, c->accountcode, sizeof(cdr->accountcode));
-			/* Destination information */
-			ast_copy_string(cdr->dst, (ast_strlen_zero(c->macroexten)) ? c->exten : c->macroexten, sizeof(cdr->dst));
-			ast_copy_string(cdr->dcontext, (ast_strlen_zero(c->macrocontext)) ? c->context : c->macrocontext, sizeof(cdr->dcontext));
+			if (!ast_check_hangup(c)) {
+				/* Destination information */ /* XXX privilege macro* ? */
+				ast_copy_string(cdr->dst, (ast_strlen_zero(c->macroexten)) ? c->exten : c->macroexten, sizeof(cdr->dst));
+				ast_copy_string(cdr->dcontext, (ast_strlen_zero(c->macrocontext)) ? c->context : c->macrocontext, sizeof(cdr->dcontext));
+			}
 		}
 		cdr = cdr->next;
 	}
 
 	return 0;
 }
-
+ 
 int ast_cdr_amaflags2int(const char *flag)
 {
 	if (!strcasecmp(flag, "default"))

Modified: team/oej/jitterbuffer-1.2/channel.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/channel.c?view=diff&rev=64192&r1=64191&r2=64192
==============================================================================
--- team/oej/jitterbuffer-1.2/channel.c (original)
+++ team/oej/jitterbuffer-1.2/channel.c Mon May 14 08:55:00 2007
@@ -958,6 +958,9 @@
 	/* Destroy the jitterbuffer */
 	ast_jb_destroy(chan);
 #endif /* AST_JB */
+
+	/* Drop out of the group counting radar */
+	ast_app_group_discard(chan);
 
 	free(chan);
 	ast_mutex_unlock(&chlock);
@@ -2925,22 +2928,6 @@
    
 static void clone_variables(struct ast_channel *original, struct ast_channel *clone)
 {
-	struct ast_var_t *varptr;
-
-	/* we need to remove all app_groupcount related variables from the original
-	   channel before merging in the clone's variables; any groups assigned to the
-	   original channel should be released, only those assigned to the clone
-	   should remain
-	*/
-
-	AST_LIST_TRAVERSE_SAFE_BEGIN(&original->varshead, varptr, entries) {
-		if (!strncmp(ast_var_name(varptr), GROUP_CATEGORY_PREFIX, strlen(GROUP_CATEGORY_PREFIX))) {
-			AST_LIST_REMOVE_CURRENT(&original->varshead, entries);
-			ast_var_delete(varptr);
-		}
-	}
-	AST_LIST_TRAVERSE_SAFE_END;
-
 	/* Append variables from clone channel into original channel */
 	/* XXX Is this always correct?  We have to in order to keep MACROS working XXX */
 	if (AST_LIST_FIRST(&clone->varshead))
@@ -3123,6 +3110,8 @@
 	for (x = 0; x < AST_MAX_FDS; x++) {
 		original->fds[x] = clone->fds[x];
 	}
+	/* Drop group from original */
+	ast_app_group_update(clone, original);
 	clone_variables(original, clone);
 	AST_LIST_HEAD_INIT_NOLOCK(&clone->varshead);
 	/* Presense of ADSI capable CPE follows clone */

Modified: team/oej/jitterbuffer-1.2/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/channels/chan_iax2.c?view=diff&rev=64192&r1=64191&r2=64192
==============================================================================
--- team/oej/jitterbuffer-1.2/channels/chan_iax2.c (original)
+++ team/oej/jitterbuffer-1.2/channels/chan_iax2.c Mon May 14 08:55:00 2007
@@ -324,8 +324,8 @@
 	char inkeys[80];				/*!< Key(s) this peer can use to authenticate to us */
 
 	/* Suggested caller id if registering */
-	char cid_num[AST_MAX_EXTENSION];		/*!< Default context (for transfer really) */
-	char cid_name[AST_MAX_EXTENSION];		/*!< Default context (for transfer really) */
+	char cid_num[AST_MAX_EXTENSION];
+	char cid_name[AST_MAX_EXTENSION];
 	
 	int expire;					/*!< Schedule entry for expiry */
 	int expiry;					/*!< How soon to expire */
@@ -2566,7 +2566,8 @@
 	iaxq.count++;
 	ast_mutex_unlock(&iaxq.lock);
 	/* Wake up the network thread */
-	pthread_kill(netthreadid, SIGURG);
+	if (netthreadid != AST_PTHREADT_NULL)
+		pthread_kill(netthreadid, SIGURG);
 	return 0;
 }
 
@@ -3167,8 +3168,12 @@
 
 static struct ast_frame *iax2_read(struct ast_channel *c) 
 {
-	ast_log(LOG_NOTICE, "I should never be called! Hanging up.\n");
-	return NULL;
+	static struct ast_frame null_frame = {
+		AST_FRAME_NULL,
+	};
+
+	ast_log(LOG_NOTICE, "I should never be called!\n");
+	return &null_frame;
 }
 
 static int iax2_start_transfer(unsigned short callno0, unsigned short callno1)
@@ -6730,6 +6735,13 @@
 			ast_log(LOG_WARNING, "midget packet received (%d of %zd min)\n", res, sizeof(*fh));
 			ast_mutex_unlock(&iaxsl[fr->callno]);
 			return 1;
+		}
+		/* Ensure text frames are NULL-terminated */
+		if (f.frametype == AST_FRAME_TEXT && buf[res - 1] != '\0') {
+			if (res < sizeof(buf))
+				buf[res++] = '\0';
+			else /* Trims one character from the text message, but that's better than overwriting the end of the buffer. */
+				buf[res - 1] = '\0';
 		}
 		f.datalen = res - sizeof(*fh);
 
@@ -8327,6 +8339,9 @@
 		peer->pokefreqnotok = DEFAULT_FREQ_NOTOK;
 		peer->context[0] = '\0';
 		peer->peercontext[0] = '\0';
+		ast_clear_flag(peer, IAX_HASCALLERID);
+		peer->cid_name[0] = '\0';
+		peer->cid_num[0] = '\0';
 		while(v) {
 			if (!strcasecmp(v->name, "secret")) {
 				ast_copy_string(peer->secret, v->value, sizeof(peer->secret));
@@ -8412,9 +8427,15 @@
 			} else if (!strcasecmp(v->name, "disallow")) {
 				ast_parse_allow_disallow(&peer->prefs, &peer->capability, v->value, 0);
 			} else if (!strcasecmp(v->name, "callerid")) {
-				ast_callerid_split(v->value, peer->cid_name, sizeof(peer->cid_name),
+				if (!ast_strlen_zero(v->value)) {
+					ast_callerid_split(v->value, peer->cid_name, sizeof(peer->cid_name),
 									peer->cid_num, sizeof(peer->cid_num));
-				ast_set_flag(peer, IAX_HASCALLERID);	
+					ast_set_flag(peer, IAX_HASCALLERID);
+				} else {
+					ast_clear_flag(peer, IAX_HASCALLERID);
+					peer->cid_name[0] = '\0';
+					peer->cid_num[0] = '\0';
+				}
 			} else if (!strcasecmp(v->name, "sendani")) {
 				ast_set2_flag(peer, ast_true(v->value), IAX_SENDANI);	
 			} else if (!strcasecmp(v->name, "inkeys")) {
@@ -8513,6 +8534,9 @@
 		ast_copy_string(user->name, name, sizeof(user->name));
 		ast_copy_string(user->language, language, sizeof(user->language));
 		ast_copy_flags(user, &globalflags, IAX_USEJITTERBUF | IAX_FORCEJITTERBUF | IAX_CODEC_USER_FIRST | IAX_CODEC_NOPREFS | IAX_CODEC_NOCAP);	
+		ast_clear_flag(user, IAX_HASCALLERID);
+		user->cid_num[0] = '\0';
+		user->cid_name[0] = '\0';
 		while(v) {
 			if (!strcasecmp(v->name, "context")) {
 				con = build_context(v->value);
@@ -8574,8 +8598,14 @@
 				} else
 					ast_copy_string(user->secret, v->value, sizeof(user->secret));
 			} else if (!strcasecmp(v->name, "callerid")) {
-				ast_callerid_split(v->value, user->cid_name, sizeof(user->cid_name), user->cid_num, sizeof(user->cid_num));
-				ast_set_flag(user, IAX_HASCALLERID);	
+				if (!ast_strlen_zero(v->value)) {
+					ast_callerid_split(v->value, user->cid_name, sizeof(user->cid_name), user->cid_num, sizeof(user->cid_num));
+					ast_set_flag(user, IAX_HASCALLERID);
+				} else {
+					ast_clear_flag(user, IAX_HASCALLERID);
+					user->cid_name[0] = '\0';
+					user->cid_num[0] = '\0';
+				}
 			} else if (!strcasecmp(v->name, "accountcode")) {
 				ast_copy_string(user->accountcode, v->value, sizeof(user->accountcode));
 			} else if (!strcasecmp(v->name, "language")) {

Modified: team/oej/jitterbuffer-1.2/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/channels/chan_misdn.c?view=diff&rev=64192&r1=64191&r2=64192
==============================================================================
--- team/oej/jitterbuffer-1.2/channels/chan_misdn.c (original)
+++ team/oej/jitterbuffer-1.2/channels/chan_misdn.c Mon May 14 08:55:00 2007
@@ -320,6 +320,7 @@
 static int stop_bc_tones(struct chan_list *cl);
 static void release_chan(struct misdn_bchannel *bc);
 
+static int misdn_check_l2l1(struct ast_channel *chan, void *data);
 static int misdn_set_opt_exec(struct ast_channel *chan, void *data);
 static int misdn_facility_exec(struct ast_channel *chan, void *data);
 
@@ -1709,8 +1710,7 @@
 	}
 	
 	port=newbc->port;
-	strncpy(newbc->dad,ext,sizeof( newbc->dad));
-	strncpy(ast->exten,ext,sizeof(ast->exten));
+
 	
 	chan_misdn_log(1, port, "* CALL: %s\n",dest);
 	
@@ -1719,7 +1719,10 @@
 	chan_misdn_log(3, port, " --> * adding2newbc ext %s\n",ast->exten);
 	if (ast->exten) {
 		int l = sizeof(newbc->dad);
-		strncpy(newbc->dad,ast->exten, l);
+		strncpy(ast->exten,ext,sizeof(ast->exten));
+
+		strncpy(newbc->dad,ext,l);
+
 		newbc->dad[l-1] = 0;
 	}
 	newbc->rad[0]=0;
@@ -1732,7 +1735,7 @@
 			newbc->oad[l-1] = 0;
 		}
 	}
-	
+
 	{
 		struct chan_list *ch=MISDN_ASTERISK_TECH_PVT(ast);
 		if (!ch) { ast_verbose("No chan_list in misdn_call\n"); return -1;}
@@ -2308,7 +2311,11 @@
 
 	if ( !frame->samples ) {
 		chan_misdn_log(4, ch->bc->port, "misdn_write: zero write\n");
-		return 0;
+		if (ch->state == MISDN_WAITING4DIGS) {
+			chan_misdn_log(4, ch->bc->port, "misdn_write: WAIT4DIGS ..\n");
+			return 0;
+		}
+		return -1;
 	}
 
 	if ( ! ch->bc->addr ) {
@@ -2678,8 +2685,6 @@
 				}
 			} while (!newbc && robin_channel != rr->channel);
 			
-			if (!newbc)
-				chan_misdn_log(-1, port, " Failed! No free channel in group %d!", group);
 		} else {		
 			for (port=misdn_cfg_get_next_port(0); port > 0;
 				 port=misdn_cfg_get_next_port(port)) {
@@ -2703,16 +2708,27 @@
 				}
 			}
 		}
-	} else {
+		
+		/* Group dial failed ?*/
+		if (!newbc) {
+			ast_log(LOG_WARNING, 
+					"Could not Dial out on group '%s'.\n"
+					"\tEither the L2 and L1 on all of these ports where DOWN (see 'show application misdn_check_l2l1')\n"
+					"\tOr there was no free channel on none of the ports\n\n"
+					, group);
+			return NULL;
+		}
+	} else { /* 'Normal' Port dial * Port dial */
 		if (channel)
 			chan_misdn_log(1, port," --> preselected_channel: %d\n",channel);
 		newbc = misdn_lib_get_free_bc(port, channel, 0, dec);
-	}
-	
-	if (!newbc) {
-		chan_misdn_log(-1, 0, "Could not create channel on port:%d with extensions:%s\n",port,ext);
-		return NULL;
-	}
+
+		if (!newbc) {
+			ast_log(LOG_WARNING, "Could not create channel on port:%d with extensions:%s\n",port,ext);
+			return NULL;
+		}
+	}
+	
 
 	/* create ast_channel and link all the objects together */
 	cl->bc=newbc;
@@ -3279,6 +3295,14 @@
 	if (tmp && (atoi(tmp) == 1)) {
 		bc->sending_complete=1;
 	}
+	
+	const char *kp=pbx_builtin_getvar_helper(chan,"MISDN_KEYPAD");
+	if (kp) {
+		strncpy(bc->keypad,kp,sizeof(bc->keypad));
+		bc->keypad[sizeof(bc->keypad)-1]=0;
+	}
+	
+	
 }
  
 void export_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_list *ch)
@@ -3298,6 +3322,9 @@
 		sprintf(tmp,"%d",bc->urate);
 		pbx_builtin_setvar_helper(chan,"MISDN_URATE",tmp);
 	}
+
+	if (bc->keypad[0]) 
+		pbx_builtin_setvar_helper(chan,"MISDN_KEYPAD",bc->keypad);
 }
 
 
@@ -3768,6 +3795,7 @@
 				
 				/** ADD IGNOREPAT **/
 				
+				ch->state=MISDN_WAITING4DIGS;
 				int stop_tone;
 				misdn_cfg_get( 0, MISDN_GEN_STOP_TONE, &stop_tone, sizeof(int));
 				if ( (!ast_strlen_zero(bc->dad)) && stop_tone ) 
@@ -3776,7 +3804,6 @@
 					dialtone_indicate(ch);
 				}
 				
-				ch->state=MISDN_WAITING4DIGS;
 			}
 		}
       
@@ -3972,9 +3999,11 @@
 
 		stop_bc_tones(ch);
 		hangup_chan(ch);
-		release_chan(bc);
+
 		if(ch)	
 			ch->state=MISDN_CLEANING;
+
+		release_chan(bc);
 	}
 	break;
 	case EVENT_BCHAN_ERROR:
@@ -4376,6 +4405,24 @@
 				 "Supported Facilities are:\n"
 				 "\n"
 				 "type=calldeflect args=Nr where to deflect\n"
+		);
+
+
+	ast_register_application("misdn_check_l2l1", misdn_check_l2l1, "misdn_check_l2l1",
+				 "misdn_check_l2l1(<port>||g:<groupname>,timeout)"
+				 "Checks if the L2 and L1 are up on either the given <port> or\n"
+				 "on the ports in the group with <groupname>\n"
+				 "If the L1/L2 are down, check_l2l1 gets up the L1/L2 and waits\n"
+				 "for <timeout> seconds that this happens. Otherwise, nothing happens\n"
+				 "\n"
+				 "This application, ensures the L1/L2 state of the Ports in a group\n"
+				 "it is intended to make the pmp_l1_check option redundant and to\n"
+				 "fix a buggy switch config from your provider\n"
+				 "\n"
+				 "a sample dialplan would look like:\n\n"
+				 "exten => _X.,1,misdn_check_l2l1(g:out|2)\n"
+				 "exten => _X.,n,dial(mISDN/g:out/${EXTEN})\n"
+				 "\n"
 		);
 
 
@@ -4421,6 +4468,7 @@
 	/* ast_unregister_application("misdn_crypt"); */
 	ast_unregister_application("misdn_set_opt");
 	ast_unregister_application("misdn_facility");
+	ast_unregister_application("misdn_check_l2l1");
   
 	ast_channel_unregister(&misdn_tech);
 
@@ -4509,6 +4557,86 @@
 	
 }
 
+static int misdn_check_l2l1(struct ast_channel *chan, void *data)
+{
+	if (strcasecmp(chan->tech->type,"mISDN")) {
+		ast_log(LOG_WARNING, "misdn_check_l2l1 makes only sense with chan_misdn channels!\n");
+		return -1;
+	}
+
+	AST_DECLARE_APP_ARGS(args,
+			AST_APP_ARG(grouppar);
+			AST_APP_ARG(timeout);
+	);
+
+	if (ast_strlen_zero((char *)data)) {
+		ast_log(LOG_WARNING, "misdn_check_l2l1 Requires arguments\n");
+		return -1;
+	}
+
+	AST_STANDARD_APP_ARGS(args, data);
+
+	if (args.argc != 2) {
+		ast_log(LOG_WARNING, "Wrong argument count\n");
+		return 0;
+	}
+
+	/*ast_log(LOG_NOTICE, "Arguments: group/port '%s' timeout '%s'\n", args.grouppar, args.timeout);*/
+	char group[BUFFERSIZE+1];
+	char *port_str;
+
+	int port=0;
+	int timeout=atoi(args.timeout);
+	int dowait=0;
+
+	port_str=args.grouppar;
+
+	int port_up;
+	if (port_str[0]=='g' && port_str[1]==':' ) {
+		/* We make a group call lets checkout which ports are in my group */
+		port_str += 2;
+		strncpy(group, port_str, BUFFERSIZE);
+		group[BUFFERSIZE-1] = 0;
+		chan_misdn_log(2, 0, "Checking Ports in group: %s\n",group);
+
+		for (	port = misdn_cfg_get_next_port(port); 
+			port > 0;
+			port = misdn_cfg_get_next_port(port)) {
+			
+			chan_misdn_log(2,0,"trying port %d\n",port);
+
+			char cfg_group[BUFFERSIZE+1];
+			misdn_cfg_get(port, MISDN_CFG_GROUPNAME, cfg_group, BUFFERSIZE);
+
+			if (!strcasecmp(cfg_group, group)) {
+				port_up = misdn_lib_port_up(port, 1);
+
+				if (!port_up) {
+					chan_misdn_log(2, 0, " --> port '%d'\n", port);
+					misdn_lib_get_port_up(port);
+					dowait=1;
+				}
+			}
+		}
+
+	} else {
+		port = atoi(port_str);
+		chan_misdn_log(2, 0, "Checking Port: %d\n",port);
+		port_up = misdn_lib_port_up(port, 1);
+		if (!port_up) {
+			misdn_lib_get_port_up(port);
+			dowait=1;
+		}
+
+	}
+
+	if (dowait) {
+		chan_misdn_log(2, 0, "Waiting for '%d' seconds\n",timeout);
+		sleep(timeout);
+	}
+
+	return 0;
+}
 
 static int misdn_set_opt_exec(struct ast_channel *chan, void *data)
 {

Modified: team/oej/jitterbuffer-1.2/channels/chan_modem.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/channels/chan_modem.c?view=diff&rev=64192&r1=64191&r2=64192
==============================================================================
--- team/oej/jitterbuffer-1.2/channels/chan_modem.c (original)
+++ team/oej/jitterbuffer-1.2/channels/chan_modem.c Mon May 14 08:55:00 2007
@@ -717,8 +717,8 @@
 		return -1;
 	}
 	if (monitor_thread != AST_PTHREADT_NULL) {
+		/* Wake up the thread */
 		pthread_kill(monitor_thread, SIGURG);
-		pthread_join(monitor_thread, NULL);
 	} else {
 		/* Start a new monitor */
 		if (ast_pthread_create(&monitor_thread, NULL, do_monitor, NULL) < 0) {

Modified: team/oej/jitterbuffer-1.2/channels/chan_phone.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/channels/chan_phone.c?view=diff&rev=64192&r1=64191&r2=64192
==============================================================================
--- team/oej/jitterbuffer-1.2/channels/chan_phone.c (original)
+++ team/oej/jitterbuffer-1.2/channels/chan_phone.c Mon May 14 08:55:00 2007
@@ -1092,10 +1092,8 @@
 		  ast_log(LOG_WARNING, "Unable to lock the interface list\n");
 		  return -1;
 		}
+		/* Wake up the thread */
 		pthread_cancel(monitor_thread);
-#if 0
-		pthread_join(monitor_thread, NULL);
-#endif
 		ast_mutex_unlock(&iflock);
 	}
 	/* Start a new monitor */

Modified: team/oej/jitterbuffer-1.2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/channels/chan_sip.c?view=diff&rev=64192&r1=64191&r2=64192
==============================================================================
--- team/oej/jitterbuffer-1.2/channels/chan_sip.c (original)
+++ team/oej/jitterbuffer-1.2/channels/chan_sip.c Mon May 14 08:55:00 2007
@@ -4750,6 +4750,8 @@
 		dst->header[x] += offset;
 	for (x=0; x < src->lines; x++)
 		dst->line[x] += offset;
+	dst->rlPart1 += offset;
+	dst->rlPart2 += offset;
 }
 
 /*! \brief  transmit_response_with_sdp: Used for 200 OK and 183 early media ---*/
@@ -5261,11 +5263,14 @@
 	
 	/* Check which device/devices we are watching  and if they are registered */
 	if (ast_get_hint(hint, sizeof(hint), NULL, 0, NULL, p->context, p->exten)) {
-		/* If they are not registered, we will override notification and show no availability */
-		if (ast_device_state(hint) == AST_DEVICE_UNAVAILABLE) {
-			local_state = NOTIFY_CLOSED;
-			pidfstate = "away";
-			pidfnote = "Not online";
+		char *hint2 = hint, *individual_hint = NULL;
+		while ((individual_hint = strsep(&hint2, "&"))) {
+			/* If they are not registered, we will override notification and show no availability */
+			if (ast_device_state(individual_hint) == AST_DEVICE_UNAVAILABLE) {
+				local_state = NOTIFY_CLOSED;
+				pidfstate = "away";
+				pidfnote = "Not online";
+			}
 		}
 	}
 
@@ -5978,6 +5983,7 @@
 		ast_sched_del(sched, peer->expire);
 	peer->expire = ast_sched_add(sched, (expiry + 10) * 1000, expire_register, peer);
 	register_peer_exten(peer, 1);
+	ast_device_state_changed("SIP/%s", peer->name);
 }
 
 /*! \brief  parse_ok_contact: Parse contact header for 200 OK on INVITE ---*/
@@ -7371,6 +7377,7 @@
 				p->noncodeccapability |= AST_RTP_DTMF;
 			else
 				p->noncodeccapability &= ~AST_RTP_DTMF;
+			p->jointnoncodeccapability = p->noncodeccapability;
 		}
 		if (user && debug)
 			ast_verbose("Found user '%s'\n", user->name);
@@ -7480,6 +7487,7 @@
 					p->noncodeccapability |= AST_RTP_DTMF;
 				else
 					p->noncodeccapability &= ~AST_RTP_DTMF;
+				p->jointnoncodeccapability = p->noncodeccapability;
 			}
 			ASTOBJ_UNREF(peer,sip_destroy_peer);
 		} else { 
@@ -11587,6 +11595,10 @@
 	/* Called with peerl lock, but releases it */
 	struct sip_pvt *p;
 	int newmsgs, oldmsgs;
+
+	/* Do we have an IP address? If not, skip this peer */
+	if (!peer->addr.sin_addr.s_addr && !peer->defaddr.sin_addr.s_addr) 
+		return 0;
 
 	/* Check for messages */
 	ast_app_messagecount(peer->mailbox, &newmsgs, &oldmsgs);
@@ -13018,6 +13030,7 @@
 				if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) {
 					peer = build_peer(cat, ast_variable_browse(cfg, cat), 0);
 					if (peer) {
+						ast_device_state_changed("SIP/%s", peer->name);
 						ASTOBJ_CONTAINER_LINK(&peerl,peer);
 						ASTOBJ_UNREF(peer, sip_destroy_peer);
 					}

Modified: team/oej/jitterbuffer-1.2/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer-1.2/channels/chan_zap.c?view=diff&rev=64192&r1=64191&r2=64192
==============================================================================
--- team/oej/jitterbuffer-1.2/channels/chan_zap.c (original)
+++ team/oej/jitterbuffer-1.2/channels/chan_zap.c Mon May 14 08:55:00 2007
@@ -5207,28 +5207,30 @@
 		i->subs[index].linear = 0;
 		zt_setlinear(i->subs[index].zfd, i->subs[index].linear);
 		features = 0;
-		if (i->busydetect && CANBUSYDETECT(i)) {
-			features |= DSP_FEATURE_BUSY_DETECT;
-		}
-		if ((i->callprogress & 1) && CANPROGRESSDETECT(i)) {
-			features |= DSP_FEATURE_CALL_PROGRESS;
-		}
-		if ((!i->outgoing && (i->callprogress & 4)) || 
-		    (i->outgoing && (i->callprogress & 2))) {
-			features |= DSP_FEATURE_FAX_DETECT;
-		}
+		if (index == SUB_REAL) {
+			if (i->busydetect && CANBUSYDETECT(i)) {
+				features |= DSP_FEATURE_BUSY_DETECT;
+			}
+			if ((i->callprogress & 1) && CANPROGRESSDETECT(i)) {
+				features |= DSP_FEATURE_CALL_PROGRESS;
+			}
+			if ((!i->outgoing && (i->callprogress & 4)) || 
+			    (i->outgoing && (i->callprogress & 2))) {
+				features |= DSP_FEATURE_FAX_DETECT;
+			}
 #ifdef ZT_TONEDETECT
-		x = ZT_TONEDETECT_ON | ZT_TONEDETECT_MUTE;
-		if (ioctl(i->subs[index].zfd, ZT_TONEDETECT, &x)) {
+			x = ZT_TONEDETECT_ON | ZT_TONEDETECT_MUTE;
+			if (ioctl(i->subs[index].zfd, ZT_TONEDETECT, &x)) {
 #endif		
-			i->hardwaredtmf = 0;
-			features |= DSP_FEATURE_DTMF_DETECT;
+				i->hardwaredtmf = 0;
+				features |= DSP_FEATURE_DTMF_DETECT;
 #ifdef ZT_TONEDETECT
-		} else if (NEED_MFDETECT(i)) {
-			i->hardwaredtmf = 1;
-			features |= DSP_FEATURE_DTMF_DETECT;
-		}
-#endif
+			} else if (NEED_MFDETECT(i)) {
+				i->hardwaredtmf = 1;
+				features |= DSP_FEATURE_DTMF_DETECT;
+			}
+#endif
+		}
 		if (features) {
 			if (i->dsp) {
 				ast_log(LOG_DEBUG, "Already have a dsp on %s?\n", tmp->name);
@@ -5297,7 +5299,7 @@
 		if (!ast_strlen_zero(i->cid_name))
 			tmp->cid.cid_name = strdup(i->cid_name);
 		if (!ast_strlen_zero(i->cid_ani))
-			tmp->cid.cid_ani = strdup(i->cid_num);
+			tmp->cid.cid_ani = strdup(i->cid_ani);
 		else if (!ast_strlen_zero(i->cid_num))	
 			tmp->cid.cid_ani = strdup(i->cid_num);
 #else
@@ -5412,6 +5414,16 @@
 	int len = 0;
 	int res;
 	int index;
+
+	/* in the bizarre case where the channel has become a zombie before we
+	   even get started here, abort safely
+	*/
+	if (!p) {
+		ast_log(LOG_WARNING, "Channel became a zombie before simple switch could be started (%s)\n", chan->name);
+		ast_hangup(chan);
+		return NULL;
+	}
+
 	if (option_verbose > 2) 
 		ast_verbose( VERBOSE_PREFIX_3 "Starting simple switch on '%s'\n", chan->name);
 	index = zt_get_index(chan, p, 1);
@@ -6859,14 +6871,8 @@
 		return -1;
 	}
 	if (monitor_thread != AST_PTHREADT_NULL) {
-		/* Just signal it to be sure it wakes up */
-#if 0
-		pthread_cancel(monitor_thread);
-#endif
+		/* Wake up the thread */
 		pthread_kill(monitor_thread, SIGURG);
-#if 0
-		pthread_join(monitor_thread, NULL);
-#endif
 	} else {
 		/* Start a new monitor */
 		if (ast_pthread_create(&monitor_thread, &attr, do_monitor, NULL) < 0) {
@@ -9018,25 +9024,17 @@

[... 831 lines stripped ...]


More information about the asterisk-commits mailing list