[Freeswitch-svn] [commit] r8655 - in freeswitch/trunk/src: . mod/applications/mod_voicemail
Freeswitch SVN
mikej at freeswitch.org
Sun May 25 22:51:34 EDT 2008
Author: mikej
Date: Sun May 25 22:51:34 2008
New Revision: 8655
Modified:
freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
freeswitch/trunk/src/switch_utils.c
Log:
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
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 Sun May 25 22:51:34 2008
@@ -952,8 +952,10 @@
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 @@
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 @@
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 @@
}
}
- 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 @@
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 @@
} 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);
}
Modified: freeswitch/trunk/src/switch_utils.c
==============================================================================
--- freeswitch/trunk/src/switch_utils.c (original)
+++ freeswitch/trunk/src/switch_utils.c Sun May 25 22:51:34 2008
@@ -373,11 +373,10 @@
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 @@
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 @@
}
- 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_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 {
More information about the Freeswitch-svn
mailing list