Overview
Comment: | Merge XMPP*Callback into a single class |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
0b4222d5e49daa2f77fb0cc3c43f0257 |
User & Date: | florob@babelmonkeys.de on 2012-01-06 19:18:33 |
Other Links: | manifest | tags |
Context
2012-01-16
| ||
22:31 | Reorder headers to avoid dependency issues (required for NetBSD) check-in: b684cb87bf user: florob@babelmonkeys.de tags: trunk | |
2012-01-06
| ||
19:18 | Merge XMPP*Callback into a single class check-in: 0b4222d5e4 user: florob@babelmonkeys.de tags: trunk | |
2012-01-04
| ||
22:25 | Use OF_SETTER/OF_GETTER. check-in: 220daa147d user: js tags: trunk | |
Changes
Modified src/XMPPCallback.h from [9b4ffbc375] to [d3b2ead060].
︙ | ︙ | |||
20 21 22 23 24 25 26 | * POSSIBILITY OF SUCH DAMAGE. */ #import <ObjFW/ObjFW.h> @class XMPPIQ; | < < < < < < < < < < < < | > > > > > > | 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 | * POSSIBILITY OF SUCH DAMAGE. */ #import <ObjFW/ObjFW.h> @class XMPPIQ; #ifdef OF_HAVE_BLOCKS typedef void(^xmpp_callback_block)(XMPPIQ*); #endif @interface XMPPCallback: OFObject { id object; SEL selector; } #ifdef OF_HAVE_BLOCKS + callbackWithCallbackBlock: (xmpp_callback_block)callback; - initWithCallbackBlock: (xmpp_callback_block)callback; #endif + callbackWithCallbackObject: (id)object selector: (SEL)selector; - initWithCallbackObject: (id)object selector: (SEL)selector; - (void)runWithIQ: (XMPPIQ*)iq; @end |
Modified src/XMPPCallback.m from [2b6add7aa0] to [00c028907e].
︙ | ︙ | |||
22 23 24 25 26 27 28 29 | #ifdef HAVE_CONFIG_H # include "config.h" #endif #import "XMPPCallback.h" #ifdef OF_HAVE_BLOCKS | > < | | | | < < < < < < < < < < < < < < | 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 | #ifdef HAVE_CONFIG_H # include "config.h" #endif #import "XMPPCallback.h" @implementation XMPPCallback #ifdef OF_HAVE_BLOCKS + callbackWithCallbackBlock: (xmpp_callback_block)callback { return [[[self alloc] initWithCallbackBlock: callback] autorelease]; } - initWithCallbackBlock: (xmpp_callback_block)callback { self = [super init]; object = [callback copy]; return self; } #endif + callbackWithCallbackObject: (id)object_ selector: (SEL)selector_ { return [[[self alloc] initWithCallbackObject: object_ selector: selector_] autorelease]; } |
︙ | ︙ | |||
81 82 83 84 85 86 87 | [object release]; [super dealloc]; } - (void)runWithIQ: (XMPPIQ*)iq { | > > > > > | | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | [object release]; [super dealloc]; } - (void)runWithIQ: (XMPPIQ*)iq { #ifdef OF_HAVE_BLOCKS if ([object isKindOfClass: [OFBlock class]]) ((xmpp_callback_block)object)(iq); else #endif [object performSelector: selector withObject: iq]; } @end |
Modified src/XMPPConnection.m from [e52bbff4d6] to [e3b662d70c].
︙ | ︙ | |||
358 359 360 361 362 363 364 | selector: (SEL)selector { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; @try { if (![iq ID]) [iq setID: [self generateStanzaID]]; | | | | 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | selector: (SEL)selector { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; @try { if (![iq ID]) [iq setID: [self generateStanzaID]]; [callbacks setObject: [XMPPCallback callbackWithCallbackObject: object selector: selector] forKey: [iq ID]]; } @finally { [pool release]; } [self sendStanza: iq]; } #ifdef OF_HAVE_BLOCKS - (void)sendIQ: (XMPPIQ*)iq withCallbackBlock: (xmpp_callback_block)callback; { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; @try { if (![iq ID]) [iq setID: [self generateStanzaID]]; [callbacks setObject: [XMPPCallback callbackWithCallbackBlock: callback] forKey: [iq ID]]; } @finally { [pool release]; } [self sendStanza: iq]; |
︙ | ︙ | |||
693 694 695 696 697 698 699 | assert(0); } - (void)XMPP_handleIQ: (XMPPIQ*)iq { BOOL handled = NO; | | | 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 | assert(0); } - (void)XMPP_handleIQ: (XMPPIQ*)iq { BOOL handled = NO; XMPPCallback *callback; if ((callback = [callbacks objectForKey: [iq ID]])) { [callback runWithIQ: iq]; [callbacks removeObjectForKey: [iq ID]]; return; } |
︙ | ︙ |
Modified tests/test.m from [cf687a7428] to [2ccadc96fb].
︙ | ︙ | |||
143 144 145 146 147 148 149 150 151 152 153 154 155 156 | of_log(@"Got roster: %@", [[conn roster] rosterItems]); pres = [XMPPPresence presence]; [pres addPriority: 10]; [pres addStatus: @"ObjXMPP test is working!"]; [conn sendStanza: pres]; } - (void)connectionDidUpgradeToTLS: (XMPPConnection*)conn { @try { [conn checkCertificate]; } @catch (SSLInvalidCertificateException *e) { | > > > > > > > > > > > | 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 | of_log(@"Got roster: %@", [[conn roster] rosterItems]); pres = [XMPPPresence presence]; [pres addPriority: 10]; [pres addStatus: @"ObjXMPP test is working!"]; [conn sendStanza: pres]; #ifdef OF_HAVE_BLOCKS XMPPIQ *iq = [XMPPIQ IQWithType: @"get" ID: [conn generateStanzaID]]; [iq addChild: [OFXMLElement elementWithName: @"ping" namespace: @"urn:xmpp:ping"]]; [conn sendIQ: iq withCallbackBlock: ^(XMPPIQ* resp) { of_log(@"Ping response: %@", resp); }]; #endif } - (void)connectionDidUpgradeToTLS: (XMPPConnection*)conn { @try { [conn checkCertificate]; } @catch (SSLInvalidCertificateException *e) { |
︙ | ︙ |