[asterisk-commits] branch bweschke/findme_followme r9204 - in /team/bweschke/findme_followme: ./...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Feb 7 13:51:37 MST 2006


Author: bweschke
Date: Tue Feb  7 14:50:13 2006
New Revision: 9204

URL: http://svn.digium.com/view/asterisk?rev=9204&view=rev
Log:
 Yes. This project really is still alive. Bringing it up to date with /trunk


Added:
    team/bweschke/findme_followme/channels/misdn/mISDN.patch
      - copied unchanged from r9156, branches/1.2/channels/misdn/mISDN.patch
    team/bweschke/findme_followme/channels/misdn/mISDNuser.patch
      - copied unchanged from r9156, branches/1.2/channels/misdn/mISDNuser.patch
Removed:
    team/bweschke/findme_followme/ChangeLog
    team/bweschke/findme_followme/ast_expr.y
Modified:
    team/bweschke/findme_followme/   (props changed)
    team/bweschke/findme_followme/Makefile
    team/bweschke/findme_followme/app.c
    team/bweschke/findme_followme/apps/app_chanspy.c
    team/bweschke/findme_followme/apps/app_cut.c
    team/bweschke/findme_followme/apps/app_dial.c
    team/bweschke/findme_followme/apps/app_directed_pickup.c
    team/bweschke/findme_followme/apps/app_externalivr.c
    team/bweschke/findme_followme/apps/app_festival.c
    team/bweschke/findme_followme/apps/app_hasnewvoicemail.c
    team/bweschke/findme_followme/apps/app_macro.c
    team/bweschke/findme_followme/apps/app_meetme.c
    team/bweschke/findme_followme/apps/app_milliwatt.c
    team/bweschke/findme_followme/apps/app_mixmonitor.c
    team/bweschke/findme_followme/apps/app_privacy.c
    team/bweschke/findme_followme/apps/app_queue.c
    team/bweschke/findme_followme/apps/app_sms.c
    team/bweschke/findme_followme/apps/app_stack.c
    team/bweschke/findme_followme/apps/app_voicemail.c
    team/bweschke/findme_followme/apps/app_waitforsilence.c
    team/bweschke/findme_followme/ast_expr2.c
    team/bweschke/findme_followme/ast_expr2.fl
    team/bweschke/findme_followme/ast_expr2.h
    team/bweschke/findme_followme/ast_expr2.y
    team/bweschke/findme_followme/ast_expr2f.c
    team/bweschke/findme_followme/asterisk.c
    team/bweschke/findme_followme/build_tools/make_svn_branch_name
    team/bweschke/findme_followme/cdr.c
    team/bweschke/findme_followme/cdr/cdr_tds.c
    team/bweschke/findme_followme/channel.c
    team/bweschke/findme_followme/channels/Makefile
    team/bweschke/findme_followme/channels/chan_agent.c
    team/bweschke/findme_followme/channels/chan_alsa.c
    team/bweschke/findme_followme/channels/chan_features.c
    team/bweschke/findme_followme/channels/chan_iax2.c
    team/bweschke/findme_followme/channels/chan_misdn.c
    team/bweschke/findme_followme/channels/chan_sip.c
    team/bweschke/findme_followme/channels/chan_zap.c
    team/bweschke/findme_followme/channels/misdn/Makefile
    team/bweschke/findme_followme/channels/misdn/isdn_msg_parser.c
    team/bweschke/findme_followme/cli.c
    team/bweschke/findme_followme/config.c
    team/bweschke/findme_followme/configs/sip.conf.sample
    team/bweschke/findme_followme/configs/voicemail.conf.sample
    team/bweschke/findme_followme/db.c
    team/bweschke/findme_followme/doc/README.ael
    team/bweschke/findme_followme/doc/README.cdr
    team/bweschke/findme_followme/doc/README.misdn
    team/bweschke/findme_followme/doc/README.variables
    team/bweschke/findme_followme/file.c
    team/bweschke/findme_followme/formats/format_pcm.c
    team/bweschke/findme_followme/formats/format_pcm_alaw.c
    team/bweschke/findme_followme/funcs/func_moh.c
    team/bweschke/findme_followme/funcs/func_strings.c
    team/bweschke/findme_followme/include/asterisk/chanspy.h
    team/bweschke/findme_followme/include/asterisk/linkedlists.h
    team/bweschke/findme_followme/include/asterisk/strings.h
    team/bweschke/findme_followme/loader.c
    team/bweschke/findme_followme/logger.c
    team/bweschke/findme_followme/manager.c
    team/bweschke/findme_followme/pbx.c
    team/bweschke/findme_followme/pbx/pbx_ael.c
    team/bweschke/findme_followme/pbx/pbx_config.c
    team/bweschke/findme_followme/pbx/pbx_dundi.c
    team/bweschke/findme_followme/pbx/pbx_spool.c
    team/bweschke/findme_followme/res/res_agi.c
    team/bweschke/findme_followme/res/res_features.c
    team/bweschke/findme_followme/res/res_monitor.c
    team/bweschke/findme_followme/res/res_odbc.c
    team/bweschke/findme_followme/translate.c
    team/bweschke/findme_followme/utils.c
    team/bweschke/findme_followme/utils/astman.c

Propchange: team/bweschke/findme_followme/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Feb  7 14:50:13 2006
@@ -1,1 +1,1 @@
-/branches/1.2:1-7430
+/branches/1.2:1-9203

Modified: team/bweschke/findme_followme/Makefile
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/Makefile?rev=9204&r1=9203&r2=9204&view=diff
==============================================================================
--- team/bweschke/findme_followme/Makefile (original)
+++ team/bweschke/findme_followme/Makefile Tue Feb  7 14:50:13 2006
@@ -322,8 +322,6 @@
   ifneq ($(wildcard .svn),)
     ASTERISKVERSIONNUM=999999
     ASTERISKVERSION=SVN-$(shell build_tools/make_svn_branch_name)
