25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

fixes some badmatches and calls to undefined functions (part of EJAB-1260)

This commit is contained in:
Evgeniy Khramtsov 2010-06-09 15:56:33 +10:00
parent 526912756b
commit ead2655a62
11 changed files with 24 additions and 22 deletions

View File

@ -348,7 +348,7 @@ get_last_info(User, Server) ->
case get_mod_last_enabled(Server) of case get_mod_last_enabled(Server) of
mod_last -> mod_last:get_last_info(User, Server); mod_last -> mod_last:get_last_info(User, Server);
mod_last_odbc -> mod_last_odbc:get_last_info(User, Server); mod_last_odbc -> mod_last_odbc:get_last_info(User, Server);
mod_mod_last -> mod_last_required no_mod_last -> mod_last_required
end. end.
%% @spec (Server) -> mod_last | mod_last_odbc | no_mod_last %% @spec (Server) -> mod_last | mod_last_odbc | no_mod_last

View File

@ -652,7 +652,7 @@ iq_disco_items(Host, From, Lang, Rsm) ->
attrs = [ attrs = [
#xmlattr{ #xmlattr{
name = 'jid', name = 'jid',
value = jlib:jid_to_string({Name, Host, ""}) value = exmpp_jid:to_binary(exmpp_jid:make(Name, Host))
}, },
#xmlattr{ #xmlattr{
name = 'name', name = 'name',

View File

