[svn-commits] oej: branch oej/videocaps r62036 - in /team/oej/videocaps: ./ channels/ funcs...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Wed Apr 25 23:25:57 MST 2007


Author: oej
Date: Thu Apr 26 01:25:56 2007
New Revision: 62036

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

Modified:
    team/oej/videocaps/   (props changed)
    team/oej/videocaps/CHANGES
    team/oej/videocaps/channels/chan_iax2.c
    team/oej/videocaps/channels/chan_sip.c
    team/oej/videocaps/channels/chan_zap.c
    team/oej/videocaps/funcs/func_groupcount.c
    team/oej/videocaps/include/asterisk/app.h
    team/oej/videocaps/include/asterisk/channel.h
    team/oej/videocaps/main/app.c
    team/oej/videocaps/main/channel.c
    team/oej/videocaps/main/cli.c
    team/oej/videocaps/main/config.c
    team/oej/videocaps/main/dial.c
    team/oej/videocaps/main/manager.c
    team/oej/videocaps/main/pbx.c
    team/oej/videocaps/res/res_monitor.c

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

Propchange: team/oej/videocaps/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Apr 26 01:25:56 2007
@@ -1,1 +1,1 @@
-/trunk:1-61752
+/trunk:1-62035

Modified: team/oej/videocaps/CHANGES
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/CHANGES?view=diff&rev=62036&r1=62035&r2=62036
==============================================================================
--- team/oej/videocaps/CHANGES (original)
+++ team/oej/videocaps/CHANGES Thu Apr 26 01:25:56 2007
@@ -1,6 +1,81 @@
 -------------------------------------------------------------------------------
 --- Functionality changes since Asterisk 1.4-beta was branched ----------------
 -------------------------------------------------------------------------------
+
+AMI - The manager (TCP/TLS/HTTP)
+--------------------------------
+  * Added the URI redirect option for the built-in HTTP server
+  * The output of CallerID in Manager events is now more consistent.
+     CallerIDNum is used for number and CallerIDName for name.
+  * enable https support for builtin web server.
+     See configs/http.conf.sample for details.
+  * Added a new action, GetConfigJSON, which can return the contents of an
+     Asterisk configuration file in JSON format.  This is intended to help
+     improve the performance of AJAX applications using the manager interface
+     over HTTP.
+  * SIP and IAX manager events now use "ChannelType" in all cases where we 
+     indicate channel driver. Previously, we used a mixture of "Channel"
+     and "ChannelDriver" headers.
+  * Added a "Bridge" action which allows you to bridge any two channels that
+     are currently active on the system.
+
+Dialplan functions
+------------------
+  * Added the DEVSTATE() dialplan function which allows retrieving any device
+    state in the dialplan, as well as creating custom device states that are
+    controllable from the dialplan.
+  * Extend CALLERID() function with "pres" and "ton" parameters to
+     fetch string representation of calling number presentation indicator
+     and numeric representation of type of calling number value.
+  * MailboxExists converted to dialplan function
+
+CLI Changes
+-----------
+  * New CLI command "core show settings"
+  * Added 'core show channels count' CLI command.
+
+SIP changes
+-----------
+  * The default SIP useragent= identifier now includes the Asterisk version
+  * A new option, match_auth_username in sip.conf changes the matching of incoming requests.
+     If set, and the incoming request carries authentication info,
+     the username to match in the users list is taken from the Digest header
+     rather than from the From: field. This feature is considered experimental.
+  * The "musiconhold" and "musicclass" settings in sip.conf are now removed,
+     since they where replaced by "mohsuggest" and "mohinterpret" in version 1.4
+  * The "localmask" setting was removed in version 1.2 and the reminder about it
+     being removed is now also removed.
+  * A new option "busy-level" for setting a level of calls where asterisk reports
+     a device as busy, to separate it from call-limit
+  * A new realtime family called "sipregs" is now supported to store SIP registration
+     data. If this family is defined, "sippeers" will be used for configuration and
+     "sipregs" for registrations. If it's not defined, "sippeers" will be used for
+     registration data, as before.
+  * The SIPPEER function have new options for port address, call and pickup groups
+  * Added support for T.140 realtime text in SIP/RTP
+
+IAX2 changes
+------------
+  * Added the trunkmaxsize configuration option to chan_iax2.
+  * Added the srvlookup option to iax.conf
+  * Added support for OSP.  The token is set and retrieved through the CHANNEL()
+     dialplan function.
+
+DUNDi changes
+-------------
+  * Added the ability to specify arguments to the Dial application when using
+     the DUNDi switch in the dialplan.
+  * Added the ability to set weights for responses dynamically.  This can be
+     done using a global variable or a dialplan function.  Using the SHELL()
+     function would allow you to have an external script set the weight for
+     each response.
+
+Voicemail Changes
+-----------------
+  * Added the ability to customize which sound files are used for some of the
+     prompts within the Voicemail application by changing them in voicemail.conf
+  * Added the ability for the "voicemail show users" CLI command to show users
+    configured by the dynamic realtime configuration method.
 
 Miscellaneous 
 -------------
