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