mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-13 00:04:53 +00:00
support a configurable number of mailboxes per folder (bug #4229)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6099 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -14,6 +14,9 @@
|
|||||||
* George Konstantoulakis <gkon@inaccessnetworks.com>
|
* George Konstantoulakis <gkon@inaccessnetworks.com>
|
||||||
* 05-10 - 2005 : Support for Swedish and Norwegian added by Daniel Nylander, http://www.danielnylander.se/
|
* 05-10 - 2005 : Support for Swedish and Norwegian added by Daniel Nylander, http://www.danielnylander.se/
|
||||||
*
|
*
|
||||||
|
* 05-11 - 2005 : An option for maximum number of messsages per mailbox added by GDS Partners (www.gdspartners.com)
|
||||||
|
* Stojan Sljivic <stojan.sljivic@gdspartners.com>
|
||||||
|
*
|
||||||
* 07-11 - 2005 : An issue with voicemail synchronization has been fixed by GDS Partners (www.gdspartners.com)
|
* 07-11 - 2005 : An issue with voicemail synchronization has been fixed by GDS Partners (www.gdspartners.com)
|
||||||
* Stojan Sljivic <stojan.sljivic@gdspartners.com>
|
* Stojan Sljivic <stojan.sljivic@gdspartners.com>
|
||||||
*/
|
*/
|
||||||
@@ -67,6 +70,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#define INTRO "vm-intro"
|
#define INTRO "vm-intro"
|
||||||
|
|
||||||
#define MAXMSG 100
|
#define MAXMSG 100
|
||||||
|
#define MAXMSGLIMIT 9999
|
||||||
|
|
||||||
#define BASEMAXINLINE 256
|
#define BASEMAXINLINE 256
|
||||||
#define BASELINELEN 72
|
#define BASELINELEN 72
|
||||||
@@ -179,6 +183,7 @@ struct ast_vm_user {
|
|||||||
char exit[80];
|
char exit[80];
|
||||||
unsigned int flags; /* VM_ flags */
|
unsigned int flags; /* VM_ flags */
|
||||||
int saydurationm;
|
int saydurationm;
|
||||||
|
int maxmsg; /* Maximum number of msgs per folder for this mailbox */
|
||||||
struct ast_vm_user *next;
|
struct ast_vm_user *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -196,8 +201,8 @@ struct vm_state {
|
|||||||
char vmbox[256];
|
char vmbox[256];
|
||||||
char fn[256];
|
char fn[256];
|
||||||
char fn2[256];
|
char fn2[256];
|
||||||
int deleted[MAXMSG];
|
int *deleted;
|
||||||
int heard[MAXMSG];
|
int *heard;
|
||||||
int curmsg;
|
int curmsg;
|
||||||
int lastmsg;
|
int lastmsg;
|
||||||
int newmessages;
|
int newmessages;
|
||||||
@@ -311,7 +316,9 @@ struct ast_vm_user *users;
|
|||||||
struct ast_vm_user *usersl;
|
struct ast_vm_user *usersl;
|
||||||
struct vm_zone *zones = NULL;
|
struct vm_zone *zones = NULL;
|
||||||
struct vm_zone *zonesl = NULL;
|
struct vm_zone *zonesl = NULL;
|
||||||
|
static struct ast_config *voicemailCfg;
|
||||||
static int maxsilence;
|
static int maxsilence;
|
||||||
|
static int maxmsg;
|
||||||
static int silencethreshold = 128;
|
static int silencethreshold = 128;
|
||||||
static char serveremail[80];
|
static char serveremail[80];
|
||||||
static char mailcmd[160]; /* Configurable mail cmd */
|
static char mailcmd[160]; /* Configurable mail cmd */
|
||||||
@@ -405,6 +412,15 @@ static void apply_option(struct ast_vm_user *vmu, const char *var, const char *v
|
|||||||
ast_copy_string(vmu->dialout, value, sizeof(vmu->dialout));
|
ast_copy_string(vmu->dialout, value, sizeof(vmu->dialout));
|
||||||
} else if (!strcasecmp(var, "exitcontext")) {
|
} else if (!strcasecmp(var, "exitcontext")) {
|
||||||
ast_copy_string(vmu->exit, value, sizeof(vmu->exit));
|
ast_copy_string(vmu->exit, value, sizeof(vmu->exit));
|
||||||
|
} else if (!strcasecmp(var, "maxmsg")) {
|
||||||
|
vmu->maxmsg = atoi(value);
|
||||||
|
if (vmu->maxmsg <= 0) {
|
||||||
|
ast_log(LOG_WARNING, "Invalid number of messages per folder maxmsg=%s. Using default value %i\n", value, MAXMSG);
|
||||||
|
vmu->maxmsg = MAXMSG;
|
||||||
|
} else if (vmu->maxmsg > MAXMSGLIMIT) {
|
||||||
|
ast_log(LOG_WARNING, "Maximum number of messages per folder is %i. Cannot accept value maxmsg=%s\n", MAXMSGLIMIT, value);
|
||||||
|
vmu->maxmsg = MAXMSGLIMIT;
|
||||||
|
}
|
||||||
} else if (!strcasecmp(var, "options")) {
|
} else if (!strcasecmp(var, "options")) {
|
||||||
apply_options(vmu, value);
|
apply_options(vmu, value);
|
||||||
}
|
}
|
||||||
@@ -842,7 +858,7 @@ static int remove_file(char *dir, int msgnum)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int last_message_index(char *dir)
|
static int last_message_index(struct ast_vm_user *vmu, char *dir)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int res;
|
int res;
|
||||||
@@ -964,11 +980,11 @@ yuck:
|
|||||||
/*
|
/*
|
||||||
* A negative return value indicates an error.
|
* A negative return value indicates an error.
|
||||||
*/
|
*/
|
||||||
static int count_messages(char *dir)
|
static int count_messages(struct ast_vm_user *vmu, char *dir)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
res = last_message_index(dir);
|
res = last_message_index(vmu, dir) + 1;
|
||||||
return res >= 0 ? res + 1 : res;
|
return res >= 0 ? res + 1 : res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1235,7 +1251,7 @@ yuck:
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static int count_messages(char *dir)
|
static int count_messages(struct ast_vm_user *vmu, char *dir)
|
||||||
{
|
{
|
||||||
/* Find all .txt files - even if they are not in sequence from 0000 */
|
/* Find all .txt files - even if they are not in sequence from 0000 */
|
||||||
|
|
||||||
@@ -1334,12 +1350,12 @@ static void copy_file(char *frompath, char *topath)
|
|||||||
/*
|
/*
|
||||||
* A negative return value indicates an error.
|
* A negative return value indicates an error.
|
||||||
*/
|
*/
|
||||||
static int last_message_index(char *dir)
|
static int last_message_index(struct ast_vm_user *vmu, char *dir)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
char fn[256];
|
char fn[256];
|
||||||
if (!ast_lock_path(dir)) {
|
if (!ast_lock_path(dir)) {
|
||||||
for (x=0;x<MAXMSG;x++) {
|
for (x = 0; x < vmu->maxmsg; x++) {
|
||||||
make_file(fn, sizeof(fn), dir, x);
|
make_file(fn, sizeof(fn), dir, x);
|
||||||
if (ast_fileexists(fn, NULL, NULL) < 1)
|
if (ast_fileexists(fn, NULL, NULL) < 1)
|
||||||
break;
|
break;
|
||||||
@@ -1988,8 +2004,8 @@ static int copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int i
|
|||||||
if (!EXISTS(todir, recipmsgnum, topath, chan->language))
|
if (!EXISTS(todir, recipmsgnum, topath, chan->language))
|
||||||
break;
|
break;
|
||||||
recipmsgnum++;
|
recipmsgnum++;
|
||||||
} while (recipmsgnum < MAXMSG);
|
} while (recipmsgnum < recip->maxmsg);
|
||||||
if (recipmsgnum < MAXMSG) {
|
if (recipmsgnum < recip->maxmsg) {
|
||||||
COPY(fromdir, msgnum, todir, recipmsgnum, frompath, topath);
|
COPY(fromdir, msgnum, todir, recipmsgnum, frompath, topath);
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_ERROR, "Recipient mailbox %s@%s is full\n", recip->mailbox, recip->context);
|
ast_log(LOG_ERROR, "Recipient mailbox %s@%s is full\n", recip->mailbox, recip->context);
|
||||||
@@ -2198,8 +2214,8 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int
|
|||||||
if (!EXISTS(dir,msgnum,fn,chan->language))
|
if (!EXISTS(dir,msgnum,fn,chan->language))
|
||||||
break;
|
break;
|
||||||
msgnum++;
|
msgnum++;
|
||||||
} while (msgnum < MAXMSG);
|
} while (msgnum < vmu->maxmsg);
|
||||||
if (msgnum < MAXMSG) {
|
if (msgnum < vmu->maxmsg) {
|
||||||
|
|
||||||
/* assign a variable with the name of the voicemail file */
|
/* assign a variable with the name of the voicemail file */
|
||||||
pbx_builtin_setvar_helper(chan, "VM_MESSAGEFILE", fn);
|
pbx_builtin_setvar_helper(chan, "VM_MESSAGEFILE", fn);
|
||||||
@@ -2302,7 +2318,7 @@ leave_vm_out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int resequence_mailbox(char * dir)
|
static int resequence_mailbox(struct ast_vm_user *vmu, char *dir)
|
||||||
{
|
{
|
||||||
/* we know max messages, so stop process when number is hit */
|
/* we know max messages, so stop process when number is hit */
|
||||||
|
|
||||||
@@ -2311,7 +2327,7 @@ static int resequence_mailbox(char * dir)
|
|||||||
char dfn[256];
|
char dfn[256];
|
||||||
|
|
||||||
if (!ast_lock_path(dir)) {
|
if (!ast_lock_path(dir)) {
|
||||||
for (x=0,dest=0;x<MAXMSG;x++) {
|
for (x = 0, dest = 0; x < vmu->maxmsg; x++) {
|
||||||
make_file(sfn, sizeof(sfn), dir, x);
|
make_file(sfn, sizeof(sfn), dir, x);
|
||||||
if (EXISTS(dir, x, sfn, NULL)) {
|
if (EXISTS(dir, x, sfn, NULL)) {
|
||||||
|
|
||||||
@@ -2339,7 +2355,7 @@ static int say_and_wait(struct ast_channel *chan, int num, char *language)
|
|||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int save_to_folder(char *dir, int msg, char *context, char *username, int box)
|
static int save_to_folder(struct ast_vm_user *vmu, char *dir, int msg, char *context, char *username, int box)
|
||||||
{
|
{
|
||||||
char sfn[256];
|
char sfn[256];
|
||||||
char dfn[256];
|
char dfn[256];
|
||||||
@@ -2350,12 +2366,12 @@ static int save_to_folder(char *dir, int msg, char *context, char *username, int
|
|||||||
make_dir(ddir, sizeof(ddir), context, username, dbox);
|
make_dir(ddir, sizeof(ddir), context, username, dbox);
|
||||||
mkdir(ddir, 0700);
|
mkdir(ddir, 0700);
|
||||||
if (!ast_lock_path(ddir)) {
|
if (!ast_lock_path(ddir)) {
|
||||||
for (x=0;x<MAXMSG;x++) {
|
for (x = 0; x < vmu->maxmsg; x++) {
|
||||||
make_file(dfn, sizeof(dfn), ddir, x);
|
make_file(dfn, sizeof(dfn), ddir, x);
|
||||||
if (!EXISTS(ddir, x, dfn, NULL))
|
if (!EXISTS(ddir, x, dfn, NULL))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (x >= MAXMSG) {
|
if (x >= vmu->maxmsg) {
|
||||||
ast_unlock_path(ddir);
|
ast_unlock_path(ddir);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -3139,7 +3155,7 @@ static int forward_message(struct ast_channel *chan, char *context, char *dir, i
|
|||||||
ast_log(LOG_DEBUG, "%s", sys);
|
ast_log(LOG_DEBUG, "%s", sys);
|
||||||
ast_safe_system(sys);
|
ast_safe_system(sys);
|
||||||
|
|
||||||
if ( (res = count_messages(todir)) )
|
if ( (res = count_messages(receiver, todir)) )
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
todircount = res;
|
todircount = res;
|
||||||
@@ -3472,7 +3488,7 @@ static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu,int box)
|
|||||||
|
|
||||||
ast_copy_string(vms->curbox, mbox(box), sizeof(vms->curbox));
|
ast_copy_string(vms->curbox, mbox(box), sizeof(vms->curbox));
|
||||||
make_dir(vms->curdir, sizeof(vms->curdir), vmu->context, vms->username, vms->curbox);
|
make_dir(vms->curdir, sizeof(vms->curdir), vmu->context, vms->username, vms->curbox);
|
||||||
count_msg = count_messages(vms->curdir);
|
count_msg = count_messages(vmu, vms->curdir);
|
||||||
if (count_msg < 0)
|
if (count_msg < 0)
|
||||||
return count_msg;
|
return count_msg;
|
||||||
else
|
else
|
||||||
@@ -3485,13 +3501,13 @@ static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu,int box)
|
|||||||
detected.
|
detected.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
last_msg = last_message_index(vms->curdir);
|
last_msg = last_message_index(vmu, vms->curdir);
|
||||||
if (last_msg < 0)
|
if (last_msg < 0)
|
||||||
return last_msg;
|
return last_msg;
|
||||||
else if(vms->lastmsg != last_msg)
|
else if(vms->lastmsg != last_msg)
|
||||||
{
|
{
|
||||||
ast_log(LOG_NOTICE, "Resequencing Mailbox: %s\n", vms->curdir);
|
ast_log(LOG_NOTICE, "Resequencing Mailbox: %s\n", vms->curdir);
|
||||||
res = resequence_mailbox(vms->curdir);
|
res = resequence_mailbox(vmu, vms->curdir);
|
||||||
if (res)
|
if (res)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -3508,7 +3524,7 @@ static int close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu)
|
|||||||
/* Get the deleted messages fixed */
|
/* Get the deleted messages fixed */
|
||||||
if (!ast_lock_path(vms->curdir)) {
|
if (!ast_lock_path(vms->curdir)) {
|
||||||
vms->curmsg = -1;
|
vms->curmsg = -1;
|
||||||
for (x=0;x < MAXMSG;x++) {
|
for (x=0;x < vmu->maxmsg;x++) {
|
||||||
if (!vms->deleted[x] && (strcasecmp(vms->curbox, "INBOX") || !vms->heard[x])) {
|
if (!vms->deleted[x] && (strcasecmp(vms->curbox, "INBOX") || !vms->heard[x])) {
|
||||||
/* Save this message. It's not in INBOX or hasn't been heard */
|
/* Save this message. It's not in INBOX or hasn't been heard */
|
||||||
make_file(vms->fn, sizeof(vms->fn), vms->curdir, x);
|
make_file(vms->fn, sizeof(vms->fn), vms->curdir, x);
|
||||||
@@ -3521,7 +3537,7 @@ static int close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu)
|
|||||||
}
|
}
|
||||||
} else if (!strcasecmp(vms->curbox, "INBOX") && vms->heard[x] && !vms->deleted[x]) {
|
} else if (!strcasecmp(vms->curbox, "INBOX") && vms->heard[x] && !vms->deleted[x]) {
|
||||||
/* Move to old folder before deleting */
|
/* Move to old folder before deleting */
|
||||||
res = save_to_folder(vms->curdir, x, vmu->context, vms->username, 1);
|
res = save_to_folder(vmu, vms->curdir, x, vmu->context, vms->username, 1);
|
||||||
if (res == ERROR_LOCK_PATH) {
|
if (res == ERROR_LOCK_PATH) {
|
||||||
/* If save failed do not delete the message */
|
/* If save failed do not delete the message */
|
||||||
vms->deleted[x] = 0;
|
vms->deleted[x] = 0;
|
||||||
@@ -3530,7 +3546,7 @@ static int close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (x = vms->curmsg + 1; x <= MAXMSG; x++) {
|
for (x = vms->curmsg + 1; x <= vmu->maxmsg; x++) {
|
||||||
make_file(vms->fn, sizeof(vms->fn), vms->curdir, x);
|
make_file(vms->fn, sizeof(vms->fn), vms->curdir, x);
|
||||||
if (!EXISTS(vms->curdir, x, vms->fn, NULL))
|
if (!EXISTS(vms->curdir, x, vms->fn, NULL))
|
||||||
break;
|
break;
|
||||||
@@ -3607,9 +3623,10 @@ static int vm_play_folder_name(struct ast_channel *chan, char *mbox)
|
|||||||
|
|
||||||
static int vm_intro_gr(struct ast_channel *chan, struct vm_state *vms)
|
static int vm_intro_gr(struct ast_channel *chan, struct vm_state *vms)
|
||||||
{
|
{
|
||||||
int res;
|
int res = 0;
|
||||||
|
|
||||||
if (vms->newmessages) {
|
if (vms->newmessages) {
|
||||||
res =ast_play_and_wait(chan, "vm-youhave");
|
res = ast_play_and_wait(chan, "vm-youhave");
|
||||||
if (!res)
|
if (!res)
|
||||||
res = ast_say_number(chan, vms->newmessages, AST_DIGIT_ANY, chan->language, NULL);
|
res = ast_say_number(chan, vms->newmessages, AST_DIGIT_ANY, chan->language, NULL);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
@@ -4766,6 +4783,9 @@ static int vm_execmain(struct ast_channel *chan, void *data)
|
|||||||
adsi_begin(chan, &useadsi);
|
adsi_begin(chan, &useadsi);
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
vms.deleted = calloc(vmu->maxmsg, sizeof(int));
|
||||||
|
vms.heard = calloc(vmu->maxmsg, sizeof(int));
|
||||||
|
|
||||||
/* Set language from config to override channel language */
|
/* Set language from config to override channel language */
|
||||||
if (vmu->language && !ast_strlen_zero(vmu->language))
|
if (vmu->language && !ast_strlen_zero(vmu->language))
|
||||||
ast_copy_string(chan->language, vmu->language, sizeof(chan->language));
|
ast_copy_string(chan->language, vmu->language, sizeof(chan->language));
|
||||||
@@ -5013,25 +5033,29 @@ static int vm_execmain(struct ast_channel *chan, void *data)
|
|||||||
break;
|
break;
|
||||||
} else if (cmd > 0) {
|
} else if (cmd > 0) {
|
||||||
box = cmd = cmd - '0';
|
box = cmd = cmd - '0';
|
||||||
cmd = save_to_folder(vms.curdir, vms.curmsg, vmu->context, vms.username, cmd);
|
cmd = save_to_folder(vmu, vms.curdir, vms.curmsg, vmu->context, vms.username, cmd);
|
||||||
if (cmd == ERROR_LOCK_PATH) {
|
if (cmd == ERROR_LOCK_PATH) {
|
||||||
res = cmd;
|
res = cmd;
|
||||||
goto out;
|
goto out;
|
||||||
|
} else if (!cmd) {
|
||||||
|
vms.deleted[vms.curmsg] = 1;
|
||||||
|
} else {
|
||||||
|
vms.deleted[vms.curmsg] = 0;
|
||||||
|
vms.heard[vms.curmsg] = 0;
|
||||||
}
|
}
|
||||||
vms.deleted[vms.curmsg]=1;
|
|
||||||
}
|
}
|
||||||
make_file(vms.fn, sizeof(vms.fn), vms.curdir, vms.curmsg);
|
make_file(vms.fn, sizeof(vms.fn), vms.curdir, vms.curmsg);
|
||||||
if (useadsi)
|
if (useadsi)
|
||||||
adsi_message(chan, &vms);
|
adsi_message(chan, &vms);
|
||||||
if (!cmd)
|
|
||||||
cmd = ast_play_and_wait(chan, "vm-message");
|
|
||||||
if (!cmd)
|
|
||||||
cmd = say_and_wait(chan, vms.curmsg + 1, chan->language);
|
|
||||||
if (!cmd)
|
|
||||||
cmd = ast_play_and_wait(chan, "vm-savedto");
|
|
||||||
snprintf(vms.fn, sizeof(vms.fn), "vm-%s", mbox(box));
|
snprintf(vms.fn, sizeof(vms.fn), "vm-%s", mbox(box));
|
||||||
if (!cmd)
|
if (!cmd) {
|
||||||
|
cmd = ast_play_and_wait(chan, "vm-message");
|
||||||
|
cmd = say_and_wait(chan, vms.curmsg + 1, chan->language);
|
||||||
|
cmd = ast_play_and_wait(chan, "vm-savedto");
|
||||||
cmd = vm_play_folder_name(chan, vms.fn);
|
cmd = vm_play_folder_name(chan, vms.fn);
|
||||||
|
} else {
|
||||||
|
cmd = ast_play_and_wait(chan, "vm-mailboxfull");
|
||||||
|
}
|
||||||
if (ast_test_flag((&globalflags), VM_SKIPAFTERCMD)) {
|
if (ast_test_flag((&globalflags), VM_SKIPAFTERCMD)) {
|
||||||
if (vms.curmsg < vms.lastmsg) {
|
if (vms.curmsg < vms.lastmsg) {
|
||||||
vms.curmsg++;
|
vms.curmsg++;
|
||||||
@@ -5096,6 +5120,10 @@ out:
|
|||||||
}
|
}
|
||||||
if (vmu)
|
if (vmu)
|
||||||
free_user(vmu);
|
free_user(vmu);
|
||||||
|
if (vms.deleted)
|
||||||
|
free(vms.deleted);
|
||||||
|
if (vms.heard)
|
||||||
|
free(vms.heard);
|
||||||
LOCAL_USER_REMOVE(u);
|
LOCAL_USER_REMOVE(u);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -5177,6 +5205,7 @@ static int append_mailbox(char *context, char *mbox, char *data)
|
|||||||
char tmp[256] = "";
|
char tmp[256] = "";
|
||||||
char *stringp;
|
char *stringp;
|
||||||
char *s;
|
char *s;
|
||||||
|
char *maxmsgstr;
|
||||||
struct ast_vm_user *vmu;
|
struct ast_vm_user *vmu;
|
||||||
|
|
||||||
ast_copy_string(tmp, data, sizeof(tmp));
|
ast_copy_string(tmp, data, sizeof(tmp));
|
||||||
@@ -5197,6 +5226,25 @@ static int append_mailbox(char *context, char *mbox, char *data)
|
|||||||
ast_copy_string(vmu->pager, s, sizeof(vmu->pager));
|
ast_copy_string(vmu->pager, s, sizeof(vmu->pager));
|
||||||
if (stringp && (s = strsep(&stringp, ",")))
|
if (stringp && (s = strsep(&stringp, ",")))
|
||||||
apply_options(vmu, s);
|
apply_options(vmu, s);
|
||||||
|
|
||||||
|
/* Check whether maxmsg was defined on the mailbox level */
|
||||||
|
if (vmu->maxmsg <= 0) {
|
||||||
|
/* Read the maxmsg from the context definition */
|
||||||
|
if ((maxmsgstr = ast_variable_retrieve(voicemailCfg, context, "maxmsg"))) {
|
||||||
|
vmu->maxmsg = atoi(maxmsgstr);
|
||||||
|
if (vmu->maxmsg <= 0) {
|
||||||
|
ast_log(LOG_WARNING, "Invalid number of messages per folder maxmsg=%s. Using default value %i\n", maxmsgstr, MAXMSG);
|
||||||
|
vmu->maxmsg = MAXMSG;
|
||||||
|
} else if (vmu->maxmsg > MAXMSGLIMIT) {
|
||||||
|
ast_log(LOG_WARNING, "Maximum number of messages per folder is %i. Cannot accept value maxmsg=%s\n", MAXMSGLIMIT, maxmsgstr);
|
||||||
|
vmu->maxmsg = MAXMSGLIMIT;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Use the maxmsg from the general section definition */
|
||||||
|
vmu->maxmsg = maxmsg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vmu->next = NULL;
|
vmu->next = NULL;
|
||||||
if (usersl)
|
if (usersl)
|
||||||
usersl->next = vmu;
|
usersl->next = vmu;
|
||||||
@@ -5414,6 +5462,7 @@ static int load_config(void)
|
|||||||
char *astsaydurationinfo;
|
char *astsaydurationinfo;
|
||||||
char *astsaydurationminfo;
|
char *astsaydurationminfo;
|
||||||
char *silencestr;
|
char *silencestr;
|
||||||
|
char *maxmsgstr;
|
||||||
char *astdirfwd;
|
char *astdirfwd;
|
||||||
char *thresholdstr;
|
char *thresholdstr;
|
||||||
char *fmt;
|
char *fmt;
|
||||||
@@ -5429,6 +5478,7 @@ static int load_config(void)
|
|||||||
int tmpadsi[4];
|
int tmpadsi[4];
|
||||||
|
|
||||||
cfg = ast_config_load(VOICEMAIL_CONFIG);
|
cfg = ast_config_load(VOICEMAIL_CONFIG);
|
||||||
|
voicemailCfg = cfg;
|
||||||
ast_mutex_lock(&vmlock);
|
ast_mutex_lock(&vmlock);
|
||||||
cur = users;
|
cur = users;
|
||||||
while (cur) {
|
while (cur) {
|
||||||
@@ -5474,6 +5524,19 @@ static int load_config(void)
|
|||||||
maxsilence *= 1000;
|
maxsilence *= 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(maxmsgstr = ast_variable_retrieve(cfg, "general", "maxmsg"))) {
|
||||||
|
maxmsg = MAXMSG;
|
||||||
|
} else {
|
||||||
|
maxmsg = atoi(maxmsgstr);
|
||||||
|
if (maxmsg <= 0) {
|
||||||
|
ast_log(LOG_WARNING, "Invalid number of messages per folder maxmsg=%s. Using default value %i\n", maxmsgstr, MAXMSG);
|
||||||
|
maxmsg = MAXMSG;
|
||||||
|
} else if (maxmsg > MAXMSGLIMIT) {
|
||||||
|
ast_log(LOG_WARNING, "Maximum number of messages per folder is %i. Cannot accept value maxmsg=%s\n", MAXMSGLIMIT, maxmsgstr);
|
||||||
|
maxmsg = MAXMSGLIMIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Load date format config for voicemail mail */
|
/* Load date format config for voicemail mail */
|
||||||
if ((emaildateformatstr = ast_variable_retrieve(cfg, "general", "emaildateformat"))) {
|
if ((emaildateformatstr = ast_variable_retrieve(cfg, "general", "emaildateformat"))) {
|
||||||
ast_copy_string(emaildateformat, emaildateformatstr, sizeof(emaildateformat));
|
ast_copy_string(emaildateformat, emaildateformatstr, sizeof(emaildateformat));
|
||||||
@@ -5652,7 +5715,6 @@ static int load_config(void)
|
|||||||
if (!(astdirfwd = ast_variable_retrieve(cfg, "general", "usedirectory")))
|
if (!(astdirfwd = ast_variable_retrieve(cfg, "general", "usedirectory")))
|
||||||
astdirfwd = "no";
|
astdirfwd = "no";
|
||||||
ast_set2_flag((&globalflags), ast_true(astdirfwd), VM_DIRECFORWARD);
|
ast_set2_flag((&globalflags), ast_true(astdirfwd), VM_DIRECFORWARD);
|
||||||
|
|
||||||
cat = ast_category_browse(cfg, NULL);
|
cat = ast_category_browse(cfg, NULL);
|
||||||
while (cat) {
|
while (cat) {
|
||||||
if (strcasecmp(cat, "general")) {
|
if (strcasecmp(cat, "general")) {
|
||||||
@@ -5769,7 +5831,6 @@ static int load_config(void)
|
|||||||
tmpread = tmpwrite+len;
|
tmpread = tmpwrite+len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast_config_destroy(cfg);
|
|
||||||
ast_mutex_unlock(&vmlock);
|
ast_mutex_unlock(&vmlock);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -5795,6 +5856,8 @@ int unload_module(void)
|
|||||||
ast_cli_unregister(&show_voicemail_users_cli);
|
ast_cli_unregister(&show_voicemail_users_cli);
|
||||||
ast_cli_unregister(&show_voicemail_zones_cli);
|
ast_cli_unregister(&show_voicemail_zones_cli);
|
||||||
ast_uninstall_vm_functions();
|
ast_uninstall_vm_functions();
|
||||||
|
if (voicemailCfg)
|
||||||
|
ast_config_destroy(voicemailCfg);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,6 +10,9 @@ serveremail=asterisk
|
|||||||
;serveremail=asterisk@linux-support.net
|
;serveremail=asterisk@linux-support.net
|
||||||
; Should the email contain the voicemail as an attachment
|
; Should the email contain the voicemail as an attachment
|
||||||
attach=yes
|
attach=yes
|
||||||
|
; Maximum number of messages per folder. If not specified a default value (100) is used.
|
||||||
|
; Maximum value for this option is 9999.
|
||||||
|
;maxmsg=100
|
||||||
; Maximum length of a voicemail message in seconds
|
; Maximum length of a voicemail message in seconds
|
||||||
;maxmessage=180
|
;maxmessage=180
|
||||||
; Minimum length of a voicemail message in seconds
|
; Minimum length of a voicemail message in seconds
|
||||||
@@ -151,8 +154,11 @@ central24=America/Chicago|'vm-received' q 'digits/at' H N 'hours'
|
|||||||
military=Zulu|'vm-received' q 'digits/at' H N 'hours' 'phonetic/z_p'
|
military=Zulu|'vm-received' q 'digits/at' H N 'hours' 'phonetic/z_p'
|
||||||
|
|
||||||
[default]
|
[default]
|
||||||
|
; Define maximum number of messages per folder for partcular context.
|
||||||
|
;maxmsg=50
|
||||||
|
|
||||||
1234 => 4242,Example Mailbox,root@localhost
|
1234 => 4242,Example Mailbox,root@localhost
|
||||||
;4200 => 9855,Mark Spencer,markster@linux-support.net,mypager@digium.com,attach=no|serveremail=myaddy@digium.com|tz=central
|
;4200 => 9855,Mark Spencer,markster@linux-support.net,mypager@digium.com,attach=no|serveremail=myaddy@digium.com|tz=central|maxmsg=10
|
||||||
;4300 => 3456,Ben Rigas,ben@american-computer.net
|
;4300 => 3456,Ben Rigas,ben@american-computer.net
|
||||||
;4310 => -5432,Sales,sales@marko.net
|
;4310 => -5432,Sales,sales@marko.net
|
||||||
;4069 => 6522,Matt Brooks,matt@marko.net,,|tz=central|attach=yes|saycid=yes|dialout=fromvm|callback=fromvm|review=yes|operator=yes|envelope=yes|sayduration=yes|saydurationm=1
|
;4069 => 6522,Matt Brooks,matt@marko.net,,|tz=central|attach=yes|saycid=yes|dialout=fromvm|callback=fromvm|review=yes|operator=yes|envelope=yes|sayduration=yes|saydurationm=1
|
||||||
|
Reference in New Issue
Block a user