(closes issue #10739)
authorJason Parker <jparker@digium.com>
Tue, 18 Sep 2007 21:07:08 +0000 (21:07 +0000)
committerJason Parker <jparker@digium.com>
Tue, 18 Sep 2007 21:07:08 +0000 (21:07 +0000)
Reported by: ruffle
Patches:
      app_voicemail.c.diff uploaded by ruffle (license 201)
      10739-moveheard.diff uploaded by qwell (license 4)
Tested by: callguy, ruffle

Add an option to disable the automatic moving of "heard" messages to the Old folder.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@82871 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_voicemail.c
configs/voicemail.conf.sample

index 54285c2..934deb9 100644 (file)
@@ -223,6 +223,7 @@ static AST_LIST_HEAD_STATIC(vmstates, vmstate);
 #define VM_ALLOCED       (1 << 13)
 #define VM_SEARCH        (1 << 14)
 #define VM_TEMPGREETWARN (1 << 15)  /*!< Remind user tempgreeting is set */
+#define VM_MOVEHEARD     (1 << 16)  /*!< Move a "heard" message to Old after listening to it */
 #define ERROR_LOCK_PATH  -100
 
 
@@ -716,6 +717,8 @@ static void apply_option(struct ast_vm_user *vmu, const char *var, const char *v
                ast_set2_flag(vmu, ast_true(value), VM_OPERATOR);       
        } else if (!strcasecmp(var, "envelope")){
                ast_set2_flag(vmu, ast_true(value), VM_ENVELOPE);       
+       } else if (!strcasecmp(var, "moveheard")){
+               ast_set2_flag(vmu, ast_true(value), VM_MOVEHEARD);
        } else if (!strcasecmp(var, "sayduration")){
                ast_set2_flag(vmu, ast_true(value), VM_SAYDURATION);    
        } else if (!strcasecmp(var, "saydurationm")){
@@ -5183,7 +5186,7 @@ static int close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu)
                return ERROR_LOCK_PATH;
         
        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] || (vms->heard[x] && !ast_test_flag(vmu, VM_MOVEHEARD)))) { 
                        /* Save this message.  It's not in INBOX or hasn't been heard */ 
                        make_file(vms->fn, sizeof(vms->fn), vms->curdir, x); 
                        if (!EXISTS(vms->curdir, x, vms->fn, NULL)) 
@@ -5193,7 +5196,7 @@ static int close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu)
                        if (strcmp(vms->fn, vms->fn2)) { 
                                RENAME(vms->curdir, x, vmu->mailbox,vmu->context, vms->curdir, vms->curmsg, vms->fn, vms->fn2);
                        } 
-               } else if (!strcasecmp(vms->curbox, "INBOX") && vms->heard[x] && !vms->deleted[x]) { 
+               } else if (!strcasecmp(vms->curbox, "INBOX") && vms->heard[x] && ast_test_flag(vmu, VM_MOVEHEARD) && !vms->deleted[x]) { 
                        /* Move to old folder before deleting */ 
                        res = save_to_folder(vmu, vms, x, 1);
                        if (res == ERROR_LOCK_PATH) {
@@ -8296,6 +8299,12 @@ static int load_config(int reload)
                }
                ast_set2_flag((&globalflags), ast_true(val), VM_ENVELOPE);      
 
+               if (!(val = ast_variable_retrieve(cfg, "general", "moveheard"))) {
+                       ast_debug(1,"Move Heard enabled globally\n");
+                       val = "yes";
+               }
+               ast_set2_flag((&globalflags), ast_true(val), VM_MOVEHEARD);     
+
                if (!(val = ast_variable_retrieve(cfg, "general", "sayduration"))) {
                        ast_debug(1,"Duration info before msg enabled globally\n");
                        val = "yes";
index 945783e..c4dac60 100644 (file)
@@ -51,6 +51,9 @@ silencethreshold=128
 ; Max number of failed login attempts
 maxlogins=3
 ;
+; Move heard messages to the 'Old' folder automagically.  Defaults to on.
+;moveheard=yes
+;
 ; User context is where entries from users.conf are registered.  The
 ; default value is 'default'
 ;
@@ -279,7 +282,7 @@ european=Europe/Copenhagen|'vm-received' a d b 'digits/at' HM
 ;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
 ;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|moveheard=yes|sayduration=yes|saydurationm=1
 ;4073 => 1099,Bianca Paige,bianca@biancapaige.com,,delete=1
 ;4110 => 3443,Rob Flynn,rflynn@blueridge.net
 ;4235 => 1234,Jim Holmes,jim@astricon.ips,,Tz=european