diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2010-07-17 20:20:02 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2010-07-17 20:20:02 +0200 |
commit | 0aac619ba4dccd81018bddaa4690213b14cfe2b6 (patch) | |
tree | cd21aa85f777f45f8b6ab9f01dbd73cfc5f1d2b5 /src/core | |
parent | dfc0469a184ae978f40cac9df20d399fdeca99a3 (diff) | |
download | ephraim-0aac619ba4dccd81018bddaa4690213b14cfe2b6.tar ephraim-0aac619ba4dccd81018bddaa4690213b14cfe2b6.zip |
Moved some message handling from GUI to core
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/ephraim_conv.erl | 16 | ||||
-rw-r--r-- | src/core/ephraim_gui.erl | 1 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/core/ephraim_conv.erl b/src/core/ephraim_conv.erl index dbf84c8..199787a 100644 --- a/src/core/ephraim_conv.erl +++ b/src/core/ephraim_conv.erl @@ -2,14 +2,16 @@ -compile([debug_info, export_all]). -record(conv_state, { - jid :: binary() + my_jid :: binary(), + jid :: binary() }). -spec init(binary()) -> ok. init(JID) -> io:format("Starting a conversation with ~p~n", [JID]), - loop(#conv_state{jid=JID}), + {jid,MyJID} = ephraim_config:get(jid), + loop(#conv_state{my_jid=list_to_binary(MyJID),jid=JID}), io:format("Stopping a conversation with ~p~n", [JID]). -spec loop(#conv_state{}) -> ok. @@ -21,8 +23,12 @@ loop(State) -> {receive_message, Packet} -> Type = exmpp_message:get_type(Packet), Body = exmpp_message:get_body(Packet), - %io:format("Received message from ~p:~n~p~n", [State#conv_state.jid, Packet]), - ephraim ! {ui_update, {receive_message, State#conv_state.jid, Type, Body}}, + if + Body =/= undefined -> + ephraim ! {ui_update, {chat_message, State#conv_state.jid, Type, State#conv_state.jid, Body}}; + true -> + io:format("Received strange message from ~p:~n~p~n", [State#conv_state.jid, Packet]) + end, loop(State); {send_message, Type, Message} -> @@ -30,7 +36,7 @@ loop(State) -> Packet2 = exmpp_message:set_type(Packet, Type), Packet3 = exmpp_xml:set_attribute(Packet2, to, State#conv_state.jid), ephraim ! {send_packet, Packet3}, - ephraim ! {ui_update, {sent_message, State#conv_state.jid, Type, Message}}, + ephraim ! {ui_update, {chat_message, State#conv_state.jid, Type, State#conv_state.my_jid, Message}}, loop(State); Msg -> diff --git a/src/core/ephraim_gui.erl b/src/core/ephraim_gui.erl index 79433e0..8ee56b8 100644 --- a/src/core/ephraim_gui.erl +++ b/src/core/ephraim_gui.erl @@ -3,6 +3,7 @@ -spec init() -> ok. init() -> + {jid,JID} = ephraim_config:get(jid), Port = open_port({spawn_executable, "ephraim-gtk"}, [binary, nouse_stdio, {packet, 4}]), ephraim ! {register_ui, self()}, loop(Port), |