? core.10831 ? core.9070 ? voicemail.patch ? sounds/vm-press5.gsm Index: sounds.txt =================================================================== RCS file: /usr/cvsroot/asterisk/sounds.txt,v retrieving revision 1.32 diff -u -r1.32 sounds.txt --- sounds.txt 5 Aug 2004 22:02:33 -0000 1.32 +++ sounds.txt 15 Aug 2004 22:37:18 -0000 @@ -636,3 +636,4 @@ %conf-lockednow.gsm%The conference is now locked %conf-unlockednow.gsm%The conference is now unlocked +%vm-press5.gsm% Press 5 to send a voicemail message Index: apps/app_voicemail.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_voicemail.c,v retrieving revision 1.137 diff -u -r1.137 app_voicemail.c --- apps/app_voicemail.c 6 Aug 2004 21:30:39 -0000 1.137 +++ apps/app_voicemail.c 15 Aug 2004 22:37:22 -0000 @@ -138,6 +138,7 @@ char zonetag[80]; /* Time zone */ char callback[80]; char dialout[80]; + char send_voicemail[80]; char exit[80]; int attach; int delete; @@ -267,6 +268,7 @@ static char dialcontext[80]; static char callcontext[80]; static char exitcontext[80]; +static char svmailcontext[80]; static char cidinternalcontexts[MAX_NUM_CID_CONTEXTS][64]; @@ -299,6 +301,8 @@ strncpy(vmu->callback, callcontext, sizeof(vmu->callback) -1); if (dialcontext) strncpy(vmu->dialout, dialcontext, sizeof(vmu->dialout) -1); + if(svmailcontext) + strncpy(vmu->send_voicemail,svmailcontext,sizeof(vmu->send_voicemail) -1); if (exitcontext) strncpy(vmu->exit, exitcontext, sizeof(vmu->exit) -1); } @@ -350,6 +354,8 @@ strncpy(vmu->callback, value, sizeof(vmu->callback) -1); } else if (!strcasecmp(var, "dialout")) { strncpy(vmu->dialout, value, sizeof(vmu->dialout) -1); + } else if (!strcasecmp(var, "send_voicemail")){ + strncpy(vmu->send_voicemail,value,sizeof(vmu->dialout)-1); } else if (!strcasecmp(var, "exitcontext")) { strncpy(vmu->exit, value, sizeof(vmu->exit) -1); @@ -2609,7 +2615,7 @@ return 0; } -static int forward_message(struct ast_channel *chan, char *context, char *dir, int curmsg, struct ast_vm_user *sender, char *fmt) +static int forward_message(struct ast_channel *chan, char *context, char *dir, int curmsg, struct ast_vm_user *sender, char *fmt,int flag) { char username[70]; char sys[256]; @@ -2666,90 +2672,97 @@ if (!extensions || !valid_extensions) return res; vmtmp = extensions; - cmd = vm_forwardoptions(chan, sender, dir, curmsg, vmfmts, context); - if (!cmd) { - while(!res && vmtmp) { - /* if (play_and_wait(chan, "vm-savedto")) - break; - */ - snprintf(todir, sizeof(todir), "%s/voicemail/%s/%s/INBOX", (char *)ast_config_AST_SPOOL_DIR, vmtmp->context, vmtmp->mailbox); - snprintf(sys, sizeof(sys), "mkdir -p %s\n", todir); - snprintf(ext_context, sizeof(ext_context), "%s@%s", vmtmp->mailbox, vmtmp->context); - ast_log(LOG_DEBUG, sys); - ast_safe_system(sys); + if(flag==1)/*Send VoiceMail*/ + { + cmd=leave_voicemail(chan,username,0,0,0); + } - todircount = count_messages(todir); - strncpy(tmp, fmt, sizeof(tmp) - 1); - stringp = tmp; - while((s = strsep(&stringp, "|"))) { - /* XXX This is a hack -- we should use build_filename or similar XXX */ - if (!strcasecmp(s, "wav49")) - s = "WAV"; - snprintf(sys, sizeof(sys), "cp %s/msg%04d.%s %s/msg%04d.%s\n", dir, curmsg, s, todir, todircount, s); + else /*Forward VoiceMail*/ + { + cmd = vm_forwardoptions(chan, sender, dir, curmsg, vmfmts, context); + if (!cmd) { + while(!res && vmtmp) { + /* if (play_and_wait(chan, "vm-savedto")) + break; + */ + snprintf(todir, sizeof(todir), "%s/voicemail/%s/%s/INBOX", (char *)ast_config_AST_SPOOL_DIR, vmtmp->context, vmtmp->mailbox); + snprintf(sys, sizeof(sys), "mkdir -p %s\n", todir); + snprintf(ext_context, sizeof(ext_context), "%s@%s", vmtmp->mailbox, vmtmp->context); ast_log(LOG_DEBUG, sys); ast_safe_system(sys); - } - snprintf(sys, sizeof(sys), "cp %s/msg%04d.txt %s/msg%04d.txt\n", dir, curmsg, todir, todircount); - ast_log(LOG_DEBUG, sys); - ast_safe_system(sys); - snprintf(fn, sizeof(fn), "%s/msg%04d", todir,todircount); + + todircount = count_messages(todir); + strncpy(tmp, fmt, sizeof(tmp) - 1); + stringp = tmp; + while((s = strsep(&stringp, "|"))) { + /* XXX This is a hack -- we should use build_filename or similar XXX */ + if (!strcasecmp(s, "wav49")) + s = "WAV"; + snprintf(sys, sizeof(sys), "cp %s/msg%04d.%s %s/msg%04d.%s\n", dir, curmsg, s, todir, todircount, s); + ast_log(LOG_DEBUG, sys); + ast_safe_system(sys); + } + snprintf(sys, sizeof(sys), "cp %s/msg%04d.txt %s/msg%04d.txt\n", dir, curmsg, todir, todircount); + ast_log(LOG_DEBUG, sys); + ast_safe_system(sys); + snprintf(fn, sizeof(fn), "%s/msg%04d", todir,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); - if ((mif=ast_load(miffile))) { + /* 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); + if ((mif=ast_load(miffile))) { - /* set callerid and duration variables */ - snprintf(callerid, sizeof(callerid), "FWD from: %s from %s", sender->fullname, ast_variable_retrieve(mif, NULL, "callerid")); - s = ast_variable_retrieve(mif, NULL, "duration"); - if (s) - duration = atoi(s); - else - duration = 0; - if (!ast_strlen_zero(vmtmp->email)) { - int attach_user_voicemail = attach_voicemail; - char *myserveremail = serveremail; - if (vmtmp->attach > -1) - attach_user_voicemail = vmtmp->attach; - if (!ast_strlen_zero(vmtmp->serveremail)) - myserveremail = vmtmp->serveremail; - sendmail(myserveremail, vmtmp, todircount, vmtmp->mailbox, callerid, fn, tmp, duration, attach_user_voicemail); - } + /* set callerid and duration variables */ + snprintf(callerid, sizeof(callerid), "FWD from: %s from %s", sender->fullname, ast_variable_retrieve(mif, NULL, "callerid")); + s = ast_variable_retrieve(mif, NULL, "duration"); + if (s) + duration = atoi(s); + else + duration = 0; + if (!ast_strlen_zero(vmtmp->email)) { + int attach_user_voicemail = attach_voicemail; + char *myserveremail = serveremail; + if (vmtmp->attach > -1) + attach_user_voicemail = vmtmp->attach; + if (!ast_strlen_zero(vmtmp->serveremail)) + myserveremail = vmtmp->serveremail; + sendmail(myserveremail, vmtmp, todircount, vmtmp->mailbox, callerid, fn, tmp, duration, attach_user_voicemail); + } - if (!ast_strlen_zero(vmtmp->pager)) { - char *myserveremail = serveremail; - if (!ast_strlen_zero(vmtmp->serveremail)) - myserveremail = vmtmp->serveremail; - sendpage(myserveremail, vmtmp->pager, todircount, vmtmp->mailbox, callerid, duration, vmtmp); - } + if (!ast_strlen_zero(vmtmp->pager)) { + char *myserveremail = serveremail; + if (!ast_strlen_zero(vmtmp->serveremail)) + myserveremail = vmtmp->serveremail; + sendpage(myserveremail, vmtmp->pager, todircount, vmtmp->mailbox, callerid, duration, vmtmp); + } - ast_destroy(mif); /* or here */ - } - /* Leave voicemail for someone */ - manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s\r\nWaiting: %d\r\n", ext_context, ast_app_has_voicemail(ext_context)); - run_externnotify(chan->context, ext_context); + ast_destroy(mif); /* or here */ + } + /* Leave voicemail for someone */ + manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s\r\nWaiting: %d\r\n", ext_context, ast_app_has_voicemail(ext_context)); + run_externnotify(chan->context, ext_context); - saved_messages++; - vmfree = vmtmp; - vmtmp = vmtmp->next; - free_user(vmfree); - } - if (saved_messages > 0) { - /* give confirmation that the message was saved */ - /* commented out since we can't forward batches yet - if (saved_messages == 1) - res = play_and_wait(chan, "vm-message"); - else - res = play_and_wait(chan, "vm-messages"); - if (!res) - res = play_and_wait(chan, "vm-saved"); */ - if (!res) - res = play_and_wait(chan, "vm-msgsaved"); + saved_messages++; + vmfree = vmtmp; + vmtmp = vmtmp->next; + free_user(vmfree); + } + if (saved_messages > 0) { + /* give confirmation that the message was saved */ + /* commented out since we can't forward batches yet + if (saved_messages == 1) + res = play_and_wait(chan, "vm-message"); + else + res = play_and_wait(chan, "vm-messages"); + if (!res) + res = play_and_wait(chan, "vm-saved"); */ + if (!res) + res = play_and_wait(chan, "vm-msgsaved"); + } } } return res ? res : cmd; } - static int wait_file2(struct ast_channel *chan, struct vm_state *vms, char *file) { int res; @@ -3733,6 +3746,14 @@ cmd = 't'; break; + case '5': /* Leave VoiceMail */ + if(!ast_strlen_zero(vmu->send_voicemail)) + cmd = forward_message(chan, context, vms.curdir, vms.curmsg, vmu, vmfmts,1); + else + cmd = play_and_wait(chan,"vm-sorry"); + cmd='t'; + break; + case '*': /* Return to main menu */ cmd = 't'; break; @@ -3752,6 +3773,8 @@ if (!ast_strlen_zero(vmu->dialout) && !cmd) { cmd = play_and_wait(chan, "vm-tomakecall"); } + if(!ast_strlen_zero(vmu->send_voicemail)&&!cmd) + cmd=play_and_wait(chan, "vm-press5"); if (!cmd) cmd = play_and_wait(chan, "vm-starmain"); if (!cmd) @@ -3808,7 +3831,7 @@ case '8': if(vms.lastmsg > -1) - cmd = forward_message(chan, context, vms.curdir, vms.curmsg, vmu, vmfmts); + cmd = forward_message(chan, context, vms.curdir, vms.curmsg, vmu, vmfmts,0); else cmd = play_and_wait(chan, "vm-nomore"); break; @@ -4183,6 +4206,7 @@ char *astmailcmd = SENDMAIL; char *s,*q,*stringp; char *dialoutcxt = NULL; + char *svmailcxt = NULL; char *callbackcxt = NULL; char *exitcxt = NULL; @@ -4349,7 +4373,15 @@ } else { dialcontext[0] = '\0'; } - + + if((svmailcxt = ast_variable_retrieve(cfg, "general", "send_voicemail"))){ + strncpy(svmailcontext, svmailcxt, sizeof(svmailcontext)-1); + ast_log(LOG_DEBUG, "found Send VoiceMail context: %s\n", svmailcontext); + } + else{ + svmailcontext[0]='\0'; + } + if ((callbackcxt = ast_variable_retrieve(cfg, "general", "callback"))) { strncpy(callcontext, callbackcxt, sizeof(callcontext) -1); ast_log(LOG_DEBUG, "found callback context: %s\n", callcontext); @@ -4966,9 +4998,3 @@ { return ASTERISK_GPL_KEY; } - - - - - - Index: configs/voicemail.conf.sample =================================================================== RCS file: /usr/cvsroot/asterisk/configs/voicemail.conf.sample,v retrieving revision 1.36 diff -u -r1.36 voicemail.conf.sample --- configs/voicemail.conf.sample 6 Aug 2004 21:30:39 -0000 1.36 +++ configs/voicemail.conf.sample 15 Aug 2004 22:37:22 -0000 @@ -98,6 +98,8 @@ ; or set to no, it will be in the envelope ; dialout=fromvm ; Context to dial out from [option 4 from the advanced menu] ; if not listed, dialing out will not be permitted + send_voicemail=fromvm ; Context to Send voicemail from [option 5 from the advanced menu] + ; if not listed, sending messages from inside voicemail will not be permitted ; callback=fromvm ; Context to call back from ; if not listed, calling the sender back will not be permitted ; review=yes ; Allow sender to review/rerecord their message before saving it [OFF by default