]> cgit.babelmonkeys.de Git - jubjub.git/blob - src/core/main.m
Open new chat windows when activating a roster row
[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, XMPPRosterDelegate>
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         id<XMPPRosterDelegate, XMPPConnectionDelegate> rosterDelegate;
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         ui = [[JubGtkUI alloc] initWithConnection: connection];
30         rosterDelegate = [ui rosterDelegate];
31
32         [connection addDelegate: rosterDelegate];
33
34         roster = [[XMPPRoster alloc] initWithConnection: connection];
35         [roster addDelegate: rosterDelegate];
36         [roster addDelegate: self];
37
38         [connection asyncConnectAndHandle];
39
40         [ui startUIThread];
41 }
42
43 - (void)connection: (XMPPConnection*)conn_
44      wasBoundToJID: (XMPPJID*)jid
45 {
46         of_log(@"Bound to JID: %@", [jid fullJID]);
47
48         [roster requestRoster];
49 }
50
51 - (void)rosterWasReceived: (XMPPRoster*)roster
52 {
53         [connection sendStanza: [XMPPPresence presence]];
54 }
55
56 -  (void)connection: (XMPPConnection*)conn
57   didReceiveElement: (OFXMLElement*)element
58 {
59         of_log(@"In:  %@", element);
60 }
61
62 - (void)connection: (XMPPConnection*)conn
63     didSendElement: (OFXMLElement*)element
64 {
65         of_log(@"Out: %@", element);
66 }
67 @end