]> cgit.babelmonkeys.de Git - jubjub.git/commitdiff
Move adding messages to the ChatUI to JubChatClient
authorFlorian Zeitz <florob@babelmonkeys.de>
Wed, 20 Feb 2013 21:34:54 +0000 (22:34 +0100)
committerFlorian Zeitz <florob@babelmonkeys.de>
Wed, 20 Feb 2013 21:34:54 +0000 (22:34 +0100)
src/core/JubChatClient.h
src/core/JubChatClient.m
src/gui/gtk/JubGtkRosterUI.m

index 79884f8ff6916613e79ab30d07e0ef27dc47cbb3..95bda4296d989aa396cadfd46d8c24bf4f90189b 100644 (file)
@@ -5,7 +5,8 @@
 #import "JubChatUI.h"
 #import "JubConfig.h"
 
-@interface JubChatClient : OFObject <XMPPConnectionDelegate, XMPPRosterDelegate>
+@interface JubChatClient : OFObject
+    <XMPPConnectionDelegate, XMPPRosterDelegate, XMPPContactManagerDelegate>
 {
        OFMutableDictionary *_chatMap;
        XMPPConnection *_connection;
index 9acdf3935addec8aed8df165bcb5630eb0208893..77a4791541806bff07e079e3ecf01b7f4f26a1ae 100644 (file)
@@ -27,6 +27,7 @@
                _contactManager = [[XMPPContactManager alloc]
                    initWithConnection: _connection
                                roster: _roster];
+               [_contactManager addDelegate: self];
 
                _streamManagement = [[XMPPStreamManagement alloc]
                    initWithConnection: _connection];
 
 - (void)dealloc
 {
+       [_roster removeDelegate: self];
+       [_contactManager removeDelegate: self];
+       [_connection removeDelegate: self];
+
        [_roster release];
        [_contactManager release];
        [_streamManagement release];
        }
 }
 
+-  (void)contact: (XMPPContact*)contact
+  didSendMessage: (XMPPMessage*)message
+{
+       if (message.body == nil || ![message.type isEqual: @"chat"])
+               return;
+
+       id<JubChatUI> chat = [self chatForContact: contact];
+       [chat addMessage: message.body
+                 sender: [message.from bareJID]];
+}
+
 - (void)rosterWasReceived: (XMPPRoster*)roster
 {
        XMPPPresence *pres = [XMPPPresence presence];
index 227837dae7f63a979c634ea90a964656361017ca..ac74a33aae1e44f23041bb4cf49886a4112a9691 100644 (file)
@@ -141,17 +141,6 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model,
        [super dealloc];
 }
 
--  (void)contact: (XMPPContact*)contact
-  didSendMessage: (XMPPMessage*)message
-{
-       if (message.body == nil || ![message.type isEqual: @"chat"])
-               return;
-
-       id<JubChatUI> chat = [_client chatForContact: contact];
-       [chat addMessage: message.body
-                 sender: [message.from bareJID]];
-}
-
 /* Roster Delegate methods */
 - (void)Jub_addRosterItem: (XMPPRosterItem*)item
                    group: (OFString*)group