+// FIXME: This needs to move somewhere else
+- (void)connection: (XMPPConnection*)connection
+ didReceiveMessage: (XMPPMessage*)message
+{
+ JubGtkChatUI *chat = [chatMap objectForKey: [message.from bareJID]];
+ if (chat == nil) {
+ OFString * title = [@"Chat with " stringByAppendingString:
+ [message.from bareJID]];
+ chat = [JubGtkChatUI alloc];
+ [[chat initWithTitle: title
+ sendBlock: ^(OFString *text) {
+ XMPPMessage *msg =
+ [XMPPMessage messageWithType: @"chat"];
+ msg.to = message.from;
+ msg.body = text;
+ [connection sendStanza: msg];
+
+ [chat addMessage: msg.body
+ sender: [message.to bareJID]];
+ }] autorelease];
+
+ [chatMap setObject: chat
+ forKey: [message.from bareJID]];
+ }
+ [chat addMessage: message.body
+ sender: [message.from bareJID]];
+}
+