[asterisk-commits] mattf: branch mattf/bug13454 r150588 - in /team/mattf/bug13454: ./ apps/ chan...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Oct 17 11:37:26 CDT 2008


Author: mattf
Date: Fri Oct 17 11:37:24 2008
New Revision: 150588

URL: http://svn.digium.com/view/asterisk?view=rev&rev=150588
Log:
Merged revisions 63654 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r63654 | mattf | 2007-05-09 12:25:21 -0500 (Wed, 09 May 2007) | 10 lines

Merged revisions 63653 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r63653 | mattf | 2007-05-09 12:20:20 -0500 (Wed, 09 May 2007) | 2 lines

Make sure we only create a DSP if it's requested on SUB_REAL

........

................

Modified:
    team/mattf/bug13454/CHANGES
    team/mattf/bug13454/Makefile
    team/mattf/bug13454/apps/app_queue.c
    team/mattf/bug13454/apps/app_rpt.c
    team/mattf/bug13454/apps/app_speech_utils.c
    team/mattf/bug13454/apps/app_voicemail.c
    team/mattf/bug13454/apps/app_waitforsilence.c
    team/mattf/bug13454/channels/chan_dahdi.c
    team/mattf/bug13454/channels/chan_iax2.c
    team/mattf/bug13454/channels/chan_local.c
    team/mattf/bug13454/channels/chan_misdn.c
    team/mattf/bug13454/channels/chan_sip.c
    team/mattf/bug13454/channels/misdn/isdn_lib.c
    team/mattf/bug13454/channels/misdn/isdn_lib.h
    team/mattf/bug13454/channels/misdn/isdn_lib_intern.h
    team/mattf/bug13454/channels/misdn_config.c
    team/mattf/bug13454/configs/agents.conf.sample
    team/mattf/bug13454/configs/misdn.conf.sample
    team/mattf/bug13454/configure
    team/mattf/bug13454/configure.ac
    team/mattf/bug13454/doc/misdn.txt
    team/mattf/bug13454/funcs/func_callerid.c
    team/mattf/bug13454/funcs/func_cdr.c
    team/mattf/bug13454/funcs/func_curl.c
    team/mattf/bug13454/funcs/func_groupcount.c
    team/mattf/bug13454/funcs/func_math.c
    team/mattf/bug13454/funcs/func_odbc.c
    team/mattf/bug13454/funcs/func_timeout.c
    team/mattf/bug13454/include/asterisk.h
    team/mattf/bug13454/include/asterisk/audiohook.h
    team/mattf/bug13454/include/asterisk/features.h
    team/mattf/bug13454/main/ast_expr2.c
    team/mattf/bug13454/main/ast_expr2.fl
    team/mattf/bug13454/main/ast_expr2.y
    team/mattf/bug13454/main/ast_expr2f.c
    team/mattf/bug13454/main/asterisk.c
    team/mattf/bug13454/main/astmm.c
    team/mattf/bug13454/main/audiohook.c
    team/mattf/bug13454/main/callerid.c
    team/mattf/bug13454/main/channel.c
    team/mattf/bug13454/main/rtp.c
    team/mattf/bug13454/main/stdtime/localtime.c
    team/mattf/bug13454/main/translate.c
    team/mattf/bug13454/pbx/ael/ael.flex
    team/mattf/bug13454/pbx/ael/ael.tab.c
    team/mattf/bug13454/pbx/ael/ael.y
    team/mattf/bug13454/pbx/ael/ael_lex.c
    team/mattf/bug13454/pbx/pbx_ael.c
    team/mattf/bug13454/pbx/pbx_config.c
    team/mattf/bug13454/res/res_smdi.c

Modified: team/mattf/bug13454/CHANGES
URL: http://svn.digium.com/view/asterisk/team/mattf/bug13454/CHANGES?view=diff&rev=150588&r1=150587&r2=150588
==============================================================================
--- team/mattf/bug13454/CHANGES (original)
+++ team/mattf/bug13454/CHANGES Fri Oct 17 11:37:24 2008
@@ -203,10 +203,11 @@
                            1. mohinterpret
                            2. mohsuggest
                2. agents.conf
+                      o multiplelogin variable added
                       o maxlogintries variable added
                       o autologoffunavail variable added
                       o endcall variable added
-                      o agentgoodbye variable added
+                      o goodbye variable added
                       o createlink variable REMOVED
                3. alsa.conf
                       o mohinterpret variable added
@@ -295,8 +296,15 @@
               21. rtp.conf
                       o rtcpinterval varaible added
               22. sip.conf
+                      o allowguest variable can't be set to 'osp'
                       o allowoverlap variable added
                       o allowtransfer variable added
+                      o limitonpeer variable added
+                      o directrtpsetup variable added
+                      o buggymwi variable added
+                      o ospauth variable REMOVED
+                      o notifyhold variable added
+                      o autoframing variable added
                       o tos variable REMOVED
                       o tos_sip variable added
                       o tos_audio variable added
@@ -305,18 +313,22 @@
                       o t1min variable added
                       o musicclass variable REMOVED
                       o mohinterpret variable added
-                      o maxcallbitratesuggest variable added
+                      o mohsuggest variable added
                       o allowsubscribe variable added
                       o videosupport variable added
                       o maxcallbitrate variable added
                       o g726nonstandard variable added
                       o dumphistory variable added
-                      o allowsubscribe variable added
                       o t38pt_udptl variable added
+                      o t38pt_rtp variable added
+                      o t38pt_tcp variable added
+                      o rfc2833compensate variable added
+                      o matchexterniplocally variable added
                       o canreinvite variable can also now be set to 'nonat'
                       o rtsavesysname variable added
                       o JitterBuffer support added
                       o t38pt_usertpsource variable added
+                      o regcontext variable can contains multiple contexts separated by an '&'
               23. skinny.conf
                       o port variable renamed to bindport
                       o JitterBuffer support added

