1 #import <ObjFW/ObjFW.h>
2 #import <ObjXMPP/ObjXMPP.h>
6 @interface AppDelegate: OFObject
7 <OFApplicationDelegate, XMPPConnectionDelegate, XMPPRosterDelegate>
9 XMPPConnection *connection;
15 OF_APPLICATION_DELEGATE(AppDelegate)
17 @implementation AppDelegate
18 - (void)applicationDidFinishLaunching
20 ui = [[JubGtkUI alloc] init];
21 id<XMPPRosterDelegate, XMPPConnectionDelegate> rosterDelegate =
24 connection = [[XMPPConnection alloc] init];
25 [connection addDelegate: self];
27 connection.domain = @"localhost";
28 connection.username = @"alice";
29 connection.password = @"test";
31 [connection asyncConnectAndHandle];
33 [connection addDelegate: rosterDelegate];
35 roster = [[XMPPRoster alloc] initWithConnection: connection];
36 [roster addDelegate: rosterDelegate];
37 [roster addDelegate: self];
42 - (void)connection: (XMPPConnection*)conn_
43 wasBoundToJID: (XMPPJID*)jid
45 of_log(@"Bound to JID: %@", [jid fullJID]);
47 [roster requestRoster];
50 - (void)rosterWasReceived: (XMPPRoster*)roster
52 [connection sendStanza: [XMPPPresence presence]];
55 - (void)connection: (XMPPConnection*)conn
56 didReceiveElement: (OFXMLElement*)element
58 of_log(@"In: %@", element);
61 - (void)connection: (XMPPConnection*)conn
62 didSendElement: (OFXMLElement*)element
64 of_log(@"Out: %@", element);