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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# include "config.h"
#endif
#import "XMPPCallback.h"
@implementation XMPPCallback
#ifdef OF_HAVE_BLOCKS
+ callbackWithCallbackBlock: (xmpp_callback_block_t)callback
{
return [[[self alloc] initWithCallbackBlock: callback] autorelease];
}
- initWithCallbackBlock: (xmpp_callback_block_t)callback
{
self = [super init];
object = [callback copy];
return self;
}
#endif
+ callbackWithCallbackObject: (id)object_
selector: (SEL)selector_
{
return [[[self alloc] initWithCallbackObject: object_
selector: selector_] autorelease];
}
- initWithCallbackObject: (id)object_
selector: (SEL)selector_
{
self = [super init];
object = object_;
selector = selector_;
return self;
}
- (void)dealloc
{
[super dealloc];
}
- (void)runWithIQ: (XMPPIQ*)iq
connection: (XMPPConnection*)connection
{
#ifdef OF_HAVE_BLOCKS
if ([object isKindOfClass: [OFBlock class]])
((xmpp_callback_block_t)object)(connection, iq);
else
#endif
[object performSelector: selector
withObject: connection
withObject: iq];
}
@end
|
|
|
|
>
|
>
>
>
>
|
|
|
|
|
|
|
>
>
>
>
>
|
|
|
|
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# include "config.h"
#endif
#import "XMPPCallback.h"
@implementation XMPPCallback
#ifdef OF_HAVE_BLOCKS
+ callbackWithBlock: (xmpp_callback_block_t)block
{
return [[(XMPPCallback*)[self alloc] initWithBlock: block] autorelease];
}
- initWithBlock: (xmpp_callback_block_t)block_
{
self = [super init];
@try {
block = [block_ copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
#endif
+ callbackWithTarget: (id)target
selector: (SEL)selector
{
return [[[self alloc] initWithTarget: target
selector: selector] autorelease];
}
- initWithTarget: (id)target_
selector: (SEL)selector_
{
self = [super init];
target = [target_ retain];
selector = selector_;
return self;
}
- (void)dealloc
{
[target release];
#ifdef OF_HAVE_BLOCKS
[block release];
#endif
[super dealloc];
}
- (void)runWithIQ: (XMPPIQ*)iq
connection: (XMPPConnection*)connection
{
#ifdef OF_HAVE_BLOCKS
if (block != NULL)
block(connection, iq);
else
#endif
[target performSelector: selector
withObject: connection
withObject: iq];
}
@end
|