Modified: team/mattf/bug13454/Makefile
URL: http://svn.digium.com/view/asterisk/team/mattf/bug13454/Makefile?view=diff&rev=150588&r1=150587&r2=150588
==============================================================================
--- team/mattf/bug13454/Makefile (original)
+++ team/mattf/bug13454/Makefile Fri Oct 17 11:37:24 2008
@@ -203,8 +203,6 @@
 
 ASTCFLAGS+=-Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
 
-ASTCFLAGS+=-include $(ASTTOPDIR)/include/asterisk/autoconfig.h
-
 ifeq ($(AST_DEVMODE),yes)
   ASTCFLAGS+=-Werror  -Wunused $(AST_DECLARATION_AFTER_STATEMENT)
 endif
@@ -271,7 +269,7 @@
   SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
 else
 # These are used for all but Darwin
-  SOLINK=-shared -Xlinker -x
+  SOLINK=-shared
   ifneq ($(findstring BSD,$(OSARCH)),)
     LDFLAGS+=-L/usr/local/lib
   endif

Modified: team/mattf/bug13454/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/mattf/bug13454/apps/app_queue.c?view=diff&rev=150588&r1=150587&r2=150588
==============================================================================
--- team/mattf/bug13454/apps/app_queue.c (original)
+++ team/mattf/bug13454/apps/app_queue.c Fri Oct 17 11:37:24 2008
@@ -2566,6 +2566,7 @@
 	struct queue_ent *qe;
 	struct member *member;
 	int starttime;
+	int callcompletedinsl;
 };
 
 static void queue_transfer_destroy(void *data)
@@ -2597,11 +2598,14 @@
 	struct queue_ent *qe = qtds->qe;
 	struct member *member = qtds->member;
 	int callstart = qtds->starttime;
+	int callcompletedinsl = qtds->callcompletedinsl;
 	struct ast_datastore *datastore;
 
 	ast_queue_log(qe->parent->name, qe->chan->uniqueid, member->membername, "TRANSFER", "%s|%s|%ld|%ld",
 				new_chan->exten, new_chan->context, (long) (callstart - qe->start),
 				(long) (time(NULL) - callstart));
+
+	update_queue(qe->parent, member, callcompletedinsl);
 	
 	if (!(datastore = ast_channel_datastore_find(new_chan, &queue_transfer_info, NULL))) {
 		ast_log(LOG_WARNING, "Can't find the queue_transfer datastore.\n");
@@ -2625,7 +2629,7 @@
 
 /*! \brief create a datastore for storing relevant info to log attended transfers in the queue_log
  */
-static void setup_transfer_datastore(struct queue_ent *qe, struct member *member, int starttime)
+static void setup_transfer_datastore(struct queue_ent *qe, struct member *member, int starttime, int callcompletedinsl)
 {
 	struct ast_datastore *ds;
 	struct queue_transfer_ds *qtds = ast_calloc(1, sizeof(*qtds));
@@ -2646,6 +2650,7 @@
 	/* This member is refcounted in try_calling, so no need to add it here, too */
 	qtds->member = member;
 	qtds->starttime = starttime;
+	qtds->callcompletedinsl = callcompletedinsl;
 	ds->data = qtds;
 	ast_channel_datastore_add(qe->chan, ds);
 	ast_channel_unlock(qe->chan);
@@ -3135,7 +3140,7 @@
 		if (member->status == AST_DEVICE_NOT_INUSE)
 			ast_log(LOG_WARNING, "The device state of this queue member, %s, is still 'Not in Use' when it probably should not be! Please check UPGRADE.txt for correct configuration settings.\n", member->membername);
 			
-		setup_transfer_datastore(qe, member, callstart);
+		setup_transfer_datastore(qe, member, callstart, callcompletedinsl);
 		bridge = ast_bridge_call(qe->chan,peer, &bridge_config);
 
 		if (!attended_transfer_occurred(qe->chan)) {
@@ -3185,11 +3190,11 @@
 				ast_channel_datastore_free(transfer_ds);
 			}
 			ast_channel_unlock(qe->chan);
+			update_queue(qe->parent, member, callcompletedinsl);
 		}
 
 		if (bridge != AST_PBX_NO_HANGUP_PEER)
 			ast_hangup(peer);
-		update_queue(qe->parent, member, callcompletedinsl);
 		res = bridge ? bridge : 1;
 		ao2_ref(member, -1);
 	}

Modified: team/mattf/bug13454/apps/app_rpt.c
URL: http://svn.digium.com/view/asterisk/team/mattf/bug13454/apps/app_rpt.c?view=diff&rev=150588&r1=150587&r2=150588
==============================================================================
--- team/mattf/bug13454/apps/app_rpt.c (original)
+++ team/mattf/bug13454/apps/app_rpt.c Fri Oct 17 11:37:24 2008
@@ -2901,7 +2901,7 @@
 
 static void *rpt_tele_thread(void *this)
 {
-DAHDI_CONFINFO ci;  /* conference info */
+struct dahdi_confinfo ci;  /* conference info */
 int	res = 0,haslink,hastx,hasremote,imdone = 0, unkeys_queued, x;
 struct	rpt_tele *mytele = (struct rpt_tele *)this;
 struct  rpt_tele *tlist;
@@ -4157,7 +4157,7 @@
 
 static void *rpt_call(void *this)
 {
-DAHDI_CONFINFO ci;  /* conference info */
+struct dahdi_confinfo ci;  /* conference info */
 struct	rpt *myrpt = (struct rpt *)this;
 int	res;
 int stopped,congstarted,dialtimer,lastcidx,aborted;
@@ -4467,7 +4467,7 @@
 	struct rpt_link *l;
 	int reconnects = 0;
 	int i,n;
-	DAHDI_CONFINFO ci;  /* conference info */
+	struct dahdi_confinfo ci;  /* conference info */
 
 	val = node_lookup(myrpt,node);
 	if (!val){
@@ -8759,7 +8759,7 @@
 int ms = MSWAIT,i,lasttx=0,val,remrx=0,identqueued,othertelemqueued;
 int tailmessagequeued,ctqueued,dtmfed;
 struct ast_channel *who;
-DAHDI_CONFINFO ci;  /* conference info */
+struct dahdi_confinfo ci;  /* conference info */
 time_t	t;
 struct rpt_link *l,*m;
 struct rpt_tele *telem;
@@ -10564,8 +10564,8 @@
 	struct ast_channel *who;
 	struct ast_channel *cs[20];
 	struct	rpt_link *l;
-	DAHDI_CONFINFO ci;  /* conference info */
-	DAHDI_PARAMS par;
+	struct dahdi_confinfo ci;  /* conference info */
+	struct dahdi_params par;
 	int ms,elap,nullfd;
 	time_t t,last_timeout_warning;
 	struct	dahdi_radio_param z;

Modified: team/mattf/bug13454/apps/app_speech_utils.c
URL: http://svn.digium.com/view/asterisk/team/mattf/bug13454/apps/app_speech_utils.c?view=diff&rev=150588&r1=150587&r2=150588
==============================================================================
--- team/mattf/bug13454/apps/app_speech_utils.c (original)
+++ team/mattf/bug13454/apps/app_speech_utils.c Fri Oct 17 11:37:24 2008
@@ -193,8 +193,11 @@
 	if (data == NULL || speech == NULL || !(result = find_result(speech->results, data)))
                 return -1;
 
-	if (result->text != NULL)
+	if (result->text != NULL) {
 		ast_copy_string(buf, result->text, len);
+	} else {
+		buf[0] = '\0';
+	}
 
         return 0;
 }
@@ -219,8 +222,11 @@
 	if (data == NULL || speech == NULL || !(result = find_result(speech->results, data)))
                 return -1;
 
-	if (result->grammar != NULL)
+	if (result->grammar != NULL) {
 		ast_copy_string(buf, result->grammar, len);
+	} else {
+		buf[0] = '\0';
+	}
 
         return 0;
 }
@@ -322,6 +328,8 @@
 		}
 		snprintf(tmp, sizeof(tmp), "%d", results);
 		ast_copy_string(buf, tmp, len);
+	} else {
+		buf[0] = '\0';
 	}
 
 	return 0;
@@ -766,6 +774,7 @@
 			speech->results->text = strdup(dtmf);
 			speech->results->grammar = strdup("dtmf");
 		}
+		ast_speech_change_state(speech, AST_SPEECH_STATE_NOT_READY);
 	}
 
         /* See if it was because they hung up */

Modified: team/mattf/bug13454/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/mattf/bug13454/apps/app_voicemail.c?view=diff&rev=150588&r1=150587&r2=150588
==============================================================================
--- team/mattf/bug13454/apps/app_voicemail.c (original)
+++ team/mattf/bug13454/apps/app_voicemail.c Fri Oct 17 11:37:24 2008
@@ -249,6 +249,7 @@
 	\arg \b no - Norwegian
 	\arg \b se - Swedish
 	\arg \b ua - Ukrainian
+	\arg \b he - Hebrew
 
 German requires the following additional soundfile:
 \arg \b 1F	einE (feminine)
@@ -305,6 +306,12 @@
 \arg \b vm-nuovi	new plural
 \arg \b vm-vecchio	old
 \arg \b vm-vecchi	old plural
+
+Hebrew also uses:
+\arg \b vm-INBOX1 '1 new message'
+\arg \b vm-OLD1   '1 old message'
+\arg \b vm-shtei	'shtei'
+\arg \b vm-nomessages 'you have no new messages'
 
 \note Don't use vm-INBOX or vm-Old, because they are the name of the INBOX and Old folders,
 spelled among others when you have to change folder. For the above reasons, vm-INBOX
@@ -616,7 +623,7 @@
 #ifdef IMAP_STORAGE
 	} else if (!strcasecmp(var, "imapuser")) {
 		ast_copy_string(vmu->imapuser, value, sizeof(vmu->imapuser));
-	} else if (!strcasecmp(var, "imappassword")) {
+	} else if (!strcasecmp(var, "imappassword") || !strcasecmp(var, "imapsecret")) {
 		ast_copy_string(vmu->imappassword, value, sizeof(vmu->imappassword));
 #endif
 	} else if (!strcasecmp(var, "delete") || !strcasecmp(var, "deletevoicemail")) {
@@ -720,7 +727,7 @@
 #ifdef IMAP_STORAGE
 		} else if (!strcasecmp(tmp->name, "imapuser")) {
 			ast_copy_string(retval->imapuser, tmp->value, sizeof(retval->imapuser));
-		} else if (!strcasecmp(tmp->name, "imappassword")) {
+		} else if (!strcasecmp(tmp->name, "imappassword") || !strcasecmp(tmp->name, "imapsecret")) {
 			ast_copy_string(retval->imappassword, tmp->value, sizeof(retval->imappassword));
 #endif
 		} else
@@ -2925,9 +2932,10 @@
 	pbx_builtin_setvar_helper(ast, "VM_MSGNUM", passdata);
 	pbx_builtin_setvar_helper(ast, "VM_CONTEXT", context);
 	pbx_builtin_setvar_helper(ast, "VM_MAILBOX", mailbox);
-	pbx_builtin_setvar_helper(ast, "VM_CALLERID", ast_callerid_merge(callerid, sizeof(callerid), cidname, cidnum, "Unknown Caller"));
-	pbx_builtin_setvar_helper(ast, "VM_CIDNAME", (cidname ? cidname : "an unknown caller"));
-	pbx_builtin_setvar_helper(ast, "VM_CIDNUM", (cidnum ? cidnum : "an unknown caller"));
+	pbx_builtin_setvar_helper(ast, "VM_CALLERID", (!ast_strlen_zero(cidname) || !ast_strlen_zero(cidnum)) ?
+		ast_callerid_merge(callerid, sizeof(callerid), cidname, cidnum, NULL) : "an unknown caller");
+	pbx_builtin_setvar_helper(ast, "VM_CIDNAME", (!ast_strlen_zero(cidname) ? cidname : "an unknown caller"));
+	pbx_builtin_setvar_helper(ast, "VM_CIDNUM", (!ast_strlen_zero(cidnum) ? cidnum : "an unknown caller"));
 	pbx_builtin_setvar_helper(ast, "VM_DATE", date);
 	pbx_builtin_setvar_helper(ast, "VM_CATEGORY", category ? ast_strdupa(category) : "no category");
 }
@@ -2969,6 +2977,70 @@
 	}
 	ast_localtime(&t, tm, z ? z->timezone : NULL);
 	return tm;
+}
+
+/*!\brief Check if the string would need encoding within the MIME standard, to
+ * avoid confusing certain mail software that expects messages to be 7-bit
+ * clean.
+ */
+static int check_mime(const char *str)
+{
+	for (; *str; str++) {
+		if (*str > 126 || *str < 32 || strchr("()<>@,:;/\"[]?.=", *str)) {
+			return 1;
+		}
+	}
+	return 0;
+}
+
+/*!\brief Encode a string according to the MIME rules for encoding strings
+ * that are not 7-bit clean or contain control characters.
+ *
+ * Additionally, if the encoded string would exceed the MIME limit of 76
+ * characters per line, then the encoding will be broken up into multiple
+ * sections, separated by a space character, in order to facilitate
+ * breaking up the associated header across multiple lines.
+ *
+ * \param start A string to be encoded
+ * \param end An expandable buffer for holding the result
+ * \param preamble The length of the first line already used for this string,
+ * to ensure that each line maintains a maximum length of 76 chars.
+ * \param postamble the length of any additional characters appended to the
+ * line, used to ensure proper field wrapping.
+ * \retval The encoded string.
+ */
+static char *encode_mime_str(const char *start, char *end, size_t endsize, size_t preamble, size_t postamble)
+{
+	char tmp[80];
+	int first_section = 1;
+	size_t endlen = 0, tmplen = 0;
+	*end = '\0';
+
+	tmplen = snprintf(tmp, sizeof(tmp), "=?%s?Q?", charset);
+	for (; *start; start++) {
+		int need_encoding = 0;
+		if (*start < 33 || *start > 126 || strchr("()<>@,:;/\"[]?.=_", *start)) {
+			need_encoding = 1;
+		}
+		if ((first_section && need_encoding && preamble + tmplen > 70) ||
+			(first_section && !need_encoding && preamble + tmplen > 72) ||
+			(!first_section && need_encoding && tmplen > 70) ||
+			(!first_section && !need_encoding && tmplen > 72)) {
+			/* Start new line */
+			endlen += snprintf(end + endlen, endsize - endlen, "%s%s?=", first_section ? "" : " ", tmp);
+			tmplen = snprintf(tmp, sizeof(tmp), "=?%s?Q?", charset);
+			first_section = 0;
+		}
+		if (need_encoding && *start == ' ') {
+			tmplen += snprintf(tmp + tmplen, sizeof(tmp) - tmplen, "_");
+		} else if (need_encoding) {
+			tmplen += snprintf(tmp + tmplen, sizeof(tmp) - tmplen, "=%hhX", *start);
+		} else {
+			tmplen += snprintf(tmp + tmplen, sizeof(tmp) - tmplen, "%c", *start);
+		}
+	}
+	snprintf(end + endlen, endsize - endlen, "%s%s?=%s", first_section ? "" : " ", tmp, endlen + postamble > 74 ? " " : "");
+	return end;
 }
 
 static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, char *cidnum, char *cidname, char *attach, char *format, int duration, int attach_user_voicemail, struct ast_channel *chan, const char *category, int imap)
@@ -2982,14 +3054,28 @@
 	char tmpcmd[256];
 	char enc_cidnum[256] = "", enc_cidname[256] = "";
 	struct tm tm;
-	char *passdata2;
-	size_t len_passdata;
+	char *passdata = NULL, *passdata2;
+	size_t len_passdata = 0, len_passdata2, tmplen;
 #ifdef IMAP_STORAGE
 #define ENDL "\r\n"
 #else
 #define ENDL "\n"
 #endif
 
+	/* One alloca for multiple fields */
+	len_passdata2 = strlen(vmu->fullname);
+	if (emailsubject && (tmplen = strlen(emailsubject)) > len_passdata2) {
+		len_passdata2 = tmplen;
+	}
+	if ((tmplen = strlen(emailtitle)) > len_passdata2) {
+		len_passdata2 = tmplen;
+	}
+	if ((tmplen = strlen(fromstring)) > len_passdata2) {
+		len_passdata2 = tmplen;
+	}
+	len_passdata2 = len_passdata2 * 3 + 200;
+	passdata2 = alloca(len_passdata2);
+
 	if (cidnum) {
 		strip_control(cidnum, enc_cidnum, sizeof(enc_cidnum));
 	}
@@ -3012,37 +3098,71 @@
 	if (*fromstring) {
 		struct ast_channel *ast;
 		if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, 0))) {
-			char *passdata;
-			int vmlen = strlen(fromstring)*3 + 200;
-			if ((passdata = alloca(vmlen))) {
-				memset(passdata, 0, vmlen);
-				prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, enc_cidnum, enc_cidname, dur, date, passdata, vmlen, category);
-				pbx_substitute_variables_helper(ast, fromstring, passdata, vmlen);
-				len_passdata = strlen(passdata) * 2 + 3;
-				passdata2 = alloca(len_passdata);
-				fprintf(p, "From: %s <%s>" ENDL, quote(passdata, passdata2, len_passdata), who);
-			} else
-				ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
+			char *ptr;
+			memset(passdata2, 0, len_passdata2);
+			prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, enc_cidnum, enc_cidname, dur, date, passdata2, len_passdata2, category);
+			pbx_substitute_variables_helper(ast, fromstring, passdata2, len_passdata2);
+			len_passdata = strlen(passdata2) * 3 + 300;
+			passdata = alloca(len_passdata);
+			if (check_mime(passdata2)) {
+				int first_line = 1;
+				encode_mime_str(passdata2, passdata, len_passdata, strlen("From: "), strlen(who) + 3);
+				while ((ptr = strchr(passdata, ' '))) {
+					*ptr = '\0';
+					fprintf(p, "%s %s" ENDL, first_line ? "From:" : "", passdata);
+					first_line = 0;
+					passdata = ptr + 1;
+				}
+				fprintf(p, "%s %s <%s>" ENDL, first_line ? "From:" : "", passdata, who);
+			} else {
+				fprintf(p, "From: %s <%s>" ENDL, quote(passdata, passdata2, len_passdata2), who);
+			}
 			ast_channel_free(ast);
 		} else
 			ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
 	} else
 		fprintf(p, "From: Asterisk PBX <%s>" ENDL, who);
