]> cgit.babelmonkeys.de Git - jubjub.git/blob - src/core/main.m
Initial commit
[jubjub.git] / src / core / main.m
1 #import <ObjFW/ObjFW.h>
2 #import <ObjXMPP/ObjXMPP.h>
3
4 #import "JubGtkUI.h"
5
6 @interface AppDelegate: OFObject
7     <OFApplicationDelegate, XMPPConnectionDelegate>
8 {
9         XMPPConnection *connection;
10         XMPPRoster *roster;
11         id<JubUI> ui;
12 }
13 @end
14
15 OF_APPLICATION_DELEGATE(AppDelegate)
16
17 @implementation AppDelegate
18 - (void)applicationDidFinishLaunching
19 {
20         ui = [[JubGtkUI alloc] init];
21
22         connection = [[XMPPConnection alloc] init];
23         [connection addDelegate: self];
24
25         connection.domain = @"localhost";
26         connection.username = @"alice";
27         connection.password = @"test";
28
29         [connection connect];
30         [connection handleConnection];
31
32         roster = [[XMPPRoster alloc] initWithConnection: connection];
33         [roster addDelegate: [ui rosterDelegate]];
34
35         [ui startUIThread];
36 }
37
38 - (void)connection: (XMPPConnection*)conn_
39      wasBoundToJID: (XMPPJID*)jid
40 {
41         of_log(@"Bound to JID: %@", [jid fullJID]);
42
43         [roster requestRoster];
44 }
45
46 -  (void)connection: (XMPPConnection*)conn
47   didReceiveElement: (OFXMLElement*)element
48 {
49         of_log(@"In:  %@", element);
50 }
51
52 - (void)connection: (XMPPConnection*)conn
53     didSendElement: (OFXMLElement*)element
54 {
55         of_log(@"Out: %@", element);
56 }
57 @end