]> cgit.babelmonkeys.de Git - jubjub.git/blob - src/core/JubChatClient.m
a31bdb598efcaee9b881955bd58cb3b5d6961a93
[jubjub.git] / src / core / JubChatClient.m
1 #import "JubChatClient.h"
2
3 @implementation JubChatClient
4 @synthesize connection;
5 @synthesize roster;
6 @synthesize ui;
7
8 - initWithConfig: (JubConfig*)config
9 {
10         self = [super init];
11
12         @try {
13                 connection = [XMPPConnection new];
14
15                 connection.username = config.username;
16                 connection.domain = config.domain;
17                 connection.server = config.server;
18                 connection.password = config.password;
19                 [connection addDelegate: self];
20
21                 roster = [[XMPPRoster alloc] initWithConnection: connection];
22                 [roster addDelegate: self];
23
24                 streamManagement = [[XMPPStreamManagement alloc]
25                     initWithConnection: connection];
26
27                 [connection asyncConnectAndHandle];
28         } @catch (id e) {
29                 [self release];
30                 @throw e;
31         }
32
33         return self;
34 }
35
36 - (void)dealloc
37 {
38         [roster release];
39         [streamManagement release];
40         [connection release];
41
42         [super dealloc];
43 }
44
45 - (void)connection: (XMPPConnection*)conn_
46      wasBoundToJID: (XMPPJID*)jid
47 {
48         of_log(@"Bound to JID: %@", [jid fullJID]);
49
50         [roster requestRoster];
51 }
52
53 - (void)rosterWasReceived: (XMPPRoster*)roster
54 {
55         [connection sendStanza: [XMPPPresence presence]];
56 }
57 @end