-	len_passdata = strlen(vmu->fullname) * 2 + 3;
-	passdata2 = alloca(len_passdata);
-	fprintf(p, "To: %s <%s>" ENDL, quote(vmu->fullname, passdata2, len_passdata), vmu->email);
+
+	if (check_mime(vmu->fullname)) {
+		int first_line = 1;
+		char *ptr;
+		encode_mime_str(vmu->fullname, passdata2, len_passdata2, strlen("To: "), strlen(vmu->email) + 3);
+		while ((ptr = strchr(passdata2, ' '))) {
+			*ptr = '\0';
+			fprintf(p, "%s %s" ENDL, first_line ? "To:" : "", passdata2);
+			first_line = 0;
+			passdata2 = ptr + 1;
+		}
+		fprintf(p, "%s %s <%s>" ENDL, first_line ? "To:" : "", passdata2, vmu->email);
+	} else {
+		fprintf(p, "To: %s <%s>" ENDL, quote(vmu->fullname, passdata2, len_passdata2), vmu->email);
+	}
 	if (emailsubject) {
 		struct ast_channel *ast;
 		if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, 0))) {
-			char *passdata;
-			int vmlen = strlen(emailsubject)*3 + 200;
-			if ((passdata = alloca(vmlen))) {
-				memset(passdata, 0, vmlen);
-				prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category);
-				pbx_substitute_variables_helper(ast, emailsubject, passdata, vmlen);
+			int vmlen = strlen(emailsubject) * 3 + 200;
+			/* Only allocate more space if the previous was not large enough */
+			if (vmlen > len_passdata) {
+				passdata = alloca(vmlen);
+				len_passdata = vmlen;
+			}
+
+			memset(passdata, 0, len_passdata);
+			prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, len_passdata, category);
+			pbx_substitute_variables_helper(ast, emailsubject, passdata, len_passdata);
+			if (check_mime(passdata)) {
+				int first_line = 1;
+				char *ptr;
+				encode_mime_str(passdata, passdata2, len_passdata2, strlen("Subject: "), 0);
+				while ((ptr = strchr(passdata2, ' '))) {
+					*ptr = '\0';
+					fprintf(p, "%s %s" ENDL, first_line ? "Subject:" : "", passdata2);
+					first_line = 0;
+					passdata2 = ptr + 1;
+				}
+				fprintf(p, "%s %s" ENDL, first_line ? "Subject:" : "", passdata2);
+			} else {
 				fprintf(p, "Subject: %s" ENDL, passdata);
-			} else {
-				ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
 			}
 			ast_channel_free(ast);
 		} else {
@@ -5169,6 +5289,8 @@
 		res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q  H 'digits/kai' M ", NULL);
 	else if (!strcasecmp(chan->language,"pt_BR"))
 		res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' Ad 'digits/pt-de' B 'digits/pt-de' Y 'digits/pt-as' HM ", NULL);		
+	else if (!strcasecmp(chan->language,"he"))
+		res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' Ad 'at2' kM", NULL);
 	else
 		res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q 'digits/at' IMp", NULL);
 #if 0
@@ -5307,10 +5429,33 @@
 	vms->starting = 0; 
 	make_file(vms->fn, sizeof(vms->fn), vms->curdir, vms->curmsg);
 	adsi_message(chan, vms);
-	if (!vms->curmsg)
-		res = wait_file2(chan, vms, "vm-first");	/* "First" */
-	else if (vms->curmsg == vms->lastmsg)
-		res = wait_file2(chan, vms, "vm-last");		/* "last" */
+	if (!strcasecmp(chan->language, "he")) {	/* HEBREW FORMAT */
+		/*
+		 * The syntax in hebrew for counting the number of message is up side down
+		 * in comparison to english.
+		 */
+		if (!vms->curmsg) {
+			res = wait_file2(chan, vms, "vm-message");
+			res = wait_file2(chan, vms, "vm-first");    /* "First" */
+		} else if (vms->curmsg == vms->lastmsg) {
+			res = wait_file2(chan, vms, "vm-message");
+			res = wait_file2(chan, vms, "vm-last");     /* "last" */
+		} else {
+			res = wait_file2(chan, vms, "vm-message");  /* "message" */
+			if (vms->curmsg && (vms->curmsg != vms->lastmsg)) {
+				ast_log(LOG_DEBUG, "curmsg: %d\n", vms->curmsg);
+				ast_log(LOG_DEBUG, "lagmsg: %d\n", vms->lastmsg);
+				if (!res) {
+					res = ast_say_number(chan, vms->curmsg + 1, AST_DIGIT_ANY, chan->language, "f");
+				}
+			}
+		}
+	} else {
+		if (!vms->curmsg)
+			res = wait_file2(chan, vms, "vm-first");	/* "First" */
+		else if (vms->curmsg == vms->lastmsg)
+			res = wait_file2(chan, vms, "vm-last");		/* "last" */
+	}
 	if (!res) {
 		/* POLISH syntax */
 		if (!strcasecmp(chan->language, "pl")) { 
@@ -5576,6 +5721,9 @@
 		return vm_play_folder_name_pl(chan, mbox);
 	} else if (!strcasecmp(chan->language, "ua")){  /* Ukrainian syntax */
 		return vm_play_folder_name_ua(chan, mbox);
+	} else if (!strcasecmp(chan->language, "he")){  /* Hebrew syntax */
+		cmd = ast_play_and_wait(chan, mbox);
+		return cmd;
 	} else {  /* Default English */
 		cmd = ast_play_and_wait(chan, mbox);
 		return cmd ? cmd : ast_play_and_wait(chan, "vm-messages"); /* "messages */
@@ -5674,6 +5822,74 @@
 	}
 	return res;
 }
+
+/* Default Hebrew syntax */
+static int vm_intro_he(struct ast_channel *chan, struct vm_state *vms)
+{
+	int res=0;
+
+	/* Introduce messages they have */
+	if (!res) {
+		if ((vms->newmessages) || (vms->oldmessages)) {
+			res = ast_play_and_wait(chan, "vm-youhave");
+		}
+		/*
+		 * The word "shtei" refers to the number 2 in hebrew when performing a count
+		 * of elements. In Hebrew, there are 6 forms of enumerating the number 2 for
+		 * an element, this is one of them.
+		 */
+		if (vms->newmessages) {
+			if (!res) {
+				if (vms->newmessages == 1) {
+					res = ast_play_and_wait(chan, "vm-INBOX1");
+				} else {
+					if (vms->newmessages == 2) {
+						res = ast_play_and_wait(chan, "vm-shtei");
+					} else {
+						res = ast_say_number(chan, vms->newmessages, AST_DIGIT_ANY, chan->language, "f");
+					}
+					res = ast_play_and_wait(chan, "vm-INBOX");
+				}
+			}
+			if (vms->oldmessages && !res) {
+				res = ast_play_and_wait(chan, "vm-and");
+				if (vms->oldmessages == 1) {
+					res = ast_play_and_wait(chan, "vm-Old1");
+				} else {
+					if (vms->oldmessages == 2) {
+						res = ast_play_and_wait(chan, "vm-shtei");
+					} else {
+						res = ast_say_number(chan, vms->oldmessages, AST_DIGIT_ANY, chan->language, "f");
+					}
+					res = ast_play_and_wait(chan, "vm-Old");
+				}
+			}
+		}
+		if (!res && vms->oldmessages && !vms->newmessages) {
+			if (!res) {
+				if (vms->oldmessages == 1) {
+					res = ast_play_and_wait(chan, "vm-Old1");
+				} else {
+					if (vms->oldmessages == 2) {
+						res = ast_play_and_wait(chan, "vm-shtei");
+					} else {
+						res = ast_say_number(chan, vms->oldmessages, AST_DIGIT_ANY, chan->language, "f");            
+					}
+					res = ast_play_and_wait(chan, "vm-Old");
+				}
+			}
+		}
+		if (!res) {
+			if (!vms->oldmessages && !vms->newmessages) {
+				if (!res) {
+					res = ast_play_and_wait(chan, "vm-nomessages");
+				}
+			}
+		}
+	}
+	return res;
+}
+
 
 /* ITALIAN syntax */
 static int vm_intro_it(struct ast_channel *chan, struct vm_state *vms)
@@ -6389,8 +6605,10 @@
 	/* Notify the user that the temp greeting is set and give them the option to remove it */
 	snprintf(prefile, sizeof(prefile), "%s%s/%s/temp", VM_SPOOL_DIR, vmu->context, vms->username);
 	if (ast_test_flag(vmu, VM_TEMPGREETWARN)) {
+		RETRIEVE(prefile, -1, vmu);
 		if (ast_fileexists(prefile, NULL, NULL) > 0)
 			ast_play_and_wait(chan, "vm-tempgreetactive");
+		DISPOSE(prefile, -1);
 	}
 
 	/* Play voicemail intro - syntax is different for different languages */
@@ -6422,6 +6640,8 @@
 		return vm_intro_ru(chan, vms);
 	} else if (!strcasecmp(chan->language, "ua")) { /* UKRAINIAN syntax */
 		return vm_intro_ua(chan, vms);
+	} else if (!strcasecmp(chan->language, "he")) { /* HEBREW syntax */
+		return vm_intro_he(chan, vms);
 	} else {					/* Default to ENGLISH */
 		return vm_intro_en(chan, vms);
 	}
