DomainPlug-insDocumentation
|
00001 #ifndef _MAILMESSAGE_H_ 00002 #define _MAILMESSAGE_H 00003 00004 #include <stlrt/atypes.h> 00005 #include <Comm/atracer.h> 00006 00007 #include <mailmessageconfig.h> 00008 00009 /* 00010 * Workaround int_types provided by libetpan itself 00011 */ 00012 #define C99_STDINT_PROVIDED 00013 00038 enum MM_MAILMIME { 00039 MM_MAILMIME_MECHANISM_ERROR, 00040 MM_MAILMIME_MECHANISM_7BIT, 00041 MM_MAILMIME_MECHANISM_8BIT, 00042 MM_MAILMIME_MECHANISM_BINARY, 00043 MM_MAILMIME_MECHANISM_QUOTED_PRINTABLE, 00044 MM_MAILMIME_MECHANISM_BASE64, 00045 MM_MAILMIME_MECHANISM_TOKEN 00046 }; 00047 00052 struct MAILMESSAGE_DECL MailBox { 00053 Str Addr, Name; 00054 00059 MailBox(Str a, Str n) { 00060 Addr = a; Name = n; 00061 } 00062 }; 00063 00064 00070 struct MAILMESSAGE_DECL MailAttachment{ 00071 MailAttachment(); 00072 00076 RealBlob Body; 00077 00081 Str Filename; 00082 00086 Str Charset; 00087 00091 Str ContentType; 00092 00093 00097 bool Html,Text,Image,Audio,Video,Application; 00098 int ContentTransferEncoding; 00099 00101 00105 const RealBlob & getBody(void) const; 00106 00108 00112 void setBody(const RealBlob & Body); 00113 00115 00119 const Str & getFilename(void) const; 00120 00122 00126 void setFilename(const Str & Filename); 00127 00129 00133 const Str & getCharset(void) const; 00134 00136 00140 void setCharset(const Str & Charset); 00141 00143 00147 const Str & getContentType(void) const; 00148 00150 00154 void setContentType(const Str & ContentType); 00155 00160 bool isHtml(void) const; 00161 00166 void setHtml(bool Html); 00167 00172 bool isText(void) const; 00173 00178 void setText(bool Text); 00179 00184 bool isImage(void) const; 00185 00190 void setImage(bool Image); 00191 00196 bool isAudio(void) const; 00197 00202 void setAudio(bool Audio); 00203 00208 bool isVideo(void) const; 00209 00214 void setVideo(bool Video); 00215 00220 bool isApplication(void) const; 00221 00226 void setApplication(bool Application); 00227 00234 void setContentTransferEncoding(int input ); 00235 00242 int getContentTransferEncoding(void); 00243 }; 00244 00245 00250 struct MAILMESSAGE_DECL MailMessage { 00251 Str FromName, 00252 FromAddr, 00253 ToName, 00254 ToAddr, 00255 Subject, 00256 BccName, 00257 BccAddr, 00258 CcName, 00259 CcAddr, 00260 ContentType, 00261 Charset, 00262 Body, 00263 FullHeader, 00264 ReportType; 00265 00266 Str OriginSubject, 00267 OriginFromName, 00268 OriginToName; 00269 00270 /* builder options: */ 00271 int ContentTransferEncoding; 00272 00273 auto_ptr< char > data_str; 00274 size_t data_len; 00275 int Date; 00276 std::list<MailAttachment> Attachments; 00277 std::list< std::pair<Str, Str> > CustomHeaders; 00278 std::list< MailBox > TOs; 00279 std::list< MailBox > BCCs; 00280 std::list< MailBox > CCs; 00281 00282 00286 MailMessage(); 00287 00293 MailMessage(Str input); 00294 virtual ~MailMessage(); 00295 00301 const Str & getFromName(void) const; 00302 00307 void setFromName(const Str & FromName); 00308 00314 void setFromName(const Str & FromName, const Str &toEnc); 00315 00320 const Str & getFromAddr(void) const; 00321 00326 void setFromAddr(const Str & FromAddr); 00327 00332 const Str & getToName(void) const; 00333 00338 void setToName(const Str & ToName); 00339 00345 void setToName(const Str & ToName, const Str &toEnc); 00346 00351 const Str & getToAddr(void) const; 00352 00357 void setToAddr(const Str & ToAddr); 00358 00363 int getDate(void) const; 00364 00369 void setDate(int Date); 00370 00375 const Str & getSubject(void) const; 00376 00381 void setSubject(const Str & Subject); 00382 00388 void setSubject(const Str & Subject, const Str &toEnc); 00389 00394 const Str & getCcName(void) const; 00395 00400 void setCcName(const Str & CcName); 00401 00406 const Str & getCcAddr(void) const; 00407 00412 void setCcAddr(const Str & CcAddr); 00413 00418 const Str & getBccName(void) const; 00419 00424 void setBccName(const Str & BccName); 00425 00430 const Str & getBccAddr(void) const; 00431 00436 void setBccAddr(const Str & BccAddr); 00437 00442 const Str & getBody(void) const; 00443 00448 void setBody(const Str & Body); 00449 00454 const Str & getFullHeader(void) const; 00455 00460 void setFullHeader(const Str & FullHeader); 00461 00466 const Str & getContentType(void) const; 00467 00472 void setContentType(const Str & ContentType); 00473 00478 const Str & getReportType(void) const; 00479 00484 void setReportType(const Str & ReportType); 00485 00490 const Str & getCharset(void) const; 00491 00496 void setCharset(const Str & Charset); 00497 00504 void setContentTransferEncoding(int); 00505 00512 int getContentTransferEncoding(void); 00513 00518 size_t getAttachments(void) const; 00519 00525 MailAttachment getAttachment(size_t index) const; 00526 00528 00532 void addAttachment(const MailAttachment & Attachment); 00533 00538 std::multimap< Str, Str > getCustomHeaders(void) const; 00539 00540 static Str decodeStr(const Str & str,const Str & code); 00541 static Str decodeStrUTF8(const Str & str); 00542 static Str decodeStrElement(const Str & str,const Str & code); 00543 Str encodeUTFStr (Str source, Str toEnc); 00544 Str encodeUTFStrPart (Str part, Str toEnc); 00545 bool is_line_ascii (const Str & in); 00546 int count_quoted_size(const Str &in); 00547 int count_base64_size(const Str & in); 00548 00550 //parser: 00551 void parseMail( struct mailmime * mime ); 00552 void setFields(struct mailimf_fields * fields); 00553 struct mailimf_fields * parseFields(void); 00554 int getMailMimePartType(struct mailmime * mime); 00555 int getMailMimeMainType(struct mailmime * mime); 00556 Str getMailMimeContentType(struct mailmime * mime); 00557 int getMailMimeDiscreteType(struct mailmime * mime); 00558 Str getMailMimeDiscreteTypeStr(struct mailmime * mime); 00559 int getMailMimeCompositeType(struct mailmime * mime); 00560 Str getMailMimeCompositeTypeStr(struct mailmime * mime); 00561 void getAttachments(std::list<MailAttachment> & attachment,struct mailmime * mime); 00562 void getAttachment(MailAttachment * Attachment,struct mailmime * mime_part); 00563 //builder: 00564 struct mailimf_fields * buildFields(void); 00565 struct mailmime * buildMessage(struct mailimf_fields * fields); 00566 struct mailmime * buildBodyText(void); 00567 struct mailmime * buildBodyAttachment(MailAttachment &attach); 00568 00573 Str stringify(void); 00574 00581 Int sendMail(Int collectorID, Int secureBody = 0); 00582 }; 00583 00584 #endif