[asterisk-commits] russell: branch russell/chan_console r72246 - in /team/russell/chan_console: ...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jun 27 15:09:58 CDT 2007
Author: russell
Date: Wed Jun 27 15:09:57 2007
New Revision: 72246
URL: http://svn.digium.com/view/asterisk?view=rev&rev=72246
Log:
Merged revisions 71721,71732,71752,71797,71830,71883,71914,71916,71952,71954,71988,72007,72052,72113,72134,72149,72183,72207,72232-72233,72241 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r71721 | mmichelson | 2007-06-25 18:18:19 -0500 (Mon, 25 Jun 2007) | 4 lines
In my commit earlier today, I accidentally left a prototype that isn't defined.
This gets rid of that prototype.
................
r71732 | mmichelson | 2007-06-25 19:10:09 -0500 (Mon, 25 Jun 2007) | 4 lines
Fixes a problem where Asterisk would not compile if IMAP_STORAGE was enabled.
Needed to add a space between file name and options.
................
r71752 | tilghman | 2007-06-26 07:30:59 -0500 (Tue, 26 Jun 2007) | 18 lines
Merged revisions 71751 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r71751 | tilghman | 2007-06-26 07:27:47 -0500 (Tue, 26 Jun 2007) | 10 lines
Merged revisions 71750 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r71750 | tilghman | 2007-06-26 07:25:58 -0500 (Tue, 26 Jun 2007) | 2 lines
Issue 10062 - Trying to move a message without selecting one first results in memory corruption
........
................
................
r71797 | mmichelson | 2007-06-26 10:50:11 -0500 (Tue, 26 Jun 2007) | 13 lines
Merged revisions 71796 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r71796 | mmichelson | 2007-06-26 10:47:31 -0500 (Tue, 26 Jun 2007) | 5 lines
Fixing bug where the authuser was mistakenly pulled from the mailbox string instead
of the IMAP user.
(closes issue 10054, reported and patched by jaroth)
........
................
r71830 | qwell | 2007-06-26 11:39:22 -0500 (Tue, 26 Jun 2007) | 4 lines
Simplify some code in res_jabber relating to SASL support.
Issue 9988, patch by phsultan.
................
r71883 | mmichelson | 2007-06-26 14:06:47 -0500 (Tue, 26 Jun 2007) | 19 lines
Merged revisions 71877 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r71877 | mmichelson | 2007-06-26 14:00:05 -0500 (Tue, 26 Jun 2007) | 11 lines
A few changes, the ultimate goal of which is to keep better track of the number of messages
that a mailbox currently has. A description of the changes:
1. Changed the "updated" field of the vm_state struct to act more as a binary semaphore than a
counting semaphore, since its current implementation made the inboxcount function not work properly.
This change falls in line with a change made by UPenn with their IMAP setup and helps to sync our changes with theirs.
2. Eliminated some redundant calls to get_vm_state_by_mailbox inside leave_voicemail
3. Use the play_folder variable to keep track of the number of old and new messages in a mailbox as the messages are deleted
4. Added an increment to the number of new messages that was not there previously in the leave_voicemail function
........
................
r71914 | mmichelson | 2007-06-26 15:34:46 -0500 (Tue, 26 Jun 2007) | 3 lines
Create directory if it does not exist.
(Closes issue 10061, Reported and patched by eliel)
................
r71916 | qwell | 2007-06-26 15:36:50 -0500 (Tue, 26 Jun 2007) | 12 lines
Merged revisions 71915 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r71915 | qwell | 2007-06-26 15:36:09 -0500 (Tue, 26 Jun 2007) | 4 lines
Don't dereference a pointer that may be NULL here.
Issue 10017.
........
................
r71952 | mmichelson | 2007-06-26 17:45:16 -0500 (Tue, 26 Jun 2007) | 4 lines
The variable msgnum was being overwritten if IMAP storage was enabled.
Put necessary #ifndef's around the line which would overwrite.
................
r71954 | mmichelson | 2007-06-26 18:03:09 -0500 (Tue, 26 Jun 2007) | 12 lines
Merged revisions 71953 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r71953 | mmichelson | 2007-06-26 18:02:09 -0500 (Tue, 26 Jun 2007) | 4 lines
Removing a pointless line. This variable was already set earlier and between then and this
line, there is no way that the values on the right side of the assignment could have changed.
........
................
r71988 | file | 2007-06-26 18:31:23 -0500 (Tue, 26 Jun 2007) | 2 lines
Add rtpdest option to SIP CHANNEL() dialplan function to return the IP address and port that RTP (be it audio/video/text) is going to.
................
r72007 | file | 2007-06-26 20:00:47 -0500 (Tue, 26 Jun 2007) | 10 lines
Merged revisions 72006 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r72006 | file | 2007-06-26 20:58:35 -0400 (Tue, 26 Jun 2007) | 2 lines
Make unloading of pbx_dundi actually work.
........
................
r72052 | crichter | 2007-06-27 03:08:58 -0500 (Wed, 27 Jun 2007) | 21 lines
Merged revisions 72042 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r72042 | crichter | 2007-06-27 09:58:06 +0200 (Mi, 27 Jun 2007) | 13 lines
Merged revisions 72040-72041 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r72040 | crichter | 2007-06-27 09:49:27 +0200 (Mi, 27 Jun 2007) | 1 line
for inbound TE calls, we setup the bchannel when we get the CONNECT_ACKNOWLEDGE, to make sure mISDN has everything ready. removed some #if 0 areas which weren't used anymore.
........
r72041 | crichter | 2007-06-27 09:54:30 +0200 (Mi, 27 Jun 2007) | 1 line
isdn_lib.c didn't compile
........
................
................
r72113 | russell | 2007-06-27 11:38:12 -0500 (Wed, 27 Jun 2007) | 11 lines
Merged revisions 72112 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r72112 | russell | 2007-06-27 11:34:24 -0500 (Wed, 27 Jun 2007) | 3 lines
Only output debug information related to RTCP timestamps when RTCP debug
is turned on (issue #10066, patch by me)
........
................
r72134 | qwell | 2007-06-27 12:14:31 -0500 (Wed, 27 Jun 2007) | 14 lines
Merged revisions 72125 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r72125 | qwell | 2007-06-27 12:10:32 -0500 (Wed, 27 Jun 2007) | 4 lines
Don't modify a variable that we don't want modified. Make a copy of it instead.
Issue 10029, patch by phsultan with slight modifications by me (to remove needless casts).
Note: chan_jingle in trunk does not appear to have the same bug.
........
................
r72149 | file | 2007-06-27 12:34:26 -0500 (Wed, 27 Jun 2007) | 10 lines
Merged revisions 72148 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r72148 | file | 2007-06-27 13:31:50 -0400 (Wed, 27 Jun 2007) | 2 lines
Make the ast_read_noaudio API call behave better under circumstances where DTMF emulation was happening and a generator was setup. (issue #10065 reported by stevefeinstein)
........
................
r72183 | qwell | 2007-06-27 13:37:44 -0500 (Wed, 27 Jun 2007) | 12 lines
Merged revisions 72182 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r72182 | qwell | 2007-06-27 13:36:56 -0500 (Wed, 27 Jun 2007) | 4 lines
Fix another problem in voicemail with missing symbols.
Issue 10074, patch by kryptolus, extended to include #if 0'd blocks (just in case)
........
................
r72207 | kpfleming | 2007-06-27 14:13:54 -0500 (Wed, 27 Jun 2007) | 10 lines
Merged revisions 72205 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r72205 | kpfleming | 2007-06-27 14:13:21 -0500 (Wed, 27 Jun 2007) | 2 lines
use the proper type for storing group number bits so that if someone specifies 'group=42' it will actually work instead of being silently ignored
........
................
r72232 | mmichelson | 2007-06-27 14:50:21 -0500 (Wed, 27 Jun 2007) | 10 lines
Adding feature to support the storage and retrieval of voicemail greetings using IMAP storage.
This feature may be turned on by adding imapgreetings=yes to the general section of voicemail.conf
voicemail.conf.sample has details on the options added.
As a result, IMAP storage now has RETRIEVE and DISPOSE macros defined.
In addition to the IMAP greeting changes, I also have added an enum for the voicemail folders
and so now the code should be easier to understand and maintain when it comes to this area.
................
r72233 | file | 2007-06-27 14:57:36 -0500 (Wed, 27 Jun 2007) | 2 lines
Fix -T option. (issue #10073 reported by xylome)
................
r72241 | file | 2007-06-27 15:07:46 -0500 (Wed, 27 Jun 2007) | 2 lines
Fix up properties.
................
Modified:
team/russell/chan_console/ (props changed)
team/russell/chan_console/CHANGES
team/russell/chan_console/apps/app_record.c
team/russell/chan_console/apps/app_voicemail.c
team/russell/chan_console/channels/chan_gtalk.c
team/russell/chan_console/channels/chan_sip.c
team/russell/chan_console/channels/chan_zap.c
team/russell/chan_console/channels/misdn/isdn_lib.c
team/russell/chan_console/configs/voicemail.conf.sample
team/russell/chan_console/configure.ac
team/russell/chan_console/funcs/func_channel.c
team/russell/chan_console/main/channel.c
team/russell/chan_console/main/logger.c
team/russell/chan_console/main/rtp.c
team/russell/chan_console/pbx/pbx_dundi.c
team/russell/chan_console/res/res_jabber.c
Propchange: team/russell/chan_console/
------------------------------------------------------------------------------
automerge = *
Propchange: team/russell/chan_console/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Propchange: team/russell/chan_console/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Jun 27 15:09:57 2007
@@ -1,1 +1,1 @@
-/trunk:1-71703
+/trunk:1-72244
Modified: team/russell/chan_console/CHANGES
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/CHANGES?view=diff&rev=72246&r1=72245&r2=72246
==============================================================================
--- team/russell/chan_console/CHANGES (original)
+++ team/russell/chan_console/CHANGES Wed Jun 27 15:09:57 2007
@@ -59,6 +59,7 @@
required due to the restructuring of how MWI is handled. See the descriptions
in this file of the "pollmailboxes" and "pollfreq" options to voicemail.conf
for more information.
+ * Added rtpdest option to CHANNEL() dialplan function.
IAX2 changes
------------
@@ -105,6 +106,7 @@
to account for this: "pollmailboxes" and "pollfreq". See the sample
configuration file for details.
* Added "tw" language support
+ * Added support for storage of greetings using an IMAP server
Queue changes
-------------
Modified: team/russell/chan_console/apps/app_record.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/apps/app_record.c?view=diff&rev=72246&r1=72245&r2=72246
==============================================================================
--- team/russell/chan_console/apps/app_record.c (original)
+++ team/russell/chan_console/apps/app_record.c Wed Jun 27 15:09:57 2007
@@ -81,6 +81,7 @@
int count = 0;
int percentflag = 0;
char *filename, *ext = NULL, *silstr, *maxstr, *options;
+ char *file, *dir;
char *vdata, *p;
int i = 0;
char tmp[256];
@@ -263,8 +264,13 @@
}
ast_dsp_set_threshold(sildet, 256);
}
-
-
+
+ /* Create the directory if it does not exist. */
+ dir = ast_strdupa(tmp);
+ if ((file = strrchr(dir, '/')))
+ *file++ = '\0';
+ ast_mkdir (dir, 0777);
+
flags = option_append ? O_CREAT|O_APPEND|O_WRONLY : O_CREAT|O_TRUNC|O_WRONLY;
s = ast_writefile( tmp, ext, NULL, flags , 0, AST_FILE_MODE);
Modified: team/russell/chan_console/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/apps/app_voicemail.c?view=diff&rev=72246&r1=72245&r2=72246
==============================================================================
--- team/russell/chan_console/apps/app_voicemail.c (original)
+++ team/russell/chan_console/apps/app_voicemail.c Wed Jun 27 15:09:57 2007
@@ -122,10 +122,12 @@
static char imapport[8];
static char imapflags[128];
static char imapfolder[64];
+static char greetingfolder[64];
static char authuser[32];
static char authpassword[42];
static int expungeonhangup = 1;
+static int imapgreetings = 0;
AST_MUTEX_DEFINE_STATIC(delimiter_lock);
static char delimiter = '\0';
@@ -154,8 +156,10 @@
static void imap_mailbox_name(char *spec, struct vm_state *vms, int box, int target);
static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, int msgnum, struct ast_channel *chan, struct ast_vm_user *vmu, char *fmt, int duration, struct vm_state *vms);
static void update_messages_by_imapuser(const char *user, unsigned long number);
-static int count_messages(struct ast_vm_user *vmu, char *dir);
-
+
+static int imap_remove_file (char *dir, int msgnum);
+static int imap_retrieve_file (char *dir, int msgnum, char *mailbox, char *context);
+static int imap_delete_old_greeting (char *dir, struct vm_state *vms);
struct vmstate {
struct vm_state *vms;
AST_LIST_ENTRY(vmstate) list;
@@ -211,6 +215,15 @@
#define VM_TEMPGREETWARN (1 << 15) /*!< Remind user tempgreeting is set */
#define ERROR_LOCK_PATH -100
+
+enum {
+ NEW_FOLDER,
+ OLD_FOLDER,
+ WORK_FOLDER,
+ FAMILY_FOLDER,
+ FRIENDS_FOLDER,
+ GREETINGS_FOLDER
+} vm_box;
enum {
OPT_SILENT = (1 << 0),
@@ -400,7 +413,7 @@
#ifdef ODBC_STORAGE
static char odbc_database[80];
static char odbc_table[80];
-#define RETRIEVE(a,b) retrieve_file(a,b)
+#define RETRIEVE(a,b,c,d) retrieve_file(a,b)
#define DISPOSE(a,b) remove_file(a,b)
#define STORE(a,b,c,d,e,f,g,h,i) store_file(a,b,c,d)
#define EXISTS(a,b,c,d) (message_exists(a,b))
@@ -409,8 +422,8 @@
#define DELETE(a,b,c) (delete_file(a,b))
#else
#ifdef IMAP_STORAGE
-#define RETRIEVE(a,b)
-#define DISPOSE(a,b)
+#define RETRIEVE(a,b,c,d) (imap_retrieve_file(a,b,c,d ))
+#define DISPOSE(a,b) (imap_remove_file(a,b))
#define STORE(a,b,c,d,e,f,g,h,i) (imap_store_file(a,b,c,d,e,f,g,h,i))
#define EXISTS(a,b,c,d) (ast_fileexists(c,NULL,d) > 0)
#define RENAME(a,b,c,d,e,f,g,h) (rename_file(g,h));
@@ -418,7 +431,7 @@
#define IMAP_DELETE(a,b,c,d) (vm_imap_delete(b,d))
#define DELETE(a,b,c) (vm_delete(c))
#else
-#define RETRIEVE(a,b)
+#define RETRIEVE(a,b,c,d)
#define DISPOSE(a,b)
#define STORE(a,b,c,d,e,f,g,h,i)
#define EXISTS(a,b,c,d) (ast_fileexists(c,NULL,d) > 0)
@@ -1967,6 +1980,8 @@
struct tm tm;
char *passdata2;
size_t len_passdata;
+ char *greeting_attachment;
+
#ifdef IMAP_STORAGE
#define ENDL "\r\n"
#else
@@ -1978,6 +1993,11 @@
ast_copy_string(who, srcemail, sizeof(who));
else
snprintf(who, sizeof(who), "%s@%s", srcemail, host);
+
+ greeting_attachment = strrchr(ast_strdupa(attach), '/');
+ if (greeting_attachment)
+ *greeting_attachment++ = '\0';
+
snprintf(dur, sizeof(dur), "%d:%02d", duration / 60, duration % 60);
strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", vmu_tm(vmu, &tm));
fprintf(p, "Date: %s" ENDL, date);
@@ -2042,8 +2062,9 @@
fprintf(p, "X-Asterisk-VM-Caller-ID-Num: %s" ENDL, cidnum);
fprintf(p, "X-Asterisk-VM-Caller-ID-Name: %s" ENDL, cidname);
fprintf(p, "X-Asterisk-VM-Duration: %d" ENDL, duration);
- if (!ast_strlen_zero(category))
+ if (!ast_strlen_zero(category))
fprintf(p, "X-Asterisk-VM-Category: %s" ENDL, category);
+ fprintf(p, "X-Asterisk-VM-Message-Type: %s\n", msgnum > -1 ? "Message" : greeting_attachment);
fprintf(p, "X-Asterisk-VM-Orig-date: %s" ENDL, date);
fprintf(p, "X-Asterisk-VM-Orig-time: %ld" ENDL, (long)time(NULL));
}
@@ -2076,12 +2097,15 @@
ast_channel_free(ast);
} else
ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
- } else {
+ } else if (msgnum > -1){
fprintf(p, "Dear %s:" ENDL ENDL "\tJust wanted to let you know you were just left a %s long message (number %d)" ENDL
"in mailbox %s from %s, on %s so you might" ENDL
"want to check it when you get a chance. Thanks!" ENDL ENDL "\t\t\t\t--Asterisk" ENDL ENDL, vmu->fullname,
dur, msgnum + 1, mailbox, (cidname ? cidname : (cidnum ? cidnum : "an unknown caller")), date);
+ } else {
+ fprintf(p, "This message is to let you know that your greeting was changed on %s." ENDL
+ "Please do not delete this message, lest your greeting vanish with it." ENDL ENDL, date);
}
if (attach_user_voicemail) {
/* Eww. We want formats to tell us their own MIME type */
@@ -2102,10 +2126,16 @@
}
}
fprintf(p, "--%s" ENDL, bound);
- fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"" ENDL, ctype, format, msgnum + 1, format);
+ if (msgnum > -1)
+ fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"" ENDL, ctype, format, msgnum + 1, format);
+ else
+ fprintf(p, "Content-Type: %s%s; name=\"%s.%s\"" ENDL, ctype, format, greeting_attachment, format);
fprintf(p, "Content-Transfer-Encoding: base64" ENDL);
fprintf(p, "Content-Description: Voicemail sound attachment." ENDL);
- fprintf(p, "Content-Disposition: attachment; filename=\"msg%04d.%s\"" ENDL ENDL, msgnum + 1, format);
+ if (msgnum > -1)
+ fprintf(p, "Content-Disposition: attachment; filename=\"msg%04d.%s\"" ENDL ENDL, msgnum + 1, format);
+ else
+ fprintf(p, "Content-Disposition: attachment; filename=\"%s.%s\"" ENDL ENDL, greeting_attachment, format);
snprintf(fname, sizeof(fname), "%s.%s", attach, format);
base_encode(fname, p);
fprintf(p, ENDL "--%s--" ENDL "." ENDL, bound);
@@ -2253,7 +2283,7 @@
return -1;
}
- RETRIEVE(fn, -1);
+ RETRIEVE(fn, -1, ext, context);
if (ast_fileexists(fn, NULL, NULL) > 0) {
res = ast_stream_and_wait(chan, fn, ecodes);
if (res) {
@@ -2514,8 +2544,11 @@
if (!ast_strlen_zero(vmu->serveremail))
myserveremail = vmu->serveremail;
- make_file(fn, sizeof(fn), dir, msgnum);
-
+ if (msgnum > -1)
+ make_file(fn, sizeof(fn), dir, msgnum);
+ else
+ ast_copy_string (fn, dir, sizeof(fn));
+
if (ast_strlen_zero(vmu->email))
ast_copy_string(vmu->email, vmu->imapuser, sizeof(vmu->email));
@@ -2528,6 +2561,12 @@
if (!(p = vm_mkftemp(tmp))) {
ast_log(LOG_WARNING, "Unable to store '%s' (can't create temporary file)\n", fn);
return -1;
+
+ }
+
+ if (msgnum < 0 && imapgreetings) {
+ init_mailstream(vms, GREETINGS_FOLDER);
+ imap_delete_old_greeting(fn, vms);
}
make_email_file(p, myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), fn, fmt, duration, 1, chan, NULL, 1);
@@ -2541,8 +2580,8 @@
fread(buf, len, 1, p);
((char *)buf)[len] = '\0';
INIT(&str, mail_string, buf, len);
- init_mailstream(vms, 0);
- imap_mailbox_name(mailbox, vms, 0, 1);
+ init_mailstream(vms, NEW_FOLDER);
+ imap_mailbox_name(mailbox, vms, NEW_FOLDER, 1);
if(!mail_append(vms->mailstream, mailbox, &str))
ast_log(LOG_ERROR, "Error while sending the message to %s\n", mailbox);
fclose(p);
@@ -2645,20 +2684,20 @@
ast_debug(3,"Copied %s to %s\n",vmu->imapuser,vms_p->imapuser);
vms_p->updated = 1;
/* set mailbox to INBOX! */
- ast_copy_string(vms_p->curbox, mbox(0), sizeof(vms_p->curbox));
+ ast_copy_string(vms_p->curbox, mbox(NEW_FOLDER), sizeof(vms_p->curbox));
init_vm_state(vms_p);
vmstate_insert(vms_p);
}
/* If no mailstream exists yet and even after attempting to initialize it fails, bail out */
- ret = init_mailstream(vms_p, 0);
+ ret = init_mailstream(vms_p, NEW_FOLDER);
if (!vms_p->mailstream) {
ast_log (LOG_ERROR,"Houston we have a problem - IMAP mailstream is NULL\n");
free_user(vmu);
return -1;
}
- if (!ret && vms_p->updated == 1) {
+ if (!ret && vms_p->updated > 0) {
if (newmsgs) {
pgm = mail_newsearchpgm();
hdr = mail_newsearchheader("X-Asterisk-VM-Extension", (char *)mailboxnc);
@@ -2689,10 +2728,8 @@
}
}
- if (vms_p->updated == 1) { /* changes, so we did the searches above */
+ if (vms_p->updated > 1) { /* changes, so we did the searches above */
vms_p->updated = 0;
- } else if (vms_p->updated > 1) { /* decrement delay count */
- vms_p->updated--;
} else { /* no changes, so don't search */
mail_ping(vms_p->mailstream);
/* Keep the old data */
@@ -2998,7 +3035,7 @@
ast_log(LOG_WARNING, "Failed to make directory (%s)\n", tempfile);
return -1;
}
- RETRIEVE(tempfile, -1);
+ RETRIEVE(tempfile, -1, ext, context);
if (ast_fileexists(tempfile, NULL, NULL) > 0)
ast_copy_string(prefile, tempfile, sizeof(prefile));
DISPOSE(tempfile, -1);
@@ -3035,7 +3072,7 @@
/* Play the beginning intro if desired */
if (!ast_strlen_zero(prefile)) {
- RETRIEVE(prefile, -1);
+ RETRIEVE(prefile, -1, ext, context);
if (ast_fileexists(prefile, NULL, NULL) > 0) {
if (ast_streamfile(chan, prefile, chan->language) > -1)
res = ast_waitstream(chan, ecodes);
@@ -3112,19 +3149,13 @@
#ifdef IMAP_STORAGE
/* Is ext a mailbox? */
/* must open stream for this user to get info! */
- vms = get_vm_state_by_mailbox(ext,0);
- if (vms) {
- ast_debug(3, "Using vm_state, interactive set to %d.\n",vms->interactive);
- newmsgs = vms->newmessages++;
- oldmsgs = vms->oldmessages;
- } else {
- res = inboxcount(ext_context, &newmsgs, &oldmsgs);
- if(res < 0) {
- ast_log(LOG_NOTICE,"Can not leave voicemail, unable to count messages\n");
- return -1;
- }
- vms = get_vm_state_by_mailbox(ext,0);
- }
+ res = inboxcount(ext_context, &newmsgs, &oldmsgs);
+ if(res < 0) {
+ ast_log(LOG_NOTICE,"Can not leave voicemail, unable to count messages\n");
+ return -1;
+ }
+ if((vms = get_vm_state_by_mailbox(ext,0)))
+ vms->newmessages++; /*still need to increment new message count*/
/* here is a big difference! We add one to it later */
msgnum = newmsgs + oldmsgs;
ast_debug(3, "Messagecount set to %d\n",msgnum);
@@ -3139,7 +3170,6 @@
return -1;
}
/* here is a big difference! We add one to it later */
- msgnum = newmsgs + oldmsgs;
ast_debug(3, "Messagecount set to %d\n",msgnum);
#else
@@ -3241,7 +3271,9 @@
ast_destroy_realtime("voicemail_data", "id", tmpid, NULL);
}
} else {
+#ifndef IMAP_STORAGE
msgnum = last_message_index(vmu, dir) + 1;
+#endif
make_file(fn, sizeof(fn), dir, msgnum);
/* assign a variable with the name of the voicemail file */
@@ -4236,7 +4268,7 @@
char buf[1024] = "";
int attach_user_voicemail = ast_test_flag((&globalflags), VM_ATTACH);
#endif
- RETRIEVE(dir, curmsg);
+ RETRIEVE(dir, curmsg, sender->mailbox, context);
cmd = vm_forwardoptions(chan, sender, dir, curmsg, vmfmts, S_OR(context, "default"), record_gain, &duration, vms);
if (!cmd) {
AST_LIST_TRAVERSE_SAFE_BEGIN(&extensions, vmtmp, list) {
@@ -4578,6 +4610,7 @@
return -1;
}
+
/* Find the format of the attached file */
strsep(&attachedfilefmt, ".");
@@ -4714,7 +4747,7 @@
/* Retrieve info from VM attribute file */
make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg);
snprintf(filename, sizeof(filename), "%s.txt", vms->fn2);
- RETRIEVE(vms->curdir, vms->curmsg);
+ RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
msg_cfg = ast_config_load(filename);
if (!msg_cfg) {
ast_log(LOG_WARNING, "No message attribute file?!! (%s)\n", filename);
@@ -4764,9 +4797,9 @@
char tmp[256], *t = tmp;
size_t left = sizeof(tmp);
- if (box == 1) {
- ast_copy_string(vms->curbox, mbox(0), sizeof(vms->curbox));
- sprintf(vms->vmbox, "vm-%s", mbox(1));
+ if (box == OLD_FOLDER) {
+ ast_copy_string(vms->curbox, mbox(NEW_FOLDER), sizeof(vms->curbox));
+ sprintf(vms->vmbox, "vm-%s", mbox(OLD_FOLDER));
} else {
ast_copy_string(vms->curbox, mbox(box), sizeof(vms->curbox));
snprintf(vms->vmbox, sizeof(vms->vmbox), "vm-%s", vms->curbox);
@@ -4786,8 +4819,10 @@
/* End with username */
ast_build_string(&t, &left, "/user=%s}", vms->imapuser);
- if(box == 0 || box == 1)
+ if(box == NEW_FOLDER || box == OLD_FOLDER)
sprintf(spec, "%s%s", tmp, use_folder? imapfolder: "INBOX");
+ else if (box == GREETINGS_FOLDER)
+ sprintf(spec, "%s%s", tmp, greetingfolder);
else
sprintf(spec, "%s%s%c%s", tmp, imapfolder, delimiter, mbox(box));
}
@@ -4819,7 +4854,7 @@
#include "linkage.c"
#endif
/* Connect to INBOX first to get folders delimiter */
- imap_mailbox_name(tmp, vms, 0, 0);
+ imap_mailbox_name(tmp, vms, NEW_FOLDER, 0);
stream = mail_open(stream, tmp, debug ? OP_DEBUG : NIL);
if (stream == NIL) {
ast_log (LOG_ERROR, "Can't connect to imap server %s\n", tmp);
@@ -4871,11 +4906,11 @@
pgm->deleted = 0;
pgm->undeleted = 1;
- /* if box = 0, check for new, if box = 1, check for read */
- if (box == 0) {
+ /* if box = NEW_FOLDER, check for new, if box = OLD_FOLDER, check for read */
+ if (box == NEW_FOLDER) {
pgm->unseen = 1;
pgm->seen = 0;
- } else if (box == 1) {
+ } else if (box == OLD_FOLDER) {
pgm->seen = 1;
pgm->unseen = 0;
}
@@ -4887,6 +4922,141 @@
vms->lastmsg = vms->vmArrayIndex - 1;
mail_free_searchpgm(&pgm);
+ return 0;
+}
+
+static int imap_remove_file(char *dir, int msgnum)
+{
+ char fn[PATH_MAX];
+ char full_fn[PATH_MAX];
+ char msgnums[80];
+
+ if (msgnum > -1) {
+ snprintf(msgnums, sizeof(msgnums), "%d", msgnum);
+ make_file(fn, sizeof(fn), dir, msgnum);
+ } else
+ ast_copy_string(fn, dir, sizeof(fn));
+
+ if ((msgnum < 0 && imapgreetings) || msgnum > -1) {
+ ast_filedelete(fn, NULL);
+ snprintf(full_fn, sizeof(full_fn), "%s.txt", fn);
+ unlink(full_fn);
+ }
+ return 0;
+}
+
+static int imap_retrieve_file (char *dir, int msgnum, char *mailbox, char *context)
+{
+ struct ast_vm_user *vmu;
+ struct vm_state *vms_p;
+ char *file, *filename;
+ char *attachment;
+ /*char *mb, *cur;*/
+ int ret = 0, i;
+ BODY *body;
+
+ /* This function is only used for retrieval of IMAP greetings
+ * regular messages are not retrieved this way, nor are greetings
+ * if they are stored locally*/
+ if (msgnum > -1 || !imapgreetings) {
+ return 0;
+ } else {
+ file = strrchr(ast_strdupa(dir), '/');
+ if (file)
+ *file++ = '\0';
+ else {
+ ast_debug (1, "Failed to procure file name from directory passed.\n");
+ return -1;
+ }
+ }
+ /* We have to get the user before we can open the stream! */
+ /* ast_log (LOG_DEBUG,"Before find_user, context is %s and mailbox is %s\n",context,mailbox); */
+ vmu = find_user(NULL, context, mailbox);
+ if (!vmu) {
+ ast_log (LOG_ERROR,"Couldn't find mailbox %s in context %s\n",mailbox,context);
+ return -1;
+ } else {
+ /* No IMAP account available */
+ if (vmu->imapuser[0] == '\0') {
+ ast_log (LOG_WARNING,"IMAP user not set for mailbox %s\n",vmu->mailbox);
+ free_user(vmu);
+ return -1;
+ }
+ }
+
+ /* check if someone is accessing this box right now... */
+ vms_p = get_vm_state_by_mailbox(mailbox,0);
+ if (!vms_p) {
+ ast_log(LOG_ERROR, "Voicemail state not found!\n");
+ return -1;
+ }
+
+ ret = init_mailstream(vms_p, GREETINGS_FOLDER);
+ if (!vms_p->mailstream) {
+ ast_log (LOG_ERROR,"IMAP mailstream is NULL\n");
+ free_user(vmu);
+ return -1;
+ }
+
+ for (i = 0; i < vms_p->mailstream->nmsgs; i++)
+ {
+ mail_fetchstructure(vms_p->mailstream, i + 1, &body);
+ /* We have the body, now we extract the file name of the first attachment. */
+ if (body->nested.part->next && body->nested.part->next->body.parameter->value) {
+ attachment = ast_strdupa(body->nested.part->next->body.parameter->value);
+ } else {
+ ast_log(LOG_ERROR, "There is no file attached to this IMAP message.\n");
+ return -1;
+ }
+ filename = strsep(&attachment, ".");
+ if (!strcmp(filename, file))
+ {
+ ast_copy_string(vms_p->fn, dir, sizeof(vms_p->fn));
+ vms_p->msgArray[vms_p->curmsg] = i + 1;
+ save_body(body, vms_p, "2", attachment);
+ free_user(vmu);
+ return 0;
+ }
+ }
+
+ free_user(vmu);
+ return -1;
+}
+
+static int imap_delete_old_greeting (char *dir, struct vm_state *vms)
+{
+ char *file, *filename;
+ char *attachment;
+ char arg[10];
+ int i;
+ BODY* body;
+
+
+ file = strrchr(ast_strdupa(dir), '/');
+ if (file)
+ *file++ = '\0';
+ else {
+ ast_log (LOG_ERROR, "Failed to procure file name from directory passed. You should never see this.\n");
+ return -1;
+ }
+
+ for (i = 0; i < vms->mailstream->nmsgs; i++) {
+ mail_fetchstructure(vms->mailstream, i + 1, &body);
+ /* We have the body, now we extract the file name of the first attachment. */
+ if (body->nested.part->next && body->nested.part->next->body.parameter->value) {
+ attachment = ast_strdupa(body->nested.part->next->body.parameter->value);
+ } else {
+ ast_log(LOG_ERROR, "There is no file attached to this IMAP message.\n");
+ return -1;
+ }
+ filename = strsep(&attachment, ".");
+ if (!strcmp(filename, file))
+ {
+ sprintf (arg,"%d", i+1);
+ mail_setflag (vms->mailstream,arg,"\\DELETED");
+ }
+ }
+ mail_expunge(vms->mailstream);
return 0;
}
@@ -6203,7 +6373,7 @@
while((cmd >= 0) && (cmd != 't')) {
if (cmd)
retries = 0;
- RETRIEVE(prefile, -1);
+ RETRIEVE(prefile, -1, vmu->mailbox, vmu->context);
if (ast_fileexists(prefile, NULL, NULL) <= 0) {
#ifndef IMAP_STORAGE
play_record_review(chan, "vm-rec-temp", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, NULL);
@@ -6624,7 +6794,7 @@
#ifdef IMAP_STORAGE
vms.interactive = 1;
- vms.updated = 2;
+ vms.updated = 1;
vmstate_insert(&vms);
init_vm_state(&vms);
#endif
@@ -6646,13 +6816,13 @@
#endif
/* Retrieve old and new message counts */
ast_debug(1, "Before open_mailbox\n");
- res = open_mailbox(&vms, vmu, 1);
+ res = open_mailbox(&vms, vmu, OLD_FOLDER);
if (res == ERROR_LOCK_PATH)
goto out;
vms.oldmessages = vms.lastmsg + 1;
ast_debug(1, "Number of old messages: %d\n",vms.oldmessages);
/* Start in INBOX */
- res = open_mailbox(&vms, vmu, 0);
+ res = open_mailbox(&vms, vmu, NEW_FOLDER);
if (res == ERROR_LOCK_PATH)
goto out;
vms.newmessages = vms.lastmsg + 1;
@@ -6673,7 +6843,8 @@
} else {
if (!vms.newmessages && vms.oldmessages) {
/* If we only have old messages start here */
- res = open_mailbox(&vms, vmu, 1);
+ res = open_mailbox(&vms, vmu, OLD_FOLDER);
+ play_folder = 1;
if (res == ERROR_LOCK_PATH)
goto out;
}
@@ -6737,6 +6908,7 @@
res = open_mailbox(&vms, vmu, cmd);
if (res == ERROR_LOCK_PATH)
goto out;
+ play_folder = cmd;
cmd = 0;
}
if (useadsi)
@@ -6873,10 +7045,20 @@
vms.deleted[vms.curmsg] = !vms.deleted[vms.curmsg];
if (useadsi)
adsi_delete(chan, &vms);
- if (vms.deleted[vms.curmsg])
+ if (vms.deleted[vms.curmsg]) {
+ if (play_folder == 0)
+ vms.newmessages--;
+ else if (play_folder == 1)
+ vms.oldmessages--;
cmd = ast_play_and_wait(chan, "vm-deleted");
- else
+ }
+ else {
+ if (play_folder == 0)
+ vms.newmessages++;
+ else if (play_folder == 1)
+ vms.oldmessages++;
cmd = ast_play_and_wait(chan, "vm-undeleted");
+ }
if (ast_test_flag((&globalflags), VM_SKIPAFTERCMD)) {
if (vms.curmsg < vms.lastmsg) {
vms.curmsg++;
@@ -6903,6 +7085,11 @@
cmd = ast_play_and_wait(chan, "vm-nomore");
break;
case '9':
+ if (vms.curmsg < 0 || vms.curmsg > vms.lastmsg) {
+ /* No message selected */
+ cmd = 0;
+ break;
+ }
if (useadsi)
adsi_folders(chan, 1, "Save to folder...");
cmd = get_folder2(chan, "vm-savefolder", 1);
@@ -7797,6 +7984,17 @@
} else {
ast_copy_string(imapfolder,"INBOX", sizeof(imapfolder));
}
+ if ((val = ast_variable_retrieve(cfg, "general", "imapgreetings"))) {
+ imapgreetings = ast_true(val);
+ } else {
+ imapgreetings = 0;
+ }
+ if ((val = ast_variable_retrieve(cfg, "general", "greetingfolder"))) {
+ ast_copy_string(greetingfolder, val, sizeof(greetingfolder));
+ } else {
+ ast_copy_string(greetingfolder, imapfolder, sizeof(greetingfolder));
+ }
+
#endif
/* External voicemail notify application */
if ((val = ast_variable_retrieve(cfg, "general", "externnotify"))) {
@@ -8387,7 +8585,7 @@
make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg);
snprintf(filename,sizeof(filename), "%s.txt", vms->fn2);
- RETRIEVE(vms->curdir, vms->curmsg);
+ RETRIEVE(vms->curdir, vms->curms, vmu->mailbox, vmu->context);
msg_cfg = ast_config_load(filename);
DISPOSE(vms->curdir, vms->curmsg);
if (!msg_cfg) {
@@ -8649,8 +8847,8 @@
/* User has hung up, no options to give */
if (!outsidecaller) {
/* user was recording a greeting and they hung up, so let's delete the recording. */
- vm_delete(tempfile);
- }
+ ast_filedelete(tempfile, NULL);
+ }
return cmd;
}
if (cmd == '0') {
@@ -8664,14 +8862,14 @@
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Message too short\n");
cmd = ast_play_and_wait(chan, "vm-tooshort");
- cmd = vm_delete(tempfile);
+ cmd = ast_filedelete(tempfile, NULL);
break;
}
else if (vmu->review && (cmd == 2 && *duration < (maxsilence + 3))) {
/* Message is all silence */
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Nothing recorded\n");
- cmd = vm_delete(tempfile);
+ cmd = ast_filedelete(tempfile, NULL);
cmd = ast_play_and_wait(chan, "vm-nothingrecorded");
if (!cmd)
cmd = ast_play_and_wait(chan, "vm-speakup");
@@ -8700,7 +8898,7 @@
case '*':
/* Cancel recording, delete message, offer to take another message*/
cmd = ast_play_and_wait(chan, "vm-deleted");
- cmd = vm_delete(tempfile);
+ cmd = ast_filedelete(tempfile, NULL);
if (outsidecaller) {
res = vm_exec(chan, NULL);
return res;
@@ -9213,10 +9411,10 @@
if (ast_strlen_zero(mailbox))
return NULL;
- if (!(start = strstr(mailbox, "user=")))
+ if (!(start = strstr(mailbox, "/user=")))
return NULL;
- ast_copy_string(buf, start+5, len);
+ ast_copy_string(buf, start+6, len);
if (!(quote = strchr(buf, '\"'))) {
if (!(eol_pnt = strchr(buf, '/')))
@@ -9342,7 +9540,7 @@
ast_debug(3, "Duplicate mailbox %s, copying message info...\n", vms->username);
altvms->newmessages = vms->newmessages;
altvms->oldmessages = vms->oldmessages;
- altvms->updated = 2;
+ altvms->updated = 1;
}
ast_debug(3, "Removing vm_state for user:%s, mailbox %s\n", vms->imapuser, vms->username);
@@ -9377,7 +9575,7 @@
ast_debug(3, "User %s mailbox set for update.\n", user);
- vms->updated = 2; /* Set updated flag since mailbox changed */
+ vms->updated = 1; /* Set updated flag since mailbox changed */
}
static void init_vm_state(struct vm_state *vms)
Modified: team/russell/chan_console/channels/chan_gtalk.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/channels/chan_gtalk.c?view=diff&rev=72246&r1=72245&r2=72246
==============================================================================
--- team/russell/chan_console/channels/chan_gtalk.c (original)
+++ team/russell/chan_console/channels/chan_gtalk.c Wed Jun 27 15:09:57 2007
@@ -969,15 +969,14 @@
/* Don't use ast_set_callerid() here because it will
* generate a needless NewCallerID event */
if (!strcasecmp(client->name, "guest")) {
- if (strchr(i->them, '/')) {
- char *aux;
- data = ast_strdupa((char *)i->them);
- aux = data;
- cid = strsep(&aux, "/");
+ data = ast_strdupa(i->them);
+ if (strchr(data, '/')) {
+ cid = strsep(&data, "/");
} else
- cid = i->them;
+ cid = data;
} else {
- cid = client->user;
+ data = ast_strdupa(client->user);
+ cid = data;
}
cid = strsep(&cid, "@");
tmp->cid.cid_num = ast_strdup(cid);
Modified: team/russell/chan_console/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/channels/chan_sip.c?view=diff&rev=72246&r1=72245&r2=72246
==============================================================================
--- team/russell/chan_console/channels/chan_sip.c (original)
+++ team/russell/chan_console/channels/chan_sip.c Wed Jun 27 15:09:57 2007
@@ -15001,9 +15001,9 @@
static int acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen)
{
- struct ast_rtp_quality qos;
struct sip_pvt *p = chan->tech_pvt;
char *all = "", *parse = ast_strdupa(preparse);
+ int res = 0;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(param);
AST_APP_ARG(type);
@@ -15017,51 +15017,68 @@
return 0;
}
- if (ast_strlen_zero(args.param) || strcasecmp(args.param, "rtpqos"))
- return -1;
-
- /* Default arguments of audio,all */
- if (ast_strlen_zero(args.type))
- args.type = "audio";
- if (ast_strlen_zero(args.field))
- args.field = "all";
-
memset(buf, 0, buflen);
- memset(&qos, 0, sizeof(qos));
-
- if (strcasecmp(args.type, "AUDIO") == 0) {
- all = ast_rtp_get_quality(p->rtp, &qos);
- } else if (strcasecmp(args.type, "VIDEO") == 0) {
- all = ast_rtp_get_quality(p->vrtp, &qos);
- } else if (strcasecmp(args.type, "TEXT") == 0) {
- all = ast_rtp_get_quality(p->trtp, &qos);
- }
-
- if (strcasecmp(args.field, "local_ssrc") == 0)
- snprintf(buf, buflen, "%u", qos.local_ssrc);
- else if (strcasecmp(args.field, "local_lostpackets") == 0)
- snprintf(buf, buflen, "%u", qos.local_lostpackets);
- else if (strcasecmp(args.field, "local_jitter") == 0)
- snprintf(buf, buflen, "%.0lf", qos.local_jitter * 1000.0);
- else if (strcasecmp(args.field, "local_count") == 0)
- snprintf(buf, buflen, "%u", qos.local_count);
- else if (strcasecmp(args.field, "remote_ssrc") == 0)
- snprintf(buf, buflen, "%u", qos.remote_ssrc);
- else if (strcasecmp(args.field, "remote_lostpackets") == 0)
- snprintf(buf, buflen, "%u", qos.remote_lostpackets);
- else if (strcasecmp(args.field, "remote_jitter") == 0)
- snprintf(buf, buflen, "%.0lf", qos.remote_jitter * 1000.0);
- else if (strcasecmp(args.field, "remote_count") == 0)
- snprintf(buf, buflen, "%u", qos.remote_count);
- else if (strcasecmp(args.field, "rtt") == 0)
- snprintf(buf, buflen, "%.0lf", qos.rtt * 1000.0);
- else if (strcasecmp(args.field, "all") == 0)
- ast_copy_string(buf, all, buflen);
- else {
- ast_log(LOG_WARNING, "Unrecognized argument '%s' to %s\n", preparse, funcname);
- return -1;
- }
- return 0;
+
+ if (!strcasecmp(args.param, "rtpdest")) {
+ struct sockaddr_in sin;
+
+ if (ast_strlen_zero(args.type))
+ args.type = "audio";
+
+ if (!strcasecmp(args.type, "audio"))
+ ast_rtp_get_peer(p->rtp, &sin);
+ else if (!strcasecmp(args.type, "video"))
+ ast_rtp_get_peer(p->vrtp, &sin);
+ else if (!strcasecmp(args.type, "text"))
+ ast_rtp_get_peer(p->trtp, &sin);
+
+ snprintf(buf, buflen, "%s:%d", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
+ } else if (!strcasecmp(args.param, "rtpqos")) {
+ struct ast_rtp_quality qos;
+
+ memset(&qos, 0, sizeof(qos));
+
+ if (ast_strlen_zero(args.type))
+ args.type = "audio";
+ if (ast_strlen_zero(args.field))
+ args.field = "all";
+
+ if (strcasecmp(args.type, "AUDIO") == 0) {
+ all = ast_rtp_get_quality(p->rtp, &qos);
+ } else if (strcasecmp(args.type, "VIDEO") == 0) {
+ all = ast_rtp_get_quality(p->vrtp, &qos);
+ } else if (strcasecmp(args.type, "TEXT") == 0) {
+ all = ast_rtp_get_quality(p->trtp, &qos);
+ }
+
+ if (strcasecmp(args.field, "local_ssrc") == 0)
+ snprintf(buf, buflen, "%u", qos.local_ssrc);
+ else if (strcasecmp(args.field, "local_lostpackets") == 0)
+ snprintf(buf, buflen, "%u", qos.local_lostpackets);
+ else if (strcasecmp(args.field, "local_jitter") == 0)
+ snprintf(buf, buflen, "%.0lf", qos.local_jitter * 1000.0);
+ else if (strcasecmp(args.field, "local_count") == 0)
+ snprintf(buf, buflen, "%u", qos.local_count);
+ else if (strcasecmp(args.field, "remote_ssrc") == 0)
+ snprintf(buf, buflen, "%u", qos.remote_ssrc);
[... 629 lines stripped ...]
More information about the asterisk-commits
mailing list