Skip to content

Commit

Permalink
Merge branch 'master' of github.com:OpenACD/OpenACD
Browse files Browse the repository at this point in the history
  • Loading branch information
ezuce-admin committed Nov 20, 2012
2 parents 049075d + fcd8352 commit 4d8a783
Show file tree
Hide file tree
Showing 54 changed files with 1,463 additions and 1,134 deletions.
9 changes: 8 additions & 1 deletion Makefile
Expand Up @@ -51,6 +51,12 @@ OALOGDIR=$(VARDIR)/log/openacd
OADBDIR=$(OAVARDIR)/db
OAPLUGINDIR=$(OADIR)/plugin.d

ifdef PREFIX
OPENACD_PREFIX=$(PREFIX)
else
OPENACD_PREFIX=/
endif

all: deps compile

deps:
Expand Down Expand Up @@ -90,6 +96,7 @@ install: compile
sed \
-e 's|%LOG_DIR%|$(OALOGDIR)|g' \
-e 's|%PLUGIN_DIR%|$(PREFIX)$(OAPLUGINDIR)|g' \
-e 's|%KEY_DIR%|$(PREFIX)$(OACONFIGDIR)|g' \
./config/app.config > $(DESTDIR)$(PREFIX)$(OACONFIGDIR)/app.config
sed \
-e 's|%DB_DIR%|$(PREFIX)$(OADBDIR)|g' \
Expand All @@ -100,7 +107,7 @@ install: compile
## Bin
#dont use DESTDIR in sed here;this is a hack to not get "rpmbuild found in installed files"
sed \
-e 's|%OPENACD_PREFIX%|"$(PREFIX)"|g' \
-e 's|%OPENACD_PREFIX%|"$(OPENACD_PREFIX)"|g' \
-e 's|%LIB_DIR%|$(libdir)|g' \
./scripts/openacd > $(DESTDIR)$(PREFIX)$(OABINDIR)/openacd
chmod +x $(DESTDIR)$(PREFIX)$(OABINDIR)/openacd
Expand Down
3 changes: 2 additions & 1 deletion config/app.config
Expand Up @@ -3,7 +3,8 @@
{logfiles, [
{"%LOG_DIR%/openacd.log", info}
]},
{plugin_dir, "%PLUGIN_DIR%"}
{plugin_dir, "%PLUGIN_DIR%"},
{rsakey, "%KEY_DIR%/key"}
]},
{sasl, [
{errlog_type, error} % disable SASL progress reports
Expand Down
Binary file modified rebar
Binary file not shown.
4 changes: 2 additions & 2 deletions rebar.config
Expand Up @@ -5,10 +5,10 @@
{deps, [
{meck, "0.7.2", {git, "git://github.com/eproxus/meck.git", "master"}},
{protobuffs, "0.6.0", {git, "http://github.com/lordnull/erlang_protobuffs.git", "master"}},
{errd, "0.1", {git, "https://github.com/Vagabond/errd.git", {tag, "8562fce3778318b0edda"}}},
{errd, "0.1", {git, "https://github.com/dannaaduna/errd.git", "master"}},
{gen_smtp, "0.1", {git, "https://github.com/Vagabond/gen_smtp.git", {tag,
"0558786233ca152064770d3d6848e7ae3745f8a1"}}},
{gen_leader, "1.0", {git, "https://github.com/Vagabond/gen_leader_revival.git", {tag, "6e563e111d7803c9e82a"}}},
{gen_leader, "1.0", {git, "https://github.com/dannaaduna/gen_leader_revival.git", "master"}},
% {mochiweb, "1.3", {git, "http://github.com/mochi/mochiweb.git", {tag, "9396655c6f253863b6ce"}}},
{mochiweb, "2.3.0", {git, "http://github.com/mochi/mochiweb.git", {tag, "v2.3.0"}}},
{gen_server_mock, "0.0.5", {git, "http://github.com/lordnull/gen_server_mock.git", {branch, "master"}}},
Expand Down
13 changes: 8 additions & 5 deletions src/agent.erl
Expand Up @@ -367,20 +367,24 @@ handle_sync_event({set_connection, Pid}, _From, StateName, #state{agent_rec = #a
agent_channel:set_connection(ChanPid, Pid),
V
end, Agent#agent.used_channels),
NewAgent = Agent#agent{connection = Pid},
case erlang:function_exported(cpx_supervisor, get_value, 1) of
true ->
case cpx_supervisor:get_value(motd) of
{ok, Motd} ->
gen_server:cast(Pid, {blab, Motd});
inform_connection(NewAgent, {blab, Motd});
_ ->
ok
end;
false ->
ok
end,
Newagent = Agent#agent{connection = Pid},
inform_connection(Agent, {set_release, Agent#agent.release_data}),
{reply, ok, StateName, State#state{agent_rec = Newagent}};
R = case Agent#agent.release_data of
undefined -> none;
O -> O
end,
inform_connection(NewAgent, {set_release, R}),
{reply, ok, StateName, State#state{agent_rec = NewAgent}};

handle_sync_event(dump_state, _From, StateName, #state{agent_rec = Agent} = State) ->
{reply, Agent, StateName, State};
Expand All @@ -407,7 +411,6 @@ handle_sync_event({change_profile, Profile}, _From, StateName, #state{agent_rec
{login, Newagent#agent.login},
{skills, Newagent#agent.skills}
],
gen_server:cast(Agent#agent.connection, {change_profile, Profile}),
cpx_agent_event:change_agent(Agent, Newagent),
cpx_monitor:set({agent, Agent#agent.id}, Deatils),
inform_connection(Agent, {change_profile, Profile}),
Expand Down
40 changes: 20 additions & 20 deletions src/agent_auth.erl
Expand Up @@ -14,7 +14,7 @@
%%
%% The Original Code is OpenACD.
%%
%% The Initial Developers of the Original Code is
%% The Initial Developers of the Original Code is
%% Andrew Thompson and Micah Warren.
%%
%% All portions of the code written by the Initial Developers are Copyright
Expand All @@ -28,9 +28,9 @@
%%

%% @doc Connection to the local authenication cache and integration to
%% another module. Authentication is first checked by the integration
%% module (if any). If that fails, this module will fall back to it's
%% local cache in the mnesia 'agent_auth' table. The cache table is both
%% another module. Authentication is first checked by the integration
%% module (if any). If that fails, this module will fall back to it's
%% local cache in the mnesia 'agent_auth' table. The cache table is both
%% ram and disc copies on all nodes.
%%
%% == Hooks ==
Expand Down Expand Up @@ -99,7 +99,7 @@
%%
%% === auth_agent_success ===
%%
%% Asynchronously triggers all hooks when an agent is successfully
%% Asynchronously triggers all hooks when an agent is successfully
%% authenticated.
%%
%% Args :: [Username :: string(), Password :: string(),
Expand Down Expand Up @@ -172,7 +172,7 @@ start() ->
end,
Store:start().

%% @doc Add `#release_opt{} Rec' to the database.
%% @doc Add `#release_opt{} Rec' to the database.
-spec(new_release/1 :: (Rec :: #release_opt{}) -> {'atomic', 'ok'} | {'aborted', any()}).
new_release(Rec) when is_record(Rec, release_opt) ->
case cpx_hooks:trigger_hooks(new_release, [Rec], first) of
Expand All @@ -185,7 +185,7 @@ new_release(Rec) when is_record(Rec, release_opt) ->
destroy_release(Label) when is_list(Label) ->
destroy_release(label, Label).

%% @doc Remove the release option with the key (id, label) of value from the
%% @doc Remove the release option with the key (id, label) of value from the
%% database.
-spec(destroy_release/2 :: (Key :: 'id' | 'label', Value :: pos_integer() | string()) -> {'atomic', 'ok'} | {'aborted', any()}).
destroy_release(Type, Val) ->
Expand Down Expand Up @@ -314,8 +314,8 @@ set_agent(Id, Newlogin, Newskills, NewSecurity, Newprofile) ->
],
set_agent(Id, Props).

%% @doc Sets the agent `string() Oldlogin' with new data in `proplist Props';
%% does not change data that is not in the proplist. The proplist's
%% @doc Sets the agent `string() Oldlogin' with new data in `proplist Props';
%% does not change data that is not in the proplist. The proplist's
%% `endpoints' field can also contain a partial list, preserving existing
%% settings.
-spec(set_agent/2 :: (Oldlogin :: string(), Props :: [{atom(), any()}]) -> {'atomic', 'ok'} | {'aborted', any()}).
Expand All @@ -325,7 +325,7 @@ set_agent(Id, Props) ->
{error, Err} -> {aborted, Err}
end.

%% @doc Update the agent `string() Oldlogin' with a new password (as well
%% @doc Update the agent `string() Oldlogin' with a new password (as well
%% as everything else).
%% @deprecated Use {@link set_agent/2} instead.
-spec(set_agent/6 :: (Oldlogin :: string(), Newlogin :: string(), Newpass :: string(), Newskills :: [atom()], NewSecurity :: security_level(), Newprofile :: string()) -> {'atomic', 'error'} | {'atomic', 'ok'}).
Expand All @@ -339,7 +339,7 @@ set_agent(Id, Newlogin, Newpass, Newskills, NewSecurity, Newprofile) ->
],
set_agent(Id, Props).

%% @doc Update the agent `string() Oldlogin' with a new password (as well
%% @doc Update the agent `string() Oldlogin' with a new password (as well
%% as everything else).
%% @deprecated Use {@link set_agent/2} instead.
-spec(set_agent/8 :: (Oldlogin :: string(), Newlogin :: string(), Newpass :: string(), Newskills :: [atom()], NewSecurity :: security_level(), Newprofile :: string(), Newfirstname :: string(), Newlastname :: string()) -> {'atomic', 'error'} | {'atomic', 'ok'}).
Expand Down Expand Up @@ -429,7 +429,7 @@ drop_extended_prop({_, _} = U, Prop) ->
{error, unhandled} -> {error, noagent}
end.

%% @doc Get an extened property either from the database or a record
%% @doc Get an extened property either from the database or a record
%% directly.
-spec(get_extended_prop/2 :: (Key :: {'login' | 'id', string()}, Prop :: atom()) -> {'ok', any()} | {'error', 'noagent'} | 'undefined').
get_extended_prop({_, _} = U, Prop) ->
Expand All @@ -439,7 +439,7 @@ get_extended_prop({_, _} = U, Prop) ->
{error, unhandled} -> {error, noagent}
end.

%% @doc Take the plaintext username and password and attempt to
%% @doc Take the plaintext username and password and attempt to
%% authenticate the agent.
-type(profile_name() :: string()).
-spec(auth/2 :: (Username :: string(), Password :: string()) -> 'deny' | {'allow', string(), skill_list(), security_level(), profile_name()}).
Expand All @@ -456,12 +456,12 @@ auth(Username, Password) ->
%%% Internal functions
%%--------------------------------------------------------------------

%% @doc adds a user to the local cache bypassing the integrated at check.
%% Note that unlike {@link cache/4} this expects the password in plain
%% @doc adds a user to the local cache bypassing the integrated at check.
%% Note that unlike {@link cache/4} this expects the password in plain
%% text!
%% @deprecated Please use {@link add_agent/1} instead.
-spec(add_agent/5 ::
(Username :: string(), Password :: string(), Skills :: [atom()], Security :: 'admin' | 'agent' | 'supervisor', Profile :: string()) ->
-spec(add_agent/5 ::
(Username :: string(), Password :: string(), Skills :: [atom()], Security :: 'admin' | 'agent' | 'supervisor', Profile :: string()) ->
{'atomic', 'ok'}).
add_agent(Username, Password, Skills, Security, Profile) ->
Rec = #agent_auth{
Expand All @@ -472,8 +472,8 @@ add_agent(Username, Password, Skills, Security, Profile) ->
profile = Profile},
add_agent(Rec).

%% @doc adds a user to the local cache bypassing the integrated at check.
%% Note that unlike {@link cache/4} this expects the password in plain
%% @doc adds a user to the local cache bypassing the integrated at check.
%% Note that unlike {@link cache/4} this expects the password in plain
%% text!
%% @deprecated Please use {@link add_agent/1} instead.
-spec(add_agent/7 ::
Expand Down Expand Up @@ -521,7 +521,7 @@ destroy(Key, Value) ->
-spec(sort_profiles/1 :: (List :: [#agent_profile{}]) -> [#agent_profile{}]).
sort_profiles(List) ->
lists:sort(fun comp_profiles/2, List).

comp_profiles(#agent_profile{name = Aname, order = S}, #agent_profile{name = Bname, order = S}) ->
Aname =< Bname;
comp_profiles(#agent_profile{order = Asort}, #agent_profile{order = Bsort}) ->
Expand Down

0 comments on commit 4d8a783

Please sign in to comment.