#import "JubGtkRosterUI.h"
#import "JubGObjectMap.h"
+#import "JubGtkChatUI.h"
static gboolean filter_roster_by_presence(GtkTreeModel *model,
GtkTreeIter *iter, gpointer data)
initWithKeyFunctions: keyFunctions
valueFunctions: rowRefFunctions];
contactMap = [[OFMutableDictionary alloc] init];
+ chatMap = [[OFMutableDictionary alloc] init];
presences = [[OFCountedSet alloc] init];
builder = g_object_ref(builder_);
g_idle_add(refilter_roster, roster_filter);
}
+// 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]];
+}
+
/* Roster Delegate methods */
struct add_roster_item_param {
OFString *group;