<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][15663] </title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=15663">15663</a></dd>
<dt>Author</dt> <dd>brian</dd>
<dt>Date</dt> <dd>2009-11-24 18:23:07 -0600 (Tue, 24 Nov 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre> voicemail tweaks </pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunkconflangenvmsoundsxml">freeswitch/trunk/conf/lang/en/vm/sounds.xml</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_voicemailmod_voicemailc">freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunkconflangenvmsoundsxml"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/conf/lang/en/vm/sounds.xml (15662 => 15663)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/conf/lang/en/vm/sounds.xml        2009-11-25 00:03:00 UTC (rev 15662)
+++ freeswitch/trunk/conf/lang/en/vm/sounds.xml        2009-11-25 00:23:07 UTC (rev 15663)
</span><span class="lines">@@ -28,7 +28,7 @@
</span><span class="cx"> <macro name="voicemail_hello">
</span><span class="cx"> <input pattern="(.*)">
</span><span class="cx"> <match>
</span><del>-        <action function="play-file" data="voicemail/vm-hello.wav"/>
</del><ins>+        <!--<action function="play-file" data="voicemail/vm-hello.wav"/> -->
</ins><span class="cx"> </match>
</span><span class="cx"> </input>
</span><span class="cx"> </macro>
</span><span class="lines">@@ -56,7 +56,6 @@
</span><span class="cx">         <action function="say" data="$1" method="pronounced" type="items"/>
</span><span class="cx">         <action function="play-file" data="voicemail/vm-$2.wav"/>
</span><span class="cx">         <action function="play-file" data="voicemail/vm-message.wav"/>
</span><del>-        <action function="play-file" data="voicemail/vm-in_folder.wav"/>
</del><span class="cx"> </match>
</span><span class="cx"> </input>
</span><span class="cx"> <input pattern="^(\d+):(.*)$">
</span><span class="lines">@@ -65,7 +64,6 @@
</span><span class="cx">         <action function="say" data="$1" method="pronounced" type="items"/>
</span><span class="cx">         <action function="play-file" data="voicemail/vm-$2.wav"/>
</span><span class="cx">         <action function="play-file" data="voicemail/vm-messages.wav"/>
</span><del>-        <action function="play-file" data="voicemail/vm-in_folder.wav"/>
</del><span class="cx"> </match>
</span><span class="cx"> </input>
</span><span class="cx"> </macro>
</span><span class="lines">@@ -89,7 +87,6 @@
</span><span class="cx"> </input>
</span><span class="cx"> </macro>
</span><span class="cx">
</span><del>-
</del><span class="cx"> <macro name="voicemail_config_menu">
</span><span class="cx"> <input pattern="^([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*])$">
</span><span class="cx"> <match>
</span><span class="lines">@@ -112,7 +109,6 @@
</span><span class="cx"> </input>
</span><span class="cx"> </macro>
</span><span class="cx">
</span><del>-
</del><span class="cx"> <macro name="voicemail_record_name">
</span><span class="cx"> <input pattern="^(.*)$">
</span><span class="cx"> <match>
</span><span class="lines">@@ -182,7 +178,7 @@
</span><span class="cx"> </macro>
</span><span class="cx">
</span><span class="cx"> <macro name="voicemail_listen_file_check">
</span><del>- <input pattern="^([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*])$">
</del><ins>+ <input pattern="^([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*]):(.*)$">
</ins><span class="cx"> <match>
</span><span class="cx">         <action function="play-file" data="voicemail/vm-listen_to_recording.wav"/>
</span><span class="cx">         <action function="play-file" data="voicemail/vm-press.wav"/>
</span><span class="lines">@@ -204,6 +200,25 @@
</span><span class="cx">         <action function="say" data="$6" method="pronounced" type="name_spelled"/>
</span><span class="cx"> </match>
</span><span class="cx"> </input>
</span><ins>+ <input pattern="^([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*])$">
+ <match>
+        <action function="play-file" data="voicemail/vm-listen_to_recording.wav"/>
+        <action function="play-file" data="voicemail/vm-press.wav"/>
+        <action function="say" data="$1" method="pronounced" type="name_spelled"/>
+        <action function="play-file" data="voicemail/vm-save_recording.wav"/>
+        <action function="play-file" data="voicemail/vm-press.wav"/>
+        <action function="say" data="$2" method="pronounced" type="name_spelled"/>
+        <action function="play-file" data="voicemail/vm-delete_recording.wav"/>
+        <action function="play-file" data="voicemail/vm-press.wav"/>
+        <action function="say" data="$3" method="pronounced" type="name_spelled"/>
+        <action function="play-file" data="voicemail/vm-return_call.wav"/>
+        <action function="play-file" data="voicemail/vm-press.wav"/>
+        <action function="say" data="$5" method="pronounced" type="name_spelled"/>
+        <action function="play-file" data="voicemail/vm-to_forward.wav"/>
+        <action function="play-file" data="voicemail/vm-press.wav"/>
+        <action function="say" data="$6" method="pronounced" type="name_spelled"/>
+ </match>
+ </input>
</ins><span class="cx"> </macro>
</span><span class="cx">
</span><span class="cx"> <macro name="voicemail_choose_greeting">
</span><span class="lines">@@ -363,7 +378,4 @@
</span><span class="cx"> </match>
</span><span class="cx"> </input>
</span><span class="cx"> </macro>
</span><del>-
-
-
</del><span class="cx"> </include><!--This line will be ignored it's here to validate the xml and is optional -->
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_voicemailmod_voicemailc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (15662 => 15663)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c        2009-11-25 00:03:00 UTC (rev 15662)
+++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c        2009-11-25 00:23:07 UTC (rev 15663)
</span><span class="lines">@@ -153,81 +153,89 @@
</span><span class="cx"> };
</span><span class="cx"> typedef struct vm_profile vm_profile_t;
</span><span class="cx">
</span><ins>+
+switch_cache_db_handle_t *vm_get_db_handle(vm_profile_t *profile)
+{
+        switch_cache_db_connection_options_t options = { {0} };
+        switch_cache_db_handle_t *dbh = NULL;
+        
+        if (profile->odbc_dsn && profile->odbc_user && profile->odbc_pass) {
+                options.odbc_options.dsn = profile->odbc_dsn;
+                options.odbc_options.user = profile->odbc_user;
+                options.odbc_options.pass = profile->odbc_pass;
+
+                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_ODBC, &options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
+                return dbh;
+        } else {
+                options.core_db_options.db_path = profile->dbname;
+                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_CORE_DB, &options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
+                return dbh;
+        }
+}
+
+
</ins><span class="cx"> static switch_status_t vm_execute_sql(vm_profile_t *profile, char *sql, switch_mutex_t *mutex)
</span><span class="cx"> {
</span><del>-        switch_core_db_t *db;
-        switch_status_t status = SWITCH_STATUS_SUCCESS;
</del><ins>+        switch_cache_db_handle_t *dbh = NULL;
+        switch_status_t status = SWITCH_STATUS_FALSE;
</ins><span class="cx">
</span><span class="cx">         if (mutex) {
</span><span class="cx">                 switch_mutex_lock(mutex);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (switch_odbc_available() && profile->odbc_dsn) {
-                switch_odbc_statement_handle_t stmt;
-                if (switch_odbc_handle_exec(profile->master_odbc, sql, &stmt) != SWITCH_ODBC_SUCCESS) {
-                        char *err_str;
-                        err_str = switch_odbc_handle_get_error(profile->master_odbc, stmt);
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERR: [%s]\n[%s]\n", sql, switch_str_nil(err_str));
-                        switch_safe_free(err_str);
-                        status = SWITCH_STATUS_FALSE;
-                }
-                switch_odbc_statement_handle_free(&stmt);
-        } else {
-                if (!(db = switch_core_db_open_file(profile->dbname))) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
-                        status = SWITCH_STATUS_FALSE;
-                        goto end;
-                }
-                status = switch_core_db_persistant_execute(db, sql, 1);
-                switch_core_db_close(db);
</del><ins>+        if (!(dbh = vm_get_db_handle(profile))) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n");
+                goto end;
</ins><span class="cx">         }
</span><span class="cx">
</span><ins>+        status = switch_cache_db_execute_sql(dbh, sql, NULL);
+
</ins><span class="cx"> end:
</span><ins>+        
+        switch_cache_db_release_db_handle(&dbh);
+
</ins><span class="cx">         if (mutex) {
</span><span class="cx">                 switch_mutex_unlock(mutex);
</span><span class="cx">         }
</span><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-
</del><span class="cx"> static switch_bool_t vm_execute_sql_callback(vm_profile_t *profile, switch_mutex_t *mutex, char *sql, switch_core_db_callback_func_t callback, void *pdata)
</span><span class="cx"> {
</span><span class="cx">         switch_bool_t ret = SWITCH_FALSE;
</span><del>-        switch_core_db_t *db;
</del><span class="cx">         char *errmsg = NULL;
</span><del>-
</del><ins>+        switch_cache_db_handle_t *dbh = NULL;
+        
</ins><span class="cx">         if (mutex) {
</span><span class="cx">                 switch_mutex_lock(mutex);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (switch_odbc_available() && profile->odbc_dsn) {
-                switch_odbc_handle_callback_exec(profile->master_odbc, sql, callback, pdata, NULL);
-        } else {
-                if (!(db = switch_core_db_open_file(profile->dbname))) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
-                        goto end;
-                }
</del><ins>+        if (!(dbh = vm_get_db_handle(profile))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n");
+ goto end;
+ }
+        
+        switch_cache_db_execute_sql_callback(dbh, sql, callback, pdata, &errmsg);
</ins><span class="cx">
</span><del>-                switch_core_db_exec(db, sql, callback, pdata, &errmsg);
-
-                if (errmsg) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR: [%s] %s\n", sql, errmsg);
-                        free(errmsg);
-                }
-
-                if (db) {
-                        switch_core_db_close(db);
-                }
</del><ins>+        if (errmsg) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR: [%s] %s\n", sql, errmsg);
+                free(errmsg);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx"> end:
</span><ins>+
+        switch_cache_db_release_db_handle(&dbh);
+
</ins><span class="cx">         if (mutex) {
</span><span class="cx">                 switch_mutex_unlock(mutex);
</span><span class="cx">         }
</span><ins>+
</ins><span class="cx">         return ret;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> static char vm_sql[] =
</span><span class="cx">         "CREATE TABLE voicemail_msgs (\n"
</span><span class="cx">         " created_epoch INTEGER,\n"
</span><span class="lines">@@ -618,8 +626,9 @@
</span><span class="cx">
</span><span class="cx">         if ((x_profile = switch_xml_find_child(x_profiles, "profile", "name", profile_name))) {
</span><span class="cx">                 switch_memory_pool_t *pool;
</span><del>-                switch_core_db_t *db = NULL;
</del><ins>+                switch_cache_db_handle_t *dbh;
</ins><span class="cx">                 int x, count;
</span><ins>+                char *errmsg;
</ins><span class="cx">
</span><span class="cx">                 if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
</span><span class="lines">@@ -679,96 +688,23 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 profile->dbname = switch_core_sprintf(profile->pool, "voicemail_%s", profile_name);
</span><del>-                if (switch_odbc_available() && profile->odbc_dsn) {
-                        if (!(profile->master_odbc = switch_odbc_handle_new(profile->odbc_dsn, profile->odbc_user, profile->odbc_pass))) {
-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n");
-                                goto end;
</del><span class="cx">
</span><del>-                        }
-                        if (switch_odbc_handle_connect(profile->master_odbc) != SWITCH_ODBC_SUCCESS) {
-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n");
-                                goto end;
-                        }
-
-                        if (switch_odbc_handle_exec(profile->master_odbc, "select count(message_len) from voicemail_msgs", NULL) != SWITCH_ODBC_SUCCESS) {
-                                switch_odbc_handle_exec(profile->master_odbc, "drop table voicemail_msgs", NULL);
-                                switch_odbc_handle_exec(profile->master_odbc, vm_sql, NULL);
-                        }
-
-                        if (switch_odbc_handle_exec(profile->master_odbc, "select count(username) from voicemail_prefs", NULL) != SWITCH_ODBC_SUCCESS) {
-                                switch_odbc_handle_exec(profile->master_odbc, "drop table voicemail_prefs", NULL);
-                                switch_odbc_handle_exec(profile->master_odbc, vm_pref_sql, NULL);
-                        }
-
-                        if (switch_odbc_handle_exec(profile->master_odbc, "select count(password) from voicemail_prefs", NULL) != SWITCH_ODBC_SUCCESS) {
-                                switch_odbc_handle_exec(profile->master_odbc, "alter table voicemail_prefs add password varchar(255)", NULL);
-                        }
-
-                        if (switch_odbc_handle_exec(profile->master_odbc, "select count(message_len) from voicemail_data", NULL) == SWITCH_ODBC_SUCCESS) {
-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Old table voicemail_data found, migrating data!\n");
-                                /* XXX: Old table found.. migrating data into new table */
-                                if (switch_odbc_handle_exec(profile->master_odbc,
-                                                                                        "insert into voicemail_msgs (created_epoch, read_epoch, username, domain, uuid, cid_name, cid_number, "
-                                                                                        "in_folder, file_path, message_len, flags, read_flags) "
-                                                                                        "select created_epoch, read_epoch, user, domain, uuid, "
-                                                                                        "cid_name, cid_number, in_folder, file_path, message_len, flags, read_flags from voicemail_data",
-                                                                                        NULL) != SWITCH_ODBC_SUCCESS) {
-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to migrate old voicemail_data to voicemail_msgs!\n");
-                                        goto end;
-                                }
-                                switch_odbc_handle_exec(profile->master_odbc, "drop table voicemail_data", NULL);
-                        }
-
-                        for (x = 0; vm_index_list[x]; x++) {
-                                switch_odbc_handle_exec(profile->master_odbc, vm_index_list[x], NULL);
-                        }
-                } else {
-                        if ((db = switch_core_db_open_file(profile->dbname))) {
-                                char *errmsg;
-                                switch_core_db_test_reactive(db, "select count(message_len) from voicemail_msgs", "drop table voicemail_msgs", vm_sql);
-
-                                switch_core_db_exec(db, "select count(message_len) from voicemail_data", NULL, NULL, &errmsg);
-                                if (errmsg) {
-                                        switch_core_db_free(errmsg);
-                                        errmsg = NULL;
-                                } else {
-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Migrating data from voicemail_data to voicemail_msgs!\n");
-                                        switch_core_db_exec(db, "insert into voicemail_msgs (created_epoch, read_epoch, username, domain, uuid, cid_name, cid_number, "
-                                                                                "in_folder, file_path, message_len, flags, read_flags) "
-                                                                                "select created_epoch, read_epoch, user, domain, uuid, "
-                                                                                "cid_name, cid_number, in_folder, file_path, message_len, flags, read_flags from voicemail_data",
-                                                                                NULL, NULL, &errmsg);
-                                        if (errmsg) {
-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL ERR [%s]\n", errmsg);
-                                                switch_core_db_free(errmsg);
-                                                errmsg = NULL;
-                                        }
-                                        switch_core_db_exec(db, "drop table voicemail_data", NULL, NULL, &errmsg);
-                                        if (errmsg) {
-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL ERR [%s]\n", errmsg);
-                                                switch_core_db_free(errmsg);
-                                                errmsg = NULL;
-                                        }
-                                }
-
-
-                                switch_core_db_test_reactive(db, "select count(username) from voicemail_prefs", "drop table voicemail_prefs", vm_pref_sql);
-                                switch_core_db_test_reactive(db, "select count(password) from voicemail_prefs", NULL,
-                                                                                                 "alter table voicemail_prefs add password varchar(255)");
-
-                                for (x = 0; vm_index_list[x]; x++) {
-                                        errmsg = NULL;
-                                        switch_core_db_exec(db, vm_index_list[x], NULL, NULL, &errmsg);
-                                        switch_safe_free(errmsg);
-                                }
-
-                        } else {
-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open SQL Database!\n");
-                                goto end;
-                        }
-                        switch_core_db_close(db);
</del><ins>+                if (!(dbh = vm_get_db_handle(profile))) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot open DB!\n");
+                        goto end;
</ins><span class="cx">                 }
</span><ins>+                
+                switch_cache_db_test_reactive(dbh, "select count(message_len) from voicemail_msgs", "drop table voicemail_msgs", vm_sql);
+                switch_cache_db_test_reactive(dbh, "select count(username) from voicemail_prefs", "drop table voicemail_prefs", vm_pref_sql);
+                switch_cache_db_test_reactive(dbh, "select count(password) from voicemail_prefs", NULL, "alter table voicemail_prefs add password varchar(255)");
+                
+                for (x = 0; vm_index_list[x]; x++) {
+                        errmsg = NULL;
+                        switch_cache_db_execute_sql(dbh, vm_index_list[x], &errmsg);
+                        switch_safe_free(errmsg);
+                }
</ins><span class="cx">
</span><ins>+                switch_cache_db_release_db_handle(&dbh);
</ins><span class="cx">
</span><span class="cx">                 switch_mutex_init(&profile->mutex, SWITCH_MUTEX_NESTED, profile->pool);
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Added Profile %s\n", profile->name);
</span><span class="lines">@@ -1496,8 +1432,9 @@
</span><span class="cx">
</span><span class="cx">                 args.input_callback = cancel_on_dtmf;
</span><span class="cx">
</span><del>-                switch_snprintf(key_buf, sizeof(key_buf), "%s:%s:%s:%s:%s:%s", profile->listen_file_key, profile->save_file_key,
-                                                profile->delete_file_key, profile->email_key, profile->callback_key, profile->forward_key);
</del><ins>+                switch_snprintf(key_buf, sizeof(key_buf), "%s:%s:%s:%s:%s:%s%s%s", profile->listen_file_key, profile->save_file_key,
+                                                profile->delete_file_key, profile->email_key, profile->callback_key,
+                                                profile->forward_key, cbt->email ? ":" : "", cbt->email ? cbt->email : "");
</ins><span class="cx">                                                 
</span><span class="cx">
</span><span class="cx">                 switch_snprintf(input, sizeof(input), "%s:%d", cbt->type == MSG_NEW ? "new" : "saved", cbt->want + 1);
</span><span class="lines">@@ -1771,7 +1708,7 @@
</span><span class="cx">         int total_new_urgent_messages = 0;
</span><span class="cx">         int total_saved_urgent_messages = 0;
</span><span class="cx">         int heard_auto_saved = 0, heard_auto_new = 0;
</span><del>-        char *vm_email = NULL;
</del><ins>+        char *vm_email = NULL, *email_addr = NULL;
</ins><span class="cx">         char *convert_cmd = profile->convert_cmd;
</span><span class="cx">         char *convert_ext = profile->convert_ext;
</span><span class="cx">         char *vm_storage_dir = NULL;
</span><span class="lines">@@ -1888,7 +1825,7 @@
</span><span class="cx">                                 message_count(profile, myid, domain_name, myfolder, &total_new_messages, &total_saved_messages,
</span><span class="cx">                                                          &total_new_urgent_messages, &total_saved_urgent_messages);
</span><span class="cx">                                 memset(&cbt, 0, sizeof(cbt));
</span><del>-                                cbt.email = vm_email;
</del><ins>+                                cbt.email = vm_email ? vm_email : email_addr;
</ins><span class="cx">                                 cbt.convert_cmd = convert_cmd;
</span><span class="cx">                                 cbt.convert_ext = convert_ext;
</span><span class="cx">                                 cbt.move = VM_MOVE_NEXT;
</span><span class="lines">@@ -2204,6 +2141,9 @@
</span><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strcasecmp(var, "vm-mailto")) {
</span><span class="cx">                                                 vm_email = switch_core_session_strdup(session, val);
</span><ins>+                                                email_addr = switch_core_session_strdup(session, val);
+                                        } else if (!strcasecmp(var, "email-addr")) {
+                                                email_addr = switch_core_session_strdup(session, val);
</ins><span class="cx">                                         } else if (!strcasecmp(var, "vm-convert-cmd")) {
</span><span class="cx">                                                 convert_cmd = switch_core_session_strdup(session, val);
</span><span class="cx">                                         } else if (!strcasecmp(var, "vm-convert-ext")) {
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>