[asterisk-commits] oej: branch oej/moremanager r61826 - in /team/oej/moremanager: ./ channels/ f...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Apr 25 13:05:32 MST 2007


Author: oej
Date: Wed Apr 25 15:05:31 2007
New Revision: 61826

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

Modified:
    team/oej/moremanager/   (props changed)
    team/oej/moremanager/channels/chan_sip.c
    team/oej/moremanager/channels/chan_zap.c
    team/oej/moremanager/funcs/func_groupcount.c
    team/oej/moremanager/include/asterisk/app.h
    team/oej/moremanager/include/asterisk/channel.h
    team/oej/moremanager/main/app.c
    team/oej/moremanager/main/channel.c
    team/oej/moremanager/main/cli.c
    team/oej/moremanager/main/dial.c
    team/oej/moremanager/main/manager.c
    team/oej/moremanager/main/pbx.c

Propchange: team/oej/moremanager/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: team/oej/moremanager/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Apr 25 15:05:31 2007
@@ -1,1 +1,1 @@
-/branches/1.4:1-61754
+/branches/1.4:1-61822

Modified: team/oej/moremanager/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/moremanager/channels/chan_sip.c?view=diff&rev=61826&r1=61825&r2=61826
==============================================================================
--- team/oej/moremanager/channels/chan_sip.c (original)
+++ team/oej/moremanager/channels/chan_sip.c Wed Apr 25 15:05:31 2007
@@ -9124,6 +9124,7 @@
 				p->noncodeccapability |= AST_RTP_DTMF;
 			else
 				p->noncodeccapability &= ~AST_RTP_DTMF;
+			p->jointnoncodeccapability = p->noncodeccapability;
 			if (p->t38.peercapability)
 				p->t38.jointcapability &= p->t38.peercapability;
 			p->maxcallbitrate = user->maxcallbitrate;
@@ -9257,6 +9258,7 @@
 					p->noncodeccapability |= AST_RTP_DTMF;
 				else
 					p->noncodeccapability &= ~AST_RTP_DTMF;
+				p->jointnoncodeccapability = p->noncodeccapability;
 				if (p->t38.peercapability)
 					p->t38.jointcapability &= p->t38.peercapability;
 			}

Modified: team/oej/moremanager/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/oej/moremanager/channels/chan_zap.c?view=diff&rev=61826&r1=61825&r2=61826
==============================================================================
--- team/oej/moremanager/channels/chan_zap.c (original)
+++ team/oej/moremanager/channels/chan_zap.c Wed Apr 25 15:05:31 2007
@@ -5298,7 +5298,7 @@
 	tmp->cid.cid_num = ast_strdup(i->cid_num);
 	tmp->cid.cid_name = ast_strdup(i->cid_name);
 	if (!ast_strlen_zero(i->cid_ani))
-		tmp->cid.cid_ani = ast_strdup(i->cid_num);
+		tmp->cid.cid_ani = ast_strdup(i->cid_ani);
 	else	
 		tmp->cid.cid_ani = ast_strdup(i->cid_num);
 #else
