#import <ObjXMPP/ObjXMPP.h>
#import "JubGtkUI.h"
+#import "JubConfig.h"
+#import "JubChatClient.h"
-@interface AppDelegate: OFObject
- <OFApplicationDelegate, XMPPConnectionDelegate, XMPPRosterDelegate>
+@interface AppDelegate: OFObject <OFApplicationDelegate, XMPPConnectionDelegate>
{
- XMPPConnection *connection;
- XMPPRoster *roster;
+ JubChatClient *client;
id<JubUI> ui;
}
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching
{
- id<XMPPRosterDelegate, XMPPConnectionDelegate> rosterDelegate;
+ JubConfig *config = [[[JubConfig alloc] initWithFile: @"config.xml"]
+ autorelease];
- connection = [[XMPPConnection alloc] init];
- [connection addDelegate: self];
+ client = [[JubChatClient alloc] initWithConfig: config];
- connection.domain = @"localhost";
- connection.username = @"alice";
- connection.password = @"test";
+ ui = [[JubGtkUI alloc] initWithClient: client];
- ui = [[JubGtkUI alloc] initWithConnection: connection];
- rosterDelegate = [ui rosterDelegate];
-
- [connection addDelegate: rosterDelegate];
-
- roster = [[XMPPRoster alloc] initWithConnection: connection];
- [roster addDelegate: rosterDelegate];
- [roster addDelegate: self];
-
- [connection asyncConnectAndHandle];
+ client.ui = ui;
+ [client.connection addDelegate: self];
[ui startUIThread];
}
-- (void)connection: (XMPPConnection*)conn_
- wasBoundToJID: (XMPPJID*)jid
-{
- of_log(@"Bound to JID: %@", [jid fullJID]);
-
- [roster requestRoster];
-}
-
-- (void)rosterWasReceived: (XMPPRoster*)roster
-{
- [connection sendStanza: [XMPPPresence presence]];
-}
-
- (void)connection: (XMPPConnection*)conn
didReceiveElement: (OFXMLElement*)element
{