summaryrefslogtreecommitdiffstats
path: root/src/core/ephraim_conv.erl
diff options
context:
space:
mode:
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 ->