Index: src/XMPPConnection.m ================================================================== --- src/XMPPConnection.m +++ src/XMPPConnection.m @@ -96,14 +96,15 @@ char *node; Stringprep_rc rc; if ((rc = stringprep_profile([username_ UTF8String], &node, "SASLprep", 0)) != STRINGPREP_OK) - @throw [XMPPStringPrepFailedException newWithClass: isa - connection: self - profile: @"SASLprep" - string: username_]; + @throw [XMPPStringPrepFailedException + exceptionWithClass: isa + connection: self + profile: @"SASLprep" + string: username_]; @try { username = [[OFString alloc] initWithUTF8String: node]; } @finally { free(node); @@ -124,14 +125,14 @@ Stringprep_rc rc; if ((rc = stringprep_profile([resource_ UTF8String], &res, "Resourceprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException - newWithClass: isa - connection: self - profile: @"Resourceprep" - string: resource_]; + exceptionWithClass: isa + connection: self + profile: @"Resourceprep" + string: resource_]; @try { resource = [[OFString alloc] initWithUTF8String: res]; } @finally { free(res); @@ -152,14 +153,14 @@ Idna_rc rc; if ((rc = idna_to_ascii_8z([server_ UTF8String], &srv, IDNA_USE_STD3_ASCII_RULES)) != IDNA_SUCCESS) @throw [XMPPIDNATranslationFailedException - newWithClass: isa - connection: self - operation: @"ToASCII" - string: server_]; + exceptionWithClass: isa + connection: self + operation: @"ToASCII" + string: server_]; @try { server = [[OFString alloc] initWithUTF8String: srv]; } @finally { free(srv); @@ -179,14 +180,15 @@ char *srv; Stringprep_rc rc; if ((rc = stringprep_profile([domain_ UTF8String], &srv, "Nameprep", 0)) != STRINGPREP_OK) - @throw [XMPPStringPrepFailedException newWithClass: isa - connection: self - profile: @"Nameprep" - string: domain_]; + @throw [XMPPStringPrepFailedException + exceptionWithClass: isa + connection: self + profile: @"Nameprep" + string: domain_]; @try { domain = [[OFString alloc] initWithUTF8String: srv]; } @finally { free(srv); @@ -206,14 +208,15 @@ char *pass; Stringprep_rc rc; if ((rc = stringprep_profile([password_ UTF8String], &pass, "SASLprep", 0)) != STRINGPREP_OK) - @throw [XMPPStringPrepFailedException newWithClass: isa - connection: self - profile: @"SASLprep" - string: password_]; + @throw [XMPPStringPrepFailedException + exceptionWithClass: isa + connection: self + profile: @"SASLprep" + string: password_]; @try { password = [[OFString alloc] initWithUTF8String: pass]; } @finally { free(pass); @@ -242,14 +245,14 @@ port: port]; else { if ((rc = idna_to_ascii_8z([domain UTF8String], &cDomainToASCII, IDNA_USE_STD3_ASCII_RULES)) != IDNA_SUCCESS) @throw [XMPPIDNATranslationFailedException - newWithClass: isa - connection: self - operation: @"ToASCII" - string: domain]; + exceptionWithClass: isa + connection: self + operation: @"ToASCII" + string: domain]; @try { domainToASCII = [OFString stringWithUTF8String: cDomainToASCII]; } @finally { @@ -258,11 +261,10 @@ @try { SRVLookup = [XMPPSRVLookup lookupWithDomain: domainToASCII]; } @catch (id e) { - [e release]; } enumerator = [SRVLookup objectEnumerator]; /* Iterate over SRV records, if any */ @@ -272,13 +274,11 @@ [sock connectToHost: [candidate target] port: [candidate port]]; break; } @catch (OFAddressTranslationFailedException *e) { - [e release]; } @catch (OFConnectionFailedException *e) { - [e release]; } } while ((candidate = [enumerator nextObject]) != nil); } else /* No SRV records -> fall back to A / AAAA record */ [sock connectToHost: domainToASCII @@ -567,14 +567,14 @@ reason = [[element elementForName: @"text" namespace: XMPP_NS_XMPP_STREAM] stringValue]; - @throw [XMPPStreamErrorException newWithClass: isa - connection: self - condition: condition - reason: reason]; + @throw [XMPPStreamErrorException exceptionWithClass: isa + connection: self + condition: condition + reason: reason]; return; } assert(0); } @@ -605,11 +605,11 @@ return; } if ([[element name] isEqual: @"failure"]) /* TODO: Find/create an exception to throw here */ - @throw [OFException newWithClass: isa]; + @throw [OFException exceptionWithClass: isa]; assert(0); } - (void)XMPP_handleSASL: (OFXMLElement*)element @@ -653,13 +653,13 @@ if ([[element name] isEqual: @"failure"]) { of_log(@"Auth failed!"); // FIXME: Do more parsing/handling @throw [XMPPAuthFailedException - newWithClass: isa - connection: self - reason: [element XMLString]]; + exceptionWithClass: isa + connection: self + reason: [element XMLString]]; } assert(0); } @@ -728,11 +728,11 @@ return; } if (encryptionRequired && !encrypted) /* TODO: Find/create an exception to throw here */ - @throw [OFException newWithClass: isa]; + @throw [OFException exceptionWithClass: isa]; if (mechs != nil) { OFEnumerator *enumerator; OFXMLElement *mech; Index: src/XMPPExceptions.h ================================================================== --- src/XMPPExceptions.h +++ src/XMPPExceptions.h @@ -32,12 +32,12 @@ #ifdef OF_HAVE_PROPERTIES @property (readonly, nonatomic) XMPPConnection *connection; #endif -+ newWithClass: (Class)class_ - connection: (XMPPConnection*)conn; ++ exceptionWithClass: (Class)class_ + connection: (XMPPConnection*)conn; - initWithClass: (Class)class_ connection: (XMPPConnection*)conn; - (XMPPConnection*)connection; @end @@ -50,12 +50,12 @@ #ifdef OF_HAVE_PROPERTIES @property (readonly, nonatomic) OFString *condition; @property (readonly, nonatomic) OFString *reason; #endif -+ newWithClass: (Class)class_ - connection: (XMPPConnection*)conn ++ exceptionWithClass: (Class)class_ + connection: (XMPPConnection*)conn condition: (OFString*)condition_ reason: (OFString*)reason_; - initWithClass: (Class)class_ connection: (XMPPConnection*)conn condition: (OFString*)condition_ @@ -72,14 +72,14 @@ #ifdef OF_HAVE_PROPERTIES @property (readonly, nonatomic) OFString *profile, *string; #endif -+ newWithClass: (Class)class_ - connection: (XMPPConnection*)conn - profile: (OFString*)profile - string: (OFString*)string; ++ exceptionWithClass: (Class)class_ + connection: (XMPPConnection*)conn + profile: (OFString*)profile + string: (OFString*)string; - initWithClass: (Class)class_ connection: (XMPPConnection*)conn profile: (OFString*)profile string: (OFString*)string; - (OFString*)profile; @@ -94,14 +94,14 @@ #ifdef OF_HAVE_PROPERTIES @property (readonly, nonatomic) OFString *operation, *string; #endif -+ newWithClass: (Class)class_ - connection: (XMPPConnection*)conn - operation: (OFString*)operation - string: (OFString*)string; ++ exceptionWithClass: (Class)class_ + connection: (XMPPConnection*)conn + operation: (OFString*)operation + string: (OFString*)string; - initWithClass: (Class)class_ connection: (XMPPConnection*)conn operation: (OFString*)operation string: (OFString*)string; - (OFString*)operation; @@ -115,13 +115,13 @@ #ifdef OF_HAVE_PROPERTIES @property (readonly, nonatomic) OFString *reason; #endif -+ newWithClass: (Class)class_ - connection: (XMPPConnection*)conn - reason: (OFString*)reason_; ++ exceptionWithClass: (Class)class_ + connection: (XMPPConnection*)conn + reason: (OFString*)reason_; - initWithClass: (Class)class_ connection: (XMPPConnection*)conn reason: (OFString*)reason_; - (OFString*)reason; @end Index: src/XMPPExceptions.m ================================================================== --- src/XMPPExceptions.m +++ src/XMPPExceptions.m @@ -25,23 +25,23 @@ #endif #import "XMPPExceptions.h" @implementation XMPPException -+ newWithClass: (Class)class_ - connection: (XMPPConnection*)conn ++ exceptionWithClass: (Class)class_ + connection: (XMPPConnection*)conn { - return [[self alloc] initWithClass: class_ - connection: conn]; + return [[[self alloc] initWithClass: class_ + connection: conn] autorelease]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; - @throw [OFNotImplementedException newWithClass: c - selector: _cmd]; + @throw [OFNotImplementedException exceptionWithClass: c + selector: _cmd]; } - initWithClass: (Class)class_ connection: (XMPPConnection*)conn { @@ -80,28 +80,28 @@ return connection; } @end @implementation XMPPStreamErrorException -+ newWithClass: (Class)class_ - connection: (XMPPConnection*)conn - condition: (OFString*)condition_ - reason: (OFString*)reason_; -{ - return [[self alloc] initWithClass: class_ - connection: conn - condition: condition_ - reason: reason_]; ++ exceptionWithClass: (Class)class_ + connection: (XMPPConnection*)conn + condition: (OFString*)condition_ + reason: (OFString*)reason_; +{ + return [[[self alloc] initWithClass: class_ + connection: conn + condition: condition_ + reason: reason_] autorelease]; } - initWithClass: (Class)class_ connection: (XMPPConnection*)conn { Class c = isa; [self release]; - @throw [OFNotImplementedException newWithClass: c - selector: _cmd]; + @throw [OFNotImplementedException exceptionWithClass: c + selector: _cmd]; } - initWithClass: (Class)class_ connection: (XMPPConnection*)conn condition: (OFString*)condition_ @@ -150,28 +150,28 @@ return reason; } @end @implementation XMPPStringPrepFailedException -+ newWithClass: (Class)class_ - connection: (XMPPConnection*)conn - profile: (OFString*)profile - string: (OFString*)string -{ - return [[self alloc] initWithClass: class_ - connection: conn - profile: profile - string: string]; ++ exceptionWithClass: (Class)class_ + connection: (XMPPConnection*)conn + profile: (OFString*)profile + string: (OFString*)string +{ + return [[[self alloc] initWithClass: class_ + connection: conn + profile: profile + string: string] autorelease]; } - initWithClass: (Class)class_ connection: (XMPPConnection*)conn { Class c = isa; [self release]; - @throw [OFNotImplementedException newWithClass: c - selector: _cmd]; + @throw [OFNotImplementedException exceptionWithClass: c + selector: _cmd]; } - initWithClass: (Class)class_ connection: (XMPPConnection*)conn profile: (OFString*)profile_ @@ -221,28 +221,28 @@ return string; } @end @implementation XMPPIDNATranslationFailedException -+ newWithClass: (Class)class_ - connection: (XMPPConnection*)conn - operation: (OFString*)operation - string: (OFString*)string -{ - return [[self alloc] initWithClass: class_ - connection: conn - operation: operation - string: string]; ++ exceptionWithClass: (Class)class_ + connection: (XMPPConnection*)conn + operation: (OFString*)operation + string: (OFString*)string +{ + return [[[self alloc] initWithClass: class_ + connection: conn + operation: operation + string: string] autorelease]; } - initWithClass: (Class)class_ connection: (XMPPConnection*)conn { Class c = isa; [self release]; - @throw [OFNotImplementedException newWithClass: c - selector: _cmd]; + @throw [OFNotImplementedException exceptionWithClass: c + selector: _cmd]; } - initWithClass: (Class)class_ connection: (XMPPConnection*)conn operation: (OFString*)operation_ @@ -291,26 +291,26 @@ return string; } @end @implementation XMPPAuthFailedException -+ newWithClass: (Class)class_ - connection: (XMPPConnection*)conn - reason: (OFString*)reason_; ++ exceptionWithClass: (Class)class_ + connection: (XMPPConnection*)conn + reason: (OFString*)reason_; { - return [[self alloc] initWithClass: class_ - connection: conn - reason: reason_]; + return [[[self alloc] initWithClass: class_ + connection: conn + reason: reason_] autorelease]; } - initWithClass: (Class)class_ connection: (XMPPConnection*)conn { Class c = isa; [self release]; - @throw [OFNotImplementedException newWithClass: c - selector: _cmd]; + @throw [OFNotImplementedException exceptionWithClass: c + selector: _cmd]; } - initWithClass: (Class)class_ connection: (XMPPConnection*)conn reason: (OFString*)reason_ Index: src/XMPPIQ.m ================================================================== --- src/XMPPIQ.m +++ src/XMPPIQ.m @@ -44,12 +44,13 @@ ID: ID_]; @try { if (![type_ isEqual: @"get"] && ![type_ isEqual: @"set"] && ![type_ isEqual: @"result"] && ![type_ isEqual: @"error"]) - @throw [OFInvalidArgumentException newWithClass: isa - selector: _cmd]; + @throw [OFInvalidArgumentException + exceptionWithClass: isa + selector: _cmd]; } @catch (id e) { [self release]; @throw e; } Index: src/XMPPJID.m ================================================================== --- src/XMPPJID.m +++ src/XMPPJID.m @@ -110,14 +110,15 @@ return; } if ((rc = stringprep_profile([node_ UTF8String], &nodepart, "Nodeprep", 0)) != STRINGPREP_OK) - @throw [XMPPStringPrepFailedException newWithClass: isa - connection: nil - profile: @"Nodeprep" - string: node_]; + @throw [XMPPStringPrepFailedException + exceptionWithClass: isa + connection: nil + profile: @"Nodeprep" + string: node_]; @try { node = [[OFString alloc] initWithUTF8String: nodepart]; } @finally { free(nodepart); @@ -137,14 +138,15 @@ char *srv; Stringprep_rc rc; if ((rc = stringprep_profile([domain_ UTF8String], &srv, "Nameprep", 0)) != STRINGPREP_OK) - @throw [XMPPStringPrepFailedException newWithClass: isa - connection: nil - profile: @"Nameprep" - string: domain_]; + @throw [XMPPStringPrepFailedException + exceptionWithClass: isa + connection: nil + profile: @"Nameprep" + string: domain_]; @try { domain = [[OFString alloc] initWithUTF8String: srv]; } @finally { free(srv); @@ -171,14 +173,14 @@ } if ((rc = stringprep_profile([resource_ UTF8String], &res, "Resourceprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException - newWithClass: isa - connection: nil - profile: @"Resourceprep" - string: resource_]; + exceptionWithClass: isa + connection: nil + profile: @"Resourceprep" + string: resource_]; @try { resource = [[OFString alloc] initWithUTF8String: res]; } @finally { free(res); Index: src/XMPPSCRAMAuth.m ================================================================== --- src/XMPPSCRAMAuth.m +++ src/XMPPSCRAMAuth.m @@ -229,13 +229,14 @@ of_range(2, [comp length] - 2)]; if ([comp hasPrefix: @"r="]) { if (![entry hasPrefix: cNonce]) @throw [XMPPAuthFailedException - newWithClass: isa - connection: nil - reason: @"Received wrong nonce"]; + exceptionWithClass: isa + connection: nil + reason: @"Received wrong " + @"nonce"]; sNonce = entry; got |= GOT_SNONCE; } else if ([comp hasPrefix: @"s="]) { salt = [OFDataArray @@ -246,11 +247,11 @@ got |= GOT_ITERCOUNT; } } if (got != (GOT_SNONCE | GOT_SALT | GOT_ITERCOUNT)) - @throw [OFInvalidServerReplyException newWithClass: isa]; + @throw [OFInvalidServerReplyException exceptionWithClass: isa]; // Add c= tmpArray = [OFDataArray dataArrayWithItemSize: 1]; [tmpArray addNItems: [GS2Header UTF8StringLength] fromCArray: [GS2Header UTF8String]]; @@ -387,18 +388,19 @@ value = [mess substringWithRange: of_range(2, [mess length] - 2)]; if ([mess hasPrefix: @"v="]) { if (![value isEqual: [serverSignature stringByBase64Encoding]]) @throw [XMPPAuthFailedException - newWithClass: isa - connection: nil - reason: @"Received wrong ServerSignature"]; + exceptionWithClass: isa + connection: nil + reason: @"Received wrong " + @"ServerSignature"]; authenticated = YES; } else - @throw [XMPPAuthFailedException newWithClass: isa - connection: nil - reason: value]; + @throw [XMPPAuthFailedException exceptionWithClass: isa + connection: nil + reason: value]; return nil; } - (OFString*)XMPP_genNonce Index: src/XMPPSRVLookup.m ================================================================== --- src/XMPPSRVLookup.m +++ src/XMPPSRVLookup.m @@ -57,12 +57,12 @@ - init { Class c = isa; [self release]; - @throw [OFNotImplementedException newWithClass: c - selector: _cmd]; + @throw [OFNotImplementedException exceptionWithClass: c + selector: _cmd]; } - initWithPriority: (uint16_t)priority_ weight: (uint16_t)weight_ port: (uint16_t)port_ @@ -98,11 +98,11 @@ port = ntohs(rdata[2]); if (dn_expand(ns_msg_base(handle), ns_msg_end(handle), (uint8_t*)&rdata[3], buffer, NS_MAXDNAME) < 1) @throw [OFInitializationFailedException - newWithClass: isa]; + exceptionWithClass: isa]; target = [[OFString alloc] initWithCString: buffer encoding: OF_STRING_ENCODING_NATIVE]; } @catch (id e) { @@ -208,13 +208,13 @@ ns_rr resourceRecord; ns_msg handle; if (res_ninit(&resState)) @throw [OFAddressTranslationFailedException - newWithClass: isa - socket: nil - host: domain]; + exceptionWithClass: isa + socket: nil + host: domain]; answer = [self allocMemoryWithSize: of_pagesize]; answerLen = res_nsearch(&resState, [request cStringWithEncoding: OF_STRING_ENCODING_NATIVE], ns_c_in, ns_t_srv, answer, (int)of_pagesize); @@ -223,20 +223,20 @@ (h_errno == NO_DATA))) return; if (answerLen < 1 || answerLen > of_pagesize) { @throw [OFAddressTranslationFailedException - newWithClass: isa - socket: nil - host: domain]; + exceptionWithClass: isa + socket: nil + host: domain]; } if (ns_initparse(answer, answerLen, &handle)) @throw [OFAddressTranslationFailedException - newWithClass: isa - socket: nil - host: domain]; + exceptionWithClass: isa + socket: nil + host: 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,12 +94,13 @@ namespace: XMPP_NS_CLIENT]; @try { if (![name_ isEqual: @"iq"] && ![name_ isEqual: @"message"] && ![name_ isEqual: @"presence"]) - @throw [OFInvalidArgumentException newWithClass: isa - selector: _cmd]; + @throw [OFInvalidArgumentException + exceptionWithClass: isa + selector: _cmd]; [self setDefaultNamespace: XMPP_NS_CLIENT]; [self setPrefix: @"stream" forNamespace: XMPP_NS_STREAM];