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