| 1 | /* |
| 2 | ** CWInternetAddress.h |
| 3 | ** |
| 4 | ** Copyright (c) 2001-2007 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_CWInternetAddress |
| 23 | #define _Pantomime_H_CWInternetAddress |
| 24 | |
| 25 | #import <Foundation/NSCoder.h> |
| 26 | #import <Foundation/NSData.h> |
| 27 | #import <Foundation/NSObject.h> |
| 28 | #import <Foundation/NSString.h> |
| 29 | |
| 30 | #include <Pantomime/CWConstants.h> |
| 31 | |
| 32 | /*! |
| 33 | @class CWInternetAddress |
| 34 | @abstract Class that wraps support around email addresses. |
| 35 | @discussion This class is used to decode an email address, |
| 36 | as described in RFC2821, and to hold the information |
| 37 | with regard to it. |
| 38 | */ |
| 39 | @interface CWInternetAddress : NSObject <NSCoding> |
| 40 | { |
| 41 | @private |
| 42 | PantomimeRecipientType _type; |
| 43 | NSString *_address; |
| 44 | NSString *_personal; |
| 45 | |
| 46 | // Needed for scripting. |
| 47 | id _container; |
| 48 | } |
| 49 | |
| 50 | /*! |
| 51 | @method initWithString: |
| 52 | @discussion This method initializes a CWInternetAddress instance |
| 53 | using <i>theString</i> and decodes from it the |
| 54 | personal and address parts of an Internet address. |
| 55 | @param theString The string from which to decode the information. |
| 56 | If nil is passed, the instance is autoreleased |
| 57 | and nil will be returned. |
| 58 | @result The CWInternetAddress instance, nil on error. |
| 59 | */ |
| 60 | - (id) initWithString: (NSString *) theString; |
| 61 | |
| 62 | /*! |
| 63 | @method initWithPersonal: address: |
| 64 | @discussion This method is used to initialize a CWInternetAddress |
| 65 | instance using the specified personal and address |
| 66 | part of an Internet address. |
| 67 | @param thePersonal The personal part of the Internet address. |
| 68 | @param theAddress The address part of the Internet address. |
| 69 | @result The CWInternetAddress instance, nil on error. |
| 70 | */ |
| 71 | - (id) initWithPersonal: (NSString *) thePersonal |
| 72 | address: (NSString *) theAddress; |
| 73 | |
| 74 | /*! |
| 75 | @method address |
| 76 | @discussion This method is used to obtain the address part |
| 77 | of the receiver. |
| 78 | @result The address part, as a NSString instance. |
| 79 | */ |
| 80 | - (NSString *) address; |
| 81 | |
| 82 | /*! |
| 83 | @method setAddress: |
| 84 | @discussion This method is used to set the address part |
| 85 | of the receiver, replacing the previous |
| 86 | value, if any. |
| 87 | @param theAddress The new address part. |
| 88 | */ |
| 89 | - (void) setAddress: (NSString *) theAddress; |
| 90 | |
| 91 | /*! |
| 92 | @method personal |
| 93 | @discussion This method is used to obtain the personal part |
| 94 | of the receiver. The personal part is generally |
| 95 | the name of a person, like John Doe. |
| 96 | @result The personal part, as a NSString instance. |
| 97 | */ |
| 98 | - (NSString *) personal; |
| 99 | |
| 100 | /*! |
| 101 | @method setPersonal: |
| 102 | @discussion This method is used to set the personal part |
| 103 | of the receiver, replacing the previous |
| 104 | value, if any. The personal part is generally |
| 105 | the name of a person, like John Doe. |
| 106 | @param thePersonal The new personal part. |
| 107 | */ |
| 108 | - (void) setPersonal: (NSString *) thePersonal; |
| 109 | |
| 110 | /*! |
| 111 | @method type |
| 112 | @discussion This method is used to obtain the type of |
| 113 | the receiver. Values can be one of the |
| 114 | PantomimeRecipientType enum. |
| 115 | @result The type. |
| 116 | */ |
| 117 | - (PantomimeRecipientType) type; |
| 118 | |
| 119 | /*! |
| 120 | @method setType: |
| 121 | @discussion This method is used to set the receiver's type. |
| 122 | The accepted values are the one of the |
| 123 | PantomimeRecipientType enum. |
| 124 | @param theType The new type, which replaces the previous value. |
| 125 | */ |
| 126 | - (void) setType: (PantomimeRecipientType) theType; |
| 127 | |
| 128 | /*! |
| 129 | @method stringValue |
| 130 | @discussion This method is used to return the receiver's personal |
| 131 | and address parts in a correctly (ie., RFC2821 safe) |
| 132 | formatted way. No encoding (ie., using quoted-printable) |
| 133 | will be performed on the receiver's personal part). |
| 134 | @result The formatted object. |
| 135 | */ |
| 136 | - (NSString *) stringValue; |
| 137 | |
| 138 | /*! |
| 139 | @method dataValue |
| 140 | @discussion This method is used to return the receiver's personal |
| 141 | and address parts in a correctly (ie., RFC2821 safe) |
| 142 | formatted way. Encoding (ie., using quoted-printable) |
| 143 | will be performed on the receiver's personal part). |
| 144 | @result The formatted object. |
| 145 | */ |
| 146 | - (NSData *) dataValue; |
| 147 | |
| 148 | |
| 149 | /*! |
| 150 | @method compare: |
| 151 | @discussion This method is used to compare anAddress with the receiver |
| 152 | (using -stringValue). |
| 153 | @result The NSComparisonResult value. |
| 154 | */ |
| 155 | - (NSComparisonResult) compare: (id) theAddress; |
| 156 | |
| 157 | |
| 158 | /*! |
| 159 | @method isEqualToAddress: |
| 160 | @discussion This method is used to compare anAddress with the receiver's |
| 161 | address only. |
| 162 | @result A boolean value |
| 163 | */ |
| 164 | - (BOOL) isEqualToAddress: (CWInternetAddress *) theAddress; |
| 165 | |
| 166 | /*! |
| 167 | @method container |
| 168 | @discussion This method is used to get the container for scripting. |
| 169 | @result The container. |
| 170 | */ |
| 171 | - (id) container; |
| 172 | |
| 173 | /*! |
| 174 | @method setContainer: |
| 175 | @discussion This method is used to set the container for scripting. |
| 176 | @param theContainer The container for scripting. |
| 177 | */ |
| 178 | - (void) setContainer: (id) theContainer; |
| 179 | |
| 180 | @end |
| 181 | |
| 182 | /*! |
| 183 | @class ToRecipient |
| 184 | @discussion This class is used to ease scripting in Pantomime. |
| 185 | */ |
| 186 | @interface ToRecipient: CWInternetAddress |
| 187 | @end |
| 188 | |
| 189 | /*! |
| 190 | @class CcRecipient |
| 191 | @discussion This class is used to ease scripting in Pantomime. |
| 192 | */ |
| 193 | @interface CcRecipient: CWInternetAddress |
| 194 | @end |
| 195 | |
| 196 | /*! |
| 197 | @class BccRecipient |
| 198 | @discussion This class is used to ease scripting in Pantomime. |
| 199 | */ |
| 200 | @interface BccRecipient: CWInternetAddress |
| 201 | @end |
| 202 | |
| 203 | |
| 204 | #endif // _Pantomime_H_CWInternetAddress |