Page MenuHomePhorge

kolab_guam_sup.erl
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

kolab_guam_sup.erl

%% Copyright 2015 Kolab Systems AG (http://www.kolabsys.com)
%%
%% Aaron Seigo (Kolab Systems) <seigo a kolabsys.com>
%%
%% This program is free software: you can redistribute it and/or modify
%% it under the terms of the GNU General Public License as published by
%% the Free Software Foundation, either version 3 of the License, or
%% (at your option) any later version.
%%
%% This program is distributed in the hope that it will be useful,
%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%% GNU General Public License for more details.
%%
%% You should have received a copy of the GNU General Public License
%% along with this program. If not, see <http://www.gnu.org/licenses/>.
-module(kolab_guam_sup).
-behaviour(supervisor).
-include_lib("eimap/src/eimap.hrl").
%% API
-export([start_link/0, default_imap_server_config/0, imap_server_config/1, imap_server_settings_to_config/1]).
%% Supervisor callbacks
-export([init/1]).
%% ===================================================================
%% API functions
%% ===================================================================
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
default_imap_server_config() -> imap_server_config(default).
imap_server_config(DefinitionName) when is_atom(DefinitionName) ->
ServerDefinitions = application:get_env(kolab_guam, imap_servers, []),
RawConfig = proplists:get_value(DefinitionName, ServerDefinitions, []),
imap_server_settings_to_config(RawConfig).
imap_server_settings_to_config(Config) when is_list(Config) ->
Defaults = #eimap_server_config{ },
#eimap_server_config{
host = proplists:get_value(host, Config, Defaults#eimap_server_config.host),
port = proplists:get_value(port, Config, Defaults#eimap_server_config.port),
tls = proplists:get_value(tls, Config, Defaults#eimap_server_config.tls)
}.
%% ===================================================================
%% Supervisor callbacks
%% ===================================================================
init([]) ->
lager:debug("Creating listeners ..."),
ListenersConfig = application:get_env(kolab_guam, listeners, []),
Children = [ create_child(Name, ListenerConfig) || { Name, ListenerConfig } <- ListenersConfig ],
lager:debug("We have ~p~n", [Children]),
{ ok, { { one_for_one, 5, 10}, Children } }.
create_child(Name, ListenerConfig) ->
lager:debug("Making listener \"~p\" with ~p", [Name, ListenerConfig]),
{ Name, { kolab_guam_listener, start_link, [Name, ListenerConfig] }, permanent, 5000, supervisor, [Name] }.

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 4, 5:16 AM (4 d, 11 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
8c/62/6d0ad9f373f90902a57327f7cb9b
Default Alt Text
kolab_guam_sup.erl (2 KB)

Event Timeline