[asterisk-commits] russell: branch group/security_events r219892 - in /team/group/security_event...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Sep 23 04:05:29 CDT 2009


Author: russell
Date: Wed Sep 23 04:05:19 2009
New Revision: 219892

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=219892
Log:
resolve, reset

Removed:
    team/group/security_events/contrib/firmware/iax/iaxy.bin
Modified:
    team/group/security_events/   (props changed)
    team/group/security_events/CHANGES
    team/group/security_events/UPGRADE.txt
    team/group/security_events/addons/format_mp3.c
    team/group/security_events/apps/app_chanspy.c
    team/group/security_events/apps/app_directed_pickup.c
    team/group/security_events/apps/app_followme.c
    team/group/security_events/apps/app_meetme.c
    team/group/security_events/apps/app_queue.c
    team/group/security_events/apps/app_voicemail.c
    team/group/security_events/channels/chan_dahdi.c
    team/group/security_events/channels/chan_iax2.c
    team/group/security_events/channels/chan_phone.c
    team/group/security_events/channels/chan_sip.c
    team/group/security_events/channels/sig_analog.c
    team/group/security_events/channels/sig_analog.h
    team/group/security_events/channels/sig_pri.c
    team/group/security_events/channels/sig_pri.h
    team/group/security_events/configs/extensions.conf.sample
    team/group/security_events/configs/func_odbc.conf.sample
    team/group/security_events/configs/voicemail.conf.sample
    team/group/security_events/configure
    team/group/security_events/configure.ac
    team/group/security_events/contrib/scripts/iax-friends.sql
    team/group/security_events/contrib/scripts/live_ast
    team/group/security_events/doc/manager_1_1.txt
    team/group/security_events/funcs/func_odbc.c
    team/group/security_events/include/asterisk/autoconfig.h.in
    team/group/security_events/include/asterisk/cdr.h
    team/group/security_events/include/asterisk/event.h
    team/group/security_events/main/channel.c
    team/group/security_events/main/config.c
    team/group/security_events/main/features.c
    team/group/security_events/main/file.c
    team/group/security_events/main/manager.c
    team/group/security_events/main/pbx.c
    team/group/security_events/res/res_config_odbc.c
    team/group/security_events/res/res_jabber.c
    team/group/security_events/res/res_limit.c
    team/group/security_events/res/res_musiconhold.c
    team/group/security_events/res/res_phoneprov.c
    team/group/security_events/res/res_rtp_asterisk.c
    team/group/security_events/sounds/Makefile

Propchange: team/group/security_events/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/group/security_events/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/group/security_events/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/group/security_events/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Sep 23 04:05:19 2009
@@ -1,1 +1,1 @@
-/trunk:1-216818
+/trunk:1-219891

Modified: team/group/security_events/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/group/security_events/CHANGES?view=diff&rev=219892&r1=219891&r2=219892
==============================================================================
--- team/group/security_events/CHANGES (original)
+++ team/group/security_events/CHANGES Wed Sep 23 04:05:19 2009
@@ -63,9 +63,11 @@
    exit the application.
  * The Voicemail application has been improved to automatically ignore messages
    that only contain silence.
- * The ChanSpy application now has the 's' option, which makes the application
+ * The ChanSpy application now has the 'S' option, which makes the application
    automatically exit once it hits a point where no more channels are available
    to spy on.
+ * The ChanSpy application also now has the 'E' option, which spies on a single
+   channel and exits when that channel hangs up.
 
 Dialplan Functions
 ------------------
@@ -105,6 +107,10 @@
    channel, is one approach that will avoid conflicts.
  * Added new dialplan function MUTEAUDIO() for muting inbound and/or outbound
    audio in a channel.
+ * func_odbc now allows multiple row results to be retrieved without using
+   mode=multirow.  If rowlimit is set, then additional rows may be retrieved
+   from the same query by using the name of the function which retrieved the
+   first row as an argument to ODBC_FETCH().
 
 Dialplan Variables
 ------------------

Modified: team/group/security_events/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/team/group/security_events/UPGRADE.txt?view=diff&rev=219892&r1=219891&r2=219892
==============================================================================
--- team/group/security_events/UPGRADE.txt (original)
+++ team/group/security_events/UPGRADE.txt Wed Sep 23 04:05:19 2009
@@ -19,6 +19,12 @@
 ===========================================================
 
 From 1.6.2 to 1.6.3:
+
+* The firmware for the IAXy has been removed from Asterisk.  It can be
+  downloaded from http://downloads.digium.com/pub/iaxy/.  To have Asterisk
+  install the firmware into its proper location, place the firmware in the
+  contrib/firmware/iax/ directory in the Asterisk source tree before running
+  "make install".
 
 * There have been some changes to the IAX2 protocol to address the security
   concerns documented in the security advisory AST-2009-006.  Please see the

