]> cgit.babelmonkeys.de Git - jubjub.git/blobdiff - src/core/main.m
Implement connection:didThrowException:
[jubjub.git] / src / core / main.m
index 62393b23ed964dd7e22bbdd2ed1fdba787a8908a..229e6c5aa502fe2624725beaaa08d9709d14d24a 100644 (file)
@@ -2,12 +2,12 @@
 #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
@@ -17,41 +17,19 @@ OF_APPLICATION_DELEGATE(AppDelegate)
 @implementation AppDelegate
 - (void)applicationDidFinishLaunching
 {
-       ui = [[JubGtkUI alloc] init];
-       id<XMPPRosterDelegate, XMPPConnectionDelegate> rosterDelegate =
-           [ui 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];
 
-       [connection asyncConnectAndHandle];
-
-       [connection addDelegate: rosterDelegate];
-
-       roster = [[XMPPRoster alloc] initWithConnection: connection];
-       [roster addDelegate: rosterDelegate];
-       [roster addDelegate: self];
+       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
 {
@@ -63,4 +41,10 @@ OF_APPLICATION_DELEGATE(AppDelegate)
 {
        of_log(@"Out: %@", element);
 }
+
+-  (void)connection: (XMPPConnection*)connection_
+  didThrowException: (id)e
+{
+       @throw e;
+}
 @end