summaryrefslogtreecommitdiffstats
path: root/mailnews/compose/src/nsMsgCompUtils.h
blob: 13d6ddd83de5350c1aa920b2c7d3e666cef1e792 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef _nsMsgCompUtils_H_
#define _nsMsgCompUtils_H_

#include "nscore.h"
#include "nsMsgSend.h"
#include "nsMsgCompFields.h"
#include "nsIMsgSend.h"
#include "nsIMsgCompUtils.h"

class nsIPrompt; 

#define ANY_SERVER "anyfolder://"

// these are msg hdr property names for storing the original
// msg uri's and disposition(replied/forwarded) when queuing
// messages to send later.
#define ORIG_URI_PROPERTY "origURIs"
#define QUEUED_DISPOSITION_PROPERTY "queuedDisposition"

class nsMsgCompUtils : public nsIMsgCompUtils
{
public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSIMSGCOMPUTILS

  nsMsgCompUtils();

private:
  virtual ~nsMsgCompUtils();
};

PR_BEGIN_EXTERN_C

//
// Create a file spec or file name using the name passed
// in as a template
//
nsresult    nsMsgCreateTempFile(const char *tFileName, nsIFile **tFile);
char        *nsMsgCreateTempFileName(const char *tFileName);


//
// Various utilities for building parts of MIME encoded 
// messages during message composition
//

nsresult    mime_sanity_check_fields_recipients (
                            const char *to,
                            const char *cc,
                            const char *bcc,
                            const char *newsgroups);

nsresult    mime_sanity_check_fields (
                            const char *from,
                            const char *reply_to,
                            const char *to,
                            const char *cc,
                            const char *bcc,
                            const char *fcc,
                            const char *newsgroups,
                            const char *followup_to,
                            const char * /*subject*/,
                            const char * /*references*/,
                            const char * /*organization*/,
                            const char * /*other_random_headers*/);

nsresult mime_generate_headers(nsIMsgCompFields *fields,
                               nsMsgDeliverMode deliver_mode,
                               msgIWritableStructuredHeaders *headers);

char        *mime_make_separator(const char *prefix);
char        *mime_gen_content_id(uint32_t aPartNum, const char *aEmailAddress);

char        *mime_generate_attachment_headers (
                           const char *type,
                           const char *type_param,
                           const char *encoding,
                           const char *description,
                           const char *x_mac_type,
                           const char *x_mac_creator,
                           const char *real_name,
                           const char *base_url,
                           bool digest_p,
                           nsMsgAttachmentHandler *ma,
                           const char *attachmentCharset, // charset of the attachment (can be null)
                           const char *bodyCharset,       // charset of the main body
                           bool bodyIsAsciiOnly,
                           const char *content_id,
                           bool       aBodyDocument);

char        *msg_generate_message_id (nsIMsgIdentity*);

bool        mime_7bit_data_p (const char *string, uint32_t size);

char        *mime_fix_header_1 (const char *string, bool addr_p, bool news_p);
char        *mime_fix_header (const char *string);
char        *mime_fix_addr_header (const char *string);
char        *mime_fix_news_header (const char *string);

bool        mime_type_requires_b64_p (const char *type);
bool        mime_type_needs_charset (const char *type);

char        *msg_make_filename_qtext(const char *srcText, bool stripCRLFs);

// Rip apart the URL and extract a reasonable value for the `real_name' slot.
void        msg_pick_real_name (nsMsgAttachmentHandler *attachment, const char16_t *proposedName, const char *charset);

//
// Informational calls...
//
void        nsMsgMIMESetConformToStandard (bool conform_p);
bool        nsMsgMIMEGetConformToStandard (void);

//
// network service type calls...
//
nsresult    nsMsgNewURL(nsIURI** aInstancePtrResult, const char * aSpec);
bool        nsMsgIsLocalFile(const char *url);
char        *nsMsgGetLocalFileFromURL(const char *url);

char        *nsMsgParseURLHost(const char *url);

char        *GenerateFileNameFromURI(nsIURI *aURL);

//
// Folder calls...
//
void GetFolderURIFromUserPrefs(nsMsgDeliverMode   aMode, nsIMsgIdentity *identity, nsCString& uri);

// Check if we should use format=flowed
void GetSerialiserFlags(const char *charset, bool *flowed, bool *delsp, bool *formatted, bool *disallowBreaks);


PR_END_EXTERN_C


#endif /* _nsMsgCompUtils_H_ */