X-Git-Url: http://cgit.babelmonkeys.de/?p=mpdbot.git;a=blobdiff_plain;f=src%2Fmpdbot.m;h=1c7ab7d4ac18cdcee606e4230ada7da49953cd92;hp=ea84079c19eaf7591280e762e886d11744f7ae24;hb=c8832bee918f82cb58fc7cf097a0c2cc9fe491bf;hpb=58c9d40544119cc2f5861b9c68b4744d08735012 diff --git a/src/mpdbot.m b/src/mpdbot.m index ea84079..1c7ab7d 100644 --- a/src/mpdbot.m +++ b/src/mpdbot.m @@ -2,7 +2,7 @@ * Copyright (c) 2010, 2011, Jonathan Schleifer * Copyright (c) 2011, Florian Zeitz * - * https://webkeks.org/hg/objxmpp/ + * http://cgit.babelmonkeys.de/cgit.cgi/mpdbot/ * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -21,8 +21,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include - #import #import @@ -51,7 +49,8 @@ OF_APPLICATION_DELEGATE(AppDelegate) [conn setDelegate: self]; if ([arguments count] != 3) { - of_log(@"Invalid count of command line arguments!"); + [of_stdout writeFormat: @"Usage: %@ \n", + [OFApplication programName]]; [OFApplication terminateWithStatus: 1]; } @@ -70,7 +69,7 @@ OF_APPLICATION_DELEGATE(AppDelegate) - (void)connectionWasAuthenticated: (XMPPConnection*)conn { - of_log(@"Auth successful"); + [of_stdout writeLine: @"Auth successful"]; } - (void)connection: (XMPPConnection*)conn @@ -79,7 +78,7 @@ OF_APPLICATION_DELEGATE(AppDelegate) XMPPPresence *pres; XMPPIQ *disco; - of_log(@"Bound to JID: %@", [jid fullJID]); + [of_stdout writeFormat: @"Bound to JID: %@\n", [jid fullJID]]; pres = [XMPPPresence presence]; [pres addPriority: 0]; @@ -130,11 +129,17 @@ OF_APPLICATION_DELEGATE(AppDelegate) - (void)connection: (XMPPConnection*)conn didReceivePresence: (XMPPPresence*)pres { - of_log(@"Presence: %@", pres); + if ([pres.type isEqual: @"subscribe"]) { + XMPPPresence *answer; + answer = [XMPPPresence presenceWithType: @"subscribed" + ID: pres.ID]; + answer.to = [XMPPJID JIDWithString: [pres.from bareJID]]; + [conn sendStanza: answer]; + } } - (void)connectionWasClosed: (XMPPConnection*)conn { - of_log(@"Connection was closed!"); + [of_stdout writeLine: @"Connection was closed!"]; } @end