diff options
Diffstat (limited to 'src/gui/CoreConnector.vala')
-rw-r--r-- | src/gui/CoreConnector.vala | 31 |
1 files changed, 13 insertions, 18 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))); } } |