1 #ifndef ZOIDBERG_MAIL_ATTACHMENT_H 2 #define ZOIDBERG_MAIL_ATTACHMENT_H 3 /* Attachment - classes which handle mail attachments 4 ** 5 ** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved. 6 */ 7 8 9 #include <Node.h> 10 11 #include <MailContainer.h> 12 #include <MailComponent.h> 13 14 class BFile; 15 16 class BMailAttachment : public BMailComponent { 17 public: 18 virtual void SetFileName(const char *name) = 0; 19 virtual status_t FileName(char *name) = 0; 20 21 virtual status_t SetTo(BFile *file, bool deleteFileWhenDone = false) = 0; 22 virtual status_t SetTo(entry_ref *ref) = 0; 23 24 virtual status_t InitCheck() = 0; 25 26 private: 27 virtual void _ReservedAttachment1(); 28 virtual void _ReservedAttachment2(); 29 virtual void _ReservedAttachment3(); 30 virtual void _ReservedAttachment4(); 31 }; 32 33 class BSimpleMailAttachment : public BMailAttachment { 34 public: 35 BSimpleMailAttachment(BPositionIO *dataToAttach, mail_encoding encoding = base64); 36 BSimpleMailAttachment(const void *dataToAttach, size_t lengthOfData, mail_encoding encoding = base64); 37 38 BSimpleMailAttachment(BFile *file, bool delete_when_done); 39 BSimpleMailAttachment(entry_ref *ref); 40 41 BSimpleMailAttachment(); 42 virtual ~BSimpleMailAttachment(); 43 44 virtual status_t SetTo(BFile *file, bool delete_file_when_done = false); 45 virtual status_t SetTo(entry_ref *ref); 46 47 virtual status_t InitCheck(); 48 49 virtual void SetFileName(const char *name); 50 virtual status_t FileName(char *name); 51 52 virtual status_t GetDecodedData(BPositionIO *data); 53 virtual status_t SetDecodedData(BPositionIO *data); 54 55 virtual BPositionIO *GetDecodedData(); 56 virtual status_t SetDecodedData(const void *data, size_t length /* data to attach */); 57 virtual status_t SetDecodedDataAndDeleteWhenDone(BPositionIO *data); 58 59 void SetEncoding(mail_encoding encoding = base64 /* note: we only support base64. This is a no-op */); 60 mail_encoding Encoding(); 61 62 virtual status_t SetToRFC822(BPositionIO *data, size_t length, bool parse_now = false); 63 virtual status_t RenderToRFC822(BPositionIO *render_to); 64 65 private: 66 void Initialize(mail_encoding encoding); 67 void ParseNow(); 68 69 virtual void _ReservedSimple1(); 70 virtual void _ReservedSimple2(); 71 virtual void _ReservedSimple3(); 72 73 status_t fStatus; 74 BPositionIO *_data, *_raw_data; 75 size_t _raw_length; 76 off_t _raw_offset; 77 bool _we_own_data; 78 mail_encoding _encoding; 79 80 uint32 _reserved[5]; 81 }; 82 83 class BAttributedMailAttachment : public BMailAttachment { 84 public: 85 BAttributedMailAttachment(BFile *file, bool delete_when_done); 86 BAttributedMailAttachment(entry_ref *ref); 87 88 BAttributedMailAttachment(); 89 virtual ~BAttributedMailAttachment(); 90 91 virtual status_t SetTo(BFile *file, bool delete_file_when_done = false); 92 virtual status_t SetTo(entry_ref *ref); 93 94 virtual status_t InitCheck(); 95 96 void SaveToDisk(BEntry *entry); 97 //-----we pay no attention to entry, but set it to the location of our file in /tmp 98 99 void SetEncoding(mail_encoding encoding /* anything but uuencode */); 100 mail_encoding Encoding(); 101 102 virtual status_t FileName(char *name); 103 virtual void SetFileName(const char *name); 104 105 virtual status_t GetDecodedData(BPositionIO *data); 106 virtual status_t SetDecodedData(BPositionIO *data); 107 108 virtual status_t SetToRFC822(BPositionIO *data, size_t length, bool parse_now = false); 109 virtual status_t RenderToRFC822(BPositionIO *render_to); 110 111 virtual status_t MIMEType(BMimeType *mime); 112 113 private: 114 status_t Initialize(); 115 116 virtual void _ReservedAttributed1(); 117 virtual void _ReservedAttributed2(); 118 virtual void _ReservedAttributed3(); 119 120 BMIMEMultipartMailContainer *fContainer; 121 status_t fStatus; 122 123 BSimpleMailAttachment *_data, *_attributes_attach; 124 BMessage _attributes; 125 126 uint32 _reserved[5]; 127 }; 128 129 #endif /* ZOIDBERG_MAIL_ATTACHMENT_H */ 130