summaryrefslogtreecommitdiffstats
path: root/src/gui/CoreConnector.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/CoreConnector.vala')
-rw-r--r--src/gui/CoreConnector.vala61
1 files changed, 31 insertions, 30 deletions
diff --git a/src/gui/CoreConnector.vala b/src/gui/CoreConnector.vala
index 445f097..5566686 100644
--- a/src/gui/CoreConnector.vala
+++ b/src/gui/CoreConnector.vala
@@ -1,26 +1,25 @@
public class CoreConnector {
+ static Eva.Term match_gui_init;
static Eva.Term match_roster_update;
static Eva.Term match_resource_entry;
static Eva.Term match_avatar;
static Eva.Term match_new_conversation;
- static Eva.Term match_receive_message;
- static Eva.Term match_sent_message;
+ static Eva.Term match_chat_message;
static construct {
+ match_gui_init = Eva.parse("{gui_init,Terms}");
match_roster_update = Eva.parse("{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_new_conversation = Eva.parse("{new_conversation,JID}");
- match_receive_message = Eva.parse("{receive_message,JID,Type,Body}");
- match_sent_message = Eva.parse("{sent_message,JID,Type,Body}");
+ match_chat_message = Eva.parse("{chat_message,JID,Type,From,Body}");
}
Eva.PacketHandler con;
public signal void update_contact(Contact contact);
public signal void new_conversation(string jid);
- public signal void receive_message(string jid, string type, string message);
- public signal void sent_message(string jid, string type, string message);
+ 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);
@@ -41,7 +40,26 @@ public class CoreConnector {
private void handle_term(Eva.Term term) {
Gee.Map<string, Eva.Term> match;
- if((match = term.match(match_roster_update)) != null) {
+ if((match = term.match(match_gui_init)) != null) {
+ Eva.Cons terms = match["Terms"] as Eva.Cons;
+
+ while(terms != null) {
+ Eva.Tuple tuple = terms.head as Eva.Tuple;
+
+ if(tuple != null && tuple.size > 0) {
+ Eva.Atom key = tuple[0] as Eva.Atom;
+
+ /*if(key != null) {
+ switch(key.value) {
+ // None yet
+ }
+ }*/
+ }
+
+ terms = terms.tail as Eva.Cons;
+ }
+ }
+ else if((match = term.match(match_roster_update)) != null) {
Eva.Binary jid_term = match["JID"] as Eva.Binary;
if(jid_term == null) {
warn_if_reached();
@@ -140,7 +158,7 @@ public class CoreConnector {
new_conversation(jid);
}
- else if((match = term.match(match_receive_message)) != null) {
+ else if((match = term.match(match_chat_message)) != null) {
Eva.Binary jid_term = match["JID"] as Eva.Binary;
if(jid_term == null) {
warn_if_reached();
@@ -155,29 +173,12 @@ public class CoreConnector {
}
string type = type_term.value;
- Eva.Binary body_term = match["Body"] as Eva.Binary;
- if(body_term == null) {
- warn_if_reached();
- return;
- }
- string body = from_utf8(body_term);
-
- receive_message(jid, type, body);
- }
- else if((match = term.match(match_sent_message)) != null) {
- Eva.Binary jid_term = match["JID"] as Eva.Binary;
- if(jid_term == null) {
+ Eva.Binary from_term = match["From"] as Eva.Binary;
+ if(from_term == null) {
warn_if_reached();
return;
}
- string jid = from_utf8(jid_term);
-
- Eva.Atom type_term = match["Type"] as Eva.Atom;
- if(type_term == null) {
- warn_if_reached();
- return;
- }
- string type = type_term.value;
+ string from = from_utf8(from_term);
Eva.Binary body_term = match["Body"] as Eva.Binary;
if(body_term == null) {
@@ -186,10 +187,10 @@ public class CoreConnector {
}
string body = from_utf8(body_term);
- sent_message(jid, type, body);
+ chat_message(jid, type, from, body);
}
else {
- stdout.printf("%s\n", term.to_string());
+ stdout.printf("Received unhandled term: %s\n", term.to_string());
}
}