connwrap - initialize gnutls session in cw_connect
[centerim.git] / libmsn / msn / message.h
blobfeec5ee63df733b78d888e37e13227720a67df27
1 #ifndef __msn_message_h__
2 #define __msn_message_h__
4 /*
5 * message.h
6 * libmsn
8 * Created by Mark Rowe on Wed Mar 17 2004.
9 * Copyright (c) 2004 Mark Rowe. All rights reserved.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <string>
27 #include <msn/sstream_fix.h>
28 #include <map>
29 #include <vector>
30 #include <stdexcept>
32 namespace MSN
35 /** This class represents an MSN message
37 * It may or may not represent an @e instant @e message.
39 * @todo Complete read/write support for formatting messages.
41 class Message
43 public:
44 enum FontEffects
46 BOLD_FONT = 1,
47 ITALIC_FONT = 2,
48 UNDERLINE_FONT = 4,
49 STRIKETHROUGH_FONT = 8
52 enum CharacterSet
54 ANSI_CHARSET = 0x00,
55 DEFAULT_CHARSET = 0x01,
56 SYMBOL_CHARSET = 0x02,
57 MAC_CHARSET = 0x4d,
58 SHIFTJIS_CHARSET = 0x80,
59 HANGEUL_CHARSET = 0x81,
60 JOHAB_CHARSET = 0x82,
61 GB2312_CHARSET = 0x86,
62 CHINESEBIG5_CHARSET = 0x88,
63 GREEK_CHARSET = 0xa1,
64 TURKISH_CHARSET = 0xa2,
65 VIETNAMESE_CHARSET = 0xa3,
66 HEBREW_CHARSET = 0xb1,
67 ARABIC_CHARSET = 0xb2,
68 BALTIC_CHARSET = 0xba,
69 RUSSIAN_CHARSET_DEFAULT = 0xcc,
70 THAI_CHARSET = 0xde,
71 EASTEUROPE_CHARSET = 0xee,
72 OEM_DEFAULT = 0xff
75 enum FontFamily
77 FF_DONTCARE = 0,
78 FF_ROMAN = 1,
79 FF_SWISS = 2,
80 FF_MODERN = 3,
81 FF_SCRIPT = 4,
82 FF_DECORATIVE = 5
85 enum FontPitch
87 DEFAULT_PITCH = 0,
88 FIXED_PITCH = 1,
89 VARIABLE_PITCH = 2
92 class Headers
94 public:
95 Headers(const std::string & rawContents_) : rawContents(rawContents_) {};
96 Headers() : rawContents("") {};
97 std::string asString() const;
98 std::string operator[](const std::string header) const;
99 void setHeader(const std::string header, const std::string value);
101 private:
102 std::string rawContents;
105 private:
106 std::string body;
107 Message::Headers header;
109 public:
110 /** Create a message with the specified @a body and @a mimeHeader.
112 Message(std::string body, std::string mimeHeader="MIME-Version: 1.0\r\nContent-Type: text/plain; charset=UTF-8\r\n\r\n");
114 /** Convert the Message into a string.
116 * This returns a string containing the MIME headers separated from the
117 * message body by a blank line.
119 std::string asString() const;
121 /** Return the value of the MIME header named @a header.
123 * @return The value of the MIME header if present, or "" if not found.
125 std::string operator[](const std::string header) const;
126 void setHeader(const std::string name, const std::string value) { header.setHeader(name, value); };
128 /** Return the body portion of this Message.
130 const std::string & getBody() const { return body; };
132 /** Return the font name used in this Message.
134 * @return The font name used for this Message, or "" if none specified.
136 const std::string getFontName() const;
138 /** Set font name for use in this Message.
140 void setFontName(const std::string & fontName);
142 /** Get the color used in this Message.
144 const std::vector<int> getColor() const;
145 const std::string getColorAsHTMLString() const;
147 /** Set the color used in this Message.
149 void setColor(std::vector<int> color);
150 void setColor(std::string color);
151 void setColor(int red, int green, int blue);
153 /** Return the font effects used in this Message.
155 * @return An integer that is a bitwise-or of Message::FontEffects members.
157 const int getFontEffects() const;
159 /** Set the font effects for use in this Message.
161 * @param fontEffects Bitwise-or of Message::FontEffects members.
163 void setFontEffects(int fontEffects);
165 /** Return the character set that the font uses in this Message.
167 const CharacterSet getFontCharacterSet() const;
169 /** Set the character set that the font should use for this Message.
171 void setFontCharacterSet(CharacterSet cs);
173 /** Return the font family used in this Message.
175 const FontFamily getFontFamily() const;
177 /** Return the font pitch used in this Message.
179 const FontPitch getFontPitch() const;
181 /** Set the font family and pitch to be used for this Message.
183 void setFontFamilyAndPitch(Message::FontFamily fontFamily, Message::FontPitch fontPitch);
185 /** Is the Message to be right-aligned?
187 const bool isRightAligned() const;
189 private:
190 std::map<std::string, std::string> getFormatInfo() const throw (std::runtime_error);
191 void setFormatInfo(std::map<std::string, std::string> & info);
195 #endif