@@ -6932,14 +6932,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_background(&monitor_thread, &attr, do_monitor, NULL) < 0) {

Modified: team/oej/moremanager/funcs/func_groupcount.c
URL: http://svn.digium.com/view/asterisk/team/oej/moremanager/funcs/func_groupcount.c?view=diff&rev=61826&r1=61825&r2=61826
==============================================================================
--- team/oej/moremanager/funcs/func_groupcount.c (original)
+++ team/oej/moremanager/funcs/func_groupcount.c Wed Apr 25 15:05:31 2007
@@ -39,24 +39,16 @@
 static int group_count_function_read(struct ast_channel *chan, char *cmd,
 				     char *data, char *buf, size_t len)
 {
-	int count;
-	char group[80] = "";
-	char category[80] = "";
-	const char *grp;
+	int count = -1;
+	char group[80] = "", category[80] = "";
 
 	ast_app_group_split_group(data, group, sizeof(group), category,
 				  sizeof(category));
 
-	if (ast_strlen_zero(group)) {
-		if ((grp = pbx_builtin_getvar_helper(chan, category)))
-			ast_copy_string(group, grp, sizeof(group));
-		else
-			ast_log(LOG_NOTICE, "No group could be found for channel '%s'\n",
-				chan->name);
-	}
-
-	count = ast_app_group_get_count(group, category);
-	snprintf(buf, len, "%d", count);
+	if ((count = ast_app_group_get_count(group, category)) == -1)
+		ast_log(LOG_NOTICE, "No group could be found for channel '%s'\n", chan->name);
+        else
+		snprintf(buf, len, "%d", count);
 
 	return 0;
 }
@@ -105,20 +97,26 @@
 static int group_function_read(struct ast_channel *chan, char *cmd,
 			       char *data, char *buf, size_t len)
 {
-	char varname[256];
-	const char *group;
-
-	if (!ast_strlen_zero(data)) {
-		snprintf(varname, sizeof(varname), "%s_%s", GROUP_CATEGORY_PREFIX,
-			 data);
-	} else {
-		ast_copy_string(varname, GROUP_CATEGORY_PREFIX, sizeof(varname));
-	}
-
-	group = pbx_builtin_getvar_helper(chan, varname);
-	if (group)
-		ast_copy_string(buf, group, len);
-
+	struct ast_group_info *gi = NULL;
+	
+	ast_app_group_list_lock();
+	
+	gi = ast_app_group_list_head();
+	while (gi) {
+		if (gi->chan != chan)
+			continue;
+		if (ast_strlen_zero(data))
+			break;
+		if (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, data))
+			break;
+		gi = AST_LIST_NEXT(gi, list);
+	}
+	
+	if (gi)
+		ast_copy_string(buf, gi->group, len);
+	
+	ast_app_group_list_unlock();
+	
 	return 0;
 }
 