@ -439,7 +439,7 @@ normal_state({route, From, ToNick,
is_user_online(From, StateData)} of is_user_online(From, StateData)} of
{true, true} -> {true, true} ->
case Type of case Type of
"groupchat" -> 'groupchat' ->
ErrText = "It is not allowed to send private " ErrText = "It is not allowed to send private "
"messages of type \"groupchat\"", "messages of type \"groupchat\"",
Err = exmpp_stanza:reply_with_error(Packet, Err = exmpp_stanza:reply_with_error(Packet,
@ -1849,7 +1849,7 @@ count_maxstanzas_shift(MaxStanzas, HistoryList) ->
end. end.
count_maxchars_shift(Nick, MaxSize, HistoryList) -> count_maxchars_shift(Nick, MaxSize, HistoryList) ->
NLen = string:len(Nick) + 1, NLen = size(Nick) + 1,
Sizes = lists:map( Sizes = lists:map(
fun({_Nick, _Packet, _HaveSubject, _TimeStamp, Size}) -> fun({_Nick, _Packet, _HaveSubject, _TimeStamp, Size}) ->
Size + NLen Size + NLen
@ -2762,7 +2762,7 @@ send_kickban_presence1(UJID, Reason, Code, StateData) ->
ItemAttrs = [?XMLATTR('affiliation', SAffiliation), ItemAttrs = [?XMLATTR('affiliation', SAffiliation),
?XMLATTR('role', <<"none">>)], ?XMLATTR('role', <<"none">>)],
ItemEls = case Reason of ItemEls = case Reason of
<<>> -> "" ->
[]; [];
_ -> _ ->
[#xmlel{name = 'reason', [#xmlel{name = 'reason',

View File

@ -602,7 +602,7 @@ check_packet(_, User, Server,
LJID = jlib:short_prepd_jid(To), LJID = jlib:short_prepd_jid(To),
{Subscription, Groups} = {Subscription, Groups} =
case NeedDb of case NeedDb of
true -> ejabberd_hooks:run_fold(roster_get_jid_info, jlib:nameprep(Server), {none, []}, [User, Server, LJID]); true -> ejabberd_hooks:run_fold(roster_get_jid_info, exmpp_stringprep:nameprep(Server), {none, []}, [User, Server, LJID]);
false -> {[], []} false -> {[], []}
end, end,
check_packet_aux(List, presence_out, check_packet_aux(List, presence_out,

View File

@ -164,7 +164,7 @@ process_iq(InitiatorJID, #iq{type = set, payload = SubEl, ns = ?NS_BYTESTREAMS}
allow -> allow ->
ActivateEl = exmpp_xml:get_path(SubEl, [{element, 'activate'}]), ActivateEl = exmpp_xml:get_path(SubEl, [{element, 'activate'}]),
SID = exmpp_xml:get_attribute_as_list(SubEl, 'sid', ""), SID = exmpp_xml:get_attribute_as_list(SubEl, 'sid', ""),
case catch exmpp_jid:parse(exmpp_xml:get_cdata_as_string(ActivateEl)) of case catch exmpp_jid:parse(exmpp_xml:get_cdata_as_list(ActivateEl)) of
TargetJID when ?IS_JID(TargetJID), SID /= "", TargetJID when ?IS_JID(TargetJID), SID /= "",
length(SID) =< 128, TargetJID /= InitiatorJID -> length(SID) =< 128, TargetJID /= InitiatorJID ->
Target = exmpp_jid:prep_to_list(TargetJID), Target = exmpp_jid:prep_to_list(TargetJID),

View File

@ -1500,7 +1500,7 @@ get_pending_nodes(Host, Owner, Plugins) ->
%% subscriptions on Host and Node.</p> %% subscriptions on Host and Node.</p>
send_pending_auth_events(Host, Node, Owner) -> send_pending_auth_events(Host, Node, Owner) ->
?DEBUG("Sending pending auth events for ~s on ~s:~s", ?DEBUG("Sending pending auth events for ~s on ~s:~s",
[exmpp_jid:jid_to_string(Owner), Host, node_to_string(Node)]), [exmpp_jid:to_list(Owner), Host, node_to_string(Node)]),
Action = Action =
fun(#pubsub_node{id = NodeID, type = Type}) -> fun(#pubsub_node{id = NodeID, type = Type}) ->
case lists:member("get-pending", features(Type)) of case lists:member("get-pending", features(Type)) of
@ -2727,12 +2727,12 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) ->
case Node of case Node of
<<>> -> <<>> ->
[#xmlel{ns = ?NS_PUBSUB, name='subscription', [#xmlel{ns = ?NS_PUBSUB, name='subscription',
attrs = [?XMLATTR('jid', exmpp_jid:jid_to_binary(SubJID)), attrs = [?XMLATTR('jid', exmpp_jid:to_binary(SubJID)),
?XMLATTR('subid', SubID), ?XMLATTR('subid', SubID),
?XMLATTR('subscription', subscription_to_string(Subscription)) | nodeAttr(SubsNode)]}]; ?XMLATTR('subscription', subscription_to_string(Subscription)) | nodeAttr(SubsNode)]}];
SubsNode -> SubsNode ->
[#xmlel{ns = ?NS_PUBSUB, name = 'subscription', [#xmlel{ns = ?NS_PUBSUB, name = 'subscription',
attrs = [?XMLATTR('jid', exmpp_jid:jid_to_binary(SubJID)), attrs = [?XMLATTR('jid', exmpp_jid:to_binary(SubJID)),
?XMLATTR('subid', SubID), ?XMLATTR('subid', SubID),
?XMLATTR('subscription', subscription_to_string(Subscription))]}]; ?XMLATTR('subscription', subscription_to_string(Subscription))]}];
_ -> _ ->
@ -3013,7 +3013,7 @@ state_can_deliver({U, S, R}, SubOptions) ->
get_resource_state({U, S, R}, ShowValues, JIDs) -> get_resource_state({U, S, R}, ShowValues, JIDs) ->
%% Get user session PID %% Get user session PID
case ejabberd_sm:get_session_pid(U, S, R) of case ejabberd_sm:get_session_pid(exmpp_jid:make(U, S, R)) of
%% If no PID, item can be delivered %% If no PID, item can be delivered
none -> lists:append([{U, S, R}], JIDs); none -> lists:append([{U, S, R}], JIDs);
%% If PID ... %% If PID ...

View File

@ -1315,7 +1315,7 @@ get_pending_nodes(Host, Owner, Plugins) ->
%% subscriptions on Host and Node.</p> %% subscriptions on Host and Node.</p>
send_pending_auth_events(Host, Node, Owner) -> send_pending_auth_events(Host, Node, Owner) ->
?DEBUG("Sending pending auth events for ~s on ~s:~s", ?DEBUG("Sending pending auth events for ~s on ~s:~s",
[exmpp_jid:jid_to_string(Owner), Host, node_to_string(Node)]), [exmpp_jid:to_list(Owner), Host, node_to_string(Node)]),
Action = Action =
fun(#pubsub_node{id = NodeID, type = Type}) -> fun(#pubsub_node{id = NodeID, type = Type}) ->
case lists:member("get-pending", features(Type)) of case lists:member("get-pending", features(Type)) of
@ -2543,12 +2543,12 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) ->
case Node of case Node of
<<>> -> <<>> ->
[#xmlel{ns = ?NS_PUBSUB, name='subscription', [#xmlel{ns = ?NS_PUBSUB, name='subscription',
attrs = [?XMLATTR('jid', exmpp_jid:jid_to_binary(SubJID)), attrs = [?XMLATTR('jid', exmpp_jid:to_binary(SubJID)),
?XMLATTR('subid', SubID), ?XMLATTR('subid', SubID),
?XMLATTR('subscription', subscription_to_string(Subscription)) | nodeAttr(SubsNode)]}]; ?XMLATTR('subscription', subscription_to_string(Subscription)) | nodeAttr(SubsNode)]}];
SubsNode -> SubsNode ->
[#xmlel{ns = ?NS_PUBSUB, name = 'subscription', [#xmlel{ns = ?NS_PUBSUB, name = 'subscription',
attrs = [?XMLATTR('jid', exmpp_jid:jid_to_binary(SubJID)), attrs = [?XMLATTR('jid', exmpp_jid:to_binary(SubJID)),
?XMLATTR('subid', SubID), ?XMLATTR('subid', SubID),
?XMLATTR('subscription', subscription_to_string(Subscription))]}]; ?XMLATTR('subscription', subscription_to_string(Subscription))]}];
_ -> _ ->
@ -2829,7 +2829,7 @@ state_can_deliver({U, S, R}, SubOptions) ->
get_resource_state({U, S, R}, ShowValues, JIDs) -> get_resource_state({U, S, R}, ShowValues, JIDs) ->
%% Get user session PID %% Get user session PID
case ejabberd_sm:get_session_pid(U, S, R) of case ejabberd_sm:get_session_pid(exmpp_jid:make(U, S, R)) of
%% If no PID, item can be delivered %% If no PID, item can be delivered
none -> lists:append([{U, S, R}], JIDs); none -> lists:append([{U, S, R}], JIDs);
%% If PID ... %% If PID ...

