Comment: | Adjust to reworked exception API. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
543fb8b84deb86ba89f48cea91784016 |
User & Date: | js on 2013-06-23 14:19:42 |
Other Links: | manifest | tags |
2013-06-23
| ||
19:57 | Get rid of BOOL. check-in: dd2c1286f9 user: js tags: trunk | |
14:19 | Adjust to reworked exception API. check-in: 543fb8b84d user: js tags: trunk | |
2013-06-12
| ||
12:53 | XMPPDiscoEntity: Caps hash must be Base64 encoded SHA1 check-in: c74a473e92 user: florob@babelmonkeys.de tags: trunk | |
Modified src/XMPPConnection.m from [004473a420] to [8415025e4d].
︙ | ︙ | |||
167 168 169 170 171 172 173 | if (username != nil) { char *node; Stringprep_rc rc; if ((rc = stringprep_profile([username UTF8String], &node, "SASLprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException | < | | | | 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | if (username != nil) { char *node; Stringprep_rc rc; if ((rc = stringprep_profile([username UTF8String], &node, "SASLprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException exceptionWithConnection: self profile: @"SASLprep" string: username]; @try { _username = [[OFString alloc] initWithUTF8String: node]; } @finally { free(node); } } else |
︙ | ︙ | |||
199 200 201 202 203 204 205 | if (resource != nil) { char *res; Stringprep_rc rc; if ((rc = stringprep_profile([resource UTF8String], &res, "Resourceprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException | < | | | | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | if (resource != nil) { char *res; Stringprep_rc rc; if ((rc = stringprep_profile([resource UTF8String], &res, "Resourceprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException exceptionWithConnection: self profile: @"Resourceprep" string: resource]; @try { _resource = [[OFString alloc] initWithUTF8String: res]; } @finally { free(res); } } else |
︙ | ︙ | |||
249 250 251 252 253 254 255 | if (domain_ != nil) { char *srv; Stringprep_rc rc; if ((rc = stringprep_profile([domain_ UTF8String], &srv, "Nameprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException | < | | | | 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | if (domain_ != nil) { char *srv; Stringprep_rc rc; if ((rc = stringprep_profile([domain_ UTF8String], &srv, "Nameprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException exceptionWithConnection: self profile: @"Nameprep" string: domain_]; @try { _domain = [[OFString alloc] initWithUTF8String: srv]; } @finally { free(srv); } |
︙ | ︙ | |||
286 287 288 289 290 291 292 | if (password != nil) { char *pass; Stringprep_rc rc; if ((rc = stringprep_profile([password UTF8String], &pass, "SASLprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException | < | | | | 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | if (password != nil) { char *pass; Stringprep_rc rc; if ((rc = stringprep_profile([password UTF8String], &pass, "SASLprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException exceptionWithConnection: self profile: @"SASLprep" string: password]; @try { _password = [[OFString alloc] initWithUTF8String: pass]; } @finally { free(pass); } } else |
︙ | ︙ | |||
335 336 337 338 339 340 341 | { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; XMPPSRVEntry *candidate = nil; XMPPSRVLookup *SRVLookup = nil; OFEnumerator *enumerator; if (_socket != nil) | | < | 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; XMPPSRVEntry *candidate = nil; XMPPSRVLookup *SRVLookup = nil; OFEnumerator *enumerator; if (_socket != nil) @throw [OFAlreadyConnectedException exception]; _socket = [[OFTCPSocket alloc] init]; if (_server) [_socket connectToHost: _server port: _port]; else { |
︙ | ︙ | |||
687 688 689 690 691 692 693 | - (void)elementBuilder: (OFXMLElementBuilder*)builder didNotExpectCloseTag: (OFString*)name prefix: (OFString*)prefix namespace: (OFString*)ns { if (![name isEqual: @"stream"] || ![prefix isEqual: @"stream"] || ![ns isEqual: XMPP_NS_STREAM]) | | < < | 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 | - (void)elementBuilder: (OFXMLElementBuilder*)builder didNotExpectCloseTag: (OFString*)name prefix: (OFString*)prefix namespace: (OFString*)ns { if (![name isEqual: @"stream"] || ![prefix isEqual: @"stream"] || ![ns isEqual: XMPP_NS_STREAM]) @throw [OFMalformedXMLException exception]; else { [self close]; } } - (void)XMPP_startStream { |
︙ | ︙ | |||
869 870 871 872 873 874 875 | condition = @"undefined"; reason = [[element elementForName: @"text" namespace: XMPP_NS_XMPP_STREAM] stringValue]; @throw [XMPPStreamErrorException | < | | | | 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 | condition = @"undefined"; reason = [[element elementForName: @"text" namespace: XMPP_NS_XMPP_STREAM] stringValue]; @throw [XMPPStreamErrorException exceptionWithConnection: self condition: condition reason: reason]; return; } assert(0); } - (void)XMPP_handleTLS: (OFXMLElement*)element |
︙ | ︙ | |||
911 912 913 914 915 916 917 | [self XMPP_startStream]; return; } if ([[element name] isEqual: @"failure"]) /* TODO: Find/create an exception to throw here */ | | | 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 | [self XMPP_startStream]; return; } if ([[element name] isEqual: @"failure"]) /* TODO: Find/create an exception to throw here */ @throw [OFException exception]; assert(0); } - (void)XMPP_handleSASL: (OFXMLElement*)element { if ([[element name] isEqual: @"challenge"]) { |
︙ | ︙ | |||
957 958 959 960 961 962 963 | return; } if ([[element name] isEqual: @"failure"]) { of_log(@"Auth failed!"); // FIXME: Do more parsing/handling @throw [XMPPAuthFailedException | < | | | 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 | return; } if ([[element name] isEqual: @"failure"]) { of_log(@"Auth failed!"); // FIXME: Do more parsing/handling @throw [XMPPAuthFailedException exceptionWithConnection: self reason: [element XMLString]]; } assert(0); } - (void)XMPP_handleIQ: (XMPPIQ*)iq { |
︙ | ︙ | |||
1024 1025 1026 1027 1028 1029 1030 | [OFXMLElement elementWithName: @"starttls" namespace: XMPP_NS_STARTTLS]]; return; } if (_encryptionRequired && !_encrypted) /* TODO: Find/create an exception to throw here */ | | | 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 | [OFXMLElement elementWithName: @"starttls" namespace: XMPP_NS_STARTTLS]]; return; } if (_encryptionRequired && !_encrypted) /* TODO: Find/create an exception to throw here */ @throw [OFException exception]; if ([element elementForName: @"ver" namespace: XMPP_NS_ROSTERVER] != nil) _supportsRosterVersioning = YES; if ([element elementForName: @"sm" namespace: XMPP_NS_SM] != nil) |
︙ | ︙ | |||
1217 1218 1219 1220 1221 1222 1223 | OFString *ret; char *cDomain; Idna_rc rc; if ((rc = idna_to_ascii_8z([domain_ UTF8String], &cDomain, IDNA_USE_STD3_ASCII_RULES)) != IDNA_SUCCESS) @throw [XMPPIDNATranslationFailedException | < | | | | 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 | OFString *ret; char *cDomain; Idna_rc rc; if ((rc = idna_to_ascii_8z([domain_ UTF8String], &cDomain, IDNA_USE_STD3_ASCII_RULES)) != IDNA_SUCCESS) @throw [XMPPIDNATranslationFailedException exceptionWithConnection: self operation: @"ToASCII" string: domain_]; @try { ret = [[OFString alloc] initWithUTF8String: cDomain]; } @finally { free(cDomain); } |
︙ | ︙ | |||
1249 1250 1251 1252 1253 1254 1255 | { return _port; } - (void)setDataStorage: (id <XMPPStorage>)dataStorage { if (_streamOpen) | > | < | 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 | { return _port; } - (void)setDataStorage: (id <XMPPStorage>)dataStorage { if (_streamOpen) /* FIXME: Find a better exception! */ @throw [OFInvalidArgumentException exception]; _dataStorage = dataStorage; } - (id <XMPPStorage>)dataStorage { return _dataStorage; |
︙ | ︙ |
Modified src/XMPPDiscoIdentity.m from [5bede0ee0a] to [16fe7db118].
︙ | ︙ | |||
43 44 45 46 47 48 49 | type: (OFString*)type name: (OFString*)name { self = [super init]; @try { if (category == nil || type == nil) | | < < | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | type: (OFString*)type name: (OFString*)name { self = [super init]; @try { if (category == nil || type == nil) @throw [OFInvalidArgumentException exception]; _category = [category copy]; _name = [name copy]; _type = [type copy]; } @catch (id e) { [self release]; @throw e; |
︙ | ︙ | |||
147 148 149 150 151 152 153 | of_comparison_result_t categoryResult; of_comparison_result_t typeResult; if (object == self) return OF_ORDERED_SAME; if (![object isKindOfClass: [XMPPDiscoIdentity class]]) | | < < | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | of_comparison_result_t categoryResult; of_comparison_result_t typeResult; if (object == self) return OF_ORDERED_SAME; if (![object isKindOfClass: [XMPPDiscoIdentity class]]) @throw [OFInvalidArgumentException exception]; identity = (XMPPDiscoIdentity*)object; categoryResult = [_category compare: identity->_category]; if (categoryResult != OF_ORDERED_SAME) return categoryResult; |
︙ | ︙ |
Modified src/XMPPDiscoNode.m from [09821a03dd] to [bd94402de0].
︙ | ︙ | |||
56 57 58 59 60 61 62 63 | - initWithJID: (XMPPJID*)JID node: (OFString*)node name: (OFString*)name { self = [super init]; @try { _JID = [JID copy]; | > > > | | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | - initWithJID: (XMPPJID*)JID node: (OFString*)node name: (OFString*)name { self = [super init]; @try { if (JID == nil) @throw [OFInvalidArgumentException exception]; _JID = [JID copy]; _node = [node copy]; _name = [name copy]; _identities = [OFSortedList new]; _features = [OFSortedList new]; _childNodes = [OFMutableDictionary new]; [self addFeature: XMPP_NS_DISCO_ITEMS]; [self addFeature: XMPP_NS_DISCO_INFO]; |
︙ | ︙ |
Modified src/XMPPExceptions.h from [5b24b061ea] to [43c3496d04].
︙ | ︙ | |||
37 38 39 40 41 42 43 | /// \brief The connection the exception relates to @property (readonly, assign) XMPPConnection *connection; #endif /** * \brief Creates a new XMPPException. * | < < | < < | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | /// \brief The connection the exception relates to @property (readonly, assign) XMPPConnection *connection; #endif /** * \brief Creates a new XMPPException. * * \param connection The connection that received the data responsible * for this exception * \return A new XMPPException */ + exceptionWithConnection: (XMPPConnection*)connection; /** * \brief Initializes an already allocated XMPPException. * * \param connection The connection that received the data responsible * for this exception * \return An initialized XMPPException */ - initWithConnection: (XMPPConnection*)connection; - (XMPPConnection*)connection; @end /** * \brief An exception indicating a stream error was received */ |
︙ | ︙ | |||
78 79 80 81 82 83 84 | /// \brief The descriptive free-form text specified by the stream error @property (readonly, assign) OFString *reason; #endif /** * \brief Creates a new XMPPStreamErrorException. * | < < | | | < < | | | | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | /// \brief The descriptive free-form text specified by the stream error @property (readonly, assign) OFString *reason; #endif /** * \brief Creates a new XMPPStreamErrorException. * * \param connection The connection that received the stream error * \param condition The defined error condition specified by the stream error * \param reason The descriptive free-form text specified by the stream error * \return A new XMPPStreamErrorException */ + exceptionWithConnection: (XMPPConnection*)connection condition: (OFString*)condition reason: (OFString*)reason; /** * \brief Initializes an already allocated XMPPStreamErrorException. * * \param connection The connection that received the stream error * \param condition The defined error condition specified by the stream error * \param reason The descriptive free-form text specified by the stream error * \return An initialized XMPPStreamErrorException */ - initWithConnection: (XMPPConnection*)connection condition: (OFString*)condition reason: (OFString*)reason; - (OFString*)condition; - (OFString*)reason; @end /** * \brief An exception indicating a stringprep profile |
︙ | ︙ | |||
127 128 129 130 131 132 133 | /// \brief The string that failed the stringprep profile @property (readonly, assign) OFString *string; #endif /** * \brief Creates a new XMPPStringPrepFailedException. * | < < | | | < < | | | | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | /// \brief The string that failed the stringprep profile @property (readonly, assign) OFString *string; #endif /** * \brief Creates a new XMPPStringPrepFailedException. * * \param connection The connection the string relates to * \param profile The name of the stringprep profile that did not apply * \param string The string that failed the stringprep profile * \return A new XMPPStringPrepFailedException */ + exceptionWithConnection: (XMPPConnection*)connection profile: (OFString*)profile string: (OFString*)string; /** * \brief Initializes an already allocated XMPPStringPrepFailedException. * * \param connection The connection the string relates to * \param profile The name of the stringprep profile that did not apply * \param string The string that failed the stringprep profile * \return An initialized XMPPStringPrepFailedException */ - initWithConnection: (XMPPConnection*)connection profile: (OFString*)profile string: (OFString*)string; - (OFString*)profile; - (OFString*)string; @end /** * \brief An exception indicating IDNA translation of a string failed |
︙ | ︙ | |||
175 176 177 178 179 180 181 | /// \brief The string that could not be translated @property (readonly, assign) OFString *string; #endif /** * \brief Creates a new XMPPIDNATranslationFailedException. * | < < | | | < < | | | | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | /// \brief The string that could not be translated @property (readonly, assign) OFString *string; #endif /** * \brief Creates a new XMPPIDNATranslationFailedException. * * \param connection The connection the string relates to * \param operation The name of the stringprep profile that did not apply * \param string The string that could not be translated * \return A new XMPPIDNATranslationFailedException */ + exceptionWithConnection: (XMPPConnection*)connection operation: (OFString*)operation string: (OFString*)string; /** * \brief Initializes an already allocated XMPPIDNATranslationFailedException. * * \param connection The connection the string relates to * \param operation The name of the stringprep profile that did not apply * \param string The string that could not be translated * \return An initialized XMPPIDNATranslationFailedException */ - initWithConnection: (XMPPConnection*)connection operation: (OFString*)operation string: (OFString*)string; - (OFString*)operation; - (OFString*)string; @end /** * \brief An exception indicating authentication failed |
︙ | ︙ | |||
220 221 222 223 224 225 226 | /// \brief The reason the authentication failed @property (readonly, assign) OFString *reason; #endif /** * \brief Creates a new XMPPAuthFailedException. * | < < | | < < | | | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | /// \brief The reason the authentication failed @property (readonly, assign) OFString *reason; #endif /** * \brief Creates a new XMPPAuthFailedException. * * \param connection The connection that could not be authenticated * \param reason The reason the authentication failed * \return A new XMPPAuthFailedException */ + exceptionWithConnection: (XMPPConnection*)connection reason: (OFString*)reason; /** * \brief Initializes an already allocated XMPPAuthFailedException. * * \param connection The connection that could not be authenticated * \param reason The reason the authentication failed * \return An initialized XMPPAuthFailedException */ - initWithConnection: (XMPPConnection*)connection reason: (OFString*)reason; - (OFString*)reason; @end |
Modified src/XMPPExceptions.m from [8b80b6f458] to [376315cbbf].
︙ | ︙ | |||
19 20 21 22 23 24 25 26 27 28 29 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #import "XMPPExceptions.h" #import "XMPPConnection.h" @implementation XMPPException | > > < | | < | > | > | | > | > < | | | < | | | | < | | < | > | > | | > | > < | | | | < | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include <stdlib.h> #import "XMPPExceptions.h" #import "XMPPConnection.h" @implementation XMPPException + exceptionWithConnection: (XMPPConnection*)connection { return [[[self alloc] initWithConnection: connection] autorelease]; } - init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } - initWithConnection: (XMPPConnection*)connection { self = [super init]; @try { _connection = [connection retain]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_connection release]; [super dealloc]; } - (XMPPConnection*)connection { OF_GETTER(_connection, false) } @end @implementation XMPPStreamErrorException + exceptionWithConnection: (XMPPConnection*)connection condition: (OFString*)condition reason: (OFString*)reason; { return [[[self alloc] initWithConnection: connection condition: condition reason: reason] autorelease]; } - initWithConnection: (XMPPConnection*)connection { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } - initWithConnection: (XMPPConnection*)connection condition: (OFString*)condition reason: (OFString*)reason { self = [super initWithConnection: connection]; @try { _condition = [condition copy]; _reason = [reason copy]; } @catch (id e) { [self release]; @throw e; |
︙ | ︙ | |||
118 119 120 121 122 123 124 | [super dealloc]; } - (OFString*)description { return [OFString stringWithFormat: | < | | | < | | | | < | | < | > | > | | > | > < | | | | < | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | [super dealloc]; } - (OFString*)description { return [OFString stringWithFormat: @"Got stream error: %@. Reason: %@!", _condition, _reason]; } - (OFString*)condition { OF_GETTER(_condition, false) } - (OFString*)reason { OF_GETTER(_reason, false) } @end @implementation XMPPStringPrepFailedException + exceptionWithConnection: (XMPPConnection*)connection profile: (OFString*)profile string: (OFString*)string { return [[[self alloc] initWithConnection: connection profile: profile string: string] autorelease]; } - initWithConnection: (XMPPConnection*)connection { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } - initWithConnection: (XMPPConnection*)connection profile: (OFString*)profile string: (OFString*)string { self = [super initWithConnection: connection]; @try { _profile = [profile copy]; _string = [string copy]; } @catch (id e) { [self release]; @throw e; |
︙ | ︙ | |||
184 185 186 187 188 189 190 | [super dealloc]; } - (OFString*)description { return [OFString stringWithFormat: | | | | | < | | | | < | | < | > | > | | > | > < | | | | < | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | [super dealloc]; } - (OFString*)description { return [OFString stringWithFormat: @"Stringprep with profile %@ failed on string '%@'!", _profile, _string]; } - (OFString*)profile { OF_GETTER(_profile, false) } - (OFString*)string { OF_GETTER(_string, false) } @end @implementation XMPPIDNATranslationFailedException + exceptionWithConnection: (XMPPConnection*)connection operation: (OFString*)operation string: (OFString*)string { return [[[self alloc] initWithConnection: connection operation: operation string: string] autorelease]; } - initWithConnection: (XMPPConnection*)connection { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } - initWithConnection: (XMPPConnection*)connection operation: (OFString*)operation string: (OFString*)string { self = [super initWithConnection: connection]; @try { _operation = [operation copy]; _string = [string copy]; } @catch (id e) { [self release]; @throw e; |
︙ | ︙ | |||
250 251 252 253 254 255 256 | [super dealloc]; } - (OFString*)description { return [OFString stringWithFormat: | | < | | < | | | < | < | > | > | | > | > < | | | < | 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | [super dealloc]; } - (OFString*)description { return [OFString stringWithFormat: @"IDNA operation %@ failed on string '%@'!", _operation, _string]; } - (OFString*)operation { OF_GETTER(_operation, false) } - (OFString*)string { OF_GETTER(_string, false) } @end @implementation XMPPAuthFailedException + exceptionWithConnection: (XMPPConnection*)connection reason: (OFString*)reason; { return [[[self alloc] initWithConnection: connection reason: reason] autorelease]; } - initWithConnection: (XMPPConnection*)connection { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } - initWithConnection: (XMPPConnection*)connection reason: (OFString*)reason { self = [super initWithConnection: connection]; @try { _reason = [reason copy]; } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ | |||
311 312 313 314 315 316 317 | [super dealloc]; } - (OFString*)description { return [OFString stringWithFormat: | | < | | 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | [super dealloc]; } - (OFString*)description { return [OFString stringWithFormat: @"Authentication failed. Reason: %@!", _reason]; } - (OFString*)reason { OF_GETTER(_reason, false) } @end |
Modified src/XMPPFileStorage.m from [b5f01ad0ba] to [e283a67940].
︙ | ︙ | |||
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #import <ObjFW/OFString.h> #import <ObjFW/OFArray.h> #import <ObjFW/OFDictionary.h> #import <ObjFW/OFNumber.h> #import <ObjFW/OFDataArray.h> #import <ObjFW/OFAutoreleasePool.h> #import <ObjFW/OFNotImplementedException.h> #import "XMPPFileStorage.h" @implementation XMPPFileStorage - init { | > > > | > | | > | > | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include <stdlib.h> #import <ObjFW/OFString.h> #import <ObjFW/OFArray.h> #import <ObjFW/OFDictionary.h> #import <ObjFW/OFNumber.h> #import <ObjFW/OFDataArray.h> #import <ObjFW/OFAutoreleasePool.h> #import <ObjFW/OFNotImplementedException.h> #import "XMPPFileStorage.h" @implementation XMPPFileStorage - init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } - initWithFile: (OFString*)file { self = [super init]; @try { OFAutoreleasePool *pool = [OFAutoreleasePool new]; _file = [file copy]; @try { _data = [[[OFDataArray dataArrayWithContentsOfFile: file] messagePackValue] retain]; } @catch (id e) { _data = [OFMutableDictionary new]; } [pool release]; } @catch (id e) { [self release]; |
︙ | ︙ | |||
74 75 76 77 78 79 80 | [_data release]; [super dealloc]; } - (void)save { | | | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | [_data release]; [super dealloc]; } - (void)save { [[_data messagePackRepresentation] writeToFile: _file]; } - (void)XMPP_setObject: (id)object forPath: (OFString*)path { OFArray *pathComponents = [path componentsSeparatedByString: @"."]; OFMutableDictionary *iter = _data; |
︙ | ︙ |
Modified src/XMPPIQ.m from [56a714ea1b] to [08cee60ca1].
︙ | ︙ | |||
42 43 44 45 46 47 48 | self = [super initWithName: @"iq" type: type ID: ID]; @try { if (![type isEqual: @"get"] && ![type isEqual: @"set"] && ![type isEqual: @"result"] && ![type isEqual: @"error"]) | | < < | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | self = [super initWithName: @"iq" type: type ID: ID]; @try { if (![type isEqual: @"get"] && ![type isEqual: @"set"] && ![type isEqual: @"result"] && ![type isEqual: @"error"]) @throw [OFInvalidArgumentException exception]; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ |
Modified src/XMPPJID.m from [70fd287265] to [9c61bb91d6].
︙ | ︙ | |||
115 116 117 118 119 120 121 | return; } if (((rc = stringprep_profile([node UTF8String], &nodepart, "Nodeprep", 0)) != STRINGPREP_OK) || (nodepart[0] == '\0') || (strlen(nodepart) > 1023)) @throw [XMPPStringPrepFailedException | < | | | | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | return; } if (((rc = stringprep_profile([node UTF8String], &nodepart, "Nodeprep", 0)) != STRINGPREP_OK) || (nodepart[0] == '\0') || (strlen(nodepart) > 1023)) @throw [XMPPStringPrepFailedException exceptionWithConnection: nil profile: @"Nodeprep" string: node]; @try { _node = [[OFString alloc] initWithUTF8String: nodepart]; } @finally { free(nodepart); } |
︙ | ︙ | |||
144 145 146 147 148 149 150 | char *srv; Stringprep_rc rc; if (((rc = stringprep_profile([domain UTF8String], &srv, "Nameprep", 0)) != STRINGPREP_OK) || (srv[0] == '\0') || (strlen(srv) > 1023)) @throw [XMPPStringPrepFailedException | < | | | | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | char *srv; Stringprep_rc rc; if (((rc = stringprep_profile([domain UTF8String], &srv, "Nameprep", 0)) != STRINGPREP_OK) || (srv[0] == '\0') || (strlen(srv) > 1023)) @throw [XMPPStringPrepFailedException exceptionWithConnection: nil profile: @"Nameprep" string: domain]; @try { _domain = [[OFString alloc] initWithUTF8String: srv]; } @finally { free(srv); } |
︙ | ︙ | |||
179 180 181 182 183 184 185 | return; } if (((rc = stringprep_profile([resource UTF8String], &res, "Resourceprep", 0)) != STRINGPREP_OK) || (res[0] == '\0') || (strlen(res) > 1023)) @throw [XMPPStringPrepFailedException | < | | | | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | return; } if (((rc = stringprep_profile([resource UTF8String], &res, "Resourceprep", 0)) != STRINGPREP_OK) || (res[0] == '\0') || (strlen(res) > 1023)) @throw [XMPPStringPrepFailedException exceptionWithConnection: nil profile: @"Resourceprep" string: resource]; @try { _resource = [[OFString alloc] initWithUTF8String: res]; } @finally { free(res); } |
︙ | ︙ |
Modified src/XMPPPresence.m from [cd7ef53266] to [71bd226691].
︙ | ︙ | |||
180 181 182 183 184 185 186 | } - (void)setPriority: (OFNumber*)priority { intmax_t prio = [priority intMaxValue]; if ((prio < -128) || (prio > 127)) | | < < | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | } - (void)setPriority: (OFNumber*)priority { intmax_t prio = [priority intMaxValue]; if ((prio < -128) || (prio > 127)) @throw [OFInvalidArgumentException exception]; OFXMLElement *oldPriority = [self elementForName: @"priority" namespace: XMPP_NS_CLIENT]; if (oldPriority != nil) [self removeChild: oldPriority]; |
︙ | ︙ | |||
215 216 217 218 219 220 221 | OFString *otherShow; of_comparison_result_t priorityOrder; if (object == self) return OF_ORDERED_SAME; if (![object isKindOfClass: [XMPPPresence class]]) | | < < | 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | OFString *otherShow; of_comparison_result_t priorityOrder; if (object == self) return OF_ORDERED_SAME; if (![object isKindOfClass: [XMPPPresence class]]) @throw [OFInvalidArgumentException exception]; otherPresence = (XMPPPresence*)object; otherPriority = [otherPresence priority]; if (otherPriority == nil) otherPriority = [OFNumber numberWithInt8: 0]; if (_priority != nil) |
︙ | ︙ |
Modified src/XMPPRoster.m from [1fa0d01ca6] to [265f350014].
︙ | ︙ | |||
209 210 211 212 213 214 215 | { [_delegates removeDelegate: delegate]; } - (void)setDataStorage: (id <XMPPStorage>)dataStorage { if (_rosterRequested) | > | < | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | { [_delegates removeDelegate: delegate]; } - (void)setDataStorage: (id <XMPPStorage>)dataStorage { if (_rosterRequested) /* FIXME: Find a better exception! */ @throw [OFInvalidArgumentException exception]; _dataStorage = dataStorage; } - (XMPPConnection*)connection { return _connection; |
︙ | ︙ |
Modified src/XMPPSCRAMAuth.m from [f160b76a65] to [764a5f4df5].
︙ | ︙ | |||
164 165 166 167 168 169 170 | else _GS2Header = (_plusAvailable ? @"p=tls-unique,," : @"y,,"); _cNonce = [[self XMPP_genNonce] retain]; [_clientFirstMessageBare release]; _clientFirstMessageBare = nil; | | | < | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | else _GS2Header = (_plusAvailable ? @"p=tls-unique,," : @"y,,"); _cNonce = [[self XMPP_genNonce] retain]; [_clientFirstMessageBare release]; _clientFirstMessageBare = nil; _clientFirstMessageBare = [[OFString alloc] initWithFormat: @"n=%@,r=%@", _authcid, _cNonce]; [ret addItems: [_GS2Header UTF8String] count: [_GS2Header UTF8StringLength]]; [ret addItems: [_clientFirstMessageBare UTF8String] count: [_clientFirstMessageBare UTF8StringLength]]; |
︙ | ︙ | |||
226 227 228 229 230 231 232 | while ((comp = [enumerator nextObject]) != nil) { OFString *entry = [comp substringWithRange: of_range(2, [comp length] - 2)]; if ([comp hasPrefix: @"r="]) { if (![entry hasPrefix: _cNonce]) @throw [XMPPAuthFailedException | < | | | | < | 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | while ((comp = [enumerator nextObject]) != nil) { OFString *entry = [comp substringWithRange: of_range(2, [comp length] - 2)]; if ([comp hasPrefix: @"r="]) { if (![entry hasPrefix: _cNonce]) @throw [XMPPAuthFailedException exceptionWithConnection: nil reason: @"Received wrong " @"nonce"]; sNonce = entry; got |= GOT_SNONCE; } else if ([comp hasPrefix: @"s="]) { salt = [OFDataArray dataArrayWithBase64EncodedString: entry]; got |= GOT_SALT; } else if ([comp hasPrefix: @"i="]) { iterCount = [entry decimalValue]; got |= GOT_ITERCOUNT; } } if (got != (GOT_SNONCE | GOT_SALT | GOT_ITERCOUNT)) @throw [OFInvalidServerReplyException exception]; // Add c=<base64(GS2Header+channelBindingData)> tmpArray = [OFDataArray dataArray]; [tmpArray addItems: [_GS2Header UTF8String] count: [_GS2Header UTF8StringLength]]; if (_plusAvailable && [_connection encrypted]) { OFDataArray *channelBinding = [((SSLSocket*)[_connection socket]) |
︙ | ︙ | |||
386 387 388 389 390 391 392 | length: [data count] * [data itemSize]]; value = [mess substringWithRange: of_range(2, [mess length] - 2)]; if ([mess hasPrefix: @"v="]) { if (![value isEqual: [_serverSignature stringByBase64Encoding]]) @throw [XMPPAuthFailedException | < | | | | < | | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | length: [data count] * [data itemSize]]; value = [mess substringWithRange: of_range(2, [mess length] - 2)]; if ([mess hasPrefix: @"v="]) { if (![value isEqual: [_serverSignature stringByBase64Encoding]]) @throw [XMPPAuthFailedException exceptionWithConnection: nil reason: @"Received wrong " @"ServerSignature"]; _authenticated = YES; } else @throw [XMPPAuthFailedException exceptionWithConnection: nil reason: value]; return nil; } - (OFString*)XMPP_genNonce { uint8_t buf[64]; |
︙ | ︙ |
Modified src/XMPPSRVLookup.m from [dde19bea60] to [54b7d6a8f6].
︙ | ︙ | |||
21 22 23 24 25 26 27 28 29 30 31 32 33 34 | * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include <assert.h> #include <arpa/inet.h> #include <netdb.h> #include <sys/types.h> #include <openssl/rand.h> | > > | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include <stdlib.h> #include <assert.h> #include <arpa/inet.h> #include <netdb.h> #include <sys/types.h> #include <openssl/rand.h> |
︙ | ︙ | |||
51 52 53 54 55 56 57 | { return [[[self alloc] initWithResourceRecord: resourceRecord handle: handle] autorelease]; } - init { | > | > | | > | > | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | { return [[[self alloc] initWithResourceRecord: resourceRecord handle: handle] autorelease]; } - init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } - initWithPriority: (uint16_t)priority weight: (uint16_t)weight port: (uint16_t)port target: (OFString*)target { |
︙ | ︙ | |||
204 205 206 207 208 209 210 | @try { int answerLen, resourceRecordCount, i; ns_rr resourceRecord; ns_msg handle; if (res_ninit(&_resState)) @throw [OFAddressTranslationFailedException | < < | | < < | < < < | | 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | @try { int answerLen, resourceRecordCount, i; ns_rr resourceRecord; ns_msg handle; if (res_ninit(&_resState)) @throw [OFAddressTranslationFailedException exceptionWithHost: _domain]; answer = [self allocMemoryWithSize: pageSize]; answerLen = res_nsearch(&_resState, [request cStringWithEncoding: OF_STRING_ENCODING_NATIVE], ns_c_in, ns_t_srv, answer, (int)pageSize); if ((answerLen == -1) && ((h_errno == HOST_NOT_FOUND) || (h_errno == NO_DATA))) return; if (answerLen < 1 || answerLen > pageSize) @throw [OFAddressTranslationFailedException exceptionWithHost: _domain]; if (ns_initparse(answer, answerLen, &handle)) @throw [OFAddressTranslationFailedException exceptionWithHost: _domain]; resourceRecordCount = ns_msg_count(handle, ns_s_an); for (i = 0; i < resourceRecordCount; i++) { if (ns_parserr(&handle, ns_s_an, i, &resourceRecord)) continue; if (ns_rr_type(resourceRecord) != ns_t_srv || |
︙ | ︙ |
Modified src/XMPPStanza.m from [8ed21f56f2] to [bb69e66d09].
︙ | ︙ | |||
92 93 94 95 96 97 98 | { self = [super initWithName: name namespace: XMPP_NS_CLIENT]; @try { if (![name isEqual: @"iq"] && ![name isEqual: @"message"] && ![name isEqual: @"presence"]) | | < < | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | { self = [super initWithName: name namespace: XMPP_NS_CLIENT]; @try { if (![name isEqual: @"iq"] && ![name isEqual: @"message"] && ![name isEqual: @"presence"]) @throw [OFInvalidArgumentException exception]; [self setDefaultNamespace: XMPP_NS_CLIENT]; [self setPrefix: @"stream" forNamespace: XMPP_NS_STREAM]; if (type != nil) [self setType: type]; |
︙ | ︙ |
Modified src/XMPPXMLElementBuilder.m from [2fa5bac2f8] to [a9f23e26ed].
︙ | ︙ | |||
28 29 30 31 32 33 34 | #import <ObjFW/OFMalformedXMLException.h> @implementation XMPPXMLElementBuilder - (void)parser: (OFXMLParser*)parser foundProcessingInstructions: (OFString*)pi { | | | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #import <ObjFW/OFMalformedXMLException.h> @implementation XMPPXMLElementBuilder - (void)parser: (OFXMLParser*)parser foundProcessingInstructions: (OFString*)pi { @throw [OFMalformedXMLException exception]; } - (void)parser: (OFXMLParser*)parser foundComment: (OFString*)comment { @throw [OFMalformedXMLException exception]; } @end |