Modified: team/group/security_events/addons/format_mp3.c
URL: http://svnview.digium.com/svn/asterisk/team/group/security_events/addons/format_mp3.c?view=diff&rev=219892&r1=219891&r2=219892
==============================================================================
--- team/group/security_events/addons/format_mp3.c (original)
+++ team/group/security_events/addons/format_mp3.c Wed Sep 23 04:05:19 2009
@@ -200,7 +200,7 @@
 
 	if(p->dbuflen) {
 		for(p->buflen=0; p->buflen < MP3_BUFLEN && p->buflen < p->dbuflen; p->buflen++) {
-			s->buf[p->buflen] = p->dbuf[p->buflen+p->dbufoffset];
+			s->buf[p->buflen + AST_FRIENDLY_OFFSET] = p->dbuf[p->buflen+p->dbufoffset];
 			p->sbufoffset++;
 		}
 		p->dbufoffset += p->buflen;
@@ -211,7 +211,7 @@
 				return NULL;
 
 			for(save = p->buflen; p->buflen < MP3_BUFLEN; p->buflen++) {
-				s->buf[p->buflen] = p->dbuf[(p->buflen-save)+p->dbufoffset];
+				s->buf[p->buflen + AST_FRIENDLY_OFFSET] = p->dbuf[(p->buflen-save)+p->dbufoffset];
 				p->sbufoffset++;
 			}
 			p->dbufoffset += (MP3_BUFLEN - save);

Modified: team/group/security_events/apps/app_chanspy.c
URL: http://svnview.digium.com/svn/asterisk/team/group/security_events/apps/app_chanspy.c?view=diff&rev=219892&r1=219891&r2=219892
==============================================================================
--- team/group/security_events/apps/app_chanspy.c (original)
+++ team/group/security_events/apps/app_chanspy.c Wed Sep 23 04:05:19 2009
@@ -71,6 +71,11 @@
 						<para>Instead of whispering on a single channel barge in on both
 						channels involved in the call.</para>
 					</option>
+					<option name="c">
+						<argument name="digit" required="true">
+							<para>Specify a DTMF digit that can be used to spy on the next available channel.</para>
+						</argument>
+					</option>
 					<option name="d">
 						<para>Override the typical numeric DTMF functionality and instead
 						use DTMF to switch between spy modes.</para>
@@ -86,6 +91,15 @@
 							</enum>
 						</enumlist>
 					</option>
+					<option name="e">
+						<argument name="ext" required="true" />
+						<para>Enable <emphasis>enforced</emphasis> mode, so the spying channel can
+						only monitor extensions whose name is in the <replaceable>ext</replaceable> : delimited 
+						list.</para>
+					</option>
+					<option name="E">
+						<para>Exit when the spied-on channel hangs up.</para>
+					</option>
 					<option name="g">
 						<argument name="grp" required="true">
 							<para>Only spy on channels in which one or more of the groups
@@ -106,6 +120,9 @@
 						<argument name="mailbox" />
 						<argument name="context" />
 					</option>
+					<option name="o">
+						<para>Only listen to audio coming from this channel.</para>
+					</option>
 					<option name="q">
 						<para>Don't play a beep when beginning to spy on a channel, or speak the
 						selected channel name.</para>
@@ -119,6 +136,9 @@
 						<para>Skip the playback of the channel type (i.e. SIP, IAX, etc) when
 						speaking the selected channel name.</para>
 					</option>
+					<option name="S">
+						<para>Stop when no more channels are left to spy on.</para>
+					</option>
 					<option name="v">
 						<argument name="value" />
 						<para>Adjust the initial volume in the range from <literal>-4</literal> 
@@ -132,11 +152,10 @@
 						<para>Enable <literal>private whisper</literal> mode, so the spying channel can
 						talk to the spied-on channel but cannot listen to that channel.</para>
 					</option>
-					<option name="o">
-						<para>Only listen to audio coming from this channel.</para>
-					</option>
-					<option name="s">
-						<para>Stop when no more channels are left to spy on.</para>
+					<option name="x">
+						<argument name="digit" required="true">
+							<para>Specify a DTMF digit that can be used to exit the application.</para>
+						</argument>
 					</option>
 					<option name="X">
 						<para>Allow the user to exit ChanSpy to a valid single digit
@@ -144,22 +163,6 @@
 						specified by the <variable>SPY_EXIT_CONTEXT</variable> channel variable. The
 						name of the last channel that was spied on will be stored
 						in the <variable>SPY_CHANNEL</variable> variable.</para>
-					</option>
-					<option name="x">
-						<argument name="digit" required="true">
-							<para>Specify a DTMF digit that can be used to exit the application.</para>
-						</argument>
-					</option>
-					<option name="c">
-						<argument name="digit" required="true">
-							<para>Specify a DTMF digit that can be used to spy on the next available channel.</para>
-						</argument>
-					</option>
-					<option name="e">
-						<argument name="ext" required="true" />
-						<para>Enable <emphasis>enforced</emphasis> mode, so the spying channel can
-						only monitor extensions whose name is in the <replaceable>ext</replaceable> : delimited 
-						list.</para>
 					</option>
 				</optionlist>		
 			</parameter>
@@ -205,6 +208,11 @@
 						<para>Instead of whispering on a single channel barge in on both
 						channels involved in the call.</para>
 					</option>
+					<option name="c">
+						<argument name="digit" required="true">
+							<para>Specify a DTMF digit that can be used to spy on the next available channel.</para>
+						</argument>
+					</option>
 					<option name="d">
 						<para>Override the typical numeric DTMF functionality and instead
 						use DTMF to switch between spy modes.</para>
@@ -220,6 +228,15 @@
 							</enum>
 						</enumlist>
 					</option>
+					<option name="e">
+						<argument name="ext" required="true" />
+						<para>Enable <emphasis>enforced</emphasis> mode, so the spying channel can
+						only monitor extensions whose name is in the <replaceable>ext</replaceable> : delimited 
+						list.</para>
+					</option>
+					<option name="E">
+						<para>Exit when the spied-on channel hangs up.</para>
+					</option>
 					<option name="g">
 						<argument name="grp" required="true">
 							<para>Only spy on channels in which one or more of the groups
@@ -240,6 +257,9 @@
 						<argument name="mailbox" />
 						<argument name="context" />
 					</option>
+					<option name="o">
+						<para>Only listen to audio coming from this channel.</para>
+					</option>
 					<option name="q">
 						<para>Don't play a beep when beginning to spy on a channel, or speak the
 						selected channel name.</para>
@@ -253,6 +273,9 @@
 						<para>Skip the playback of the channel type (i.e. SIP, IAX, etc) when
 						speaking the selected channel name.</para>
 					</option>
+					<option name="S">
+						<para>Stop when there are no more extensions left to spy on.</para>
+					</option>
 					<option name="v">
 						<argument name="value" />
 						<para>Adjust the initial volume in the range from <literal>-4</literal> 
@@ -266,11 +289,10 @@
 						<para>Enable <literal>private whisper</literal> mode, so the spying channel can
 						talk to the spied-on channel but cannot listen to that channel.</para>
 					</option>
-					<option name="o">
-						<para>Only listen to audio coming from this channel.</para>
-					</option>
-					<option name="s">
-						<para>Stop when there are no more extensions left to spy on.</para>
+					<option name="x">
+						<argument name="digit" required="true">
+							<para>Specify a DTMF digit that can be used to exit the application.</para>
+						</argument>
 					</option>
 					<option name="X">
 						<para>Allow the user to exit ChanSpy to a valid single digit
@@ -278,22 +300,6 @@
 						specified by the <variable>SPY_EXIT_CONTEXT</variable> channel variable. The
 						name of the last channel that was spied on will be stored
 						in the <variable>SPY_CHANNEL</variable> variable.</para>
-					</option>
-					<option name="x">
-						<argument name="digit" required="true">
-							<para>Specify a DTMF digit that can be used to exit the application.</para>
-						</argument>
-					</option>
-					<option name="c">
-						<argument name="digit" required="true">
-							<para>Specify a DTMF digit that can be used to spy on the next available channel.</para>
-						</argument>
-					</option>
-					<option name="e">
-						<argument name="ext" required="true" />
-						<para>Enable <emphasis>enforced</emphasis> mode, so the spying channel can
-						only monitor extensions whose name is in the <replaceable>ext</replaceable> : delimited 
-						list.</para>
 					</option>
 				</optionlist>	
 			</parameter>
@@ -356,6 +362,7 @@
 	OPTION_DTMF_CYCLE        = (1 << 15),	/* Custom DTMF for cycling next avaliable channel, (default is '*') */
 	OPTION_DAHDI_SCAN        = (1 << 16),	/* Scan groups in DAHDIScan mode */
 	OPTION_STOP              = (1 << 17),
+	OPTION_EXITONHANGUP      = (1 << 18),   /* Hang up when the spied-on channel hangs up. */
 };
 
 enum {
@@ -370,23 +377,24 @@
 };
 
 AST_APP_OPTIONS(spy_opts, {
-	AST_APP_OPTION('q', OPTION_QUIET),
 	AST_APP_OPTION('b', OPTION_BRIDGED),
 	AST_APP_OPTION('B', OPTION_BARGE),
+	AST_APP_OPTION_ARG('c', OPTION_DTMF_CYCLE, OPT_ARG_CYCLE),
+	AST_APP_OPTION('d', OPTION_DTMF_SWITCH_MODES),
+	AST_APP_OPTION_ARG('e', OPTION_ENFORCED, OPT_ARG_ENFORCED),
+	AST_APP_OPTION('E', OPTION_EXITONHANGUP),
+	AST_APP_OPTION_ARG('g', OPTION_GROUP, OPT_ARG_GROUP),
+	AST_APP_OPTION_ARG('n', OPTION_NAME, OPT_ARG_NAME),
+	AST_APP_OPTION('o', OPTION_READONLY),
+	AST_APP_OPTION('q', OPTION_QUIET),
+	AST_APP_OPTION_ARG('r', OPTION_RECORD, OPT_ARG_RECORD),
+	AST_APP_OPTION('s', OPTION_NOTECH),
+	AST_APP_OPTION('S', OPTION_STOP),
+	AST_APP_OPTION_ARG('v', OPTION_VOLUME, OPT_ARG_VOLUME),
 	AST_APP_OPTION('w', OPTION_WHISPER),
 	AST_APP_OPTION('W', OPTION_PRIVATE),
-	AST_APP_OPTION_ARG('v', OPTION_VOLUME, OPT_ARG_VOLUME),
-	AST_APP_OPTION_ARG('g', OPTION_GROUP, OPT_ARG_GROUP),
-	AST_APP_OPTION_ARG('r', OPTION_RECORD, OPT_ARG_RECORD),
-	AST_APP_OPTION_ARG('e', OPTION_ENFORCED, OPT_ARG_ENFORCED),
-	AST_APP_OPTION('o', OPTION_READONLY),
-	AST_APP_OPTION('s', OPTION_STOP),
+	AST_APP_OPTION_ARG('x', OPTION_DTMF_EXIT, OPT_ARG_EXIT),
 	AST_APP_OPTION('X', OPTION_EXIT),
-	AST_APP_OPTION('s', OPTION_NOTECH),
-	AST_APP_OPTION_ARG('n', OPTION_NAME, OPT_ARG_NAME),
-	AST_APP_OPTION('d', OPTION_DTMF_SWITCH_MODES),
-	AST_APP_OPTION_ARG('x', OPTION_DTMF_EXIT, OPT_ARG_EXIT),
-	AST_APP_OPTION_ARG('c', OPTION_DTMF_CYCLE, OPT_ARG_CYCLE),
 });
 
 struct chanspy_translation_helper {
@@ -957,6 +965,8 @@
 						next_autochan = NULL;
 					}
 				}