View File

@ -1161,7 +1161,9 @@ set_item(Item) ->
{M, JID} = Item#pubsub_item.modification, {M, JID} = Item#pubsub_item.modification,
P = encode_jid(JID), P = encode_jid(JID),
Payload = Item#pubsub_item.payload, Payload = Item#pubsub_item.payload,
XML = ?PUBSUB:escape(lists:flatten(lists:map(fun(X) -> xml:element_to_string(X) end, Payload))), XML = ?PUBSUB:escape(lists:flatten(
lists:map(fun(X) -> exmpp_xml:document_to_list(X) end,
Payload))),
S = fun({T1, T2, T3}) -> S = fun({T1, T2, T3}) ->
lists:flatten([i2l(T1, 6), ":", i2l(T2, 6), ":", i2l(T3, 6)]) lists:flatten([i2l(T1, 6), ":", i2l(T2, 6), ":", i2l(T3, 6)])
end, end,
@ -1293,7 +1295,7 @@ update_subscription(NodeId, JID, Subscription) ->
"values('", NodeId, "', '", J, "', 'n', '", S, "');"]) "values('", NodeId, "', '", J, "', 'n', '", S, "');"])
end. end.
decode_jid(SJID) -> jlib:short_prepd_jid(jlib:string_to_jid(SJID)). %% TODO rewrite using exmpp decode_jid(SJID) -> jlib:short_prepd_jid(exmpp_jid:parse(SJID)). %% TODO rewrite using exmpp
decode_node(N) -> ?PUBSUB:string_to_node(N). decode_node(N) -> ?PUBSUB:string_to_node(N).
@ -1315,7 +1317,7 @@ decode_subscriptions(Subscriptions) ->
end end
end, [], string:tokens(Subscriptions, ",")). end, [], string:tokens(Subscriptions, ",")).
encode_jid(JID) -> ?PUBSUB:escape(jlib:jid_to_string(JID)). %% TODO rewrite using exmpp encode_jid(JID) -> ?PUBSUB:escape(exmpp_jid:to_list(JID)). %% TODO rewrite using exmpp
encode_affiliation(owner) -> "o"; encode_affiliation(owner) -> "o";
encode_affiliation(publisher) -> "p"; encode_affiliation(publisher) -> "p";

