]> git.babelmonkeys.de Git - mpdbot.git/commitdiff
Use new callback API of objXMPP
authorFlorian Zeitz <florob@babelmonkeys.de>
Thu, 5 Jul 2012 21:16:36 +0000 (23:16 +0200)
committerFlorian Zeitz <florob@babelmonkeys.de>
Thu, 5 Jul 2012 21:16:36 +0000 (23:16 +0200)
src/mpdbot.m

index ac113f57783e6dec97e17f726129c0201392fb74..eb92876880af712e30f7ee333ce276ed681dea54 100644 (file)
@@ -30,8 +30,7 @@
 
 @interface AppDelegate: OFObject <OFApplicationDelegate, XMPPConnectionDelegate>
 {
-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;
 }