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>
|
#import <ObjFW/ObjFW.h>
|
||||||
|
|
||||||
|
@class XMPPConnection;
|
||||||
@class XMPPIQ;
|
@class XMPPIQ;
|
||||||
|
|
||||||
#ifdef OF_HAVE_BLOCKS
|
#ifdef OF_HAVE_BLOCKS
|
||||||
typedef void(^xmpp_callback_block_t)(XMPPIQ*);
|
typedef void(^xmpp_callback_block_t)(XMPPConnection*, XMPPIQ*);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@interface XMPPCallback: OFObject
|
@interface XMPPCallback: OFObject
|
||||||
|
@ -44,5 +45,6 @@ typedef void(^xmpp_callback_block_t)(XMPPIQ*);
|
||||||
- initWithCallbackObject: (id)object
|
- initWithCallbackObject: (id)object
|
||||||
selector: (SEL)selector;
|
selector: (SEL)selector;
|
||||||
|
|
||||||
- (void)runWithIQ: (XMPPIQ*)iq;
|
- (void)runWithIQ: (XMPPIQ*)iq
|
||||||
|
connection: (XMPPConnection*)connection;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -67,13 +67,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)runWithIQ: (XMPPIQ*)iq
|
- (void)runWithIQ: (XMPPIQ*)iq
|
||||||
|
connection: (XMPPConnection*)connection
|
||||||
{
|
{
|
||||||
#ifdef OF_HAVE_BLOCKS
|
#ifdef OF_HAVE_BLOCKS
|
||||||
if ([object isKindOfClass: [OFBlock class]])
|
if ([object isKindOfClass: [OFBlock class]])
|
||||||
((xmpp_callback_block_t)object)(iq);
|
((xmpp_callback_block_t)object)(connection, iq);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
[object performSelector: selector
|
[object performSelector: selector
|
||||||
|
withObject: connection
|
||||||
withObject: iq];
|
withObject: iq];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
#import <ObjFW/ObjFW.h>
|
#import <ObjFW/ObjFW.h>
|
||||||
|
|
||||||
|
#import "XMPPCallback.h"
|
||||||
|
|
||||||
@class XMPPConnection;
|
@class XMPPConnection;
|
||||||
@class XMPPJID;
|
@class XMPPJID;
|
||||||
@class XMPPIQ;
|
@class XMPPIQ;
|
||||||
|
@ -301,7 +303,7 @@
|
||||||
* \param callback The callback block
|
* \param callback The callback block
|
||||||
*/
|
*/
|
||||||
- (void)sendIQ: (XMPPIQ*)iq
|
- (void)sendIQ: (XMPPIQ*)iq
|
||||||
withCallbackBlock: (void(^)(XMPPIQ*))block;
|
withCallbackBlock: (xmpp_callback_block_t)block;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -788,7 +788,8 @@
|
||||||
XMPPCallback *callback;
|
XMPPCallback *callback;
|
||||||
|
|
||||||
if ((callback = [callbacks objectForKey: [iq ID]])) {
|
if ((callback = [callbacks objectForKey: [iq ID]])) {
|
||||||
[callback runWithIQ: iq];
|
[callback runWithIQ: iq
|
||||||
|
connection: self];
|
||||||
[callbacks removeObjectForKey: [iq ID]];
|
[callbacks removeObjectForKey: [iq ID]];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue