aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_voicemail.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/app_voicemail.c')
-rw-r--r--apps/app_voicemail.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index c035aa9d1..16996c3f3 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -405,7 +405,11 @@ static AST_LIST_HEAD_STATIC(vmstates, vmstate);
#define BASELINELEN 72
#define BASEMAXINLINE 256
-#define eol "\r\n"
+#ifdef IMAP_STORAGE
+#define ENDL "\r\n"
+#else
+#define ENDL "\n"
+#endif
#define MAX_DATETIME_FORMAT 512
#define MAX_NUM_CID_CONTEXTS 10
@@ -3892,14 +3896,16 @@ static int inchar(struct baseio *bio, FILE *fi)
static int ochar(struct baseio *bio, int c, FILE *so)
{
if (bio->linelength >= BASELINELEN) {
- if (fputs(eol,so) == EOF)
+ if (fputs(ENDL, so) == EOF) {
return -1;
+ }
bio->linelength= 0;
}
- if (putc(((unsigned char)c),so) == EOF)
+ if (putc(((unsigned char) c), so) == EOF) {
return -1;
+ }
bio->linelength++;
@@ -3967,9 +3973,10 @@ static int base_encode(char *filename, FILE *so)
}
fclose(fi);
-
- if (fputs(eol,so)==EOF)
+
+ if (fputs(ENDL, so) == EOF) {
return 0;
+ }
return 1;
}
@@ -4174,11 +4181,6 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in
char *greeting_attachment;
char filename[256];
-#ifdef IMAP_STORAGE
-#define ENDL "\r\n"
-#else
-#define ENDL "\n"
-#endif
/* One alloca for multiple fields */
len_passdata2 = strlen(vmu->fullname);
@@ -4359,7 +4361,22 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in
memset(passdata, 0, vmlen);
prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, cidnum, cidname, dur, date, passdata, vmlen, category, flag);
pbx_substitute_variables_helper(ast, e_body, passdata, vmlen);
+#ifdef IMAP_STORAGE
+ {
+ /* Convert body to native line terminators for IMAP backend */
+ char *line = passdata, *next;
+ do {
+ /* Terminate line before outputting it to the file */
+ if ((next = strchr(line, '\n'))) {
+ *next++ = '\0';
+ }
+ fprintf(p, "%s" ENDL, line);
+ line = next;
+ } while (!ast_strlen_zero(line));
+ }
+#else
fprintf(p, "%s" ENDL, passdata);
+#endif
ast_channel_free(ast);
} else
ast_log(AST_LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
@@ -11313,7 +11330,7 @@ static int load_module(void)
/* compute the location of the voicemail spool directory */
snprintf(VM_SPOOL_DIR, sizeof(VM_SPOOL_DIR), "%s/voicemail/", ast_config_AST_SPOOL_DIR);
-
+
if (!(mwi_subscription_tps = ast_taskprocessor_get("app_voicemail", 0))) {
ast_log(AST_LOG_WARNING, "failed to reference mwi subscription taskprocessor. MWI will not work\n");
}