+			} else if (res == 0 && ast_test_flag(flags, OPTION_EXITONHANGUP)) {
+				goto exit;
 			}
 		}
 
@@ -1089,6 +1099,10 @@
 	if (oldwf && ast_set_write_format(chan, oldwf) < 0)
 		ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
 
+	if (ast_test_flag(&flags, OPTION_EXITONHANGUP)) {
+		ast_verb(3, "Stopped spying due to the spied-on channel hanging up.\n");
+	}
+
 	return res;
 }
 

Modified: team/group/security_events/apps/app_directed_pickup.c
URL: http://svnview.digium.com/svn/asterisk/team/group/security_events/apps/app_directed_pickup.c?view=diff&rev=219892&r1=219891&r2=219892
==============================================================================
--- team/group/security_events/apps/app_directed_pickup.c (original)
+++ team/group/security_events/apps/app_directed_pickup.c Wed Sep 23 04:05:19 2009
@@ -216,7 +216,7 @@
 
 	while ((target = ast_channel_iterator_next(iter))) {
 		ast_channel_lock(target);
-		if (can_pickup(target)) {
+		if ((chan != target) && can_pickup(target)) {
 			break;
 		}
 		ast_channel_unlock(target);

Modified: team/group/security_events/apps/app_followme.c
URL: http://svnview.digium.com/svn/asterisk/team/group/security_events/apps/app_followme.c?view=diff&rev=219892&r1=219891&r2=219892
==============================================================================
--- team/group/security_events/apps/app_followme.c (original)
+++ team/group/security_events/apps/app_followme.c Wed Sep 23 04:05:19 2009
@@ -835,6 +835,10 @@
 			if (outbound) {
 				ast_set_callerid(outbound, caller->cid.cid_num, caller->cid.cid_name, caller->cid.cid_num);
 				ast_channel_inherit_variables(tpargs->chan, outbound);
+				ast_channel_datastore_inherit(tpargs->chan, outbound);
+				ast_string_field_set(outbound, language, tpargs->chan->language);
+				ast_string_field_set(outbound, accountcode, tpargs->chan->accountcode);
+				ast_string_field_set(outbound, musicclass, tpargs->chan->musicclass);
 				ast_verb(3, "calling %s\n", dialarg);
 				if (!ast_call(outbound,dialarg,0)) {
 					tmpuser->ochan = outbound;

Modified: team/group/security_events/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/team/group/security_events/apps/app_meetme.c?view=diff&rev=219892&r1=219891&r2=219892
==============================================================================
--- team/group/security_events/apps/app_meetme.c (original)
+++ team/group/security_events/apps/app_meetme.c Wed Sep 23 04:05:19 2009
@@ -2055,7 +2055,7 @@
 	int res;
 	int retrydahdi;
 	int origfd;
-	int musiconhold = 0;
+	int musiconhold = 0, mohtempstopped = 0;
 	int firstpass = 0;
 	int lastmarked = 0;
 	int currentmarked = 0;
@@ -2095,6 +2095,7 @@
  	struct timeval nexteventts = { 0, };
  	int to;
 	int setusercount = 0;
+	int confsilence = 0, totalsilence = 0;
 
 	if (!(user = ast_calloc(1, sizeof(*user))))
 		return ret;
@@ -2525,6 +2526,11 @@
 
 	conf_flush(fd, chan);
 
+	if (!(dsp = ast_dsp_new())) {
+		ast_log(LOG_WARNING, "Unable to allocate DSP!\n");
+		res = -1;
+	}
+
 	if (confflags & CONFFLAG_AGI) {
 		/* Get name of AGI file to run from $(MEETME_AGI_BACKGROUND)
 		   or use default filename of conf-background.agi */
@@ -2561,10 +2567,6 @@
 			x = 1;
 			ast_channel_setoption(chan, AST_OPTION_TONE_VERIFY, &x, sizeof(char), 0);
 		}	
-		if (confflags & (CONFFLAG_OPTIMIZETALKER | CONFFLAG_MONITORTALKER) && !(dsp = ast_dsp_new())) {
-			ast_log(LOG_WARNING, "Unable to allocate DSP!\n");
-			res = -1;
-		}
 		for (;;) {
 			int menu_was_active = 0;
 
@@ -2933,8 +2935,6 @@
 					}
 
 					if (confflags & (CONFFLAG_OPTIMIZETALKER | CONFFLAG_MONITORTALKER)) {
-						int totalsilence;
-
 						if (user->talking == -1) {
 							user->talking = 0;
 						}
@@ -3275,7 +3275,11 @@
  							if ((conf->transframe[idx]->frametype != AST_FRAME_NULL) &&
 							    can_write(chan, confflags)) {
 								struct ast_frame *cur;
-								
+								if (musiconhold && !ast_dsp_silence(dsp, conf->transframe[idx], &confsilence) && confsilence < MEETME_DELAYDETECTTALK) {
+									ast_moh_stop(chan);
+									mohtempstopped = 1;
+								}
+
 								/* the translator may have returned a list of frames, so
 								   write each one onto the channel
 								*/
@@ -3285,6 +3289,10 @@
 										break;
 									}
 								}
+								if (musiconhold && mohtempstopped && confsilence > MEETME_DELAYDETECTENDTALK) {
+									mohtempstopped = 0;
+									ast_moh_start(chan, NULL, NULL);
+								}
 							}
 						} else {
 							ast_mutex_unlock(&conf->listenlock);
@@ -3292,12 +3300,20 @@
 						}
 						ast_mutex_unlock(&conf->listenlock);
 					} else {
-bailoutandtrynormal:					
+bailoutandtrynormal:
+						if (musiconhold && !ast_dsp_silence(dsp, &fr, &confsilence) && confsilence < MEETME_DELAYDETECTTALK) {
+							ast_moh_stop(chan);
+							mohtempstopped = 1;
+						}
 						if (user->listen.actual) {
 							ast_frame_adjust_volume(&fr, user->listen.actual);
 						}
 						if (can_write(chan, confflags) && ast_write(chan, &fr) < 0) {
 							ast_log(LOG_WARNING, "Unable to write frame to channel %s\n", chan->name);
+						}
+						if (musiconhold && mohtempstopped && confsilence > MEETME_DELAYDETECTENDTALK) {
+							mohtempstopped = 0;
+							ast_moh_start(chan, NULL, NULL);
 						}
 					}
 				} else {

Modified: team/group/security_events/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/group/security_events/apps/app_queue.c?view=diff&rev=219892&r1=219891&r2=219892
==============================================================================
--- team/group/security_events/apps/app_queue.c (original)
+++ team/group/security_events/apps/app_queue.c Wed Sep 23 04:05:19 2009
@@ -2710,6 +2710,7 @@
 
 	/* Inherit specially named variables from parent channel */
 	ast_channel_inherit_variables(qe->chan, tmp->chan);
+	ast_channel_datastore_inherit(qe->chan, tmp->chan);
 
 	/* Presense of ADSI CPE on outgoing channel follows ours */
 	tmp->chan->adsicpe = qe->chan->adsicpe;
@@ -3082,7 +3083,11 @@
 			*to = 0;
 			return NULL;
 		}
