char *web_tail;
char *email_from;
char *date_fmt;
+ char *convert_cmd;
+ char *convert_ext;
date_location_t play_date_announcement;
uint32_t digit_timeout;
uint32_t max_login_attempts;
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "play-date-announcement", SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE,
&profile->play_date_announcement, VM_DATE_FIRST, &config_play_date_announcement, NULL, NULL);
-
+
+ SWITCH_CONFIG_SET_ITEM(profile->config[i++], "convert-cmd", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+ &profile->convert_cmd, NULL, &profile->config_str_pool, NULL, NULL);
+ SWITCH_CONFIG_SET_ITEM(profile->config[i++], "convert-ext", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+ &profile->convert_ext, NULL, &profile->config_str_pool, NULL, NULL);
+
+
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "digit-timeout", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
&profile->digit_timeout, 10000, &config_int_digit_timeout, NULL, NULL);
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "max-login-attempts", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
int want;
msg_type_t type;
msg_move_t move;
+ char *convert_cmd;
+ char *convert_ext;
};
typedef struct listen_callback listen_callback_t;
body = switch_mprintf("%u second Voicemail from %s %s", message_len, cbt->cid_name, cbt->cid_number);
}
- switch_simple_email(cbt->email, from, header_string, body, cbt->file_path);
+ switch_simple_email(cbt->email, from, header_string, body, cbt->file_path, cbt->convert_cmd, cbt->convert_ext);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Sending message to %s\n", cbt->email);
switch_safe_free(body);
TRY_CODE(switch_ivr_phrase_macro(session, VM_ACK_MACRO, "emailed", NULL, NULL));
int total_saved_urgent_messages = 0;
int heard_auto_saved = 0, heard_auto_new = 0;
char *vm_email = NULL;
+ char *convert_cmd = profile->convert_cmd;
+ char *convert_ext = profile->convert_ext;
char *vm_storage_dir = NULL;
char global_buf[2] = "";
switch_input_args_t args = { 0 };
&total_new_urgent_messages, &total_saved_urgent_messages);
memset(&cbt, 0, sizeof(cbt));
cbt.email = vm_email;
+ cbt.convert_cmd = convert_cmd;
+ cbt.convert_ext = convert_ext;
cbt.move = VM_MOVE_NEXT;
switch (play_msg_type) {
case MSG_NEW:
}
} else if (!strcasecmp(var, "vm-mailto")) {
vm_email = switch_core_session_strdup(session, val);
+ } else if (!strcasecmp(var, "vm-convert-cmd")) {
+ convert_cmd = switch_core_session_strdup(session, val);
+ } else if (!strcasecmp(var, "vm-convert-ext")) {
+ convert_ext = switch_core_session_strdup(session, val);
} else if (!strcasecmp(var, "storage-dir")) {
vm_storage_dir = switch_core_session_strdup(session, val);
-
+
} else if (!strcasecmp(var, "timezone")) {
switch_channel_set_variable(channel, var, val);
}
const char *tmp;
switch_event_t *local_event = NULL;
switch_status_t ret = SWITCH_STATUS_SUCCESS;
-
+ char *convert_cmd = profile->convert_cmd;
+ char *convert_ext = profile->convert_ext;
+
if (!params) {
switch_event_create(&local_event, SWITCH_EVENT_REQUEST_PARAMS);
params = local_event;
insert_db = switch_true(val);
} else if (!strcasecmp(var, "vm-attach-file")) {
email_attach = switch_true(val);
+ } else if (!strcasecmp(var, "vm-convert-cmd")) {
+ convert_cmd = switch_core_strdup(pool, val);
+ } else if (!strcasecmp(var, "vm-convert-ext")) {
+ convert_ext = switch_core_strdup(pool, val);
} else if (!strcasecmp(var, "timezone")) {
vm_timezone = switch_core_strdup(pool, val);
}
}
if (email_attach) {
- switch_simple_email(vm_email, from, header_string, body, file_path);
+ switch_simple_email(vm_email, from, header_string, body, file_path, convert_cmd, convert_ext);
} else {
- switch_simple_email(vm_email, from, header_string, body, NULL);
+ switch_simple_email(vm_email, from, header_string, body, NULL, NULL, NULL);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending message to %s\n", vm_email);
body = switch_mprintf("%u second Voicemail from %s %s", message_len, caller_id_name, caller_id_number);
}
- switch_simple_email(vm_notify_email, from, header_string, body, NULL);
+ switch_simple_email(vm_notify_email, from, header_string, body, NULL, NULL, NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending notify message to %s\n", vm_notify_email);
return 1;
}
-SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, const char *from, const char *headers, const char *body, const char *file)
+SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
+ const char *from,
+ const char *headers,
+ const char *body,
+ const char *file,
+ const char *convert_cmd,
+ const char *convert_ext)
{
char *bound = "XXXX_boundary_XXXX";
const char *mime_type = "audio/inline";
unsigned int b = 0, l = 0;
unsigned char in[B64BUFFLEN];
unsigned char out[B64BUFFLEN + 512];
+ char *dupfile = NULL, *ext = NULL;
+ char *newfile = NULL;
+ switch_bool_t rval = SWITCH_FALSE;
+
+ if (!switch_strlen_zero(file) && !switch_strlen_zero(convert_cmd) && !switch_strlen_zero(convert_ext)) {
+ if ((ext = strrchr(file, '.'))) {
+ dupfile = strdup(file);
+ if ((ext = strrchr(dupfile, '.'))) {
+ *ext++ = '\0';
+ newfile = switch_mprintf("%s.%s", dupfile, convert_ext);
+ }
+ }
+
+ if (newfile) {
+ char cmd[1024] = "";
+ switch_snprintf(cmd, sizeof(cmd), "%s %s %s", convert_cmd, file, newfile);
+ switch_system(cmd, SWITCH_TRUE);
+ file = newfile;
+ }
+
+ switch_safe_free(dupfile);
+ }
switch_snprintf(filename, 80, "%smail.%d%04x", SWITCH_GLOBAL_dirs.temp_dir, (int) switch_epoch_time_now(NULL), rand() & 0xffff);
if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644))) {
if (file) {
if ((ifd = open(file, O_RDONLY | O_BINARY)) < 1) {
- return SWITCH_FALSE;
+ rval = SWITCH_FALSE; goto end;
}
}
switch_snprintf(buf, B64BUFFLEN, "MIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"%s\"\n", bound);
if (!write_buf(fd, buf)) {
- return SWITCH_FALSE;
+ rval = SWITCH_FALSE; goto end;
}
if (headers && !write_buf(fd, headers))
- return SWITCH_FALSE;
+ rval = SWITCH_FALSE; goto end;
if (!write_buf(fd, "\n\n"))
- return SWITCH_FALSE;
+ rval = SWITCH_FALSE; goto end;
if (body && switch_stristr("content-type", body)) {
switch_snprintf(buf, B64BUFFLEN, "--%s\n", bound);
switch_snprintf(buf, B64BUFFLEN, "--%s\nContent-Type: text/plain\n\n", bound);
}
if (!write_buf(fd, buf))
- return SWITCH_FALSE;
+ rval = SWITCH_FALSE; goto end;
if (body) {
if (!write_buf(fd, body)) {
- return SWITCH_FALSE;
+ rval = SWITCH_FALSE; goto end;
}
}
"Content-Description: Sound attachment.\n"
"Content-Disposition: attachment; filename=\"%s\"\n\n", bound, mime_type, stipped_file, stipped_file);
if (!write_buf(fd, buf))
- return SWITCH_FALSE;
+ rval = SWITCH_FALSE; goto end;
while ((ilen = read(ifd, in, B64BUFFLEN))) {
for (x = 0; x < ilen; x++) {
}
}
if (write(fd, &out, bytes) != bytes) {
- return -1;
+ rval = -1;
} else
bytes = 0;
out[bytes++] = '=', l += 2;
}
if (write(fd, &out, bytes) != bytes) {
- return -1;
+ rval = -1;
}
}
switch_snprintf(buf, B64BUFFLEN, "\n\n--%s--\n.\n", bound);
if (!write_buf(fd, buf))
- return SWITCH_FALSE;
+ rval = SWITCH_FALSE; goto end;
}
if (fd) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Emailed data to [%s]\n", to);
}
- return SWITCH_TRUE;
+ rval = SWITCH_TRUE;
+
+ end:
+
+ if (newfile) {
+ unlink(newfile);
+ free(newfile);
+ }
+
+ return rval;
}
SWITCH_DECLARE(switch_bool_t) switch_is_lan_addr(const char *ip)