-  else
-    ASTERISKVERSIONNUM=000000
   endif
 endif
 

Modified: team/bweschke/findme_followme/app.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/app.c?rev=9204&r1=9203&r2=9204&view=diff
==============================================================================
--- team/bweschke/findme_followme/app.c (original)
+++ team/bweschke/findme_followme/app.c Tue Feb  7 14:50:13 2006
@@ -316,8 +316,12 @@
 				}
 			}
 		}
-		if (peer)
-			res = ast_autoservice_stop(peer);
+		if (peer) {
+			/* Stop autoservice on the peer channel, but don't overwrite any error condition 
+			   that has occurred previously while acting on the primary channel */	
+			if (ast_autoservice_stop(peer) && !res)
+				res = -1;
+		}
 	}
 	return res;
 }
@@ -430,11 +434,11 @@
 			   const char *stop, const char *pause,
 			   const char *restart, int skipms) 
 {
-	long elapsed = 0, last_elapsed = 0;
 	char *breaks = NULL;
 	char *end = NULL;
 	int blen = 2;
 	int res;
+	long pause_restart_point = 0;
 
 	if (stop)
 		blen += strlen(stop);
@@ -456,9 +460,6 @@
 	if (chan->_state != AST_STATE_UP)
 		res = ast_answer(chan);
 
-	if (chan)
-		ast_stopstream(chan);
-
 	if (file) {
 		if ((end = strchr(file,':'))) {
 			if (!strcasecmp(end, ":end")) {
@@ -469,25 +470,18 @@
 	}
 
 	for (;;) {
-		struct timeval started = ast_tvnow();
-
-		if (chan)
-			ast_stopstream(chan);
+		ast_stopstream(chan);
 		res = ast_streamfile(chan, file, chan->language);
 		if (!res) {
-			if (end) {
+			if (pause_restart_point) {
+				ast_seekstream(chan->stream, pause_restart_point, SEEK_SET);
+				pause_restart_point = 0;
+			}
+			else if (end) {
 				ast_seekstream(chan->stream, 0, SEEK_END);
-				end=NULL;
-			}
-			res = 1;
-			if (elapsed) {
-				ast_stream_fastforward(chan->stream, elapsed);
-				last_elapsed = elapsed - 200;
-			}
-			if (res)
-				res = ast_waitstream_fr(chan, breaks, fwd, rev, skipms);
-			else
-				break;
+				end = NULL;
+			};
+			res = ast_waitstream_fr(chan, breaks, fwd, rev, skipms);
 		}
 
 		if (res < 1)
@@ -496,17 +490,16 @@
 		/* We go at next loop if we got the restart char */
 		if (restart && strchr(restart, res)) {
 			ast_log(LOG_DEBUG, "we'll restart the stream here at next loop\n");
-			elapsed=0; /* To make sure the next stream will start at beginning */
+			pause_restart_point = 0;
 			continue;
 		}
 
-		if (pause != NULL && strchr(pause, res)) {
-			elapsed = ast_tvdiff_ms(ast_tvnow(), started) + last_elapsed;
-			for(;;) {
-				if (chan)
-					ast_stopstream(chan);
+		if (pause && strchr(pause, res)) {
+			pause_restart_point = ast_tellstream(chan->stream);
+			for (;;) {
+				ast_stopstream(chan);
 				res = ast_waitfordigit(chan, 1000);
-				if (res == 0)
+				if (!res)
 					continue;
 				else if (res == -1 || strchr(pause, res) || (stop && strchr(stop, res)))
 					break;
@@ -516,17 +509,16 @@
 				continue;
 			}
 		}
+
 		if (res == -1)
 			break;
 
 		/* if we get one of our stop chars, return it to the calling function */
-		if (stop && strchr(stop, res)) {
-			/* res = 0; */
-			break;
-		}
-	}
-	if (chan)
-		ast_stopstream(chan);
+		if (stop && strchr(stop, res))
+			break;
+	}
+
+	ast_stopstream(chan);
 
 	return res;
 }

Modified: team/bweschke/findme_followme/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_chanspy.c?rev=9204&r1=9203&r2=9204&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_chanspy.c (original)
+++ team/bweschke/findme_followme/apps/app_chanspy.c Tue Feb  7 14:50:13 2006
@@ -208,9 +208,9 @@
 
 static void stop_spying(struct ast_channel *chan, struct ast_channel_spy *spy) 
 {
-	/* If our status has changed, then the channel we're spying on is gone....
+	/* If our status has changed to DONE, then the channel we're spying on is gone....
 	   DON'T TOUCH IT!!!  RUN AWAY!!! */
-	if (spy->status != CHANSPY_RUNNING)
+	if (spy->status == CHANSPY_DONE)
 		return;
 
 	if (!chan)
@@ -439,8 +439,8 @@
 
 	if (recbase) {
 		char filename[512];
-		snprintf(filename,sizeof(filename),"%s/%s.%ld.raw",ast_config_AST_MONITOR_DIR, recbase, time(NULL));
-		if ((fd = open(filename, O_CREAT | O_WRONLY, O_TRUNC)) <= 0) {
+		snprintf(filename,sizeof(filename),"%s/%s.%d.raw",ast_config_AST_MONITOR_DIR, recbase, (int)time(NULL));
+		if ((fd = open(filename, O_CREAT | O_WRONLY, O_TRUNC, 0644)) <= 0) {
 			ast_log(LOG_WARNING, "Cannot open %s for recording\n", filename);
 			fd = 0;
 		}
@@ -482,7 +482,7 @@
 					}
 				}
 				
-				if (igrp && (!spec || ((strlen(spec) < strlen(peer->name) &&
+				if (igrp && (!spec || ((strlen(spec) <= strlen(peer->name) &&
 							!strncasecmp(peer->name, spec, strlen(spec)))))) {
 					if (peer && (!bronly || ast_bridged_channel(peer)) &&
 					    !ast_check_hangup(peer) && !ast_test_flag(peer, AST_FLAG_SPYING)) {

Modified: team/bweschke/findme_followme/apps/app_cut.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_cut.c?rev=9204&r1=9203&r2=9204&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_cut.c (original)
+++ team/bweschke/findme_followme/apps/app_cut.c Tue Feb  7 14:50:13 2006
@@ -120,8 +120,9 @@
 		int blen = strlen(buffer);
 		if (element_count++) {
 			strncat(buffer + blen, ",", buflen - blen - 1);
-		}
-		strncat(buffer + blen + 1, sortable_keys[count2].key, buflen - blen - 2);
+			blen++;
+		}
+		strncat(buffer + blen, sortable_keys[count2].key, buflen - blen - 1);
 	}
 
 	return 0;

Modified: team/bweschke/findme_followme/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_dial.c?rev=9204&r1=9203&r2=9204&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_dial.c (original)
+++ team/bweschke/findme_followme/apps/app_dial.c Tue Feb  7 14:50:13 2006
@@ -161,7 +161,7 @@
 "    S(x) - Hang up the call after 'x' seconds *after* the called party has\n"
 "           answered the call.\n"  	
 "    t    - Allow the called party to transfer the calling party by sending the\n"
-"           DTMF sequence defiend in features.conf.\n"
+"           DTMF sequence defined in features.conf.\n"
 "    T    - Allow the calling party to transfer the called party by sending the\n"
 "           DTMF sequence defined in features.conf.\n"
 "    w    - Allow the called party to enable recording of the call by sending\n"
@@ -648,6 +648,7 @@
 					ast_hangup(o->chan);
 					o->chan = NULL;
 					ast_clear_flag(o, DIAL_STILLGOING);
+					HANDLE_CAUSE(in->hangupcause, in);
 				}
 			}
 			o = o->next;
@@ -962,7 +963,7 @@
 	/* If a channel group has been specified, get it for use when we create peer channels */
 	outbound_group = pbx_builtin_getvar_helper(chan, "OUTBOUND_GROUP");
 
-	ast_copy_flags(peerflags, &opts, OPT_DTMF_EXIT | OPT_GO_ON | OPT_ORIGINAL_CLID);
+	ast_copy_flags(peerflags, &opts, OPT_DTMF_EXIT | OPT_GO_ON | OPT_ORIGINAL_CLID | OPT_CALLER_HANGUP);
 	cur = args.peers;
 	do {
 		/* Remember where to start next time */

Modified: team/bweschke/findme_followme/apps/app_directed_pickup.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_directed_pickup.c?rev=9204&r1=9203&r2=9204&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_directed_pickup.c (original)
+++ team/bweschke/findme_followme/apps/app_directed_pickup.c Tue Feb  7 14:50:13 2006
@@ -77,7 +77,7 @@
 
 	/* Find a channel to pickup */
 	origin = ast_get_channel_by_exten_locked(exten, context);
-	if (origin) {
+	if (origin && origin->cdr) {
 		ast_cdr_getvar(origin->cdr, "dstchannel", &tmp, workspace,
 			       sizeof(workspace), 0);
 		if (tmp) {
@@ -89,6 +89,8 @@
 		}
 		ast_mutex_unlock(&origin->lock);
 	} else {
+		if (origin)
+			ast_mutex_unlock(&origin->lock);
 		ast_log(LOG_DEBUG, "No originating channel found.\n");
 	}
 	

Modified: team/bweschke/findme_followme/apps/app_externalivr.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_externalivr.c?rev=9204&r1=9203&r2=9204&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_externalivr.c (original)
+++ team/bweschke/findme_followme/apps/app_externalivr.c Tue Feb  7 14:50:13 2006
@@ -94,9 +94,9 @@
 	char tmp[256];
 
 	if (!data) {
-		snprintf(tmp, sizeof(tmp), "%c,%10ld", event, time(NULL));
+		snprintf(tmp, sizeof(tmp), "%c,%10d", event, (int)time(NULL));
 	} else {
-		snprintf(tmp, sizeof(tmp), "%c,%10ld,%s", event, time(NULL), data);
+		snprintf(tmp, sizeof(tmp), "%c,%10d,%s", event, (int)time(NULL), data);
 	}
 
 	fprintf(handle, "%s\n", tmp);
@@ -345,8 +345,6 @@
 			goto exit;
 		}
 
-		setvbuf(child_events, NULL, _IONBF, 0);
-
 		if (!(child_commands = fdopen(child_commands_fd, "r"))) {
 			ast_chan_log(LOG_WARNING, chan, "Could not open stream for child commands\n");
 			goto exit;
@@ -356,6 +354,10 @@
 			ast_chan_log(LOG_WARNING, chan, "Could not open stream for child errors\n");
 			goto exit;
 		}
+
+		setvbuf(child_events, NULL, _IONBF, 0);
+		setvbuf(child_commands, NULL, _IONBF, 0);
+		setvbuf(child_errors, NULL, _IONBF, 0);
 
 		res = 0;
 

Modified: team/bweschke/findme_followme/apps/app_festival.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_festival.c?rev=9204&r1=9203&r2=9204&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_festival.c (original)
+++ team/bweschke/findme_followme/apps/app_festival.c Tue Feb  7 14:50:13 2006
@@ -175,7 +175,8 @@
 	if (chan->_state != AST_STATE_UP)
 		ast_answer(chan);
 	ast_stopstream(chan);
-
+	ast_indicate(chan, -1);
+	
 	owriteformat = chan->writeformat;
 	res = ast_set_write_format(chan, AST_FORMAT_SLINEAR);
 	if (res < 0) {

Modified: team/bweschke/findme_followme/apps/app_hasnewvoicemail.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_hasnewvoicemail.c?rev=9204&r1=9203&r2=9204&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_hasnewvoicemail.c (original)
+++ team/bweschke/findme_followme/apps/app_hasnewvoicemail.c Tue Feb  7 14:50:13 2006
@@ -90,7 +90,6 @@
 		while ((vment = readdir(vmdir))) {
 			if (!strncmp(vment->d_name + 7, ".txt", 4)) {
 				count++;
-				break;
 			}
 		}
 		closedir(vmdir);

Modified: team/bweschke/findme_followme/apps/app_macro.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_macro.c?rev=9204&r1=9203&r2=9204&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_macro.c (original)
+++ team/bweschke/findme_followme/apps/app_macro.c Tue Feb  7 14:50:13 2006
@@ -105,7 +105,7 @@
 	char oldcontext[AST_MAX_CONTEXT] = "";
 	int offset, depth = 0;
 	int setmacrocontext=0;
-	int autoloopflag;
+	int autoloopflag, dead = 0;
   
 	char *save_macro_exten;
 	char *save_macro_context;
@@ -214,8 +214,8 @@
 				break;
 			}
 			switch(res) {
-	        	case MACRO_EXIT_RESULT:
-                        	res = 0;
+			case MACRO_EXIT_RESULT:
+				res = 0;
 				goto out;
 			case AST_PBX_KEEPALIVE:
 				if (option_debug)
@@ -229,6 +229,7 @@
 					ast_log(LOG_DEBUG, "Spawn extension (%s,%s,%d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, chan->name, macro);
 				else if (option_verbose > 1)
 					ast_verbose( VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, chan->name, macro);
+				dead = 1;
 				goto out;
 			}
 		}
@@ -248,37 +249,44 @@
 	out:
 	/* Reset the depth back to what it was when the routine was entered (like if we called Macro recursively) */
 	snprintf(depthc, sizeof(depthc), "%d", depth);
-	pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc);
-
-	ast_set2_flag(chan, autoloopflag, AST_FLAG_IN_AUTOLOOP);
-  	for (x=1; x<argc; x++) {
+	if (!dead) {
+		pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc);
+
+		ast_set2_flag(chan, autoloopflag, AST_FLAG_IN_AUTOLOOP);
+	}
+
+  	for (x = 1; x < argc; x++) {
   		/* Restore old arguments and delete ours */
 		snprintf(varname, sizeof(varname), "ARG%d", x);
   		if (oldargs[x]) {
-			pbx_builtin_setvar_helper(chan, varname, oldargs[x]);
+			if (!dead)
+				pbx_builtin_setvar_helper(chan, varname, oldargs[x]);
 			free(oldargs[x]);
-		} else {
+		} else if (!dead) {
 			pbx_builtin_setvar_helper(chan, varname, NULL);
 		}
   	}
 
 	/* Restore macro variables */
-	pbx_builtin_setvar_helper(chan, "MACRO_EXTEN", save_macro_exten);
+	if (!dead) {
+		pbx_builtin_setvar_helper(chan, "MACRO_EXTEN", save_macro_exten);
+		pbx_builtin_setvar_helper(chan, "MACRO_CONTEXT", save_macro_context);
+		pbx_builtin_setvar_helper(chan, "MACRO_PRIORITY", save_macro_priority);
+	}
 	if (save_macro_exten)
 		free(save_macro_exten);
-	pbx_builtin_setvar_helper(chan, "MACRO_CONTEXT", save_macro_context);
 	if (save_macro_context)
 		free(save_macro_context);
-	pbx_builtin_setvar_helper(chan, "MACRO_PRIORITY", save_macro_priority);
 	if (save_macro_priority)
 		free(save_macro_priority);
-	if (setmacrocontext) {
+
+	if (!dead && setmacrocontext) {
 		chan->macrocontext[0] = '\0';
 		chan->macroexten[0] = '\0';
 		chan->macropriority = 0;
 	}
 
-	if (!strcasecmp(chan->context, fullmacro)) {
+	if (!dead && !strcasecmp(chan->context, fullmacro)) {
   		/* If we're leaving the macro normally, restore original information */
 		chan->priority = oldpriority;
 		ast_copy_string(chan->context, oldcontext, sizeof(chan->context));
@@ -298,7 +306,8 @@
 		}
 	}
 
-	pbx_builtin_setvar_helper(chan, "MACRO_OFFSET", save_macro_offset);
+	if (!dead)
+		pbx_builtin_setvar_helper(chan, "MACRO_OFFSET", save_macro_offset);
 	if (save_macro_offset)
 		free(save_macro_offset);
 	LOCAL_USER_REMOVE(u);

Modified: team/bweschke/findme_followme/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_meetme.c?rev=9204&r1=9203&r2=9204&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_meetme.c (original)
+++ team/bweschke/findme_followme/apps/app_meetme.c Tue Feb  7 14:50:13 2006
@@ -263,14 +263,17 @@
 		return "(not talking)";
 }
 
-static int careful_write(int fd, unsigned char *data, int len)
+static int careful_write(int fd, unsigned char *data, int len, int block)
 {
 	int res;
 	int x;
 
 	while (len) {
-		x = ZT_IOMUX_WRITE | ZT_IOMUX_SIGEVENT;
-		res = ioctl(fd, ZT_IOMUX, &x);
+		if (block) {
+			x = ZT_IOMUX_WRITE | ZT_IOMUX_SIGEVENT;
+			res = ioctl(fd, ZT_IOMUX, &x);
+		} else
+			res = 0;
 		if (res >= 0)
 			res = write(fd, data, len);
 		if (res < 1) {
@@ -423,7 +426,7 @@
 		len = 0;
 	}
 	if (data) 
-		careful_write(conf->fd, data, len);
+		careful_write(conf->fd, data, len, 1);
 
 	ast_mutex_unlock(&conflock);
 
@@ -1308,7 +1311,11 @@
 						   audio frames (in which case carefully writing would only
 						   have delayed the audio even further).
 						*/
-						write(fd, f->data, f->datalen);
+						/* As it turns out, we do want to use careful write.  We just
+						   don't want to block, but we do want to at least *try*
+						   to write out all the samples.
+						 */
+						careful_write(fd, f->data, f->datalen, 0);
 					}
 				} else if ((f->frametype == AST_FRAME_DTMF) && (confflags & CONFFLAG_EXIT_CONTEXT)) {
 					char tmp[2];
@@ -1631,7 +1638,8 @@
 			if (dynamic_pin) {
 				if (dynamic_pin[0] == 'q') {
 					/* Query the user to enter a PIN */
-					ast_app_getdata(chan, "conf-getpin", dynamic_pin, AST_MAX_EXTENSION - 1, 0);
+					if (ast_app_getdata(chan, "conf-getpin", dynamic_pin, AST_MAX_EXTENSION - 1, 0) < 0)
+						return NULL;
 				}
 				cnf = build_conf(confno, dynamic_pin, "", make, dynamic);
 			} else {

Modified: team/bweschke/findme_followme/apps/app_milliwatt.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_milliwatt.c?rev=9204&r1=9203&r2=9204&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_milliwatt.c (original)
+++ team/bweschke/findme_followme/apps/app_milliwatt.c Tue Feb  7 14:50:13 2006
@@ -73,30 +73,29 @@
 static int milliwatt_generate(struct ast_channel *chan, void *data, int len, int samples)
 {
 	struct ast_frame wf;
-	unsigned char waste[AST_FRIENDLY_OFFSET];
-	unsigned char buf[640];
+	unsigned char buf[AST_FRIENDLY_OFFSET + 640];
 	int i,*indexp = (int *) data;
 
-	if (len > sizeof(buf))
+	if (len + AST_FRIENDLY_OFFSET > sizeof(buf))
 	{
-		ast_log(LOG_WARNING,"Only doing %d bytes (%d bytes requested)\n",(int)sizeof(buf),len);
-		len = sizeof(buf);
+		ast_log(LOG_WARNING,"Only doing %d bytes (%d bytes requested)\n",(int)(sizeof(buf) - AST_FRIENDLY_OFFSET),len);
+		len = sizeof(buf) - AST_FRIENDLY_OFFSET;
 	}
-	waste[0] = 0; /* make compiler happy */
 	wf.frametype = AST_FRAME_VOICE;
 	wf.subclass = AST_FORMAT_ULAW;
 	wf.offset = AST_FRIENDLY_OFFSET;
 	wf.mallocd = 0;
-	wf.data = buf;
+	wf.data = buf + AST_FRIENDLY_OFFSET;
 	wf.datalen = len;
 	wf.samples = wf.datalen;
 	wf.src = "app_milliwatt";
 	wf.delivery.tv_sec = 0;
 	wf.delivery.tv_usec = 0;
+	wf.prev = wf.next = NULL;
 	/* create a buffer containing the digital milliwatt pattern */
 	for(i = 0; i < len; i++)
 	{
-		buf[i] = digital_milliwatt[(*indexp)++];
+		buf[AST_FRIENDLY_OFFSET + i] = digital_milliwatt[(*indexp)++];
 		*indexp &= 7;
 	}
 	if (ast_write(chan,&wf) < 0)

Modified: team/bweschke/findme_followme/apps/app_mixmonitor.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_mixmonitor.c?rev=9204&r1=9203&r2=9204&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_mixmonitor.c (original)
+++ team/bweschke/findme_followme/apps/app_mixmonitor.c Tue Feb  7 14:50:13 2006
@@ -112,9 +112,9 @@
 
 static void stopmon(struct ast_channel *chan, struct ast_channel_spy *spy) 
 {
-	/* If our status has changed, then the channel we're spying on is gone....
+	/* If our status has changed to DONE, then the channel we're spying on is gone....
 	   DON'T TOUCH IT!!!  RUN AWAY!!! */
-	if (spy->status != CHANSPY_RUNNING)
+	if (spy->status == CHANSPY_DONE)
 		return;
 
 	if (!chan)

Modified: team/bweschke/findme_followme/apps/app_privacy.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_privacy.c?rev=9204&r1=9203&r2=9204&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_privacy.c (original)
+++ team/bweschke/findme_followme/apps/app_privacy.c Tue Feb  7 14:50:13 2006
@@ -193,7 +193,7 @@
 		}
 		
 		/*Got a number, play sounds and send them on their way*/
-		if ((retries < maxretries) && res == 1 ) {
+		if ((retries < maxretries) && !res ) {
 			res = ast_streamfile(chan, "privacy-thankyou", chan->language);
 			if (!res)
 				res = ast_waitstream(chan, "");

Modified: team/bweschke/findme_followme/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_queue.c?rev=9204&r1=9203&r2=9204&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_queue.c (original)
+++ team/bweschke/findme_followme/apps/app_queue.c Tue Feb  7 14:50:13 2006
@@ -484,11 +484,11 @@
 							"Membership: %s\r\n"
 							"Penalty: %d\r\n"
 							"CallsTaken: %d\r\n"
-							"LastCall: %ld\r\n"
+							"LastCall: %d\r\n"
 							"Status: %d\r\n"
 							"Paused: %d\r\n",
 						q->name, cur->interface, cur->dynamic ? "dynamic" : "static",
-						cur->penalty, cur->calls, cur->lastcall, cur->status, cur->paused);
+						cur->penalty, cur->calls, (int)cur->lastcall, cur->status, cur->paused);
 					}
 				}
 			}
@@ -755,28 +755,66 @@
 	}
 }
 
+static void free_members(struct ast_call_queue *q, int all)
+{
+	/* Free non-dynamic members */
+	struct member *curm, *next, *prev = NULL;
+
+	for (curm = q->members; curm; curm = next) {
+		next = curm->next;
+		if (all || !curm->dynamic) {
+			if (prev)
+				prev->next = next;
+			else
+				q->members = next;
+			free(curm);
+		} else 
+			prev = curm;
+	}
+}
+
+static void destroy_queue(struct ast_call_queue *q)
+{
+	free_members(q, 1);
+	ast_mutex_destroy(&q->lock);
+	free(q);
+}
+
+static void remove_queue(struct ast_call_queue *q)
+{
+	struct ast_call_queue *cur, *prev = NULL;
+
+	ast_mutex_lock(&qlock);
+	for (cur = queues; cur; cur = cur->next) {
+		if (cur == q) {
+			if (prev)
+				prev->next = cur->next;
+			else
+				queues = cur->next;
+		} else {
+			prev = cur;
+		}
+	}
+	ast_mutex_unlock(&qlock);
+}
 
 /*!\brief Reload a single queue via realtime.
    \return Return the queue, or NULL if it doesn't exist.
-   \note Should be called with the global qlock locked.
-   When found, the queue is returned with q->lock locked. */
+   \note Should be called with the global qlock locked. */
 static struct ast_call_queue *find_queue_by_name_rt(const char *queuename, struct ast_variable *queue_vars, struct ast_config *member_config)
 {
 	struct ast_variable *v;
-	struct ast_call_queue *q, *prev_q;
+	struct ast_call_queue *q, *prev_q = NULL;
 	struct member *m, *prev_m, *next_m;
 	char *interface;
 	char *tmp, *tmp_name;
 	char tmpbuf[64];	/* Must be longer than the longest queue param name. */
 
 	/* Find the queue in the in-core list (we will create a new one if not found). */
-	q = queues;
-	prev_q = NULL;
-	while (q) {
+	for (q = queues; q; q = q->next) {
 		if (!strcasecmp(q->name, queuename)) {
 			break;
 		}
-		q = q->next;
 		prev_q = q;
 	}
 
@@ -788,6 +826,7 @@
 				ast_mutex_unlock(&q->lock);
 				return NULL;
 			} else {
+				ast_mutex_unlock(&q->lock);
 				return q;
 			}
 		}
@@ -814,7 +853,7 @@
 					prev_q->next = q->next;
 				}
 				ast_mutex_unlock(&q->lock);
-				free(q);
+				destroy_queue(q);
 			} else
 				ast_mutex_unlock(&q->lock);
 		}
@@ -882,13 +921,60 @@
 		m = next_m;
 	}
 
