From c29a48695d3d46e556aea2ea3c5fb8b558d43f7c Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Thu, 8 Sep 2016 17:08:48 +0300 Subject: [PATCH] Rename #error{} record to #stanza_error{} --- include/xmpp_codec.hrl | 16 ++--- src/ejabberd_c2s.erl | 4 +- src/ejabberd_piefxis.erl | 2 +- src/ejabberd_router.erl | 4 +- src/ejabberd_s2s_in.erl | 2 +- src/ejabberd_s2s_out.erl | 6 +- src/ejabberd_service.erl | 2 +- src/gen_pubsub_node.erl | 2 +- src/mod_adhoc.erl | 8 +-- src/mod_announce.erl | 6 +- src/mod_blocking.erl | 16 ++--- src/mod_caps.erl | 4 +- src/mod_configure.erl | 10 ++-- src/mod_disco.erl | 16 ++--- src/mod_http_upload.erl | 2 +- src/mod_irc.erl | 2 +- src/mod_mix.erl | 2 +- src/mod_muc_room.erl | 32 +++++----- src/mod_multicast.erl | 2 +- src/mod_privacy.erl | 18 +++--- src/mod_pubsub.erl | 90 ++++++++++++++--------------- src/mod_vcard.erl | 12 ++-- src/xmpp.erl | 122 +++++++++++++++++++-------------------- src/xmpp_codec.erl | 18 +++--- tools/xmpp_codec.spec | 2 +- 25 files changed, 201 insertions(+), 199 deletions(-) diff --git a/include/xmpp_codec.hrl b/include/xmpp_codec.hrl index d2acf316c..635fcf3cb 100644 --- a/include/xmpp_codec.hrl +++ b/include/xmpp_codec.hrl @@ -829,13 +829,13 @@ xmlns = <<>> :: binary()}). -type sm_failed() :: #sm_failed{}. --record(error, {type :: 'auth' | 'cancel' | 'continue' | 'modify' | 'wait', - code :: non_neg_integer(), - by = <<>> :: binary(), - reason :: atom() | #gone{} | #redirect{}, - text :: #text{}, - sub_els = [] :: [xmpp_element() | fxml:xmlel()]}). --type error() :: #error{}. +-record(stanza_error, {type :: 'auth' | 'cancel' | 'continue' | 'modify' | 'wait', + code :: non_neg_integer(), + by = <<>> :: binary(), + reason :: atom() | #gone{} | #redirect{}, + text :: #text{}, + sub_els = [] :: [xmpp_element() | fxml:xmlel()]}). +-type stanza_error() :: #stanza_error{}. -record(mix_join, {jid :: jid:jid(), subscribe = [] :: [binary()]}). @@ -1042,7 +1042,7 @@ register() | sm_r() | stat_error() | - error() | + stanza_error() | stream_error() | muc_user() | vcard_adr() | diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index 9c1d99091..e658536ab 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -961,7 +961,7 @@ wait_for_bind(Pkt, StateData) -> end, fsm_next_state(wait_for_bind, StateData). --spec open_session(state()) -> {ok, state()} | {error, error()}. +-spec open_session(state()) -> {ok, state()} | {error, stanza_error()}. open_session(StateData) -> U = StateData#state.user, R = StateData#state.resource, @@ -1568,7 +1568,7 @@ send_element(StateData, #xmlel{} = El) -> send_element(StateData, Pkt) -> send_element(StateData, xmpp:encode(Pkt)). --spec send_error(state(), xmlel() | stanza(), error()) -> ok. +-spec send_error(state(), xmlel() | stanza(), stanza_error()) -> ok. send_error(StateData, Stanza, Error) -> Type = xmpp:get_type(Stanza), if Type == error; Type == result; diff --git a/src/ejabberd_piefxis.erl b/src/ejabberd_piefxis.erl index 6a2b5e644..7d7d01060 100644 --- a/src/ejabberd_piefxis.erl +++ b/src/ejabberd_piefxis.erl @@ -487,7 +487,7 @@ process_privacy(#privacy_query{lists = Lists, Txt = <<"No module is handling this query">>, Error = {error, xmpp:err_feature_not_implemented(Txt, ?MYLANG)}, case mod_privacy:process_iq_set(Error, IQ) of - {error, #error{reason = Reason}} = Err -> + {error, #stanza_error{reason = Reason}} = Err -> if Reason == 'item-not-found', Lists == [], Active == undefined, Default /= undefined -> %% Failed to set default list because there is no diff --git a/src/ejabberd_router.erl b/src/ejabberd_router.erl index d65edc6e3..db82f67ea 100644 --- a/src/ejabberd_router.erl +++ b/src/ejabberd_router.erl @@ -86,7 +86,7 @@ route(From, To, Packet) -> %% Route the error packet only if the originating packet is not an error itself. %% RFC3920 9.3.1 -spec route_error(jid(), jid(), xmlel(), xmlel()) -> ok; - (jid(), jid(), stanza(), error()) -> ok. + (jid(), jid(), stanza(), stanza_error()) -> ok. route_error(From, To, #xmlel{} = ErrPacket, #xmlel{} = OrigPacket) -> #xmlel{attrs = Attrs} = OrigPacket, @@ -94,7 +94,7 @@ route_error(From, To, #xmlel{} = ErrPacket, #xmlel{} = OrigPacket) -> false -> route(From, To, ErrPacket); true -> ok end; -route_error(From, To, Packet, #error{} = Err) -> +route_error(From, To, Packet, #stanza_error{} = Err) -> Type = xmpp:get_type(Packet), if Type == error; Type == result -> ok; diff --git a/src/ejabberd_s2s_in.erl b/src/ejabberd_s2s_in.erl index 7be4906fb..fd560a451 100644 --- a/src/ejabberd_s2s_in.erl +++ b/src/ejabberd_s2s_in.erl @@ -541,7 +541,7 @@ send_element(StateData, El) -> El1 = fix_ns(xmpp:encode(El)), send_text(StateData, fxml:element_to_binary(El1)). --spec send_error(state(), xmlel() | stanza(), error()) -> ok. +-spec send_error(state(), xmlel() | stanza(), stanza_error()) -> ok. send_error(StateData, Stanza, Error) -> Type = xmpp:get_type(Stanza), if Type == error; Type == result; diff --git a/src/ejabberd_s2s_out.erl b/src/ejabberd_s2s_out.erl index 4284f7f7b..dd37445d7 100644 --- a/src/ejabberd_s2s_out.erl +++ b/src/ejabberd_s2s_out.erl @@ -785,13 +785,13 @@ fix_ns(El) -> El. %% Bounce a single message (xmlelement) --spec bounce_element(stanza(), error()) -> ok. +-spec bounce_element(stanza(), stanza_error()) -> ok. bounce_element(El, Error) -> From = xmpp:get_from(El), To = xmpp:get_to(El), ejabberd_router:route_error(To, From, El, Error). --spec bounce_queue(queue:queue(), error()) -> ok. +-spec bounce_queue(queue:queue(), stanza_error()) -> ok. bounce_queue(Q, Error) -> case queue:out(Q) of {{value, El}, Q1} -> @@ -807,7 +807,7 @@ cancel_timer(Timer) -> erlang:cancel_timer(Timer), receive {timeout, Timer, _} -> ok after 0 -> ok end. --spec bounce_messages(error()) -> ok. +-spec bounce_messages(stanza_error()) -> ok. bounce_messages(Error) -> receive {send_element, El} -> diff --git a/src/ejabberd_service.erl b/src/ejabberd_service.erl index 3df39438a..002d74949 100644 --- a/src/ejabberd_service.erl +++ b/src/ejabberd_service.erl @@ -308,7 +308,7 @@ send_element(StateData, El) -> El1 = fix_ns(xmpp:encode(El)), send_text(StateData, fxml:element_to_binary(El1)). --spec send_error(state(), xmlel() | stanza(), error()) -> ok. +-spec send_error(state(), xmlel() | stanza(), stanza_error()) -> ok. send_error(StateData, Stanza, Error) -> Type = xmpp:get_type(Stanza), if Type == error; Type == result; diff --git a/src/gen_pubsub_node.erl b/src/gen_pubsub_node.erl index cc94ea147..5690c8a1d 100644 --- a/src/gen_pubsub_node.erl +++ b/src/gen_pubsub_node.erl @@ -178,7 +178,7 @@ -callback get_items(nodeIdx(), jid(), accessModel(), boolean(), boolean(), binary(), undefined | rsm_set()) -> - {result, {[pubsubItem()], undefined | rsm_set()}} | {error, error()}. + {result, {[pubsubItem()], undefined | rsm_set()}} | {error, stanza_error()}. -callback get_items(nodeIdx(), jid(), undefined | rsm_set()) -> {result, {[pubsubItem()], undefined | rsm_set()}}. diff --git a/src/mod_adhoc.erl b/src/mod_adhoc.erl index e6d94e40a..5b582d82b 100644 --- a/src/mod_adhoc.erl +++ b/src/mod_adhoc.erl @@ -173,9 +173,9 @@ get_sm_identity(Acc, _From, _To, ?NS_COMMANDS, Lang) -> get_sm_identity(Acc, _From, _To, _Node, _Lang) -> Acc. %------------------------------------------------------------------------- --spec get_local_features({error, error()} | {result, [binary()]} | empty, +-spec get_local_features({error, stanza_error()} | {result, [binary()]} | empty, jid(), jid(), binary(), binary()) -> - {error, error()} | {result, [binary()]} | empty. + {error, stanza_error()} | {result, [binary()]} | empty. get_local_features(Acc, _From, _To, <<"">>, _Lang) -> Feats = case Acc of {result, I} -> I; @@ -238,7 +238,7 @@ process_adhoc_request(#iq{from = From, to = To, process_adhoc_request(#iq{} = IQ, _Hooks) -> xmpp:make_error(IQ, xmpp:err_bad_request()). --spec ping_item(empty | {error, error()} | {result, [disco_item()]}, +-spec ping_item(empty | {error, stanza_error()} | {result, [disco_item()]}, jid(), jid(), binary()) -> {result, [disco_item()]}. ping_item(Acc, _From, #jid{server = Server} = _To, Lang) -> @@ -252,7 +252,7 @@ ping_item(Acc, _From, #jid{server = Server} = _To, {result, Items ++ Nodes}. -spec ping_command(adhoc_command(), jid(), jid(), adhoc_command()) -> - adhoc_command() | {error, error()}. + adhoc_command() | {error, stanza_error()}. ping_command(_Acc, _From, _To, #adhoc_command{lang = Lang, node = <<"ping">>, action = Action} = Request) -> diff --git a/src/mod_announce.erl b/src/mod_announce.erl index eb201fc88..d9209f418 100644 --- a/src/mod_announce.erl +++ b/src/mod_announce.erl @@ -336,8 +336,8 @@ disco_items(Acc, From, #jid{lserver = LServer} = _To, Node, Lang) -> end. %%------------------------------------------------------------------------- --spec announce_items(empty | {error, error()} | {result, [disco_item()]}, - jid(), jid(), binary()) -> {error, error()} | +-spec announce_items(empty | {error, stanza_error()} | {result, [disco_item()]}, + jid(), jid(), binary()) -> {error, stanza_error()} | {result, [disco_item()]} | empty. announce_items(Acc, From, #jid{lserver = LServer, server = Server} = _To, Lang) -> @@ -386,7 +386,7 @@ commands_result(Allow, From, To, Request) -> end. -spec announce_commands(adhoc_command(), jid(), jid(), adhoc_command()) -> - adhoc_command() | {error, error()}. + adhoc_command() | {error, stanza_error()}. announce_commands(Acc, From, #jid{lserver = LServer} = To, #adhoc_command{node = Node} = Request) -> LNode = tokenize(Node), diff --git a/src/mod_blocking.erl b/src/mod_blocking.erl index 98fb1e441..55e3ca151 100644 --- a/src/mod_blocking.erl +++ b/src/mod_blocking.erl @@ -72,19 +72,19 @@ depends(_Host, _Opts) -> process_iq(IQ) -> xmpp:make_error(IQ, xmpp:err_not_allowed()). --spec process_iq_get({error, error()} | {result, xmpp_element() | undefined}, +-spec process_iq_get({error, stanza_error()} | {result, xmpp_element() | undefined}, iq(), userlist()) -> - {error, error()} | {result, block_list()}. + {error, stanza_error()} | {result, block_list()}. process_iq_get(_, #iq{lang = Lang, from = From, sub_els = [#block_list{}]}, _) -> #jid{luser = LUser, lserver = LServer} = From, {stop, process_blocklist_get(LUser, LServer, Lang)}; process_iq_get(Acc, _, _) -> Acc. --spec process_iq_set({error, error()} | +-spec process_iq_set({error, stanza_error()} | {result, xmpp_element() | undefined} | {result, xmpp_element() | undefined, userlist()}, - iq()) -> {error, error()} | + iq()) -> {error, stanza_error()} | {result, undefined} | {result, undefined, userlist()}. process_iq_set(_, #iq{from = From, lang = Lang, sub_els = [SubEl]}) -> @@ -136,7 +136,7 @@ list_to_blocklist_jids([_ | Items], JIDs) -> -spec process_blocklist_block(binary(), binary(), [ljid()], binary()) -> - {error, error()} | + {error, stanza_error()} | {result, undefined, userlist()}. process_blocklist_block(LUser, LServer, JIDs, Lang) -> Filter = fun (List) -> @@ -171,7 +171,7 @@ process_blocklist_block(LUser, LServer, JIDs, Lang) -> end. -spec process_blocklist_unblock_all(binary(), binary(), binary()) -> - {error, error()} | + {error, stanza_error()} | {result, undefined} | {result, undefined, userlist()}. process_blocklist_unblock_all(LUser, LServer, Lang) -> @@ -195,7 +195,7 @@ process_blocklist_unblock_all(LUser, LServer, Lang) -> end. -spec process_blocklist_unblock(binary(), binary(), [ljid()], binary()) -> - {error, error()} | + {error, stanza_error()} | {result, undefined} | {result, undefined, userlist()}. process_blocklist_unblock(LUser, LServer, JIDs, Lang) -> @@ -240,7 +240,7 @@ broadcast_blocklist_event(LUser, LServer, Event) -> {broadcast, {blocking, Event}}). -spec process_blocklist_get(binary(), binary(), binary()) -> - {error, error()} | {result, block_list()}. + {error, stanza_error()} | {result, block_list()}. process_blocklist_get(LUser, LServer, Lang) -> Mod = db_mod(LServer), case Mod:process_blocklist_get(LUser, LServer) of diff --git a/src/mod_caps.erl b/src/mod_caps.erl index a388b085f..ae11ab651 100644 --- a/src/mod_caps.erl +++ b/src/mod_caps.erl @@ -158,10 +158,10 @@ caps_stream_features(Acc, MyHost) -> [#caps{hash = <<"sha-1">>, node = ?EJABBERD_URI, version = Hash}|Acc] end. --spec disco_features({error, error()} | {result, [binary()]} | empty, +-spec disco_features({error, stanza_error()} | {result, [binary()]} | empty, jid(), jid(), binary(), binary()) -> - {error, error()} | {result, [binary()]} | empty. + {error, stanza_error()} | {result, [binary()]} | empty. disco_features(Acc, From, To, Node, Lang) -> case is_valid_node(Node) of true -> diff --git a/src/mod_configure.erl b/src/mod_configure.erl index a798d010f..dd361028b 100644 --- a/src/mod_configure.erl +++ b/src/mod_configure.erl @@ -270,8 +270,8 @@ get_local_features(Acc, From, end. %%%----------------------------------------------------------------------- --spec adhoc_sm_items(empty | {error, error()} | {result, [disco_item()]}, - jid(), jid(), binary()) -> {error, error()} | +-spec adhoc_sm_items(empty | {error, stanza_error()} | {result, [disco_item()]}, + jid(), jid(), binary()) -> {error, stanza_error()} | {result, [disco_item()]} | empty. adhoc_sm_items(Acc, From, #jid{lserver = LServer} = To, @@ -325,8 +325,8 @@ get_user_resources(User, Server) -> %%%----------------------------------------------------------------------- --spec adhoc_local_items(empty | {error, error()} | {result, [disco_item()]}, - jid(), jid(), binary()) -> {error, error()} | +-spec adhoc_local_items(empty | {error, stanza_error()} | {result, [disco_item()]}, + jid(), jid(), binary()) -> {error, stanza_error()} | {result, [disco_item()]} | empty. adhoc_local_items(Acc, From, @@ -773,7 +773,7 @@ get_stopped_nodes(_Lang) -> end). -spec adhoc_local_commands(adhoc_command(), jid(), jid(), adhoc_command()) -> - adhoc_command() | {error, error()}. + adhoc_command() | {error, stanza_error()}. adhoc_local_commands(Acc, From, #jid{lserver = LServer} = To, #adhoc_command{node = Node, lang = Lang} = Request) -> diff --git a/src/mod_disco.erl b/src/mod_disco.erl index e33241928..953d1da10 100644 --- a/src/mod_disco.erl +++ b/src/mod_disco.erl @@ -198,9 +198,9 @@ get_local_identity(Acc, _From, _To, <<"">>, _Lang) -> get_local_identity(Acc, _From, _To, _Node, _Lang) -> Acc. --spec get_local_features({error, error()} | {result, [binary()]} | empty, +-spec get_local_features({error, stanza_error()} | {result, [binary()]} | empty, jid(), jid(), binary(), binary()) -> - {error, error()} | {result, [binary()]}. + {error, stanza_error()} | {result, [binary()]}. get_local_features({error, _Error} = Acc, _From, _To, _Node, _Lang) -> Acc; @@ -222,10 +222,10 @@ get_local_features(Acc, _From, _To, _Node, Lang) -> {error, xmpp:err_item_not_found(Txt, Lang)} end. --spec get_local_services({error, error()} | {result, [disco_item()]} | empty, +-spec get_local_services({error, stanza_error()} | {result, [disco_item()]} | empty, jid(), jid(), binary(), binary()) -> - {error, error()} | {result, [disco_item()]}. + {error, stanza_error()} | {result, [disco_item()]}. get_local_services({error, _Error} = Acc, _From, _To, _Node, _Lang) -> Acc; @@ -296,10 +296,10 @@ process_sm_iq_items(#iq{type = get, lang = Lang, xmpp:make_error(IQ, xmpp:err_subscription_required(Txt, Lang)) end. --spec get_sm_items({error, error()} | {result, [disco_item()]} | empty, +-spec get_sm_items({error, stanza_error()} | {result, [disco_item()]} | empty, jid(), jid(), binary(), binary()) -> - {error, error()} | {result, [disco_item()]}. + {error, stanza_error()} | {result, [disco_item()]}. get_sm_items({error, _Error} = Acc, _From, _To, _Node, _Lang) -> Acc; @@ -383,9 +383,9 @@ get_sm_identity(Acc, _From, _ -> [] end. --spec get_sm_features({error, error()} | {result, [binary()]} | empty, +-spec get_sm_features({error, stanza_error()} | {result, [binary()]} | empty, jid(), jid(), binary(), binary()) -> - {error, error()} | {result, [binary()]}. + {error, stanza_error()} | {result, [binary()]}. get_sm_features(empty, From, To, _Node, Lang) -> #jid{luser = LFrom, lserver = LSFrom} = From, #jid{luser = LTo, lserver = LSTo} = To, diff --git a/src/mod_http_upload.erl b/src/mod_http_upload.erl index babdbb7b6..f1f5d8173 100644 --- a/src/mod_http_upload.erl +++ b/src/mod_http_upload.erl @@ -601,7 +601,7 @@ create_slot(#state{service_url = undefined, {ok, [UserStr, RandStr, FileStr]}; deny -> {error, xmpp:err_service_unavailable()}; - #error{} = Error -> + #stanza_error{} = Error -> {error, Error} end; create_slot(#state{service_url = ServiceURL}, diff --git a/src/mod_irc.erl b/src/mod_irc.erl index a833287c8..fefebcfa3 100644 --- a/src/mod_irc.erl +++ b/src/mod_irc.erl @@ -679,7 +679,7 @@ adhoc_join(From, To, #adhoc_command{lang = Lang, xdata = X} = Request) -> end. -spec adhoc_register(binary(), jid(), jid(), adhoc_command()) -> - adhoc_command() | {error, error()}. + adhoc_command() | {error, stanza_error()}. adhoc_register(_ServerHost, _From, _To, #adhoc_command{action = cancel} = Request) -> xmpp_util:make_adhoc_response(Request, #adhoc_command{status = canceled}); diff --git a/src/mod_mix.erl b/src/mod_mix.erl index 52a3c8ed8..f39408210 100644 --- a/src/mod_mix.erl +++ b/src/mod_mix.erl @@ -52,7 +52,7 @@ stop(Host) -> supervisor:delete_child(ejabberd_sup, Proc), ok. --spec disco_features({error, error()} | {result, [binary()]} | empty, +-spec disco_features({error, stanza_error()} | {result, [binary()]} | empty, jid(), jid(), binary(), binary()) -> {result, [binary()]}. disco_features(_Acc, _From, _To, _Node, _Lang) -> {result, [?NS_MIX_0]}. diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl index 2f2962b97..c32551091 100644 --- a/src/mod_muc_room.erl +++ b/src/mod_muc_room.erl @@ -1136,8 +1136,8 @@ decide_fate_message(_, _, _) -> continue_delivery. %% Check if the elements of this error stanza indicate %% that the sender is a dead participant. %% If so, return true to kick the participant. --spec check_error_kick(error()) -> boolean(). -check_error_kick(#error{reason = Reason}) -> +-spec check_error_kick(stanza_error()) -> boolean(). +check_error_kick(#stanza_error{reason = Reason}) -> case Reason of #gone{} -> true; 'internal-server-error' -> true; @@ -1153,8 +1153,8 @@ check_error_kick(#error{reason = Reason}) -> check_error_kick(undefined) -> false. --spec get_error_condition(error()) -> string(). -get_error_condition(#error{reason = Reason}) -> +-spec get_error_condition(stanza_error()) -> string(). +get_error_condition(#stanza_error{reason = Reason}) -> case Reason of #gone{} -> "gone"; #redirect{} -> "redirect"; @@ -1673,7 +1673,7 @@ nick_collision(User, Nick, StateData) -> -spec add_new_user(jid(), binary(), presence() | iq(), state()) -> state() | - {error, error()} | + {error, stanza_error()} | {ignore, state()} | {result, xmpp_element(), state()}. add_new_user(From, Nick, Packet, StateData) -> @@ -2467,7 +2467,7 @@ can_change_subject(Role, StateData) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Admin stuff --spec process_iq_admin(jid(), iq(), #state{}) -> {error, error()} | +-spec process_iq_admin(jid(), iq(), #state{}) -> {error, stanza_error()} | {result, undefined, #state{}} | {result, muc_admin()}. process_iq_admin(_From, #iq{lang = Lang, sub_els = [#muc_admin{items = []}]}, @@ -2557,7 +2557,7 @@ search_affiliation(Affiliation, StateData) -> -spec process_admin_items_set(jid(), [muc_item()], binary(), #state{}) -> {result, undefined, #state{}} | - {error, error()}. + {error, stanza_error()}. process_admin_items_set(UJID, Items, Lang, StateData) -> UAffiliation = get_affiliation(UJID, StateData), URole = get_role(UJID, StateData), @@ -2939,7 +2939,7 @@ get_actor_nick(MJID, StateData) -> -spec process_iq_owner(jid(), iq(), state()) -> {result, undefined | muc_owner()} | {result, undefined | muc_owner(), state() | stop} | - {error, error()}. + {error, stanza_error()}. process_iq_owner(From, #iq{type = set, lang = Lang, sub_els = [#muc_owner{destroy = Destroy, config = Config, @@ -3294,7 +3294,7 @@ get_config(Lang, StateData, From) -> [StateData, From, Lang]), #xdata{type = form, title = Title, fields = Fields}. --spec set_config(xdata(), state(), binary()) -> {error, error()} | +-spec set_config(xdata(), state(), binary()) -> {error, stanza_error()} | {result, undefined, state()}. set_config(#xdata{fields = Fields}, StateData, Lang) -> Options = [{Var, Vals} || #xdata_field{var = Var, values = Vals} <- Fields], @@ -3377,7 +3377,7 @@ get_config_opt_name(Pos) -> end). -spec set_xoption([{binary(), [binary()]}], #config{}, - binary(), binary()) -> #config{} | {error, error()}. + binary(), binary()) -> #config{} | {error, stanza_error()}. set_xoption([], Config, _ServerHost, _Lang) -> Config; set_xoption([{<<"muc#roomconfig_roomname">>, Vals} | Opts], @@ -3836,7 +3836,7 @@ destroy_room(DEl, StateData) -> end). -spec process_iq_disco_info(jid(), iq(), state()) -> - {result, disco_info()} | {error, error()}. + {result, disco_info()} | {error, stanza_error()}. process_iq_disco_info(_From, #iq{type = set, lang = Lang}, _StateData) -> Txt = <<"Value 'set' of 'type' attribute is not allowed">>, {error, xmpp:err_not_allowed(Txt, Lang)}; @@ -3901,7 +3901,7 @@ iq_disco_info_extras(Lang, StateData) -> integer_to_binary(Len), Lang)]}. -spec process_iq_disco_items(jid(), iq(), state()) -> - {error, error()} | {result, disco_items()}. + {error, stanza_error()} | {result, disco_items()}. process_iq_disco_items(_From, #iq{type = set, lang = Lang}, _StateData) -> Txt = <<"Value 'set' of 'type' attribute is not allowed">>, {error, xmpp:err_not_allowed(Txt, Lang)}; @@ -3919,7 +3919,7 @@ process_iq_disco_items(From, #iq{type = get, lang = Lang}, StateData) -> end end. --spec process_iq_captcha(jid(), iq(), state()) -> {error, error()} | +-spec process_iq_captcha(jid(), iq(), state()) -> {error, stanza_error()} | {result, undefined}. process_iq_captcha(_From, #iq{type = get, lang = Lang}, _StateData) -> Txt = <<"Value 'get' of 'type' attribute is not allowed">>, @@ -3939,7 +3939,7 @@ process_iq_captcha(_From, #iq{type = set, lang = Lang, sub_els = [SubEl]}, -spec process_iq_vcard(jid(), iq(), state()) -> {result, vcard_temp() | xmlel()} | {result, undefined, state()} | - {error, error()}. + {error, stanza_error()}. process_iq_vcard(_From, #iq{type = get}, StateData) -> #state{config = #config{vcard = VCardRaw}} = StateData, case fxml_stream:parse_element(VCardRaw) of @@ -3962,7 +3962,7 @@ process_iq_vcard(From, #iq{type = set, lang = Lang, sub_els = [SubEl]}, end. -spec process_iq_mucsub(jid(), iq(), state()) -> - {error, error()} | + {error, stanza_error()} | {result, undefined | muc_subscribe(), state()} | {ignore, state()}. process_iq_mucsub(_From, #iq{type = set, lang = Lang, @@ -4205,7 +4205,7 @@ is_invitation(Packet) -> (_) -> false end, Els). --spec check_invitation(jid(), message(), state()) -> {error, error()} | jid(). +-spec check_invitation(jid(), message(), state()) -> {error, stanza_error()} | jid(). check_invitation(From, Packet, StateData) -> Lang = xmpp:get_lang(Packet), FAffiliation = get_affiliation(From, StateData), diff --git a/src/mod_multicast.erl b/src/mod_multicast.erl index f1c090ae4..72046491f 100644 --- a/src/mod_multicast.erl +++ b/src/mod_multicast.erl @@ -243,7 +243,7 @@ handle_iq(From, To, Packet, State) -> end. -spec process_iq(jid(), iq(), state()) -> {result, xmpp_element()} | - {error, error()} | reply. + {error, stanza_error()} | reply. process_iq(From, #iq{type = get, lang = Lang, sub_els = [#disco_info{}]}, State) -> {result, iq_disco_info(From, Lang, State)}; diff --git a/src/mod_privacy.erl b/src/mod_privacy.erl index f94c422b3..3be3f2d3b 100644 --- a/src/mod_privacy.erl +++ b/src/mod_privacy.erl @@ -100,8 +100,8 @@ stop(Host) -> process_iq(IQ) -> xmpp:make_error(IQ, xmpp:err_not_allowed()). --spec process_iq_get({error, error()} | {result, xmpp_element() | undefined}, - iq(), userlist()) -> {error, error()} | {result, privacy_query()}. +-spec process_iq_get({error, stanza_error()} | {result, xmpp_element() | undefined}, + iq(), userlist()) -> {error, stanza_error()} | {result, privacy_query()}. process_iq_get(_, #iq{from = From, lang = Lang, sub_els = [#privacy_query{lists = Lists}]}, #userlist{name = Active}) -> @@ -117,7 +117,7 @@ process_iq_get(_, #iq{from = From, lang = Lang, end. -spec process_lists_get(binary(), binary(), binary(), binary()) -> - {error, error()} | {result, privacy_query()}. + {error, stanza_error()} | {result, privacy_query()}. process_lists_get(LUser, LServer, Active, Lang) -> Mod = gen_mod:db_mod(LServer, ?MODULE), case Mod:process_lists_get(LUser, LServer) of @@ -135,7 +135,7 @@ process_lists_get(LUser, LServer, Active, Lang) -> end. -spec process_list_get(binary(), binary(), binary(), binary()) -> - {error, error()} | {result, privacy_query()}. + {error, stanza_error()} | {result, privacy_query()}. process_list_get(LUser, LServer, Name, Lang) -> Mod = gen_mod:db_mod(LServer, ?MODULE), case Mod:process_list_get(LUser, LServer, Name) of @@ -214,10 +214,10 @@ decode_value(Type, Value) -> undefined -> none end. --spec process_iq_set({error, error()} | +-spec process_iq_set({error, stanza_error()} | {result, xmpp_element() | undefined} | {result, xmpp_element() | undefined, userlist()}, - iq()) -> {error, error()} | + iq()) -> {error, stanza_error()} | {result, undefined, userlist()}. process_iq_set(_, #iq{from = From, lang = Lang, sub_els = [#privacy_query{default = Default, @@ -239,7 +239,7 @@ process_iq_set(_, #iq{from = From, lang = Lang, end. -spec process_default_set(binary(), binary(), none | binary(), - binary()) -> {error, error()} | {result, undefined}. + binary()) -> {error, stanza_error()} | {result, undefined}. process_default_set(LUser, LServer, Value, Lang) -> Mod = gen_mod:db_mod(LServer, ?MODULE), case Mod:process_default_set(LUser, LServer, Value) of @@ -258,7 +258,7 @@ process_default_set(LUser, LServer, Value, Lang) -> end. -spec process_active_set(binary(), binary(), none | binary(), binary()) -> - {error, error()} | + {error, stanza_error()} | {result, undefined, userlist()}. process_active_set(_LUser, _LServer, none, _Lang) -> {result, undefined, #userlist{}}; @@ -280,7 +280,7 @@ set_privacy_list(#privacy{us = {_, LServer}} = Privacy) -> Mod:set_privacy_list(Privacy). -spec process_lists_set(binary(), binary(), binary(), [privacy_item()], - binary()) -> {error, error()} | {result, undefined}. + binary()) -> {error, stanza_error()} | {result, undefined}. process_lists_set(LUser, LServer, Name, [], Lang) -> Mod = gen_mod:db_mod(LServer, ?MODULE), case Mod:remove_privacy_list(LUser, LServer, Name) of diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl index a7a0e2d88..b470d83d9 100644 --- a/src/mod_pubsub.erl +++ b/src/mod_pubsub.erl @@ -525,9 +525,9 @@ disco_local_identity(Acc, _From, To, <<>>, _Lang) -> disco_local_identity(Acc, _From, _To, _Node, _Lang) -> Acc. --spec disco_local_features({error, error()} | {result, [binary()]} | empty, +-spec disco_local_features({error, stanza_error()} | {result, [binary()]} | empty, jid(), jid(), binary(), binary()) -> - {error, error()} | {result, [binary()]} | empty. + {error, stanza_error()} | {result, [binary()]} | empty. disco_local_features(Acc, _From, To, <<>>, _Lang) -> Host = host(To#jid.lserver), Feats = case Acc of @@ -538,9 +538,9 @@ disco_local_features(Acc, _From, To, <<>>, _Lang) -> disco_local_features(Acc, _From, _To, _Node, _Lang) -> Acc. --spec disco_local_items({error, error()} | {result, [disco_item()]} | empty, +-spec disco_local_items({error, stanza_error()} | {result, [disco_item()]} | empty, jid(), jid(), binary(), binary()) -> - {error, error()} | {result, [disco_item()]} | empty. + {error, stanza_error()} | {result, [disco_item()]} | empty. disco_local_items(Acc, _From, _To, <<>>, _Lang) -> Acc; disco_local_items(Acc, _From, _To, _Node, _Lang) -> Acc. @@ -578,9 +578,9 @@ disco_identity(Host, Node, From) -> _ -> [] end. --spec disco_sm_features({error, error()} | {result, [binary()]} | empty, +-spec disco_sm_features({error, stanza_error()} | {result, [binary()]} | empty, jid(), jid(), binary(), binary()) -> - {error, error()} | {result, [binary()]}. + {error, stanza_error()} | {result, [binary()]}. disco_sm_features(empty, From, To, Node, Lang) -> disco_sm_features({result, []}, From, To, Node, Lang); disco_sm_features({result, OtherFeatures} = _Acc, From, To, Node, _Lang) -> @@ -612,9 +612,9 @@ disco_features(Host, Node, From) -> _ -> [] end. --spec disco_sm_items({error, error()} | {result, [disco_item()]} | empty, +-spec disco_sm_items({error, stanza_error()} | {result, [disco_item()]} | empty, jid(), jid(), binary(), binary()) -> - {error, error()} | {result, [disco_item()]}. + {error, stanza_error()} | {result, [disco_item()]}. disco_sm_items(empty, From, To, Node, Lang) -> disco_sm_items({result, []}, From, To, Node, Lang); disco_sm_items({result, OtherItems}, From, To, Node, _Lang) -> @@ -1052,12 +1052,12 @@ command_disco_info(_Host, ?NS_PUBSUB_GET_PENDING, _From) -> features = [?NS_COMMANDS]}}. -spec node_disco_info(binary(), binary(), jid()) -> {result, disco_info()} | - {error, error()}. + {error, stanza_error()}. node_disco_info(Host, Node, From) -> node_disco_info(Host, Node, From, true, true). -spec node_disco_info(binary(), binary(), jid(), boolean(), boolean()) -> - {result, disco_info()} | {error, error()}. + {result, disco_info()} | {error, stanza_error()}. node_disco_info(Host, Node, _From, _Identity, _Features) -> Action = fun(#pubsub_node{type = Type, options = Options}) -> @@ -1075,7 +1075,7 @@ node_disco_info(Host, Node, _From, _Identity, _Features) -> end. -spec iq_disco_info(binary(), binary(), jid(), binary()) - -> {result, disco_info()} | {error, error()}. + -> {result, disco_info()} | {error, stanza_error()}. iq_disco_info(Host, SNode, From, Lang) -> [Node | _] = case SNode of <<>> -> [<<>>]; @@ -1105,7 +1105,7 @@ iq_disco_info(Host, SNode, From, Lang) -> end. -spec iq_disco_items(host(), binary(), jid(), undefined | rsm_set()) -> - {result, disco_items()} | {error, error()}. + {result, disco_items()} | {error, stanza_error()}. iq_disco_items(Host, <<>>, From, _RSM) -> Items = lists:map( @@ -1193,7 +1193,7 @@ iq_get_vcard(Lang) -> desc = <>}. -spec iq_pubsub(binary() | ljid(), atom(), iq()) -> - {result, pubsub()} | {error, error()}. + {result, pubsub()} | {error, stanza_error()}. iq_pubsub(Host, Access, #iq{from = From, type = IQType, lang = Lang, sub_els = [SubEl]}) -> case {IQType, SubEl} of @@ -1272,7 +1272,7 @@ iq_pubsub(Host, Access, #iq{from = From, type = IQType, lang = Lang, end. -spec iq_pubsub_owner(binary() | ljid(), iq()) -> {result, pubsub_owner() | undefined} | - {error, error()}. + {error, stanza_error()}. iq_pubsub_owner(Host, #iq{type = IQType, from = From, lang = Lang, sub_els = [SubEl]}) -> case {IQType, SubEl} of @@ -1312,7 +1312,7 @@ iq_pubsub_owner(Host, #iq{type = IQType, from = From, end. -spec adhoc_request(binary(), binary(), jid(), adhoc_command(), - atom(), [binary()]) -> adhoc_command() | {error, error()}. + atom(), [binary()]) -> adhoc_command() | {error, stanza_error()}. adhoc_request(Host, _ServerHost, Owner, #adhoc_command{node = ?NS_PUBSUB_GET_PENDING, lang = Lang, action = execute, xdata = undefined}, @@ -1342,7 +1342,7 @@ adhoc_request(_Host, _ServerHost, _Owner, Other, _Access, _Plugins) -> {error, xmpp:err_item_not_found()}. -spec send_pending_node_form(binary(), jid(), binary(), - [binary()]) -> adhoc_command() | {error, error()}. + [binary()]) -> adhoc_command() | {error, stanza_error()}. send_pending_node_form(Host, Owner, _Lang, Plugins) -> Filter = fun (Type) -> lists:member(<<"get-pending">>, plugin_features(Host, Type)) @@ -1369,7 +1369,7 @@ send_pending_node_form(Host, Owner, _Lang, Plugins) -> end. -spec get_pending_nodes(binary(), jid(), [binary()]) -> {ok, [binary()]} | - {error, error()}. + {error, stanza_error()}. get_pending_nodes(Host, Owner, Plugins) -> Tr = fun (Type) -> case node_call(Host, Type, get_pending_nodes, [Host, Owner]) of @@ -1386,7 +1386,7 @@ get_pending_nodes(Host, Owner, Plugins) -> %% @doc

