message.h (5215B)
1 /* -*- Mode: c++; -*- */ 2 /* -------------------------------------------------------------------- 3 * Filename: 4 * src/mailbox/message.h 5 * 6 * Description: 7 * Declaration of the Message class. 8 * 9 * Authors: 10 * Andreas Aardal Hanssen <andreas-binc curly bincimap spot org> 11 * 12 * Bugs: 13 * 14 * ChangeLog: 15 * 16 * -------------------------------------------------------------------- 17 * Copyright 2002-2005 Andreas Aardal Hanssen 18 * 19 * This program is free software; you can redistribute it and/or modify 20 * it under the terms of the GNU General Public License as published by 21 * the Free Software Foundation; either version 2 of the License, or 22 * (at your option) any later version. 23 * 24 * This program is distributed in the hope that it will be useful, 25 * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 * GNU General Public License for more details. 28 * 29 * You should have received a copy of the GNU General Public License 30 * along with this program; if not, write to the Free Software 31 * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. 32 * -------------------------------------------------------------------- 33 */ 34 #ifdef HAVE_CONFIG_H 35 #include <config.h> 36 #endif 37 38 #ifndef message_h_included 39 #define message_h_included 40 #include <vector> 41 #include <string> 42 #include <time.h> 43 44 #ifndef UINTMAX 45 #define UINTMAX ((unsigned int)-1) 46 #endif 47 48 namespace Binc { 49 50 /*! 51 \class Message 52 \brief The Message class provides an interface for 53 IMAP messages. 54 55 Mailbox independent operations and properties are available 56 through this interface. 57 58 This class is an abstract, and has no implementation. 59 60 \sa MaildirMessage 61 */ 62 class Message { 63 public: 64 65 /*! 66 Standard IMAP message flags. 67 68 */ 69 enum Flags { 70 F_NONE = 0x00, /*!< No flag is set */ 71 F_SEEN = 0x01, /*!< The message has been seen */ 72 F_ANSWERED = 0x02, /*!< The message has been answered */ 73 F_DELETED = 0x04, /*!< The message is marked as deleted */ 74 F_DRAFT = 0x08, /*!< The message is a draft */ 75 F_RECENT = 0x10, /*!< The message arrived recently */ 76 F_FLAGGED = 0x20, /*!< The message is flagged / important */ 77 F_EXPUNGED = 0x40, /*!< The message has been expunged */ 78 }; 79 80 virtual void setUID(unsigned int) = 0; 81 virtual unsigned int getUID(void) const = 0; 82 83 virtual void setSize(unsigned int) = 0; 84 virtual unsigned int getSize(bool render = false) const = 0; 85 86 virtual void setStdFlag(unsigned char) = 0; 87 virtual void resetStdFlags(void) = 0; 88 virtual unsigned char getStdFlags(void) const = 0; 89 90 virtual void setFlagsUnchanged(void) = 0; 91 virtual bool hasFlagsChanged(void) const = 0; 92 93 virtual void setInternalDate(time_t) = 0; 94 virtual time_t getInternalDate(void) const = 0; 95 96 virtual void rewind(void) = 0; 97 virtual int readChunk(std::string &) = 0; 98 virtual bool appendChunk(const std::string &) = 0; 99 virtual void close(void) = 0; 100 101 virtual void setExpunged(void) = 0; 102 virtual void setUnExpunged(void) = 0; 103 virtual bool isExpunged(void) const = 0; 104 105 virtual const std::string &getHeader(const std::string &header) = 0; 106 107 virtual bool headerContains(const std::string &header, 108 const std::string &text) = 0; 109 110 virtual bool bodyContains(const std::string &text) = 0; 111 virtual bool textContains(const std::string &text) = 0; 112 113 virtual bool printBodyStructure(bool extended = true) const = 0; 114 115 virtual bool printEnvelope(void) const = 0; 116 117 virtual bool printHeader(const std::string §ion, 118 std::vector<std::string> headers, 119 bool includeHeaders = false, 120 unsigned int startOffset = 0, 121 unsigned int length = UINTMAX, 122 bool mime = false) const = 0; 123 virtual unsigned int getHeaderSize(const std::string §ion, 124 std::vector<std::string> headers, 125 bool includeHeaders = false, 126 unsigned int startOffset = 0, 127 unsigned int length = UINTMAX, 128 bool mime = false) const = 0; 129 130 virtual bool printBody(const std::string §ion, 131 unsigned int startOffset = 0, 132 unsigned int length = UINTMAX) const = 0; 133 virtual unsigned int getBodySize(const std::string §ion, 134 unsigned int startOffset = 0, 135 unsigned int length = UINTMAX) const = 0; 136 137 virtual bool printDoc(unsigned int startOffset = 0, 138 unsigned int length = UINTMAX, 139 bool onlyText = false) const = 0; 140 virtual unsigned int getDocSize(unsigned int startOffset = 0, 141 unsigned int length = UINTMAX, 142 bool onlyText = false) const = 0; 143 144 Message(void); 145 virtual ~Message(void); 146 147 void setLastError(const std::string &) const; 148 const std::string &getLastError(void) const; 149 150 private: 151 static std::string lastError; 152 }; 153 154 inline Message::Message(void) 155 { 156 } 157 158 inline Message::~Message(void) 159 { 160 } 161 162 inline void Message::setLastError(const std::string &error) const 163 { 164 lastError = error; 165 } 166 167 inline const std::string &Message::getLastError(void) const 168 { 169 return lastError; 170 } 171 } 172 173 #endif