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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
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
@implementation XMPPBlockCallback
+ callbackWithCallbackBlock: (xmpp_callback_block)callback_
+ callbackWithCallbackBlock: (xmpp_callback_block)callback
{
return [[[self alloc] initWithCallbackBlock: callback_] autorelease];
return [[[self alloc] initWithCallbackBlock: callback] autorelease];
}
- initWithCallbackBlock: (xmpp_callback_block)callback_
- initWithCallbackBlock: (xmpp_callback_block)callback
{
self = [super init];
callback = [callback_ copy];
object = [callback copy];
return self;
}
- (void)dealloc
{
[callback release];
[super dealloc];
}
- (void)runWithIQ: (XMPPIQ*)iq
{
callback(iq);
}
@end
#endif
@implementation XMPPObjectCallback
+ callbackWithCallbackObject: (id)object_
selector: (SEL)selector_
{
return [[[self alloc] initWithCallbackObject: object_
selector: selector_] autorelease];
}
|
81
82
83
84
85
86
87
88
89
90
91
|
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];
[object performSelector: selector
withObject: iq];
}
@end
|