Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 10254) +++ apps/app_voicemail.c (working copy) @@ -224,7 +224,7 @@ /*! Structure for linked list of users */ struct ast_vm_user { char context[AST_MAX_CONTEXT]; /*!< Voicemail context */ - char mailbox[AST_MAX_EXTENSION];/*!< Mailbox id, unique within vm context */ + char ext[AST_MAX_EXTENSION]; /*!< Mailbox extension, unique within vm context */ char password[80]; /*!< Secret pin code, numbers only */ char fullname[80]; /*!< Full name, for directory app */ char email[80]; /*!< E-mail address */ @@ -532,7 +532,7 @@ } } -static struct ast_vm_user *find_user_realtime(struct ast_vm_user *ivm, const char *context, const char *mailbox) +static struct ast_vm_user *find_user_realtime(struct ast_vm_user *ivm, const char *context, const char *ext) { struct ast_variable *var, *tmp; struct ast_vm_user *retval; @@ -542,13 +542,13 @@ ast_set_flag(retval, VM_ALLOCED); else memset(retval, 0, sizeof(*retval)); - if (mailbox) - ast_copy_string(retval->mailbox, mailbox, sizeof(retval->mailbox)); + if (ext) + ast_copy_string(retval->ext, ext, sizeof(retval->ext)); populate_defaults(retval); if (!context && ast_test_flag((&globalflags), VM_SEARCH)) - var = ast_load_realtime("voicemail", "mailbox", mailbox, NULL); + var = ast_load_realtime("voicemail", "mailbox", ext, NULL); else - var = ast_load_realtime("voicemail", "mailbox", mailbox, "context", context, NULL); + var = ast_load_realtime("voicemail", "mailbox", ext, "context", context, NULL); if (var) { tmp = var; while(tmp) { @@ -578,7 +578,7 @@ return retval; } -static struct ast_vm_user *find_user(struct ast_vm_user *ivm, const char *context, const char *mailbox) +static struct ast_vm_user *find_user(struct ast_vm_user *ivm, const char *context, const char *ext) { /* This function could be made to generate one from a database, too */ struct ast_vm_user *vmu=NULL, *cur; @@ -588,9 +588,9 @@ context = "default"; AST_LIST_TRAVERSE(&users, cur, list) { - if (ast_test_flag((&globalflags), VM_SEARCH) && !strcasecmp(mailbox, cur->mailbox)) + if (ast_test_flag((&globalflags), VM_SEARCH) && !strcasecmp(ext, cur->ext)) break; - if (context && (!strcasecmp(context, cur->context)) && (!strcasecmp(mailbox, cur->mailbox))) + if (context && (!strcasecmp(context, cur->context)) && (!strcasecmp(ext, cur->ext))) break; } if (cur) { @@ -601,12 +601,12 @@ AST_LIST_NEXT(vmu, list) = NULL; } } else - vmu = find_user_realtime(ivm, context, mailbox); + vmu = find_user_realtime(ivm, context, ext); AST_LIST_UNLOCK(&users); return vmu; } -static int reset_user_pw(const char *context, const char *mailbox, const char *newpass) +static int reset_user_pw(const char *context, const char *ext, const char *newpass) { /* This function could be made to generate one from a database, too */ struct ast_vm_user *cur; @@ -614,7 +614,7 @@ AST_LIST_LOCK(&users); AST_LIST_TRAVERSE(&users, cur, list) { if ((!context || !strcasecmp(context, cur->context)) && - (!strcasecmp(mailbox, cur->mailbox))) + (!strcasecmp(ext, cur->ext))) break; } if (cur) { @@ -729,7 +729,7 @@ } /* Compare user, pass AND context */ - if (!ast_strlen_zero(user) && !strcmp(user, vmu->mailbox) && + if (!ast_strlen_zero(user) && !strcmp(user, vmu->ext) && !ast_strlen_zero(pass) && !strcmp(pass, vmu->password) && !strcasecmp(currcontext, vmu->context)) { /* This is the line */ @@ -757,21 +757,21 @@ chown(tmpout, statbuf.st_uid, statbuf.st_gid); unlink(tmpin); rename(tmpout, tmpin); - reset_user_pw(vmu->context, vmu->mailbox, newpassword); + reset_user_pw(vmu->context, vmu->ext, newpassword); ast_copy_string(vmu->password, newpassword, sizeof(vmu->password)); } static void vm_change_password_shell(struct ast_vm_user *vmu, char *newpassword) { char buf[255]; - snprintf(buf,255,"%s %s %s %s",ext_pass_cmd,vmu->context,vmu->mailbox,newpassword); + snprintf(buf,255,"%s %s %s %s",ext_pass_cmd,vmu->context,vmu->ext,newpassword); if (!ast_safe_system(buf)) ast_copy_string(vmu->password, newpassword, sizeof(vmu->password)); } -static int make_dir(char *dest, int len, char *context, char *ext, char *mailbox) +static int make_dir(char *dest, int len, char *context, char *ext, char *folder) { - return snprintf(dest, len, "%s%s/%s/%s", VM_SPOOL_DIR, context, ext, mailbox); + return snprintf(dest, len, "%s%s/%s/%s", VM_SPOOL_DIR, context, ext, folder); } static int make_file(char *dest, int len, char *dir, int num) @@ -779,14 +779,14 @@ return snprintf(dest, len, "%s/msg%04d", dir, num); } -/*! \brief basically mkdir -p $dest/$context/$ext/$mailbox +/*! \brief basically mkdir -p $dest/$context/$ext/$folder * \param dest String. base directory. * \param context String. Ignored if is null or empty string. * \param ext String. Ignored if is null or empty string. - * \param mailbox String. Ignored if is null or empty string. + * \param folder String. Ignored if is null or empty string. * \return 0 on failure, 1 on success. */ -static int create_dirpath(char *dest, int len, char *context, char *ext, char *mailbox) +static int create_dirpath(char *dest, int len, char *context, char *ext, char *folder) { mode_t mode = VOICEMAIL_DIR_MODE; @@ -804,8 +804,8 @@ return 0; } } - if(mailbox && mailbox[0] != '\0') { - make_dir(dest, len, context, ext, mailbox); + if(folder && folder[0] != '\0') { + make_dir(dest, len, context, ext, folder); if(mkdir(dest, mode) && errno != EEXIST) { ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dest, strerror(errno)); return 0; @@ -1136,7 +1136,7 @@ return; } -static void copy_file(char *sdir, int smsg, char *ddir, int dmsg, char *dmailboxuser, char *dmailboxcontext) +static void copy_file(char *sdir, int smsg, char *ddir, int dmsg, char *dext, char *dcontext) { int res; SQLHSTMT stmt; @@ -1169,8 +1169,8 @@ SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(ddir), 0, (void *)ddir, 0, NULL); SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(msgnumd), 0, (void *)msgnumd, 0, NULL); #ifdef EXTENDED_ODBC_STORAGE - SQLBindParameter(stmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(dmailboxuser), 0, (void *)dmailboxuser, 0, NULL); - SQLBindParameter(stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(dmailboxcontext), 0, (void *)dmailboxcontext, 0, NULL); + SQLBindParameter(stmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(dext), 0, (void *)dext, 0, NULL); + SQLBindParameter(stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(dcontext), 0, (void *)dcontext, 0, NULL); SQLBindParameter(stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(sdir), 0, (void *)sdir, 0, NULL); SQLBindParameter(stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(msgnums), 0, (void *)msgnums, 0, NULL); #else @@ -1190,7 +1190,7 @@ return; } -static int store_file(char *dir, char *mailboxuser, char *mailboxcontext, int msgnum) +static int store_file(char *dir, char *ext, char *mailboxcontext, int msgnum) { int x = 0; int res; @@ -1287,7 +1287,7 @@ SQLBindParameter(stmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(origtime), 0, (void *)origtime, 0, NULL); SQLBindParameter(stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(duration), 0, (void *)duration, 0, NULL); #ifdef EXTENDED_ODBC_STORAGE - SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(mailboxuser), 0, (void *)mailboxuser, 0, NULL); + SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(ext), 0, (void *)ext, 0, NULL); SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(mailboxcontext), 0, (void *)mailboxcontext, 0, NULL); if (!ast_strlen_zero(category)) SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(category), 0, (void *)category, 0, NULL); @@ -1314,7 +1314,7 @@ return x; } -static void rename_file(char *sdir, int smsg, char *mailboxuser, char *mailboxcontext, char *ddir, int dmsg) +static void rename_file(char *sdir, int smsg, char *ext, char *mailboxcontext, char *ddir, int dmsg) { int res; SQLHSTMT stmt; @@ -1347,7 +1347,7 @@ SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(ddir), 0, (void *)ddir, 0, NULL); SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(msgnumd), 0, (void *)msgnumd, 0, NULL); #ifdef EXTENDED_ODBC_STORAGE - SQLBindParameter(stmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(mailboxuser), 0, (void *)mailboxuser, 0, NULL); + SQLBindParameter(stmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(ext), 0, (void *)ext, 0, NULL); SQLBindParameter(stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(mailboxcontext), 0, (void *)mailboxcontext, 0, NULL); SQLBindParameter(stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(sdir), 0, (void *)sdir, 0, NULL); SQLBindParameter(stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(msgnums), 0, (void *)msgnums, 0, NULL); @@ -1623,7 +1623,7 @@ return 1; } -static void prep_email_sub_vars(struct ast_channel *ast, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, char *cidnum, char *cidname, char *dur, char *date, char *passdata, size_t passdatasize, const char *category) +static void prep_email_sub_vars(struct ast_channel *ast, struct ast_vm_user *vmu, int msgnum, char *context, char *ext, char *cidnum, char *cidname, char *dur, char *date, char *passdata, size_t passdatasize, const char *category) { char callerid[256]; /* Prepare variables for substition in email body and subject */ @@ -1632,7 +1632,7 @@ snprintf(passdata, passdatasize, "%d", msgnum); pbx_builtin_setvar_helper(ast, "VM_MSGNUM", passdata); pbx_builtin_setvar_helper(ast, "VM_CONTEXT", context); - pbx_builtin_setvar_helper(ast, "VM_MAILBOX", mailbox); + pbx_builtin_setvar_helper(ast, "VM_MAILBOX", ext); pbx_builtin_setvar_helper(ast, "VM_CALLERID", ast_callerid_merge(callerid, sizeof(callerid), cidname, cidnum, "Unknown Caller")); pbx_builtin_setvar_helper(ast, "VM_CIDNAME", (cidname ? cidname : "an unknown caller")); pbx_builtin_setvar_helper(ast, "VM_CIDNUM", (cidnum ? cidnum : "an unknown caller")); @@ -1675,7 +1675,7 @@ return p; } -static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, char *cidnum, char *cidname, char *attach, char *format, int duration, int attach_user_voicemail, const char *category) +static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *ext, char *cidnum, char *cidname, char *attach, char *format, int duration, int attach_user_voicemail, const char *category) { FILE *p=NULL; char date[256]; @@ -1689,7 +1689,7 @@ struct tm tm; if (vmu && ast_strlen_zero(vmu->email)) { - ast_log(LOG_WARNING, "E-mail address missing for mailbox [%s]. E-mail will not be sent.\n", vmu->mailbox); + ast_log(LOG_WARNING, "E-mail address missing for mailbox [%s]. E-mail will not be sent.\n", vmu->ext); return(0); } if (!strcmp(format, "wav49")) @@ -1722,7 +1722,7 @@ int vmlen = strlen(fromstring)*3 + 200; if ((passdata = alloca(vmlen))) { memset(passdata, 0, vmlen); - prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category); + prep_email_sub_vars(ast, vmu, msgnum + 1, context, ext, cidnum, cidname, dur, date, passdata, vmlen, category); pbx_substitute_variables_helper(ast,fromstring,passdata,vmlen); fprintf(p, "From: %s <%s>\n",passdata,who); } else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n"); @@ -1739,7 +1739,7 @@ int vmlen = strlen(emailsubject)*3 + 200; if ((passdata = alloca(vmlen))) { memset(passdata, 0, vmlen); - prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category); + prep_email_sub_vars(ast, vmu, msgnum + 1, context, ext, cidnum, cidname, dur, date, passdata, vmlen, category); pbx_substitute_variables_helper(ast,emailsubject,passdata,vmlen); fprintf(p, "Subject: %s\n",passdata); } else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n"); @@ -1747,17 +1747,17 @@ } else ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n"); } else if (*emailtitle) { - fprintf(p, emailtitle, msgnum + 1, mailbox) ; + fprintf(p, emailtitle, msgnum + 1, ext) ; fprintf(p,"\n") ; } else if (ast_test_flag((&globalflags), VM_PBXSKIP)) - fprintf(p, "Subject: New message %d in mailbox %s\n", msgnum + 1, mailbox); + fprintf(p, "Subject: New message %d in mailbox %s\n", msgnum + 1, ext); else - fprintf(p, "Subject: [PBX]: New message %d in mailbox %s\n", msgnum + 1, mailbox); - fprintf(p, "Message-ID: \n", msgnum, (unsigned int)rand(), mailbox, getpid(), host); + fprintf(p, "Subject: [PBX]: New message %d in mailbox %s\n", msgnum + 1, ext); + fprintf(p, "Message-ID: \n", msgnum, (unsigned int)rand(), ext, getpid(), host); fprintf(p, "MIME-Version: 1.0\n"); if (attach_user_voicemail) { /* Something unique. */ - snprintf(bound, sizeof(bound), "voicemail_%d%s%d%d", msgnum, mailbox, getpid(), (unsigned int)rand()); + snprintf(bound, sizeof(bound), "voicemail_%d%s%d%d", msgnum, ext, getpid(), (unsigned int)rand()); fprintf(p, "Content-Type: multipart/mixed; boundary=\"%s\"\n\n\n", bound); @@ -1771,7 +1771,7 @@ int vmlen = strlen(emailbody)*3 + 200; if ((passdata = alloca(vmlen))) { memset(passdata, 0, vmlen); - prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category); + prep_email_sub_vars(ast, vmu, msgnum + 1, context, ext, cidnum, cidname, dur, date, passdata, vmlen, category); pbx_substitute_variables_helper(ast,emailbody,passdata,vmlen); fprintf(p, "%s\n",passdata); } else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n"); @@ -1782,7 +1782,7 @@ "in mailbox %s from %s, on %s so you might\n" "want to check it when you get a chance. Thanks!\n\n\t\t\t\t--Asterisk\n\n", vmu->fullname, - dur, msgnum + 1, mailbox, (cidname ? cidname : (cidnum ? cidnum : "an unknown caller")), date); + dur, msgnum + 1, ext, (cidname ? cidname : (cidnum ? cidnum : "an unknown caller")), date); } if (attach_user_voicemail) { /* Eww. We want formats to tell us their own MIME type */ @@ -1808,7 +1808,7 @@ return 0; } -static int sendpage(char *srcemail, char *pager, int msgnum, char *context, char *mailbox, char *cidnum, char *cidname, int duration, struct ast_vm_user *vmu, const char *category) +static int sendpage(char *srcemail, char *pager, int msgnum, char *context, char *ext, char *cidnum, char *cidname, int duration, struct ast_vm_user *vmu, const char *category) { char date[256]; char host[MAXHOSTNAMELEN]=""; @@ -1840,7 +1840,7 @@ int vmlen = strlen(fromstring)*3 + 200; if ((passdata = alloca(vmlen))) { memset(passdata, 0, vmlen); - prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category); + prep_email_sub_vars(ast, vmu, msgnum + 1, context, ext, cidnum, cidname, dur, date, passdata, vmlen, category); pbx_substitute_variables_helper(ast,pagerfromstring,passdata,vmlen); fprintf(p, "From: %s <%s>\n",passdata,who); } else @@ -1857,7 +1857,7 @@ int vmlen = strlen(pagersubject)*3 + 200; if ((passdata = alloca(vmlen))) { memset(passdata, 0, vmlen); - prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category); + prep_email_sub_vars(ast, vmu, msgnum + 1, context, ext, cidnum, cidname, dur, date, passdata, vmlen, category); pbx_substitute_variables_helper(ast,pagersubject,passdata,vmlen); fprintf(p, "Subject: %s\n\n",passdata); } else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n"); @@ -1873,7 +1873,7 @@ int vmlen = strlen(pagerbody)*3 + 200; if ((passdata = alloca(vmlen))) { memset(passdata, 0, vmlen); - prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category); + prep_email_sub_vars(ast, vmu, msgnum + 1, context, ext, cidnum, cidname, dur, date, passdata, vmlen, category); pbx_substitute_variables_helper(ast,pagerbody,passdata,vmlen); fprintf(p, "%s\n",passdata); } else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n"); @@ -1881,7 +1881,7 @@ } else ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n"); } else { fprintf(p, "New %s long msg in box %s\n" - "from %s, on %s", dur, mailbox, (cidname ? cidname : (cidnum ? cidnum : "unknown")), date); + "from %s, on %s", dur, ext, (cidname ? cidname : (cidnum ? cidnum : "unknown")), date); } fclose(p); snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp); @@ -1980,7 +1980,7 @@ } #ifdef USE_ODBC_STORAGE -static int messagecount(const char *mailbox, int *newmsgs, int *oldmsgs) +static int messagecount(const char *ext, int *newmsgs, int *oldmsgs) { int x = 0; int res; @@ -1994,11 +1994,11 @@ *newmsgs = 0; if (oldmsgs) *oldmsgs = 0; - /* If no mailbox, return immediately */ - if (ast_strlen_zero(mailbox)) + /* If no ext, return immediately */ + if (ast_strlen_zero(ext)) return 0; - ast_copy_string(tmp, mailbox, sizeof(tmp)); + ast_copy_string(tmp, ext, sizeof(tmp)); context = strchr(tmp, '@'); if (context) { @@ -2083,7 +2083,7 @@ return x; } -static int has_voicemail(const char *mailbox, const char *folder) +static int has_voicemail(const char *ext, const char *folder) { int nummsgs = 0; int res; @@ -2094,11 +2094,11 @@ char *context; if (!folder) folder = "INBOX"; - /* If no mailbox, return immediately */ - if (ast_strlen_zero(mailbox)) + /* If no ext, return immediately */ + if (ast_strlen_zero(ext)) return 0; - ast_copy_string(tmp, mailbox, sizeof(tmp)); + ast_copy_string(tmp, ext, sizeof(tmp)); context = strchr(tmp, '@'); if (context) { @@ -2154,7 +2154,7 @@ #else -static int has_voicemail(const char *mailbox, const char *folder) +static int has_voicemail(const char *ext, const char *folder) { DIR *dir; struct dirent *de; @@ -2165,11 +2165,11 @@ int ret; if (!folder) folder = "INBOX"; - /* If no mailbox, return immediately */ - if (ast_strlen_zero(mailbox)) + /* If no ext, return immediately */ + if (ast_strlen_zero(ext)) return 0; - if (strchr(mailbox, ',')) { - ast_copy_string(tmp, mailbox, sizeof(tmp)); + if (strchr(ext, ',')) { + ast_copy_string(tmp, ext, sizeof(tmp)); mb = tmp; ret = 0; while((cur = strsep(&mb, ","))) { @@ -2180,7 +2180,7 @@ } return 0; } - ast_copy_string(tmp, mailbox, sizeof(tmp)); + ast_copy_string(tmp, ext, sizeof(tmp)); context = strchr(tmp, '@'); if (context) { *context = '\0'; @@ -2202,7 +2202,7 @@ } -static int messagecount(const char *mailbox, int *newmsgs, int *oldmsgs) +static int messagecount(const char *ext, int *newmsgs, int *oldmsgs) { DIR *dir; struct dirent *de; @@ -2215,12 +2215,12 @@ *newmsgs = 0; if (oldmsgs) *oldmsgs = 0; - /* If no mailbox, return immediately */ - if (ast_strlen_zero(mailbox)) + /* If no ext, return immediately */ + if (ast_strlen_zero(ext)) return 0; - if (strchr(mailbox, ',')) { + if (strchr(ext, ',')) { int tmpnew, tmpold; - ast_copy_string(tmp, mailbox, sizeof(tmp)); + ast_copy_string(tmp, ext, sizeof(tmp)); mb = tmp; ret = 0; while((cur = strsep(&mb, ", "))) { @@ -2237,7 +2237,7 @@ } return 0; } - ast_copy_string(tmp, mailbox, sizeof(tmp)); + ast_copy_string(tmp, ext, sizeof(tmp)); context = strchr(tmp, '@'); if (context) { *context = '\0'; @@ -2283,11 +2283,11 @@ char *frombox = mbox(imbox); int recipmsgnum; - ast_log(LOG_NOTICE, "Copying message from %s@%s to %s@%s\n", vmu->mailbox, vmu->context, recip->mailbox, recip->context); + ast_log(LOG_NOTICE, "Copying message from %s@%s to %s@%s\n", vmu->ext, vmu->context, recip->ext, recip->context); - create_dirpath(todir, sizeof(todir), recip->context, recip->mailbox, "INBOX"); + create_dirpath(todir, sizeof(todir), recip->context, recip->ext, "INBOX"); - make_dir(fromdir, sizeof(fromdir), vmu->context, vmu->mailbox, frombox); + make_dir(fromdir, sizeof(fromdir), vmu->context, vmu->ext, frombox); make_file(frompath, sizeof(frompath), fromdir, msgnum); if (vm_lock_path(todir)) @@ -2301,9 +2301,9 @@ recipmsgnum++; } while (recipmsgnum < recip->maxmsg); if (recipmsgnum < recip->maxmsg) { - COPY(fromdir, msgnum, todir, recipmsgnum, recip->mailbox, recip->context, frompath, topath); + COPY(fromdir, msgnum, todir, recipmsgnum, recip->ext, recip->context, frompath, topath); } 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->ext, recip->context); } ast_unlock_path(todir); notify_new_message(chan, recip, recipmsgnum, duration, fmt, chan->cid.cid_num, chan->cid.cid_name); @@ -2537,8 +2537,8 @@ } /* - * This operation can be very expensive if done say over NFS or if the mailbox has 100+ messages - * in the mailbox. So we should get this first so we don't cut off the first few seconds of the + * This operation can be very expensive if done say over NFS or if the extension has 100+ messages + * in the folder. So we should get this first so we don't cut off the first few seconds of the * message. */ do { @@ -2628,7 +2628,7 @@ } } if (ast_fileexists(fn, NULL, NULL)) { - STORE(dir, vmu->mailbox, vmu->context, msgnum); + STORE(dir, vmu->ext, vmu->context, msgnum); notify_new_message(chan, vmu, msgnum, duration, fmt, chan->cid.cid_num, chan->cid.cid_name); DISPOSE(dir, msgnum); } @@ -2666,7 +2666,7 @@ if(x != dest) { make_file(dfn, sizeof(dfn), dir, dest); - RENAME(dir, x, vmu->mailbox, vmu->context, dir, dest, sfn, dfn); + RENAME(dir, x, vmu->ext, vmu->context, dir, dest, sfn, dfn); } dest++; @@ -3302,9 +3302,9 @@ int newmsgs = 0, oldmsgs = 0; const char *category = pbx_builtin_getvar_helper(chan, "VM_CATEGORY"); - make_dir(todir, sizeof(todir), vmu->context, vmu->mailbox, "INBOX"); + make_dir(todir, sizeof(todir), vmu->context, vmu->ext, "INBOX"); make_file(fn, sizeof(fn), todir, msgnum); - snprintf(ext_context, sizeof(ext_context), "%s@%s", vmu->mailbox, vmu->context); + snprintf(ext_context, sizeof(ext_context), "%s@%s", vmu->ext, vmu->context); /* Attach only the first format */ if ((fmt = ast_strdupa(fmt))) { @@ -3317,14 +3317,14 @@ attach_user_voicemail = ast_test_flag(vmu, VM_ATTACH); if (!ast_strlen_zero(vmu->serveremail)) myserveremail = vmu->serveremail; - sendmail(myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, cidnum, cidname, fn, fmt, duration, attach_user_voicemail, category); + sendmail(myserveremail, vmu, msgnum, vmu->context, vmu->ext, cidnum, cidname, fn, fmt, duration, attach_user_voicemail, category); } if (!ast_strlen_zero(vmu->pager)) { char *myserveremail = serveremail; if (!ast_strlen_zero(vmu->serveremail)) myserveremail = vmu->serveremail; - sendpage(myserveremail, vmu->pager, msgnum, vmu->context, vmu->mailbox, cidnum, cidname, duration, vmu, category); + sendpage(myserveremail, vmu->pager, msgnum, vmu->context, vmu->ext, cidnum, cidname, duration, vmu, category); } } @@ -3336,8 +3336,8 @@ if (ast_app_has_voicemail(ext_context, NULL)) { ast_app_messagecount(ext_context, &newmsgs, &oldmsgs); } - manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s@%s\r\nWaiting: %d\r\nNew: %d\r\nOld: %d\r\n", vmu->mailbox, vmu->context, ast_app_has_voicemail(ext_context, NULL), newmsgs, oldmsgs); - run_externnotify(vmu->context, vmu->mailbox); + manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s@%s\r\nWaiting: %d\r\nNew: %d\r\nOld: %d\r\n", vmu->ext, vmu->context, ast_app_has_voicemail(ext_context, NULL), newmsgs, oldmsgs); + run_externnotify(vmu->context, vmu->ext); return 0; } @@ -3486,9 +3486,9 @@ /* if (ast_play_and_wait(chan, "vm-savedto")) break; */ - snprintf(todir, sizeof(todir), "%s%s/%s/INBOX", VM_SPOOL_DIR, vmtmp->context, vmtmp->mailbox); + snprintf(todir, sizeof(todir), "%s%s/%s/INBOX", VM_SPOOL_DIR, vmtmp->context, vmtmp->ext); snprintf(sys, sizeof(sys), "mkdir -p %s\n", todir); - snprintf(ext_context, sizeof(ext_context), "%s@%s", vmtmp->mailbox, vmtmp->context); + snprintf(ext_context, sizeof(ext_context), "%s@%s", vmtmp->ext, vmtmp->context); ast_log(LOG_DEBUG, "%s", sys); ast_safe_system(sys); @@ -3517,7 +3517,7 @@ ast_safe_system(sys); snprintf(fn, sizeof(fn), "%s/msg%04d", todir,todircount); - STORE(todir, vmtmp->mailbox, vmtmp->context, todircount); + STORE(todir, vmtmp->ext, vmtmp->context, todircount); /* load the information on the source message so we can send an e-mail like a new message */ snprintf(miffile, sizeof(miffile), "%s/msg%04d.txt", dir, curmsg); @@ -3537,21 +3537,21 @@ attach_user_voicemail = ast_test_flag(vmtmp, VM_ATTACH); if (!ast_strlen_zero(vmtmp->serveremail)) myserveremail = vmtmp->serveremail; - sendmail(myserveremail, vmtmp, todircount, vmtmp->context, vmtmp->mailbox, chan->cid.cid_num, chan->cid.cid_name, fn, tmp, duration, attach_user_voicemail, category); + sendmail(myserveremail, vmtmp, todircount, vmtmp->context, vmtmp->ext, chan->cid.cid_num, chan->cid.cid_name, fn, tmp, duration, attach_user_voicemail, category); } if (!ast_strlen_zero(vmtmp->pager)) { char *myserveremail = serveremail; if (!ast_strlen_zero(vmtmp->serveremail)) myserveremail = vmtmp->serveremail; - sendpage(myserveremail, vmtmp->pager, todircount, vmtmp->context, vmtmp->mailbox, chan->cid.cid_num, chan->cid.cid_name, duration, vmtmp, category); + sendpage(myserveremail, vmtmp->pager, todircount, vmtmp->context, vmtmp->ext, chan->cid.cid_num, chan->cid.cid_name, duration, vmtmp, category); } ast_config_destroy(mif); /* or here */ } /* Leave voicemail for someone */ manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s\r\nWaiting: %d\r\n", ext_context, has_voicemail(ext_context, NULL)); - run_externnotify(vmtmp->context, vmtmp->mailbox); + run_externnotify(vmtmp->context, vmtmp->ext); saved_messages++; AST_LIST_REMOVE_CURRENT(&extensions, list); @@ -3885,7 +3885,7 @@ vms->curmsg++; make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg); if (strcmp(vms->fn, vms->fn2)) { - RENAME(vms->curdir, x, vmu->mailbox,vmu->context, vms->curdir, vms->curmsg, vms->fn, vms->fn2); + RENAME(vms->curdir, x, vmu->ext,vmu->context, vms->curdir, vms->curmsg, vms->fn, vms->fn2); } } else if (!strcasecmp(vms->curbox, "INBOX") && vms->heard[x] && !vms->deleted[x]) { /* Move to old folder before deleting */ @@ -4928,7 +4928,7 @@ } } -static int vm_authenticate(struct ast_channel *chan, char *mailbox, int mailbox_size, +static int vm_authenticate(struct ast_channel *chan, char *ext, int ext_size, struct ast_vm_user *res_vmu, const char *context, const char *prefix, int skipuser, int maxlogins, int silent) { @@ -4945,17 +4945,17 @@ return -1; } - /* Authenticate them and get their mailbox/password */ + /* Authenticate them and get their ext/password */ while (!valid && (logretries < maxlogins)) { /* Prompt for, and read in the username */ - if (!skipuser && ast_readstring(chan, mailbox, mailbox_size - 1, 2000, 10000, "#") < 0) { + if (!skipuser && ast_readstring(chan, ext, ext_size - 1, 2000, 10000, "#") < 0) { ast_log(LOG_WARNING, "Couldn't read username\n"); return -1; } - if (ast_strlen_zero(mailbox)) { + if (ast_strlen_zero(ext)) { if (chan->cid.cid_num) { - ast_copy_string(mailbox, chan->cid.cid_num, mailbox_size); + ast_copy_string(ext, chan->cid.cid_num, ext_size); } else { if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Username not entered\n"); @@ -4968,11 +4968,11 @@ if (!ast_strlen_zero(prefix)) { char fullusername[80] = ""; ast_copy_string(fullusername, prefix, sizeof(fullusername)); - strncat(fullusername, mailbox, sizeof(fullusername) - 1 - strlen(fullusername)); - ast_copy_string(mailbox, fullusername, mailbox_size); + strncat(fullusername, ext, sizeof(fullusername) - 1 - strlen(fullusername)); + ast_copy_string(ext, fullusername, ext_size); } - vmu = find_user(&vmus, context, mailbox); + vmu = find_user(&vmus, context, ext); if (vmu && (vmu->password[0] == '\0' || (vmu->password[0] == '-' && vmu->password[1] == '\0'))) { /* saved password is blank, so don't bother asking */ password[0] = '\0'; @@ -4995,9 +4995,9 @@ valid++; else { if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "Incorrect password '%s' for user '%s' (context = %s)\n", password, mailbox, context ? context : "default"); + ast_verbose( VERBOSE_PREFIX_3 "Incorrect password '%s' for user '%s' (context = %s)\n", password, ext, context ? context : "default"); if (!ast_strlen_zero(prefix)) - mailbox[0] = '\0'; + ext[0] = '\0'; } logretries++; if (!valid) { @@ -5205,7 +5205,7 @@ res = 0; /* Check to see if this is a new user */ - if (!strcasecmp(vmu->mailbox, vmu->password) && + if (!strcasecmp(vmu->ext, vmu->password) && (ast_test_flag(vmu, VM_FORCENAME | VM_FORCEGREET))) { if (ast_play_and_wait(chan, "vm-newuser") == -1) ast_log(LOG_WARNING, "Couldn't stream new user file\n"); @@ -5504,7 +5504,7 @@ if (valid) { snprintf(ext_context, sizeof(ext_context), "%s@%s", vms.username, vmu->context); manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s\r\nWaiting: %d\r\n", ext_context, has_voicemail(ext_context, NULL)); - run_externnotify(vmu->context, vmu->mailbox); + run_externnotify(vmu->context, vmu->ext); } if (vmu) free_user(vmu); @@ -5614,7 +5614,7 @@ ast_copy_string(tmp, data, sizeof(tmp)); if ((vmu = ast_calloc(1, sizeof(*vmu)))) { ast_copy_string(vmu->context, context, sizeof(vmu->context)); - ast_copy_string(vmu->mailbox, mbox, sizeof(vmu->mailbox)); + ast_copy_string(vmu->ext, mbox, sizeof(vmu->ext)); populate_defaults(vmu); @@ -5684,7 +5684,7 @@ static int vmauthenticate(struct ast_channel *chan, void *data) { struct localuser *u; - char *s = data, *user=NULL, *context=NULL, mailbox[AST_MAX_EXTENSION] = ""; + char *s = data, *user=NULL, *context=NULL, ext[AST_MAX_EXTENSION] = ""; struct ast_vm_user vmus; char *options = NULL; int silent = 0, skipuser = 0; @@ -5703,7 +5703,7 @@ context = strsep(&s, ""); if (!ast_strlen_zero(user)) skipuser++; - ast_copy_string(mailbox, user, sizeof(mailbox)); + ast_copy_string(ext, user, sizeof(ext)); } } @@ -5711,8 +5711,8 @@ silent = (strchr(options, 's')) != NULL; } - if (!vm_authenticate(chan, mailbox, sizeof(mailbox), &vmus, context, NULL, skipuser, 3, silent)) { - pbx_builtin_setvar_helper(chan, "AUTH_MAILBOX", mailbox); + if (!vm_authenticate(chan, ext, sizeof(ext), &vmus, context, NULL, skipuser, 3, silent)) { + pbx_builtin_setvar_helper(chan, "AUTH_MAILBOX", ext); pbx_builtin_setvar_helper(chan, "AUTH_CONTEXT", vmus.context); ast_play_and_wait(chan, "auth-thankyou"); res = 0; @@ -5764,7 +5764,7 @@ char count[12]; if ((argc == 3) || ((argc == 5) && !strcmp(argv[4],vmu->context))) { - make_dir(dirname, 255, vmu->context, vmu->mailbox, "INBOX"); + make_dir(dirname, 255, vmu->context, vmu->ext, "INBOX"); if ((vmdir = opendir(dirname))) { /* No matter what the format of VM, there will always be a .txt file for each message. */ while ((vment = readdir(vmdir))) @@ -5773,7 +5773,7 @@ closedir(vmdir); } snprintf(count,sizeof(count),"%d",vmcount); - ast_cli(fd, output_format, vmu->context, vmu->mailbox, vmu->fullname, vmu->zonetag, count); + ast_cli(fd, output_format, vmu->context, vmu->ext, vmu->fullname, vmu->zonetag, count); } } } else { @@ -6612,7 +6612,7 @@ ast_verbose(VERBOSE_PREFIX_3 "Saving message as is\n"); ast_streamfile(chan, "vm-msgsaved", chan->language); ast_waitstream(chan, ""); - STORE(recordfile, vmu->mailbox, vmu->context, -1); + STORE(recordfile, vmu->ext, vmu->context, -1); DISPOSE(recordfile, -1); cmd = 't'; return res;