@@ -6435,6 +6655,8 @@
 		if (vms->starting) {
 			if (vms->lastmsg > -1) {
 				res = ast_play_and_wait(chan, "vm-onefor");
+				if (!strcasecmp(chan->language, "he")) 
+					res = ast_play_and_wait(chan, "vm-for");
 				if (!res)
 					res = vm_play_folder_name(chan, vms->vmbox);
 			}
@@ -6646,8 +6868,10 @@
 		default: 
 			cmd = 0;
 			snprintf(prefile, sizeof(prefile), "%s%s/%s/temp", VM_SPOOL_DIR, vmu->context, vms->username);
+			RETRIEVE(prefile, -1, vmu);
 			if (ast_fileexists(prefile, NULL, NULL))
 				cmd = ast_play_and_wait(chan, "vm-tmpexists");
+			DISPOSE(prefile, -1);
 			if (!cmd)
 				cmd = ast_play_and_wait(chan, "vm-options");
 			if (!cmd)
@@ -6777,6 +7001,24 @@
 	return cmd;
 }
 
+/* Hebrew Syntax */
+static int vm_browse_messages_he(struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu)
+{
+	int cmd = 0;
+
+	if (vms->lastmsg > -1) {
+		cmd = play_message(chan, vmu, vms);
+	} else {
+		if (!strcasecmp(vms->fn, "INBOX")) {
+			cmd = ast_play_and_wait(chan, "vm-nonewmessages");
+		} else {
+			cmd = ast_play_and_wait(chan, "vm-nomessages");
+		}
+	}
+	return cmd;
+}
+
+
 /* ITALIAN syntax */
 static int vm_browse_messages_it(struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu)
 {
@@ -6844,6 +7086,8 @@
 		return vm_browse_messages_pt(chan, vms, vmu);
 	} else if (!strcasecmp(chan->language, "gr")){
 		return vm_browse_messages_gr(chan, vms, vmu);   /* GREEK */
+	} else if (!strcasecmp(chan->language, "he")) {
+		return vm_browse_messages_he(chan, vms, vmu); /* HEBREW */ 
 	} else {	/* Default to English syntax */
 		return vm_browse_messages_en(chan, vms, vmu);
 	}
