ObjXMPP  Diff

Differences From Artifact [c6e609221e]:

To Artifact [2e45d71ec9]:


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
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
+ callbackWithCallbackBlock: (xmpp_callback_block_t)callback
+ callbackWithBlock: (xmpp_callback_block_t)block
{
	return [[[self alloc] initWithCallbackBlock: callback] autorelease];
	return [[(XMPPCallback*)[self alloc] initWithBlock: block] autorelease];
}

- initWithCallbackBlock: (xmpp_callback_block_t)callback
- initWithBlock: (xmpp_callback_block_t)block_
{
	self = [super init];

	@try {
	object = [callback copy];
		block = [block_ copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}
#endif

+ callbackWithCallbackObject: (id)object_
		    selector: (SEL)selector_
+ callbackWithTarget: (id)target
	    selector: (SEL)selector
{
	return [[[self alloc] initWithCallbackObject: object_
					    selector: selector_] autorelease];
	return [[[self alloc] initWithTarget: target
				    selector: selector] autorelease];
}

- initWithCallbackObject: (id)object_
		selector: (SEL)selector_
- initWithTarget: (id)target_
	selector: (SEL)selector_
{
	self = [super init];

	object = object_;
	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 ([object isKindOfClass: [OFBlock class]])
		((xmpp_callback_block_t)object)(connection, iq);
	if (block != NULL)
		block(connection, iq);
	else
#endif
		[object performSelector: selector
		[target performSelector: selector
			     withObject: connection
			     withObject: iq];
}
@end