1 #import <ObjFW/ObjFW.h>
2 #import <ObjXMPP/ObjXMPP.h>
7 #import "JubChatClient.h"
9 @interface AppDelegate: OFObject <OFApplicationDelegate, XMPPConnectionDelegate>
11 JubChatClient *_client;
16 OF_APPLICATION_DELEGATE(AppDelegate)
18 @implementation AppDelegate
19 - (void)applicationDidFinishLaunching
21 JubConfig *config = [[[JubConfig alloc] initWithFile: @"config.xml"]
24 _client = [[JubChatClient alloc] initWithConfig: config];
26 if ([config.frontend isEqual: @"gtk"])
27 _ui = [[JubGtkUI alloc] initWithClient: _client];
28 else if ([config.frontend isEqual: @"cli"])
29 _ui = [[JubCLIUI alloc] initWithClient: _client];
31 [of_stderr writeFormat: @"Unknown frontend '%@', known "
32 @"frontends are 'gtk' and 'cli'\n", config.frontend];
33 [OFApplication terminate];
37 [_client.connection addDelegate: self];
40 [_client.connection asyncConnectAndHandle];
43 - (void)connection: (XMPPConnection*)connection
44 didReceiveElement: (OFXMLElement*)element
46 of_log(@"In: %@", element);
49 - (void)connection: (XMPPConnection*)connection
50 didSendElement: (OFXMLElement*)element
52 of_log(@"Out: %@", element);
55 - (void)connection: (XMPPConnection*)connection
56 didThrowException: (id)e