@@ -152,38 +150,36 @@
 static int group_list_function_read(struct ast_channel *chan, char *cmd,
 				    char *data, char *buf, size_t len)
 {
-	struct ast_var_t *current;
-	struct varshead *headp;
+	struct ast_group_info *gi = NULL;
 	char tmp1[1024] = "";
 	char tmp2[1024] = "";
 
 	if (!chan)
 		return -1;
 
-	headp = &chan->varshead;
-	AST_LIST_TRAVERSE(headp, current, entries) {
-		if (!strncmp(ast_var_name(current), GROUP_CATEGORY_PREFIX "_", strlen(GROUP_CATEGORY_PREFIX) + 1)) {
-			if (!ast_strlen_zero(tmp1)) {
-				ast_copy_string(tmp2, tmp1, sizeof(tmp2));
-				snprintf(tmp1, sizeof(tmp1), "%s %s@%s", tmp2,
-					 ast_var_value(current),
-					 (ast_var_name(current) +
-					  strlen(GROUP_CATEGORY_PREFIX) + 1));
-			} else {
-				snprintf(tmp1, sizeof(tmp1), "%s@%s", ast_var_value(current),
-					 (ast_var_name(current) +
-					  strlen(GROUP_CATEGORY_PREFIX) + 1));
-			}
-		} else if (!strcmp(ast_var_name(current), GROUP_CATEGORY_PREFIX)) {
-			if (!ast_strlen_zero(tmp1)) {
-				ast_copy_string(tmp2, tmp1, sizeof(tmp2));
-				snprintf(tmp1, sizeof(tmp1), "%s %s", tmp2,
-					 ast_var_value(current));
-			} else {
-				snprintf(tmp1, sizeof(tmp1), "%s", ast_var_value(current));
-			}
+	ast_app_group_list_lock();
+
+	gi = ast_app_group_list_head();
+	while (gi) {
+		if (gi->chan != chan)
+			continue;
+		if (!ast_strlen_zero(tmp1)) {
+			ast_copy_string(tmp2, tmp1, sizeof(tmp2));
+			if (!ast_strlen_zero(gi->category))
+				snprintf(tmp1, sizeof(tmp1), "%s %s@%s", tmp2, gi->group, gi->category);
+                        else
+				snprintf(tmp1, sizeof(tmp1), "%s %s", tmp2, gi->group);
+		} else {
+			if (!ast_strlen_zero(gi->category))
+				snprintf(tmp1, sizeof(tmp1), "%s@%s", gi->group, gi->category);
+                        else
+				snprintf(tmp1, sizeof(tmp1), "%s", gi->group);
 		}
-	}
+		gi = AST_LIST_NEXT(gi, list);
+	}
+	
+	ast_app_group_list_unlock();
+
 	ast_copy_string(buf, tmp1, len);
 
 	return 0;

Modified: team/oej/moremanager/include/asterisk/app.h
URL: http://svn.digium.com/view/asterisk/team/oej/moremanager/include/asterisk/app.h?view=diff&rev=61826&r1=61825&r2=61826
==============================================================================
--- team/oej/moremanager/include/asterisk/app.h (original)
+++ team/oej/moremanager/include/asterisk/app.h Wed Apr 25 15:05:31 2007
@@ -203,7 +203,12 @@
 /*! Read a file into asterisk*/
 char *ast_read_textfile(const char *file);
 
-#define GROUP_CATEGORY_PREFIX "GROUP"
+struct ast_group_info {
+	struct ast_channel *chan;
+	char *category;
+	char *group;
+	AST_LIST_ENTRY(ast_group_info) list;
+};
 
 /*! Split a group string into group and category, returning a default category if none is provided. */
 int ast_app_group_split_group(const char *data, char *group, int group_max, char *category, int category_max);
@@ -216,6 +221,18 @@
 
 /*! Get the current channel count of all groups that match the specified pattern and category. */
 int ast_app_group_match_get_count(const char *groupmatch, const char *category);
+
+/*! Discard all group counting for a channel */
+int ast_app_group_discard(struct ast_channel *chan);
+
+/*! Lock the group count list */
+int ast_app_group_list_lock(void);
+
+/*! Get the head of the group count list */
+struct ast_group_info *ast_app_group_list_head(void);
+
+/*! Unlock the group count list */
+int ast_app_group_list_unlock(void);
 
 /*!
   \brief Define an application argument

Modified: team/oej/moremanager/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/oej/moremanager/include/asterisk/channel.h?view=diff&rev=61826&r1=61825&r2=61826
==============================================================================
--- team/oej/moremanager/include/asterisk/channel.h (original)
+++ team/oej/moremanager/include/asterisk/channel.h Wed Apr 25 15:05:31 2007
@@ -428,7 +428,7 @@
 
 	char emulate_dtmf_digit;			/*!< Digit being emulated */
 	unsigned int emulate_dtmf_duration;	/*!< Number of ms left to emulate DTMF for */
-	struct timeval dtmf_begin_tv;       /*!< The time that an in process digit began */
+	struct timeval dtmf_tv;       /*!< The time that an in process digit began, or the last digit ended */
 
 	/*! \brief Data stores on the channel */
 	AST_LIST_HEAD_NOLOCK(datastores, ast_datastore) datastores;

Modified: team/oej/moremanager/main/app.c
URL: http://svn.digium.com/view/asterisk/team/oej/moremanager/main/app.c?view=diff&rev=61826&r1=61825&r2=61826
==============================================================================
--- team/oej/moremanager/main/app.c (original)
+++ team/oej/moremanager/main/app.c Wed Apr 25 15:05:31 2007
@@ -49,9 +49,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' 
@@ -782,61 +784,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, const 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(const char *group, const char *category)
 {
-	struct ast_channel *chan;
+	struct ast_group_info *gi = NULL;
 	int count = 0;
-	const char *test;
-	char cat[80];
-	const char *s;
 
 	if (ast_strlen_zero(group))
 		return 0;
-
- 	s = S_OR(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_channel_unlock(chan);
-	}
+	
+	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(const char *groupmatch, const char *category)
 {
+	struct ast_group_info *gi = NULL;
 	regex_t regexbuf;
-	struct ast_channel *chan;
 	int count = 0;
-	const char *test;
-	char cat[80];
-	const char *s;
 
 	if (ast_strlen_zero(groupmatch))
 		return 0;
@@ -845,20 +860,48 @@
 	if (regcomp(&regexbuf, groupmatch, REG_EXTENDED | REG_NOSUB))
 		return 0;
 
-	s = S_OR(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_channel_unlock(chan);
-	}
+	}
+	AST_LIST_UNLOCK(&groups);
 
 	regfree(&regexbuf);
 
 	return count;
+}
+
+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/moremanager/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/oej/moremanager/main/channel.c?view=diff&rev=61826&r1=61825&r2=61826
==============================================================================
--- team/oej/moremanager/main/channel.c (original)
+++ team/oej/moremanager/main/channel.c Wed Apr 25 15:05:31 2007
@@ -104,8 +104,16 @@
 AST_THREADSTORAGE(state2str_threadbuf, state2str_threadbuf_init);
 #define STATE2STR_BUFSIZE   32
 
-/*! 100ms */
+/*! Default amount of time to use when emulating a digit as a begin and end 
+ *  100ms */
 #define AST_DEFAULT_EMULATE_DTMF_DURATION 100
+
+/*! Minimum allowed digit length - 80ms */
+#define AST_MIN_DTMF_DURATION 80
+
+/*! Minimum amount of time between the end of the last digit and the beginning 
+ *  of a new one - 45ms */
+#define AST_MIN_DTMF_GAP 45
 
 struct chanlist {
 	const struct ast_channel_tech *tech;
@@ -2118,7 +2126,8 @@
 	prestate = chan->_state;
 
 	if (!ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_EMULATE_DTMF | AST_FLAG_IN_DTMF) && 
-	    !ast_strlen_zero(chan->dtmfq)) {
+	    !ast_strlen_zero(chan->dtmfq) && 
+		(ast_tvzero(chan->dtmf_tv) || ast_tvdiff_ms(ast_tvnow(), chan->dtmf_tv) > AST_MIN_DTMF_GAP) ) {
 		/* We have DTMF that has been deferred.  Return it now */
 		chan->dtmff.subclass = chan->dtmfq[0];
 		/* Drop first digit from the buffer */
@@ -2131,8 +2140,8 @@
 			ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
 			chan->emulate_dtmf_digit = f->subclass;
 			chan->emulate_dtmf_duration = AST_DEFAULT_EMULATE_DTMF_DURATION;
-			chan->dtmf_begin_tv = ast_tvnow();
-		}
+		}
+		chan->dtmf_tv = ast_tvnow();
 		goto done;
 	}
 	