@@ -53,11 +128,9 @@
   * Added maxfiles option to options section of asterisk.conf which allows you to specify
      what Asterisk should set as the maximum number of open files when it loads.
   * Added the jittertargetextra configuration option.
-  * Added the trunkmaxsize configuration option to chan_iax2.
   * Added G729 passthrough support to chan_phone for Sigma Designs boards.
   * Added the parkedcalltransfers option to features.conf
   * Added 's' option to Page application.
-  * Added the srvlookup option to iax.conf
   * Added 'E' and 'V' commands to ExternalIVR.
   * Added 'DBDel' and 'DBDelTree' manager commands.
   * Added 'o' and 'X' options to Chanspy.
@@ -68,71 +141,3 @@
   * Added a new realtime configuration module, res_config_sqlite
   * Added a new dialplan application, Bridge, which allows you to bridge the
     calling channel to any other active channel on the system.
-
-AMI - The manager (TCP/TLS/HTTP)
---------------------------------
-  * Added the URI redirect option for the built-in HTTP server
-  * The output of CallerID in Manager events is now more consistent.
-     CallerIDNum is used for number and CallerIDName for name.
-  * enable https support for builtin web server.
-     See configs/http.conf.sample for details.
-  * Added a new action, GetConfigJSON, which can return the contents of an
-    Asterisk configuration file in JSON format.  This is intended to help
-    improve the performance of AJAX applications using the manager interface
-    over HTTP.
-  * SIP and IAX manager events now use "ChannelType" in all cases where we 
-    indicate channel driver. Previously, we used a mixture of "Channel"
-    and "ChannelDriver" headers.
-  * Added a "Bridge" action which allows you to bridge any two channels that
-    are currently active on the system.
-
-Dialplan functions
-------------------
-  * Added the DEVSTATE() dialplan function which allows retrieving any device
-    state in the dialplan, as well as creating custom device states that are
-    controllable from the dialplan.
-  * Extend CALLERID() function with "pres" and "ton" parameters to
-     fetch string representation of calling number presentation indicator
-     and numeric representation of type of calling number value.
-  * MailboxExists converted to dialplan function
-
-CLI Changes
------------
-  * New CLI command "core show settings"
-  * Added 'core show channels count' CLI command.
-
-SIP changes
------------
-  * The default SIP useragent= identifier now includes the Asterisk version
-  * A new option, match_auth_username in sip.conf changes the matching of incoming requests.
-     If set, and the incoming request carries authentication info,
-     the username to match in the users list is taken from the Digest header
-     rather than from the From: field. This feature is considered experimental.
-  * The "musiconhold" and "musicclass" settings in sip.conf are now removed,
-     since they where replaced by "mohsuggest" and "mohinterpret" in version 1.4
-  * The "localmask" setting was removed in version 1.2 and the reminder about it
-     being removed is now also removed.
-  * A new option "busy-level" for setting a level of calls where asterisk reports
-     a device as busy, to separate it from call-limit
-  * A new realtime family called "sipregs" is now supported to store SIP registration
-     data. If this family is defined, "sippeers" will be used for configuration and
-     "sipregs" for registrations. If it's not defined, "sippeers" will be used for
-     registration data, as before.
-  * The SIPPEER function have new options for port address, call and pickup groups
-  * Added support for T.140 realtime text in SIP/RTP
-
-DUNDi changes
--------------
-  * Added the ability to specify arguments to the Dial application when using
-     the DUNDi switch in the dialplan.
-  * Added the ability to set weights for responses dynamically.  This can be
-     done using a global variable or a dialplan function.  Using the SHELL()
-     function would allow you to have an external script set the weight for
-     each response.
-
-Voicemail Changes
------------------
-  * Added the ability to customize which sound files are used for some of the
-     prompts within the Voicemail application by changing them in voicemail.conf
-  * Added the ability for the "voicemail show users" CLI command to show users
-    configured by the dynamic realtime configuration method.

