[Asterisk-Users] Re: 'a' and 'o' extensions do not work with app_voicemail.c (was: Newbie needs help)

Chad Scott chad at idworld.net
Mon Jun 28 11:09:07 MST 2004


I've been doing some debugging on this and I think it's a code problem.

I'm by no means an expert on Asterisk or how it is written or 
implemented, but the following patch to app_voicemail.c fixes the 
issue.  With this code change, Asterisk correctly transfers to the 'a'  
and 'o' extensions as I'd expect them to.

As I said, I'm not an expert, so I would strongly recommend against 
committing this as-is... someone please interpret why this works and 
fix the root problem (or help me understand why this works so I can fix 
the root problem).

Index: app_voicemail.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_voicemail.c,v
retrieving revision 1.119
diff -C3 -r1.119 app_voicemail.c
*** app_voicemail.c     26 Jun 2004 16:06:19 -0000      1.119
--- app_voicemail.c     28 Jun 2004 17:58:17 -0000
***************
*** 1727,1735 ****
                 make_dir(dir, sizeof(dir), vmu->context, ext, "INBOX");
                 if (mkdir(dir, 0700) && (errno != EEXIST))
                         ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", 
dir, strerror(errno));
!               if (ast_exists_extension(chan, 
strlen(chan->macrocontext) ? chan->macrocontext : chan->context, "o", 
1, chan->callerid))
                         strcat(ecodes, "0");
!               if (ast_exists_extension(chan, 
strlen(chan->macrocontext) ? chan->macrocontext : chan->context, "a", 
1, chan->callerid))
                         strcat(ecodes, "*");
                 /* Play the beginning intro if desired */
                 if (!ast_strlen_zero(prefile)) {
--- 1727,1735 ----
                 make_dir(dir, sizeof(dir), vmu->context, ext, "INBOX");
                 if (mkdir(dir, 0700) && (errno != EEXIST))
                         ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", 
dir, strerror(errno));
!               if (ast_exists_extension(chan, chan->context, "o", 1, 
chan->callerid))
                         strcat(ecodes, "0");
!               if (ast_exists_extension(chan, chan->context, "a", 1, 
chan->callerid))
                         strcat(ecodes, "*");
                 /* Play the beginning intro if desired */
                 if (!ast_strlen_zero(prefile)) {
***************
*** 1768,1775 ****
                         strncpy(chan->exten, "a", sizeof(chan->exten) - 
1);
                         if (!ast_strlen_zero(vmu->exit)) {
                                 strncpy(chan->context, vmu->exit, 
sizeof(chan->context) - 1);
-                       } else if 
(!ast_strlen_zero(chan->macrocontext)) {
-                               strncpy(chan->context, 
chan->macrocontext, sizeof(chan->context) - 1);
                         }
                         chan->priority = 0;
                         free_user(vmu);
--- 1768,1773 ----

On Jun 26, 2004, at 8:52 PM, Chad Scott wrote:

> I've been banging my head on a brick wall for about an hour now trying 
> to understand why the following doesn't work (which is even provided 
> as an example in the distribution!).
>
> The goal is to create a voicemail-only extension not associated with a 
> phone.  I'd rather not have an extension dedicated to VoicemailMain(), 
> so I would like the user to be able to hit '*' during the introductory 
> message and be prompted for a password.
>
> For whatever reason, this doesn't work as expected.  The first 
> section, macro-stdexten, is what is provided in the distribution.  It 
> defines exten => a,1,VoicemailMain(${ARG1}), which should match the 
> return extension from Voicemail() if the user presses '*'.  Neither 
> this nor my "vmonly" macro do this properly.  The '*' key instead does 
> nothing.
>
> Am I not understanding macros properly?
>
> Thanks,
> Chad
>
> [macro-stdexten];
> ;
> ; Standard extension macro:
> ;   ${ARG1} - Extension  (we could have used ${MACRO_EXTEN} here as 
> well
> ;   ${ARG2} - Device(s) to ring
> ;
> exten => s,1,Dial(${ARG2},20)                                   ; Ring 
> the interface, 20 seconds maximum
> exten => s,2,Goto(s-${DIALSTATUS})                              ; Jump 
> based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
>
> exten => s-NOANSWER,1,Voicemail(u${ARG1})               ; If 
> unavailable, send to voicemail w/ unavail announce
> exten => s-NOANSWER,2,Goto(default,s,1)                 ; If they 
> press #, return to start
>
> exten => s-BUSY,1,Voicemail(b${ARG1})                   ; If busy, 
> send to voicemail w/ busy announce
> exten => s-BUSY,2,Goto(default,s,1)                             ; If 
> they press #, return to start
>
> exten => s-.,1,Goto(s-NOANSWER,1)                               ; 
> Treat anything else as no answer
>
> exten => a,1,VoicemailMain(${ARG1})                             ; If 
> they press *, send the user into VoicemailMain
>
> [macro-vmonly]
> exten => s,1,Voicemail(${ARG1})
> exten => s,2,Hangup
>
> exten => a,1,VoicemailMain(${ARG1})
>
> _______________________________________________
> Asterisk-Users mailing list
> Asterisk-Users at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-users
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users




More information about the asterisk-users mailing list