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];
39 [_client.connection asyncConnectAndHandle];
44 - (void)connection: (XMPPConnection*)connection
45 didReceiveElement: (OFXMLElement*)element
47 of_log(@"In: %@", element);
50 - (void)connection: (XMPPConnection*)connection
51 didSendElement: (OFXMLElement*)element
53 of_log(@"Out: %@", element);
56 - (void)connection: (XMPPConnection*)connection
57 didThrowException: (id)e