Modified: team/oej/videocaps/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/channels/chan_iax2.c?view=diff&rev=62036&r1=62035&r2=62036
==============================================================================
--- team/oej/videocaps/channels/chan_iax2.c (original)
+++ team/oej/videocaps/channels/chan_iax2.c Thu Apr 26 01:25:56 2007
@@ -8586,6 +8586,9 @@
 			peer->pokefreqnotok = DEFAULT_FREQ_NOTOK;
 			ast_string_field_set(peer,context,"");
 			ast_string_field_set(peer,peercontext,"");
+			ast_clear_flag(peer, IAX_HASCALLERID);
+			ast_string_field_set(peer, cid_name, "");
+			ast_string_field_set(peer, cid_num, "");
 		}
 
 		if (!v) {
@@ -8686,18 +8689,36 @@
 			} else if (!strcasecmp(v->name, "disallow")) {
 				ast_parse_allow_disallow(&peer->prefs, &peer->capability, v->value, 0);
 			} else if (!strcasecmp(v->name, "callerid")) {
-				char name2[80];
-				char num2[80];
-				ast_callerid_split(v->value, name2, 80, num2, 80);
-				ast_string_field_set(peer, cid_name, name2);
-				ast_string_field_set(peer, cid_num, num2);
-				ast_set_flag(peer, IAX_HASCALLERID);	
+				if (!ast_strlen_zero(v->value)) {
+					char name2[80];
+					char num2[80];
+					ast_callerid_split(v->value, name2, 80, num2, 80);
+					ast_string_field_set(peer, cid_name, name2);
+					ast_string_field_set(peer, cid_num, num2);
+					ast_set_flag(peer, IAX_HASCALLERID);
+				} else {
+					ast_clear_flag(peer, IAX_HASCALLERID);
+					ast_string_field_set(peer, cid_name, "");
+					ast_string_field_set(peer, cid_num, "");
+				}
 			} else if (!strcasecmp(v->name, "fullname")) {
-				ast_string_field_set(peer, cid_name, v->value);
-				ast_set_flag(peer, IAX_HASCALLERID);	
+				if (!ast_strlen_zero(v->value)) {
+					ast_string_field_set(peer, cid_name, v->value);
+					ast_set_flag(peer, IAX_HASCALLERID);
+				} else {
+					ast_string_field_set(peer, cid_name, "");
+					if (ast_strlen_zero(peer->cid_num))
+						ast_clear_flag(peer, IAX_HASCALLERID);
+				}
 			} else if (!strcasecmp(v->name, "cid_number")) {
-				ast_string_field_set(peer, cid_num, v->value);
-				ast_set_flag(peer, IAX_HASCALLERID);	
+				if (!ast_strlen_zero(v->value)) {
+					ast_string_field_set(peer, cid_num, v->value);
+					ast_set_flag(peer, IAX_HASCALLERID);
+				} else {
+					ast_string_field_set(peer, cid_num, "");
+					if (ast_strlen_zero(peer->cid_name))
+						ast_clear_flag(peer, IAX_HASCALLERID);
+				}
 			} else if (!strcasecmp(v->name, "sendani")) {
 				ast_set2_flag(peer, ast_true(v->value), IAX_SENDANI);	
 			} else if (!strcasecmp(v->name, "inkeys")) {
@@ -8805,6 +8826,9 @@
 			ast_string_field_set(user, name, name);
 			ast_string_field_set(user, language, 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);
+			ast_string_field_set(user, cid_name, "");
+			ast_string_field_set(user, cid_num, "");
 		}
 		if (!v) {
 			v = alt;
@@ -8877,18 +8901,36 @@
 				} else
 					ast_string_field_set(user, secret, v->value);
 			} else if (!strcasecmp(v->name, "callerid")) {
-				char name2[80];
-				char num2[80];
-				ast_callerid_split(v->value, name2, 80, num2, 80);
-				ast_string_field_set(user, cid_name, name2);
-				ast_string_field_set(user, cid_num, num2);
-				ast_set_flag(user, IAX_HASCALLERID);	
+				if (!ast_strlen_zero(v->value) && strcasecmp(v->value, "asreceived")) {
+					char name2[80];
+					char num2[80];
+					ast_callerid_split(v->value, name2, sizeof(name2), num2, sizeof(num2));
+					ast_string_field_set(user, cid_name, name2);
+					ast_string_field_set(user, cid_num, num2);
+					ast_set_flag(user, IAX_HASCALLERID);
+				} else {
+					ast_clear_flag(user, IAX_HASCALLERID);
+					ast_string_field_set(user, cid_name, "");
+					ast_string_field_set(user, cid_num, "");
+				}
 			} else if (!strcasecmp(v->name, "fullname")) {
-				ast_string_field_set(user, cid_name, v->value);
-				ast_set_flag(user, IAX_HASCALLERID);	
+				if (!ast_strlen_zero(v->value)) {
+					ast_string_field_set(user, cid_name, v->value);
+					ast_set_flag(user, IAX_HASCALLERID);
+				} else {
+					ast_string_field_set(user, cid_name, "");
+					if (ast_strlen_zero(user->cid_num))
+						ast_clear_flag(user, IAX_HASCALLERID);
+				}
 			} else if (!strcasecmp(v->name, "cid_number")) {
-				ast_string_field_set(user, cid_num, v->value);
-				ast_set_flag(user, IAX_HASCALLERID);	
+				if (!ast_strlen_zero(v->value)) {
+					ast_string_field_set(user, cid_num, v->value);
+					ast_set_flag(user, IAX_HASCALLERID);
+				} else {
+					ast_string_field_set(user, cid_num, "");
+					if (ast_strlen_zero(user->cid_name))
+						ast_clear_flag(user, IAX_HASCALLERID);
+				}
 			} else if (!strcasecmp(v->name, "accountcode")) {
 				ast_string_field_set(user, accountcode, v->value);
 			} else if (!strcasecmp(v->name, "mohinterpret")) {

Modified: team/oej/videocaps/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/channels/chan_sip.c?view=diff&rev=62036&r1=62035&r2=62036
==============================================================================
--- team/oej/videocaps/channels/chan_sip.c (original)
+++ team/oej/videocaps/channels/chan_sip.c Thu Apr 26 01:25:56 2007
@@ -10203,6 +10203,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;
 		/* If we do not support video, remove video from call structure */
@@ -10350,6 +10351,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/videocaps/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/channels/chan_zap.c?view=diff&rev=62036&r1=62035&r2=62036
==============================================================================
--- team/oej/videocaps/channels/chan_zap.c (original)
+++ team/oej/videocaps/channels/chan_zap.c Thu Apr 26 01:25:56 2007
@@ -5641,7 +5641,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
@@ -5743,6 +5743,15 @@
 	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);
