diff --git a/src/XMPPConnection.m b/src/XMPPConnection.m index df6d9c4..9f4ea18 100644 --- a/src/XMPPConnection.m +++ b/src/XMPPConnection.m @@ -171,10 +171,9 @@ if ((rc = stringprep_profile([username UTF8String], &node, "SASLprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException - exceptionWithClass: [self class] - connection: self - profile: @"SASLprep" - string: username]; + exceptionWithConnection: self + profile: @"SASLprep" + string: username]; @try { _username = [[OFString alloc] initWithUTF8String: node]; @@ -203,10 +202,9 @@ if ((rc = stringprep_profile([resource UTF8String], &res, "Resourceprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException - exceptionWithClass: [self class] - connection: self - profile: @"Resourceprep" - string: resource]; + exceptionWithConnection: self + profile: @"Resourceprep" + string: resource]; @try { _resource = [[OFString alloc] initWithUTF8String: res]; @@ -253,10 +251,9 @@ if ((rc = stringprep_profile([domain_ UTF8String], &srv, "Nameprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException - exceptionWithClass: [self class] - connection: self - profile: @"Nameprep" - string: domain_]; + exceptionWithConnection: self + profile: @"Nameprep" + string: domain_]; @try { _domain = [[OFString alloc] initWithUTF8String: srv]; @@ -290,10 +287,9 @@ if ((rc = stringprep_profile([password UTF8String], &pass, "SASLprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException - exceptionWithClass: [self class] - connection: self - profile: @"SASLprep" - string: password]; + exceptionWithConnection: self + profile: @"SASLprep" + string: password]; @try { _password = [[OFString alloc] initWithUTF8String: pass]; @@ -339,8 +335,7 @@ OFEnumerator *enumerator; if (_socket != nil) - @throw [OFAlreadyConnectedException - exceptionWithClass: [self class]]; + @throw [OFAlreadyConnectedException exception]; _socket = [[OFTCPSocket alloc] init]; @@ -691,9 +686,7 @@ { if (![name isEqual: @"stream"] || ![prefix isEqual: @"stream"] || ![ns isEqual: XMPP_NS_STREAM]) - @throw [OFMalformedXMLException - exceptionWithClass: [builder class] - parser: nil]; + @throw [OFMalformedXMLException exception]; else { [self close]; } @@ -873,10 +866,9 @@ namespace: XMPP_NS_XMPP_STREAM] stringValue]; @throw [XMPPStreamErrorException - exceptionWithClass: [self class] - connection: self - condition: condition - reason: reason]; + exceptionWithConnection: self + condition: condition + reason: reason]; return; } @@ -915,7 +907,7 @@ if ([[element name] isEqual: @"failure"]) /* TODO: Find/create an exception to throw here */ - @throw [OFException exceptionWithClass: [self class]]; + @throw [OFException exception]; assert(0); } @@ -961,9 +953,8 @@ of_log(@"Auth failed!"); // FIXME: Do more parsing/handling @throw [XMPPAuthFailedException - exceptionWithClass: [self class] - connection: self - reason: [element XMLString]]; + exceptionWithConnection: self + reason: [element XMLString]]; } assert(0); @@ -1028,7 +1019,7 @@ if (_encryptionRequired && !_encrypted) /* TODO: Find/create an exception to throw here */ - @throw [OFException exceptionWithClass: [self class]]; + @throw [OFException exception]; if ([element elementForName: @"ver" namespace: XMPP_NS_ROSTERVER] != nil) @@ -1221,10 +1212,9 @@ if ((rc = idna_to_ascii_8z([domain_ UTF8String], &cDomain, IDNA_USE_STD3_ASCII_RULES)) != IDNA_SUCCESS) @throw [XMPPIDNATranslationFailedException - exceptionWithClass: [self class] - connection: self - operation: @"ToASCII" - string: domain_]; + exceptionWithConnection: self + operation: @"ToASCII" + string: domain_]; @try { ret = [[OFString alloc] initWithUTF8String: cDomain]; @@ -1253,8 +1243,8 @@ - (void)setDataStorage: (id )dataStorage { if (_streamOpen) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + /* FIXME: Find a better exception! */ + @throw [OFInvalidArgumentException exception]; _dataStorage = dataStorage; } diff --git a/src/XMPPDiscoIdentity.m b/src/XMPPDiscoIdentity.m index 8d7923e..31d8cbc 100644 --- a/src/XMPPDiscoIdentity.m +++ b/src/XMPPDiscoIdentity.m @@ -47,9 +47,7 @@ @try { if (category == nil || type == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; _category = [category copy]; _name = [name copy]; @@ -151,9 +149,7 @@ return OF_ORDERED_SAME; if (![object isKindOfClass: [XMPPDiscoIdentity class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; identity = (XMPPDiscoIdentity*)object; diff --git a/src/XMPPDiscoNode.m b/src/XMPPDiscoNode.m index fe400d2..068b5d9 100644 --- a/src/XMPPDiscoNode.m +++ b/src/XMPPDiscoNode.m @@ -60,8 +60,11 @@ self = [super init]; @try { + if (JID == nil) + @throw [OFInvalidArgumentException exception]; + _JID = [JID copy]; - _node= [node copy]; + _node = [node copy]; _name = [name copy]; _identities = [OFSortedList new]; _features = [OFSortedList new]; diff --git a/src/XMPPExceptions.h b/src/XMPPExceptions.h index d522f9c..feb59f2 100644 --- a/src/XMPPExceptions.h +++ b/src/XMPPExceptions.h @@ -41,24 +41,20 @@ /** * \brief Creates a new XMPPException. * - * \param class_ The class of the object which caused the exception * \param connection The connection that received the data responsible * for this exception * \return A new XMPPException */ -+ exceptionWithClass: (Class)class_ - connection: (XMPPConnection*)connection; ++ exceptionWithConnection: (XMPPConnection*)connection; /** * \brief Initializes an already allocated XMPPException. * - * \param class_ The class of the object which caused the exception * \param connection The connection that received the data responsible * for this exception * \return An initialized XMPPException */ -- initWithClass: (Class)class_ - connection: (XMPPConnection*)connection; +- initWithConnection: (XMPPConnection*)connection; - (XMPPConnection*)connection; @end @@ -82,30 +78,26 @@ /** * \brief Creates a new XMPPStreamErrorException. * - * \param class_ The class of the object which caused the exception * \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 */ -+ exceptionWithClass: (Class)class_ - connection: (XMPPConnection*)connection - condition: (OFString*)condition - reason: (OFString*)reason; ++ exceptionWithConnection: (XMPPConnection*)connection + condition: (OFString*)condition + reason: (OFString*)reason; /** * \brief Initializes an already allocated XMPPStreamErrorException. * - * \param class_ The class of the object which caused the exception * \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 */ -- initWithClass: (Class)class_ - connection: (XMPPConnection*)connection - condition: (OFString*)condition - reason: (OFString*)reason; +- initWithConnection: (XMPPConnection*)connection + condition: (OFString*)condition + reason: (OFString*)reason; - (OFString*)condition; - (OFString*)reason; @@ -131,30 +123,26 @@ /** * \brief Creates a new XMPPStringPrepFailedException. * - * \param class_ The class of the object which caused the exception * \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 */ -+ exceptionWithClass: (Class)class_ - connection: (XMPPConnection*)connection - profile: (OFString*)profile - string: (OFString*)string; ++ exceptionWithConnection: (XMPPConnection*)connection + profile: (OFString*)profile + string: (OFString*)string; /** * \brief Initializes an already allocated XMPPStringPrepFailedException. * - * \param class_ The class of the object which caused the exception * \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 */ -- initWithClass: (Class)class_ - connection: (XMPPConnection*)connection - profile: (OFString*)profile - string: (OFString*)string; +- initWithConnection: (XMPPConnection*)connection + profile: (OFString*)profile + string: (OFString*)string; - (OFString*)profile; - (OFString*)string; @@ -179,30 +167,26 @@ /** * \brief Creates a new XMPPIDNATranslationFailedException. * - * \param class_ The class of the object which caused the exception * \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 */ -+ exceptionWithClass: (Class)class_ - connection: (XMPPConnection*)connection - operation: (OFString*)operation - string: (OFString*)string; ++ exceptionWithConnection: (XMPPConnection*)connection + operation: (OFString*)operation + string: (OFString*)string; /** * \brief Initializes an already allocated XMPPIDNATranslationFailedException. * - * \param class_ The class of the object which caused the exception * \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 */ -- initWithClass: (Class)class_ - connection: (XMPPConnection*)connection - operation: (OFString*)operation - string: (OFString*)string; +- initWithConnection: (XMPPConnection*)connection + operation: (OFString*)operation + string: (OFString*)string; - (OFString*)operation; - (OFString*)string; @@ -224,26 +208,22 @@ /** * \brief Creates a new XMPPAuthFailedException. * - * \param class_ The class of the object which caused the exception * \param connection The connection that could not be authenticated * \param reason The reason the authentication failed * \return A new XMPPAuthFailedException */ -+ exceptionWithClass: (Class)class_ - connection: (XMPPConnection*)connection - reason: (OFString*)reason; ++ exceptionWithConnection: (XMPPConnection*)connection + reason: (OFString*)reason; /** * \brief Initializes an already allocated XMPPAuthFailedException. * - * \param class_ The class of the object which caused the exception * \param connection The connection that could not be authenticated * \param reason The reason the authentication failed * \return An initialized XMPPAuthFailedException */ -- initWithClass: (Class)class_ - connection: (XMPPConnection*)connection - reason: (OFString*)reason; +- initWithConnection: (XMPPConnection*)connection + reason: (OFString*)reason; - (OFString*)reason; @end diff --git a/src/XMPPExceptions.m b/src/XMPPExceptions.m index a01d0c4..9d7146f 100644 --- a/src/XMPPExceptions.m +++ b/src/XMPPExceptions.m @@ -24,29 +24,32 @@ # include "config.h" #endif +#include + #import "XMPPExceptions.h" #import "XMPPConnection.h" @implementation XMPPException -+ exceptionWithClass: (Class)class - connection: (XMPPConnection*)connection ++ exceptionWithConnection: (XMPPConnection*)connection { - return [[[self alloc] initWithClass: class - connection: connection] autorelease]; + return [[[self alloc] initWithConnection: connection] autorelease]; } -- initWithClass: (Class)class +- init { - Class c = [self class]; - [self release]; - @throw [OFNotImplementedException exceptionWithClass: c - selector: _cmd]; + @try { + [self doesNotRecognizeSelector: _cmd]; + } @catch (id e) { + [self release]; + @throw e; + } + + abort(); } -- initWithClass: (Class)class - connection: (XMPPConnection*)connection +- initWithConnection: (XMPPConnection*)connection { - self = [super initWithClass: class]; + self = [super init]; @try { _connection = [connection retain]; @@ -67,38 +70,37 @@ - (XMPPConnection*)connection { - OF_GETTER(_connection, NO) + OF_GETTER(_connection, false) } @end @implementation XMPPStreamErrorException -+ exceptionWithClass: (Class)class - connection: (XMPPConnection*)connection ++ 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; + reason: (OFString*)reason { - return [[[self alloc] initWithClass: class - connection: connection - condition: condition - reason: reason] autorelease]; -} - -- initWithClass: (Class)class - connection: (XMPPConnection*)connection -{ - Class c = [self class]; - [self release]; - @throw [OFNotImplementedException exceptionWithClass: c - selector: _cmd]; -} - -- initWithClass: (Class)class - connection: (XMPPConnection*)connection - condition: (OFString*)condition - reason: (OFString*)reason -{ - self = [super initWithClass: class - connection: connection]; + self = [super initWithConnection: connection]; @try { _condition = [condition copy]; @@ -122,49 +124,47 @@ - (OFString*)description { return [OFString stringWithFormat: - @"Got stream error in class %@: %@. Reason: %@!", [self inClass], - _condition, _reason]; + @"Got stream error: %@. Reason: %@!", _condition, _reason]; } - (OFString*)condition { - OF_GETTER(_condition, NO) + OF_GETTER(_condition, false) } - (OFString*)reason { - OF_GETTER(_reason, NO) + OF_GETTER(_reason, false) } @end @implementation XMPPStringPrepFailedException -+ exceptionWithClass: (Class)class - connection: (XMPPConnection*)connection ++ 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 { - return [[[self alloc] initWithClass: class - connection: connection - profile: profile - string: string] autorelease]; -} - -- initWithClass: (Class)class - connection: (XMPPConnection*)connection -{ - Class c = [self class]; - [self release]; - @throw [OFNotImplementedException exceptionWithClass: c - selector: _cmd]; -} - -- initWithClass: (Class)class - connection: (XMPPConnection*)connection - profile: (OFString*)profile - string: (OFString*)string -{ - self = [super initWithClass: class - connection: connection]; + self = [super initWithConnection: connection]; @try { _profile = [profile copy]; @@ -188,49 +188,48 @@ - (OFString*)description { return [OFString stringWithFormat: - @"Stringprep with profile %@ failed in class %@ on string '%@'!", - _profile, [self inClass], _string]; + @"Stringprep with profile %@ failed on string '%@'!", + _profile, _string]; } - (OFString*)profile { - OF_GETTER(_profile, NO) + OF_GETTER(_profile, false) } - (OFString*)string { - OF_GETTER(_string, NO) + OF_GETTER(_string, false) } @end @implementation XMPPIDNATranslationFailedException -+ exceptionWithClass: (Class)class - connection: (XMPPConnection*)connection ++ 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 { - return [[[self alloc] initWithClass: class - connection: connection - operation: operation - string: string] autorelease]; -} - -- initWithClass: (Class)class - connection: (XMPPConnection*)connection -{ - Class c = [self class]; - [self release]; - @throw [OFNotImplementedException exceptionWithClass: c - selector: _cmd]; -} - -- initWithClass: (Class)class - connection: (XMPPConnection*)connection - operation: (OFString*)operation - string: (OFString*)string -{ - self = [super initWithClass: class - connection: connection]; + self = [super initWithConnection: connection]; @try { _operation = [operation copy]; @@ -254,46 +253,44 @@ - (OFString*)description { return [OFString stringWithFormat: - @"IDNA operation %@ failed in class %@ on string '%@'!", _operation, - [self inClass], _string]; + @"IDNA operation %@ failed on string '%@'!", _operation, _string]; } - (OFString*)operation { - OF_GETTER(_operation, NO) + OF_GETTER(_operation, false) } - (OFString*)string { - OF_GETTER(_string, NO) + OF_GETTER(_string, false) } @end @implementation XMPPAuthFailedException -+ exceptionWithClass: (Class)class - connection: (XMPPConnection*)connection - reason: (OFString*)reason; ++ exceptionWithConnection: (XMPPConnection*)connection + reason: (OFString*)reason; { - return [[[self alloc] initWithClass: class - connection: connection - reason: reason] autorelease]; + return [[[self alloc] initWithConnection: connection + reason: reason] autorelease]; } -- initWithClass: (Class)class - connection: (XMPPConnection*)connection +- initWithConnection: (XMPPConnection*)connection { - Class c = [self class]; - [self release]; - @throw [OFNotImplementedException exceptionWithClass: c - selector: _cmd]; + @try { + [self doesNotRecognizeSelector: _cmd]; + } @catch (id e) { + [self release]; + @throw e; + } + + abort(); } -- initWithClass: (Class)class - connection: (XMPPConnection*)connection - reason: (OFString*)reason +- initWithConnection: (XMPPConnection*)connection + reason: (OFString*)reason { - self = [super initWithClass: class - connection: connection]; + self = [super initWithConnection: connection]; @try { _reason = [reason copy]; @@ -315,12 +312,11 @@ - (OFString*)description { return [OFString stringWithFormat: - @"Authentication failed in class %@. Reason: %@!", [self inClass], - _reason]; + @"Authentication failed. Reason: %@!", _reason]; } - (OFString*)reason { - OF_GETTER(_reason, NO) + OF_GETTER(_reason, false) } @end diff --git a/src/XMPPFileStorage.m b/src/XMPPFileStorage.m index bf9a03c..3f9529a 100644 --- a/src/XMPPFileStorage.m +++ b/src/XMPPFileStorage.m @@ -24,6 +24,8 @@ # include "config.h" #endif +#include + #import #import #import @@ -38,10 +40,14 @@ @implementation XMPPFileStorage - init { - Class c = [self class]; - [self release]; - @throw [OFNotImplementedException exceptionWithClass: c - selector: _cmd]; + @try { + [self doesNotRecognizeSelector: _cmd]; + } @catch (id e) { + [self release]; + @throw e; + } + + abort(); } - initWithFile: (OFString*)file @@ -54,7 +60,7 @@ _file = [file copy]; @try { _data = [[[OFDataArray dataArrayWithContentsOfFile: - file] binaryPackValue] retain]; + file] messagePackValue] retain]; } @catch (id e) { _data = [OFMutableDictionary new]; } @@ -78,7 +84,7 @@ - (void)save { - [[_data binaryPackRepresentation] writeToFile: _file]; + [[_data messagePackRepresentation] writeToFile: _file]; } - (void)XMPP_setObject: (id)object diff --git a/src/XMPPIQ.m b/src/XMPPIQ.m index cfa53f3..7a34d8a 100644 --- a/src/XMPPIQ.m +++ b/src/XMPPIQ.m @@ -46,9 +46,7 @@ @try { if (![type isEqual: @"get"] && ![type isEqual: @"set"] && ![type isEqual: @"result"] && ![type isEqual: @"error"]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; } @catch (id e) { [self release]; @throw e; diff --git a/src/XMPPJID.m b/src/XMPPJID.m index ac575cd..dfafdd1 100644 --- a/src/XMPPJID.m +++ b/src/XMPPJID.m @@ -119,10 +119,9 @@ "Nodeprep", 0)) != STRINGPREP_OK) || (nodepart[0] == '\0') || (strlen(nodepart) > 1023)) @throw [XMPPStringPrepFailedException - exceptionWithClass: [self class] - connection: nil - profile: @"Nodeprep" - string: node]; + exceptionWithConnection: nil + profile: @"Nodeprep" + string: node]; @try { _node = [[OFString alloc] initWithUTF8String: nodepart]; @@ -148,10 +147,9 @@ "Nameprep", 0)) != STRINGPREP_OK) || (srv[0] == '\0') || (strlen(srv) > 1023)) @throw [XMPPStringPrepFailedException - exceptionWithClass: [self class] - connection: nil - profile: @"Nameprep" - string: domain]; + exceptionWithConnection: nil + profile: @"Nameprep" + string: domain]; @try { _domain = [[OFString alloc] initWithUTF8String: srv]; @@ -183,10 +181,9 @@ "Resourceprep", 0)) != STRINGPREP_OK) || (res[0] == '\0') || (strlen(res) > 1023)) @throw [XMPPStringPrepFailedException - exceptionWithClass: [self class] - connection: nil - profile: @"Resourceprep" - string: resource]; + exceptionWithConnection: nil + profile: @"Resourceprep" + string: resource]; @try { _resource = [[OFString alloc] initWithUTF8String: res]; diff --git a/src/XMPPPresence.m b/src/XMPPPresence.m index a38a84b..21d1e62 100644 --- a/src/XMPPPresence.m +++ b/src/XMPPPresence.m @@ -184,9 +184,7 @@ static int show_to_int(OFString *show) intmax_t prio = [priority intMaxValue]; if ((prio < -128) || (prio > 127)) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; OFXMLElement *oldPriority = [self elementForName: @"priority" namespace: XMPP_NS_CLIENT]; @@ -219,9 +217,7 @@ static int show_to_int(OFString *show) return OF_ORDERED_SAME; if (![object isKindOfClass: [XMPPPresence class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; otherPresence = (XMPPPresence*)object; otherPriority = [otherPresence priority]; diff --git a/src/XMPPRoster.m b/src/XMPPRoster.m index a1d882a..901612e 100644 --- a/src/XMPPRoster.m +++ b/src/XMPPRoster.m @@ -213,8 +213,8 @@ - (void)setDataStorage: (id )dataStorage { if (_rosterRequested) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + /* FIXME: Find a better exception! */ + @throw [OFInvalidArgumentException exception]; _dataStorage = dataStorage; } diff --git a/src/XMPPSCRAMAuth.m b/src/XMPPSCRAMAuth.m index 468605f..7e807af 100644 --- a/src/XMPPSCRAMAuth.m +++ b/src/XMPPSCRAMAuth.m @@ -168,9 +168,8 @@ [_clientFirstMessageBare release]; _clientFirstMessageBare = nil; - _clientFirstMessageBare = [[OFString alloc] initWithFormat: @"n=%@,r=%@", - _authcid, - _cNonce]; + _clientFirstMessageBare = [[OFString alloc] + initWithFormat: @"n=%@,r=%@", _authcid, _cNonce]; [ret addItems: [_GS2Header UTF8String] count: [_GS2Header UTF8StringLength]]; @@ -230,10 +229,9 @@ if ([comp hasPrefix: @"r="]) { if (![entry hasPrefix: _cNonce]) @throw [XMPPAuthFailedException - exceptionWithClass: [self class] - connection: nil - reason: @"Received wrong " - @"nonce"]; + exceptionWithConnection: nil + reason: @"Received wrong " + @"nonce"]; sNonce = entry; got |= GOT_SNONCE; @@ -248,8 +246,7 @@ } if (got != (GOT_SNONCE | GOT_SALT | GOT_ITERCOUNT)) - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; // Add c= tmpArray = [OFDataArray dataArray]; @@ -390,15 +387,13 @@ if ([mess hasPrefix: @"v="]) { if (![value isEqual: [_serverSignature stringByBase64Encoding]]) @throw [XMPPAuthFailedException - exceptionWithClass: [self class] - connection: nil - reason: @"Received wrong " - @"ServerSignature"]; + exceptionWithConnection: nil + reason: @"Received wrong " + @"ServerSignature"]; _authenticated = YES; } else - @throw [XMPPAuthFailedException exceptionWithClass: [self class] - connection: nil - reason: value]; + @throw [XMPPAuthFailedException exceptionWithConnection: nil + reason: value]; return nil; } diff --git a/src/XMPPSRVLookup.m b/src/XMPPSRVLookup.m index be66c32..f35a261 100644 --- a/src/XMPPSRVLookup.m +++ b/src/XMPPSRVLookup.m @@ -25,6 +25,8 @@ # include "config.h" #endif +#include + #include #include @@ -55,10 +57,14 @@ - init { - Class c = [self class]; - [self release]; - @throw [OFNotImplementedException exceptionWithClass: c - selector: _cmd]; + @try { + [self doesNotRecognizeSelector: _cmd]; + } @catch (id e) { + [self release]; + @throw e; + } + + abort(); } - initWithPriority: (uint16_t)priority @@ -208,9 +214,7 @@ if (res_ninit(&_resState)) @throw [OFAddressTranslationFailedException - exceptionWithClass: [self class] - socket: nil - host: _domain]; + exceptionWithHost: _domain]; answer = [self allocMemoryWithSize: pageSize]; answerLen = res_nsearch(&_resState, @@ -221,18 +225,13 @@ (h_errno == NO_DATA))) return; - if (answerLen < 1 || answerLen > pageSize) { + if (answerLen < 1 || answerLen > pageSize) @throw [OFAddressTranslationFailedException - exceptionWithClass: [self class] - socket: nil - host: _domain]; - } + exceptionWithHost: _domain]; if (ns_initparse(answer, answerLen, &handle)) @throw [OFAddressTranslationFailedException - exceptionWithClass: [self class] - socket: nil - host: _domain]; + exceptionWithHost: _domain]; resourceRecordCount = ns_msg_count(handle, ns_s_an); for (i = 0; i < resourceRecordCount; i++) { diff --git a/src/XMPPStanza.m b/src/XMPPStanza.m index f30365c..f42307b 100644 --- a/src/XMPPStanza.m +++ b/src/XMPPStanza.m @@ -96,9 +96,7 @@ @try { if (![name isEqual: @"iq"] && ![name isEqual: @"message"] && ![name isEqual: @"presence"]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; [self setDefaultNamespace: XMPP_NS_CLIENT]; [self setPrefix: @"stream" diff --git a/src/XMPPXMLElementBuilder.m b/src/XMPPXMLElementBuilder.m index 67dc33f..8583292 100644 --- a/src/XMPPXMLElementBuilder.m +++ b/src/XMPPXMLElementBuilder.m @@ -32,12 +32,12 @@ - (void)parser: (OFXMLParser*)parser foundProcessingInstructions: (OFString*)pi { - @throw [OFMalformedXMLException exceptionWithClass: [self class]]; + @throw [OFMalformedXMLException exception]; } - (void)parser: (OFXMLParser*)parser foundComment: (OFString*)comment { - @throw [OFMalformedXMLException exceptionWithClass: [self class]]; + @throw [OFMalformedXMLException exception]; } @end