Asterisk:Patch:vmaltext

From My Notepad
Jump to: navigation, search

Asterisk 1.4 VM_ALTEXT patch

This patch instructs the voicemail application to use the number stored in the channel variable VM_ALTEXT as the extension number instead of the actual voicemail extension number configured in voicemail.conf.

This is the function from asterisk 1.4.8:

static int invent_message(struct ast_channel *chan, char *context, char *ext, int busy, char *ecodes)
{
        int res;
        char fn[PATH_MAX];
        char dest[PATH_MAX];
        const char *vmaltext = NULL;

        vmaltext = pbx_builtin_getvar_helper(chan, "VM_ALTEXT");

        snprintf(fn, sizeof(fn), "%s%s/%s/greet", VM_SPOOL_DIR, context, ext);

        if ((res = create_dirpath(dest, sizeof(dest), context, ext, "greet"))) {
                ast_log(LOG_WARNING, "Failed to make directory(%s)\n", fn);
                return -1;
        }

        RETRIEVE(fn, -1);
        if (ast_fileexists(fn, NULL, NULL) > 0) {
                res = ast_stream_and_wait(chan, fn, chan->language, ecodes);
                if (res) {
                        DISPOSE(fn, -1);
                        return res;
                }
        } else {
                /* Dispose just in case */
                DISPOSE(fn, -1);
                res = ast_stream_and_wait(chan, "vm-theperson", chan->language, ecodes);
                if (res)
                        return res;
                if (!ast_strlen_zero(vmaltext))
                        res = ast_say_digit_str(chan, vmaltext, ecodes, chan->language);
                else
                        res = ast_say_digit_str(chan, ext, ecodes, chan->language);
                if (res)
                        return res;
        }
        res = ast_stream_and_wait(chan, busy ? "vm-isonphone" : "vm-isunavail", chan->language, ecodes);
        return res;
}