From: Florian Zeitz Date: Wed, 20 Feb 2013 21:34:54 +0000 (+0100) Subject: Move adding messages to the ChatUI to JubChatClient X-Git-Url: https://cgit.babelmonkeys.de/?a=commitdiff_plain;h=bfecc06eee92ced72c224a4d2c98dbdb8f08d3f2;p=jubjub.git Move adding messages to the ChatUI to JubChatClient --- diff --git a/src/core/JubChatClient.h b/src/core/JubChatClient.h index 79884f8..95bda42 100644 --- a/src/core/JubChatClient.h +++ b/src/core/JubChatClient.h @@ -5,7 +5,8 @@ #import "JubChatUI.h" #import "JubConfig.h" -@interface JubChatClient : OFObject +@interface JubChatClient : OFObject + { OFMutableDictionary *_chatMap; XMPPConnection *_connection; diff --git a/src/core/JubChatClient.m b/src/core/JubChatClient.m index 9acdf39..77a4791 100644 --- a/src/core/JubChatClient.m +++ b/src/core/JubChatClient.m @@ -27,6 +27,7 @@ _contactManager = [[XMPPContactManager alloc] initWithConnection: _connection roster: _roster]; + [_contactManager addDelegate: self]; _streamManagement = [[XMPPStreamManagement alloc] initWithConnection: _connection]; @@ -42,6 +43,10 @@ - (void)dealloc { + [_roster removeDelegate: self]; + [_contactManager removeDelegate: self]; + [_connection removeDelegate: self]; + [_roster release]; [_contactManager release]; [_streamManagement release]; @@ -103,6 +108,17 @@ } } +- (void)contact: (XMPPContact*)contact + didSendMessage: (XMPPMessage*)message +{ + if (message.body == nil || ![message.type isEqual: @"chat"]) + return; + + id chat = [self chatForContact: contact]; + [chat addMessage: message.body + sender: [message.from bareJID]]; +} + - (void)rosterWasReceived: (XMPPRoster*)roster { XMPPPresence *pres = [XMPPPresence presence]; diff --git a/src/gui/gtk/JubGtkRosterUI.m b/src/gui/gtk/JubGtkRosterUI.m index 227837d..ac74a33 100644 --- a/src/gui/gtk/JubGtkRosterUI.m +++ b/src/gui/gtk/JubGtkRosterUI.m @@ -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 chat = [_client chatForContact: contact]; - [chat addMessage: message.body - sender: [message.from bareJID]]; -} - /* Roster Delegate methods */ - (void)Jub_addRosterItem: (XMPPRosterItem*)item group: (OFString*)group