@@ -7439,6 +7683,8 @@
 		case '*':
 			if (!vms.starting) {
 				cmd = ast_play_and_wait(chan, "vm-onefor");
+				if (!strcasecmp(chan->language, "he")) 
+					cmd = ast_play_and_wait(chan, "vm-for");
 				if (!cmd)
 					cmd = vm_play_folder_name(chan, vms.vmbox);
 				if (!cmd)

Modified: team/mattf/bug13454/apps/app_waitforsilence.c
URL: http://svn.digium.com/view/asterisk/team/mattf/bug13454/apps/app_waitforsilence.c?view=diff&rev=150588&r1=150587&r2=150588
==============================================================================
--- team/mattf/bug13454/apps/app_waitforsilence.c (original)
+++ team/mattf/bug13454/apps/app_waitforsilence.c Fri Oct 17 11:37:24 2008
@@ -107,13 +107,13 @@
 		res = ast_waitfor(chan, silencereqd);
 
 		/* Must have gotten a hangup; let's exit */
-		if (res <= 0) {
+		if (res < 0) {
 			f = NULL;
 			break;
 		}
 		
 		/* We waited and got no frame; sounds like digital silence or a muted digital channel */
-		if (!res) {
+		if (res == 0) {
 			dspsilence = silencereqd;
 		} else {
 			/* Looks like we did get a frame, so let's check it out */
@@ -122,6 +122,8 @@
 				break;
 			if (f && f->frametype == AST_FRAME_VOICE) {
 				ast_dsp_silence(sildet, f, &dspsilence);
+			}
+			if (f) {
 				ast_frfree(f);
 			}
 		}

Modified: team/mattf/bug13454/channels/chan_dahdi.c
URL: http://svn.digium.com/view/asterisk/team/mattf/bug13454/channels/chan_dahdi.c?view=diff&rev=150588&r1=150587&r2=150588
==============================================================================
--- team/mattf/bug13454/channels/chan_dahdi.c (original)
+++ team/mattf/bug13454/channels/chan_dahdi.c Fri Oct 17 11:37:24 2008
@@ -3755,7 +3755,7 @@
 {
 	int res;
 	struct dahdi_spaninfo zi;
-#if defined(HAVE_DAHDI) || defined(HAVE_ZAPTEL_CHANALARMS)
+#if !defined(HAVE_ZAPTEL) || defined(HAVE_ZAPTEL_CHANALARMS)
 	/*
 	 * The conditional compilation is needed only in asterisk-1.4 for
 	 * backward compatibility with old zaptel drivers that don't have
@@ -3774,7 +3774,7 @@
 	}
 	if (zi.alarms != DAHDI_ALARM_NONE)
 		return zi.alarms;
-#if defined(HAVE_DAHDI) || defined(HAVE_ZAPTEL_CHANALARMS)
+#if !defined(HAVE_ZAPTEL) || defined(HAVE_ZAPTEL_CHANALARMS)
 	/* No alarms on the span. Check for channel alarms. */
 	if ((res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &params)) >= 0)
 		return params.chan_alarms;
@@ -11083,8 +11083,9 @@
 					return -1;
 		} else if (!strcasecmp(v->name, "buffers")) {
 			int res;
-			char policy[8] = "";
-			res = sscanf(v->value, "%d,%s", &confp->chan.buf_no, policy);
+			char policy[21] = "";
+
+			res = sscanf(v->value, "%d,%20s", &confp->chan.buf_no, policy);
 			if (res != 2) {
 				ast_log(LOG_WARNING, "Parsing buffers option data failed, using defaults.\n");
 				confp->chan.buf_no = numbufs;
@@ -11753,14 +11754,13 @@
 	/*< \todo why check for the pseudo in the per-channel section.
 	 * Any actual use for manual setup of the pseudo channel? */
 	if (!found_pseudo && reload == 0) {
-		/* Make sure pseudo isn't a member of any groups if
-		   we're automatically making it. */	
-		
-		confp->chan.group = 0;
-		confp->chan.callgroup = 0;
-		confp->chan.pickupgroup = 0;
-
-		tmp = mkintf(CHAN_PSEUDO, confp, NULL, reload);
+		/* use the default configuration for a channel, so
+		   that any settings from real configured channels
+		   don't "leak" into the pseudo channel config
+		*/
+		struct dahdi_chan_conf conf = dahdi_chan_conf_default();
+
+		tmp = mkintf(CHAN_PSEUDO, &conf, NULL, reload);
 
 		if (tmp) {
 			if (option_verbose > 2)

Modified: team/mattf/bug13454/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/mattf/bug13454/channels/chan_iax2.c?view=diff&rev=150588&r1=150587&r2=150588
==============================================================================
--- team/mattf/bug13454/channels/chan_iax2.c (original)
+++ team/mattf/bug13454/channels/chan_iax2.c Fri Oct 17 11:37:24 2008
@@ -10695,7 +10695,11 @@
 		index = atoi(codecnum);
 		if((codec = ast_codec_pref_index(&peer->prefs, index))) {
 			ast_copy_string(buf, ast_getformatname(codec), len);
-		}
+		} else {
+			buf[0] = '\0';
+		}
+	} else {
+		buf[0] = '\0';
 	}
 
 	peer_unref(peer);

Modified: team/mattf/bug13454/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/mattf/bug13454/channels/chan_local.c?view=diff&rev=150588&r1=150587&r2=150588
==============================================================================
--- team/mattf/bug13454/channels/chan_local.c (original)
+++ team/mattf/bug13454/channels/chan_local.c Fri Oct 17 11:37:24 2008
@@ -483,6 +483,11 @@
 	ast_cdr_update(p->chan);
 	p->chan->cdrflags = p->owner->cdrflags;
 
+	if (!ast_exists_extension(NULL, p->chan->context, p->chan->exten, 1, p->owner->cid.cid_num)) {
+		ast_log(LOG_NOTICE, "No such extension/context %s@%s while calling Local channel\n", p->chan->exten, p->chan->context);
+		return -1;
+	}
+
 	/* copy the channel variables from the incoming channel to the outgoing channel */
 	/* Note that due to certain assumptions, they MUST be in the same order */
 	AST_LIST_TRAVERSE(&p->owner->varshead, varptr, entries) {
@@ -549,8 +554,12 @@
 	} else {
 		p->owner = NULL;
 		ast_module_user_remove(p->u_owner);
+		while (p->chan && ast_channel_trylock(p->chan)) {
+			DEADLOCK_AVOIDANCE(&p->lock);
+		}
 		if (p->chan) {
 			ast_queue_hangup(p->chan);
+			ast_channel_unlock(p->chan);
 		}
 	}
 	
@@ -617,15 +626,22 @@
 
 	tmp->reqformat = format;
 
+#if 0
+	/* We can't do this check here, because we don't know the CallerID yet, and
+	 * the CallerID could potentially affect what step is actually taken (or
+	 * even if that step exists). */
 	if (!ast_exists_extension(NULL, tmp->context, tmp->exten, 1, NULL)) {
 		ast_log(LOG_NOTICE, "No such extension/context %s@%s creating local channel\n", tmp->exten, tmp->context);
 		tmp = local_pvt_destroy(tmp);
 	} else {
+#endif
 		/* Add to list */
 		AST_LIST_LOCK(&locals);
 		AST_LIST_INSERT_HEAD(&locals, tmp, list);
 		AST_LIST_UNLOCK(&locals);
-	}
+#if 0
+	}
+#endif
 	
 	return tmp;
 }

Modified: team/mattf/bug13454/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/mattf/bug13454/channels/chan_misdn.c?view=diff&rev=150588&r1=150587&r2=150588
==============================================================================
--- team/mattf/bug13454/channels/chan_misdn.c (original)
+++ team/mattf/bug13454/channels/chan_misdn.c Fri Oct 17 11:37:24 2008
@@ -21,7 +21,10 @@
  * \file
  *
  * \brief the chan_misdn channel driver for Asterisk
+ *
  * \author Christian Richter <crich at beronet.com>
+ *
+ * \extref MISDN http://www.misdn.org/
  *
  * \ingroup channel_drivers
  */
@@ -72,13 +75,14 @@
 #include "asterisk/term.h"
 #include "asterisk/sched.h"
 #include "asterisk/stringfields.h"
+#include "asterisk/causes.h"
 
 #include "chan_misdn_config.h"
 #include "isdn_lib.h"
 
-char global_tracefile[BUFFERSIZE+1];
-
-static int g_config_initialized=0;
+char global_tracefile[BUFFERSIZE + 1];
+
+static int g_config_initialized = 0;
 
 struct misdn_jb{
 	int size;
@@ -94,17 +98,17 @@
 
 
 
-/* allocates the jb-structure and initialize the elements*/
+/*! \brief allocates the jb-structure and initialize the elements */
 struct misdn_jb *misdn_jb_init(int size, int upper_threshold);
 
-/* frees the data and destroys the given jitterbuffer struct */
+/*! \brief frees the data and destroys the given jitterbuffer struct */
 void misdn_jb_destroy(struct misdn_jb *jb);
 
-/* fills the jitterbuffer with len data returns < 0 if there was an
+/*! \brief fills the jitterbuffer with len data returns < 0 if there was an
 error (buffer overrun). */
 int misdn_jb_fill(struct misdn_jb *jb, const char *data, int len);
 
-/* gets len bytes out of the jitterbuffer if available, else only the
+/*! \brief gets len bytes out of the jitterbuffer if available, else only the
 available data is returned and the return value indicates the number
 of data. */
 int misdn_jb_empty(struct misdn_jb *jb, char *data, int len);
@@ -132,9 +136,8 @@
 	MISDN_RELEASED, /*!<  when connected */
 	MISDN_BRIDGED, /*!<  when bridged */
 	MISDN_CLEANING, /*!< when hangup from * but we were connected before */
-	MISDN_HUNGUP_FROM_MISDN, /*!< when DISCONNECT/RELEASE/REL_COMP  cam from misdn */
-	MISDN_HUNGUP_FROM_AST, /*!< when DISCONNECT/RELEASE/REL_COMP came out of */
-	/* misdn_hangup */
+	MISDN_HUNGUP_FROM_MISDN, /*!< when DISCONNECT/RELEASE/REL_COMP  came from misdn */
+	MISDN_HUNGUP_FROM_AST, /*!< when DISCONNECT/RELEASE/REL_COMP came out of misdn_hangup */
 	MISDN_HOLDED, /*!< if this chan is holded */
 	MISDN_HOLD_DISCONNECT, /*!< if this chan is holded */
   
@@ -150,17 +153,16 @@
 
 struct chan_list {
   
-	char allowed_bearers[BUFFERSIZE+1];
+	char allowed_bearers[BUFFERSIZE + 1];
 	
 	enum misdn_chan_state state;
 	int need_queue_hangup;
 	int need_hangup;
 	int need_busy;
 	
+	int originator;
 	int noautorespond_on_setup;
 	
-	int originator;
-
 	int norxtone;
 	int notxtone; 
 
@@ -174,7 +176,7 @@
 	char ast_rd_buf[4096];
 	struct ast_frame frame;
 
-	int faxdetect; /* 0:no 1:yes 2:yes+nojump */
+	int faxdetect; /*!<  0:no 1:yes 2:yes+nojump */
 	int faxdetect_timeout;
 	struct timeval faxdetect_tv;
 	int faxhandled;
@@ -246,11 +248,13 @@
 
 static inline void free_robin_list_r (struct robin_list *r)
 {
-        if (r) {
-                if (r->next) free_robin_list_r(r->next);
-                if (r->group) free(r->group);
-                free(r);
-        }
+	if (r) {
+		if (r->next)

[... 9201 lines stripped ...]



More information about the asterisk-commits mailing list