[Asterisk-cvs] asterisk/apps app_meetme.c, 1.72,
1.73 app_voicemail.c, 1.196, 1.197
markster at lists.digium.com
markster at lists.digium.com
Sun Jan 23 03:02:31 CST 2005
Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv2917/apps
Modified Files:
app_meetme.c app_voicemail.c
Log Message:
Make sure two voicemails can't take the same message space (bug #3394)
Index: app_meetme.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_meetme.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- app_meetme.c 22 Jan 2005 04:51:30 -0000 1.72
+++ app_meetme.c 23 Jan 2005 09:05:01 -0000 1.73
@@ -626,7 +626,7 @@
snprintf(user->namerecloc,sizeof(user->namerecloc),"%s/meetme-username-%s-%d",AST_SPOOL_DIR,conf->confno,user->user_no);
if (!(confflags & CONFFLAG_QUIET) && (confflags & CONFFLAG_INTROUSER))
- ast_record_review(chan,"vm-rec-name",user->namerecloc, 10,"sln", &duration);
+ ast_record_review(chan,"vm-rec-name",user->namerecloc, 10,"sln", &duration, NULL);
while((confflags & CONFFLAG_WAITMARKED) && (conf->markedusers == 0)) {
confflags &= ~CONFFLAG_QUIET;
Index: app_voicemail.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_voicemail.c,v
retrieving revision 1.196
retrieving revision 1.197
diff -u -d -r1.196 -r1.197
--- app_voicemail.c 21 Jan 2005 07:06:24 -0000 1.196
+++ app_voicemail.c 23 Jan 2005 09:05:01 -0000 1.197
@@ -185,7 +185,7 @@
};
static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int msg, int option);
static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num, char *outgoing_context);
-static int play_record_review(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt, int outsidecaller, struct ast_vm_user *vmu, int *duration);
+static int play_record_review(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt, int outsidecaller, struct ast_vm_user *vmu, int *duration, const char *unlockdir);
static int vm_tempgreeting(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc);
static int vm_play_folder_name(struct ast_channel *chan, char *mbox);
@@ -1299,11 +1299,13 @@
{
int x;
char fn[256];
+ ast_lock_path(dir);
for (x=0;x<MAXMSG;x++) {
make_file(fn, sizeof(fn), dir, x);
if (ast_fileexists(fn, NULL, NULL) < 1)
break;
}
+ ast_unlock_path(dir);
return x-1;
}
@@ -1934,6 +1936,7 @@
make_dir(fromdir, sizeof(fromdir), vmu->context, vmu->mailbox, frombox);
make_file(frompath, sizeof(frompath), fromdir, msgnum);
+ ast_lock_path(topath);
recipmsgnum = 0;
do {
make_file(topath, sizeof(topath), todir, recipmsgnum);
@@ -1946,7 +1949,7 @@
} else {
ast_log(LOG_ERROR, "Recipient mailbox %s@%s is full\n", recip->mailbox, recip->context);
}
-
+ ast_unlock_path(topath);
notify_new_message(chan, recip, recipmsgnum, duration, fmt, chan->cid.cid_num, chan->cid.cid_name);
}
@@ -2132,18 +2135,19 @@
strncpy(fmt, vmfmts, sizeof(fmt) - 1);
if (!ast_strlen_zero(fmt)) {
msgnum = 0;
- do {
- make_file(fn, sizeof(fn), dir, msgnum);
- if (!EXISTS(dir,msgnum,fn,chan->language))
- break;
- msgnum++;
- } while (msgnum < MAXMSG);
if (res >= 0) {
/* Unless we're *really* silent, try to send the beep */
res = ast_streamfile(chan, "beep", chan->language);
if (!res)
res = ast_waitstream(chan, "");
}
+ ast_lock_path(dir);
+ do {
+ make_file(fn, sizeof(fn), dir, msgnum);
+ if (!EXISTS(dir,msgnum,fn,chan->language))
+ break;
+ msgnum++;
+ } while (msgnum < MAXMSG);
if (msgnum < MAXMSG) {
/* Store information */
snprintf(txtfile, sizeof(txtfile), "%s.txt", fn);
@@ -2177,7 +2181,7 @@
fclose(txt);
} else
ast_log(LOG_WARNING, "Error opening text file for output\n");
- res = play_record_review(chan, NULL, fn, vmmaxmessage, fmt, 1, vmu, &duration);
+ res = play_record_review(chan, NULL, fn, vmmaxmessage, fmt, 1, vmu, &duration, dir);
if (res == '0')
goto transfer;
if (res > 0)
@@ -2220,6 +2224,7 @@
DISPOSE(dir, msgnum);
}
} else {
+ ast_unlock_path(dir);
res = ast_streamfile(chan, "vm-mailboxfull", chan->language);
if (!res)
res = ast_waitstream(chan, "");
@@ -2248,6 +2253,7 @@
char sfn[256];
char dfn[256];
+ ast_lock_path(dir);
for (x=0,dest=0;x<MAXMSG;x++) {
make_file(sfn, sizeof(sfn), dir, x);
if (EXISTS(dir, x, sfn, NULL)) {
@@ -2260,6 +2266,7 @@
dest++;
}
}
+ ast_unlock_path(dir);
}
@@ -2280,16 +2287,20 @@
make_file(sfn, sizeof(sfn), dir, msg);
make_dir(ddir, sizeof(ddir), context, username, dbox);
mkdir(ddir, 0700);
+ ast_lock_path(ddir);
for (x=0;x<MAXMSG;x++) {
make_file(dfn, sizeof(dfn), ddir, x);
if (!EXISTS(ddir, x, dfn, NULL))
break;
}
- if (x >= MAXMSG)
+ if (x >= MAXMSG) {
+ ast_unlock_path(ddir);
return -1;
+ }
if (strcmp(sfn, dfn)) {
COPY(dir, msg, ddir, x, sfn, dfn);
}
+ ast_unlock_path(ddir);
return 0;
}
@@ -3403,6 +3414,7 @@
int x;
if (vms->lastmsg > -1) {
/* Get the deleted messages fixed */
+ ast_lock_path(vms->curdir);
vms->curmsg = -1;
for (x=0;x < MAXMSG;x++) {
if (!vms->deleted[x] && (strcasecmp(vms->curbox, "INBOX") || !vms->heard[x])) {
@@ -3426,6 +3438,7 @@
break;
DELETE(vms->curdir, x, vms->fn);
}
+ ast_unlock_path(vms->curdir);
}
memset(vms->deleted, 0, sizeof(vms->deleted));
memset(vms->heard, 0, sizeof(vms->heard));
@@ -4067,7 +4080,7 @@
/* If forcename is set, have the user record their name */
if (ast_test_flag(vmu, VM_FORCENAME)) {
snprintf(prefile,sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->context, vms->username);
- cmd = play_record_review(chan,"vm-rec-name",prefile, maxgreet, fmtc, 0, vmu, &duration);
+ cmd = play_record_review(chan,"vm-rec-name",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL);
if (cmd < 0 || cmd == 't' || cmd == '#')
return cmd;
}
@@ -4075,11 +4088,11 @@
/* If forcegreetings is set, have the user record their greetings */
if (ast_test_flag(vmu, VM_FORCEGREET)) {
snprintf(prefile,sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, vms->username);
- cmd = play_record_review(chan,"vm-rec-unv",prefile, maxgreet, fmtc, 0, vmu, &duration);
+ cmd = play_record_review(chan,"vm-rec-unv",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL);
if (cmd < 0 || cmd == 't' || cmd == '#')
return cmd;
snprintf(prefile,sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, vms->username);
- cmd = play_record_review(chan,"vm-rec-busy",prefile, maxgreet, fmtc, 0, vmu, &duration);
+ cmd = play_record_review(chan,"vm-rec-busy",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL);
if (cmd < 0 || cmd == 't' || cmd == '#')
return cmd;
}
@@ -4113,15 +4126,15 @@
switch (cmd) {
case '1':
snprintf(prefile,sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, vms->username);
- cmd = play_record_review(chan,"vm-rec-unv",prefile, maxgreet, fmtc, 0, vmu, &duration);
+ cmd = play_record_review(chan,"vm-rec-unv",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL);
break;
case '2':
snprintf(prefile,sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, vms->username);
- cmd = play_record_review(chan,"vm-rec-busy",prefile, maxgreet, fmtc, 0, vmu, &duration);
+ cmd = play_record_review(chan,"vm-rec-busy",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL);
break;
case '3':
snprintf(prefile,sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->context, vms->username);
- cmd = play_record_review(chan,"vm-rec-name",prefile, maxgreet, fmtc, 0, vmu, &duration);
+ cmd = play_record_review(chan,"vm-rec-name",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL);
break;
case '4':
cmd = vm_tempgreeting(chan, vmu, vms, fmtc);
@@ -4209,7 +4222,7 @@
if (ast_fileexists(prefile, NULL, NULL) > 0) {
switch (cmd) {
case '1':
- cmd = play_record_review(chan,"vm-rec-temp",prefile, maxgreet, fmtc, 0, vmu, &duration);
+ cmd = play_record_review(chan,"vm-rec-temp",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL);
break;
case '2':
ast_filedelete(prefile, NULL);
@@ -4233,7 +4246,7 @@
}
}
} else {
- play_record_review(chan,"vm-rec-temp",prefile, maxgreet, fmtc, 0, vmu, &duration);
+ play_record_review(chan,"vm-rec-temp",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL);
cmd = 't';
}
}
@@ -4908,7 +4921,8 @@
return 0;
}
-static int vm_box_exists(struct ast_channel *chan, void *data) {
+static int vm_box_exists(struct ast_channel *chan, void *data)
+{
struct localuser *u;
struct ast_vm_user svm;
char *context, *box;
@@ -5738,7 +5752,7 @@
-static int play_record_review(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt, int outsidecaller, struct ast_vm_user *vmu, int *duration)
+static int play_record_review(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt, int outsidecaller, struct ast_vm_user *vmu, int *duration, const char *unlockdir)
{
/* Record message & let caller review or re-record it, or set options if applicable */
int res = 0;
@@ -5793,7 +5807,7 @@
}
recorded = 1;
/* After an attempt has been made to record message, we have to take care of INTRO and beep for incoming messages, but not for greetings */
- cmd = ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, silencethreshold, maxsilence);
+ cmd = ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, silencethreshold, maxsilence, unlockdir);
if (cmd == -1) {
/* User has hung up, no options to give */
return cmd;
More information about the svn-commits
mailing list