ObjXMPP  Check-in [779fac15b1]

Overview
Comment:Add the XMPPConnection to xmpp_calback_block_t.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 779fac15b13769eb14ea21e69cbcbbf83adb4a7e54424c6bfe05ce14eb4472df
User & Date: js on 2012-02-04 11:52:49
Other Links: manifest | tags
Context
2012-02-04
12:32
Oops, forgot to adjust tests. check-in: 2178192b6f user: js tags: trunk
11:52
Add the XMPPConnection to xmpp_calback_block_t. check-in: 779fac15b1 user: js tags: trunk
2012-02-03
16:26
Add xml:lang support. check-in: 93625a9695 user: js tags: trunk
Changes

Modified src/XMPPCallback.h from [e7183d6d5f] to [40b148c42d].

18
19
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
47


48
18
19
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
47

48
49
50







+



-
+


















-
+
+

 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import <ObjFW/ObjFW.h>

@class XMPPConnection;
@class XMPPIQ;

#ifdef OF_HAVE_BLOCKS
typedef void(^xmpp_callback_block_t)(XMPPIQ*);
typedef void(^xmpp_callback_block_t)(XMPPConnection*, XMPPIQ*);
#endif

@interface XMPPCallback: OFObject
{
	id object;
	SEL selector;
}

#ifdef OF_HAVE_BLOCKS
+ 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;

- (void)runWithIQ: (XMPPIQ*)iq;
- (void)runWithIQ: (XMPPIQ*)iq
       connection: (XMPPConnection*)connection;
@end

Modified src/XMPPCallback.m from [d293755462] to [3b1b31ea2a].

63
64
65
66
67
68
69

70
71
72
73

74
75
76

77
78
79
63
64
65
66
67
68
69
70
71
72
73

74
75
76
77
78
79
80
81







+



-
+



+




- (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)(iq);
		((xmpp_callback_block_t)object)(connection, iq);
	else
#endif
		[object performSelector: selector
			     withObject: connection
			     withObject: iq];
}
@end

Modified src/XMPPConnection.h from [a038cc0172] to [2a2611c59b].

19
20
21
22
23
24
25


26
27
28
29
30
31
32
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34







+
+







 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import <ObjFW/ObjFW.h>

#import "XMPPCallback.h"

@class XMPPConnection;
@class XMPPJID;
@class XMPPIQ;
@class XMPPMessage;
@class XMPPPresence;
@class XMPPAuthenticator;
@class SSLSocket;
297
298
299
300
301
302
303
304

305
306
307
308
309
310
311
299
300
301
302
303
304
305

306
307
308
309
310
311
312
313







-
+







#ifdef OF_HAVE_BLOCKS
/**
 * \brief Sends an XMPPIQ, registering a callback block.
 *
 * \param callback The callback block
 */
-      (void)sendIQ: (XMPPIQ*)iq
  withCallbackBlock: (void(^)(XMPPIQ*))block;
  withCallbackBlock: (xmpp_callback_block_t)block;
#endif

/**
 * \brief Generates a new, unique stanza ID.
 *
 * \return A new, generated, unique stanza ID.
 */

Modified src/XMPPConnection.m from [e6f55ed039] to [a92b5f400a].

784
785
786
787
788
789
790
791


792
793
794
795
796
797
798
784
785
786
787
788
789
790

791
792
793
794
795
796
797
798
799







-
+
+








- (void)XMPP_handleIQ: (XMPPIQ*)iq
{
	BOOL handled = NO;
	XMPPCallback *callback;

	if ((callback = [callbacks objectForKey: [iq ID]])) {
		[callback runWithIQ: iq];
		[callback runWithIQ: iq
			 connection: self];
		[callbacks removeObjectForKey: [iq ID]];
		return;
	}

	handled = [delegates broadcastSelector: @selector(
						    connection:didReceiveIQ:)
				    withObject: self