summaryrefslogtreecommitdiffstats
path: root/src/core/ephraim_conv.erl
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2010-07-17 20:20:02 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2010-07-17 20:20:02 +0200
commit0aac619ba4dccd81018bddaa4690213b14cfe2b6 (patch)
treecd21aa85f777f45f8b6ab9f01dbd73cfc5f1d2b5 /src/core/ephraim_conv.erl
parentdfc0469a184ae978f40cac9df20d399fdeca99a3 (diff)
downloadephraim-0aac619ba4dccd81018bddaa4690213b14cfe2b6.tar
ephraim-0aac619ba4dccd81018bddaa4690213b14cfe2b6.zip
Moved some message handling from GUI to core
Diffstat (limited to 'src/core/ephraim_conv.erl')
-rw-r--r--src/core/ephraim_conv.erl16
1 files changed, 11 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 ->