| 1 | /* |
| 2 | ** CWTransport.h |
| 3 | ** |
| 4 | ** Copyright (c) 2001-2006 Ludovic Marcotte |
| 5 | ** |
| 6 | ** Author: Ludovic Marcotte <[email protected]> |
| 7 | ** |
| 8 | ** This library is free software; you can redistribute it and/or |
| 9 | ** modify it under the terms of the GNU Lesser General Public |
| 10 | ** License as published by the Free Software Foundation; either |
| 11 | ** version 2.1 of the License, or (at your option) any later version. |
| 12 | ** |
| 13 | ** This library is distributed in the hope that it will be useful, |
| 14 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | ** Lesser General Public License for more details. |
| 17 | ** |
| 18 | ** You should have received a copy of the GNU General Public License |
| 19 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | */ |
| 21 | |
| 22 | #ifndef _Pantomime_H_CWTransport |
| 23 | #define _Pantomime_H_CWTransport |
| 24 | |
| 25 | #import <Foundation/NSArray.h> |
| 26 | #import <Foundation/NSData.h> |
| 27 | #import <Foundation/NSNotification.h> |
| 28 | |
| 29 | /*! |
| 30 | @const PantomimeMessageSent |
| 31 | */ |
| 32 | extern NSString* PantomimeMessageSent; |
| 33 | |
| 34 | /*! |
| 35 | @const PantomimeMessageNotSent |
| 36 | */ |
| 37 | extern NSString* PantomimeMessageNotSent; |
| 38 | |
| 39 | |
| 40 | @class CWMessage; |
| 41 | |
| 42 | /*! |
| 43 | @category NSObject (TransportClient) |
| 44 | @discussion This informal protocol defines methods that can implemented in |
| 45 | CWTransport's delegate (CWSMTP or CWSendmail instances) to control |
| 46 | the behavior of the class or to obtain status information. |
| 47 | */ |
| 48 | @interface NSObject (TransportClient) |
| 49 | /*! |
| 50 | @method messageSent: |
| 51 | @discussion This method is automatically invoked on the delegate |
| 52 | after the SMTP DATA command has completed. The userInfo's |
| 53 | part of the notification contains the message that has |
| 54 | been sent. The key to obtain it is "Message". |
| 55 | A PantomimeMessageSent notification is also posted. |
| 56 | @param theNotification The notification holding the information. |
| 57 | */ |
| 58 | - (void) messageSent: (NSNotification *) theNotification; |
| 59 | |
| 60 | /*! |
| 61 | @method messageNotSent: |
| 62 | @discussion This method is automatically invoked on the delegate |
| 63 | if any error occurs when trying to send a message |
| 64 | (like if a SMTP server won't relay our mails). The userInfo's |
| 65 | part of the notification contains the message that has |
| 66 | not been sent. The key to obtain it is "Message". |
| 67 | A PantomimeMessageNotSent notification is also posted. |
| 68 | @param theNotification The notification holding the information. |
| 69 | */ |
| 70 | - (void) messageNotSent: (NSNotification *) theNotification; |
| 71 | @end |
| 72 | |
| 73 | /*! |
| 74 | @protocol CWTransport |
| 75 | @discussion This protocol defines a generic interface for sending messages. |
| 76 | The CWSMTP and CWSendmail classes fully implement this protocol. |
| 77 | */ |
| 78 | @protocol CWTransport |
| 79 | |
| 80 | /*! |
| 81 | @method sendMessage |
| 82 | @discussion This method sends the message previously set with -setMessage: |
| 83 | or -setMessageData:. It posts a PantomimeTransportMessageNotSent |
| 84 | notification (and calls -messageNotSent: on the delegate, if any) |
| 85 | if the message could not be sent. It ports a PantomimeTransportMessageSent |
| 86 | notification (and calls -messageSent: on the delegate, if any) |
| 87 | if the message has been successfully sent. This method is |
| 88 | fully asynchronous. |
| 89 | */ |
| 90 | - (void) sendMessage; |
| 91 | |
| 92 | /*! |
| 93 | @method setMessage: |
| 94 | @discussion This method is used to set the message (instance of the CWMessage class) |
| 95 | that the transport class will eventually send (by calling -sendMessage). |
| 96 | @param theMessage The message to send. |
| 97 | */ |
| 98 | - (void) setMessage: (CWMessage *) theMessage; |
| 99 | |
| 100 | /*! |
| 101 | @method message |
| 102 | @discussion This method is used to obtain the Message instance |
| 103 | previously set by calling -setMessage: |
| 104 | @result The CWMessage instance. |
| 105 | */ |
| 106 | - (CWMessage *) message; |
| 107 | |
| 108 | /*! |
| 109 | @method setMessageData: |
| 110 | @discussion This method is used to set the message (as raw source) that the transport |
| 111 | class will eventually send (by calling -sendMessage). |
| 112 | @param theMessage The message to send. |
| 113 | */ |
| 114 | - (void) setMessageData: (NSData *) theData; |
| 115 | |
| 116 | /*! |
| 117 | @method messageData |
| 118 | @discussion This method is used to obtain the message (its raw representation) |
| 119 | previously set by calling -setMessageData: |
| 120 | @result The message's raw representation. |
| 121 | */ |
| 122 | - (NSData *) messageData; |
| 123 | |
| 124 | /*! |
| 125 | @method setRecipients: |
| 126 | @discussion This method is used to specify the recipients of the |
| 127 | message. |
| 128 | @param theRecipients An NSArray instance which contains CWInternetAddress |
| 129 | instances for all recipients. |
| 130 | */ |
| 131 | - (void) setRecipients: (NSArray *) theRecipients; |
| 132 | |
| 133 | /*! |
| 134 | @method recipients |
| 135 | @discussion This method is used to obtain the recipients set when |
| 136 | calling -setRecipients:. |
| 137 | @result The array of recipients. |
| 138 | */ |
| 139 | - (NSArray *) recipients; |
| 140 | |
| 141 | @end |
| 142 | |
| 143 | #endif // _Pantomime_H_CWTransport |