From bdaae5b6704e29919ec7f284b9e3abe54f96f2f8 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 17 Jun 2010 13:07:17 +0200 Subject: Added CMake build system --- core/ephraim.erl | 62 -------------------------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 core/ephraim.erl (limited to 'core/ephraim.erl') diff --git a/core/ephraim.erl b/core/ephraim.erl deleted file mode 100644 index 6a68de0..0000000 --- a/core/ephraim.erl +++ /dev/null @@ -1,62 +0,0 @@ --module(ephraim). --compile([debug_info, export_all]). - --record(state, { - conn :: pid(), - convs :: dict(), - guis :: set() - }). - --spec start() -> ok. -start() -> - Pid = spawn(?MODULE, init, []), - case register(ephraim, Pid) of - true -> - ok - end. - --spec stop() -> ok. -stop() -> - ephraim ! stop, - ok. - --spec init() -> ok. -init() -> - Conn = spawn(ephraim_conn, init, []), - loop(#state{conn=Conn,convs=dict:new(),guis=sets:new()}). - --spec get_conv(#state{},exmpp_jid:jid()) -> {#state{},pid()}. -get_conv(State, JID) -> - Key = exmpp_jid:to_lower(exmpp_jid:bare(JID)), - case dict:find(Key, State#state.convs) of - {ok, Conv} -> - {State, Conv}; - error -> - Conv = spawn(ephraim_conv, init, [Key]), - Dict = dict:store(Key, Conv, State#state.convs), - {State#state{convs=Dict}, Conv} - end. - --spec loop(#state{}) -> ok. -loop(State) -> - receive - stop -> - dict:fold(fun(_,Conv,Msg) -> Conv ! Msg end, stop, State#state.convs), - State#state.conn ! stop, - ok; - {register_gui, Pid} -> - GUIs = State#state.guis, - State2 = State#state{guis=sets:add_element(Pid,GUIs)}, - loop(State2); - {unregister_gui, Pid} -> - GUIs = State#state.guis, - State2 = State#state{guis=sets:del_element(Pid,GUIs)}, - loop(State2); - {receive_message, From, Packet} -> - {State2, Conv} = get_conv(State, From), - Conv ! {receive_message, Packet}, - loop(State2); - Msg -> - io:format("ephraim: ~p~n", [Msg]), - loop(State) - end. -- cgit v1.2.3