@@ -2269,28 +2278,50 @@
 				ast_frfree(f);
 				f = &ast_null_frame;
 			} else if (!ast_test_flag(chan, AST_FLAG_IN_DTMF | AST_FLAG_END_DTMF_ONLY)) {
-				f->frametype = AST_FRAME_DTMF_BEGIN;
-				ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
-				chan->emulate_dtmf_digit = f->subclass;
-				chan->dtmf_begin_tv = ast_tvnow();
-				if (f->len)
-					chan->emulate_dtmf_duration = f->len;
-				else
-					chan->emulate_dtmf_duration = AST_DEFAULT_EMULATE_DTMF_DURATION;
+				if (!ast_tvzero(chan->dtmf_tv) && 
+				    ast_tvdiff_ms(ast_tvnow(), chan->dtmf_tv) < AST_MIN_DTMF_GAP) {
+					/* If it hasn't been long enough, defer this digit */
+					if (strlen(chan->dtmfq) < sizeof(chan->dtmfq) - 2)
+						chan->dtmfq[strlen(chan->dtmfq)] = f->subclass;
+					else
+						ast_log(LOG_WARNING, "Dropping deferred DTMF digits on %s\n", chan->name);
+					ast_frfree(f);
+					f = &ast_null_frame;
+				} else {
+					/* There was no begin, turn this into a begin and send the end later */
+					f->frametype = AST_FRAME_DTMF_BEGIN;
+					ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
+					chan->emulate_dtmf_digit = f->subclass;
+					chan->dtmf_tv = ast_tvnow();
+					if (f->len && f->len > AST_MIN_DTMF_DURATION)
+						chan->emulate_dtmf_duration = f->len;
+					else
+						chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION;
+				}
 			} else {
+				struct timeval now = ast_tvnow();
 				ast_clear_flag(chan, AST_FLAG_IN_DTMF);
 				if (!f->len)
-					f->len = ast_tvdiff_ms(ast_tvnow(), chan->dtmf_begin_tv);
+					f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
+				if (f->len < AST_MIN_DTMF_DURATION) {
+					ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
+					chan->emulate_dtmf_digit = f->subclass;
+					chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION - f->len;
+					f = &ast_null_frame;
+				} else
+					chan->dtmf_tv = now;
 			}
 			break;
 		case AST_FRAME_DTMF_BEGIN:
 			ast_log(LOG_DTMF, "DTMF begin '%c' received on %s\n", f->subclass, chan->name);