+
+		/* Poll for events from both the incoming channel as well as any outgoing channels */
 		winner = ast_waitfor_n(watchers, pos, to);
+
+		/* Service all of the outgoing channels */
 		for (o = start; o; o = o->call_next) {
 			/* We go with a static buffer here instead of using ast_strdupa. Using
 			 * ast_strdupa in a loop like this one can cause a stack overflow
@@ -3231,7 +3236,11 @@
 							if (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) {
 								if (qe->parent->timeoutrestart)
 									*to = orig;
-								ring_one(qe, outgoing, &numbusies);
+								/* Have enough time for a queue member to answer? */
+								if (*to > 500) {
+									ring_one(qe, outgoing, &numbusies);
+									starttime = (long) time(NULL);
+								}
 							}
 							numbusies++;
 							break;
@@ -3246,7 +3255,10 @@
 							if (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) {
 								if (qe->parent->timeoutrestart)
 									*to = orig;
-								ring_one(qe, outgoing, &numbusies);
+								if (*to > 500) {
+									ring_one(qe, outgoing, &numbusies);
+									starttime = (long) time(NULL);
+								}
 							}
 							numbusies++;
 							break;
@@ -3286,18 +3298,23 @@
 						}
 					}
 					ast_frfree(f);
-				} else {
+				} else { /* ast_read() returned NULL */
 					endtime = (long) time(NULL) - starttime;
 					rna(endtime * 1000, qe, on, membername, 1);
 					do_hang(o);
 					if (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) {
 						if (qe->parent->timeoutrestart)
 							*to = orig;
-						ring_one(qe, outgoing, &numbusies);
+						if (*to > 500) {
+							ring_one(qe, outgoing, &numbusies);
+							starttime = (long) time(NULL);
+						}
 					}
 				}
 			}
 		}
+
+		/* If we received an event from the caller, deal with it. */
 		if (winner == in) {
 			f = ast_read(in);
 			if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP))) {

Modified: team/group/security_events/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/group/security_events/apps/app_voicemail.c?view=diff&rev=219892&r1=219891&r2=219892
==============================================================================
--- team/group/security_events/apps/app_voicemail.c (original)
+++ team/group/security_events/apps/app_voicemail.c Wed Sep 23 04:05:19 2009
@@ -323,6 +323,7 @@
 static char greetingfolder[64];
 static char authuser[32];
 static char authpassword[42];
+static int imapversion = 1;
 
 static int expungeonhangup = 1;
 static int imapgreetings = 0;
@@ -592,6 +593,7 @@
 	char imapuser[80];               /*!< IMAP server login */
 	char imappassword[80];           /*!< IMAP server password if authpassword not defined */
 	char imapvmshareid[80];          /*!< Shared mailbox ID to use rather than the dialed one */
+	int imapversion;                 /*!< If configuration changes, use the new values */
 #endif
 	double volgain;                  /*!< Volume gain for voicemails sent via email */
 	AST_LIST_ENTRY(ast_vm_user) list;
@@ -632,6 +634,7 @@
 	MAILSTREAM *mailstream;
 	int vmArrayIndex;
 	char imapuser[80];                   /*!< IMAP server login */
+	int imapversion;
 	int interactive;
 	char introfn[PATH_MAX];              /*!< Name of prepended file */
 	unsigned int quota_limit;
@@ -783,6 +786,7 @@
 static char vm_reenterpassword[80] = "vm-reenterpassword";
 static char vm_mismatch[80] = "vm-mismatch";
 static char vm_invalid_password[80] = "vm-invalid-password";
+static char vm_pls_try_again[80] = "vm-pls-try-again";
 
 static struct ast_flags globalflags = {0};
 
@@ -900,10 +904,13 @@
 #ifdef IMAP_STORAGE
 	} else if (!strcasecmp(var, "imapuser")) {
 		ast_copy_string(vmu->imapuser, value, sizeof(vmu->imapuser));
+		vmu->imapversion = imapversion;
 	} else if (!strcasecmp(var, "imappassword") || !strcasecmp(var, "imapsecret")) {
 		ast_copy_string(vmu->imappassword, value, sizeof(vmu->imappassword));
+		vmu->imapversion = imapversion;
 	} else if (!strcasecmp(var, "imapvmshareid")) {
 		ast_copy_string(vmu->imapvmshareid, value, sizeof(vmu->imapvmshareid));
+		vmu->imapversion = imapversion;
 #endif
 	} else if (!strcasecmp(var, "delete") || !strcasecmp(var, "deletevoicemail")) {
 		ast_set2_flag(vmu, ast_true(value), VM_DELETE);	
@@ -942,6 +949,7 @@
 	} else if (!strcasecmp(var, "exitcontext")) {
 		ast_copy_string(vmu->exit, value, sizeof(vmu->exit));
 	} else if (!strcasecmp(var, "maxmessage") || !strcasecmp(var, "maxsecs")) {
+		vmu->maxsecs = atoi(value);
 		if (vmu->maxsecs <= 0) {
 			ast_log(AST_LOG_WARNING, "Invalid max message length of %s. Using global value %d\n", value, vmmaxsecs);
 			vmu->maxsecs = vmmaxsecs;
@@ -1067,28 +1075,27 @@
  * \param vmu The voicemail user to change the password for.
  * \param password The new value to be set to the password for this user.
  * 
- * This only works if the voicemail user has a unique id, and if there is a realtime engine configured.
+ * This only works if there is a realtime engine configured.
  * This is called from the (top level) vm_change_password.
  *
  * \return zero on success, -1 on error.
  */
 static int change_password_realtime(struct ast_vm_user *vmu, const char *password)
 {
-	int res;
-	if (!ast_strlen_zero(vmu->uniqueid)) {
-		if (strlen(password) > 10) {
-			ast_realtime_require_field("voicemail", "password", RQ_CHAR, strlen(password), SENTINEL);
-		}
-		res = ast_update2_realtime("voicemail", "context", vmu->context, "mailbox", vmu->mailbox, SENTINEL, "password", password, SENTINEL);
-		if (res > 0) {
-			ast_copy_string(vmu->password, password, sizeof(vmu->password));
-			res = 0;
-		} else if (!res) {
-			res = -1;
-		}
-		return res;
-	}
-	return -1;
+	int res = -1;
+	if (!strcmp(vmu->password, password)) {
+		/* No change (but an update would return 0 rows updated, so we opt out here) */
+		return 0;
+	}
+
+	if (strlen(password) > 10) {
+		ast_realtime_require_field("voicemail", "password", RQ_CHAR, strlen(password), SENTINEL);
+	}
+	if (ast_update2_realtime("voicemail", "context", vmu->context, "mailbox", vmu->mailbox, SENTINEL, "password", password, SENTINEL) > 0) {
+		ast_copy_string(vmu->password, password, sizeof(vmu->password));
+		res = 0;
+	}
+	return res;
 }
 
 /*!
@@ -1138,10 +1145,13 @@
 #ifdef IMAP_STORAGE
 		} else if (!strcasecmp(var->name, "imapuser")) {
 			ast_copy_string(retval->imapuser, var->value, sizeof(retval->imapuser));
+			retval->imapversion = imapversion;
 		} else if (!strcasecmp(var->name, "imappassword") || !strcasecmp(var->name, "imapsecret")) {
 			ast_copy_string(retval->imappassword, var->value, sizeof(retval->imappassword));
+			retval->imapversion = imapversion;
 		} else if (!strcasecmp(var->name, "imapvmshareid")) {
 			ast_copy_string(retval->imapvmshareid, var->value, sizeof(retval->imapvmshareid));
+			retval->imapversion = imapversion;
 #endif
 		} else
 			apply_option(retval, var->name, var->value);
@@ -1227,6 +1237,11 @@
 		context = "default";
 
 	AST_LIST_TRAVERSE(&users, cur, list) {
+#ifdef IMAP_STORAGE
+		if (cur->imapversion != imapversion) {
+			continue;
+		}
+#endif
 		if (ast_test_flag((&globalflags), VM_SEARCH) && !strcasecmp(mailbox, cur->mailbox))
 			break;
 		if (context && (!strcasecmp(context, cur->context)) && (!strcasecmp(mailbox, cur->mailbox)))
@@ -2253,6 +2268,7 @@
 	}
 
 	ast_copy_string(vms->imapuser, vmu->imapuser, sizeof(vms->imapuser));
+	vms->imapversion = vmu->imapversion;
 	ast_debug(3, "Before init_mailstream, user is %s\n", vmu->imapuser);
 
 	if ((ret = init_mailstream(vms, box)) || !vms->mailstream) {
@@ -2609,6 +2625,7 @@
 	ast_copy_string(vms_p->username, vmu->mailbox, sizeof(vms_p->username)); /* save for access from interactive entry point */
 	ast_copy_string(vms_p->context, vmu->context, sizeof(vms_p->context));
 	vms_p->mailstream = NIL; /* save for access from interactive entry point */
+	vms_p->imapversion = vmu->imapversion;
 	if (option_debug > 4)
 		ast_log(AST_LOG_DEBUG, "Copied %s to %s\n", vmu->imapuser, vms_p->imapuser);
 	vms_p->updated = 1;
@@ -2636,6 +2653,9 @@
 			ast_debug(3, "error: vms is NULL for %s\n", user);
 			continue;
 		}
+		if (vlist->vms->imapversion != imapversion) {
+			continue;
+		}
 		if (!vlist->vms->imapuser) {
 			ast_debug(3, "error: imapuser is NULL for %s\n", user);
 			continue;
@@ -2670,6 +2690,9 @@
 	AST_LIST_TRAVERSE(&vmstates, vlist, list) {
 		if (!vlist->vms) {
 			ast_debug(3, "error: vms is NULL for %s\n", mailbox);
+			continue;
+		}
+		if (vlist->vms->imapversion != imapversion) {
 			continue;
 		}
 		if (!vlist->vms->username || !vlist->vms->context) {
@@ -8431,6 +8454,9 @@
 		}
 		if (++tries == 3)
 			return -1;
+		if (cmd != 0) {
+			cmd = ast_play_and_wait(chan, vm_pls_try_again);
+		}
 	}
 	if (pwdchange & PWDCHANGE_INTERNAL)
 		vm_change_password(vmu, newpassword);
@@ -8528,6 +8554,9 @@
 			if (cmd != 0) {
 				ast_log(AST_LOG_NOTICE, "Invalid password for user %s (%s)\n", vms->username, newpassword);
 				cmd = ast_play_and_wait(chan, vm_invalid_password);
+				if (!cmd) {
+					cmd = ast_play_and_wait(chan, vm_pls_try_again);
+				}
 				break;
 			}
 			newpassword2[1] = '\0';
@@ -8545,6 +8574,9 @@
 			if (strcmp(newpassword, newpassword2)) {
 				ast_log(AST_LOG_NOTICE, "Password mismatch for user %s (%s != %s)\n", vms->username, newpassword, newpassword2);
 				cmd = ast_play_and_wait(chan, vm_mismatch);
+				if (!cmd) {
+					cmd = ast_play_and_wait(chan, vm_pls_try_again);
+				}
 				break;
 			}
 			if (pwdchange & PWDCHANGE_INTERNAL)
@@ -10711,6 +10743,8 @@
 			mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) 60L);
 		}
 
+		/* Increment configuration version */
+		imapversion++;
 #endif
 		/* External voicemail notify application */
 		if ((val = ast_variable_retrieve(cfg, "general", "externnotify"))) {
@@ -10965,6 +10999,9 @@
 			ast_copy_string(vm_reenterpassword, val, sizeof(vm_reenterpassword));
 		if ((val = ast_variable_retrieve(cfg, "general", "vm-mismatch")))
 			ast_copy_string(vm_mismatch, val, sizeof(vm_mismatch));
+		if ((val = ast_variable_retrieve(cfg, "general", "vm-pls-try-again"))) {
+			ast_copy_string(vm_pls_try_again, val, sizeof(vm_pls_try_again));
+		}
 		/* load configurable audio prompts */
 		if ((val = ast_variable_retrieve(cfg, "general", "listen-control-forward-key")) && is_valid_dtmf(val))
 			ast_copy_string(listen_control_forward_key, val, sizeof(listen_control_forward_key));

Modified: team/group/security_events/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/group/security_events/channels/chan_dahdi.c?view=diff&rev=219892&r1=219891&r2=219892
==============================================================================
--- team/group/security_events/channels/chan_dahdi.c (original)
+++ team/group/security_events/channels/chan_dahdi.c Wed Sep 23 04:05:19 2009
@@ -565,10 +565,8 @@
 	struct dahdi_pvt *pvts[MAX_CHANNELS];     /*!< Member channel pvt structs */
 	int numchans;                          /*!< Number of channels in this R2 block */
 	int monitored_count;                   /*!< Number of channels being monitored */
-	ast_mutex_t monitored_count_lock;      /*!< lock access to the counter */
-	ast_cond_t do_monitor;                 /*!< Condition to wake up the monitor thread when there's work to do */
-
 };