@@ -7308,14 +7317,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/videocaps/funcs/func_groupcount.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/funcs/func_groupcount.c?view=diff&rev=62036&r1=62035&r2=62036
==============================================================================
--- team/oej/videocaps/funcs/func_groupcount.c (original)
+++ team/oej/videocaps/funcs/func_groupcount.c Thu Apr 26 01:25:56 2007
@@ -40,24 +40,16 @@
 static int group_count_function_read(struct ast_channel *chan, const 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;
 }
@@ -106,20 +98,26 @@
 static int group_function_read(struct ast_channel *chan, const 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;
 }
 
@@ -153,38 +151,36 @@
 static int group_list_function_read(struct ast_channel *chan, const 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/videocaps/include/asterisk/app.h
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/include/asterisk/app.h?view=diff&rev=62036&r1=62035&r2=62036
==============================================================================
--- team/oej/videocaps/include/asterisk/app.h (original)
+++ team/oej/videocaps/include/asterisk/app.h Thu Apr 26 01:25:56 2007
@@ -205,7 +205,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);
@@ -218,6 +223,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/videocaps/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/include/asterisk/channel.h?view=diff&rev=62036&r1=62035&r2=62036
==============================================================================
--- team/oej/videocaps/include/asterisk/channel.h (original)
+++ team/oej/videocaps/include/asterisk/channel.h Thu Apr 26 01:25:56 2007
@@ -492,7 +492,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/videocaps/main/app.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/main/app.c?view=diff&rev=62036&r1=62035&r2=62036
==============================================================================
--- team/oej/videocaps/main/app.c (original)
+++ team/oej/videocaps/main/app.c Thu Apr 26 01:25:56 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' 
@@ -804,61 +806,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;
@@ -867,20 +882,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/videocaps/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/main/channel.c?view=diff&rev=62036&r1=62035&r2=62036
==============================================================================
--- team/oej/videocaps/main/channel.c (original)
+++ team/oej/videocaps/main/channel.c Thu Apr 26 01:25:56 2007
@@ -104,7 +104,16 @@
 AST_THREADSTORAGE(state2str_threadbuf);
 #define STATE2STR_BUFSIZE   32
 
