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];
22 connection = [[XMPPConnection alloc] init];
23 [connection addDelegate: self];
25 connection.domain = @"localhost";
26 connection.username = @"alice";
27 connection.password = @"test";
30 [connection handleConnection];
32 [connection addDelegate: [ui rosterDelegate]];
34 roster = [[XMPPRoster alloc] initWithConnection: connection];
35 [roster addDelegate: [ui rosterDelegate]];
36 [roster addDelegate: self];
41 - (void)connection: (XMPPConnection*)conn_
42 wasBoundToJID: (XMPPJID*)jid
44 of_log(@"Bound to JID: %@", [jid fullJID]);
46 [roster requestRoster];
49 - (void)rosterWasReceived: (XMPPRoster*)roster
51 [connection sendStanza: [XMPPPresence presence]];
54 - (void)connection: (XMPPConnection*)conn
55 didReceiveElement: (OFXMLElement*)element
57 of_log(@"In: %@", element);
60 - (void)connection: (XMPPConnection*)conn
61 didSendElement: (OFXMLElement*)element
63 of_log(@"Out: %@", element);