X-Git-Url: http://cgit.babelmonkeys.de/?a=blobdiff_plain;f=src%2Fcore%2FJubChatClient.m;fp=src%2Fcore%2FJubChatClient.m;h=a31bdb598efcaee9b881955bd58cb3b5d6961a93;hb=0daa7a1cf98c6281dd7ba09baf0bf36cd1e154f7;hp=0000000000000000000000000000000000000000;hpb=68a17f7fc1f5fe8c2fee68ff35e672af4fd1e2f2;p=jubjub.git diff --git a/src/core/JubChatClient.m b/src/core/JubChatClient.m new file mode 100644 index 0000000..a31bdb5 --- /dev/null +++ b/src/core/JubChatClient.m @@ -0,0 +1,57 @@ +#import "JubChatClient.h" + +@implementation JubChatClient +@synthesize connection; +@synthesize roster; +@synthesize ui; + +- initWithConfig: (JubConfig*)config +{ + self = [super init]; + + @try { + connection = [XMPPConnection new]; + + connection.username = config.username; + connection.domain = config.domain; + connection.server = config.server; + connection.password = config.password; + [connection addDelegate: self]; + + roster = [[XMPPRoster alloc] initWithConnection: connection]; + [roster addDelegate: self]; + + streamManagement = [[XMPPStreamManagement alloc] + initWithConnection: connection]; + + [connection asyncConnectAndHandle]; + } @catch (id e) { + [self release]; + @throw e; + } + + return self; +} + +- (void)dealloc +{ + [roster release]; + [streamManagement release]; + [connection release]; + + [super dealloc]; +} + +- (void)connection: (XMPPConnection*)conn_ + wasBoundToJID: (XMPPJID*)jid +{ + of_log(@"Bound to JID: %@", [jid fullJID]); + + [roster requestRoster]; +} + +- (void)rosterWasReceived: (XMPPRoster*)roster +{ + [connection sendStanza: [XMPPPresence presence]]; +} +@end