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 id<XMPPRosterDelegate, XMPPConnectionDelegate> rosterDelegate;
22 connection = [[XMPPConnection alloc] init];
23 [connection addDelegate: self];
25 connection.domain = @"localhost";
26 connection.username = @"alice";
27 connection.password = @"test";
29 ui = [[JubGtkUI alloc] initWithConnection: connection];
30 rosterDelegate = [ui rosterDelegate];
32 [connection addDelegate: rosterDelegate];
34 roster = [[XMPPRoster alloc] initWithConnection: connection];
35 [roster addDelegate: rosterDelegate];
36 [roster addDelegate: self];
38 [connection asyncConnectAndHandle];
43 - (void)connection: (XMPPConnection*)conn_
44 wasBoundToJID: (XMPPJID*)jid
46 of_log(@"Bound to JID: %@", [jid fullJID]);
48 [roster requestRoster];
51 - (void)rosterWasReceived: (XMPPRoster*)roster
53 [connection sendStanza: [XMPPPresence presence]];
56 - (void)connection: (XMPPConnection*)conn
57 didReceiveElement: (OFXMLElement*)element
59 of_log(@"In: %@", element);
62 - (void)connection: (XMPPConnection*)conn
63 didSendElement: (OFXMLElement*)element
65 of_log(@"Out: %@", element);