-			if (ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_END_DTMF_ONLY)) {
+			if ( ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_END_DTMF_ONLY) || 
+			    (!ast_tvzero(chan->dtmf_tv) && 
+			      ast_tvdiff_ms(ast_tvnow(), chan->dtmf_tv) < AST_MIN_DTMF_GAP) ) {
 				ast_frfree(f);
 				f = &ast_null_frame;
 			} else {
 				ast_set_flag(chan, AST_FLAG_IN_DTMF);
-				chan->dtmf_begin_tv = ast_tvnow();
+				chan->dtmf_tv = ast_tvnow();
 			}
 			break;
 		case AST_FRAME_VOICE:
@@ -2308,10 +2339,12 @@
 				f = &ast_null_frame;
 			} else if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF)) {
 				if ((f->samples / 8) >= chan->emulate_dtmf_duration) { /* XXX 8kHz */
+					struct timeval now = ast_tvnow();
 					chan->emulate_dtmf_duration = 0;
 					f->frametype = AST_FRAME_DTMF_END;
 					f->subclass = chan->emulate_dtmf_digit;
-					f->len = ast_tvdiff_ms(ast_tvnow(), chan->dtmf_begin_tv);
+					f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
+					chan->dtmf_tv = now;
 				} else {
 					chan->emulate_dtmf_duration -= f->samples / 8; /* XXX 8kHz */
 					ast_frfree(f);
@@ -3360,22 +3393,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))
@@ -3565,6 +3582,8 @@
 		if (x != AST_GENERATOR_FD)
 			original->fds[x] = clone->fds[x];
 	}
+
+	ast_app_group_discard(original);
 
 	/* move any whisperer over */
 	ast_channel_whisper_stop(original);

Modified: team/oej/moremanager/main/cli.c
URL: http://svn.digium.com/view/asterisk/team/oej/moremanager/main/cli.c?view=diff&rev=61826&r1=61825&r2=61826
==============================================================================
--- team/oej/moremanager/main/cli.c (original)
+++ team/oej/moremanager/main/cli.c Wed Apr 25 15:05:31 2007
@@ -1289,10 +1289,8 @@
 {
 #define FORMAT_STRING  "%-25s  %-20s  %-20s\n"
 
-	struct ast_channel *c = NULL;
+	struct ast_group_info *gi = NULL;
 	int numchans = 0;
-	struct ast_var_t *current;
-	struct varshead *headp;
 	regex_t regexbuf;
 	int havepattern = 0;
 
@@ -1306,26 +1304,20 @@
 	}
 
 	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++;
-				}
-			}
-		}
-		numchans++;
-		ast_channel_unlock(c);
-	}
-
+
+	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++;
+		}
+		gi = AST_LIST_NEXT(gi, list);
+	}
+	
+	ast_app_group_list_unlock();
+	
 	if (havepattern)
 		regfree(&regexbuf);
 