+	ast_mutex_unlock(&q->lock);
+
 	return q;
 }
 
-static int join_queue(char *queuename, struct queue_ent *qe, enum queue_result *reason)
+static struct ast_call_queue *load_realtime_queue(char *queuename)
 {
 	struct ast_variable *queue_vars = NULL;
 	struct ast_config *member_config = NULL;
+	struct ast_call_queue *q;
+
+	/* Find the queue in the in-core list first. */
+	ast_mutex_lock(&qlock);
+	for (q = queues; q; q = q->next) {
+		if (!strcasecmp(q->name, queuename)) {
+			break;
+		}
+	}
+	ast_mutex_unlock(&qlock);
+
+	if (!q) {
+		/*! \note Load from realtime before taking the global qlock, to avoid blocking all
+		   queue operations while waiting for the DB.
+
+		   This will be two separate database transactions, so we might
+		   see queue parameters as they were before another process
+		   changed the queue and member list as it was after the change.
+		   Thus we might see an empty member list when a queue is
+		   deleted. In practise, this is unlikely to cause a problem. */
+
+		queue_vars = ast_load_realtime("queues", "name", queuename, NULL);
+		if (queue_vars) {
+			member_config = ast_load_realtime_multientry("queue_members", "interface LIKE", "%", "queue_name", queuename, NULL);
+			if (!member_config) {
+				ast_log(LOG_ERROR, "no queue_members defined in your config (extconfig.conf).\n");
+				return NULL;
+			}
+		}
+
+		ast_mutex_lock(&qlock);
+
+		q = find_queue_by_name_rt(queuename, queue_vars, member_config);
+		if (member_config)
+			ast_config_destroy(member_config);
+		if (queue_vars)
+			ast_variables_destroy(queue_vars);
+
+		ast_mutex_unlock(&qlock);
+	}
+	return q;
+}
+
+static int join_queue(char *queuename, struct queue_ent *qe, enum queue_result *reason)
+{
 	struct ast_call_queue *q;
 	struct queue_ent *cur, *prev = NULL;
 	int res = -1;
@@ -896,35 +982,12 @@
 	int inserted = 0;
 	enum queue_member_status stat;
 
-	/*! \note Load from realtime before taking the global qlock, to avoid blocking all
-	   queue operations while waiting for the DB.
-
-	   This will be two separate database transactions, so we might
-	   see queue parameters as they were before another process
-	   changed the queue and member list as it was after the change.
-	   Thus we might see an empty member list when a queue is
-	   deleted. In practise, this is unlikely to cause a problem. */
-	queue_vars = ast_load_realtime("queues", "name", queuename, NULL);
-	if (queue_vars) {
-		member_config = ast_load_realtime_multientry("queue_members", "interface LIKE", "%", "queue_name", queuename, NULL);
-		if (!member_config) {
-			ast_log(LOG_ERROR, "no queue_members defined in your config (extconfig.conf).\n");
-			return res;
-		}
-	}
+	q = load_realtime_queue(queuename);
+	if (!q)
+		return res;
 
 	ast_mutex_lock(&qlock);
-	q = find_queue_by_name_rt(queuename, queue_vars, member_config);
-	/* Note: If found, find_queue_by_name_rt() returns with q->lock locked. */
-	if(member_config)
-		ast_config_destroy(member_config);
-	if(queue_vars)
-		ast_variables_destroy(queue_vars);
-
-	if (!q) {
-		ast_mutex_unlock(&qlock);
-		return res;
-	}
+	ast_mutex_lock(&q->lock);
 
 	/* This is our one */
 	stat = get_member_status(q);
@@ -976,48 +1039,6 @@
 	return res;
 }
 
