]> cgit.babelmonkeys.de Git - jubjub.git/blobdiff - src/core/main.m
Add User Avatar support
[jubjub.git] / src / core / main.m
index 229e6c5aa502fe2624725beaaa08d9709d14d24a..6de6785be8ec4378c4dfaa02bff19294a789038d 100644 (file)
@@ -2,13 +2,14 @@
 #import <ObjXMPP/ObjXMPP.h>
 
 #import "JubGtkUI.h"
+#import "JubCLIUI.h"
 #import "JubConfig.h"
 #import "JubChatClient.h"
 
 @interface AppDelegate: OFObject <OFApplicationDelegate, XMPPConnectionDelegate>
 {
-       JubChatClient *client;
-       id<JubUI> ui;
+       JubChatClient *_client;
+       id<JubUI> _ui;
 }
 @end
 
@@ -20,29 +21,38 @@ OF_APPLICATION_DELEGATE(AppDelegate)
        JubConfig *config = [[[JubConfig alloc] initWithFile: @"config.xml"]
            autorelease];
 
-       client = [[JubChatClient alloc] initWithConfig: config];
+       _client = [[JubChatClient alloc] initWithConfig: config];
 
-       ui = [[JubGtkUI alloc] initWithClient: client];
+       if ([config.frontend isEqual: @"gtk"])
+               _ui = [[JubGtkUI alloc] initWithClient: _client];
+       else if ([config.frontend isEqual: @"cli"])
+               _ui = [[JubCLIUI alloc] initWithClient: _client];
+       else {
+               [of_stderr writeFormat: @"Unknown frontend '%@', known "
+                   @"frontends are 'gtk' and 'cli'\n", config.frontend];
+               [OFApplication terminate];
+       }
 
-       client.ui = ui;
-       [client.connection addDelegate: self];
+       _client.ui = _ui;
+       [_client.connection addDelegate: self];
 
-       [ui startUIThread];
+       [_ui startUIThread];
+       [_client.connection asyncConnectAndHandle];
 }
 
--  (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_
+-  (void)connection: (XMPPConnection*)connection
   didThrowException: (id)e
 {
        @throw e;