[asterisk-commits] tilghman: branch 1.6.0 r160387 - in /branches/1.6.0: ./ apps/ channels/ inclu...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Dec 2 16:16:32 CST 2008
Author: tilghman
Date: Tue Dec 2 16:16:32 2008
New Revision: 160387
URL: http://svn.digium.com/view/asterisk?view=rev&rev=160387
Log:
Merged revisions 147518,147689,148000,148112,148268,148917,148988,149062,149131,149201,149205,149208 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r147518 | file | 2008-10-08 09:53:51 -0500 (Wed, 08 Oct 2008) | 9 lines
Merged revisions 147517 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r147517 | file | 2008-10-08 11:51:42 -0300 (Wed, 08 Oct 2008) | 2 lines
If we receive DTMF make sure that the state of the speech structure goes back to being not ready. (issue #LUMENVOX-8)
........
................
r147689 | kpfleming | 2008-10-08 17:26:55 -0500 (Wed, 08 Oct 2008) | 9 lines
Merged revisions 147681 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r147681 | kpfleming | 2008-10-08 17:22:09 -0500 (Wed, 08 Oct 2008) | 3 lines
when parsing a text configuration option, ensure that the buffer on the stack is actually large enough to hold the legal values of that option, and also ensure that sscanf() knows to stop parsing if it would overrun the buffer (without these changes, specifying "buffers=...,immediate" would overflow the buffer on the stack, and could not have worked as expected)
........
................
r148000 | tilghman | 2008-10-09 14:39:34 -0500 (Thu, 09 Oct 2008) | 11 lines
Merged revisions 147997 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r147997 | tilghman | 2008-10-09 14:38:33 -0500 (Thu, 09 Oct 2008) | 4 lines
When blank, callerid name and number should display "unknown caller" in voicemail
emails.
(Closes issue #13643)
........
................
r148112 | mmichelson | 2008-10-09 18:15:33 -0500 (Thu, 09 Oct 2008) | 26 lines
Merged revisions 146026 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r146026 | murf | 2008-10-03 12:12:54 -0500 (Fri, 03 Oct 2008) | 18 lines
(closes issue #13579)
Reported by: dwagner
(closes issue #13584)
Reported by: dwagner
Tested by: murf, putnopvut
The thought occurred to me that the res= from the extension spawn
was ending up being returned from the bridge.
"Thou shalt not poison the return value". Made the change
and it appears to allow blind xfers to work as normal.
If I'm wrong, reopen the bugs. But it looks good to me!
Many thanks to putnopvut for helping me reproduce this!
........
................
r148268 | tilghman | 2008-10-10 11:31:31 -0500 (Fri, 10 Oct 2008) | 14 lines
Merged revisions 148257 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r148257 | tilghman | 2008-10-10 11:25:31 -0500 (Fri, 10 Oct 2008) | 7 lines
User not notified of temporary greeting, if ODBC storage is in use.
(closes issue #13659)
Reported by: moliveras
Patches:
20081009__bug13659.diff.txt uploaded by Corydon76 (license 14)
Tested by: moliveras
........
................
r148917 | tilghman | 2008-10-14 12:46:48 -0500 (Tue, 14 Oct 2008) | 11 lines
Merged revisions 148916 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r148916 | tilghman | 2008-10-14 12:41:08 -0500 (Tue, 14 Oct 2008) | 4 lines
Ensure that mail headers are 7-bit clean, even when UTF-8 characters are used
in headers like 'Subject' and 'To'.
Closes AST-107.
........
................
r148988 | tilghman | 2008-10-14 14:03:44 -0500 (Tue, 14 Oct 2008) | 9 lines
Merged revisions 148987 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r148987 | tilghman | 2008-10-14 14:03:08 -0500 (Tue, 14 Oct 2008) | 2 lines
Some compilers warn, some don't. Fixing.
........
................
r149062 | tilghman | 2008-10-14 15:16:48 -0500 (Tue, 14 Oct 2008) | 13 lines
Merged revisions 149061 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r149061 | tilghman | 2008-10-14 15:09:06 -0500 (Tue, 14 Oct 2008) | 6 lines
Check correct values in the return of ast_waitfor(); also, get rid of a
possible memory leak.
(closes issue #13658)
Reported by: explidous
Patch by: me
........
................
r149131 | mmichelson | 2008-10-14 16:08:48 -0500 (Tue, 14 Oct 2008) | 15 lines
Merged revisions 149130 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r149130 | mmichelson | 2008-10-14 15:49:02 -0500 (Tue, 14 Oct 2008) | 7 lines
Don't allow reserved characters to be used in register
lines in sip.conf.
(closes issue #13570)
Reported by: putnopvut
........
................
r149201 | mmichelson | 2008-10-14 17:41:13 -0500 (Tue, 14 Oct 2008) | 20 lines
Merged revisions 149200 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r149200 | mmichelson | 2008-10-14 17:40:42 -0500 (Tue, 14 Oct 2008) | 12 lines
Update the queue with the correct number of calls and
whether the call was completed within the service level
when a transfer takes place. This way, we do not "break"
the leastrecent and fewestcalls strategies by not logging
a call until after the transferred call has ended.
(closes issue #13395)
Reported by: Marquis
Patches:
app_queue.c.transfer.patch uploaded by Marquis (license 32)
........
................
r149205 | mmichelson | 2008-10-14 18:04:44 -0500 (Tue, 14 Oct 2008) | 20 lines
Merged revisions 149204 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r149204 | mmichelson | 2008-10-14 18:00:01 -0500 (Tue, 14 Oct 2008) | 12 lines
Add a tolerance period for sync-triggered audiohooks
so that if packetization of audio is close (but not equal)
we don't end up flushing the audiohooks over small
inconsistencies in synchronization.
Related to issue #13005, and solves the issue
for most people who were experiencing the problem.
However, a small number of people are still experiencing
the problem on long calls, so I am not closing
the issue yet
........
................
r149208 | mmichelson | 2008-10-14 18:15:04 -0500 (Tue, 14 Oct 2008) | 17 lines
Merged revisions 149207 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r149207 | mmichelson | 2008-10-14 18:10:26 -0500 (Tue, 14 Oct 2008) | 9 lines
Call register_peer_exten even in the case that the peer's
IP/port does not change.
(closes issue #13309)
Reported by: dimas
Patches:
v2-13309.patch uploaded by dimas (license 88)
........
................
Modified:
branches/1.6.0/ (props changed)
branches/1.6.0/Makefile
branches/1.6.0/apps/app_queue.c
branches/1.6.0/apps/app_speech_utils.c
branches/1.6.0/apps/app_voicemail.c
branches/1.6.0/apps/app_waitforsilence.c
branches/1.6.0/channels/chan_dahdi.c
branches/1.6.0/channels/chan_sip.c
branches/1.6.0/include/asterisk/audiohook.h
branches/1.6.0/main/audiohook.c
branches/1.6.0/main/features.c
Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.
Modified: branches/1.6.0/Makefile
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/Makefile?view=diff&rev=160387&r1=160386&r2=160387
==============================================================================
--- branches/1.6.0/Makefile (original)
+++ branches/1.6.0/Makefile Tue Dec 2 16:16:32 2008
@@ -887,3 +887,5 @@
$(MAKE) -C doc/tex asterisk.pdf
.PHONY: menuselect menuselect.makeopts main sounds clean dist-clean distclean all prereqs cleantest uninstall _uninstall uninstall-all pdf dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_DIST_CLEAN) $(SUBDIRS_CLEAN) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS) badshell main/version.c include/asterisk/version.h installdirs
+
+FORCE:
Modified: branches/1.6.0/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/apps/app_queue.c?view=diff&rev=160387&r1=160386&r2=160387
==============================================================================
--- branches/1.6.0/apps/app_queue.c (original)
+++ branches/1.6.0/apps/app_queue.c Tue Dec 2 16:16:32 2008
@@ -3057,6 +3057,7 @@
struct queue_ent *qe;
struct member *member;
int starttime;
+ int callcompletedinsl;
};
static void queue_transfer_destroy(void *data)
@@ -3088,11 +3089,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");
@@ -3116,7 +3120,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));
@@ -3137,6 +3141,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);
@@ -3814,7 +3819,7 @@
ast_copy_string(oldcontext, qe->chan->context, sizeof(oldcontext));
ast_copy_string(oldexten, qe->chan->exten, sizeof(oldexten));
time(&callstart);
- setup_transfer_datastore(qe, member, callstart);
+ setup_transfer_datastore(qe, member, callstart, callcompletedinsl);
bridge = ast_bridge_call(qe->chan,peer, &bridge_config);
/* If the queue member did an attended transfer, then the TRANSFER already was logged in the queue_log
@@ -3843,11 +3848,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: branches/1.6.0/apps/app_speech_utils.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/apps/app_speech_utils.c?view=diff&rev=160387&r1=160386&r2=160387
==============================================================================
--- branches/1.6.0/apps/app_speech_utils.c (original)
+++ branches/1.6.0/apps/app_speech_utils.c Tue Dec 2 16:16:32 2008
@@ -727,6 +727,7 @@
speech->results->text = ast_strdup(dtmf);
speech->results->grammar = ast_strdup("dtmf");
}
+ ast_speech_change_state(speech, AST_SPEECH_STATE_NOT_READY);
}
/* See if it was because they hung up */
Modified: branches/1.6.0/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/apps/app_voicemail.c?view=diff&rev=160387&r1=160386&r2=160387
==============================================================================
--- branches/1.6.0/apps/app_voicemail.c (original)
+++ branches/1.6.0/apps/app_voicemail.c Tue Dec 2 16:16:32 2008
@@ -3230,7 +3230,8 @@
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_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);
@@ -3277,6 +3278,90 @@
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;
+}
+
+/*!
+ * \brief Creates the email file to be sent to indicate a new voicemail exists for a user.
+ * \param p The output file to generate the email contents into.
+ * \param srcemail The email address to send the email to, presumably the email address for the owner of the mailbox.
+ * \param vmu The voicemail user who is sending the voicemail.
+ * \param msgnum The message index in the mailbox folder.
+ * \param context
+ * \param mailbox The voicemail box to read the voicemail to be notified in this email.
+ * \param cidnum The caller ID number.
+ * \param cidname The caller ID name.
+ * \param attach the name of the sound file to be attached to the email, if attach_user_voicemail == 1.
+ * \param format The message sound file format. i.e. .wav
+ * \param duration The time of the message content, in seconds.
+ * \param attach_user_voicemail if 1, the sound file is attached to the email.
+ * \param chan
+ * \param category
+ * \param imap if == 1, indicates the target folder for the email notification to be sent to will be an IMAP mailstore. This causes additional mailbox headers to be set, which would facilitate searching for the email in the destination IMAP folder.
+ *
+ * The email body, and base 64 encoded attachement (if any) are stored to the file identified by *p. This method does not actually send the email. That is done by invoking the configure 'mailcmd' and piping this generated file into it, or with the sendemail() function.
+ */
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)
{
char date[256];
@@ -3288,8 +3373,8 @@
char tmpcmd[256];
struct ast_tm tm;
char enc_cidnum[256] = "", enc_cidname[256] = "";
- char *passdata2;
- size_t len_passdata;
+ char *passdata = NULL, *passdata2;
+ size_t len_passdata = 0, len_passdata2, tmplen;
char *greeting_attachment;
#ifdef IMAP_STORAGE
@@ -3297,6 +3382,17 @@
#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(fromstring)) > len_passdata2) {
+ len_passdata2 = tmplen;
+ }
+ len_passdata2 = len_passdata2 * 3 + 200;
+ passdata2 = alloca(len_passdata2);
if (!ast_strlen_zero(cidnum)) {
strip_control(cidnum, enc_cidnum, sizeof(enc_cidnum));
@@ -3325,15 +3421,25 @@
if (!ast_strlen_zero(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;
- 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);
+ 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");
@@ -3341,19 +3447,48 @@
} 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 (!ast_strlen_zero(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;
- 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, emailsubject, passdata, vmlen);
- fprintf(p, "Subject: %s" ENDL, passdata);
+ /* 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);
+ }
ast_channel_free(ast);
} else {
ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
@@ -6894,8 +7029,11 @@
/* 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)) {
- if (ast_fileexists(prefile, NULL, NULL) > 0)
+ RETRIEVE(prefile, -1, vmu->mailbox, vmu->context);
+ 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 */
@@ -7186,9 +7324,11 @@
default:
cmd = 0;
snprintf(prefile, sizeof(prefile), "%s%s/%s/temp", VM_SPOOL_DIR, vmu->context, vms->username);
+ RETRIEVE(prefile, -1, vmu->mailbox, vmu->context);
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");
}
Modified: branches/1.6.0/apps/app_waitforsilence.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/apps/app_waitforsilence.c?view=diff&rev=160387&r1=160386&r2=160387
==============================================================================
--- branches/1.6.0/apps/app_waitforsilence.c (original)
+++ branches/1.6.0/apps/app_waitforsilence.c Tue Dec 2 16:16:32 2008
@@ -69,7 +69,7 @@
"TIMEOUT - if exited without silence detected after timeout\n";
static int do_waiting(struct ast_channel *chan, int silencereqd, time_t waitstart, int timeout) {
- struct ast_frame *f;
+ struct ast_frame *f = NULL;
int dspsilence = 0;
static int silencethreshold = 128;
int rfmt = 0;
@@ -78,48 +78,47 @@
time_t now;
rfmt = chan->readformat; /* Set to linear mode */
- res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
- if (res < 0) {
+ if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR)) < 0) {
ast_log(LOG_WARNING, "Unable to set channel to linear mode, giving up\n");
return -1;
}
- sildet = ast_dsp_new(); /* Create the silence detector */
- if (!sildet) {
+ /* Create the silence detector */
+ if (!(sildet = ast_dsp_new())) {
ast_log(LOG_WARNING, "Unable to create silence detector :(\n");
return -1;
}
ast_dsp_set_threshold(sildet, silencethreshold);
/* Await silence... */
- f = NULL;
- for(;;) {
+ for (;;) {
/* Start with no silence received */
dspsilence = 0;
res = ast_waitfor(chan, silencereqd);
/* Must have gotten a hangup; let's exit */
- if (res <= 0) {
- f = NULL;
+ if (res < 0) {
+ pbx_builtin_setvar_helper(chan, "WAITSTATUS", "HANGUP");
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 */
- f = ast_read(chan);
- if (!f)
+ if (!(f = ast_read(chan))) {
+ pbx_builtin_setvar_helper(chan, "WAITSTATUS", "HANGUP");
break;
- if (f && f->frametype == AST_FRAME_VOICE) {
+ }
+ if (f->frametype == AST_FRAME_VOICE) {
ast_dsp_silence(sildet, f, &dspsilence);
- ast_frfree(f);
}
+ ast_frfree(f);
}
- ast_verb(3, "Got %dms silence< %dms required\n", dspsilence, silencereqd);
+ ast_verb(6, "Got %dms silence< %dms required\n", dspsilence, silencereqd);
if (dspsilence >= silencereqd) {
ast_verb(3, "Exiting with %dms silence >= %dms required\n", dspsilence, silencereqd);
Modified: branches/1.6.0/channels/chan_dahdi.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/channels/chan_dahdi.c?view=diff&rev=160387&r1=160386&r2=160387
==============================================================================
--- branches/1.6.0/channels/chan_dahdi.c (original)
+++ branches/1.6.0/channels/chan_dahdi.c Tue Dec 2 16:16:32 2008
@@ -13547,8 +13547,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;
Modified: branches/1.6.0/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/channels/chan_sip.c?view=diff&rev=160387&r1=160386&r2=160387
==============================================================================
--- branches/1.6.0/channels/chan_sip.c (original)
+++ branches/1.6.0/channels/chan_sip.c Tue Dec 2 16:16:32 2008
@@ -188,6 +188,8 @@
#define SIPBUFSIZE 512
#define XMIT_ERROR -2
+
+#define SIP_RESERVED ";/?:@&=+$,# "
/* #define VOCAL_DATA_HACK */
@@ -3499,8 +3501,10 @@
context = global_regcontext;
}
if (onoff) {
- ast_add_extension(context, 1, ext, 1, NULL, NULL, "Noop",
- ast_strdup(peer->name), ast_free_ptr, "SIP");
+ if (!ast_exists_extension(NULL, context, ext, 1, NULL)) {
+ ast_add_extension(context, 1, ext, 1, NULL, NULL, "Noop",
+ ast_strdup(peer->name), ast_free, "SIP");
+ }
} else if (pbx_find_extension(NULL, NULL, &q, context, ext, 1, NULL, "", E_MATCH)) {
ast_context_remove_extension(context, ext, 1, NULL);
}
@@ -6136,8 +6140,10 @@
enum sip_transport transport = SIP_TRANSPORT_UDP;
char buf[256] = "";
char *username = NULL;
+ char *port = NULL;
char *hostname=NULL, *secret=NULL, *authuser=NULL;
char *callback=NULL;
+ char *reserved = NULL;
if (!value)
return -1;
@@ -6162,12 +6168,34 @@
if (authuser)
*authuser++ = '\0';
}
+ if ((reserved = strpbrk(username, SIP_RESERVED))) {
+ goto invalid_char;
+ }
+ if (!ast_strlen_zero(secret) && (reserved = strpbrk(secret, SIP_RESERVED))) {
+ goto invalid_char;
+ }
+ if (!ast_strlen_zero(authuser) && (reserved = strpbrk(authuser, SIP_RESERVED))) {
+ goto invalid_char;
+ }
/* split host[:port][/contact] */
callback = strchr(hostname, '/');
if (callback)
*callback++ = '\0';
if (ast_strlen_zero(callback))
callback = "s";
+ /* Separate host from port when checking for reserved characters
+ */
+ if ((port = strchr(hostname, ':'))) {
+ *port = '\0';
+ }
+ if ((reserved = strpbrk(hostname, SIP_RESERVED))) {
+ goto invalid_char;
+ }
+ /* And then re-merge the host and port so they are stored correctly
+ */
+ if (port) {
+ *port = ':';
+ }
if (!(reg = ast_calloc(1, sizeof(*reg)))) {
ast_log(LOG_ERROR, "Out of memory. Can't allocate SIP registry entry\n");
return -1;
@@ -6201,6 +6229,10 @@
ASTOBJ_CONTAINER_LINK(®l, reg); /* Add the new registry entry to the list */
registry_unref(reg); /* release the reference given by ASTOBJ_INIT. The container has another reference */
return 0;
+
+invalid_char:
+ ast_log(LOG_WARNING, "A reserved character ('%c') was used in a \"register\" line. This registration will not occur\n", *reserved);
+ return -1;
}
/*! \brief Parse multiline SIP headers into one header
@@ -10063,11 +10095,11 @@
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: SIP\r\nPeer: SIP/%s\r\nPeerStatus: Registered\r\n", peer->name);
/* Is this a new IP address for us? */
- if (inaddrcmp(&peer->addr, &oldsin)) {
- sip_poke_peer(peer);
- ast_verb(3, "Registered SIP '%s' at %s port %d expires %d\n", peer->name, ast_inet_ntoa(peer->addr.sin_addr), ntohs(peer->addr.sin_port), expiry);
- register_peer_exten(peer, TRUE);
- }
+ if (VERBOSITY_ATLEAST(2) && inaddrcmp(&peer->addr, &oldsin)) {
+ ast_verbose(VERBOSE_PREFIX_3 "Registered SIP '%s' at %s port %d\n", peer->name, ast_inet_ntoa(peer->addr.sin_addr), ntohs(peer->addr.sin_port));
+ }
+ sip_poke_peer(peer);
+ register_peer_exten(peer, 1);
/* Save User agent */
useragent = get_header(req, "User-Agent");
Modified: branches/1.6.0/include/asterisk/audiohook.h
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/include/asterisk/audiohook.h?view=diff&rev=160387&r1=160386&r2=160387
==============================================================================
--- branches/1.6.0/include/asterisk/audiohook.h (original)
+++ branches/1.6.0/include/asterisk/audiohook.h Tue Dec 2 16:16:32 2008
@@ -59,6 +59,8 @@
AST_AUDIOHOOK_WANTS_DTMF = (1 << 1), /*!< Audiohook also wants to receive DTMF frames */
AST_AUDIOHOOK_TRIGGER_SYNC = (1 << 2), /*!< Audiohook wants to be triggered when both sides have combined audio available */
};
+
+#define AST_AUDIOHOOK_SYNC_TOLERANCE 100 /*< Tolerance in milliseconds for audiohooks synchronization */
struct ast_audiohook;
Modified: branches/1.6.0/main/audiohook.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/audiohook.c?view=diff&rev=160387&r1=160386&r2=160387
==============================================================================
--- branches/1.6.0/main/audiohook.c (original)
+++ branches/1.6.0/main/audiohook.c Tue Dec 2 16:16:32 2008
@@ -123,12 +123,18 @@
struct ast_slinfactory *factory = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_factory : &audiohook->write_factory);
struct ast_slinfactory *other_factory = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->write_factory : &audiohook->read_factory);
struct timeval *time = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_time : &audiohook->write_time), previous_time = *time;
+ int our_factory_ms;
+ int other_factory_samples;
+ int other_factory_ms;
/* Update last feeding time to be current */
*time = ast_tvnow();
- /* If we are using a sync trigger and this factory suddenly got audio fed in after a lapse, then flush both factories to ensure they remain in sync */
- if (ast_test_flag(audiohook, AST_AUDIOHOOK_TRIGGER_SYNC) && ast_slinfactory_available(other_factory) && (ast_tvdiff_ms(*time, previous_time) > (ast_slinfactory_available(other_factory) / 8))) {
+ our_factory_ms = ast_tvdiff_ms(*time, previous_time) + (ast_slinfactory_available(factory) / 8);
+ other_factory_samples = ast_slinfactory_available(other_factory);
+ other_factory_ms = other_factory_samples / 8;
+
+ if (ast_test_flag(audiohook, AST_AUDIOHOOK_TRIGGER_SYNC) && other_factory_samples && (our_factory_ms - other_factory_ms > AST_AUDIOHOOK_SYNC_TOLERANCE)) {
if (option_debug)
ast_log(LOG_DEBUG, "Flushing audiohook %p so it remains in sync\n", audiohook);
ast_slinfactory_flush(factory);
Modified: branches/1.6.0/main/features.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/features.c?view=diff&rev=160387&r1=160386&r2=160387
==============================================================================
--- branches/1.6.0/main/features.c (original)
+++ branches/1.6.0/main/features.c Tue Dec 2 16:16:32 2008
@@ -2192,6 +2192,7 @@
char save_exten[AST_MAX_EXTENSION];
int save_prio;
int found = 0; /* set if we find at least one match */
+ int spawn_error = 0;
if (bridge_cdr && ast_opt_end_cdr_before_h_exten) {
ast_cdr_end(bridge_cdr);
@@ -2210,15 +2211,13 @@
ast_copy_string(chan->exten, "h", sizeof(chan->exten));
chan->priority = 1;
ast_channel_unlock(chan);
- while ((res = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num, &found, 1)) == 0) {
+ while ((spawn_error = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num, &found, 1)) == 0) {
chan->priority++;
}
- if (found && res) {
+ if (found && spawn_error) {
/* Something bad happened, or a hangup has been requested. */
ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", chan->context, chan->exten, chan->priority, chan->name);
ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", chan->context, chan->exten, chan->priority, chan->name);
- } else if (!found && res) {
- res = 0;
}
/* swap it back */
ast_channel_lock(chan);
More information about the asterisk-commits
mailing list