#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;
- id<JubUI> ui;
+ JubChatClient *_client;
+ id<JubUI> _ui;
}
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching
{
- ui = [[JubGtkUI alloc] init];
+ 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];
- [connection connect];
- [connection handleConnection];
+ _client.ui = _ui;
+ [_client.connection addDelegate: self];
- [connection addDelegate: [ui rosterDelegate]];
-
- roster = [[XMPPRoster alloc] initWithConnection: connection];
- [roster addDelegate: [ui rosterDelegate]];
- [roster addDelegate: self];
-
- [ui startUIThread];
-}
-
-- (void)connection: (XMPPConnection*)conn_
- wasBoundToJID: (XMPPJID*)jid
-{
- of_log(@"Bound to JID: %@", [jid fullJID]);
-
- [roster requestRoster];
+ [_ui startUIThread];
}
-- (void)rosterWasReceived: (XMPPRoster*)roster
-{
- [connection sendStanza: [XMPPPresence presence]];
-}
-
-- (void)connection: (XMPPConnection*)conn
+- (void)connection: (XMPPConnection*)connection
didReceiveElement: (OFXMLElement*)element
{
of_log(@"In: %@", element);
}
-- (void)connection: (XMPPConnection*)conn
+- (void)connection: (XMPPConnection*)connection
didSendElement: (OFXMLElement*)element
{
of_log(@"Out: %@", element);
}
+
+- (void)connection: (XMPPConnection*)connection
+ didThrowException: (id)e
+{
+ @throw e;
+}
@end