From: Florian Zeitz Date: Thu, 5 Jul 2012 21:16:36 +0000 (+0200) Subject: Use new callback API of objXMPP X-Git-Url: https://cgit.babelmonkeys.de/?a=commitdiff_plain;h=fb736d0ba5442efc5a592aa5389f2ac3280b755b;p=mpdbot.git Use new callback API of objXMPP --- diff --git a/src/mpdbot.m b/src/mpdbot.m index ac113f5..eb92876 100644 --- a/src/mpdbot.m +++ b/src/mpdbot.m @@ -30,8 +30,7 @@ @interface AppDelegate: OFObject { -OFString *discoID; -PEPThread *pepper; + PEPThread *pepper; } @end @@ -75,6 +74,7 @@ OF_APPLICATION_DELEGATE(AppDelegate) { XMPPPresence *pres; XMPPIQ *disco; + OFString *discoID; [of_stdout writeFormat: @"Bound to JID: %@\n", [jid fullJID]]; @@ -91,31 +91,30 @@ OF_APPLICATION_DELEGATE(AppDelegate) elementWithName: @"query" namespace: NS_DISCO_INFO]]; - [conn sendStanza: disco]; + [conn sendIQ: disco + withCallbackObject: self + selector: @selector(mpdbot_handleDiscoForConnection:withIQ:)]; } -- (BOOL)connection: (XMPPConnection*)conn - didReceiveIQ: (XMPPIQ*)iq +- (BOOL)mpdbot_handleDiscoForConnection: (XMPPConnection*)conn + withIQ: (XMPPIQ*)iq { OFXMLElement *query = [iq elementForName: @"query" namespace: NS_DISCO_INFO]; - if ([iq.ID isEqual: discoID]) { - for (OFXMLElement *identity - in [query elementsForName: @"identity" - namespace: NS_DISCO_INFO]) { - if ([[[identity attributeForName: @"category"] - stringValue] isEqual: @"pubsub"] && - [[[identity attributeForName: @"type"] stringValue] - isEqual: @"pep"]) { - pepper = [[PEPThread alloc] - initWithObject: conn]; - [pepper start]; - - return YES; - } + for (OFXMLElement *identity in [query elementsForName: @"identity" + namespace: NS_DISCO_INFO]) { + if ([[[identity attributeForName: @"category"] + stringValue] isEqual: @"pubsub"] && + [[[identity attributeForName: @"type"] stringValue] + isEqual: @"pep"]) { + pepper = [[PEPThread alloc] + initWithObject: conn]; + [pepper start]; + + return YES; } - [of_stderr writeLine: @"Server does NOT support PEP"]; } + [of_stderr writeLine: @"Server does NOT support PEP"]; return NO; }