-static void free_members(struct ast_call_queue *q, int all)
-{
-	/* Free non-dynamic members */
-	struct member *curm, *next, *prev;
-
-	curm = q->members;
-	prev = NULL;
-	while(curm) {
-		next = curm->next;
-		if (all || !curm->dynamic) {
-			if (prev)
-				prev->next = next;
-			else
-				q->members = next;
-			free(curm);
-		} else 
-			prev = curm;
-		curm = next;
-	}
-}
-
-static void destroy_queue(struct ast_call_queue *q)
-{
-	struct ast_call_queue *cur, *prev = NULL;
-
-	ast_mutex_lock(&qlock);
-	for (cur = queues; cur; cur = cur->next) {
-		if (cur == q) {
-			if (prev)
-				prev->next = cur->next;
-			else
-				queues = cur->next;
-		} else {
-			prev = cur;
-		}
-	}
-	ast_mutex_unlock(&qlock);
-	free_members(q, 1);
-        ast_mutex_destroy(&q->lock);
-	free(q);
-}
-
 static int play_file(struct ast_channel *chan, char *filename)
 {
 	int res;
@@ -1225,6 +1246,7 @@
 	ast_mutex_unlock(&q->lock);
 	if (q->dead && !q->count) {	
 		/* It's dead and nobody is in it, so kill it */
+		remove_queue(q);
 		destroy_queue(q);
 	}
 }