Send a subscription approval form to Owner for all pending %% subscriptions on Host and Node.

-spec send_pending_auth_events(binary(), binary(), jid(), - binary()) -> adhoc_command() | {error, error()}. + binary()) -> adhoc_command() | {error, stanza_error()}. send_pending_auth_events(Host, Node, Owner, Lang) -> ?DEBUG("Sending pending auth events for ~s on ~s:~s", [jid:to_string(Owner), Host, Node]), @@ -1520,7 +1520,7 @@ handle_authorization_response(Host, From, To, Packet, X) -> end. -spec update_auth(binary(), binary(), _, _, jid() | error, boolean(), _) -> - {result, ok} | {error, error()}. + {result, ok} | {error, stanza_error()}. update_auth(Host, Node, Type, Nidx, Subscriber, Allow, Subs) -> Sub= lists:filter(fun ({pending, _}) -> true; @@ -1598,12 +1598,12 @@ update_auth(Host, Node, Type, Nidx, Subscriber, Allow, Subs) -> %%
  • node plugin create_node just sets default affiliation/subscription
  • %% -spec create_node(host(), binary(), binary(), jid(), - binary()) -> {result, pubsub()} | {error, error()}. + binary()) -> {result, pubsub()} | {error, stanza_error()}. create_node(Host, ServerHost, Node, Owner, Type) -> create_node(Host, ServerHost, Node, Owner, Type, all, []). -spec create_node(host(), binary(), binary(), jid(), binary(), - atom(), [{binary(), [binary()]}]) -> {result, pubsub()} | {error, error()}. + atom(), [{binary(), [binary()]}]) -> {result, pubsub()} | {error, stanza_error()}. create_node(Host, ServerHost, <<>>, Owner, Type, Access, Configuration) -> case lists:member(<<"instant-nodes">>, plugin_features(Host, Type)) of true -> @@ -1693,7 +1693,7 @@ create_node(Host, ServerHost, Node, Owner, GivenType, Access, Configuration) -> %%
  • The node is the root collection node, which cannot be deleted.
  • %%
  • The specified node does not exist.
  • %% --spec delete_node(host(), binary(), jid()) -> {result, pubsub_owner()} | {error, error()}. +-spec delete_node(host(), binary(), jid()) -> {result, pubsub_owner()} | {error, stanza_error()}. delete_node(_Host, <<>>, _Owner) -> {error, xmpp:err_not_allowed(<<"No node specified">>, ?MYLANG)}; delete_node(Host, Node, Owner) -> @@ -1770,7 +1770,7 @@ delete_node(Host, Node, Owner) -> %%
  • The node does not exist.
  • %% -spec subscribe_node(host(), binary(), jid(), binary(), [{binary(), [binary()]}]) -> - {result, pubsub()} | {error, error()}. + {result, pubsub()} | {error, stanza_error()}. subscribe_node(Host, Node, From, JID, Configuration) -> SubModule = subscription_plugin(Host), SubOpts = case SubModule:parse_options_xform(Configuration) of @@ -1874,7 +1874,7 @@ subscribe_node(Host, Node, From, JID, Configuration) -> %%
  • The request specifies a subscription ID that is not valid or current.
  • %% -spec unsubscribe_node(host(), binary(), jid(), jid(), binary()) -> - {result, undefined} | {error, error()}. + {result, undefined} | {error, stanza_error()}. unsubscribe_node(Host, Node, From, JID, SubId) -> Subscriber = jid:tolower(JID), Action = fun (#pubsub_node{type = Type, id = Nidx}) -> @@ -1901,7 +1901,7 @@ unsubscribe_node(Host, Node, From, JID, SubId) -> %%
  • The request does not match the node configuration.
  • %% -spec publish_item(host(), binary(), binary(), jid(), binary(), - [xmlel()]) -> {result, pubsub()} | {error, error()}. + [xmlel()]) -> {result, pubsub()} | {error, stanza_error()}. publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) -> publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload, [], all). publish_item(Host, ServerHost, Node, Publisher, <<>>, Payload, PubOpts, Access) -> @@ -1984,7 +1984,7 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload, PubOpts, Access {result, Reply}; {result, {_, Result}} -> {result, Result}; - {error, #error{reason = 'item-not-found'}} -> + {error, #stanza_error{reason = 'item-not-found'}} -> Type = select_type(ServerHost, Host, Node), case lists:member(<<"auto-create">>, plugin_features(Host, Type)) of true -> @@ -2015,7 +2015,7 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload, PubOpts, Access %%
  • The service does not support the deletion of items.
  • %% -spec delete_item(host(), binary(), jid(), binary()) -> {result, undefined} | - {error, error()}. + {error, stanza_error()}. delete_item(Host, Node, Publisher, ItemId) -> delete_item(Host, Node, Publisher, ItemId, false). delete_item(_, <<>>, _, _, _) -> @@ -2071,7 +2071,7 @@ delete_item(Host, Node, Publisher, ItemId, ForceNotify) -> %%
  • The specified node does not exist.
  • %% -spec purge_node(mod_pubsub:host(), binary(), jid()) -> {result, undefined} | - {error, error()}. + {error, stanza_error()}. purge_node(Host, Node, Owner) -> Action = fun (#pubsub_node{options = Options, type = Type, id = Nidx}) -> Features = plugin_features(Host, Type), @@ -2117,7 +2117,7 @@ purge_node(Host, Node, Owner) -> %% to read the items. -spec get_items(host(), binary(), jid(), binary(), binary(), [binary()], undefined | rsm_set()) -> - {result, pubsub()} | {error, error()}. + {result, pubsub()} | {error, stanza_error()}. get_items(Host, Node, From, SubId, SMaxItems, ItemIds, RSM) -> MaxItems = if SMaxItems == undefined -> case get_max_items_node(Host) of @@ -2270,7 +2270,7 @@ dispatch_items(From, To, _Node, Stanza) -> %% @doc

    Return the list of affiliations as an XMPP response.

    -spec get_affiliations(host(), binary(), jid(), [binary()]) -> - {result, pubsub()} | {error, error()}. + {result, pubsub()} | {error, stanza_error()}. get_affiliations(Host, Node, JID, Plugins) when is_list(Plugins) -> Result = lists:foldl( @@ -2310,7 +2310,7 @@ get_affiliations(Host, Node, JID, Plugins) when is_list(Plugins) -> end. -spec get_affiliations(host(), binary(), jid()) -> - {result, pubsub_owner()} | {error, error()}. + {result, pubsub_owner()} | {error, stanza_error()}. get_affiliations(Host, Node, JID) -> Action = fun(#pubsub_node{type = Type, id = Nidx}) -> @@ -2342,7 +2342,7 @@ get_affiliations(Host, Node, JID) -> end. -spec set_affiliations(host(), binary(), jid(), [ps_affiliation()]) -> - {result, undefined} | {error, error()}. + {result, undefined} | {error, stanza_error()}. set_affiliations(Host, Node, From, Affs) -> Owner = jid:tolower(jid:remove_resource(From)), Action = @@ -2396,7 +2396,7 @@ set_affiliations(Host, Node, From, Affs) -> end. -spec get_options(binary(), binary(), jid(), binary(), binary()) -> - {result, xdata()} | {error, error()}. + {result, xdata()} | {error, stanza_error()}. get_options(Host, Node, JID, SubId, Lang) -> Action = fun (#pubsub_node{type = Type, id = Nidx}) -> case lists:member(<<"subscription-options">>, plugin_features(Host, Type)) of @@ -2413,7 +2413,7 @@ get_options(Host, Node, JID, SubId, Lang) -> end. -spec get_options_helper(binary(), jid(), binary(), binary(), _, binary(), - binary()) -> {result, pubsub()} | {error, error()}. + binary()) -> {result, pubsub()} | {error, stanza_error()}. get_options_helper(Host, JID, Lang, Node, Nidx, SubId, Type) -> Subscriber = jid:tolower(JID), {result, Subs} = node_call(Host, Type, get_subscriptions, [Nidx, Subscriber]), @@ -2454,7 +2454,7 @@ read_sub(Host, Node, Nidx, Subscriber, SubId, Lang) -> -spec set_options(binary(), binary(), jid(), binary(), [{binary(), [binary()]}]) -> - {result, undefined} | {error, error()}. + {result, undefined} | {error, stanza_error()}. set_options(Host, Node, JID, SubId, Configuration) -> Action = fun (#pubsub_node{type = Type, id = Nidx}) -> case lists:member(<<"subscription-options">>, plugin_features(Host, Type)) of @@ -2472,7 +2472,7 @@ set_options(Host, Node, JID, SubId, Configuration) -> -spec set_options_helper(binary(), [{binary(), [binary()]}], jid(), nodeIdx(), binary(), binary()) -> - {result, undefined} | {error, error()}. + {result, undefined} | {error, stanza_error()}. set_options_helper(Host, Configuration, JID, Nidx, SubId, Type) -> SubModule = subscription_plugin(Host), SubOpts = case SubModule:parse_options_xform(Configuration) of @@ -2494,7 +2494,7 @@ set_options_helper(Host, Configuration, JID, Nidx, SubId, Type) -> end. -spec write_sub(binary(), nodeIdx(), ljid(), binary(), _) -> {result, undefined} | - {error, error()}. + {error, stanza_error()}. write_sub(_Host, _Nidx, _Subscriber, _SubId, invalid) -> {error, extended_error(xmpp:err_bad_request(), err_invalid_options())}; write_sub(_Host, _Nidx, _Subscriber, _SubId, []) -> @@ -2509,7 +2509,7 @@ write_sub(Host, Nidx, Subscriber, SubId, Options) -> %% @doc

    Return the list of subscriptions as an XMPP response.

    -spec get_subscriptions(host(), binary(), jid(), [binary()]) -> - {result, pubsub()} | {error, error()}. + {result, pubsub()} | {error, stanza_error()}. get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) -> Result = lists:foldl(fun (Type, {Status, Acc}) -> Features = plugin_features(Host, Type), @@ -2576,7 +2576,7 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) -> end. -spec get_subscriptions(host(), binary(), jid()) -> {result, pubsub_owner()} | - {error, error()}. + {error, stanza_error()}. get_subscriptions(Host, Node, JID) -> Action = fun (#pubsub_node{type = Type, id = Nidx}) -> Features = plugin_features(Host, Type), @@ -2633,7 +2633,7 @@ get_subscriptions_for_send_last(_Host, _PType, _, _JID, _LJID, _BJID) -> []. -spec set_subscriptions(host(), binary(), jid(), [ps_subscription()]) -> - {result, undefined} | {error, error()}. + {result, undefined} | {error, stanza_error()}. set_subscriptions(Host, Node, From, Entities) -> Owner = jid:tolower(jid:remove_resource(From)), Notify = fun(#ps_subscription{jid = JID, type = Sub}) -> @@ -3163,7 +3163,7 @@ user_resource(_, _, Resource) -> %%%%%%% Configuration handling -spec get_configure(host(), binary(), binary(), jid(), - binary()) -> {error, error()} | {result, pubsub_owner()}. + binary()) -> {error, stanza_error()} | {result, pubsub_owner()}. get_configure(Host, ServerHost, Node, From, Lang) -> Action = fun (#pubsub_node{options = Options, type = Type, id = Nidx}) -> case node_call(Host, Type, get_affiliation, [Nidx, From]) of @@ -3381,7 +3381,7 @@ get_configure_xfields(_Type, Options, Lang, Groups) -> %%
  • The specified node does not exist.
  • %% -spec set_configure(host(), binary(), jid(), [{binary(), [binary()]}], - binary()) -> {result, undefined} | {error, error()}. + binary()) -> {result, undefined} | {error, stanza_error()}. set_configure(_Host, <<>>, _From, _Config, _Lang) -> {error, extended_error(xmpp:err_bad_request(), err_nodeid_required())}; set_configure(Host, Node, From, Config, Lang) -> @@ -3851,9 +3851,9 @@ transaction_retry(Host, ServerHost, Fun, Trans, DBType, Count) -> %%%% helpers %% Add pubsub-specific error element --spec extended_error(error(), ps_error()) -> error(). +-spec extended_error(stanza_error(), ps_error()) -> stanza_error(). extended_error(StanzaErr, PubSubErr) -> - StanzaErr#error{sub_els = [PubSubErr]}. + StanzaErr#stanza_error{sub_els = [PubSubErr]}. -spec err_closed_node() -> ps_error(). err_closed_node() -> @@ -4033,7 +4033,7 @@ purge_offline(LJID) -> ?DEBUG("on_user_offline ~p", [Error]) end. --spec purge_offline(host(), ljid(), binary()) -> ok | {error, error()}. +-spec purge_offline(host(), ljid(), binary()) -> ok | {error, stanza_error()}. purge_offline(Host, LJID, Node) -> Nidx = Node#pubsub_node.id, Type = Node#pubsub_node.type, diff --git a/src/mod_vcard.erl b/src/mod_vcard.erl index f0fb556ba..1f6edb460 100644 --- a/src/mod_vcard.erl +++ b/src/mod_vcard.erl @@ -150,9 +150,9 @@ do_route(From, To, #iq{} = IQ) -> do_route(_, _, _) -> ok. --spec get_sm_features({error, error()} | empty | {result, [binary()]}, +-spec get_sm_features({error, stanza_error()} | empty | {result, [binary()]}, jid(), jid(), binary(), binary()) -> - {error, error()} | empty | {result, [binary()]}. + {error, stanza_error()} | empty | {result, [binary()]}. get_sm_features({error, _Error} = Acc, _From, _To, _Node, _Lang) -> Acc; @@ -230,9 +230,9 @@ process_search(#iq{type = set, lang = Lang} = IQ) -> Txt = <<"Incorrect data form">>, xmpp:make_error(IQ, xmpp:err_bad_request(Txt, Lang)). --spec disco_items({error, error()} | {result, [disco_item()]} | empty, +-spec disco_items({error, stanza_error()} | {result, [disco_item()]} | empty, jid(), jid(), binary(), binary()) -> - {error, error()} | {result, [disco_item()]}. + {error, stanza_error()} | {result, [disco_item()]}. disco_items(empty, _From, _To, <<"">>, _Lang) -> {result, []}; disco_items(empty, _From, _To, _Node, Lang) -> @@ -240,9 +240,9 @@ disco_items(empty, _From, _To, _Node, Lang) -> disco_items(Acc, _From, _To, _Node, _Lang) -> Acc. --spec disco_features({error, error()} | {result, [binary()]} | empty, +-spec disco_features({error, stanza_error()} | {result, [binary()]} | empty, jid(), jid(), binary(), binary()) -> - {error, error()} | {result, [binary()]}. + {error, stanza_error()} | {result, [binary()]}. disco_features({error, _Error} = Acc, _From, _To, _Node, _Lang) -> Acc; disco_features(Acc, _From, _To, <<"">>, _Lang) -> diff --git a/src/xmpp.erl b/src/xmpp.erl index 10872b341..49d824af2 100644 --- a/src/xmpp.erl +++ b/src/xmpp.erl @@ -88,10 +88,10 @@ make_iq_result(#iq{type = Type, from = From, to = To} = IQ, El) end, IQ#iq{type = result, to = From, from = To, sub_els = SubEls}. --spec make_error(message(), error() | xmlel()) -> message(); - (presence(), error() | xmlel()) -> presence(); - (iq(), error() | xmlel()) -> iq(); - (xmlel(), error() | xmlel()) -> xmlel(). +-spec make_error(message(), stanza_error() | xmlel()) -> message(); + (presence(), stanza_error() | xmlel()) -> presence(); + (iq(), stanza_error() | xmlel()) -> iq(); + (xmlel(), stanza_error() | xmlel()) -> xmlel(). make_error(#message{type = Type, from = From, to = To, sub_els = Els} = Msg, Err) when Type /= error -> Msg#message{type = error, from = To, to = From, sub_els = Els ++ [Err]}; @@ -150,9 +150,9 @@ get_to(#iq{to = J}) -> J; get_to(#message{to = J}) -> J; get_to(#presence{to = J}) -> J. --spec get_error(iq() | message() | presence()) -> undefined | error(). +-spec get_error(iq() | message() | presence()) -> undefined | stanza_error(). get_error(Stanza) -> - case get_subtag(Stanza, #error{}) of + case get_subtag(Stanza, #stanza_error{}) of false -> undefined; Error -> Error end. @@ -206,9 +206,9 @@ set_from_to(#iq{} = IQ, F, T) -> IQ#iq{from = F, to = T}; set_from_to(#message{} = Msg, F, T) -> Msg#message{from = F, to = T}; set_from_to(#presence{} = Pres, F, T) -> Pres#presence{from = F, to = T}. --spec set_error(iq(), error()) -> iq(); - (message(), error()) -> message(); - (presence(), error()) -> presence(). +-spec set_error(iq(), stanza_error()) -> iq(); + (message(), stanza_error()) -> message(); + (presence(), stanza_error()) -> presence(). set_error(Stanza, E) -> set_subtag(Stanza, E). -spec set_els(iq(), [xmpp_element() | xmlel()]) -> iq(); @@ -383,199 +383,199 @@ pp(Term) -> %%%=================================================================== %%% Functions to construct general XMPP errors %%%=================================================================== --spec err_bad_request() -> error(). +-spec err_bad_request() -> stanza_error(). err_bad_request() -> err(modify, 'bad-request', 400). --spec err_bad_request(binary(), binary()) -> error(). +-spec err_bad_request(binary(), binary()) -> stanza_error(). err_bad_request(Text, Lang) -> err(modify, 'bad-request', 400, Text, Lang). --spec err_conflict() -> error(). +-spec err_conflict() -> stanza_error(). err_conflict() -> err(cancel, 'conflict', 409). --spec err_conflict(binary(), binary()) -> error(). +-spec err_conflict(binary(), binary()) -> stanza_error(). err_conflict(Text, Lang) -> err(cancel, 'conflict', 409, Text, Lang). --spec err_feature_not_implemented() -> error(). +-spec err_feature_not_implemented() -> stanza_error(). err_feature_not_implemented() -> err(cancel, 'feature-not-implemented', 501). --spec err_feature_not_implemented(binary(), binary()) -> error(). +-spec err_feature_not_implemented(binary(), binary()) -> stanza_error(). err_feature_not_implemented(Text, Lang) -> err(cancel, 'feature-not-implemented', 501, Text, Lang). --spec err_forbidden() -> error(). +-spec err_forbidden() -> stanza_error(). err_forbidden() -> err(auth, 'forbidden', 403). --spec err_forbidden(binary(), binary()) -> error(). +-spec err_forbidden(binary(), binary()) -> stanza_error(). err_forbidden(Text, Lang) -> err(auth, 'forbidden', 403, Text, Lang). %% RFC 6120 says error type SHOULD be "cancel". %% RFC 3920 and XEP-0082 says it SHOULD be "modify". --spec err_gone() -> error(). +-spec err_gone() -> stanza_error(). err_gone() -> err(modify, 'gone', 302). --spec err_gone(binary(), binary()) -> error(). +-spec err_gone(binary(), binary()) -> stanza_error(). err_gone(Text, Lang) -> err(modify, 'gone', 302, Text, Lang). %% RFC 6120 sasy error type SHOULD be "cancel". %% RFC 3920 and XEP-0082 says it SHOULD be "wait". --spec err_internal_server_error() -> error(). +-spec err_internal_server_error() -> stanza_error(). err_internal_server_error() -> err(wait, 'internal-server-error', 500). --spec err_internal_server_error(binary(), binary()) -> error(). +-spec err_internal_server_error(binary(), binary()) -> stanza_error(). err_internal_server_error(Text, Lang) -> err(wait, 'internal-server-error', 500, Text, Lang). --spec err_item_not_found() -> error(). +-spec err_item_not_found() -> stanza_error(). err_item_not_found() -> err(cancel, 'item-not-found', 404). --spec err_item_not_found(binary(), binary()) -> error(). +-spec err_item_not_found(binary(), binary()) -> stanza_error(). err_item_not_found(Text, Lang) -> err(cancel, 'item-not-found', 404, Text, Lang). --spec err_jid_malformed() -> error(). +-spec err_jid_malformed() -> stanza_error(). err_jid_malformed() -> err(modify, 'jid-malformed', 400). --spec err_jid_malformed(binary(), binary()) -> error(). +-spec err_jid_malformed(binary(), binary()) -> stanza_error(). err_jid_malformed(Text, Lang) -> err(modify, 'jid-malformed', 400, Text, Lang). --spec err_not_acceptable() -> error(). +-spec err_not_acceptable() -> stanza_error(). err_not_acceptable() -> err(modify, 'not-acceptable', 406). --spec err_not_acceptable(binary(), binary()) -> error(). +-spec err_not_acceptable(binary(), binary()) -> stanza_error(). err_not_acceptable(Text, Lang) -> err(modify, 'not-acceptable', 406, Text, Lang). --spec err_not_allowed() -> error(). +-spec err_not_allowed() -> stanza_error(). err_not_allowed() -> err(cancel, 'not-allowed', 405). --spec err_not_allowed(binary(), binary()) -> error(). +-spec err_not_allowed(binary(), binary()) -> stanza_error(). err_not_allowed(Text, Lang) -> err(cancel, 'not-allowed', 405, Text, Lang). --spec err_not_authorized() -> error(). +-spec err_not_authorized() -> stanza_error(). err_not_authorized() -> err(auth, 'not-authorized', 401). --spec err_not_authorized(binary(), binary()) -> error(). +-spec err_not_authorized(binary(), binary()) -> stanza_error(). err_not_authorized(Text, Lang) -> err(auth, 'not-authorized', 401, Text, Lang). --spec err_payment_required() -> error(). +-spec err_payment_required() -> stanza_error(). err_payment_required() -> err(auth, 'not-authorized', 402). --spec err_payment_required(binary(), binary()) -> error(). +-spec err_payment_required(binary(), binary()) -> stanza_error(). err_payment_required(Text, Lang) -> err(auth, 'not-authorized', 402, Text, Lang). %% is defined in neither RFC 3920 nor XEP-0086. %% We choose '403' error code (as in ). --spec err_policy_violation() -> error(). +-spec err_policy_violation() -> stanza_error(). err_policy_violation() -> err(modify, 'policy-violation', 403). --spec err_policy_violation(binary(), binary()) -> error(). +-spec err_policy_violation(binary(), binary()) -> stanza_error(). err_policy_violation(Text, Lang) -> err(modify, 'policy-violation', 403, Text, Lang). --spec err_recipient_unavailable() -> error(). +-spec err_recipient_unavailable() -> stanza_error(). err_recipient_unavailable() -> err(wait, 'recipient-unavailable', 404). --spec err_recipient_unavailable(binary(), binary()) -> error(). +-spec err_recipient_unavailable(binary(), binary()) -> stanza_error(). err_recipient_unavailable(Text, Lang) -> err(wait, 'recipient-unavailable', 404, Text, Lang). --spec err_redirect() -> error(). +-spec err_redirect() -> stanza_error(). err_redirect() -> err(modify, 'redirect', 302). --spec err_redirect(binary(), binary()) -> error(). +-spec err_redirect(binary(), binary()) -> stanza_error(). err_redirect(Text, Lang) -> err(modify, 'redirect', 302, Text, Lang). --spec err_registration_required() -> error(). +-spec err_registration_required() -> stanza_error(). err_registration_required() -> err(auth, 'registration-required', 407). --spec err_registration_required(binary(), binary()) -> error(). +-spec err_registration_required(binary(), binary()) -> stanza_error(). err_registration_required(Text, Lang) -> err(auth, 'registration-required', 407, Text, Lang). --spec err_remote_server_not_found() -> error(). +-spec err_remote_server_not_found() -> stanza_error(). err_remote_server_not_found() -> err(cancel, 'remote-server-not-found', 404). --spec err_remote_server_not_found(binary(), binary()) -> error(). +-spec err_remote_server_not_found(binary(), binary()) -> stanza_error(). err_remote_server_not_found(Text, Lang) -> err(cancel, 'remote-server-not-found', 404, Text, Lang). --spec err_remote_server_timeout() -> error(). +-spec err_remote_server_timeout() -> stanza_error(). err_remote_server_timeout() -> err(wait, 'remote-server-timeout', 504). --spec err_remote_server_timeout(binary(), binary()) -> error(). +-spec err_remote_server_timeout(binary(), binary()) -> stanza_error(). err_remote_server_timeout(Text, Lang) -> err(wait, 'remote-server-timeout', 504, Text, Lang). --spec err_resource_constraint() -> error(). +-spec err_resource_constraint() -> stanza_error(). err_resource_constraint() -> err(wait, 'resource-constraint', 500). --spec err_resource_constraint(binary(), binary()) -> error(). +-spec err_resource_constraint(binary(), binary()) -> stanza_error(). err_resource_constraint(Text, Lang) -> err(wait, 'resource-constraint', 500, Text, Lang). --spec err_service_unavailable() -> error(). +-spec err_service_unavailable() -> stanza_error(). err_service_unavailable() -> err(cancel, 'service-unavailable', 503). --spec err_service_unavailable(binary(), binary()) -> error(). +-spec err_service_unavailable(binary(), binary()) -> stanza_error(). err_service_unavailable(Text, Lang) -> err(cancel, 'service-unavailable', 503, Text, Lang). --spec err_subscription_required() -> error(). +-spec err_subscription_required() -> stanza_error(). err_subscription_required() -> err(auth, 'subscription-required', 407). --spec err_subscription_required(binary(), binary()) -> error(). +-spec err_subscription_required(binary(), binary()) -> stanza_error(). err_subscription_required(Text, Lang) -> err(auth, 'subscription-required', 407, Text, Lang). %% No error type is defined for . %% Let user provide the type. -spec err_undefined_condition('auth' | 'cancel' | 'continue' | - 'modify' | 'wait') -> error(). + 'modify' | 'wait') -> stanza_error(). err_undefined_condition(Type) -> err(Type, 'undefined-condition', 500). -spec err_undefined_condition('auth' | 'cancel' | 'continue' | 'modify' | 'wait', - binary(), binary()) -> error(). + binary(), binary()) -> stanza_error(). err_undefined_condition(Type, Text, Lang) -> err(Type, 'undefined-condition', 500, Text, Lang). %% RFC 6120 says error type SHOULD be "wait" or "modify". %% RFC 3920 and XEP-0082 says it SHOULD be "wait". --spec err_unexpected_request() -> error(). +-spec err_unexpected_request() -> stanza_error(). err_unexpected_request() -> err(wait, 'unexpected-request', 400). --spec err_unexpected_request(binary(), binary()) -> error(). +-spec err_unexpected_request(binary(), binary()) -> stanza_error(). err_unexpected_request(Text, Lang) -> err(wait, 'unexpected-request', 400, Text, Lang). @@ -786,17 +786,17 @@ serr_unsupported_version(Text, Lang) -> %%% Internal functions %%%=================================================================== -spec err('auth' | 'cancel' | 'continue' | 'modify' | 'wait', - atom() | gone() | redirect(), non_neg_integer()) -> error(). + atom() | gone() | redirect(), non_neg_integer()) -> stanza_error(). err(Type, Reason, Code) -> - #error{type = Type, reason = Reason, code = Code}. + #stanza_error{type = Type, reason = Reason, code = Code}. -spec err('auth' | 'cancel' | 'continue' | 'modify' | 'wait', atom() | gone() | redirect(), non_neg_integer(), - binary(), binary()) -> error(). + binary(), binary()) -> stanza_error(). err(Type, Reason, Code, Text, Lang) -> - #error{type = Type, reason = Reason, code = Code, - text = #text{lang = Lang, - data = translate:translate(Lang, Text)}}. + #stanza_error{type = Type, reason = Reason, code = Code, + text = #text{lang = Lang, + data = translate:translate(Lang, Text)}}. -spec serr(atom() | 'see-other-host'()) -> stream_error(). serr(Reason) -> diff --git a/src/xmpp_codec.erl b/src/xmpp_codec.erl index 135a2acbb..8653d591c 100644 --- a/src/xmpp_codec.erl +++ b/src/xmpp_codec.erl @@ -2567,7 +2567,7 @@ encode({redirect, _} = Redirect) -> encode_error_redirect(Redirect, [{<<"xmlns">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}]); -encode({error, _, _, _, _, _, _} = Error) -> +encode({stanza_error, _, _, _, _, _, _} = Error) -> encode_error(Error, [{<<"xmlns">>, <<"jabber:client">>}]); encode({bind, _, _} = Bind) -> @@ -3176,7 +3176,6 @@ get_name({delay, _, _, _}) -> <<"delay">>; get_name({disco_info, _, _, _, _}) -> <<"query">>; get_name({disco_item, _, _, _}) -> <<"item">>; get_name({disco_items, _, _, _}) -> <<"query">>; -get_name({error, _, _, _, _, _, _}) -> <<"error">>; get_name({expire, _, _}) -> <<"x">>; get_name({feature_csi, _}) -> <<"csi">>; get_name({feature_register}) -> <<"register">>; @@ -3329,6 +3328,8 @@ get_name({sm_failed, _, _, _}) -> <<"failed">>; get_name({sm_r, _}) -> <<"r">>; get_name({sm_resume, _, _, _}) -> <<"resume">>; get_name({sm_resumed, _, _, _}) -> <<"resumed">>; +get_name({stanza_error, _, _, _, _, _, _}) -> + <<"error">>; get_name({stanza_id, _, _}) -> <<"stanza-id">>; get_name({starttls, _}) -> <<"starttls">>; get_name({starttls_failure}) -> <<"failure">>; @@ -3441,8 +3442,6 @@ get_ns({disco_item, _, _, _}) -> <<"http://jabber.org/protocol/disco#items">>; get_ns({disco_items, _, _, _}) -> <<"http://jabber.org/protocol/disco#items">>; -get_ns({error, _, _, _, _, _, _}) -> - <<"jabber:client">>; get_ns({expire, _, _}) -> <<"jabber:x:expire">>; get_ns({feature_csi, Xmlns}) -> Xmlns; get_ns({feature_register}) -> @@ -3633,6 +3632,8 @@ get_ns({sm_failed, _, _, Xmlns}) -> Xmlns; get_ns({sm_r, Xmlns}) -> Xmlns; get_ns({sm_resume, _, _, Xmlns}) -> Xmlns; get_ns({sm_resumed, _, _, Xmlns}) -> Xmlns; +get_ns({stanza_error, _, _, _, _, _, _}) -> + <<"jabber:client">>; get_ns({stanza_id, _, _}) -> <<"urn:xmpp:sid:0">>; get_ns({starttls, _}) -> <<"urn:ietf:params:xml:ns:xmpp-tls">>; @@ -3778,7 +3779,8 @@ pp(presence, 9) -> sub_els]; pp(gone, 1) -> [uri]; pp(redirect, 1) -> [uri]; -pp(error, 6) -> [type, code, by, reason, text, sub_els]; +pp(stanza_error, 6) -> + [type, code, by, reason, text, sub_els]; pp(bind, 2) -> [jid, resource]; pp(legacy_auth, 4) -> [username, password, digest, resource]; @@ -25595,7 +25597,7 @@ decode_error(__TopXMLNS, __IgnoreEls, {Type, Code, By} = decode_error_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), - {error, Type, Code, By, Reason, Text, __Els}. + {stanza_error, Type, Code, By, Reason, Text, __Els}. decode_error_els(__TopXMLNS, __IgnoreEls, [], Text, Reason, __Els) -> @@ -25965,8 +25967,8 @@ decode_error_attrs(__TopXMLNS, [], Type, Code, By) -> decode_error_attr_code(__TopXMLNS, Code), decode_error_attr_by(__TopXMLNS, By)}. -encode_error({error, Type, Code, By, Reason, Text, - __Els}, +encode_error({stanza_error, Type, Code, By, Reason, + Text, __Els}, _xmlns_attrs) -> _els = [encode(_el) || _el <- __Els] ++ lists:reverse('encode_error_$text'(Text, diff --git a/tools/xmpp_codec.spec b/tools/xmpp_codec.spec index a11c8dd76..265bd6de9 100644 --- a/tools/xmpp_codec.spec +++ b/tools/xmpp_codec.spec @@ -528,7 +528,7 @@ -xml(error, #elem{name = <<"error">>, xmlns = <<"jabber:client">>, - result = {error, '$type', '$code', '$by', '$reason', '$text', '$_els'}, + result = {stanza_error, '$type', '$code', '$by', '$reason', '$text', '$_els'}, attrs = [#attr{name = <<"type">>, label = '$type', required = true,