aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/rfc822/MCAttachment.h
blob: ae02d256c490f06ba527510f3fc84ef19148d72b (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
#ifndef MAILCORE_MCATTACHMENT_H

#define MAILCORE_MCATTACHMENT_H

#include <MailCore/MCBaseTypes.h>
#include <MailCore/MCAbstractPart.h>
#include <MailCore/MCAbstractMultipart.h>
#include <MailCore/MCMessageConstants.h>

#ifdef __cplusplus

namespace mailcore {
    
    class MessagePart;
    
    class MAILCORE_EXPORT Attachment : public AbstractPart {
    public:
        static String * mimeTypeForFilename(String * filename);
        static Attachment * attachmentWithContentsOfFile(String * filename);
        static Attachment * attachmentWithData(String * filename, Data * data);
        static Attachment * attachmentWithHTMLString(String * htmlString);
        static Attachment * attachmentWithRFC822Message(Data * messageData);
        static Attachment * attachmentWithText(String * text);
        
        Attachment();
        virtual ~Attachment();
        
        virtual void setPartID(String * partID);
        virtual String * partID();

        virtual void setData(Data * data);
        virtual Data * data();
        virtual String * decodedString();
        
    public: // subclass behavior
        Attachment(Attachment * other);
        virtual String * description();
        virtual Object * copy();
        
    public: // private
        static AbstractPart * attachmentsWithMIME(struct mailmime * mime);
        
    private:
        Data * mData;
        String * mPartID;

        void init();
        static void fillMultipartSubAttachments(AbstractMultipart * multipart, struct mailmime * mime);
        static AbstractPart * attachmentsWithMIMEWithMain(struct mailmime * mime, bool isMain);
        static Attachment * attachmentWithSingleMIME(struct mailmime * mime);
        static MessagePart * attachmentWithMessageMIME(struct mailmime * mime);
        static Encoding encodingForMIMEEncoding(struct mailmime_mechanism * mechanism, int defaultMimeEncoding);
        static HashMap * readMimeTypesFile(String * filename);
        void setContentTypeParameters(HashMap * parameters);
    };
    
}

#endif

#endif