Skip to content

Commit

Permalink
Dialyzer updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kalta committed Jul 24, 2014
1 parent b351487 commit 05281eb
Show file tree
Hide file tree
Showing 23 changed files with 159 additions and 167 deletions.
55 changes: 28 additions & 27 deletions include/nksip.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -204,33 +204,6 @@
}).


%% Meta current uses:
%% - {nksip_min_se, MinSE}

-record(dialog, {
id :: nksip_dialog_lib:id(),
app_id :: nksip:app_id(),
call_id :: nksip:call_id(),
created :: nksip_lib:timestamp(),
updated :: nksip_lib:timestamp(),
local_seq :: 0 | nksip:cseq(),
remote_seq :: 0 | nksip:cseq(),
local_uri :: nksip:uri(),
remote_uri :: nksip:uri(),
local_target :: nksip:uri(), % Only for use in proxy
remote_target :: nksip:uri(),
route_set :: [nksip:uri()],
blocked_route_set :: boolean(),
early :: boolean(),
secure :: boolean(),
caller_tag :: nksip:tag(),
invite :: nksip:invite(),
subscriptions = [] :: [nksip:subscription()],
supported = [] :: [nksip:token()],
meta = [] :: nksip:optslist()
}).


-record(invite, {
status :: nksip_dialog:invite_status(),
answered :: nksip_lib:timestamp(),
Expand Down Expand Up @@ -263,6 +236,34 @@
}).


%% Meta current uses:
%% - {nksip_min_se, MinSE}