+
 struct dahdi_mfcr2_conf {
 	openr2_variant_t variant;
 	int mfback_timeout;
@@ -683,7 +681,13 @@
 	mwisend_states 	mwisend_current;
 };
 
-static struct dahdi_pvt {
+/*! Specify the lists dahdi_pvt can be put in. */
+enum DAHDI_IFLIST {
+	DAHDI_IFLIST_NONE,	/*!< The dahdi_pvt is not in any list. */
+	DAHDI_IFLIST_MAIN,	/*!< The dahdi_pvt is in the main interface list */
+};
+
+struct dahdi_pvt {
 	ast_mutex_t lock;
 	struct callerid_state *cs;
 	struct ast_channel *owner;			/*!< Our current active owner (if applicable) */
@@ -718,6 +722,7 @@
 	/*! \brief Tx gain set by chan_dahdi.conf */
 	float txgain;
 	int tonezone;					/*!< tone zone for this chan, or -1 for default */
+	enum DAHDI_IFLIST which_iflist;	/*!< Which interface list is this structure listed? */
 	struct dahdi_pvt *next;				/*!< Next channel in list */
 	struct dahdi_pvt *prev;				/*!< Prev channel in list */
 
@@ -784,7 +789,7 @@
 	unsigned int dialing:1;
 	/*! \brief TRUE if the transfer capability of the call is digital. */
 	unsigned int digital:1;
-	/*! \brief TRUE if Do-Not-Disturb is enabled. */
+	/*! \brief TRUE if Do-Not-Disturb is enabled, present only for non sig_analog */
 	unsigned int dnd:1;
 	/*! \brief XXX BOOLEAN Purpose??? */
 	unsigned int echobreak:1;
@@ -946,12 +951,12 @@
 	unsigned int inservice:1;
 	/*!
 	 * \brief TRUE if the channel is locally blocked.
-	 * \note Applies to SS7 channels.
+	 * \note Applies to SS7 and MFCR2 channels.
 	 */
 	unsigned int locallyblocked:1;
 	/*!
 	 * \brief TRUE if the channel is remotely blocked.
-	 * \note Applies to SS7 channels.
+	 * \note Applies to SS7 and MFCR2 channels.
 	 */
 	unsigned int remotelyblocked:1;
 #if defined(HAVE_PRI)
@@ -1248,7 +1253,10 @@
 	/*! \brief TRUE if confrence is muted. */
 	int muting;
 	void *sig_pvt;
-} *iflist = NULL, *ifend = NULL;
+};
+
+static struct dahdi_pvt *iflist = NULL;	/*!< Main interface list start */
+static struct dahdi_pvt *ifend = NULL;	/*!< Main interface list end */
 
 /*! \brief Channel configuration from chan_dahdi.conf .
  * This struct is used for parsing the [channels] section of chan_dahdi.conf.
@@ -1416,7 +1424,6 @@
 static int dahdi_setoption(struct ast_channel *chan, int option, void *data, int datalen);
 static int dahdi_queryoption(struct ast_channel *chan, int option, void *data, int *datalen);
 static int dahdi_func_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
-static int handle_init_event(struct dahdi_pvt *i, int event);
 static int dahdi_func_write(struct ast_channel *chan, const char *function, char *data, const char *value);
 
 static const struct ast_channel_tech dahdi_tech = {
@@ -1807,7 +1814,7 @@
 	p->callwaitingrepeat = CALLWAITING_REPEAT_SAMPLES;
 	if (p->cidspill) {
 		ast_log(LOG_WARNING, "Spill already exists?!?\n");
-		free(p->cidspill);
+		ast_free(p->cidspill);
 	}
 	if (!(p->cidspill = ast_malloc(2400 /* SAS */ + 680 /* CAS */ + READ_SIZE * 4)))
 		return -1;
