From fe332740f7c0be59d4ede7097e5bd1eabbf40e39 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 25 Jun 2010 06:14:12 +0200 Subject: Chatting works now --- src/gui/Ephraim.vala | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'src/gui/Ephraim.vala') diff --git a/src/gui/Ephraim.vala b/src/gui/Ephraim.vala index 9d3083c..fe9f431 100644 --- a/src/gui/Ephraim.vala +++ b/src/gui/Ephraim.vala @@ -26,15 +26,33 @@ public class Ephraim { Gee.TreeMap conversations = new Gee.TreeMap(); unowned Gtk.Notebook conversationNotebook = builder.get_object("Conversations") as Gtk.Notebook; + // FIXME + string me = "/me"; + coreconn.new_conversation.connect((jid) => { Contact contact = roster.get_contact(jid); if(contact != null) { - conversations[jid] = new Conversation(conversationNotebook, jid, contact.display_string); + conversations[jid] = new Conversation(conversationNotebook, me, jid, contact.display_string); } else { - conversations[jid] = new Conversation(conversationNotebook, jid, null); + conversations[jid] = new Conversation(conversationNotebook, me, jid, null); } + + conversations[jid].send_message.connect((type, message) => coreconn.send_message(jid, type, message)); + }); + + coreconn.receive_message.connect((jid, type, message) => { + if(!(jid in conversations)) + return; + + conversations[jid].receive_message(type, message); + }); + coreconn.sent_message.connect((jid, type, message) => { + if(!(jid in conversations)) + return; + + conversations[jid].sent_message(type, message); }); if(!coreconn.start()) @@ -65,6 +83,24 @@ public class Ephraim { }); rosterView.has_tooltip = true; + rosterView.row_activated.connect((view, path, column) => { + Gtk.TreeIter iter; + roster.get_iter(out iter, path); + + Value value; + roster.get_value(iter, 0, out value); + + Contact contact = value.get_object() as Contact; + if(contact == null) + return; + + Gee.Map.Entry res = contact.get_resource_with_highest_priority(); + if(res == null) + return; //FIXME + + coreconn.start_conversation(contact.jid + "/" + res.key); + }); + Gtk.TreeViewColumn presenceColumn = new Gtk.TreeViewColumn.with_attributes(null, new CellRendererPresence(), "contact", 0, null); presenceColumn.min_width = 32; rosterView.append_column(presenceColumn); -- cgit v1.2.3