diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/CoreConnector.vala | 31 | ||||
-rw-r--r-- | src/gui/Ephraim.vala | 12 |
2 files changed, 19 insertions, 24 deletions
diff --git a/src/gui/CoreConnector.vala b/src/gui/CoreConnector.vala index 46c94f2..9159c49 100644 --- a/src/gui/CoreConnector.vala +++ b/src/gui/CoreConnector.vala @@ -12,16 +12,16 @@ public class CoreConnector { match_roster_update = Eva.parse("{account,Account,{roster_update,JID,Name,Subscription,Groups,Resources,Avatar}}"); match_resource_entry = Eva.parse("{Name,{resource_entry,Priority,Show,Status}}"); match_avatar = Eva.parse("{avatar,Data}"); - match_conversation = Eva.parse("{account,Account,{conversation,Ref,Message}}"); - match_conversation_new = Eva.parse("{new,JID}"); + match_conversation = Eva.parse("{account,Account,{conversation,JID,Message}}"); + match_conversation_new = Eva.parse("new"); match_conversation_message = Eva.parse("{message,From,Type,Body}"); } Eva.PacketHandler con; public signal void update_contact(Contact contact); - public signal void new_conversation(Eva.Ref conv_ref, string jid); - public signal void chat_message(Eva.Ref conv_ref, string from, string type, string message); + public signal void new_conversation(string jid); + public signal void chat_message(string jid, string from, string type, string message); public void start() { con = new Eva.PacketHandler(new UnixInputStream(3, true), new UnixOutputStream(4, true), 4); @@ -178,11 +178,13 @@ public class CoreConnector { update_contact(contact); } else if((match = term.match(match_conversation)) != null) { - Eva.Ref conv_ref = match["Ref"] as Eva.Ref; - if(conv_ref == null) { + Eva.Binary jid_term = match["JID"] as Eva.Binary; + if(jid_term == null) { warn_if_reached(); return; } + string jid = from_utf8(jid_term); + Eva.Term message_term = match["Message"]; if(message_term == null) { warn_if_reached(); @@ -191,14 +193,7 @@ public class CoreConnector { Gee.Map<string, Eva.Term> cmatch; if((cmatch = message_term.match(match_conversation_new)) != null) { - Eva.Binary jid_term = cmatch["JID"] as Eva.Binary; - if(jid_term == null) { - warn_if_reached(); - return; - } - - string jid = from_utf8(jid_term); - new_conversation(conv_ref, jid); + new_conversation(jid); } else if((cmatch = message_term.match(match_conversation_message)) != null) { Eva.Binary from_term = cmatch["From"] as Eva.Binary; @@ -221,8 +216,8 @@ public class CoreConnector { return; } string body = from_utf8(body_term); - - chat_message(conv_ref, from, type, body); + + chat_message(jid, from, type, body); } else { stdout.printf("Received unhandled term: %s\n", term.to_string()); @@ -235,12 +230,12 @@ public class CoreConnector { public void start_conversation(string jid) { char[] jid_utf8 = jid.to_utf8(); - con.send(Eva.parse("{start_conversation,~w}", new Eva.Binary(jid_utf8))); + con.send(Eva.parse("{account,foo_account,{conversation,~w,new}}", new Eva.Binary(jid_utf8))); } public void send_message(string jid, string type, string message) { char[] jid_utf8 = jid.to_utf8(); char[] message_utf8 = message.to_utf8(); - con.send(Eva.parse("{send_message,~w,~a,~w}", new Eva.Binary(jid_utf8), type, new Eva.Binary(message_utf8))); + con.send(Eva.parse("{account,foo_account,{conversation,~w,{send_message,~a,~w}}}", new Eva.Binary(jid_utf8), type, new Eva.Binary(message_utf8))); } } diff --git a/src/gui/Ephraim.vala b/src/gui/Ephraim.vala index fb5e77f..5ddcd5e 100644 --- a/src/gui/Ephraim.vala +++ b/src/gui/Ephraim.vala @@ -17,7 +17,7 @@ public class Ephraim { unowned Gtk.TreeView rosterView = builder.get_object("Roster") as Gtk.TreeView; - Gee.TreeMap<Eva.Ref, Conversation> conversations = new Gee.TreeMap<Eva.Ref, Conversation>(); + Gee.TreeMap<string, Conversation> conversations = new Gee.TreeMap<string, Conversation>(); unowned Gtk.Notebook conversationNotebook = builder.get_object("Conversations") as Gtk.Notebook; ContactList roster = new ContactList(rosterView); @@ -28,22 +28,22 @@ public class Ephraim { coreconn.update_contact.connect(roster.update_contact); - coreconn.new_conversation.connect((conv_ref, jid) => { + coreconn.new_conversation.connect((jid) => { Contact contact = roster.get_contact(jid); Conversation conv = new Conversation(conversationNotebook, jid, contact != null ? contact.display_string : null); - conversations[conv_ref] = conv; + conversations[jid] = conv; conv.send_message.connect((type, message) => coreconn.send_message(jid, type, message)); }); - coreconn.chat_message.connect((conv_ref, from, type, message) => { - if(!(conv_ref in conversations.keys)) { + coreconn.chat_message.connect((jid, from, type, message) => { + if(!(jid in conversations.keys)) { warn_if_reached(); return; } - conversations[conv_ref].chat_message(from, type, message); + conversations[jid].chat_message(from, type, message); }); //if(!coreconn.start()) |