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";
32 [connection handleConnection];
34 [connection addDelegate: rosterDelegate];
36 roster = [[XMPPRoster alloc] initWithConnection: connection];
37 [roster addDelegate: rosterDelegate];
38 [roster addDelegate: self];
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);