-record(dialog, {
id :: nksip_dialog_lib:id(),
app_id :: nksip:app_id(),
call_id :: nksip:call_id(),
created :: nksip_lib:timestamp(),
updated :: nksip_lib:timestamp(),
local_seq :: 0 | nksip:cseq(),
remote_seq :: 0 | nksip:cseq(),
local_uri :: nksip:uri(),
remote_uri :: nksip:uri(),
local_target :: nksip:uri(), % Only for use in proxy
remote_target :: nksip:uri(),
route_set :: [nksip:uri()],
blocked_route_set :: boolean(),
early :: boolean(),
secure :: boolean(),
caller_tag :: nksip:tag(),
invite :: nksip:invite(),
subscriptions = [] :: [#subscription{}],
supported = [] :: [nksip:token()],
meta = [] :: nksip:optslist()
}).



-record(sdp_m, {
media :: binary(), % <<"audio">>, ...
port = 0 :: inet:port_number(),
Expand Down
2 changes: 1 addition & 1 deletion plugins/src/nksip_100rel_callbacks.erl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ nkcb_parse_uas_opt(Req, Resp, Opts) ->


%% @doc Called when a new reponse is going to be sent
-spec nkcb_uas_send_reply({nksip:response(), nksip:optlist()},
-spec nkcb_uas_send_reply({nksip:response(), nksip:optslist()},
nksip_call:trans(), nksip_call:call()) ->
{continue, list()} | {error, term()}.

Expand Down
2 changes: 1 addition & 1 deletion plugins/src/nksip_event_compositor_callbacks.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
%% @private This plugin callback is called when a call to one of the method specific
%% application-level SipApp callbacks is needed.
-spec nkcb_sip_method(nksip_call:trans(), nksip_call:call()) ->
{reply, nksip:sip_reply()} | noreply.
{reply, nksip:sipreply()} | noreply.


nkcb_sip_method(#trans{method='PUBLISH', request=Req}, #call{app_id=AppId}) ->
Expand Down
2 changes: 1 addition & 1 deletion plugins/src/nksip_refer_callbacks.erl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ nkcb_parse_uac_opts(Req, Opts) ->
%% @private This plugin callback is called when a call to one of the method specific
%% application-level SipApp callbacks is needed.
-spec nkcb_sip_method(nksip_call:trans(), nksip_call:call()) ->
{reply, nksip:sip_reply()} | noreply.
{reply, nksip:sipreply()} | noreply.

nkcb_sip_method(#trans{method='REFER', request=Req}, #call{app_id=AppId}=Call) ->
Module = AppId:module(),
Expand Down
2 changes: 1 addition & 1 deletion plugins/src/nksip_registrar_callbacks.erl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
%% @private This plugin callback is called when a call to one of the method specific
%% application-level SipApp callbacks is needed.
-spec nkcb_sip_method(nksip_call:trans(), nksip_call:call()) ->
{reply, nksip:sip_reply()} | noreply.
{reply, nksip:sipreply()} | noreply.


nkcb_sip_method(#trans{method='REGISTER', request=Req}, #call{app_id=AppId}) ->
Expand Down
6 changes: 3 additions & 3 deletions plugins/src/nksip_timers_callbacks.erl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ nkcb_make_uac_dialog(Method, Uri, Opts, #call{dialogs=[Dialog|_]}=Call) ->


%% @doc Called when the UAC is preparing a request to be sent
-spec nkcb_uac_pre_request(nksip:request(), nksip:optlist(),
-spec nkcb_uac_pre_request(nksip:request(), nksip:optslist(),
nksip_call_uac:uac_from(), nksip:call()) ->
{continue, list()}.

Expand Down Expand Up @@ -186,7 +186,7 @@ nkcb_uac_response(Req, Resp, UAC, Call) ->

%% @doc Called when preparing a UAS dialog response
-spec nkcb_uas_dialog_response(nksip:request(), nksip:response(),
nksip:optlist(), nksip:call()) ->
nksip:optslist(), nksip:call()) ->
{ok, nksip:response(), nksip:optslist()} | continue.

nkcb_uas_dialog_response(Req, Resp, Opts, Call) ->
Expand All @@ -202,7 +202,7 @@ nkcb_uas_dialog_response(Req, Resp, Opts, Call) ->


%% @doc Called when the UAS is proceesing a request
-spec nkcb_uas_process(nksip_trans:trans(), nksip_call:call()) ->
-spec nkcb_uas_process(nksip_call:trans(), nksip_call:call()) ->
{ok, nksip:call()} | {continue, list()}.

nkcb_uas_process(#trans{request=Req}=UAS, Call) ->
Expand Down
8 changes: 4 additions & 4 deletions src/nksip_auth.erl
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ realms(#sipmsg{headers=Headers}) ->
get_realms(Headers, []);

realms(RespId) ->
{ok, Hd1} = case nksip_response:header(RespId, ?RESP_WWW) of
WWW when is_list(WWW) -> [{?RESP_WWW, Data} || Data <- WWW];
Hd1 = case nksip_response:header(RespId, ?RESP_WWW) of
{ok, WWW} when is_list(WWW) -> [{?RESP_WWW, Data} || Data <- WWW];
_ -> []
end,
{ok, Hd2} = case nksip_response:header(RespId, ?RESP_PROXY) of
Proxy when is_list(Proxy) -> [{?RESP_PROXY, Data} || Data <- Proxy];
Hd2 = case nksip_response:header(RespId, ?RESP_PROXY) of
{ok, Proxy} when is_list(Proxy) -> [{?RESP_PROXY, Data} || Data <- Proxy];
_ -> []
end,
get_realms(Hd1++Hd2, []).
Expand Down
14 changes: 7 additions & 7 deletions src/nksip_call.erl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

-type trans() :: #trans{}.

-type trans_id() :: binary().
-type trans_id() :: integer().

-type fork() :: #fork{}.

Expand Down Expand Up @@ -83,7 +83,7 @@ call_id(#call{call_id=CallId}) ->

%% @private Sends a new request.
-spec send(nksip:request(), nksip:optslist()) ->
nksip_uac:result() | nksip_uac:ack_result().
nksip_uac:uac_result() | nksip_uac:uac_ack_result().

send(#sipmsg{app_id=AppId, call_id=CallId}=Req, Opts) ->
nksip_router:send_work_sync(AppId, CallId, {send, Req, Opts}).
Expand All @@ -92,24 +92,24 @@ send(#sipmsg{app_id=AppId, call_id=CallId}=Req, Opts) ->
%% @private Generates and sends a new request.
-spec send(nksip:app_id(), nksip:call_id(), nksip:method(),
nksip:user_uri(), nksip:optslist()) ->
nksip_uac:result() | nksip_uac:ack_result().
nksip_uac:uac_result() | nksip_uac:uac_ack_result().

send(AppId, CallId, Method, Uri, Opts) ->
nksip_router:send_work_sync(AppId, CallId, {send, Method, Uri, Opts}).


%% @private Generates and sends a new in-dialog request.
-spec send_dialog(nksip:app_id(), nksip:call_id(), nksip:method(),
nksip_dialog:id(), nksip:optslist()) ->
nksip_uac:result() | nksip_uac:ack_result().
nksip_dialog_lib:id(), nksip:optslist()) ->
nksip_uac:uac_result() | nksip_uac:uac_ack_result().

send_dialog(AppId, CallId, Method, DialogId, Opts) ->
nksip_router:send_work_sync(AppId, CallId, {send_dialog, DialogId, Method, Opts}).


%% @private Cancels an ongoing INVITE request.
-spec send_cancel(nksip:app_id(), nksip:call_id(), nksip_sipmsg:id(),
nksip:optlist()) ->
nksip:optslist()) ->
nksip_uac:uac_cancel_result().

send_cancel(AppId, CallId, RequestId, Opts) ->
Expand Down Expand Up @@ -178,7 +178,7 @@ get_all_dialogs(AppId, CallId) ->


%% @private Deletes a dialog
-spec stop_dialog(nksip:app_id(), nksip:call_id(), nksip_dialog:id()) ->
-spec stop_dialog(nksip:app_id(), nksip:call_id(), nksip_dialog_lib:id()) ->
ok | {error, term()}.

stop_dialog(AppId, CallId, DialogId) ->
Expand Down
19 changes: 10 additions & 9 deletions src/nksip_call_event.erl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ uac_response(_Req, _Resp, Dialog, _Call) ->

%% @private
-spec uac_do_response(nksip:method(), nksip:sip_code(), nksip:request(),
nksip:response(), nksip:subscription(), nksip:dialog(),
nksip:response(), #subscription{}, nksip:dialog(),
nksip_call:call()) ->
nksip:dialog().

Expand Down Expand Up @@ -212,7 +212,7 @@ uas_response(_Req, _Resp, Dialog, _Call) ->

%% @private
-spec uas_do_response(nksip:method(), nksip:sip_code(), nksip:request(),
nksip:response(), nksip:subscription(), nksip:dialog(),
nksip:response(), #subscription{}, nksip:dialog(),
nksip_call:call()) ->
nksip:dialog().

Expand Down Expand Up @@ -256,7 +256,7 @@ uas_do_response(_, _Code, _Req, _Resp, _Subs, Dialog, _Call) ->


%% @private
-spec update(term(), nksip:subscription(), nksip:dialog(), nksip_call:call()) ->
-spec update(term(), #subscription{}, nksip:dialog(), nksip_call:call()) ->
nksip:dialog().

update({subscribe, #sipmsg{class={req, Method}}=Req, Resp}, Subs, Dialog, Call) ->
Expand Down Expand Up @@ -409,7 +409,7 @@ stop(#subscription{id=Id}, Dialog, Call) ->

%% @private
-spec request_uac_opts(nksip:method(), nksip:optslist(),
nksip:dialog() | nksip:subscription()) ->
nksip:dialog() | #subscription{}) ->
{ok, nksip:optslist()} | {error, unknown_subscription}.

request_uac_opts(Method, Opts, #dialog{}=Dialog) ->
Expand Down Expand Up @@ -455,7 +455,8 @@ request_uac_opts('NOTIFY', Opts, #subscription{event=Event, timer_expire=Timer})


%% @private Called when a dialog timer is fired
-spec timer({middle|timeout, nksip_subscription:id()}, nksip:dialog(), nksip_call:call()) ->
-spec timer({middle|timeout, nksip_subscription_lib:id()},
nksip:dialog(), nksip_call:call()) ->
nksip_call:call().

timer({Type, Id}, Dialog, Call) ->
Expand All @@ -479,7 +480,7 @@ timer({Type, Id}, Dialog, Call) ->

%% @private Creates a new event
-spec create(uac|uas, nksip:request(), nksip:dialog(), nksip_call:call()) ->
nksip:subscription().
#subscription{}.

create(Class, #sipmsg{class={req, Method}}=Req, Dialog, Call) ->
Event = case Method of
Expand Down Expand Up @@ -522,7 +523,7 @@ do_is_prov_event(Id, [_|Rest]) -> do_is_prov_event(Id, Rest).


%% @private Updates an updated event into dialog
-spec store(nksip:subscription(), nksip:dialog(), nksip_call:call()) ->
-spec store(#subscription{}, nksip:dialog(), nksip_call:call()) ->
nksip:dialog().

store(Subs, Dialog, _Call) ->
Expand Down Expand Up @@ -554,7 +555,7 @@ store(Subs, Dialog, _Call) ->


%% @private
-spec dialog_update(term(), nksip:subscription(), nksip:dialog(), nksip_call:call()) ->
-spec dialog_update(term(), #subscription{}, nksip:dialog(), nksip_call:call()) ->
ok.

dialog_update(Status, Subs, Dialog, #call{app_id=AppId}=Call) ->
Expand All @@ -572,7 +573,7 @@ cancel_timer(Ref) ->


%% @private
-spec start_timer(integer(), {atom(), nksip_subscription:id()}, nksip:dialog()) ->
-spec start_timer(integer(), {atom(), nksip_subscription_lib:id()}, nksip:dialog()) ->
reference().

start_timer(Time, Tag, #dialog{id=Id}) ->
Expand Down
10 changes: 5 additions & 5 deletions src/nksip_call_uac_dialog.erl
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ pre_request(Req, Call) ->
true ->
ok
end;
false ->
not_found ->
{error, unknown_dialog}
end.


%% @private
-spec request(nksip:request(), boolean(), nksip_call:call()) ->
-spec request(nksip:request(), true|false|undefined, nksip_call:call()) ->
nksip_call:call().

request(#sipmsg{class={req, 'ACK'}}=Req, _, Call) ->
request(#sipmsg{class={req, 'ACK'}}=Req, undefined, Call) ->
do_ack(Req, Call);

request(#sipmsg{class={req, Method}, dialog_id=DialogId}=Req, IsProxy, Call) ->
Expand Down Expand Up @@ -463,7 +463,7 @@ do_response(_, _Code, _Req, _Resp, Dialog, Call) ->


%% @private
-spec make(integer(), nksip:method(), nksip:optslist(), nksip_call:call()) ->
-spec make(nksip_dialog_lib:id(), nksip:method(), nksip:optslist(), nksip_call:call()) ->
{ok, RUri::nksip:uri(), nksip:optslist(), nksip_call:call()} | {error, Error}
when Error :: invalid_dialog | unknown_dialog | unknown_subscription.

Expand Down Expand Up @@ -564,7 +564,7 @@ get_sdp(#sipmsg{body=Body}, #invite{sdp_offer=Offer, sdp_answer=Answer}) ->

%% @private
-spec generate(nksip:method(), nksip:optslist(), nksip:dialog(), nksip_call:call()) ->
{{RUri, Opts}, nksip:dialog()}
{RUri, Opts, nksip:dialog()}
when RUri::nksip:uri(), Opts::nksip:optslist().

generate(Method, Opts, Dialog, _Call) ->
Expand Down
4 changes: 2 additions & 2 deletions src/nksip_call_uac_make.erl
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ do_remove_local_routes(AppId, [Route|RestRoutes]) ->


%% @doc Generates a <i>CANCEL</i> request from an <i>INVITE</i> request.
-spec make_cancel(nksip:request(), nksip:optlist()) ->
-spec make_cancel(nksip:request(), nksip:optslist()) ->
nksip:request().

make_cancel(Req, Opts) ->
Expand Down Expand Up @@ -438,7 +438,7 @@ parse_opts([Term|Rest], Req, Opts) ->
parse_opts(Rest, Req, Opts);
error when is_tuple(Term) ->
throw({invalid_config, element(1, Term)});
error_ ->
error ->
throw({invalid_config, Term})
end.

Expand Down
5 changes: 2 additions & 3 deletions src/nksip_call_uas.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@

-export([request/2, reply/3, do_reply/3]).
-export_type([status/0, incoming/0]).
-import(nksip_call_lib, [update/2]).


-import(nksip_call_lib, [update/2]).
-include("nksip.hrl").
-include("nksip_call.hrl").

Expand Down Expand Up @@ -229,7 +228,7 @@ process_request(Req, UASTransId, Call) ->
code = 0,
to_tags = [],
stateless = true,
iter = undefined,
iter = 1,
cancel = undefined,
loop_id = LoopId,
timeout_timer = undefined,
Expand Down
4 changes: 2 additions & 2 deletions src/nksip_call_uas_reply.erl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
%% ===================================================================

%% @doc Sends a transaction reply
-spec reply(nksip_uas:incoming(), nksip_call:trans(), nksip_call:call()) ->
-spec reply(nksip_call_uas:incoming(), nksip_call:trans(), nksip_call:call()) ->
{ok | {error, term()}, nksip_call:call()}.


Expand Down Expand Up @@ -84,7 +84,7 @@ reply(SipReply, #trans{id=Id, method=Method, status=Status}, Call) ->


%% @private
-spec send(nksip_uas:incoming(), nksip_call:trans(), nksip_call:call()) ->
-spec send(nksip_call_uas:incoming(), nksip_call:trans(), nksip_call:call()) ->
{ok, nksip_call:call()} | {error, term()}.

send({Resp, SendOpts}, UAS, Call) ->
Expand Down
1 change: 1 addition & 0 deletions src/nksip_call_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
{send, nksip:request(), nksip:optslist()} |
{send, nksip:method(), nksip:user_uri(), nksip:optslist()} |
{send_dialog, nksip_dialog_lib:id(), nksip:method(), nksip:optslist()} |
{send_cancel, nksip_sipmsg:id(), nksip:sipreply()} |
{cancel, nksip_sipmsg:id()} |
{send_reply, nksip_sipmsg:id(), nksip:sipreply()} |
{incoming, #sipmsg{}} |
Expand Down
Loading

0 comments on commit 05281eb

Please sign in to comment.