Make method names more consistent with ObjFW.
This commit is contained in:
parent
89b1f86a4d
commit
00a064a4a5
7 changed files with 66 additions and 54 deletions
|
@ -31,19 +31,22 @@ typedef void(^xmpp_callback_block_t)(XMPPConnection*, XMPPIQ*);
|
||||||
|
|
||||||
@interface XMPPCallback: OFObject
|
@interface XMPPCallback: OFObject
|
||||||
{
|
{
|
||||||
id object;
|
id target;
|
||||||
SEL selector;
|
SEL selector;
|
||||||
|
#ifdef OF_HAVE_BLOCKS
|
||||||
|
xmpp_callback_block_t block;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OF_HAVE_BLOCKS
|
#ifdef OF_HAVE_BLOCKS
|
||||||
+ callbackWithCallbackBlock: (xmpp_callback_block_t)callback;
|
+ callbackWithBlock: (xmpp_callback_block_t)callback;
|
||||||
- initWithCallbackBlock: (xmpp_callback_block_t)callback;
|
- initWithBlock: (xmpp_callback_block_t)callback;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
+ callbackWithCallbackObject: (id)object
|
+ callbackWithTarget: (id)target
|
||||||
selector: (SEL)selector;
|
selector: (SEL)selector;
|
||||||
- initWithCallbackObject: (id)object
|
- initWithTarget: (id)target
|
||||||
selector: (SEL)selector;
|
selector: (SEL)selector;
|
||||||
|
|
||||||
- (void)runWithIQ: (XMPPIQ*)iq
|
- (void)runWithIQ: (XMPPIQ*)iq
|
||||||
connection: (XMPPConnection*)connection;
|
connection: (XMPPConnection*)connection;
|
||||||
|
|
|
@ -28,34 +28,39 @@
|
||||||
|
|
||||||
@implementation XMPPCallback
|
@implementation XMPPCallback
|
||||||
#ifdef OF_HAVE_BLOCKS
|
#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];
|
self = [super init];
|
||||||
|
|
||||||
object = [callback copy];
|
@try {
|
||||||
|
block = [block_ copy];
|
||||||
|
} @catch (id e) {
|
||||||
|
[self release];
|
||||||
|
@throw e;
|
||||||
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
+ callbackWithCallbackObject: (id)object_
|
+ callbackWithTarget: (id)target
|
||||||
selector: (SEL)selector_
|
selector: (SEL)selector
|
||||||
{
|
{
|
||||||
return [[[self alloc] initWithCallbackObject: object_
|
return [[[self alloc] initWithTarget: target
|
||||||
selector: selector_] autorelease];
|
selector: selector] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithCallbackObject: (id)object_
|
- initWithTarget: (id)target_
|
||||||
selector: (SEL)selector_
|
selector: (SEL)selector_
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
object = object_;
|
target = [target_ retain];
|
||||||
selector = selector_;
|
selector = selector_;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -63,6 +68,11 @@
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
|
[target release];
|
||||||
|
#ifdef OF_HAVE_BLOCKS
|
||||||
|
[block release];
|
||||||
|
#endif
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,11 +80,11 @@
|
||||||
connection: (XMPPConnection*)connection
|
connection: (XMPPConnection*)connection
|
||||||
{
|
{
|
||||||
#ifdef OF_HAVE_BLOCKS
|
#ifdef OF_HAVE_BLOCKS
|
||||||
if ([object isKindOfClass: [OFBlock class]])
|
if (block != NULL)
|
||||||
((xmpp_callback_block_t)object)(connection, iq);
|
block(connection, iq);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
[object performSelector: selector
|
[target performSelector: selector
|
||||||
withObject: connection
|
withObject: connection
|
||||||
withObject: iq];
|
withObject: iq];
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,9 +315,9 @@
|
||||||
* \param selector The selector of the callback method,
|
* \param selector The selector of the callback method,
|
||||||
* must take exactly one parameter of type XMPPIQ*
|
* must take exactly one parameter of type XMPPIQ*
|
||||||
*/
|
*/
|
||||||
- (void)sendIQ: (XMPPIQ*)iq
|
- (void)sendIQ: (XMPPIQ*)iq
|
||||||
withCallbackObject: (id)object
|
callbackTarget: (id)target
|
||||||
selector: (SEL)selector;
|
selector: (SEL)selector;
|
||||||
|
|
||||||
#ifdef OF_HAVE_BLOCKS
|
#ifdef OF_HAVE_BLOCKS
|
||||||
/**
|
/**
|
||||||
|
@ -325,8 +325,8 @@
|
||||||
*
|
*
|
||||||
* \param callback The callback block
|
* \param callback The callback block
|
||||||
*/
|
*/
|
||||||
- (void)sendIQ: (XMPPIQ*)iq
|
- (void)sendIQ: (XMPPIQ*)iq
|
||||||
withCallbackBlock: (xmpp_callback_block_t)block;
|
callbackBlock: (xmpp_callback_block_t)block;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -370,10 +370,10 @@
|
||||||
- (void)XMPP_handlePresence: (XMPPPresence*)presence;
|
- (void)XMPP_handlePresence: (XMPPPresence*)presence;
|
||||||
- (void)XMPP_handleFeatures: (OFXMLElement*)element;
|
- (void)XMPP_handleFeatures: (OFXMLElement*)element;
|
||||||
- (void)XMPP_handleResourceBindForConnection: (XMPPConnection*)connection
|
- (void)XMPP_handleResourceBindForConnection: (XMPPConnection*)connection
|
||||||
withIQ: (XMPPIQ*)iq;
|
IQ: (XMPPIQ*)iq;
|
||||||
- (void)XMPP_sendSession;
|
- (void)XMPP_sendSession;
|
||||||
- (void)XMPP_handleSessionForConnection: (XMPPConnection*)connection
|
- (void)XMPP_handleSessionForConnection: (XMPPConnection*)connection
|
||||||
withIQ: (XMPPIQ*)iq;
|
IQ: (XMPPIQ*)iq;
|
||||||
- (OFString*)XMPP_IDNAToASCII: (OFString*)domain;
|
- (OFString*)XMPP_IDNAToASCII: (OFString*)domain;
|
||||||
- (XMPPMulticastDelegate*)XMPP_delegates;
|
- (XMPPMulticastDelegate*)XMPP_delegates;
|
||||||
/// \endcond
|
/// \endcond
|
||||||
|
|
|
@ -469,9 +469,9 @@
|
||||||
[sock writeString: [element XMLString]];
|
[sock writeString: [element XMLString]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)sendIQ: (XMPPIQ*)iq
|
- (void)sendIQ: (XMPPIQ*)iq
|
||||||
withCallbackObject: (id)object
|
callbackTarget: (id)target
|
||||||
selector: (SEL)selector
|
selector: (SEL)selector
|
||||||
{
|
{
|
||||||
OFAutoreleasePool *pool;
|
OFAutoreleasePool *pool;
|
||||||
XMPPCallback *callback;
|
XMPPCallback *callback;
|
||||||
|
@ -480,8 +480,8 @@
|
||||||
[iq setID: [self generateStanzaID]];
|
[iq setID: [self generateStanzaID]];
|
||||||
|
|
||||||
pool = [[OFAutoreleasePool alloc] init];
|
pool = [[OFAutoreleasePool alloc] init];
|
||||||
callback = [XMPPCallback callbackWithCallbackObject: object
|
callback = [XMPPCallback callbackWithTarget: target
|
||||||
selector: selector];
|
selector: selector];
|
||||||
[callbacks setObject: callback
|
[callbacks setObject: callback
|
||||||
forKey: [iq ID]];
|
forKey: [iq ID]];
|
||||||
[pool release];
|
[pool release];
|
||||||
|
@ -490,8 +490,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OF_HAVE_BLOCKS
|
#ifdef OF_HAVE_BLOCKS
|
||||||
- (void)sendIQ: (XMPPIQ*)iq
|
- (void)sendIQ: (XMPPIQ*)iq
|
||||||
withCallbackBlock: (xmpp_callback_block_t)block;
|
callbackBlock: (xmpp_callback_block_t)block
|
||||||
{
|
{
|
||||||
OFAutoreleasePool *pool;
|
OFAutoreleasePool *pool;
|
||||||
XMPPCallback *callback;
|
XMPPCallback *callback;
|
||||||
|
@ -500,7 +500,7 @@
|
||||||
[iq setID: [self generateStanzaID]];
|
[iq setID: [self generateStanzaID]];
|
||||||
|
|
||||||
pool = [[OFAutoreleasePool alloc] init];
|
pool = [[OFAutoreleasePool alloc] init];
|
||||||
callback = [XMPPCallback callbackWithCallbackBlock: block];
|
callback = [XMPPCallback callbackWithBlock: block];
|
||||||
[callbacks setObject: callback
|
[callbacks setObject: callback
|
||||||
forKey: [iq ID]];
|
forKey: [iq ID]];
|
||||||
[pool release];
|
[pool release];
|
||||||
|
@ -1038,10 +1038,10 @@
|
||||||
|
|
||||||
[iq addChild: bind];
|
[iq addChild: bind];
|
||||||
|
|
||||||
[self sendIQ: iq
|
[self sendIQ: iq
|
||||||
withCallbackObject: self
|
callbackTarget: self
|
||||||
selector: @selector(XMPP_handleResourceBindForConnection:
|
selector: @selector(XMPP_handleResourceBindForConnection:
|
||||||
withIQ:)];
|
IQ:)];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_sendStreamError: (OFString*)condition
|
- (void)XMPP_sendStreamError: (OFString*)condition
|
||||||
|
@ -1065,7 +1065,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_handleResourceBindForConnection: (XMPPConnection*)connection
|
- (void)XMPP_handleResourceBindForConnection: (XMPPConnection*)connection
|
||||||
withIQ: (XMPPIQ*)iq
|
IQ: (XMPPIQ*)iq
|
||||||
{
|
{
|
||||||
OFXMLElement *bindElement;
|
OFXMLElement *bindElement;
|
||||||
OFXMLElement *jidElement;
|
OFXMLElement *jidElement;
|
||||||
|
@ -1099,14 +1099,13 @@
|
||||||
ID: [self generateStanzaID]];
|
ID: [self generateStanzaID]];
|
||||||
[iq addChild: [OFXMLElement elementWithName: @"session"
|
[iq addChild: [OFXMLElement elementWithName: @"session"
|
||||||
namespace: XMPP_NS_SESSION]];
|
namespace: XMPP_NS_SESSION]];
|
||||||
[self sendIQ: iq
|
[self sendIQ: iq
|
||||||
withCallbackObject: self
|
callbackTarget: self
|
||||||
selector: @selector(
|
selector: @selector(XMPP_handleSessionForConnection:IQ:)];
|
||||||
XMPP_handleSessionForConnection:withIQ:)];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_handleSessionForConnection: (XMPPConnection*)connection
|
- (void)XMPP_handleSessionForConnection: (XMPPConnection*)connection
|
||||||
withIQ: (XMPPIQ*)iq
|
IQ: (XMPPIQ*)iq
|
||||||
{
|
{
|
||||||
if (![[iq type] isEqual: @"result"])
|
if (![[iq type] isEqual: @"result"])
|
||||||
assert(0);
|
assert(0);
|
||||||
|
|
|
@ -156,7 +156,7 @@
|
||||||
/// \cond internal
|
/// \cond internal
|
||||||
- (void)XMPP_updateRosterItem: (XMPPRosterItem*)rosterItem;
|
- (void)XMPP_updateRosterItem: (XMPPRosterItem*)rosterItem;
|
||||||
- (void)XMPP_handleInitialRosterForConnection: (XMPPConnection*)connection
|
- (void)XMPP_handleInitialRosterForConnection: (XMPPConnection*)connection
|
||||||
withIQ: (XMPPIQ*)iq;
|
IQ: (XMPPIQ*)iq;
|
||||||
- (XMPPRosterItem*)XMPP_rosterItemWithXMLElement: (OFXMLElement*)element;
|
- (XMPPRosterItem*)XMPP_rosterItemWithXMLElement: (OFXMLElement*)element;
|
||||||
/// \endcond
|
/// \endcond
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -97,10 +97,10 @@
|
||||||
|
|
||||||
[iq addChild: query];
|
[iq addChild: query];
|
||||||
|
|
||||||
[connection sendIQ: iq
|
[connection sendIQ: iq
|
||||||
withCallbackObject: self
|
callbackTarget: self
|
||||||
selector: @selector(XMPP_handleInitialRosterForConnection:
|
selector: @selector(XMPP_handleInitialRosterForConnection:
|
||||||
withIQ:)];
|
IQ:)];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)connection: (XMPPConnection*)connection_
|
- (BOOL)connection: (XMPPConnection*)connection_
|
||||||
|
@ -306,7 +306,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_handleInitialRosterForConnection: (XMPPConnection*)connection_
|
- (void)XMPP_handleInitialRosterForConnection: (XMPPConnection*)connection_
|
||||||
withIQ: (XMPPIQ*)iq
|
IQ: (XMPPIQ*)iq
|
||||||
{
|
{
|
||||||
OFXMLElement *rosterElement;
|
OFXMLElement *rosterElement;
|
||||||
OFEnumerator *enumerator;
|
OFEnumerator *enumerator;
|
||||||
|
|
|
@ -169,8 +169,8 @@ OF_APPLICATION_DELEGATE(AppDelegate)
|
||||||
ID: [conn generateStanzaID]];
|
ID: [conn generateStanzaID]];
|
||||||
[iq addChild: [OFXMLElement elementWithName: @"ping"
|
[iq addChild: [OFXMLElement elementWithName: @"ping"
|
||||||
namespace: @"urn:xmpp:ping"]];
|
namespace: @"urn:xmpp:ping"]];
|
||||||
[conn sendIQ: iq
|
[conn sendIQ: iq
|
||||||
withCallbackBlock: ^ (XMPPConnection *c, XMPPIQ *resp) {
|
callbackBlock: ^ (XMPPConnection *c, XMPPIQ *resp) {
|
||||||
of_log(@"Ping response: %@", resp);
|
of_log(@"Ping response: %@", resp);
|
||||||
}];
|
}];
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue