#import "JubChatUI.h"
#import "JubConfig.h"
-@interface JubChatClient : OFObject <XMPPConnectionDelegate, XMPPRosterDelegate>
+@interface JubChatClient : OFObject
+ <XMPPConnectionDelegate, XMPPRosterDelegate, XMPPContactManagerDelegate>
{
OFMutableDictionary *_chatMap;
XMPPConnection *_connection;
_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];
[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