Modified: team/oej/moremanager/main/dial.c
URL: http://svn.digium.com/view/asterisk/team/oej/moremanager/main/dial.c?view=diff&rev=61826&r1=61825&r2=61826
==============================================================================
--- team/oej/moremanager/main/dial.c (original)
+++ team/oej/moremanager/main/dial.c Wed Apr 25 15:05:31 2007
@@ -325,11 +325,13 @@
 			if (option_verbose > 2)
 				ast_verbose(VERBOSE_PREFIX_3 "%s is ringing\n", channel->owner->name);
 			ast_indicate(chan, AST_CONTROL_RINGING);
+			set_state(dial, AST_DIAL_RESULT_RINGING);
 			break;
 		case AST_CONTROL_PROGRESS:
 			if (option_verbose > 2)
 				ast_verbose (VERBOSE_PREFIX_3 "%s is making progress, passing it to %s\n", channel->owner->name, chan->name);
 			ast_indicate(chan, AST_CONTROL_PROGRESS);
+			set_state(dial, AST_DIAL_RESULT_PROGRESS);
 			break;
 		case AST_CONTROL_VIDUPDATE:
 			if (option_verbose > 2)
@@ -340,6 +342,7 @@
 			if (option_verbose > 2)
 				ast_verbose (VERBOSE_PREFIX_3 "%s is proceeding, passing it to %s\n", channel->owner->name, chan->name);
 			ast_indicate(chan, AST_CONTROL_PROCEEDING);
+			set_state(dial, AST_DIAL_RESULT_PROCEEDING);
 			break;
 		case AST_CONTROL_HOLD:
 			if (option_verbose > 2)

Modified: team/oej/moremanager/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/oej/moremanager/main/manager.c?view=diff&rev=61826&r1=61825&r2=61826
==============================================================================
--- team/oej/moremanager/main/manager.c (original)
+++ team/oej/moremanager/main/manager.c Wed Apr 25 15:05:31 2007
@@ -927,7 +927,8 @@
 				} else if (ha)
 					ast_free_ha(ha);
 				if (!strcasecmp(authtype, "MD5")) {
-					if (!ast_strlen_zero(key) && s->challenge) {
+					if (!ast_strlen_zero(key) && 
+					    !ast_strlen_zero(s->challenge) && !ast_strlen_zero(password)) {
 						int x;
 						int len = 0;
 						char md5key[256] = "";

Modified: team/oej/moremanager/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/oej/moremanager/main/pbx.c?view=diff&rev=61826&r1=61825&r2=61826
==============================================================================
--- team/oej/moremanager/main/pbx.c (original)
+++ team/oej/moremanager/main/pbx.c Wed Apr 25 15:05:31 2007
@@ -1642,7 +1642,21 @@
 			parse_variable_name(vars, &offset, &offset2, &isfunction);
 			if (isfunction) {
 				/* Evaluate function */
-				cp4 = ast_func_read(c, vars, workspace, VAR_BUF_SIZE) ? NULL : workspace;
+				if (c)
+					cp4 = ast_func_read(c, vars, workspace, VAR_BUF_SIZE) ? NULL : workspace;
+				else {
+					struct varshead old;
+					struct ast_channel *c = ast_channel_alloc(0, 0, "", "", "", "", "", 0, "Bogus/%p", vars);
+					if (c) {
+						memcpy(&old, &c->varshead, sizeof(old));
+						memcpy(&c->varshead, headp, sizeof(c->varshead));
+						cp4 = ast_func_read(c, vars, workspace, VAR_BUF_SIZE) ? NULL : workspace;
+						/* Don't deallocate the varshead that was passed in */
+						memcpy(&c->varshead, &old, sizeof(c->varshead));
+						ast_channel_free(c);
+					} else
+						ast_log(LOG_ERROR, "Unable to allocate bogus channel for variable substitution.  Function results may be blank.\n");
+				}
 
 				if (option_debug)
 					ast_log(LOG_DEBUG, "Function result is '%s'\n", cp4 ? cp4 : "(null)");



More information about the asterisk-commits mailing list