]> cgit.babelmonkeys.de Git - jubjub.git/blob - src/core/main.m
229e6c5aa502fe2624725beaaa08d9709d14d24a
[jubjub.git] / src / core / main.m
1 #import <ObjFW/ObjFW.h>
2 #import <ObjXMPP/ObjXMPP.h>
3
4 #import "JubGtkUI.h"
5 #import "JubConfig.h"
6 #import "JubChatClient.h"
7
8 @interface AppDelegate: OFObject <OFApplicationDelegate, XMPPConnectionDelegate>
9 {
10         JubChatClient *client;
11         id<JubUI> ui;
12 }
13 @end
14
15 OF_APPLICATION_DELEGATE(AppDelegate)
16
17 @implementation AppDelegate
18 - (void)applicationDidFinishLaunching
19 {
20         JubConfig *config = [[[JubConfig alloc] initWithFile: @"config.xml"]
21             autorelease];
22
23         client = [[JubChatClient alloc] initWithConfig: config];
24
25         ui = [[JubGtkUI alloc] initWithClient: client];
26
27         client.ui = ui;
28         [client.connection addDelegate: self];
29
30         [ui startUIThread];
31 }
32
33 -  (void)connection: (XMPPConnection*)conn
34   didReceiveElement: (OFXMLElement*)element
35 {
36         of_log(@"In:  %@", element);
37 }
38
39 - (void)connection: (XMPPConnection*)conn
40     didSendElement: (OFXMLElement*)element
41 {
42         of_log(@"Out: %@", element);
43 }
44
45 -  (void)connection: (XMPPConnection*)connection_
46   didThrowException: (id)e
47 {
48         @throw e;
49 }
50 @end