Add the XMPPConnection to xmpp_calback_block_t.
This commit is contained in:
parent
6ddf416e50
commit
39e245987c
4 changed files with 12 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -67,13 +67,15 @@
|
|||
}
|
||||
|
||||
- (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
|
||||
|
|
|
@ -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
|
||||
|
||||
/**
|
||||
|
|
|
@ -788,7 +788,8 @@
|
|||
XMPPCallback *callback;
|
||||
|
||||
if ((callback = [callbacks objectForKey: [iq ID]])) {
|
||||
[callback runWithIQ: iq];
|
||||
[callback runWithIQ: iq
|
||||
connection: self];
|
||||
[callbacks removeObjectForKey: [iq ID]];
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue