1 Debian patch touch this file
| 1 | /* |
| 2 | ** CWConstants.h |
| 3 | ** |
| 4 | ** Copyright (c) 2001-2007 Ludovic Marcotte |
| 5 | ** Copyright (C) 2013-2017 The GNUstep team |
| 6 | ** |
| 7 | ** Author: Ludovic Marcotte <[email protected]> |
| 8 | ** Riccardo Mottola |
| 9 | ** |
| 10 | ** This library is free software; you can redistribute it and/or |
| 11 | ** modify it under the terms of the GNU Lesser General Public |
| 12 | ** License as published by the Free Software Foundation; either |
| 13 | ** version 2.1 of the License, or (at your option) any later version. |
| 14 | ** |
| 15 | ** This library is distributed in the hope that it will be useful, |
| 16 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | ** Lesser General Public License for more details. |
| 19 | ** |
| 20 | ** You should have received a copy of the GNU General Public License |
| 21 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | */ |
| 23 | |
| 24 | #ifndef _Pantomime_H_CWConstants |
| 25 | #define _Pantomime_H_CWConstants |
| 26 | |
| 27 | #ifdef GNUSTEP |
| 28 | #include <GNUstepBase/NSDebug+GNUstepBase.h> |
| 29 | #endif |
| 30 | |
| 31 | // |
| 32 | // The current version of Pantomime. |
| 33 | // |
| 34 | #define PANTOMIME_VERSION @"1.4.0" |
| 35 | |
| 36 | // |
| 37 | // Useful macros that we must define ourself on OS X. |
| 38 | // |
| 39 | #ifdef MACOSX |
| 40 | #define RETAIN(object) [object retain] |
| 41 | #define RELEASE(object) [object release] |
| 42 | #define AUTORELEASE(object) [object autorelease] |
| 43 | #define TEST_RELEASE(object) ({ if (object) [object release]; }) |
| 44 | #define ASSIGN(object,value) ({\ |
| 45 | id __value = (id)(value); \ |
| 46 | id __object = (id)(object); \ |
| 47 | if (__value != __object) \ |
| 48 | { \ |
| 49 | if (__value != nil) \ |
| 50 | { \ |
| 51 | [__value retain]; \ |
| 52 | } \ |
| 53 | object = __value; \ |
| 54 | if (__object != nil) \ |
| 55 | { \ |
| 56 | [__object release]; \ |
| 57 | } \ |
| 58 | } \ |
| 59 | }) |
| 60 | #define DESTROY(object) ({ \ |
| 61 | if (object) \ |
| 62 | { \ |
| 63 | id __o = object; \ |
| 64 | object = nil; \ |
| 65 | [__o release]; \ |
| 66 | } \ |
| 67 | }) |
| 68 | |
| 69 | #define NSLocalizedString(key, comment) \ |
| 70 | [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil] |
| 71 | |
| 72 | #define _(X) NSLocalizedString (X, @"") |
| 73 | #endif |
| 74 | |
| 75 | // |
| 76 | // We must define NSObject: -subclassResponsibility: on OS X. |
| 77 | // |
| 78 | #ifdef MACOSX |
| 79 | #import <Pantomime/CWMacOSXGlue.h> |
| 80 | #endif |
| 81 | |
| 82 | |
| 83 | // |
| 84 | // Only for older Mac versions |
| 85 | // |
| 86 | #if defined(__APPLE__) && (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4) |
| 87 | #ifndef NSUInteger |
| 88 | #define NSUInteger unsigned int |
| 89 | #endif |
| 90 | #ifndef NSInteger |
| 91 | #define NSInteger int |
| 92 | #endif |
| 93 | #endif |
| 94 | |
| 95 | |
| 96 | #ifndef NSDebugLog |
| 97 | #ifdef DEBUG |
| 98 | #define NSDebugLog(format, args...) \ |
| 99 | do { NSLog(format, ##args); } while(0) |
| 100 | #else |
| 101 | #define NSDebugLog(format, args...) |
| 102 | #endif |
| 103 | #endif |
| 104 | |
| 105 | // |
| 106 | // Some macros, to minimize the code. |
| 107 | // |
| 108 | #define PERFORM_SELECTOR_1(del, sel, name) ({ \ |
| 109 | \ |
| 110 | BOOL zBOOL; \ |
| 111 | \ |
| 112 | zBOOL = NO; \ |
| 113 | \ |
| 114 | if (del && [del respondsToSelector: sel]) \ |
| 115 | { \ |
| 116 | [del performSelector: sel \ |
| 117 | withObject: [NSNotification notificationWithName: name \ |
| 118 | object: self]]; \ |
| 119 | zBOOL = YES; \ |
| 120 | } \ |
| 121 | \ |
| 122 | zBOOL; \ |
| 123 | }) |
| 124 | |
| 125 | #define PERFORM_SELECTOR_2(del, sel, name, obj, key) \ |
| 126 | if (del && [del respondsToSelector: sel]) \ |
| 127 | { \ |
| 128 | [del performSelector: sel \ |
| 129 | withObject: [NSNotification notificationWithName: name \ |
| 130 | object: self \ |
| 131 | userInfo: [NSDictionary dictionaryWithObject: obj forKey: key]]]; \ |
| 132 | } |
| 133 | |
| 134 | #define PERFORM_SELECTOR_3(del, sel, name, info) \ |
| 135 | if (del && [del respondsToSelector: sel]) \ |
| 136 | { \ |
| 137 | [del performSelector: sel \ |
| 138 | withObject: [NSNotification notificationWithName: name \ |
| 139 | object: self \ |
| 140 | userInfo: info]]; \ |
| 141 | } |
| 142 | |
| 143 | #define AUTHENTICATION_COMPLETED(del, s) \ |
| •144 | POST_NOTIFICATION(PantomimeAuthenticationCompleted, self, [NSDictionary dictionaryWithObject: ((id)s != nil ?(id)s:(id)@"") forKey: @"Mechanism"]); \ |
| 145 | PERFORM_SELECTOR_2(del, @selector(authenticationCompleted:), PantomimeAuthenticationCompleted, ((id)s != nil ?(id)s:(id)@""), @"Mechanism"); |
| 146 | |
| 147 | |
| 148 | #define AUTHENTICATION_FAILED(del, s) \ |
| 149 | NSLog(@"AUTHENTICATION_FAILED: |%@|", s); \ |
| •150 | POST_NOTIFICATION(PantomimeAuthenticationFailed, self, [NSDictionary dictionaryWithObject: ((id)s != nil ?(id)s:(id)@"") forKey: @"Mechanism"]); \ |
| 151 | PERFORM_SELECTOR_2(del, @selector(authenticationFailed:), PantomimeAuthenticationFailed, ((id)s != nil ?(id)s:(id)@""), @"Mechanism"); |
| 152 | |
| 153 | #define POST_NOTIFICATION(name, obj, info) \ |
| 154 | [[NSNotificationCenter defaultCenter] postNotificationName: name \ |
| 155 | object: obj \ |
| 156 | userInfo: info] |
| 157 | |
| 158 | /*! |
| 159 | @typedef PantomimeEncoding |
| 160 | @abstract Supported encodings. |
| 161 | @discussion This enum lists the supported Content-Transfer-Encoding |
| 162 | values. See RFC 2045 - 6. Content-Transfer-Encoding Header Field |
| 163 | (all all sub-sections) for a detailed description of the |
| 164 | possible values. |
| 165 | @constant PantomimeEncodingNone No encoding. |
| 166 | @constant PantomimeEncoding7bit No encoding, same value as PantomimeEncodingNone. |
| 167 | @constant PantomimeEncodingQuotedPrintable The quoted-printable encoding. |
| 168 | @constant PantomimeEncodingBase64 The base64 encoding. |
| 169 | @constant PantomimeEncoding8bit Identity encoding. |
| 170 | @constant PantomimeEncodingBinary Identity encoding. |
| 171 | */ |
| 172 | typedef enum |
| 173 | { |
| 174 | PantomimeEncodingNone = 0, |
| 175 | PantomimeEncoding7bit = 0, |
| 176 | PantomimeEncodingQuotedPrintable = 1, |
| 177 | PantomimeEncodingBase64 = 2, |
| 178 | PantomimeEncoding8bit = 3, |
| 179 | PantomimeEncodingBinary = 4 |
| 180 | } PantomimeEncoding; |
| 181 | |
| 182 | |
| 183 | /*! |
| 184 | @typedef PantomimeFolderFormat |
| 185 | @abstract The supported folder formats. |
| 186 | @discussion Pantomime supports various local folder formats. Currently, |
| 187 | the mbox and maildir formats are supported. Also, a custom |
| 188 | format is defined to represent folder which holds folders |
| 189 | (ie., not messages). |
| 190 | @constant PantomimeFormatMbox The mbox format. |
| 191 | @constant PantomimeFormatMaildir The maildir format. |
| 192 | @constant PantomimeFormatMailSpoolFile The mail spool file, in mbox format but without cache synchronization. |
| 193 | @constant PantomimeFormatFolder Custom format. |
| 194 | */ |
| 195 | typedef enum { |
| 196 | PantomimeFormatMbox = 0, |
| 197 | PantomimeFormatMaildir = 1, |
| 198 | PantomimeFormatMailSpoolFile = 2, |
| 199 | PantomimeFormatFolder = 3 |
| 200 | } PantomimeFolderFormat; |
| 201 | |
| 202 | |
| 203 | /*! |
| 204 | @typedef PantomimeMessageFormat |
| 205 | @abstract The format of a message. |
| 206 | @discussion Pantomime supports two formats when encoding |
| 207 | plain/text parts. The formats are described in RFC 2646. |
| 208 | @constant PantomimeFormatUnknown Unknown format. |
| 209 | @constant PantomimeFormatFlowed The "format=flowed" is used. |
| 210 | */ |
| 211 | typedef enum |
| 212 | { |
| 213 | PantomimeFormatUnknown = 0, |
| 214 | PantomimeFormatFlowed = 1 |
| 215 | } PantomimeMessageFormat; |
| 216 | |
| 217 | |
| 218 | /*! |
| 219 | @typedef PantomimeFlag |
| 220 | @abstract Valid message flags. |
| 221 | @discussion This enum lists valid message flags. Flags can be combined |
| 222 | using a bitwise OR. |
| 223 | @constant PantomimeAnswered The message has been answered. |
| 224 | @constant PantomimeDraft The message is an unsent, draft message. |
| 225 | @constant PantomimeFlagged The message is flagged. |
| 226 | @constant PantomimeRecent The message has been recently received. |
| 227 | @constant PantomimeSeen The message has been read. |
| 228 | @constant PantomimeDeleted The message is marked as deleted. |
| 229 | */ |
| 230 | typedef enum |
| 231 | { |
| 232 | PantomimeAnswered = 1, |
| 233 | PantomimeDraft = 2, |
| 234 | PantomimeFlagged = 4, |
| 235 | PantomimeRecent = 8, |
| 236 | PantomimeSeen = 16, |
| 237 | PantomimeDeleted = 32 |
| 238 | } PantomimeFlag; |
| 239 | |
| 240 | |
| 241 | /*! |
| 242 | @typedef PantomimeFolderType |
| 243 | @abstract Flags/name attributes for mailboxes/folders. |
| 244 | @discussion This enum lists the potential mailbox / folder |
| 245 | flags which some IMAP servers can enforce. |
| 246 | Those flags have few meaning for POP3 and |
| 247 | Local mailboxes. Flags can be combined using |
| 248 | a bitwise OR. |
| 249 | @constant PantomimeHoldsFolders The folder holds folders. |
| 250 | @constant PantomimeHoldsMessages The folder holds messages. |
| 251 | @constant PantomimeNoInferiors The folder has no sub-folders. |
| 252 | @constant PantomimeNoSelect The folder can't be opened. |
| 253 | @constant PantomimeMarked The folder is marked as "interesting". |
| 254 | @constant PantomimeUnmarked The folder does not contain any new |
| 255 | messages since the last time it has been open. |
| 256 | */ |
| 257 | typedef enum |
| 258 | { |
| 259 | PantomimeHoldsFolders = 1, |
| 260 | PantomimeHoldsMessages = 2, |
| 261 | PantomimeNoInferiors = 4, |
| 262 | PantomimeNoSelect = 8, |
| 263 | PantomimeMarked = 16, |
| 264 | PantomimeUnmarked = 32 |
| 265 | } PantomimeFolderType; |
| 266 | |
| 267 | |
| 268 | /*! |
| 269 | @typedef PantomimeSearchMask |
| 270 | @abstract Mask for Folder: -search: mask: options: |
| 271 | @discussion This enum lists the possible values of the |
| 272 | search mask. Values can be combined using |
| 273 | a bitwise OR. |
| 274 | @constant PantomimeFrom Search in the "From:" header value. |
| 275 | @constant PantomimeTo Search in the "To:" header value. |
| 276 | @constant PantomimeSubject Search in the "Subject:" header value. |
| 277 | @constant PantomimeContent Search in the message content. |
| 278 | */ |
| 279 | typedef enum |
| 280 | { |
| 281 | PantomimeFrom = 1, |
| 282 | PantomimeTo = 2, |
| 283 | PantomimeSubject = 4, |
| 284 | PantomimeContent = 8 |
| 285 | } PantomimeSearchMask; |
| 286 | |
| 287 | |
| 288 | /*! |
| 289 | @typedef PantomimSearchOption |
| 290 | @abstract Options for Folder: -search: mask: options: |
| 291 | @discussion This enum lists the possible options when |
| 292 | performing a search. |
| 293 | @constant PantomimeCaseInsensitiveSearch Don't consider the case when performing a search operation. |
| 294 | @constant PantomimeRegularExpression The search criteria represents a regular expression. |
| 295 | */ |
| 296 | typedef enum |
| 297 | { |
| 298 | PantomimeCaseInsensitiveSearch = 1, |
| 299 | PantomimeRegularExpression = 2 |
| 300 | } PantomimeSearchOption; |
| 301 | |
| 302 | |
| 303 | /*! |
| 304 | @typedef PantomimeFolderMode |
| 305 | @abstract Valid modes for folder. |
| 306 | @discussion This enum lists the valid mode to be used when |
| 307 | opening a folder. |
| 308 | @constant PantomimeUnknownMode Unknown mode. |
| 309 | @constant PantomimeReadOnlyMode The folder will be open in read-only. |
| 310 | @constant PantomimeReadWriteMode The folder will be open in read-write. |
| 311 | */ |
| 312 | typedef enum |
| 313 | { |
| 314 | PantomimeUnknownMode = 1, |
| 315 | PantomimeReadOnlyMode = 2, |
| 316 | PantomimeReadWriteMode = 3 |
| 317 | } PantomimeFolderMode; |
| 318 | |
| 319 | /*! |
| 320 | @typedef PantomimeForwardMode |
| 321 | @abstract Valid modes when forwarding a message. |
| 322 | @discussion This enum lists the valid mode to be |
| 323 | used when forwarding a message. |
| 324 | @constant PantomimeAttachmentForwardMode The message will be attached. |
| 325 | @constant PantomimeInlineForwardMode The text parts of the message will be |
| 326 | extracted and included inline in the |
| 327 | forwarded response. |
| 328 | */ |
| 329 | typedef enum |
| 330 | { |
| 331 | PantomimeAttachmentForwardMode = 1, |
| 332 | PantomimeInlineForwardMode = 2 |
| 333 | } PantomimeForwardMode; |
| 334 | |
| 335 | |
| 336 | /*! |
| 337 | @typedef PantomimeContentDisposition |
| 338 | @abstract Valid modes when setting a Content-Disposition. |
| 339 | @discussion This enum lists the valid Content-Disposition |
| 340 | as stated in the RFC2183 standard. |
| 341 | @constant PantomimeAttachmentDisposition The part is separated from the mail body. |
| 342 | @constant PantomimeInlineDisposition The part is part of the mail body. |
| 343 | */ |
| 344 | typedef enum |
| 345 | { |
| 346 | PantomimeAttachmentDisposition = 1, |
| 347 | PantomimeInlineDisposition = 2 |
| 348 | } PantomimeContentDisposition; |
| 349 | |
| 350 | /*! |
| 351 | @typedef PantomimeReplyMode |
| 352 | @abstract Valid modes when replying to a message. |
| 353 | @discussion This enum lists the valid modes to be |
| 354 | used when replying to a message. Those |
| 355 | modes are to be used with CWMessage: -reply: |
| 356 | PantomimeSimpleReplyMode and PantomimeNormalReplyMode |
| 357 | can NOT be combined but can be individually combined |
| 358 | with PantomimeReplyAllMode. |
| 359 | @constant PantomimeSimpleReplyMode Reply to the sender, without a message content |
| 360 | @constant PantomimeNormalReplyMode Reply to the sender, with a properly build message content. |
| 361 | @constant PantomimeReplyAllMode Reply to all recipients. |
| 362 | */ |
| 363 | typedef enum |
| 364 | { |
| 365 | PantomimeSimpleReplyMode = 1, |
| 366 | PantomimeNormalReplyMode = 2, |
| 367 | PantomimeReplyAllMode = 4 |
| 368 | } PantomimeReplyMode; |
| 369 | |
| 370 | |
| 371 | /*! |
| 372 | @typedef PantomimeRecipientType |
| 373 | @abstract Valid recipient types. |
| 374 | @discussion This enum lists the valid kind of recipients |
| 375 | a message can have. |
| 376 | @constant PantomimeToRecipient Recipient which will appear in the "To:" header value. |
| 377 | @constant PantomimeCcRecipient Recipient which will appear in the "Cc:" header value. |
| 378 | @constant PantomimeBccRecipient Recipient which will obtain a black carbon copy of the message. |
| 379 | @constant PantomimeResentToRecipient Recipient which will appear in the "Resent-To:" header value. |
| 380 | @constant PantomimeResentCcRecipient Recipient which will appear in the "Resent-Cc:" header value. |
| 381 | @constant PantomimeResentBccRecipient Recipient which will obtain a black carbon copy of the message |
| 382 | being redirected. |
| 383 | */ |
| 384 | typedef enum |
| 385 | { |
| 386 | PantomimeToRecipient = 1, |
| 387 | PantomimeCcRecipient = 2, |
| 388 | PantomimeBccRecipient = 3, |
| 389 | PantomimeResentToRecipient = 4, |
| 390 | PantomimeResentCcRecipient = 5, |
| 391 | PantomimeResentBccRecipient = 6 |
| 392 | } PantomimeRecipientType; |
| 393 | |
| 394 | #endif // _Pantomime_H_CWConstants |