View File

@ -218,7 +218,7 @@ get_entity_subscriptions(_Host, Owner) ->
{selected, ["host", "node", "type", "nodeid", "jid", "subscription"], RItems} -> {selected, ["host", "node", "type", "nodeid", "jid", "subscription"], RItems} ->
lists:map(fun({H, N, T, I, J, S}) -> lists:map(fun({H, N, T, I, J, S}) ->
O = node_flat_odbc:decode_jid(H), O = node_flat_odbc:decode_jid(H),
Node = nodetree_odbc:raw_to_node(O, {N, "", T, I}), Node = nodetree_tree_odbc:raw_to_node(O, {N, "", T, I}),
{Node, node_flat_odbc:decode_subscription(S), node_flat_odbc:decode_jid(J)} {Node, node_flat_odbc:decode_subscription(S), node_flat_odbc:decode_jid(J)}
end, RItems); end, RItems);
_ -> _ ->
@ -251,7 +251,7 @@ get_entity_subscriptions_for_send_last(_Host, Owner) ->
{selected, ["host", "node", "type", "nodeid", "jid", "subscription"], RItems} -> {selected, ["host", "node", "type", "nodeid", "jid", "subscription"], RItems} ->
lists:map(fun({H, N, T, I, J, S}) -> lists:map(fun({H, N, T, I, J, S}) ->
O = node_flat_odbc:decode_jid(H), O = node_flat_odbc:decode_jid(H),
Node = nodetree_odbc:raw_to_node(O, {N, "", T, I}), Node = nodetree_tree_odbc:raw_to_node(O, {N, "", T, I}),
{Node, node_flat_odbc:decode_subscription(S), node_flat_odbc:decode_jid(J)} {Node, node_flat_odbc:decode_subscription(S), node_flat_odbc:decode_jid(J)}
end, RItems); end, RItems);
_ -> _ ->

View File

@ -238,7 +238,7 @@ type_and_options(Type, _Lang) ->
tr_xfield_options({Value, Label}, Lang) -> tr_xfield_options({Value, Label}, Lang) ->
#xmlel{ns = ?NS_DATA_FORMS, #xmlel{ns = ?NS_DATA_FORMS,
name = 'option', name = 'option',
attrs = [?XMLATTR('label', transalte:translate(Lang, Label))], attrs = [?XMLATTR('label', translate:translate(Lang, Label))],
children = [#xmlel{ns = ?NS_DATA_FORMS, children = [#xmlel{ns = ?NS_DATA_FORMS,
name = 'value', name = 'value',
children = [?XMLCDATA(Value)]}]}. children = [?XMLCDATA(Value)]}]}.

View File

@ -773,7 +773,7 @@ remove_user(User, Server) when is_binary(User), is_binary(Server) ->
%% Both or To, send a "unsubscribe" presence stanza. %% Both or To, send a "unsubscribe" presence stanza.
send_unsubscription_to_rosteritems(LUser, LServer) -> send_unsubscription_to_rosteritems(LUser, LServer) ->
RosterItems = get_user_roster([], {LUser, LServer}), RosterItems = get_user_roster([], {LUser, LServer}),
From = jlib:make_jid({LUser, LServer, ""}), From = exmpp_jid:make(LUser, LServer),
lists:foreach(fun(RosterItem) -> lists:foreach(fun(RosterItem) ->
send_unsubscribing_presence(From, RosterItem) send_unsubscribing_presence(From, RosterItem)
end, end,