Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add the XMPPConnection to xmpp_calback_block_t.

  • Loading branch information...
commit 39e245987c44d38044333f96c69c4c71f166a081 1 parent 6ddf416
@Midar authored
View
6 src/XMPPCallback.h
@@ -22,10 +22,11 @@
#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
@@ -44,5 +45,6 @@ typedef void(^xmpp_callback_block_t)(XMPPIQ*);
- initWithCallbackObject: (id)object
selector: (SEL)selector;
-- (void)runWithIQ: (XMPPIQ*)iq;
+- (void)runWithIQ: (XMPPIQ*)iq
+ connection: (XMPPConnection*)connection;
@end
View
4 src/XMPPCallback.m
@@ -67,13 +67,15 @@ - (void)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
View
4 src/XMPPConnection.h
@@ -23,6 +23,8 @@
#import <ObjFW/ObjFW.h>
+#import "XMPPCallback.h"
+
@class XMPPConnection;
@class XMPPJID;
@class XMPPIQ;
@@ -301,7 +303,7 @@
* \param callback The callback block
*/
- (void)sendIQ: (XMPPIQ*)iq
- withCallbackBlock: (void(^)(XMPPIQ*))block;
+ withCallbackBlock: (xmpp_callback_block_t)block;
#endif
/**
View
3  src/XMPPConnection.m
@@ -788,7 +788,8 @@ - (void)XMPP_handleIQ: (XMPPIQ*)iq
XMPPCallback *callback;
if ((callback = [callbacks objectForKey: [iq ID]])) {
- [callback runWithIQ: iq];
+ [callback runWithIQ: iq
+ connection: self];
[callbacks removeObjectForKey: [iq ID]];
return;
}
Please sign in to comment.
Something went wrong with that request. Please try again.