From ead2655a62023a0b01cdbdd916015fb6f2f56949 Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Wed, 9 Jun 2010 15:56:33 +1000 Subject: [PATCH] fixes some badmatches and calls to undefined functions (part of EJAB-1260) --- src/ejabberd_auth_external.erl | 2 +- src/mod_muc/mod_muc.erl | 2 +- src/mod_muc/mod_muc_room.erl | 6 +++--- src/mod_privacy_odbc.erl | 2 +- src/mod_proxy65/mod_proxy65_service.erl | 2 +- src/mod_pubsub/mod_pubsub.erl | 8 ++++---- src/mod_pubsub/mod_pubsub_odbc.erl | 8 ++++---- src/mod_pubsub/node_flat_odbc.erl | 8 +++++--- src/mod_pubsub/node_pep_odbc.erl | 4 ++-- src/mod_pubsub/pubsub_subscription_odbc.erl | 2 +- src/mod_roster_odbc.erl | 2 +- 11 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/ejabberd_auth_external.erl b/src/ejabberd_auth_external.erl index 140e5451e..b2fd35d36 100644 --- a/src/ejabberd_auth_external.erl +++ b/src/ejabberd_auth_external.erl @@ -348,7 +348,7 @@ get_last_info(User, Server) -> case get_mod_last_enabled(Server) of mod_last -> mod_last: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. %% @spec (Server) -> mod_last | mod_last_odbc | no_mod_last diff --git a/src/mod_muc/mod_muc.erl b/src/mod_muc/mod_muc.erl index b02d8b8a4..01bbc113d 100644 --- a/src/mod_muc/mod_muc.erl +++ b/src/mod_muc/mod_muc.erl @@ -652,7 +652,7 @@ iq_disco_items(Host, From, Lang, Rsm) -> attrs = [ #xmlattr{ name = 'jid', - value = jlib:jid_to_string({Name, Host, ""}) + value = exmpp_jid:to_binary(exmpp_jid:make(Name, Host)) }, #xmlattr{ name = 'name', diff --git a/src/mod_muc/mod_muc_room.erl b/src/mod_muc/mod_muc_room.erl index dccbd1a97..50a4c7273 100644 --- a/src/mod_muc/mod_muc_room.erl +++ b/src/mod_muc/mod_muc_room.erl @@ -439,7 +439,7 @@ normal_state({route, From, ToNick, is_user_online(From, StateData)} of {true, true} -> case Type of - "groupchat" -> + 'groupchat' -> ErrText = "It is not allowed to send private " "messages of type \"groupchat\"", Err = exmpp_stanza:reply_with_error(Packet, @@ -1849,7 +1849,7 @@ count_maxstanzas_shift(MaxStanzas, HistoryList) -> end. count_maxchars_shift(Nick, MaxSize, HistoryList) -> - NLen = string:len(Nick) + 1, + NLen = size(Nick) + 1, Sizes = lists:map( fun({_Nick, _Packet, _HaveSubject, _TimeStamp, Size}) -> Size + NLen @@ -2762,7 +2762,7 @@ send_kickban_presence1(UJID, Reason, Code, StateData) -> ItemAttrs = [?XMLATTR('affiliation', SAffiliation), ?XMLATTR('role', <<"none">>)], ItemEls = case Reason of - <<>> -> + "" -> []; _ -> [#xmlel{name = 'reason', diff --git a/src/mod_privacy_odbc.erl b/src/mod_privacy_odbc.erl index 90568f032..b0323a877 100644 --- a/src/mod_privacy_odbc.erl +++ b/src/mod_privacy_odbc.erl @@ -602,7 +602,7 @@ check_packet(_, User, Server, LJID = jlib:short_prepd_jid(To), {Subscription, Groups} = 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 -> {[], []} end, check_packet_aux(List, presence_out, diff --git a/src/mod_proxy65/mod_proxy65_service.erl b/src/mod_proxy65/mod_proxy65_service.erl index 4e0fff240..7ccbbb53d 100644 --- a/src/mod_proxy65/mod_proxy65_service.erl +++ b/src/mod_proxy65/mod_proxy65_service.erl @@ -164,7 +164,7 @@ process_iq(InitiatorJID, #iq{type = set, payload = SubEl, ns = ?NS_BYTESTREAMS} allow -> ActivateEl = exmpp_xml:get_path(SubEl, [{element, 'activate'}]), 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 /= "", length(SID) =< 128, TargetJID /= InitiatorJID -> Target = exmpp_jid:prep_to_list(TargetJID), diff --git a/src/mod_pubsub/mod_pubsub.erl b/src/mod_pubsub/mod_pubsub.erl index 109637fe3..8cc604676 100644 --- a/src/mod_pubsub/mod_pubsub.erl +++ b/src/mod_pubsub/mod_pubsub.erl @@ -1500,7 +1500,7 @@ get_pending_nodes(Host, Owner, Plugins) -> %% subscriptions on Host and Node.

send_pending_auth_events(Host, Node, Owner) -> ?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 = fun(#pubsub_node{id = NodeID, type = Type}) -> 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 <<>> -> [#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('subscription', subscription_to_string(Subscription)) | nodeAttr(SubsNode)]}]; SubsNode -> [#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('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 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 none -> lists:append([{U, S, R}], JIDs); %% If PID ... diff --git a/src/mod_pubsub/mod_pubsub_odbc.erl b/src/mod_pubsub/mod_pubsub_odbc.erl index ddb58dda7..b2e2f6757 100644 --- a/src/mod_pubsub/mod_pubsub_odbc.erl +++ b/src/mod_pubsub/mod_pubsub_odbc.erl @@ -1315,7 +1315,7 @@ get_pending_nodes(Host, Owner, Plugins) -> %% subscriptions on Host and Node.

send_pending_auth_events(Host, Node, Owner) -> ?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 = fun(#pubsub_node{id = NodeID, type = Type}) -> 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 <<>> -> [#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('subscription', subscription_to_string(Subscription)) | nodeAttr(SubsNode)]}]; SubsNode -> [#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('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 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 none -> lists:append([{U, S, R}], JIDs); %% If PID ... diff --git a/src/mod_pubsub/node_flat_odbc.erl b/src/mod_pubsub/node_flat_odbc.erl index 1582d2167..2a15af325 100644 --- a/src/mod_pubsub/node_flat_odbc.erl +++ b/src/mod_pubsub/node_flat_odbc.erl @@ -1161,7 +1161,9 @@ set_item(Item) -> {M, JID} = Item#pubsub_item.modification, P = encode_jid(JID), 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}) -> lists:flatten([i2l(T1, 6), ":", i2l(T2, 6), ":", i2l(T3, 6)]) end, @@ -1293,7 +1295,7 @@ update_subscription(NodeId, JID, Subscription) -> "values('", NodeId, "', '", J, "', 'n', '", S, "');"]) 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). @@ -1315,7 +1317,7 @@ decode_subscriptions(Subscriptions) -> end 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(publisher) -> "p"; diff --git a/src/mod_pubsub/node_pep_odbc.erl b/src/mod_pubsub/node_pep_odbc.erl index 4155ba318..b567d9f19 100644 --- a/src/mod_pubsub/node_pep_odbc.erl +++ b/src/mod_pubsub/node_pep_odbc.erl @@ -218,7 +218,7 @@ get_entity_subscriptions(_Host, Owner) -> {selected, ["host", "node", "type", "nodeid", "jid", "subscription"], RItems} -> lists:map(fun({H, N, T, I, J, S}) -> 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)} end, RItems); _ -> @@ -251,7 +251,7 @@ get_entity_subscriptions_for_send_last(_Host, Owner) -> {selected, ["host", "node", "type", "nodeid", "jid", "subscription"], RItems} -> lists:map(fun({H, N, T, I, J, S}) -> 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)} end, RItems); _ -> diff --git a/src/mod_pubsub/pubsub_subscription_odbc.erl b/src/mod_pubsub/pubsub_subscription_odbc.erl index 3c2fa6c26..f5591e032 100644 --- a/src/mod_pubsub/pubsub_subscription_odbc.erl +++ b/src/mod_pubsub/pubsub_subscription_odbc.erl @@ -238,7 +238,7 @@ type_and_options(Type, _Lang) -> tr_xfield_options({Value, Label}, Lang) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'option', - attrs = [?XMLATTR('label', transalte:translate(Lang, Label))], + attrs = [?XMLATTR('label', translate:translate(Lang, Label))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [?XMLCDATA(Value)]}]}. diff --git a/src/mod_roster_odbc.erl b/src/mod_roster_odbc.erl index 72daafbe1..a5e9ee251 100644 --- a/src/mod_roster_odbc.erl +++ b/src/mod_roster_odbc.erl @@ -773,7 +773,7 @@ remove_user(User, Server) when is_binary(User), is_binary(Server) -> %% Both or To, send a "unsubscribe" presence stanza. send_unsubscription_to_rosteritems(LUser, LServer) -> RosterItems = get_user_roster([], {LUser, LServer}), - From = jlib:make_jid({LUser, LServer, ""}), + From = exmpp_jid:make(LUser, LServer), lists:foreach(fun(RosterItem) -> send_unsubscribing_presence(From, RosterItem) end,