merge MODAPP-88: Fix Email with no Attachement; Allow Email & Local VM Storage; Add Notify Only Email; Extra, note about missing prompts.

Added param "vm-email-only" to make voicemail sent by email only (previously default behavior
Added param "vm-mailto-notify" to allow sending an second email to an mobile or other device for notification only 


git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8655 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2008-05-26 02:51:34 +00:00
parent 08b13d6f03
commit aa93dc3e9c
2 changed files with 28 additions and 23 deletions

View File

@ -952,8 +952,10 @@ record_file:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "failed to delete file [%s]\n", file_path);
}
if (switch_channel_ready(channel)) {
/* TODO Rel 1.0 : Add Playback of Prompt <message is too short, please rerecord your message>, then go back at record_file */
goto record_file;
} else {
status = SWITCH_STATUS_BREAK;
goto end;
}
} else {
@ -1741,7 +1743,9 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, cons
switch_file_handle_t fh = { 0 };
switch_input_args_t args = { 0 };
char *email_vm = NULL;
char *email_vm_notify = NULL;
int send_mail = 0;
int send_mail_only = 0;
cc_t cc = { 0 };
char *read_flags = NORMAL_FLAG_STRING;
int priority = 3;
@ -1804,8 +1808,12 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, cons
if (!strcasecmp(var, "vm-mailto")) {
email_vm = switch_core_session_strdup(session, val);
} else if (!strcasecmp(var, "vm-mailto-notify")) {
email_vm_notify = switch_core_session_strdup(session, val);
} else if (!strcasecmp(var, "email-addr")) {
email_addr = val;
} else if (!strcasecmp(var, "vm-email-only")) {
send_mail_only = switch_true(val);
} else if (!strcasecmp(var, "vm-email-all-messages")) {
send_mail = switch_true(val);
} else if (!strcasecmp(var, "vm-delete-file")) {
@ -1944,7 +1952,7 @@ greet:
}
}
if (!send_mail && switch_file_exists(file_path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
if (!send_mail_only && switch_file_exists(file_path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
char *usql;
switch_event_t *event;
char *mwi_id = NULL;
@ -1979,7 +1987,7 @@ greet:
end:
if (send_mail && !switch_strlen_zero(email_vm)) {
if (send_mail && !switch_strlen_zero(email_vm) && switch_file_exists(file_path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
switch_event_t *event;
char *from;
char *body;
@ -2080,10 +2088,13 @@ end:
} else {
switch_simple_email(email_vm, from, header_string, body, NULL);
}
if (!switch_strlen_zero(email_vm_notify)) {
switch_simple_email(email_vm_notify, from, header_string, body, NULL);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending message to %s\n", email_vm);
switch_safe_free(body);
if (email_delete) {
if (email_delete && send_mail_only) {
if (unlink(file_path) != 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "failed to delete file [%s]\n", file_path);
}

View File

@ -373,11 +373,10 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, const char *fr
if ((ifd = open(file, O_RDONLY)) < 1) {
return SWITCH_FALSE;
}
switch_snprintf(buf, B64BUFFLEN, "MIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"%s\"\n", bound);
if (!write_buf(fd, buf)) {
return SWITCH_FALSE;
}
}
switch_snprintf(buf, B64BUFFLEN, "MIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"%s\"\n", bound);
if (!write_buf(fd, buf)) {
return SWITCH_FALSE;
}
if (headers && !write_buf(fd, headers))
@ -386,15 +385,13 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, const char *fr
if (!write_buf(fd, "\n\n"))
return SWITCH_FALSE;
if (file) {
if (body && switch_stristr("content-type", body)) {
switch_snprintf(buf, B64BUFFLEN, "--%s\n", bound);
} else {
switch_snprintf(buf, B64BUFFLEN, "--%s\nContent-Type: text/plain\n\n", bound);
}
if (!write_buf(fd, buf))
return SWITCH_FALSE;
}
if (body && switch_stristr("content-type", body)) {
switch_snprintf(buf, B64BUFFLEN, "--%s\n", bound);
} else {
switch_snprintf(buf, B64BUFFLEN, "--%s\nContent-Type: text/plain\n\n", bound);
}
if (!write_buf(fd, buf))
return SWITCH_FALSE;
if (body) {
if (!write_buf(fd, body)) {
@ -456,11 +453,9 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, const char *fr
}
if (file) {
switch_snprintf(buf, B64BUFFLEN, "\n\n--%s--\n.\n", bound);
if (!write_buf(fd, buf))
return SWITCH_FALSE;
}
switch_snprintf(buf, B64BUFFLEN, "\n\n--%s--\n.\n", bound);
if (!write_buf(fd, buf))
return SWITCH_FALSE;
}
if (fd) {
@ -478,7 +473,6 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, const char *fr
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "failed to delete file [%s]\n", filename);
}
if (file) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Emailed file [%s] to [%s]\n", filename, to);
} else {