Index: src/XMPPCallback.h ================================================================== --- src/XMPPCallback.h +++ src/XMPPCallback.h @@ -23,22 +23,24 @@ #import @class XMPPIQ; #ifdef OF_HAVE_BLOCKS -typedef void(^xmpp_callback_block)(XMPPIQ*); +typedef void(^xmpp_callback_block_t)(XMPPIQ*); #endif @interface XMPPCallback: OFObject { id object; SEL selector; } + #ifdef OF_HAVE_BLOCKS -+ callbackWithCallbackBlock: (xmpp_callback_block)callback; -- initWithCallbackBlock: (xmpp_callback_block)callback; ++ callbackWithCallbackBlock: (xmpp_callback_block_t)callback; +- initWithCallbackBlock: (xmpp_callback_block_t)callback; #endif + + callbackWithCallbackObject: (id)object selector: (SEL)selector; - initWithCallbackObject: (id)object selector: (SEL)selector; Index: src/XMPPCallback.m ================================================================== --- src/XMPPCallback.m +++ src/XMPPCallback.m @@ -26,16 +26,16 @@ #import "XMPPCallback.h" @implementation XMPPCallback #ifdef OF_HAVE_BLOCKS -+ callbackWithCallbackBlock: (xmpp_callback_block)callback ++ callbackWithCallbackBlock: (xmpp_callback_block_t)callback { return [[[self alloc] initWithCallbackBlock: callback] autorelease]; } -- initWithCallbackBlock: (xmpp_callback_block)callback +- initWithCallbackBlock: (xmpp_callback_block_t)callback { self = [super init]; object = [callback copy]; @@ -53,30 +53,27 @@ - initWithCallbackObject: (id)object_ selector: (SEL)selector_ { self = [super init]; - // TODO: Retain or follow delegate paradigm? - object = [object_ retain]; + object = object_; selector = selector_; return self; } - (void)dealloc { - [object release]; - [super dealloc]; } - (void)runWithIQ: (XMPPIQ*)iq { #ifdef OF_HAVE_BLOCKS if ([object isKindOfClass: [OFBlock class]]) - ((xmpp_callback_block)object)(iq); + ((xmpp_callback_block_t)object)(iq); else #endif [object performSelector: selector withObject: iq]; } @end Index: src/XMPPConnection.m ================================================================== --- src/XMPPConnection.m +++ src/XMPPConnection.m @@ -381,13 +381,13 @@ didSendElement: element]; [sock writeString: [element XMLString]]; } -- (void)sendIQ: (XMPPIQ*)iq -withCallbackObject: (id)object - selector: (SEL)selector +- (void)sendIQ: (XMPPIQ*)iq + withCallbackObject: (id)object + selector: (SEL)selector { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; @try { if (![iq ID]) [iq setID: [self generateStanzaID]]; @@ -402,12 +402,12 @@ [self sendStanza: iq]; } #ifdef OF_HAVE_BLOCKS -- (void)sendIQ: (XMPPIQ*)iq -withCallbackBlock: (xmpp_callback_block)callback; +- (void)sendIQ: (XMPPIQ*)iq + withCallbackBlock: (xmpp_callback_block_t)callback; { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; @try { if (![iq ID]) [iq setID: [self generateStanzaID]]; @@ -931,13 +931,13 @@ namespace: XMPP_NS_BIND stringValue: resource]]; [iq addChild: bind]; - [self sendIQ: iq - withCallbackObject: self - selector: @selector(XMPP_handleResourceBind:)]; + [self sendIQ: iq + withCallbackObject: self + selector: @selector(XMPP_handleResourceBind:)]; } - (void)XMPP_sendStreamError: (OFString*)condition text: (OFString*)text { @@ -990,13 +990,13 @@ iq = [XMPPIQ IQWithType: @"set" ID: [self generateStanzaID]]; [iq addChild: [OFXMLElement elementWithName: @"session" namespace: XMPP_NS_SESSION]]; - [self sendIQ: iq - withCallbackObject: self - selector: @selector(XMPP_handleSession:)]; + [self sendIQ: iq + withCallbackObject: self + selector: @selector(XMPP_handleSession:)]; } - (void)XMPP_handleSession: (XMPPIQ*)iq { if (![[iq type] isEqual: @"result"]) Index: src/XMPPEXTERNALAuth.m ================================================================== --- src/XMPPEXTERNALAuth.m +++ src/XMPPEXTERNALAuth.m @@ -40,11 +40,11 @@ password: nil] autorelease]; } - (OFDataArray*)initialMessage { - OFDataArray *message = [OFDataArray dataArrayWithItemSize: 1]; + OFDataArray *message = [OFDataArray dataArray]; /* authzid */ if (authzid) [message addItem: authzid]; Index: src/XMPPPLAINAuth.m ================================================================== --- src/XMPPPLAINAuth.m +++ src/XMPPPLAINAuth.m @@ -44,11 +44,11 @@ password: password] autorelease]; } - (OFDataArray*)initialMessage { - OFDataArray *message = [OFDataArray dataArrayWithItemSize: 1]; + OFDataArray *message = [OFDataArray dataArray]; /* authzid */ if (authzid) [message addItem: authzid]; Index: src/XMPPPresence.m ================================================================== --- src/XMPPPresence.m +++ src/XMPPPresence.m @@ -79,10 +79,12 @@ - (OFString*)type { if (type == nil) return @"available"; + + return type; } - (void)addShow: (OFString*)show { [self addChild: [OFXMLElement elementWithName: @"show" Index: src/XMPPSCRAMAuth.m ================================================================== --- src/XMPPSCRAMAuth.m +++ src/XMPPSCRAMAuth.m @@ -143,11 +143,11 @@ [old release]; } - (OFDataArray*)initialMessage { - OFDataArray *ret = [OFDataArray dataArrayWithItemSize: 1]; + OFDataArray *ret = [OFDataArray dataArray]; /* New authentication attempt, reset status */ [cNonce release]; cNonce = nil; [GS2Header release]; @@ -213,12 +213,12 @@ GOT_SALT = 0x02, GOT_ITERCOUNT = 0x04 } got = 0; hash = [[[hashType alloc] init] autorelease]; - ret = [OFDataArray dataArrayWithItemSize: 1]; - authMessage = [OFDataArray dataArrayWithItemSize: 1]; + ret = [OFDataArray dataArray]; + authMessage = [OFDataArray dataArray]; OFString *chal = [OFString stringWithUTF8String: [data cArray] length: [data count] * [data itemSize]]; @@ -250,11 +250,11 @@ if (got != (GOT_SNONCE | GOT_SALT | GOT_ITERCOUNT)) @throw [OFInvalidServerReplyException exceptionWithClass: isa]; // Add c= - tmpArray = [OFDataArray dataArrayWithItemSize: 1]; + tmpArray = [OFDataArray dataArray]; [tmpArray addNItems: [GS2Header UTF8StringLength] fromCArray: [GS2Header UTF8String]]; if (plusAvailable && [connection encrypted]) { OFDataArray *channelBinding = [((SSLSocket*)[connection socket]) channelBindingDataWithType: @"tls-unique"]; @@ -276,11 +276,11 @@ /* * IETF RFC 5802: * SaltedPassword := Hi(Normalize(password), salt, i) */ - tmpArray = [OFDataArray dataArrayWithItemSize: 1]; + tmpArray = [OFDataArray dataArray]; [tmpArray addNItems: [password UTF8StringLength] fromCArray: [password UTF8String]]; saltedPassword = [self XMPP_hiWithData: tmpArray salt: salt @@ -303,11 +303,11 @@ /* * IETF RFC 5802: * ClientKey := HMAC(SaltedPassword, "Client Key") */ - tmpArray = [OFDataArray dataArrayWithItemSize: 1]; + tmpArray = [OFDataArray dataArray]; [tmpArray addNItems: 10 fromCArray: "Client Key"]; clientKey = [self XMPP_HMACWithKey: saltedPassword data: tmpArray]; @@ -315,11 +315,11 @@ * IETF RFC 5802: * StoredKey := H(ClientKey) */ [hash updateWithBuffer: (void*) clientKey length: [hashType digestSize]]; - tmpArray = [OFDataArray dataArrayWithItemSize: 1]; + tmpArray = [OFDataArray dataArray]; [tmpArray addNItems: [hashType digestSize] fromCArray: [hash digest]]; /* * IETF RFC 5802: @@ -330,33 +330,33 @@ /* * IETF RFC 5802: * ServerKey := HMAC(SaltedPassword, "Server Key") */ - tmpArray = [OFDataArray dataArrayWithItemSize: 1]; + tmpArray = [OFDataArray dataArray]; [tmpArray addNItems: 10 fromCArray: "Server Key"]; serverKey = [self XMPP_HMACWithKey: saltedPassword data: tmpArray]; /* * IETF RFC 5802: * ServerSignature := HMAC(ServerKey, AuthMessage) */ - tmpArray = [OFDataArray dataArrayWithItemSize: 1]; + tmpArray = [OFDataArray dataArray]; [tmpArray addNItems: [hashType digestSize] fromCArray: serverKey]; - serverSignature = [[OFDataArray alloc] initWithItemSize: 1]; + serverSignature = [[OFDataArray alloc] init]; [serverSignature addNItems: [hashType digestSize] fromCArray: [self XMPP_HMACWithKey: tmpArray data: authMessage]]; /* * IETF RFC 5802: * ClientProof := ClientKey XOR ClientSignature */ - tmpArray = [OFDataArray dataArrayWithItemSize: 1]; + tmpArray = [OFDataArray dataArray]; for (i = 0; i < [hashType digestSize]; i++) { uint8_t c = clientKey[i] ^ clientSignature[i]; [tmpArray addItem: &c]; } @@ -426,11 +426,11 @@ - (uint8_t*)XMPP_HMACWithKey: (OFDataArray*)key data: (OFDataArray*)data { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - OFDataArray *k = [OFDataArray dataArrayWithItemSize: 1]; + OFDataArray *k = [OFDataArray dataArray]; size_t i, kSize, blockSize = [hashType blockSize]; uint8_t *kI = NULL, *kO = NULL; OFHash *hashI, *hashO; if ([key itemSize] * [key count] > blockSize) { @@ -503,11 +503,11 @@ for (j = 0; j < digestSize; j++) result[j] ^= uOld[j]; for (j = 0; j < i - 1; j++) { - tmp = [OFDataArray dataArrayWithItemSize: 1]; + tmp = [OFDataArray dataArray]; [tmp addNItems: digestSize fromCArray: uOld]; u = [self XMPP_HMACWithKey: str data: tmp]; @@ -518,11 +518,11 @@ uOld = u; [pool releaseObjects]; } - ret = [OFDataArray dataArrayWithItemSize: 1]; + ret = [OFDataArray dataArray]; [ret addNItems: digestSize fromCArray: result]; } @finally { [self freeMemory: result]; }