<!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][16270] </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=16270">16270</a></dd>
<dt>Author</dt> <dd>anthm</dd>
<dt>Date</dt> <dd>2010-01-12 19:32:01 -0600 (Tue, 12 Jan 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre><a href="http://jira.freeswitch.org/browse/BOUNTY-13">BOUNTY-13</a></pre>

<h3>Modified Paths</h3>
<ul>
<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="freeswitchtrunksrcmodapplicationsmod_voicemailmod_voicemailc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (16269 => 16270)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c        2010-01-13 01:06:18 UTC (rev 16269)
+++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c        2010-01-13 01:32:01 UTC (rev 16270)
</span><span class="lines">@@ -248,7 +248,8 @@
</span><span class="cx">         &quot;   file_path     VARCHAR(255),\n&quot; 
</span><span class="cx">         &quot;   message_len   INTEGER,\n&quot; 
</span><span class="cx">         &quot;   flags         VARCHAR(255),\n&quot; 
</span><del>-        &quot;   read_flags    VARCHAR(255)\n&quot; 
</del><ins>+        &quot;   read_flags    VARCHAR(255),\n&quot; 
+        &quot;   forwarded_by  VARCHAR(255)\n&quot; 
</ins><span class="cx">         &quot;);\n&quot;;
</span><span class="cx"> 
</span><span class="cx"> static char vm_pref_sql[] =
</span><span class="lines">@@ -267,6 +268,7 @@
</span><span class="cx">         &quot;create index voicemail_msgs_idx4 on voicemail_msgs(uuid)&quot;,
</span><span class="cx">         &quot;create index voicemail_msgs_idx5 on voicemail_msgs(in_folder)&quot;,
</span><span class="cx">         &quot;create index voicemail_msgs_idx6 on voicemail_msgs(read_flags)&quot;,
</span><ins>+        &quot;create index voicemail_msgs_idx7 on voicemail_msgs(forwarded_by)&quot;,
</ins><span class="cx">         &quot;create index voicemail_prefs_idx1 on voicemail_prefs(username)&quot;,
</span><span class="cx">         &quot;create index voicemail_prefs_idx2 on voicemail_prefs(domain)&quot;,
</span><span class="cx">         NULL
</span><span class="lines">@@ -299,7 +301,7 @@
</span><span class="cx">                 if (switch_thread_rwlock_trywrlock(profile-&gt;rwlock) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         /* Lock failed, set the destroy flag so it'll be destroyed whenever its not in use anymore */
</span><span class="cx">                         switch_set_flag(profile, PFLAG_DESTROY);
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;[%s] Profile is in use, memory will be freed whenever its not longer in use\n&quot;, profile-&gt;name);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;[%s] Profile is in use, memory will be freed whenever its no longer in use\n&quot;, profile-&gt;name);
</ins><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -689,7 +691,9 @@
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="cx">                 
</span><del>-                switch_cache_db_test_reactive(dbh, &quot;select count(message_len) from voicemail_msgs&quot;, &quot;drop table voicemail_msgs&quot;, vm_sql);
</del><ins>+                switch_cache_db_test_reactive(dbh, &quot;select count(forwarded_by) from voicemail_msgs&quot;, NULL, &quot;alter table voicemail_msgs add forwarded_by varchar(255)&quot;);
+                switch_cache_db_test_reactive(dbh, &quot;select count(forwarded_by) from voicemail_msgs&quot;, &quot;drop table voicemail_msgs&quot;, vm_sql);
+                
</ins><span class="cx">                 switch_cache_db_test_reactive(dbh, &quot;select count(username) from voicemail_prefs&quot;, &quot;drop table voicemail_prefs&quot;, vm_pref_sql);
</span><span class="cx">                 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;);
</span><span class="cx">                 
</span><span class="lines">@@ -1203,6 +1207,7 @@
</span><span class="cx">         char message_len[255];
</span><span class="cx">         char flags[255];
</span><span class="cx">         char read_flags[255];
</span><ins>+        char forwarded_by[255];
</ins><span class="cx">         char *email;
</span><span class="cx">         int index;
</span><span class="cx">         int want;
</span><span class="lines">@@ -1233,6 +1238,7 @@
</span><span class="cx">         switch_copy_string(cbt-&gt;message_len, argv[9], 255);
</span><span class="cx">         switch_copy_string(cbt-&gt;flags, argv[10], 255);
</span><span class="cx">         switch_copy_string(cbt-&gt;read_flags, argv[11], 255);
</span><ins>+        switch_copy_string(cbt-&gt;forwarded_by, argv[12], 255);
</ins><span class="cx"> 
</span><span class="cx">         return -1;
</span><span class="cx"> }
</span><span class="lines">@@ -2264,16 +2270,17 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> static switch_status_t deliver_vm(vm_profile_t *profile, 
</span><del>-                                                                switch_xml_t x_user, 
-                                                                const char *domain_name, 
-                                                                const char *path, 
-                                                                uint32_t message_len,
-                                                                const char *read_flags,
-                                                                switch_event_t *params, 
-                                                                switch_memory_pool_t *pool, 
-                                                                const char *caller_id_name, 
-                                                                const char *caller_id_number,
-                                                                switch_bool_t copy)
</del><ins>+                                                                  switch_xml_t x_user, 
+                                                                  const char *domain_name, 
+                                                                  const char *path, 
+                                                                  uint32_t message_len,
+                                                                  const char *read_flags,
+                                                                  switch_event_t *params, 
+                                                                  switch_memory_pool_t *pool, 
+                                                                  const char *caller_id_name, 
+                                                                  const char *caller_id_number,
+                                                                  const char *forwarded_by,
+                                                                  switch_bool_t copy)
</ins><span class="cx"> {
</span><span class="cx">         char *file_path = NULL, *dir_path = NULL;
</span><span class="cx">         const char *myid = switch_xml_attr(x_user, &quot;id&quot;);
</span><span class="lines">@@ -2413,10 +2420,10 @@
</span><span class="cx">                 switch_event_fire(&amp;message_event);
</span><span class="cx"> 
</span><span class="cx">                 usql = switch_mprintf(&quot;insert into voicemail_msgs(created_epoch, read_epoch, username, domain, uuid, cid_name, &quot;
</span><del>-                                                          &quot;cid_number, in_folder, file_path, message_len, flags, read_flags) &quot;
-                                                          &quot;values(%ld,0,'%q','%q','%q','%q','%q','%q','%q','%u','','%q')&quot;, (long) switch_epoch_time_now(NULL),
</del><ins>+                                                          &quot;cid_number, in_folder, file_path, message_len, flags, read_flags, forwarded_by) &quot;
+                                                          &quot;values(%ld,0,'%q','%q','%q','%q','%q','%q','%q','%u','','%q','%q')&quot;, (long) switch_epoch_time_now(NULL),
</ins><span class="cx">                                                           myid, domain_name, uuid_str, caller_id_name, caller_id_number,
</span><del>-                                                          myfolder, file_path, message_len, read_flags);
</del><ins>+                                                          myfolder, file_path, message_len, read_flags, switch_str_nil(forwarded_by));
</ins><span class="cx"> 
</span><span class="cx">                 vm_execute_sql(profile, usql, profile-&gt;mutex);
</span><span class="cx">                 switch_safe_free(usql);
</span><span class="lines">@@ -2618,9 +2625,10 @@
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         int isgroup = 0, isall = 0;
</span><span class="cx">         int argc = 0;
</span><del>-        char *argv[4];
</del><ins>+        char *argv[5] = { 0 };
</ins><span class="cx">         char *box, *path, *cid_num, *cid_name;
</span><span class="cx">         switch_memory_pool_t *pool = NULL;
</span><ins>+        char *forwarded_by = NULL;
</ins><span class="cx"> 
</span><span class="cx">         if (zstr(data)) {
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -2640,6 +2648,7 @@
</span><span class="cx">         path = argv[1];
</span><span class="cx">         cid_num = argv[2] ? argv[2] : &quot;anonymous&quot;;
</span><span class="cx">         cid_name = argv[3] ? argv[3] : &quot;anonymous&quot;;
</span><ins>+        forwarded_by = argv[4];
</ins><span class="cx"> 
</span><span class="cx">         user = box;
</span><span class="cx">         
</span><span class="lines">@@ -2695,6 +2704,9 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx"> 
</span><ins>+                if (forwarded_by) {
+                        switch_event_add_header_string(my_params, SWITCH_STACK_BOTTOM, &quot;Forwarded-By&quot;, forwarded_by);
+                }
</ins><span class="cx">                 switch_event_add_header_string(my_params, SWITCH_STACK_BOTTOM, &quot;domain&quot;, domain);
</span><span class="cx">                 switch_event_add_header_string(my_params, SWITCH_STACK_BOTTOM, &quot;purpose&quot;, &quot;publish-vm&quot;);
</span><span class="cx">                 
</span><span class="lines">@@ -2724,14 +2736,14 @@
</span><span class="cx"> 
</span><span class="cx">                                                                 if (switch_xml_locate_user_in_domain(uname, x_domain, &amp;ux, NULL) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                                         switch_event_create(&amp;my_params, SWITCH_EVENT_REQUEST_PARAMS);
</span><del>-                                                                        status = deliver_vm(profile, ux, domain, path, 0, &quot;B&quot;, my_params, pool, cid_name, cid_num, SWITCH_TRUE);
</del><ins>+                                                                        status = deliver_vm(profile, ux, domain, path, 0, &quot;B&quot;, my_params, pool, cid_name, cid_num, forwarded_by, SWITCH_TRUE);
</ins><span class="cx">                                                                         switch_event_destroy(&amp;my_params);
</span><span class="cx">                                                                 }
</span><span class="cx">                                                                 continue;
</span><span class="cx">                                                         }
</span><span class="cx">                                                         
</span><span class="cx">                                                         switch_event_create(&amp;my_params, SWITCH_EVENT_REQUEST_PARAMS);
</span><del>-                                                        status = deliver_vm(profile, ut, domain, path, 0, &quot;B&quot;, my_params, pool, cid_name, cid_num, SWITCH_TRUE);
</del><ins>+                                                        status = deliver_vm(profile, ut, domain, path, 0, &quot;B&quot;, my_params, pool, cid_name, cid_num, forwarded_by, SWITCH_TRUE);
</ins><span class="cx">                                                         switch_event_destroy(&amp;my_params);
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><span class="lines">@@ -2752,7 +2764,7 @@
</span><span class="cx">                                                         }
</span><span class="cx"> 
</span><span class="cx">                                                         switch_event_create(&amp;my_params, SWITCH_EVENT_REQUEST_PARAMS);
</span><del>-                                                        status = deliver_vm(profile, ut, domain, path, 0, &quot;B&quot;, my_params, pool, cid_name, cid_num, SWITCH_TRUE);
</del><ins>+                                                        status = deliver_vm(profile, ut, domain, path, 0, &quot;B&quot;, my_params, pool, cid_name, cid_num, forwarded_by, SWITCH_TRUE);
</ins><span class="cx">                                                         switch_event_destroy(&amp;my_params);
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><span class="lines">@@ -2764,7 +2776,7 @@
</span><span class="cx"> 
</span><span class="cx">                         if ((status = switch_xml_locate_user_in_domain(user, x_domain, &amp;ut, &amp;x_group)) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_event_create(&amp;my_params, SWITCH_EVENT_REQUEST_PARAMS);
</span><del>-                                status = deliver_vm(profile, ut, domain, path, 0, &quot;B&quot;, my_params, pool, cid_name, cid_num, SWITCH_TRUE);
</del><ins>+                                status = deliver_vm(profile, ut, domain, path, 0, &quot;B&quot;, my_params, pool, cid_name, cid_num, forwarded_by, SWITCH_TRUE);
</ins><span class="cx">                                 switch_event_destroy(&amp;my_params);
</span><span class="cx">                         } else {
</span><span class="cx">                                 status = SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -3100,11 +3112,12 @@
</span><span class="cx">         if (x_domain_root) {
</span><span class="cx">                 switch_channel_get_variables(channel, &amp;vars);
</span><span class="cx">                 status = deliver_vm(profile, x_user, domain_name, file_path, message_len, read_flags, vars, 
</span><del>-                                                        switch_core_session_get_pool(session), caller_id_name, caller_id_number, SWITCH_FALSE);
</del><ins>+                                                        switch_core_session_get_pool(session), caller_id_name, caller_id_number, NULL, SWITCH_FALSE);
</ins><span class="cx">                 switch_event_destroy(&amp;vars);
</span><span class="cx">                 if (status == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         if ((vm_cc = switch_channel_get_variable(channel, &quot;vm_cc&quot;))) {
</span><del>-                                char *cmd = switch_core_session_sprintf(session, &quot;%s %s %s %s&quot;, vm_cc, file_path, caller_id_number, caller_id_name);
</del><ins>+                                char *cmd = switch_core_session_sprintf(session, &quot;%s %s %s %s %s@%s&quot;, vm_cc, file_path, caller_id_number, caller_id_name, id, domain_name);
+                                
</ins><span class="cx">                                 if (voicemail_inject(cmd) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, &quot;Sent Carbon Copy to %s\n&quot;, vm_cc);
</span><span class="cx">                                 } else {
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>