@@ -1262,11 +1284,11 @@
 					"Membership: %s\r\n"
 					"Penalty: %d\r\n"
 					"CallsTaken: %d\r\n"
-					"LastCall: %ld\r\n"
+					"LastCall: %d\r\n"
 					"Status: %d\r\n"
 					"Paused: %d\r\n",
 				q->name, cur->interface, cur->dynamic ? "dynamic" : "static",
-				cur->penalty, cur->calls, cur->lastcall, cur->status, cur->paused);
+				cur->penalty, cur->calls, (int)cur->lastcall, cur->status, cur->paused);
 			}
 			break;
 		}
@@ -2404,41 +2426,42 @@
 	struct member *new_member;
 	int res = RES_NOSUCHQUEUE;
 
+	/* \note Ensure the appropriate realtime queue is loaded.  Note that this
+	 * short-circuits if the queue is already in memory. */
+	q = load_realtime_queue(queuename);
+
 	ast_mutex_lock(&qlock);
-	for (q = queues ; q ; q = q->next) {
+
+	if (q) {
 		ast_mutex_lock(&q->lock);
-		if (!strcmp(q->name, queuename)) {
-			if (interface_exists(q, interface) == NULL) {
-				new_member = create_queue_member(interface, penalty, paused);
-
-				if (new_member != NULL) {
-					new_member->dynamic = 1;
-					new_member->next = q->members;
-					q->members = new_member;
-					manager_event(EVENT_FLAG_AGENT, "QueueMemberAdded",
-						"Queue: %s\r\n"
-						"Location: %s\r\n"
-						"Membership: %s\r\n"
-						"Penalty: %d\r\n"
-						"CallsTaken: %d\r\n"
-						"LastCall: %ld\r\n"
-						"Status: %d\r\n"
-						"Paused: %d\r\n",
-					q->name, new_member->interface, new_member->dynamic ? "dynamic" : "static",
-					new_member->penalty, new_member->calls, new_member->lastcall, new_member->status, new_member->paused);
+		if (interface_exists(q, interface) == NULL) {
+			new_member = create_queue_member(interface, penalty, paused);
+
+			if (new_member != NULL) {
+				new_member->dynamic = 1;
+				new_member->next = q->members;
+				q->members = new_member;
+				manager_event(EVENT_FLAG_AGENT, "QueueMemberAdded",
+					"Queue: %s\r\n"
+					"Location: %s\r\n"
+					"Membership: %s\r\n"
+					"Penalty: %d\r\n"
+					"CallsTaken: %d\r\n"
+					"LastCall: %d\r\n"
+					"Status: %d\r\n"
+					"Paused: %d\r\n",
+				q->name, new_member->interface, new_member->dynamic ? "dynamic" : "static",
+				new_member->penalty, new_member->calls, (int)new_member->lastcall, new_member->status, new_member->paused);
 					
-					if (dump)
-						dump_queue_members(q);
-
-					res = RES_OKAY;
-				} else {
-					res = RES_OUTOFMEMORY;
-				}
+				if (dump)
+					dump_queue_members(q);
+
+				res = RES_OKAY;
 			} else {
-				res = RES_EXISTS;
-			}
-			ast_mutex_unlock(&q->lock);
-			break;
+				res = RES_OUTOFMEMORY;
+			}
+		} else {
+			res = RES_EXISTS;
 		}
 		ast_mutex_unlock(&q->lock);
 	}
@@ -3243,7 +3266,7 @@
 			else
 				queues = q->next;
 			if (!q->count) {
-				free(q);
+				destroy_queue(q);
 			} else
 				ast_log(LOG_WARNING, "XXX Leaking a little memory :( XXX\n");
 		} else {
@@ -3272,7 +3295,13 @@
 	time(&now);
 	if ((!queue_show && argc != 2) || (queue_show && argc != 3))
 		return RESULT_SHOWUSAGE;
+
+	/* We only want to load realtime queues when a specific queue is asked for. */
+	if (queue_show)
+		load_realtime_queue(argv[2]);
+
 	ast_mutex_lock(&qlock);
+
 	q = queues;
 	if (!q) {	
 		ast_mutex_unlock(&qlock);
@@ -3435,13 +3464,13 @@
 						"Membership: %s\r\n"
 						"Penalty: %d\r\n"
 						"CallsTaken: %d\r\n"
-						"LastCall: %ld\r\n"
+						"LastCall: %d\r\n"
 						"Status: %d\r\n"
 						"Paused: %d\r\n"
 						"%s"
 						"\r\n",
 							q->name, mem->interface, mem->dynamic ? "dynamic" : "static",
-							mem->penalty, mem->calls, mem->lastcall, mem->status, mem->paused, idText);
+							mem->penalty, mem->calls, (int)mem->lastcall, mem->status, mem->paused, idText);
 				}
 			}
 			/* List Queue Entries */