-#define AST_DEFAULT_EMULATE_DTMF_DURATION 100 /*!< 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
 
 /*! \brief List of channel drivers */
 struct chanlist {
@@ -1124,6 +1133,8 @@
 	while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries)))
 		ast_var_delete(vardata);
 
+	ast_app_group_discard(chan);
+
 	/* Destroy the jitterbuffer */
 	ast_jb_destroy(chan);
 
@@ -2070,7 +2081,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 */
@@ -2083,8 +2095,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;
 	}
 	
@@ -2222,29 +2234,51 @@
 				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:
 			send_dtmf_event(chan, "Received", f->subclass, "Yes", "No");
 			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:
@@ -2262,10 +2296,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);
@@ -3318,22 +3354,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))
@@ -3526,6 +3546,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/videocaps/main/cli.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/main/cli.c?view=diff&rev=62036&r1=62035&r2=62036
==============================================================================
--- team/oej/videocaps/main/cli.c (original)
+++ team/oej/videocaps/main/cli.c Thu Apr 26 01:25:56 2007
@@ -905,10 +905,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;
 
@@ -922,26 +920,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/videocaps/main/config.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/main/config.c?view=diff&rev=62036&r1=62035&r2=62036
==============================================================================
--- team/oej/videocaps/main/config.c (original)
+++ team/oej/videocaps/main/config.c Thu Apr 26 01:25:56 2007
@@ -1270,6 +1270,8 @@
 
 	if (result)
 		result->include_level--;
+	else
+		cfg->include_level--;
 
 	return result;
 }

Modified: team/oej/videocaps/main/dial.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/main/dial.c?view=diff&rev=62036&r1=62035&r2=62036
==============================================================================
--- team/oej/videocaps/main/dial.c (original)
+++ team/oej/videocaps/main/dial.c Thu Apr 26 01:25:56 2007
@@ -343,11 +343,13 @@
 				ast_verbose(VERBOSE_PREFIX_3 "%s is ringing\n", channel->owner->name);
 			if (!dial->options[AST_DIAL_OPTION_MUSIC])
 				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)
@@ -358,6 +360,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/videocaps/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/main/manager.c?view=diff&rev=62036&r1=62035&r2=62036
==============================================================================
--- team/oej/videocaps/main/manager.c (original)
+++ team/oej/videocaps/main/manager.c Thu Apr 26 01:25:56 2007
@@ -984,7 +984,8 @@
 	}
 	if (!strcasecmp(astman_get_header(m, "AuthType"), "MD5")) {
 		const char *key = astman_get_header(m, "Key");
-		if (!ast_strlen_zero(key) && !ast_strlen_zero(s->challenge)) {
+		if (!ast_strlen_zero(key) && !ast_strlen_zero(s->challenge) &&
+		    !ast_strlen_zero(password)) {
 			int x;
 			int len = 0;
 			char md5key[256] = "";
@@ -1065,6 +1066,17 @@
 	return 0;
 }
 
+/*! The amount of space in out must be at least ( 2 * strlen(in) + 1 ) */
+static void json_escape(char *out, const char *in)
+{
+	for (; *in; in++) {
+		if (*in == '\\' || *in == '\"')
+			*out++ = '\\';
+		*out++ = *in;
+	}
+	*out = '\0';
+}
+
 static char mandescr_getconfigjson[] =
 "Description: A 'GetConfigJSON' action will dump the contents of a configuration\n"
 "file by category and contents in JSON format.  This only makes sense to be used\n"
@@ -1079,6 +1091,8 @@
 	char *category = NULL;
 	struct ast_variable *v;
 	int comma1 = 0;
+	char *buf = NULL;
+	unsigned int buf_len = 0;
 
 	if (ast_strlen_zero(fn)) {
 		astman_send_error(s, m, "Filename not specified");
@@ -1089,16 +1103,37 @@
 		astman_send_error(s, m, "Config file not found");

[... 83 lines stripped ...]


More information about the svn-commits mailing list