Index: src/XMPPConnection.m ================================================================== --- src/XMPPConnection.m +++ src/XMPPConnection.m @@ -169,14 +169,13 @@ Stringprep_rc rc; 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]; } @finally { free(node); @@ -201,14 +200,13 @@ Stringprep_rc rc; 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]; } @finally { free(res); @@ -251,14 +249,13 @@ Stringprep_rc rc; 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]; } @finally { free(srv); @@ -288,14 +285,13 @@ Stringprep_rc rc; 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]; } @finally { free(pass); @@ -337,12 +333,11 @@ XMPPSRVEntry *candidate = nil; XMPPSRVLookup *SRVLookup = nil; OFEnumerator *enumerator; if (_socket != nil) - @throw [OFAlreadyConnectedException - exceptionWithClass: [self class]]; + @throw [OFAlreadyConnectedException exception]; _socket = [[OFTCPSocket alloc] init]; if (_server) [_socket connectToHost: _server @@ -689,13 +684,11 @@ prefix: (OFString*)prefix namespace: (OFString*)ns { 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]; } } @@ -871,14 +864,13 @@ reason = [[element elementForName: @"text" namespace: XMPP_NS_XMPP_STREAM] stringValue]; @throw [XMPPStreamErrorException - exceptionWithClass: [self class] - connection: self - condition: condition - reason: reason]; + exceptionWithConnection: self + condition: condition + reason: reason]; return; } assert(0); } @@ -913,11 +905,11 @@ return; } if ([[element name] isEqual: @"failure"]) /* TODO: Find/create an exception to throw here */ - @throw [OFException exceptionWithClass: [self class]]; + @throw [OFException exception]; assert(0); } - (void)XMPP_handleSASL: (OFXMLElement*)element @@ -959,13 +951,12 @@ if ([[element name] isEqual: @"failure"]) { 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); } @@ -1026,11 +1017,11 @@ return; } 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) _supportsRosterVersioning = YES; @@ -1219,14 +1210,13 @@ Idna_rc rc; 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]; } @finally { free(cDomain); @@ -1251,12 +1241,12 @@ } - (void)setDataStorage: (id )dataStorage { if (_streamOpen) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + /* FIXME: Find a better exception! */ + @throw [OFInvalidArgumentException exception]; _dataStorage = dataStorage; } - (id )dataStorage Index: src/XMPPDiscoIdentity.m ================================================================== --- src/XMPPDiscoIdentity.m +++ src/XMPPDiscoIdentity.m @@ -45,13 +45,11 @@ { self = [super init]; @try { if (category == nil || type == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; _category = [category copy]; _name = [name copy]; _type = [type copy]; } @catch (id e) { @@ -149,13 +147,11 @@ if (object == self) return OF_ORDERED_SAME; if (![object isKindOfClass: [XMPPDiscoIdentity class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; identity = (XMPPDiscoIdentity*)object; categoryResult = [_category compare: identity->_category]; if (categoryResult != OF_ORDERED_SAME) Index: src/XMPPDiscoNode.m ================================================================== --- src/XMPPDiscoNode.m +++ src/XMPPDiscoNode.m @@ -58,12 +58,15 @@ name: (OFString*)name { 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]; _childNodes = [OFMutableDictionary new]; Index: src/XMPPExceptions.h ================================================================== --- src/XMPPExceptions.h +++ src/XMPPExceptions.h @@ -39,28 +39,24 @@ #endif /** * \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 /** @@ -80,34 +76,30 @@ #endif /** * \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; @end @@ -129,34 +121,30 @@ #endif /** * \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; @end @@ -177,34 +165,30 @@ #endif /** * \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; @end @@ -222,28 +206,24 @@ #endif /** * \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 Index: src/XMPPExceptions.m ================================================================== --- src/XMPPExceptions.m +++ src/XMPPExceptions.m @@ -21,34 +21,37 @@ */ #ifdef HAVE_CONFIG_H # include "config.h" #endif + +#include #import "XMPPExceptions.h" #import "XMPPConnection.h" @implementation XMPPException -+ exceptionWithClass: (Class)class - connection: (XMPPConnection*)connection -{ - return [[[self alloc] initWithClass: class - connection: connection] autorelease]; -} - -- initWithClass: (Class)class -{ - Class c = [self class]; - [self release]; - @throw [OFNotImplementedException exceptionWithClass: c - selector: _cmd]; -} - -- initWithClass: (Class)class - connection: (XMPPConnection*)connection -{ - self = [super initWithClass: class]; ++ 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]; @@ -65,42 +68,41 @@ [super dealloc]; } - (XMPPConnection*)connection { - OF_GETTER(_connection, NO) + OF_GETTER(_connection, false) } @end @implementation XMPPStreamErrorException -+ exceptionWithClass: (Class)class - connection: (XMPPConnection*)connection - condition: (OFString*)condition - 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]; ++ 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) { @@ -120,53 +122,51 @@ } - (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 - 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]; ++ 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) { @@ -186,53 +186,52 @@ } - (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 - 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]; ++ 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) { @@ -252,50 +251,48 @@ } - (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; -{ - return [[[self alloc] initWithClass: class - connection: connection - 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 - reason: (OFString*)reason -{ - self = [super initWithClass: class - connection: connection]; ++ 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]; @@ -313,14 +310,13 @@ } - (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 Index: src/XMPPFileStorage.m ================================================================== --- src/XMPPFileStorage.m +++ src/XMPPFileStorage.m @@ -21,10 +21,12 @@ */ #ifdef HAVE_CONFIG_H # include "config.h" #endif + +#include #import #import #import #import @@ -36,14 +38,18 @@ #import "XMPPFileStorage.h" @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 { self = [super init]; @@ -52,11 +58,11 @@ OFAutoreleasePool *pool = [OFAutoreleasePool new]; _file = [file copy]; @try { _data = [[[OFDataArray dataArrayWithContentsOfFile: - file] binaryPackValue] retain]; + file] messagePackValue] retain]; } @catch (id e) { _data = [OFMutableDictionary new]; } [pool release]; @@ -76,11 +82,11 @@ [super dealloc]; } - (void)save { - [[_data binaryPackRepresentation] writeToFile: _file]; + [[_data messagePackRepresentation] writeToFile: _file]; } - (void)XMPP_setObject: (id)object forPath: (OFString*)path { Index: src/XMPPIQ.m ================================================================== --- src/XMPPIQ.m +++ src/XMPPIQ.m @@ -44,13 +44,11 @@ ID: ID]; @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; } Index: src/XMPPJID.m ================================================================== --- src/XMPPJID.m +++ src/XMPPJID.m @@ -117,14 +117,13 @@ if (((rc = stringprep_profile([node UTF8String], &nodepart, "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]; } @finally { free(nodepart); @@ -146,14 +145,13 @@ if (((rc = stringprep_profile([domain UTF8String], &srv, "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]; } @finally { free(srv); @@ -181,14 +179,13 @@ if (((rc = stringprep_profile([resource UTF8String], &res, "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]; } @finally { free(res); Index: src/XMPPPresence.m ================================================================== --- src/XMPPPresence.m +++ src/XMPPPresence.m @@ -182,13 +182,11 @@ - (void)setPriority: (OFNumber*)priority { 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]; if (oldPriority != nil) @@ -217,13 +215,11 @@ if (object == self) 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]; if (otherPriority == nil) otherPriority = [OFNumber numberWithInt8: 0]; Index: src/XMPPRoster.m ================================================================== --- src/XMPPRoster.m +++ src/XMPPRoster.m @@ -211,12 +211,12 @@ } - (void)setDataStorage: (id )dataStorage { if (_rosterRequested) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + /* FIXME: Find a better exception! */ + @throw [OFInvalidArgumentException exception]; _dataStorage = dataStorage; } - (XMPPConnection*)connection Index: src/XMPPSCRAMAuth.m ================================================================== --- src/XMPPSCRAMAuth.m +++ src/XMPPSCRAMAuth.m @@ -166,13 +166,12 @@ _cNonce = [[self XMPP_genNonce] retain]; [_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]]; [ret addItems: [_clientFirstMessageBare UTF8String] @@ -228,14 +227,13 @@ of_range(2, [comp length] - 2)]; 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; } else if ([comp hasPrefix: @"s="]) { salt = [OFDataArray @@ -246,12 +244,11 @@ got |= GOT_ITERCOUNT; } } if (got != (GOT_SNONCE | GOT_SALT | GOT_ITERCOUNT)) - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; // Add c= tmpArray = [OFDataArray dataArray]; [tmpArray addItems: [_GS2Header UTF8String] count: [_GS2Header UTF8StringLength]]; @@ -388,19 +385,17 @@ value = [mess substringWithRange: of_range(2, [mess length] - 2)]; 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; } - (OFString*)XMPP_genNonce Index: src/XMPPSRVLookup.m ================================================================== --- src/XMPPSRVLookup.m +++ src/XMPPSRVLookup.m @@ -23,10 +23,12 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif +#include + #include #include #include #include @@ -53,14 +55,18 @@ handle: handle] autorelease]; } - 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 weight: (uint16_t)weight port: (uint16_t)port @@ -206,13 +212,11 @@ ns_rr resourceRecord; ns_msg handle; if (res_ninit(&_resState)) @throw [OFAddressTranslationFailedException - exceptionWithClass: [self class] - socket: nil - host: _domain]; + 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); @@ -219,22 +223,17 @@ if ((answerLen == -1) && ((h_errno == HOST_NOT_FOUND) || (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++) { if (ns_parserr(&handle, ns_s_an, i, &resourceRecord)) continue; Index: src/XMPPStanza.m ================================================================== --- src/XMPPStanza.m +++ src/XMPPStanza.m @@ -94,13 +94,11 @@ namespace: XMPP_NS_CLIENT]; @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" forNamespace: XMPP_NS_STREAM]; Index: src/XMPPXMLElementBuilder.m ================================================================== --- src/XMPPXMLElementBuilder.m +++ src/XMPPXMLElementBuilder.m @@ -30,14 +30,14 @@ @implementation XMPPXMLElementBuilder - (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