1 #import <ObjFW/ObjFW.h>
2 #import <ObjXMPP/ObjXMPP.h>
7 @interface AppDelegate: OFObject
8 <OFApplicationDelegate, XMPPConnectionDelegate, XMPPRosterDelegate>
10 XMPPConnection *connection;
16 OF_APPLICATION_DELEGATE(AppDelegate)
18 @implementation AppDelegate
19 - (void)applicationDidFinishLaunching
21 id<XMPPRosterDelegate, XMPPConnectionDelegate> rosterDelegate;
22 JubConfig *config = [[JubConfig alloc] initWithFile: @"config.xml"];
24 connection = [[XMPPConnection alloc] init];
25 [connection addDelegate: self];
27 connection.domain = config.domain;
28 connection.server = config.server;
29 connection.username = config.username;
30 connection.password = config.password;
32 ui = [[JubGtkUI alloc] initWithConnection: connection];
33 rosterDelegate = [ui rosterDelegate];
35 [connection addDelegate: rosterDelegate];
37 roster = [[XMPPRoster alloc] initWithConnection: connection];
38 [roster addDelegate: rosterDelegate];
39 [roster addDelegate: self];
41 [connection asyncConnectAndHandle];
46 - (void)connection: (XMPPConnection*)conn_
47 wasBoundToJID: (XMPPJID*)jid
49 of_log(@"Bound to JID: %@", [jid fullJID]);
51 [roster requestRoster];
54 - (void)rosterWasReceived: (XMPPRoster*)roster
56 [connection sendStanza: [XMPPPresence presence]];
59 - (void)connection: (XMPPConnection*)conn
60 didReceiveElement: (OFXMLElement*)element
62 of_log(@"In: %@", element);
65 - (void)connection: (XMPPConnection*)conn
66 didSendElement: (OFXMLElement*)element
68 of_log(@"Out: %@", element);