<!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">   &lt;macro name=&quot;voicemail_hello&quot;&gt;
</span><span class="cx">     &lt;input pattern=&quot;(.*)&quot;&gt;
</span><span class="cx">       &lt;match&gt;
</span><del>-        &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-hello.wav&quot;/&gt;
</del><ins>+        &lt;!--&lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-hello.wav&quot;/&gt; --&gt;
</ins><span class="cx">       &lt;/match&gt;
</span><span class="cx">     &lt;/input&gt;
</span><span class="cx">   &lt;/macro&gt;
</span><span class="lines">@@ -56,7 +56,6 @@
</span><span class="cx">         &lt;action function=&quot;say&quot; data=&quot;$1&quot; method=&quot;pronounced&quot; type=&quot;items&quot;/&gt;
</span><span class="cx">         &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-$2.wav&quot;/&gt; 
</span><span class="cx">         &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-message.wav&quot;/&gt;
</span><del>-        &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-in_folder.wav&quot;/&gt;
</del><span class="cx">       &lt;/match&gt;
</span><span class="cx">     &lt;/input&gt;
</span><span class="cx">     &lt;input pattern=&quot;^(\d+):(.*)$&quot;&gt;
</span><span class="lines">@@ -65,7 +64,6 @@
</span><span class="cx">         &lt;action function=&quot;say&quot; data=&quot;$1&quot; method=&quot;pronounced&quot; type=&quot;items&quot;/&gt;
</span><span class="cx">         &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-$2.wav&quot;/&gt; 
</span><span class="cx">         &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-messages.wav&quot;/&gt;
</span><del>-        &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-in_folder.wav&quot;/&gt;
</del><span class="cx">       &lt;/match&gt;
</span><span class="cx">     &lt;/input&gt;
</span><span class="cx">   &lt;/macro&gt;
</span><span class="lines">@@ -89,7 +87,6 @@
</span><span class="cx">     &lt;/input&gt;
</span><span class="cx">   &lt;/macro&gt;
</span><span class="cx"> 
</span><del>-
</del><span class="cx">   &lt;macro name=&quot;voicemail_config_menu&quot;&gt;
</span><span class="cx">     &lt;input pattern=&quot;^([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*])$&quot;&gt;
</span><span class="cx">       &lt;match&gt;
</span><span class="lines">@@ -112,7 +109,6 @@
</span><span class="cx">     &lt;/input&gt;
</span><span class="cx">   &lt;/macro&gt;
</span><span class="cx"> 
</span><del>-
</del><span class="cx">   &lt;macro name=&quot;voicemail_record_name&quot;&gt;
</span><span class="cx">     &lt;input pattern=&quot;^(.*)$&quot;&gt;
</span><span class="cx">       &lt;match&gt;
</span><span class="lines">@@ -182,7 +178,7 @@
</span><span class="cx">   &lt;/macro&gt;
</span><span class="cx"> 
</span><span class="cx">   &lt;macro name=&quot;voicemail_listen_file_check&quot;&gt;
</span><del>-    &lt;input pattern=&quot;^([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*])$&quot;&gt;
</del><ins>+    &lt;input pattern=&quot;^([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*]):(.*)$&quot;&gt;
</ins><span class="cx">       &lt;match&gt;
</span><span class="cx">         &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-listen_to_recording.wav&quot;/&gt;
</span><span class="cx">         &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-press.wav&quot;/&gt;
</span><span class="lines">@@ -204,6 +200,25 @@
</span><span class="cx">         &lt;action function=&quot;say&quot; data=&quot;$6&quot; method=&quot;pronounced&quot; type=&quot;name_spelled&quot;/&gt;
</span><span class="cx">       &lt;/match&gt;
</span><span class="cx">     &lt;/input&gt;
</span><ins>+    &lt;input pattern=&quot;^([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*]):([0-9#*])$&quot;&gt;
+      &lt;match&gt;
+        &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-listen_to_recording.wav&quot;/&gt;
+        &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-press.wav&quot;/&gt;
+        &lt;action function=&quot;say&quot; data=&quot;$1&quot; method=&quot;pronounced&quot; type=&quot;name_spelled&quot;/&gt;
+        &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-save_recording.wav&quot;/&gt;
+        &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-press.wav&quot;/&gt;
+        &lt;action function=&quot;say&quot; data=&quot;$2&quot; method=&quot;pronounced&quot; type=&quot;name_spelled&quot;/&gt;
+        &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-delete_recording.wav&quot;/&gt;
+        &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-press.wav&quot;/&gt;
+        &lt;action function=&quot;say&quot; data=&quot;$3&quot; method=&quot;pronounced&quot; type=&quot;name_spelled&quot;/&gt;
+        &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-return_call.wav&quot;/&gt;
+        &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-press.wav&quot;/&gt;
+        &lt;action function=&quot;say&quot; data=&quot;$5&quot; method=&quot;pronounced&quot; type=&quot;name_spelled&quot;/&gt;
+        &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-to_forward.wav&quot;/&gt;
+        &lt;action function=&quot;play-file&quot; data=&quot;voicemail/vm-press.wav&quot;/&gt;
+        &lt;action function=&quot;say&quot; data=&quot;$6&quot; method=&quot;pronounced&quot; type=&quot;name_spelled&quot;/&gt;
+      &lt;/match&gt;
+    &lt;/input&gt;
</ins><span class="cx">   &lt;/macro&gt;
</span><span class="cx"> 
</span><span class="cx">   &lt;macro name=&quot;voicemail_choose_greeting&quot;&gt;
</span><span class="lines">@@ -363,7 +378,4 @@
</span><span class="cx">       &lt;/match&gt;
</span><span class="cx">     &lt;/input&gt;
</span><span class="cx">   &lt;/macro&gt;
</span><del>-
-
-
</del><span class="cx"> &lt;/include&gt;&lt;!--This line will be ignored it's here to validate the xml and is optional --&gt;
</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-&gt;odbc_dsn &amp;&amp; profile-&gt;odbc_user &amp;&amp; profile-&gt;odbc_pass) {
+                options.odbc_options.dsn = profile-&gt;odbc_dsn;
+                options.odbc_options.user = profile-&gt;odbc_user;
+                options.odbc_options.pass = profile-&gt;odbc_pass;
+
+                if (switch_cache_db_get_db_handle(&amp;dbh, SCDB_TYPE_ODBC, &amp;options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
+                return dbh;
+        } else {
+                options.core_db_options.db_path = profile-&gt;dbname;
+                if (switch_cache_db_get_db_handle(&amp;dbh, SCDB_TYPE_CORE_DB, &amp;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() &amp;&amp; profile-&gt;odbc_dsn) {
-                switch_odbc_statement_handle_t stmt;
-                if (switch_odbc_handle_exec(profile-&gt;master_odbc, sql, &amp;stmt) != SWITCH_ODBC_SUCCESS) {
-                        char *err_str;
-                        err_str = switch_odbc_handle_get_error(profile-&gt;master_odbc, stmt);
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;ERR: [%s]\n[%s]\n&quot;, sql, switch_str_nil(err_str));
-                        switch_safe_free(err_str);
-                        status = SWITCH_STATUS_FALSE;
-                }
-                switch_odbc_statement_handle_free(&amp;stmt);
-        } else {
-                if (!(db = switch_core_db_open_file(profile-&gt;dbname))) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error Opening DB %s\n&quot;, profile-&gt;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, &quot;Error Opening DB\n&quot;);
+                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(&amp;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() &amp;&amp; profile-&gt;odbc_dsn) {
-                switch_odbc_handle_callback_exec(profile-&gt;master_odbc, sql, callback, pdata, NULL);
-        } else {
-                if (!(db = switch_core_db_open_file(profile-&gt;dbname))) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error Opening DB %s\n&quot;, profile-&gt;dbname);
-                        goto end;
-                }
</del><ins>+        if (!(dbh = vm_get_db_handle(profile))) {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error Opening DB\n&quot;);
+        goto end;
+    }
+        
+        switch_cache_db_execute_sql_callback(dbh, sql, callback, pdata, &amp;errmsg);
</ins><span class="cx"> 
</span><del>-                switch_core_db_exec(db, sql, callback, pdata, &amp;errmsg);
-
-                if (errmsg) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;SQL ERR: [%s] %s\n&quot;, sql, errmsg);
-                        free(errmsg);
-                }
-
-                if (db) {
-                        switch_core_db_close(db);
-                }
</del><ins>+        if (errmsg) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;SQL ERR: [%s] %s\n&quot;, 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(&amp;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">         &quot;CREATE TABLE voicemail_msgs (\n&quot;
</span><span class="cx">         &quot;   created_epoch INTEGER,\n&quot;
</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, &quot;profile&quot;, &quot;name&quot;, 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(&amp;pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Pool Failure\n&quot;);
</span><span class="lines">@@ -679,96 +688,23 @@
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 profile-&gt;dbname = switch_core_sprintf(profile-&gt;pool, &quot;voicemail_%s&quot;, profile_name);
</span><del>-                if (switch_odbc_available() &amp;&amp; profile-&gt;odbc_dsn) {
-                        if (!(profile-&gt;master_odbc = switch_odbc_handle_new(profile-&gt;odbc_dsn, profile-&gt;odbc_user, profile-&gt;odbc_pass))) {
-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Cannot Open ODBC Database!\n&quot;);
-                                goto end;
</del><span class="cx"> 
</span><del>-                        }
-                        if (switch_odbc_handle_connect(profile-&gt;master_odbc) != SWITCH_ODBC_SUCCESS) {
-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Cannot Open ODBC Database!\n&quot;);
-                                goto end;
-                        }
-
-                        if (switch_odbc_handle_exec(profile-&gt;master_odbc, &quot;select count(message_len) from voicemail_msgs&quot;, NULL) != SWITCH_ODBC_SUCCESS) {
-                                switch_odbc_handle_exec(profile-&gt;master_odbc, &quot;drop table voicemail_msgs&quot;, NULL);
-                                switch_odbc_handle_exec(profile-&gt;master_odbc, vm_sql, NULL);
-                        }
-
-                        if (switch_odbc_handle_exec(profile-&gt;master_odbc, &quot;select count(username) from voicemail_prefs&quot;, NULL) != SWITCH_ODBC_SUCCESS) {
-                                switch_odbc_handle_exec(profile-&gt;master_odbc, &quot;drop table voicemail_prefs&quot;, NULL);
-                                switch_odbc_handle_exec(profile-&gt;master_odbc, vm_pref_sql, NULL);
-                        }
-
-                        if (switch_odbc_handle_exec(profile-&gt;master_odbc, &quot;select count(password) from voicemail_prefs&quot;, NULL) != SWITCH_ODBC_SUCCESS) {
-                                switch_odbc_handle_exec(profile-&gt;master_odbc, &quot;alter table voicemail_prefs add password varchar(255)&quot;, NULL);
-                        }
-
-                        if (switch_odbc_handle_exec(profile-&gt;master_odbc, &quot;select count(message_len) from voicemail_data&quot;, NULL) == SWITCH_ODBC_SUCCESS) {
-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Old table voicemail_data found, migrating data!\n&quot;);
-                                /* XXX: Old table found.. migrating data into new table */
-                                if (switch_odbc_handle_exec(profile-&gt;master_odbc,
-                                                                                        &quot;insert into voicemail_msgs (created_epoch, read_epoch, username, domain, uuid, cid_name, cid_number, &quot;
-                                                                                        &quot;in_folder, file_path, message_len, flags, read_flags) &quot;
-                                                                                        &quot;select created_epoch, read_epoch, user, domain, uuid, &quot;
-                                                                                        &quot;cid_name, cid_number, in_folder, file_path, message_len, flags, read_flags from voicemail_data&quot;,
-                                                                                        NULL) != SWITCH_ODBC_SUCCESS) {
-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Failed to migrate old voicemail_data to voicemail_msgs!\n&quot;);
-                                        goto end;
-                                }
-                                switch_odbc_handle_exec(profile-&gt;master_odbc, &quot;drop table voicemail_data&quot;, NULL);
-                        }
-
-                        for (x = 0; vm_index_list[x]; x++) {
-                                switch_odbc_handle_exec(profile-&gt;master_odbc, vm_index_list[x], NULL);
-                        }
-                } else {
-                        if ((db = switch_core_db_open_file(profile-&gt;dbname))) {
-                                char *errmsg;
-                                switch_core_db_test_reactive(db, &quot;select count(message_len) from voicemail_msgs&quot;, &quot;drop table voicemail_msgs&quot;, vm_sql);
-
-                                switch_core_db_exec(db, &quot;select count(message_len) from voicemail_data&quot;, NULL, NULL, &amp;errmsg);
-                                if (errmsg) {
-                                        switch_core_db_free(errmsg);
-                                        errmsg = NULL;
-                                } else {
-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Migrating data from voicemail_data to voicemail_msgs!\n&quot;);
-                                        switch_core_db_exec(db, &quot;insert into voicemail_msgs (created_epoch, read_epoch, username, domain, uuid, cid_name, cid_number, &quot;
-                                                                                &quot;in_folder, file_path, message_len, flags, read_flags) &quot;
-                                                                                &quot;select created_epoch, read_epoch, user, domain, uuid, &quot;
-                                                                                &quot;cid_name, cid_number, in_folder, file_path, message_len, flags, read_flags from voicemail_data&quot;,
-                                                                                NULL, NULL, &amp;errmsg);
-                                        if (errmsg) {
-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;SQL ERR [%s]\n&quot;, errmsg);
-                                                switch_core_db_free(errmsg);
-                                                errmsg = NULL;
-                                        }
-                                        switch_core_db_exec(db, &quot;drop table voicemail_data&quot;, NULL, NULL, &amp;errmsg);
-                                        if (errmsg) {
-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;SQL ERR [%s]\n&quot;, errmsg);
-                                                switch_core_db_free(errmsg);
-                                                errmsg = NULL;
-                                        }
-                                }
-
-
-                                switch_core_db_test_reactive(db, &quot;select count(username) from voicemail_prefs&quot;, &quot;drop table voicemail_prefs&quot;, vm_pref_sql);
-                                switch_core_db_test_reactive(db, &quot;select count(password) from voicemail_prefs&quot;, NULL, 
-                                                                                                 &quot;alter table voicemail_prefs add password varchar(255)&quot;);
-
-                                for (x = 0; vm_index_list[x]; x++) {
-                                        errmsg = NULL;
-                                        switch_core_db_exec(db, vm_index_list[x], NULL, NULL, &amp;errmsg);
-                                        switch_safe_free(errmsg);
-                                }
-
-                        } else {
-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Cannot Open SQL Database!\n&quot;);
-                                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, &quot;Cannot open DB!\n&quot;);
+                        goto end;
</ins><span class="cx">                 }
</span><ins>+                
+                switch_cache_db_test_reactive(dbh, &quot;select count(message_len) from voicemail_msgs&quot;, &quot;drop table voicemail_msgs&quot;, vm_sql);
+                switch_cache_db_test_reactive(dbh, &quot;select count(username) from voicemail_prefs&quot;, &quot;drop table voicemail_prefs&quot;, vm_pref_sql);
+                switch_cache_db_test_reactive(dbh, &quot;select count(password) from voicemail_prefs&quot;, NULL, &quot;alter table voicemail_prefs add password varchar(255)&quot;);
+                
+                for (x = 0; vm_index_list[x]; x++) {
+                        errmsg = NULL;
+                        switch_cache_db_execute_sql(dbh, vm_index_list[x], &amp;errmsg);
+                        switch_safe_free(errmsg);
+                }
</ins><span class="cx"> 
</span><ins>+                switch_cache_db_release_db_handle(&amp;dbh);
</ins><span class="cx"> 
</span><span class="cx">                 switch_mutex_init(&amp;profile-&gt;mutex, SWITCH_MUTEX_NESTED, profile-&gt;pool);
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Added Profile %s\n&quot;, profile-&gt;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), &quot;%s:%s:%s:%s:%s:%s&quot;, profile-&gt;listen_file_key, profile-&gt;save_file_key, 
-                                                profile-&gt;delete_file_key, profile-&gt;email_key, profile-&gt;callback_key, profile-&gt;forward_key);
</del><ins>+                switch_snprintf(key_buf, sizeof(key_buf), &quot;%s:%s:%s:%s:%s:%s%s%s&quot;, profile-&gt;listen_file_key, profile-&gt;save_file_key, 
+                                                profile-&gt;delete_file_key, profile-&gt;email_key, profile-&gt;callback_key, 
+                                                profile-&gt;forward_key, cbt-&gt;email ? &quot;:&quot; : &quot;&quot;, cbt-&gt;email ? cbt-&gt;email : &quot;&quot;);
</ins><span class="cx">                                                 
</span><span class="cx"> 
</span><span class="cx">                 switch_snprintf(input, sizeof(input), &quot;%s:%d&quot;, cbt-&gt;type == MSG_NEW ? &quot;new&quot; : &quot;saved&quot;, cbt-&gt;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-&gt;convert_cmd;
</span><span class="cx">         char *convert_ext = profile-&gt;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, &amp;total_new_messages, &amp;total_saved_messages,
</span><span class="cx">                                                           &amp;total_new_urgent_messages, &amp;total_saved_urgent_messages);
</span><span class="cx">                                 memset(&amp;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, &quot;vm-mailto&quot;)) {
</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, &quot;email-addr&quot;)) {
+                                                email_addr = switch_core_session_strdup(session, val);
</ins><span class="cx">                                         } else if (!strcasecmp(var, &quot;vm-convert-cmd&quot;)) {
</span><span class="cx">                                                 convert_cmd = switch_core_session_strdup(session, val);
</span><span class="cx">                                         } else if (!strcasecmp(var, &quot;vm-convert-ext&quot;)) {
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>