]> cgit.babelmonkeys.de Git - jubjub.git/blobdiff - src/core/main.m
Prefix ivars with an underscore
[jubjub.git] / src / core / main.m
index ff97a3b602b56b98e01f071e7c3040923f23e912..459a15c9a898f0ab126b50aad6a81019a97e8a46 100644 (file)
@@ -2,13 +2,13 @@
 #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
 
@@ -17,49 +17,34 @@ OF_APPLICATION_DELEGATE(AppDelegate)
 @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