[asterisk-commits] mjordan: branch mjordan/voicemail_refactor_11_10_19 r403172 - in /team/mjorda...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Nov 27 08:54:47 CST 2013
Author: mjordan
Date: Wed Nov 27 08:54:42 2013
New Revision: 403172
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=403172
Log:
This branch is most likely dead, but I may as well not lose stuff
Added:
team/mjordan/voicemail_refactor_11_10_19/main/message_storage.c.bakup
- copied, changed from r354937, team/mjordan/voicemail_refactor_11_10_19/main/message_storage.c
team/mjordan/voicemail_refactor_11_10_19/res/res_message_file.c.bakup
- copied, changed from r354937, team/mjordan/voicemail_refactor_11_10_19/res/res_message_file.c
team/mjordan/voicemail_refactor_11_10_19/res/res_message_imap.c.bakup
- copied, changed from r354937, team/mjordan/voicemail_refactor_11_10_19/res/res_message_imap.c
team/mjordan/voicemail_refactor_11_10_19/res/res_message_odbc.c.bakup
- copied, changed from r354937, team/mjordan/voicemail_refactor_11_10_19/res/res_message_odbc.c
Removed:
team/mjordan/voicemail_refactor_11_10_19/main/message_storage.c
team/mjordan/voicemail_refactor_11_10_19/res/res_message_file.c
team/mjordan/voicemail_refactor_11_10_19/res/res_message_imap.c
team/mjordan/voicemail_refactor_11_10_19/res/res_message_odbc.c
Modified:
team/mjordan/voicemail_refactor_11_10_19/apps/app_voicemail.c
team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/include/voicemail.h
team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/vm_configuration.c
team/mjordan/voicemail_refactor_11_10_19/include/asterisk/message_storage.h
team/mjordan/voicemail_refactor_11_10_19/main/asterisk.c
team/mjordan/voicemail_refactor_11_10_19/res/Makefile
Modified: team/mjordan/voicemail_refactor_11_10_19/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/voicemail_refactor_11_10_19/apps/app_voicemail.c?view=diff&rev=403172&r1=403171&r2=403172
==============================================================================
--- team/mjordan/voicemail_refactor_11_10_19/apps/app_voicemail.c (original)
+++ team/mjordan/voicemail_refactor_11_10_19/apps/app_voicemail.c Wed Nov 27 08:54:42 2013
@@ -124,8 +124,8 @@
#include "asterisk/event.h"
#include "asterisk/taskprocessor.h"
#include "asterisk/test.h"
-
#include "voicemail/include/voicemail.h"
+#include "voicemail/include/voicemail_test.h"
#ifdef ODBC_STORAGE
#include "asterisk/res_odbc.h"
@@ -500,14 +500,6 @@
#define VOICEMAIL_CONFIG "voicemail.conf"
#define ASTERISK_USERNAME "asterisk"
-/* Define fast-forward, pause, restart, and reverse keys
- * while listening to a voicemail message - these are
- * strings, not characters */
-#define DEFAULT_LISTEN_CONTROL_FORWARD_KEY "#"
-#define DEFAULT_LISTEN_CONTROL_REVERSE_KEY "*"
-#define DEFAULT_LISTEN_CONTROL_PAUSE_KEY "0"
-#define DEFAULT_LISTEN_CONTROL_RESTART_KEY "2"
-#define DEFAULT_LISTEN_CONTROL_STOP_KEY "13456789"
#define VALID_DTMF "1234567890*#" /* Yes ABCD are valid dtmf but what phones have those? */
/* Default mail command to mail voicemail. Change it with the
@@ -816,7 +808,10 @@
static char VM_SPOOL_DIR[PATH_MAX];
+/* TODO: remove */
+/*
static char ext_pass_cmd[128];
+*/
static char ext_pass_check_cmd[128];
static int my_umask;
@@ -917,34 +912,6 @@
static AST_RWLIST_HEAD_STATIC(mwi_subs, mwi_sub);
-/* custom audio control prompts for voicemail playback */
-static char listen_control_forward_key[12];
-static char listen_control_reverse_key[12];
-static char listen_control_pause_key[12];
-static char listen_control_restart_key[12];
-static char listen_control_stop_key[12];
-
-/* custom password sounds */
-static char vm_password[80] = "vm-password";
-static char vm_newpassword[80] = "vm-newpassword";
-static char vm_passchanged[80] = "vm-passchanged";
-static char vm_reenterpassword[80] = "vm-reenterpassword";
-static char vm_mismatch[80] = "vm-mismatch";
-static char vm_invalid_password[80] = "vm-invalid-password";
-static char vm_pls_try_again[80] = "vm-pls-try-again";
-
-/*
- * XXX If we have the time, motivation, etc. to fix up this prompt, one of the following would be appropriate:
- * 1. create a sound along the lines of "Please try again. When done, press the pound key" which could be spliced
- * from existing sound clips. This would require some programming changes in the area of vm_forward options and also
- * app.c's __ast_play_and_record function
- * 2. create a sound prompt saying "Please try again. When done recording, press any key to stop and send the prepended
- * message." At the time of this comment, I think this would require new voice work to be commissioned.
- * 3. Something way different like providing instructions before a time out or a post-recording menu. This would require
- * more effort than either of the other two.
- */
-static char vm_prepend_timeout[80] = "vm-then-pound";
-
static struct ast_flags globalflags = {0};
static int saydurationminfo;
@@ -964,15 +931,15 @@
static char pagerfromstring[100];
static char charset[32] = "ISO-8859-1";
-static unsigned char adsifdn[4] = "\x00\x00\x00\x0F";
+/*static unsigned char adsifdn[4] = "\x00\x00\x00\x0F";
static unsigned char adsisec[4] = "\x9B\xDB\xF7\xAC";
-static int adsiver = 1;
+static int adsiver = 1;*/
static char emaildateformat[32] = "%A, %B %d, %Y at %r";
static char pagerdateformat[32] = "%A, %B %d, %Y at %r";
/* Forward declarations - generic */
static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu, int box);
-static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int msg, int option, signed char record_gain);
+static int advanced_options(struct ast_channel *chan, struct ast_vm_config *vmconfig, struct ast_vm_user *vmu, struct vm_state *vms, int msg, int option, signed char record_gain);
static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num, char *outgoing_context);
static int play_record_review(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime,
char *fmt, int outsidecaller, struct ast_vm_user *vmu, int *duration, int *sound_duration, const char *unlockdir,
@@ -983,7 +950,6 @@
static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, const char *fromfolder, char *cidnum, char *cidname, char *attach, char *attach2, char *format, int duration, int attach_user_voicemail, struct ast_channel *chan, const char *category, int imap, const char *flag);
static void apply_options(struct ast_vm_user *vmu, const char *options);
static int add_email_attachment(FILE *p, struct ast_vm_user *vmu, char *format, char *attach, char *greeting_attachment, char *mailbox, char *bound, char *filename, int last, int msgnum);
-static int is_valid_dtmf(const char *key);
static void read_password_from_file(const char *secretfn, char *password, int passwordlen);
static int write_password_to_file(const char *secretfn, const char *password);
static const char *substitute_escapes(const char *value);
@@ -1083,8 +1049,8 @@
*/
static void populate_defaults(struct ast_vm_user *vmu)
{
- ast_copy_flags(vmu->flags, (&globalflags), AST_FLAGS_ALL);
- vmu->password_location = passwordlocation;
+ ast_copy_flags(vmu, (&globalflags), AST_FLAGS_ALL);
+ vmu->passwordlocation = passwordlocation;
if (saydurationminfo) {
vmu->saydurationm = saydurationminfo;
}
@@ -1457,28 +1423,6 @@
}
/*!
- * \brief Determines if a DTMF key entered is valid.
- * \param key The character to be compared. expects a single character. Though is capable of handling a string, this is internally copies using ast_strdupa.
- *
- * Tests the character entered against the set of valid DTMF characters.
- * \return 1 if the character entered is a valid DTMF digit, 0 if the character is invalid.
- */
-static int is_valid_dtmf(const char *key)
-{
- int i;
- char *local_key = ast_strdupa(key);
-
- for (i = 0; i < strlen(key); ++i) {
- if (!strchr(VALID_DTMF, *local_key)) {
- ast_log(AST_LOG_WARNING, "Invalid DTMF key \"%c\" used in voicemail configuration file\n", *local_key);
- return 0;
- }
- local_key++;
- }
- return 1;
-}
-
-/*!
* \brief Finds a voicemail user from the realtime engine.
* \param ivm
* \param context
@@ -1620,7 +1564,7 @@
ast_test_suite_event_notify("PASSWORDCHANGED", "Message: secret.conf updated with new password\r\nPasswordSource: secret.conf");
ast_verb(4, "Writing voicemail password to file %s succeeded\n", secretfn);
reset_user_pw(vmu->context, vmu->mailbox, newpassword);
- ast_string_field_set(vmu, password, newpassword);
+ ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
break;
} else {
ast_verb(4, "Writing voicemail password to file %s failed, falling back to config file\n", secretfn);
@@ -1654,7 +1598,7 @@
if (found) {
ast_test_suite_event_notify("PASSWORDCHANGED", "Message: voicemail.conf updated with new password\r\nPasswordSource: voicemail.conf");
reset_user_pw(vmu->context, vmu->mailbox, newpassword);
- ast_string_field_set(vmu, password, newpassword);
+ ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
ast_config_text_file_save(VOICEMAIL_CONFIG, cfg, "AppVoicemail");
break;
}
@@ -1694,21 +1638,21 @@
if (found) {
ast_test_suite_event_notify("PASSWORDCHANGED", "Message: users.conf updated with new password\r\nPasswordSource: users.conf");
reset_user_pw(vmu->context, vmu->mailbox, newpassword);
- ast_string_field_set(vmu, password, newpassword);
+ ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
ast_config_text_file_save("users.conf", cfg, "AppVoicemail");
}
}
}
}
-static void vm_change_password_shell(struct ast_vm_user *vmu, char *newpassword)
+static void vm_change_password_shell(struct ast_vm_config *vconfig, struct ast_vm_user *vmu, char *newpassword)
{
char buf[255];
- snprintf(buf, sizeof(buf), "%s %s %s %s", ext_pass_cmd, vmu->context, vmu->mailbox, newpassword);
+ snprintf(buf, sizeof(buf), "%s %s %s %s", vconfig->extern_pass_cmd, vmu->context, vmu->mailbox, newpassword);
ast_debug(1, "External password: %s\n",buf);
if (!ast_safe_system(buf)) {
ast_test_suite_event_notify("PASSWORDCHANGED", "Message: external script updated with new password\r\nPasswordSource: external");
- ast_string_field_set(vmu, password, newpassword);
+ ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
/* Reset the password in memory, too */
reset_user_pw(vmu->context, vmu->mailbox, newpassword);
}
@@ -4141,7 +4085,7 @@
}
closedir(msgdir);
- for (x = 0; x < vmu->max_messages; x++) {
+ for (x = 0; x < vmu->maxmsg; x++) {
if (map[x] == 1) {
stopcount--;
} else if (map[x] == 0 && !stopcount) {
@@ -6353,11 +6297,11 @@
{
int bytes = 0;
bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_CENT, 0, "Comedian Mail", "");
- bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, "(C)2002-2006 Digium, Inc.", "");
+ bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, "(C)2002-2012 Digium, Inc.", "");
return bytes;
}
-static int adsi_load_vmail(struct ast_channel *chan, int *useadsi)
+static int adsi_load_vmail(struct ast_channel *chan, struct ast_vm_config *vconfig, int *useadsi)
{
unsigned char buf[256];
int bytes = 0;
@@ -6378,7 +6322,10 @@
bytes += ast_adsi_data_mode(buf + bytes);
ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
- if (ast_adsi_begin_download(chan, addesc, adsifdn, adsisec, adsiver)) {
+ if (ast_adsi_begin_download(chan, addesc,
+ vconfig->adsi_config->adsifdn,
+ vconfig->adsi_config->adsisec,
+ vconfig->adsi_config->adsiver)) {
bytes = 0;
bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Load Cancelled.", "");
bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "ADSI Unavailable", "");
@@ -6476,7 +6423,9 @@
bytes = 0;
/* Load the session now */
- if (ast_adsi_load_session(chan, adsifdn, adsiver, 1) == 1) {
+ if (ast_adsi_load_session(chan,
+ vconfig->adsi_config->adsifdn,
+ vconfig->adsi_config->adsiver, 1) == 1) {
*useadsi = 1;
bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Scripts Loaded!", "");
} else
@@ -6488,19 +6437,27 @@
static void adsi_begin(struct ast_channel *chan, int *useadsi)
{
+ struct ast_vm_config *vconfig;
int x;
- if (!ast_adsi_available(chan))
+ if (!ast_adsi_available(chan)) {
return;
- x = ast_adsi_load_session(chan, adsifdn, adsiver, 1);
- if (x < 0)
+ }
+ vconfig = vm_get_config();
+ x = ast_adsi_load_session(chan,
+ vconfig->adsi_config->adsifdn,
+ vconfig->adsi_config->adsiver, 1);
+ if (x < 0) {
+ ao2_ref(vconfig, -1);
return;
+ }
if (!x) {
- if (adsi_load_vmail(chan, useadsi)) {
+ if (adsi_load_vmail(chan, vconfig, useadsi)) {
ast_log(AST_LOG_WARNING, "Unable to upload voicemail scripts\n");
- return;
- }
- } else
+ }
+ } else {
*useadsi = 1;
+ }
+ ao2_ref(vconfig, -1);
}
static void adsi_login(struct ast_channel *chan)
@@ -6941,6 +6898,7 @@
static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu, char *curdir, int curmsg, char *vm_fmts,
char *context, signed char record_gain, long *duration, struct vm_state *vms, char *flag)
{
+ struct ast_vm_config *vconfig = vm_get_config();
int cmd = 0;
int retries = 0, prepend_duration = 0, already_recorded = 0;
char msgfile[PATH_MAX], backup[PATH_MAX], backup_textfile[PATH_MAX];
@@ -7018,8 +6976,8 @@
cmd = ast_play_and_prepend(chan, NULL, msgfile, 0, vm_fmts, &prepend_duration, NULL, 1, silencethreshold, maxsilence);
if (cmd == 'S') { /* If we timed out, tell the user it didn't work properly and clean up the files */
- ast_stream_and_wait(chan, vm_pls_try_again, ""); /* this might be removed if a proper vm_prepend_timeout is ever recorded */
- ast_stream_and_wait(chan, vm_prepend_timeout, "");
+ ast_stream_and_wait(chan, vconfig->sound_config->vm_pls_try_again, ""); /* this might be removed if a proper vm_prepend_timeout is ever recorded */
+ ast_stream_and_wait(chan, vconfig->sound_config->vm_prepend_timeout, "");
ast_filerename(backup, msgfile, NULL);
}
@@ -7089,6 +7047,7 @@
rename(backup_textfile, textfile);
}
+ ao2_ref(vconfig, -1);
if (cmd == 't' || cmd == 'S') /* XXX entering this block with a value of 'S' is probably no longer possible. */
cmd = 0;
return cmd;
@@ -7545,10 +7504,15 @@
return res;
}
-static int wait_file(struct ast_channel *chan, struct vm_state *vms, char *file)
+static int wait_file(struct ast_channel *chan, struct ast_vm_config *vmconfig, struct vm_state *vms, char *file)
{
ast_test_suite_event_notify("PLAYVOICE", "Message: Playing %s", file);
- return ast_control_streamfile(chan, file, listen_control_forward_key, listen_control_reverse_key, listen_control_stop_key, listen_control_pause_key, listen_control_restart_key, skipms, NULL);
+ return ast_control_streamfile(chan, file,
+ vmconfig->listen_control_config->listen_control_forward_key,
+ vmconfig->listen_control_config->listen_control_reverse_key,
+ vmconfig->listen_control_config->listen_control_stop_key,
+ vmconfig->listen_control_config->listen_control_pause_key,
+ vmconfig->listen_control_config->listen_control_restart_key, skipms, NULL);
}
static int play_message_category(struct ast_channel *chan, const char *category)
@@ -7774,6 +7738,7 @@
const char *origtime, *context, *category, *duration, *flag;
struct ast_config *msg_cfg;
struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE };
+ struct ast_vm_config *vmconfig = vm_get_config();
vms->starting = 0;
make_file(vms->fn, sizeof(vms->fn), vms->curdir, vms->curmsg);
@@ -7911,10 +7876,10 @@
* as a separate file from the rest of the message
*/
if (!ast_strlen_zero(vms->introfn) && ast_fileexists(vms->introfn, NULL, NULL) > 0) {
- wait_file(chan, vms, vms->introfn);
+ wait_file(chan, vmconfig, vms, vms->introfn);
}
#endif
- if ((res = wait_file(chan, vms, vms->fn)) < 0) {
+ if ((res = wait_file(chan, vmconfig, vms, vms->fn)) < 0) {
ast_log(AST_LOG_WARNING, "Playback of message %s failed\n", vms->fn);
res = 0;
}
@@ -9304,6 +9269,7 @@
char prefile[PATH_MAX] = "";
unsigned char buf[256];
int bytes = 0;
+ struct ast_vm_config *vconfig;
ast_test_suite_event_notify("NEWUSER", "Message: entering new user state");
if (ast_adsi_available(chan)) {
@@ -9346,48 +9312,63 @@
* Change the password last since new users will be able to skip over any steps this one comes before
* by hanging up and calling back to voicemail main since the password is used to verify new user status.
*/
+ vconfig = vm_get_config();
for (;;) {
newpassword[1] = '\0';
- newpassword[0] = cmd = ast_play_and_wait(chan, vm_newpassword);
- if (cmd == '#')
+ newpassword[0] = cmd = ast_play_and_wait(chan, vconfig->sound_config->vm_newpassword);
+ if (cmd == '#') {
newpassword[0] = '\0';
- if (cmd < 0 || cmd == 't' || cmd == '#')
+ }
+ if (cmd < 0 || cmd == 't' || cmd == '#') {
+ ao2_ref(vconfig, -1);
return cmd;
+ }
cmd = ast_readstring(chan, newpassword + strlen(newpassword), sizeof(newpassword) - 1, 2000, 10000, "#");
- if (cmd < 0 || cmd == 't' || cmd == '#')
+ if (cmd < 0 || cmd == 't' || cmd == '#') {
+ ao2_ref(vconfig, -1);
return cmd;
+ }
cmd = check_password(vmu, newpassword); /* perform password validation */
if (cmd != 0) {
ast_log(AST_LOG_NOTICE, "Invalid password for user %s (%s)\n", vms->username, newpassword);
- cmd = ast_play_and_wait(chan, vm_invalid_password);
+ cmd = ast_play_and_wait(chan, vconfig->sound_config->vm_invalid_password);
} else {
newpassword2[1] = '\0';
- newpassword2[0] = cmd = ast_play_and_wait(chan, vm_reenterpassword);
+ newpassword2[0] = cmd = ast_play_and_wait(chan, vconfig->sound_config->vm_reenter_password);
if (cmd == '#')
newpassword2[0] = '\0';
- if (cmd < 0 || cmd == 't' || cmd == '#')
+ if (cmd < 0 || cmd == 't' || cmd == '#') {
+ ao2_ref(vconfig, -1);
return cmd;
+ }
cmd = ast_readstring(chan, newpassword2 + strlen(newpassword2), sizeof(newpassword2) - 1, 2000, 10000, "#");
- if (cmd < 0 || cmd == 't' || cmd == '#')
+ if (cmd < 0 || cmd == 't' || cmd == '#') {
+ ao2_ref(vconfig, -1);
return cmd;
+ }
if (!strcmp(newpassword, newpassword2))
break;
ast_log(AST_LOG_NOTICE, "Password mismatch for user %s (%s != %s)\n", vms->username, newpassword, newpassword2);
- cmd = ast_play_and_wait(chan, vm_mismatch);
- }
- if (++tries == 3)
+ cmd = ast_play_and_wait(chan, vconfig->sound_config->vm_mismatch);
+ }
+ if (++tries == 3) {
+ ao2_ref(vconfig, -1);
return -1;
+ }
if (cmd != 0) {
- cmd = ast_play_and_wait(chan, vm_pls_try_again);
- }
- }
- if (pwdchange & PWDCHANGE_INTERNAL)
+ cmd = ast_play_and_wait(chan, vconfig->sound_config->vm_pls_try_again);
+ }
+ }
+ if (pwdchange & PWDCHANGE_INTERNAL) {
vm_change_password(vmu, newpassword);
- if ((pwdchange & PWDCHANGE_EXTERNAL) && !ast_strlen_zero(ext_pass_cmd))
- vm_change_password_shell(vmu, newpassword);
+ }
+ if ((pwdchange & PWDCHANGE_EXTERNAL) && !ast_strlen_zero(vconfig->extern_pass_cmd)) {
+ vm_change_password_shell(vconfig, vmu, newpassword);
+ }
ast_debug(1, "User %s set password to %s of length %d\n", vms->username, newpassword, (int) strlen(newpassword));
- cmd = ast_play_and_wait(chan, vm_passchanged);
+ cmd = ast_play_and_wait(chan, vconfig->sound_config->vm_password_changed);
+ ao2_ref(vconfig, -1);
return cmd;
}
@@ -9402,6 +9383,7 @@
char prefile[PATH_MAX] = "";
unsigned char buf[256];
int bytes = 0;
+ struct ast_vm_config *vconfig = vm_get_config();
ast_test_suite_event_notify("VMOPTIONS", "Message: entering mailbox options");
if (ast_adsi_available(chan)) {
@@ -9437,7 +9419,7 @@
break;
}
newpassword[1] = '\0';
- newpassword[0] = cmd = ast_play_and_wait(chan, vm_newpassword);
+ newpassword[0] = cmd = ast_play_and_wait(chan, vconfig->sound_config->vm_newpassword);
if (cmd == '#')
newpassword[0] = '\0';
else {
@@ -9450,14 +9432,14 @@
cmd = check_password(vmu, newpassword); /* perform password validation */
if (cmd != 0) {
ast_log(AST_LOG_NOTICE, "Invalid password for user %s (%s)\n", vms->username, newpassword);
- cmd = ast_play_and_wait(chan, vm_invalid_password);
+ cmd = ast_play_and_wait(chan, vconfig->sound_config->vm_invalid_password);
if (!cmd) {
- cmd = ast_play_and_wait(chan, vm_pls_try_again);
+ cmd = ast_play_and_wait(chan, vconfig->sound_config->vm_pls_try_again);
}
break;
}
newpassword2[1] = '\0';
- newpassword2[0] = cmd = ast_play_and_wait(chan, vm_reenterpassword);
+ newpassword2[0] = cmd = ast_play_and_wait(chan, vconfig->sound_config->vm_reenter_password);
if (cmd == '#')
newpassword2[0] = '\0';
else {
@@ -9470,9 +9452,9 @@
}
if (strcmp(newpassword, newpassword2)) {
ast_log(AST_LOG_NOTICE, "Password mismatch for user %s (%s != %s)\n", vms->username, newpassword, newpassword2);
- cmd = ast_play_and_wait(chan, vm_mismatch);
+ cmd = ast_play_and_wait(chan, vconfig->sound_config->vm_mismatch);
if (!cmd) {
- cmd = ast_play_and_wait(chan, vm_pls_try_again);
+ cmd = ast_play_and_wait(chan, vconfig->sound_config->vm_pls_try_again);
}
break;
}
@@ -9480,13 +9462,13 @@
if (pwdchange & PWDCHANGE_INTERNAL) {
vm_change_password(vmu, newpassword);
}
- if ((pwdchange & PWDCHANGE_EXTERNAL) && !ast_strlen_zero(ext_pass_cmd)) {
- vm_change_password_shell(vmu, newpassword);
+ if ((pwdchange & PWDCHANGE_EXTERNAL) && !ast_strlen_zero(vconfig->extern_pass_cmd)) {
+ vm_change_password_shell(vconfig, vmu, newpassword);
}
ast_debug(1, "User %s set password to %s of length %d\n",
vms->username, newpassword, (int) strlen(newpassword));
- cmd = ast_play_and_wait(chan, vm_passchanged);
+ cmd = ast_play_and_wait(chan, vconfig->sound_config->vm_password_changed);
break;
case '*':
cmd = 't';
@@ -9514,8 +9496,10 @@
ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd);
}
}
- if (cmd == 't')
+ if (cmd == 't') {
cmd = 0;
+ }
+ ao2_ref(vconfig, -1);
return cmd;
}
@@ -9850,6 +9834,7 @@
int useadsi = 0, valid = 0, logretries = 0;
char password[AST_MAX_EXTENSION]="", *passptr;
struct ast_vm_user vmus, *vmu = NULL;
+ struct ast_vm_config *vconfig;
/* If ADSI is supported, setup login screen */
adsi_begin(chan, &useadsi);
@@ -9903,11 +9888,14 @@
/* saved password is blank, so don't bother asking */
password[0] = '\0';
} else {
- ast_test_suite_event_notify("PLAYBACK", "Message: %s", vm_password);
- if (ast_streamfile(chan, vm_password, ast_channel_language(chan))) {
+ vconfig = vm_get_config();
+ ast_test_suite_event_notify("PLAYBACK", "Message: %s", vconfig->sound_config->vm_password);
+ if (ast_streamfile(chan, vconfig->sound_config->vm_password, ast_channel_language(chan))) {
ast_log(AST_LOG_WARNING, "Unable to stream password file\n");
+ ao2_ref(vconfig, -1);
return -1;
}
+ ao2_ref(vconfig, -1);
if (ast_readstring(chan, password, sizeof(password) - 1, 2000, 10000, "#") < 0) {
ast_log(AST_LOG_WARNING, "Unable to read password\n");
return -1;
@@ -9994,6 +9982,7 @@
#ifdef IMAP_STORAGE
int deleted = 0;
#endif
+ struct ast_vm_config *vmconfig;
/* Add the vm_state to the active list and keep it active */
memset(&vms, 0, sizeof(vms));
@@ -10086,6 +10075,7 @@
else
valid = 0;
}
+ vmconfig = vm_get_config();
if (!valid)
res = vm_authenticate(chan, vms.username, sizeof(vms.username), &vmus, context, prefixstr, skipuser, maxlogins, 0);
@@ -10288,7 +10278,7 @@
switch (cmd) {
case '1': /* Reply */
if (vms.lastmsg > -1 && !vms.starting) {
- cmd = advanced_options(chan, vmu, &vms, vms.curmsg, 1, record_gain);
+ cmd = advanced_options(chan, vmconfig, vmu, &vms, vms.curmsg, 1, record_gain);
if (cmd == ERROR_LOCK_PATH || cmd == OPERATOR_EXIT) {
res = cmd;
goto out;
@@ -10302,7 +10292,7 @@
if (!vms.starting)
ast_verb(3, "Callback Requested\n");
if (!ast_strlen_zero(vmu->callback) && vms.lastmsg > -1 && !vms.starting) {
- cmd = advanced_options(chan, vmu, &vms, vms.curmsg, 2, record_gain);
+ cmd = advanced_options(chan, vmconfig, vmu, &vms, vms.curmsg, 2, record_gain);
if (cmd == 9) {
silentexit = 1;
goto out;
@@ -10317,7 +10307,7 @@
break;
case '3': /* Envelope */
if (vms.lastmsg > -1 && !vms.starting) {
- cmd = advanced_options(chan, vmu, &vms, vms.curmsg, 3, record_gain);
+ cmd = advanced_options(chan, vmconfig, vmu, &vms, vms.curmsg, 3, record_gain);
if (cmd == ERROR_LOCK_PATH) {
res = cmd;
goto out;
@@ -10711,6 +10701,7 @@
vmstate_delete(&vms);
}
#endif
+ ao2_ref(vmconfig, -1);
if (vmu)
free_user(vmu);
@@ -12041,6 +12032,16 @@
}
#endif
+static void load_smdi(struct ast_vm_config *vconfig)
+{
+ if (vconfig->smdi_config->enabled) {
+ if (!(smdi_iface = ast_smdi_interface_find(vconfig->smdi_config->smdi_interface))) {
+ ast_log(AST_LOG_ERROR, "No valid SMDI interface specfied, disabling SMDI voicemail notification\n");
+ vconfig->smdi_config->enabled = 0;
+ }
+ }
+}
+
static int actual_load_config(int reload, struct ast_config *cfg, struct ast_config *ucfg)
{
struct ast_vm_user *current;
@@ -12049,18 +12050,14 @@
const char *val;
char *q, *stringp, *tmp;
int x;
- int tmpadsi[4];
char secretfn[PATH_MAX] = "";
+
+ /* TODO: FIX THIS */
+ load_smdi(NULL);
#ifdef IMAP_STORAGE
ast_copy_string(imapparentfolder, "\0", sizeof(imapparentfolder));
#endif
- /* set audio control prompts */
- strcpy(listen_control_forward_key, DEFAULT_LISTEN_CONTROL_FORWARD_KEY);
- strcpy(listen_control_reverse_key, DEFAULT_LISTEN_CONTROL_REVERSE_KEY);
- strcpy(listen_control_pause_key, DEFAULT_LISTEN_CONTROL_PAUSE_KEY);
- strcpy(listen_control_restart_key, DEFAULT_LISTEN_CONTROL_RESTART_KEY);
- strcpy(listen_control_stop_key, DEFAULT_LISTEN_CONTROL_STOP_KEY);
/* Free all the users structure */
free_vm_users();
@@ -12069,9 +12066,6 @@
free_vm_zones();
AST_LIST_LOCK(&users);
-
- memset(ext_pass_cmd, 0, sizeof(ext_pass_cmd));
- memset(ext_pass_check_cmd, 0, sizeof(ext_pass_check_cmd));
if (cfg) {
/* General settings */
@@ -12155,16 +12149,16 @@
if ((val = ast_variable_retrieve(cfg, "general", "pagerdateformat"))) {
ast_copy_string(pagerdateformat, val, sizeof(pagerdateformat));
}
-
+ /* TODO: CRAP, externpass externpassynotify*/
/* External password changing command */
- if ((val = ast_variable_retrieve(cfg, "general", "externpass"))) {
+/* if ((val = ast_variable_retrieve(cfg, "general", "externpass"))) {
ast_copy_string(ext_pass_cmd, val, sizeof(ext_pass_cmd));
pwdchange = PWDCHANGE_EXTERNAL;
} else if ((val = ast_variable_retrieve(cfg, "general", "externpassnotify"))) {
ast_copy_string(ext_pass_cmd, val, sizeof(ext_pass_cmd));
pwdchange = PWDCHANGE_EXTERNAL | PWDCHANGE_INTERNAL;
}
-
+*/
/* External password validation command */
if ((val = ast_variable_retrieve(cfg, "general", "externpasscheck"))) {
ast_copy_string(ext_pass_check_cmd, val, sizeof(ext_pass_check_cmd));
@@ -12265,20 +12259,6 @@
ast_debug(1, "found externnotify: %s\n", externnotify);
} else {
externnotify[0] = '\0';
- }
-
- /* SMDI voicemail notification */
- if ((val = ast_variable_retrieve(cfg, "general", "smdienable")) && ast_true(val)) {
- ast_debug(1, "Enabled SMDI voicemail notification\n");
- if ((val = ast_variable_retrieve(cfg, "general", "smdiport"))) {
- smdi_iface = ast_smdi_interface_find(val);
- } else {
- ast_debug(1, "No SMDI interface set, trying default (/dev/ttyS0)\n");
- smdi_iface = ast_smdi_interface_find("/dev/ttyS0");
- }
- if (!smdi_iface) {
- ast_log(AST_LOG_ERROR, "No valid SMDI interface specfied, disabling SMDI voicemail notification\n");
- }
}
/* Silence treshold */
@@ -12506,38 +12486,6 @@
} else {
exitcontext[0] = '\0';
}
-
- /* load password sounds configuration */
- if ((val = ast_variable_retrieve(cfg, "general", "vm-password")))
- ast_copy_string(vm_password, val, sizeof(vm_password));
- if ((val = ast_variable_retrieve(cfg, "general", "vm-newpassword")))
- ast_copy_string(vm_newpassword, val, sizeof(vm_newpassword));
- if ((val = ast_variable_retrieve(cfg, "general", "vm-invalid-password")))
- ast_copy_string(vm_invalid_password, val, sizeof(vm_invalid_password));
- if ((val = ast_variable_retrieve(cfg, "general", "vm-passchanged")))
- ast_copy_string(vm_passchanged, val, sizeof(vm_passchanged));
- if ((val = ast_variable_retrieve(cfg, "general", "vm-reenterpassword")))
- ast_copy_string(vm_reenterpassword, val, sizeof(vm_reenterpassword));
- if ((val = ast_variable_retrieve(cfg, "general", "vm-mismatch")))
- ast_copy_string(vm_mismatch, val, sizeof(vm_mismatch));
- if ((val = ast_variable_retrieve(cfg, "general", "vm-pls-try-again"))) {
- ast_copy_string(vm_pls_try_again, val, sizeof(vm_pls_try_again));
- }
- if ((val = ast_variable_retrieve(cfg, "general", "vm-prepend-timeout"))) {
- ast_copy_string(vm_prepend_timeout, val, sizeof(vm_prepend_timeout));
- }
- /* load configurable audio prompts */
- if ((val = ast_variable_retrieve(cfg, "general", "listen-control-forward-key")) && is_valid_dtmf(val))
- ast_copy_string(listen_control_forward_key, val, sizeof(listen_control_forward_key));
- if ((val = ast_variable_retrieve(cfg, "general", "listen-control-reverse-key")) && is_valid_dtmf(val))
- ast_copy_string(listen_control_reverse_key, val, sizeof(listen_control_reverse_key));
- if ((val = ast_variable_retrieve(cfg, "general", "listen-control-pause-key")) && is_valid_dtmf(val))
- ast_copy_string(listen_control_pause_key, val, sizeof(listen_control_pause_key));
- if ((val = ast_variable_retrieve(cfg, "general", "listen-control-restart-key")) && is_valid_dtmf(val))
- ast_copy_string(listen_control_restart_key, val, sizeof(listen_control_restart_key));
- if ((val = ast_variable_retrieve(cfg, "general", "listen-control-stop-key")) && is_valid_dtmf(val))
- ast_copy_string(listen_control_stop_key, val, sizeof(listen_control_stop_key));
-
if (!(val = ast_variable_retrieve(cfg, "general", "usedirectory")))
val = "no";
ast_set2_flag((&globalflags), ast_true(val), VM_DIRECFORWARD);
@@ -12590,23 +12538,6 @@
ast_copy_string(pagerfromstring, val, sizeof(pagerfromstring));
if ((val = ast_variable_retrieve(cfg, "general", "charset")))
ast_copy_string(charset, val, sizeof(charset));
- if ((val = ast_variable_retrieve(cfg, "general", "adsifdn"))) {
- sscanf(val, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]);
- for (x = 0; x < 4; x++) {
- memcpy(&adsifdn[x], &tmpadsi[x], 1);
- }
- }
- if ((val = ast_variable_retrieve(cfg, "general", "adsisec"))) {
- sscanf(val, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]);
- for (x = 0; x < 4; x++) {
- memcpy(&adsisec[x], &tmpadsi[x], 1);
- }
- }
- if ((val = ast_variable_retrieve(cfg, "general", "adsiver"))) {
- if (atoi(val)) {
- adsiver = atoi(val);
- }
- }
if ((val = ast_variable_retrieve(cfg, "general", "tz"))) {
ast_copy_string(zonetag, val, sizeof(zonetag));
}
@@ -13360,6 +13291,7 @@
res |= AST_TEST_UNREGISTER(test_voicemail_notify_endl);
res |= AST_TEST_UNREGISTER(test_voicemail_load_config);
res |= AST_TEST_UNREGISTER(test_voicemail_vm_info);
+ vm_unregister_config_tests();
#endif
ast_cli_unregister_multiple(cli_voicemail, ARRAY_LEN(cli_voicemail));
ast_uninstall_vm_functions();
@@ -13412,6 +13344,7 @@
res |= AST_TEST_REGISTER(test_voicemail_notify_endl);
res |= AST_TEST_REGISTER(test_voicemail_load_config);
res |= AST_TEST_REGISTER(test_voicemail_vm_info);
+ vm_register_config_tests();
#endif
if (res)
@@ -13498,7 +13431,7 @@
*
* \return zero on success, -1 on error.
*/
-static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int msg, int option, signed char record_gain)
+static int advanced_options(struct ast_channel *chan, struct ast_vm_config *vmconfig, struct ast_vm_user *vmu, struct vm_state *vms, int msg, int option, signed char record_gain)
{
int res = 0;
char filename[PATH_MAX];
@@ -13686,9 +13619,10 @@
if (!res) {
make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);
vms->heard[msg] = 1;
- res = wait_file(chan, vms, vms->fn);
+ res = wait_file(chan, vmconfig, vms, vms->fn);
}
#endif
+
return res;
}
Modified: team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/include/voicemail.h
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/include/voicemail.h?view=diff&rev=403172&r1=403171&r2=403172
==============================================================================
--- team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/include/voicemail.h (original)
+++ team/mjordan/voicemail_refactor_11_10_19/apps/voicemail/include/voicemail.h Wed Nov 27 08:54:42 2013
@@ -79,11 +79,47 @@
VM_OPT_BACKEND_REALTIME
};
-struct vm_backend_tech {
- int (* const load_voicemail_config)(struct ast_config *cfg);
-
- int (* const load_voicemail_users)(const struct vm_config * const vmcfg, struct ast_config *ucfg, struct ao2_container *user_container);
-};
+//struct vm_backend_tech {
+// int (* const load_voicemail_config)(struct ast_config *cfg);
+//
+// int (* const load_voicemail_users)(const struct ast_vm_config * const vmcfg, struct ast_config *ucfg, struct ao2_container *user_container);
+//};
+
+
+#ifdef IMAP_STORAGE
+
+struct vm_imap_config {
+ char delimiter;
+ int version;
+ int read_timeout;
+ int write_timeout;
+ int open_timeout;
+ int close_timeout;
+ unsigned int expunge_on_hangup;
+ unsigned int greetings;
+ AST_DECLARE_STRING_FIELDS(
+ AST_STRING_FIELD(server);
+ AST_STRING_FIELD(port);
+ AST_STRING_FIELD(server_flags);
+ AST_STRING_FIELD(folder);
+ AST_STRING_FIELD(parent_folder);
+ AST_STRING_FIELD(greeting_folder);
+ AST_STRING_FIELD(auth_user);
+ AST_STRING_FIELD(auth_password);
+ );
+};
+#endif
+
+#ifdef ODBC_STORAGE
+
+struct vm_odbc_config {
+ AST_DECLARE_STRING_FIELDS(
+ AST_STRING_FIELD(database);
+ AST_STRING_FIELD(table);
+ );
+};
+
+#endif
struct vm_sound_config {
AST_DECLARE_STRING_FIELDS(
@@ -94,6 +130,7 @@
AST_STRING_FIELD(vm_reenter_password);
AST_STRING_FIELD(vm_mismatch);
AST_STRING_FIELD(vm_pls_try_again);
+ AST_STRING_FIELD(vm_prepend_timeout);
);
};
@@ -128,40 +165,40 @@
);
};
-struct ast_vm_user {
- char context[AST_MAX_CONTEXT]; /*!< Voicemail context */
- char mailbox[AST_MAX_EXTENSION]; /*!< Mailbox id, unique within vm context */
- char language[MAX_LANGUAGE]; /*!< Config: Language setting */
- char callback[AST_MAX_CONTEXT]; /*!< Callback context */
- char dialout[AST_MAX_CONTEXT]; /*!< Dialout context */
- char uniqueid[80]; /*!< Unique integer identifier TODO: make this an integer? */
- char exit[AST_MAX_CONTEXT]; /*!< Context to exit out to */
- char attachfmt[MAX_FORMAT_LENGTH]; /*!< Attachment format */
- int min_say_duration; /*!< Minimum number of seconds for say */
- int min_message_duration; /*!< Minimum number of seconds per message for this mailbox */
- int max_messages; /*!< Maximum number of msgs per folder for this mailbox */
- int max_deleted_messages; /*!< Maximum number of deleted msgs saved for this mailbox */
- int max_message_duration; /*!< Maximum number of seconds per message for this mailbox */
- int hash_key;
- enum vm_passwordlocation password_location; /*!< Storage location of the password */
- double volgain; /*!< Volume gain for voicemails sent via email */
- struct ast_flags flags; /*!< VM_ flags */
- AST_DECLARE_STRING_FIELDS(
- AST_STRING_FIELD(fullname);
- AST_STRING_FIELD(password);
- AST_STRING_FIELD(email_address);
- AST_STRING_FIELD(email_subject);
- AST_STRING_FIELD(email_body);
- AST_STRING_FIELD(pager_address);
- AST_STRING_FIELD(pager_subject);
- AST_STRING_FIELD(pager_body);
- AST_STRING_FIELD(email_from_address);
- AST_STRING_FIELD(locale);
- AST_STRING_FIELD(mail_command);
- AST_STRING_FIELD(zonetag);
- AST_STRING_FIELD(timezone);
- );
-};
+//struct ast_vm_user {
+// char context[AST_MAX_CONTEXT]; /*!< Voicemail context */
+// char mailbox[AST_MAX_EXTENSION]; /*!< Mailbox id, unique within vm context */
+// char language[MAX_LANGUAGE]; /*!< Config: Language setting */
+// char callback[AST_MAX_CONTEXT]; /*!< Callback context */
+// char dialout[AST_MAX_CONTEXT]; /*!< Dialout context */
+// char uniqueid[80]; /*!< Unique integer identifier TODO: make this an integer? */
+// char exit[AST_MAX_CONTEXT]; /*!< Context to exit out to */
+// char attachfmt[MAX_FORMAT_LENGTH]; /*!< Attachment format */
+// int min_say_duration; /*!< Minimum number of seconds for say */
+// int min_message_duration; /*!< Minimum number of seconds per message for this mailbox */
+// int max_messages; /*!< Maximum number of msgs per folder for this mailbox */
+// int max_deleted_messages; /*!< Maximum number of deleted msgs saved for this mailbox */
+// int max_message_duration; /*!< Maximum number of seconds per message for this mailbox */
+// int hash_key;
+// enum vm_passwordlocation password_location; /*!< Storage location of the password */
+// double volgain; /*!< Volume gain for voicemails sent via email */
+// struct ast_flags flags; /*!< VM_ flags */
+// AST_DECLARE_STRING_FIELDS(
+// AST_STRING_FIELD(fullname);
+// AST_STRING_FIELD(password);
+// AST_STRING_FIELD(email_address);
+// AST_STRING_FIELD(email_subject);
+// AST_STRING_FIELD(email_body);
+// AST_STRING_FIELD(pager_address);
+// AST_STRING_FIELD(pager_subject);
+// AST_STRING_FIELD(pager_body);
+// AST_STRING_FIELD(email_from_address);
+// AST_STRING_FIELD(locale);
+// AST_STRING_FIELD(mail_command);
+// AST_STRING_FIELD(zonetag);
+// AST_STRING_FIELD(timezone);
+// );
+//};
/* Stuff we'll need for IMAP:
* imapfolder
@@ -171,7 +208,7 @@
* imapversion (int)
*/
-struct vm_config {
+struct ast_vm_config {
double volgain;
unsigned int max_silence;
unsigned int max_deleted_messages;
@@ -197,10 +234,16 @@
char extern_pass_cmd[PATH_MAX];
char extern_pass_check_cmd[PATH_MAX];
char directory_intro_path[PATH_MAX];
- struct vm_sound_config * sound_config;
- struct vm_listen_control_config * listen_control_config;
- struct vm_smdi_config * smdi_config;
- struct vm_adsi_config * adsi_config;
+ struct vm_sound_config *sound_config;
+ struct vm_listen_control_config *listen_control_config;
+ struct vm_smdi_config *smdi_config;
+ struct vm_adsi_config *adsi_config;
+#ifdef IMAP_STORAGE
+ struct vm_imap_config *imap_config;
+#endif
+#ifdef ODBC_STORAGE
+ struct vm_odbc_config *odbc_config;
+#endif
struct ast_flags globalflags;
struct ast_flags passwordflags;
AST_DECLARE_STRING_FIELDS(
@@ -222,31 +265,31 @@
/*! \brief Obtain a reference to the current voicemail configuration
*
- * \note The vm_config object is a ref counted object. Calling this method automatically
+ * \note The ast_vm_config object is a ref counted object. Calling this method automatically
* increases that reference count by 1 - when finished with the object, the caller of this
* method must decrease the reference count.
*
[... 4162 lines stripped ...]
More information about the asterisk-commits
mailing list