libmsn 4.2
|
00001 #ifndef __msn_message_h__ 00002 #define __msn_message_h__ 00003 00004 /* 00005 * message.h 00006 * libmsn 00007 * 00008 * Created by Mark Rowe on Wed Mar 17 2004. 00009 * Refactored by Tiago Salem Herrmann on 08/2007. 00010 * Copyright (c) 2004 Mark Rowe. All rights reserved. 00011 * Copyright (c) 2007 Tiago Salem Herrmann. All rights reserved 00012 * 00013 * This program is free software; you can redistribute it and/or modify 00014 * it under the terms of the GNU General Public License as published by 00015 * the Free Software Foundation; either version 2 of the License, or 00016 * (at your option) any later version. 00017 * 00018 * This program is distributed in the hope that it will be useful, 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 * GNU General Public License for more details. 00022 * 00023 * You should have received a copy of the GNU General Public License 00024 * along with this program; if not, write to the Free Software 00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00026 */ 00027 00028 #ifdef WIN32 00029 #include <windows.h> 00030 #endif 00031 #include <string> 00032 #include <map> 00033 #include <vector> 00034 #include <stdexcept> 00035 00036 #include "libmsn_export.h" 00037 00038 #ifdef _MSC_VER 00039 #pragma warning( disable : 4290 ) 00040 #endif 00041 00042 namespace MSN 00043 { 00044 00051 class LIBMSN_EXPORT Message 00052 { 00053 public: 00054 enum FontEffects 00055 { 00056 BOLD_FONT = 1, 00057 ITALIC_FONT = 2, 00058 UNDERLINE_FONT = 4, 00059 STRIKETHROUGH_FONT = 8 00060 }; 00061 00062 #ifdef WIN32 00063 typedef int CharacterSet; 00064 typedef int FontFamily; 00065 typedef int FontPitch; 00066 #else 00067 enum CharacterSet 00068 { 00069 ANSI_CHARSET = 0x00, 00070 DEFAULT_CHARSET = 0x01, 00071 SYMBOL_CHARSET = 0x02, 00072 MAC_CHARSET = 0x4d, 00073 SHIFTJIS_CHARSET = 0x80, 00074 HANGEUL_CHARSET = 0x81, 00075 JOHAB_CHARSET = 0x82, 00076 GB2312_CHARSET = 0x86, 00077 CHINESEBIG5_CHARSET = 0x88, 00078 GREEK_CHARSET = 0xa1, 00079 TURKISH_CHARSET = 0xa2, 00080 VIETNAMESE_CHARSET = 0xa3, 00081 HEBREW_CHARSET = 0xb1, 00082 ARABIC_CHARSET = 0xb2, 00083 BALTIC_CHARSET = 0xba, 00084 RUSSIAN_CHARSET_DEFAULT = 0xcc, 00085 THAI_CHARSET = 0xde, 00086 EASTEUROPE_CHARSET = 0xee, 00087 OEM_DEFAULT = 0xff 00088 }; 00089 00090 enum FontFamily 00091 { 00092 FF_DONTCARE = 0, 00093 FF_ROMAN = 1, 00094 FF_SWISS = 2, 00095 FF_MODERN = 3, 00096 FF_SCRIPT = 4, 00097 FF_DECORATIVE = 5 00098 }; 00099 00100 enum FontPitch 00101 { 00102 DEFAULT_PITCH = 0, 00103 FIXED_PITCH = 1, 00104 VARIABLE_PITCH = 2 00105 }; 00106 #endif 00107 00108 class Headers 00109 { 00110 public: 00111 Headers(const std::string & rawContents_) : rawContents(rawContents_) {}; 00112 Headers() : rawContents("") {}; 00113 std::string asString() const; 00114 std::string operator[](const std::string header) const; 00115 void setHeader(const std::string header, const std::string value); 00116 00117 private: 00118 std::string rawContents; 00119 }; 00120 00121 private: 00122 std::string body; 00123 Message::Headers header; 00124 00125 public: 00128 Message(std::string body, std::string mimeHeader="MIME-Version: 1.0\r\nContent-Type: text/plain; charset=UTF-8\r\n\r\n"); 00129 00135 std::string asString() const; 00136 00141 std::string operator[](const std::string header) const; 00142 void setHeader(const std::string name, const std::string value) { header.setHeader(name, value); }; 00143 00146 std::string getBody() const { return body; }; 00147 00152 std::string getFontName() const; 00153 00156 void setFontName(const std::string & fontName); 00157 00160 std::vector<int> getColor() const; 00161 std::string getColorAsHTMLString() const; 00162 00165 void setColor(std::vector<int> color); 00166 void setColor(std::string color); 00167 void setColor(int red, int green, int blue); 00168 00173 int getFontEffects() const; 00174 00179 void setFontEffects(int fontEffects); 00180 00183 CharacterSet getFontCharacterSet() const; 00184 00187 void setFontCharacterSet(CharacterSet cs); 00188 00191 FontFamily getFontFamily() const; 00192 00195 FontPitch getFontPitch() const; 00196 00199 void setFontFamilyAndPitch(Message::FontFamily fontFamily, Message::FontPitch fontPitch); 00200 00203 bool isRightAligned() const; 00204 00205 private: 00206 std::map<std::string, std::string> getFormatInfo() const throw (std::runtime_error); 00207 void setFormatInfo(std::map<std::string, std::string> & info); 00208 }; 00209 00210 } 00211 #endif