Author: anthm Date: Tue Oct 23 11:07:14 2007 New Revision: 6030 Modified: freeswitch/trunk/conf/directory.xml freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Log: merge MODAPP-40 Modified: freeswitch/trunk/conf/directory.xml ============================================================================== --- freeswitch/trunk/conf/directory.xml (original) +++ freeswitch/trunk/conf/directory.xml Tue Oct 23 11:07:14 2007 @@ -39,6 +39,9 @@ <!-- omit password for authless registration --> <param name="password" value="1234"/> <param name="vm-password" value="1234"/><!--if vm-password is omitted password param is used--> + <!--<param name="email-addr" value="me@mydomain.com"/>--> + <!--<param name="vm-delete-file" value="true"/>--> + <!--<param name="vm-attach-file" value="true"/>--> <!--<param name="vm-mailto" value="me@mydomain.com"/>--> <!--<param name="vm-email-all-messages" value="true"/>--> <!-- optionally use this instead if you want to store the hash of user:domain:pass--> Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (original) +++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Tue Oct 23 11:07:14 2007 @@ -1062,7 +1062,6 @@ body = switch_channel_expand_variables(channel,profile->email_body); } - //TBD add better formatting to the body -- TRX done :) switch_simple_email(cbt->email, from, headers, body, cbt->file_path); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending message to %s\n", cbt->email); switch_safe_free(body); @@ -1105,6 +1104,7 @@ int total_saved_urgent_messages = 0; int heard_auto_saved = 0, heard_auto_new = 0; char *email_vm = NULL; + channel = switch_core_session_get_channel(session); assert(channel != NULL); @@ -1488,7 +1488,6 @@ vm_check_state = VM_CHECK_FOLDER_SUMMARY; - //vm_check_state = VM_CHECK_MENU; } else { goto failed; } @@ -1542,6 +1541,9 @@ cc_t cc = { 0 }; char *read_flags = NORMAL_FLAG_STRING; int priority = 3; + int email_attach = 1; + int email_delete = 1; + memset(&cbt, 0, sizeof(cbt)); if (!(profile = switch_core_hash_find(globals.profile_hash, profile_name))) { @@ -1579,6 +1581,7 @@ int ok = 1; char *xtra = switch_mprintf("mailbox=%s", id); switch_xml_t x_domain, x_domain_root, x_user, x_params, x_param; + const char *email_addr = NULL; assert(xtra); x_user = x_domain = x_domain_root = NULL; @@ -1591,12 +1594,22 @@ if (!strcasecmp(var, "vm-mailto")) { email_vm = switch_core_session_strdup(session, val); + } else if (!strcasecmp(var, "email-addr")) { + email_addr = val; } else if (!strcasecmp(var, "vm-email-all-messages")) { send_mail = switch_true(val); + } else if (!strcasecmp(var, "vm-delete-file")) { + email_delete = switch_true(val); + } else if (!strcasecmp(var, "vm-attach-file")) { + email_attach = switch_true(val); } } } + if (send_mail && switch_strlen_zero(email_vm) && !switch_strlen_zero(email_addr)) { + email_vm = switch_core_session_strdup(session, email_addr); + } + } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", id, domain_name); ok = 0; @@ -1760,11 +1773,17 @@ body = switch_channel_expand_variables(channel,profile->email_body); } - //TBD add better formatting to the body -- TRX done :) - switch_simple_email(email_vm, from, headers, body, file_path); + if(email_attach) { + switch_simple_email(email_vm, from, headers, body, file_path); + } else { + switch_simple_email(email_vm, from, headers, body, NULL); + } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending message to %s\n", email_vm); switch_safe_free(body); - unlink(file_path); + if(email_delete) { + unlink(file_path); + } } switch_safe_free(file_path);