@@ -1837,7 +1844,7 @@
 
 	if (p->cidspill) {
 		ast_log(LOG_WARNING, "cidspill already exists??\n");
-		free(p->cidspill);
+		ast_free(p->cidspill);
 	}
 
 	if ((p->cidspill = ast_malloc(MAX_CALLERID_SIZE))) {
@@ -2102,6 +2109,15 @@
 	}
 
 	return 0;
+}
+
+static void my_cancel_cidspill(void *pvt)
+{
+	struct dahdi_pvt *p = pvt;
+	if (p->cidspill) {
+		ast_free(p->cidspill);
+		p->cidspill = NULL;
+	}
 }
 
 static void my_increase_ss_count(void)
@@ -2395,6 +2411,9 @@
 	case DAHDI_EVENT_PULSE_START:
 		res = ANALOG_EVENT_PULSE_START;
 	break;
+	case DAHDI_EVENT_REMOVED:
+		res = ANALOG_EVENT_REMOVED;
+	break;
 	case DAHDI_EVENT_NEONMWI_ACTIVE:
 		res = ANALOG_EVENT_NEONMWI_ACTIVE;
 		break;
@@ -2434,6 +2453,8 @@
 	struct dahdi_pvt *p = pvt;
 	int res;
 	struct dahdi_params par;
+
+	memset(&par, 0, sizeof(par));
 
 	if (p->subs[SUB_REAL].dfd > -1)
 		res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &par);
@@ -2833,6 +2854,7 @@
 	.check_waitingfordt = my_check_waitingfordt,
 	.set_confirmanswer = my_set_confirmanswer,
 	.check_confirmanswer = my_check_confirmanswer,
+	.cancel_cidspill = my_cancel_cidspill,
 };
 
 static struct dahdi_pvt *round_robin[32];
@@ -3009,7 +3031,7 @@
 	p->mfcr2_answer_pending = 0;
 	p->mfcr2_call_accepted = 0;
 	ast_mutex_unlock(&p->lock);
-	ast_log(LOG_NOTICE, "New MFC/R2 call detected on chan %d.\n", openr2_chan_get_number(r2chan));
+	ast_verbose("New MFC/R2 call detected on chan %d.\n", openr2_chan_get_number(r2chan));
 }
 
 static void dahdi_r2_on_hardware_alarm(openr2_chan_t *r2chan, int alarm)
@@ -3046,24 +3068,6 @@
 	ast_mutex_unlock(&p->lock);
 }
 
-static void dahdi_r2_update_monitor_count(struct dahdi_mfcr2 *mfcr2, int increment)
-{
-	ast_mutex_lock(&mfcr2->monitored_count_lock);
-	if (increment) {
-		mfcr2->monitored_count++;
-		if (mfcr2->monitored_count == 1) {
-			ast_log(LOG_DEBUG, "At least one device needs monitoring, let's wake up the monitor thread.\n");
-			ast_cond_signal(&mfcr2->do_monitor);
-		}
-	} else {
-		mfcr2->monitored_count--;
-		if (mfcr2->monitored_count < 0) {
-			ast_log(LOG_ERROR, "we have a bug here!.\n");
-		}
-	}
-	ast_mutex_unlock(&mfcr2->monitored_count_lock);
-}
-
 static void dahdi_r2_disconnect_call(struct dahdi_pvt *p, openr2_call_disconnect_cause_t cause)
 {
 	if (openr2_chan_disconnect_call(p->r2chan, cause)) {
@@ -3081,7 +3085,7 @@
 {
 	struct dahdi_pvt *p;
 	struct ast_channel *c;
-	ast_log(LOG_NOTICE, "MFC/R2 call offered on chan %d. ANI = %s, DNIS = %s, Category = %s\n",
+	ast_verbose("MFC/R2 call offered on chan %d. ANI = %s, DNIS = %s, Category = %s\n",
 			openr2_chan_get_number(r2chan), ani ? ani : "(restricted)", dnis,
 			openr2_proto_get_category_string(category));
 	p = openr2_chan_get_client_data(r2chan);
@@ -3116,7 +3120,6 @@
 		/* The user wants us to start the PBX thread right away without accepting the call first */
 		c = dahdi_new(p, AST_STATE_RING, 1, SUB_REAL, DAHDI_LAW_ALAW, 0, NULL);
 		if (c) {
-			dahdi_r2_update_monitor_count(p->mfcr2, 0);
 			/* Done here, don't disable reading now since we still need to generate MF tones to accept
 			   the call or reject it and detect the tone off condition of the other end, all of this
 			   will be done in the PBX thread now */
@@ -3136,7 +3139,7 @@
 static void dahdi_r2_on_call_end(openr2_chan_t *r2chan)
 {
 	struct dahdi_pvt *p = openr2_chan_get_client_data(r2chan);
-	ast_log(LOG_NOTICE, "MFC/R2 call end on chan %d\n", p->channel);
+	ast_verbose("MFC/R2 call end on channel %d\n", p->channel);
 	ast_mutex_lock(&p->lock);
 	p->mfcr2call = 0;
 	ast_mutex_unlock(&p->lock);
@@ -3147,12 +3150,12 @@
 {
 	struct dahdi_pvt *p = NULL;
 	struct ast_channel *c = NULL;

[... 4164 lines stripped ...]



More information about the asterisk-commits mailing list