Index: channels/chan_zap.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v retrieving revision 1.400 diff -u -r1.400 chan_zap.c --- channels/chan_zap.c 17 Jan 2005 12:37:55 -0000 1.400 +++ channels/chan_zap.c 17 Jan 2005 23:35:22 -0000 @@ -90,6 +90,12 @@ */ /* #define ZAP_CHECK_HOOKSTATE */ +/* + * Define if you want to lookup the mailbox for a channel in the astdb. Useful + * if you like keeping dialplan logic lookups in astdb. + */ +/* #define ASTDB_MAILBOX_FAMILY "chan2ext" */ + /* Typically, how many rings before we should send Caller*ID */ #define DEFAULT_CIDRINGS 1 @@ -1433,8 +1439,17 @@ static int has_voicemail(struct zt_pvt *p) { - +#ifdef ASTDB_MAILBOX_FAMILY + char channame[AST_MAX_EXTENSION]="", mailbox[AST_MAX_EXTENSION]=""; + snprintf(channame, sizeof(channame), "Zap/%d", p->channel); + if (ast_db_get(ASTDB_MAILBOX_FAMILY, channame, mailbox, sizeof(mailbox) - 1)) { + return ast_app_has_voicemail(p->mailbox, "INBOX"); + } else { + return ast_app_has_voicemail(mailbox, "INBOX"); + } +#else return ast_app_has_voicemail(p->mailbox, NULL); +#endif } static int send_callerid(struct zt_pvt *p) @@ -5958,12 +5973,15 @@ #if 0 printf("Checking channel %d\n", last->channel); #endif - if (!last->cidspill && !last->owner && !ast_strlen_zero(last->mailbox) && (thispass - last->onhooktime > 3) && - (last->sig & __ZT_SIG_FXO)) { + if (!last->cidspill && !last->owner +#ifndef ASTDB_MAILBOX_FAMILY + && !ast_strlen_zero(last->mailbox) +#endif + && (thispass - last->onhooktime > 3) && (last->sig & __ZT_SIG_FXO)) { #if 0 printf("Channel %d has mailbox %s\n", last->channel, last->mailbox); #endif - res = ast_app_has_voicemail(last->mailbox, NULL); + res = has_voicemail(last); if (last->msgstate != res) { int x; ast_log(LOG_DEBUG, "Message status for %s changed from %d to %d on %d\n", last->mailbox, last->msgstate, res, last->channel);