Modified: team/bweschke/findme_followme/apps/app_sms.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_sms.c?rev=9204&r1=9203&r2=9204&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_sms.c (original)
+++ team/bweschke/findme_followme/apps/app_sms.c Tue Feb  7 14:50:13 2006
@@ -694,7 +694,7 @@
 		}
 		while (fgets (line, sizeof (line), s))
 		{								 /* process line in file */
-			char *p;
+			unsigned char *p;
 			for (p = line; *p && *p != '\n' && *p != '\r'; p++);
 			*p = 0;					 /* strip eoln */
 			p = line;
@@ -1379,8 +1379,8 @@
 		ast_copy_string (h.cli, chan->cid.cid_num, sizeof (h.cli));
 
 	{
-		char *d = data,
-			*p,
+		unsigned char *p;
+		unsigned char *d = data,
 			answer = 0;
 		if (!*d || *d == '|') {
 			ast_log (LOG_ERROR, "Requires queue name\n");
@@ -1449,7 +1449,7 @@
 			d = p;
 			h.udl = 0;
 			while (*p && h.udl < SMSLEN)
-				h.ud[h.udl++] = utf8decode((unsigned char **)&p);
+				h.ud[h.udl++] = utf8decode(&p);
 			if (is7bit (h.dcs) && packsms7 (0, h.udhl, h.udh, h.udl, h.ud) < 0)
 				ast_log (LOG_WARNING, "Invalid 7 bit GSM data\n");
 			if (is8bit (h.dcs) && packsms8 (0, h.udhl, h.udh, h.udl, h.ud) < 0)

Modified: team/bweschke/findme_followme/apps/app_stack.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_stack.c?rev=9204&r1=9203&r2=9204&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_stack.c (original)
+++ team/bweschke/findme_followme/apps/app_stack.c Tue Feb  7 14:50:13 2006
@@ -52,22 +52,18 @@
 
 static const char *gosub_descrip =
 "Gosub([[context|]exten|]priority)\n"
-"  Jumps to the label specified, saving the return address.\n"
-"  Returns 0 if the label exists or -1 otherwise.\n";
+"  Jumps to the label specified, saving the return address.\n";
 static const char *gosubif_descrip =
-"Gosub(condition?labeliftrue[:labeliffalse])\n"
+"GosubIf(condition?labeliftrue[:labeliffalse])\n"
 "  If the condition is true, then jump to labeliftrue.  If false, jumps to\n"
 "labeliffalse, if specified.  In either case, a jump saves the return point\n"
-"in the dialplan, to be returned to with a Return.\n"
-"  Returns 0 if the label exists or -1 otherwise.\n";
+"in the dialplan, to be returned to with a Return.\n";
 static const char *return_descrip =
 "Return()\n"
-"  Jumps to the last label in the stack, removing it.\n"
-"  Returns 0 if there's a label in the stack or -1 otherwise.\n";
+"  Jumps to the last label on the stack, removing it.\n";
 static const char *pop_descrip =
 "StackPop()\n"
-"  Removes last label in the stack, discarding it.\n"
-"  Always returns 0, even if the stack is empty.\n";
+"  Removes last label on the stack, discarding it.\n";
 
 STANDARD_LOCAL_USER;
 

Modified: team/bweschke/findme_followme/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_voicemail.c?rev=9204&r1=9203&r2=9204&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_voicemail.c (original)
+++ team/bweschke/findme_followme/apps/app_voicemail.c Tue Feb  7 14:50:13 2006
@@ -445,7 +445,7 @@
 		ast_copy_string(vmu->language, value, sizeof(vmu->language));
 	} else if (!strcasecmp(var, "tz")) {
 		ast_copy_string(vmu->zonetag, value, sizeof(vmu->zonetag));
-	} else if (!strcasecmp(var, "delete")) {
+	} else if (!strcasecmp(var, "delete") || !strcasecmp(var, "deletevoicemail")) {
 		ast_set2_flag(vmu, ast_true(value), VM_DELETE);	
 	} else if (!strcasecmp(var, "saycid")){
 		ast_set2_flag(vmu, ast_true(value), VM_SAYCID);	
@@ -2005,7 +2005,7 @@
 			ast_log(LOG_WARNING, "SQL Alloc Handle failed!\n");
 			goto yuck;
 		}
-		snprintf(sql, sizeof(sql), "SELECT COUNT(*) FROM %s WHERE dir like \"%%%s/%s/%s\"%c", odbc_table, context, tmp, "INBOX", '\0');
+		snprintf(sql, sizeof(sql), "SELECT COUNT(*) FROM %s WHERE dir LIKE '%%%s/%s/%s'", odbc_table, context, tmp, "INBOX");
 		res = SQLPrepare(stmt, sql, SQL_NTS);
 		if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
 			ast_log(LOG_WARNING, "SQL Prepare failed![%s]\n", sql);
@@ -2038,7 +2038,7 @@
 			ast_log(LOG_WARNING, "SQL Alloc Handle failed!\n");
 			goto yuck;
 		}
-		snprintf(sql, sizeof(sql), "SELECT COUNT(*) FROM %s WHERE dir like \"%%%s/%s/%s\"%c", odbc_table, context, tmp, "Old", '\0');

[... 6760 lines stripped ...]


More information about the asterisk-commits mailing list