Handle HAVE_ALL and HAVE_NONE. Cleanup the BITFIELD message.
[etorrent.git] / lib / etorrent-1.0 / src / etorrent_event_mgr.erl
blob530f261c9e39566b8d86928ac773a7f42a9ca05a
1 %%%-------------------------------------------------------------------
2 %%% File : etorrent_event_mgr.erl
3 %%% Author : Jesper Louis Andersen <>
4 %%% Description : Event tracking inside the etorrent application.
5 %%%
6 %%% Created : 25 Aug 2007 by Jesper Louis Andersen <>
7 %%%-------------------------------------------------------------------
8 -module(etorrent_event_mgr).
10 %% API
11 -export([start_link/0,
13 persisted_state_to_disk/0,
15 started_torrent/1,
16 checking_torrent/1,
17 seeding_torrent/1]).
19 -define(SERVER, ?MODULE).
21 %%====================================================================
22 %% gen_event callbacks
23 %%====================================================================
24 %%--------------------------------------------------------------------
25 %% Function: start_link() -> {ok,Pid} | {error,Error}
26 %% Description: Creates an event manager.
27 %%--------------------------------------------------------------------
28 start_link() ->
29 {ok, Pid} = gen_event:start_link({local, ?SERVER}),
30 {ok, Dir} = application:get_env(etorrent, logger_dir),
31 {ok, Fname} = application:get_env(etorrent, logger_fname),
32 Args = etorrent_file_logger:init(Dir, Fname),
33 gen_event:add_handler(?SERVER, etorrent_file_logger, Args),
34 {ok, Pid}.
36 started_torrent(Id) ->
37 gen_event:notify(?SERVER, {started_torrent, Id}).
40 checking_torrent(Id) ->
41 gen_event:notify(?SERVER, {checking_torrent, Id}).
43 seeding_torrent(Id) ->
44 gen_event:notify(?SERVER, {seeding_torrent, Id}).
46 persisted_state_to_disk() ->
47 gen_event:notify(?SERVER, persisted_state_to_disk).