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

Convert to exmpp.

SVN Revision: 1468
This commit is contained in:
Jean-Sébastien Pédron 2008-07-22 14:03:11 +00:00
parent a8ab6c1568
commit 37b99639d4
3 changed files with 147 additions and 113 deletions

View File

@ -1,3 +1,7 @@
2008-07-22 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
* src/mod_disco.erl, src/gen_iq_handler.erl: Convert to exmpp.
2008-07-21 Jean-Sébastien Pédron <js.pedron@meetic-corp.com> 2008-07-21 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
* src/gen_iq_handler.erl: Prepare gen_iq_handler to pass arguments in * src/gen_iq_handler.erl: Prepare gen_iq_handler to pass arguments in

View File

@ -59,6 +59,7 @@
% XXX OLD FORMAT: modules not in the following list will receive % XXX OLD FORMAT: modules not in the following list will receive
% old format strudctures. % old format strudctures.
-define(CONVERTED_MODULES, [ -define(CONVERTED_MODULES, [
mod_disco,
mod_roster, mod_roster,
mod_vcard mod_vcard
]). ]).

View File

@ -47,8 +47,9 @@
register_extra_domain/2, register_extra_domain/2,
unregister_extra_domain/2]). unregister_extra_domain/2]).
-include_lib("exmpp/include/exmpp.hrl").
-include("ejabberd.hrl"). -include("ejabberd.hrl").
-include("jlib.hrl").
-record(disco_publish, {owner_node, jid, name, node}). -record(disco_publish, {owner_node, jid, name, node}).
@ -62,13 +63,13 @@ start(Host, Opts) ->
ejabberd_local:refresh_iq_handlers(), ejabberd_local:refresh_iq_handlers(),
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue), IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_ITEMS, gen_iq_handler:add_iq_handler(ejabberd_local, Host, atom_to_list(?NS_DISCO_ITEMS),
?MODULE, process_local_iq_items, IQDisc), ?MODULE, process_local_iq_items, IQDisc),
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_INFO, gen_iq_handler:add_iq_handler(ejabberd_local, Host, atom_to_list(?NS_DISCO_INFO),
?MODULE, process_local_iq_info, IQDisc), ?MODULE, process_local_iq_info, IQDisc),
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_DISCO_ITEMS, gen_iq_handler:add_iq_handler(ejabberd_sm, Host, atom_to_list(?NS_DISCO_ITEMS),
?MODULE, process_sm_iq_items, IQDisc), ?MODULE, process_sm_iq_items, IQDisc),
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_DISCO_INFO, gen_iq_handler:add_iq_handler(ejabberd_sm, Host, atom_to_list(?NS_DISCO_INFO),
?MODULE, process_sm_iq_info, IQDisc), ?MODULE, process_sm_iq_info, IQDisc),
catch ets:new(disco_features, [named_table, ordered_set, public]), catch ets:new(disco_features, [named_table, ordered_set, public]),
@ -100,10 +101,10 @@ stop(Host) ->
ejabberd_hooks:delete(disco_local_identity, Host, ?MODULE, get_local_identity, 100), ejabberd_hooks:delete(disco_local_identity, Host, ?MODULE, get_local_identity, 100),
ejabberd_hooks:delete(disco_local_features, Host, ?MODULE, get_local_features, 100), ejabberd_hooks:delete(disco_local_features, Host, ?MODULE, get_local_features, 100),
ejabberd_hooks:delete(disco_local_items, Host, ?MODULE, get_local_services, 100), ejabberd_hooks:delete(disco_local_items, Host, ?MODULE, get_local_services, 100),
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_DISCO_ITEMS), gen_iq_handler:remove_iq_handler(ejabberd_local, Host, atom_to_list(?NS_DISCO_ITEMS)),
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_DISCO_INFO), gen_iq_handler:remove_iq_handler(ejabberd_local, Host, atom_to_list(?NS_DISCO_INFO)),
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_DISCO_ITEMS), gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, atom_to_list(?NS_DISCO_ITEMS)),
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_DISCO_INFO), gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, atom_to_list(?NS_DISCO_INFO)),
catch ets:match_delete(disco_features, {{'_', Host}}), catch ets:match_delete(disco_features, {{'_', Host}}),
catch ets:match_delete(disco_extra_domains, {{'_', Host}}), catch ets:match_delete(disco_extra_domains, {{'_', Host}}),
ok. ok.
@ -125,71 +126,82 @@ unregister_extra_domain(Host, Domain) ->
catch ets:new(disco_extra_domains, [named_table, ordered_set, public]), catch ets:new(disco_extra_domains, [named_table, ordered_set, public]),
ets:delete(disco_extra_domains, {Domain, Host}). ets:delete(disco_extra_domains, {Domain, Host}).
process_local_iq_items(From, To, #iq{type = Type, lang = Lang, sub_el = SubEl} = IQ) -> process_local_iq_items(From, To, IQ) ->
case Type of case exmpp_iq:get_type(IQ) of
set -> set ->
IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]}; exmpp_iq:error(IQ, 'not-allowed');
get -> get ->
Node = xml:get_tag_attr_s("node", SubEl), SubEl = exmpp_iq:get_request(IQ),
Host = To#jid.lserver, Node = exmpp_xml:get_attribute(SubEl, 'node'),
Host = To#jid.ldomain,
Lang = exmpp_stanza:get_lang(IQ),
% XXX OLD FORMAT: From, To.
FromOld = jlib:to_old_jid(From),
ToOld = jlib:to_old_jid(To),
case ejabberd_hooks:run_fold(disco_local_items, case ejabberd_hooks:run_fold(disco_local_items,
Host, Host,
empty, empty,
[From, To, Node, Lang]) of [FromOld, ToOld, Node, Lang]) of
{result, Items} -> {result, Items} ->
% XXX OLD FORMAT: Items might be an #xmlelement.
ANode = case Node of ANode = case Node of
"" -> []; "" -> [];
_ -> [{"node", Node}] _ -> [#xmlattr{name = 'node', value = Node}]
end, end,
IQ#iq{type = result, Result = #xmlel{ns = ?NS_DISCO_ITEMS, name = 'query',
sub_el = [{xmlelement, "query", attrs = ANode, children = Items},
[{"xmlns", ?NS_DISCO_ITEMS} | ANode], exmpp_iq:result(IQ, Result);
Items
}]};
{error, Error} -> {error, Error} ->
IQ#iq{type = error, sub_el = [SubEl, Error]} % XXX OLD FORMAT: Error.
exmpp_iq:error(IQ, Error)
end end
end. end.
process_local_iq_info(From, To, #iq{type = Type, lang = Lang, process_local_iq_info(From, To, IQ) ->
sub_el = SubEl} = IQ) -> case exmpp_iq:get_type(IQ) of
case Type of
set -> set ->
IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]}; exmpp_iq:error(IQ, 'not-allowed');
get -> get ->
Host = To#jid.lserver, Host = To#jid.ldomain,
Node = xml:get_tag_attr_s("node", SubEl), SubEl = exmpp_iq:get_request(IQ),
Node = exmpp_xml:get_attribute(SubEl, 'node'),
Lang = exmpp_stanza:get_lang(IQ),
% XXX OLD FORMAT: From, To.
FromOld = jlib:to_old_jid(From),
ToOld = jlib:to_old_jid(To),
% XXX OLD FORMAT: Identity might be an #xmlelement.
Identity = ejabberd_hooks:run_fold(disco_local_identity, Identity = ejabberd_hooks:run_fold(disco_local_identity,
Host, Host,
[], [],
[From, To, Node, Lang]), [FromOld, ToOld, Node, Lang]),
% XXX OLD FORMAT: From, To.
case ejabberd_hooks:run_fold(disco_local_features, case ejabberd_hooks:run_fold(disco_local_features,
Host, Host,
empty, empty,
[From, To, Node, Lang]) of [FromOld, ToOld, Node, Lang]) of
{result, Features} -> {result, Features} ->
ANode = case Node of ANode = case Node of
"" -> []; "" -> [];
_ -> [{"node", Node}] _ -> [#xmlattr{name = 'node', value = Node}]
end, end,
IQ#iq{type = result, Result = #xmlel{ns = ?NS_DISCO_INFO, name = 'query',
sub_el = [{xmlelement, "query", attrs = ANode,
[{"xmlns", ?NS_DISCO_INFO} | ANode], children = Identity ++ lists:map(fun feature_to_xml/1,
Identity ++ Features)},
lists:map(fun feature_to_xml/1, Features) exmpp_iq:result(IQ, Result);
}]};
{error, Error} -> {error, Error} ->
IQ#iq{type = error, sub_el = [SubEl, Error]} exmpp_iq:error(IQ, Error)
end end
end. end.
get_local_identity(Acc, _From, _To, [], _Lang) -> get_local_identity(Acc, _From, _To, [], _Lang) ->
Acc ++ [{xmlelement, "identity", Acc ++ [#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = [
[{"category", "server"}, #xmlattr{name = 'category', value = "server"},
{"type", "im"}, #xmlattr{name = 'type', value = "im"},
{"name", "ejabberd"}], []}]; #xmlattr{name = 'name', value = "ejabberd"}
]}];
get_local_identity(Acc, _From, _To, _Node, _Lang) -> get_local_identity(Acc, _From, _To, _Node, _Lang) ->
Acc. Acc.
@ -202,7 +214,7 @@ get_local_features(Acc, _From, To, [], _Lang) ->
{result, Features} -> Features; {result, Features} -> Features;
empty -> [] empty -> []
end, end,
Host = To#jid.lserver, Host = To#jid.ldomain,
{result, {result,
ets:select(disco_features, [{{{'_', Host}}, [], ['$_']}]) ++ Feats}; ets:select(disco_features, [{{{'_', Host}}, [], ['$_']}]) ++ Feats};
@ -211,29 +223,36 @@ get_local_features(Acc, _From, _To, _Node, _Lang) ->
{result, _Features} -> {result, _Features} ->
Acc; Acc;
empty -> empty ->
{error, ?ERR_ITEM_NOT_FOUND} {error, 'item-not-found'}
end. end.
feature_to_xml({{Feature, _Host}}) -> feature_to_xml({{Feature, _Host}}) ->
feature_to_xml(Feature); feature_to_xml(Feature);
feature_to_xml(Feature) when is_list(Feature) -> feature_to_xml(Feature) when is_list(Feature) ->
{xmlelement, "feature", [{"var", Feature}], []}. #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [
#xmlattr{name = 'var', value = Feature}
]}.
domain_to_xml({Domain}) -> domain_to_xml({Domain}) ->
{xmlelement, "item", [{"jid", Domain}], []}; #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [
#xmlattr{name = 'jid', value = Domain}
]};
domain_to_xml(Domain) -> domain_to_xml(Domain) ->
{xmlelement, "item", [{"jid", Domain}], []}. #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [
#xmlattr{name = 'jid', value = Domain}
]}.
get_local_services({error, _Error} = Acc, _From, _To, _Node, _Lang) -> get_local_services({error, _Error} = Acc, _From, _To, _Node, _Lang) ->
Acc; Acc;
get_local_services(Acc, _From, To, [], _Lang) -> get_local_services(Acc, _From, To, [], _Lang) ->
% XXX OLD FORMAT: Items might be an #xmlelement.
Items = case Acc of Items = case Acc of
{result, Its} -> Its; {result, Its} -> Its;
empty -> [] empty -> []
end, end,
Host = To#jid.lserver, Host = To#jid.ldomain,
{result, {result,
lists:usort( lists:usort(
lists:map(fun domain_to_xml/1, lists:map(fun domain_to_xml/1,
@ -246,7 +265,7 @@ get_local_services({result, _} = Acc, _From, _To, _Node, _Lang) ->
Acc; Acc;
get_local_services(empty, _From, _To, _Node, _Lang) -> get_local_services(empty, _From, _To, _Node, _Lang) ->
{error, ?ERR_ITEM_NOT_FOUND}. {error, 'item-not-found'}.
get_vh_services(Host) -> get_vh_services(Host) ->
Hosts = lists:sort(fun(H1, H2) -> length(H1) >= length(H2) end, ?MYHOSTS), Hosts = lists:sort(fun(H1, H2) -> length(H1) >= length(H2) end, ?MYHOSTS),
@ -264,46 +283,49 @@ get_vh_services(Host) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
process_sm_iq_items(From, To, #iq{type = Type, lang = Lang, sub_el = SubEl} = IQ) -> process_sm_iq_items(From, To, IQ) ->
case Type of SubEl = exmpp_iq:get_request(IQ),
case exmpp_iq:get_type(IQ) of
set -> set ->
#jid{luser = LTo, lserver = ToServer} = To, #jid{lnode = LTo, ldomain = ToServer} = To,
#jid{luser = LFrom, lserver = LServer} = From, #jid{lnode = LFrom, ldomain = LServer} = From,
Self = (LTo == LFrom) andalso (ToServer == LServer), Self = (LTo == LFrom) andalso (ToServer == LServer),
Node = xml:get_tag_attr_s("node", SubEl), Node = exmpp_xml:get_attribute(SubEl, 'node'),
if if
Self, Node /= [] -> Self, Node /= [] ->
%% Here, we treat disco publish attempts to your own JID. %% Here, we treat disco publish attempts to your own JID.
{xmlelement, _, _, Items} = SubEl, Items = SubEl#xmlel.children,
case process_disco_publish({LFrom, LServer}, Node, Items) of case process_disco_publish({LFrom, LServer}, Node, Items) of
ok -> ok ->
IQ#iq{type = result, sub_el = []}; exmpp_iq:result(IQ);
{error, Err} -> {error, Err} ->
IQ#iq{type = error, sub_el = [SubEl, Err]} exmpp_iq:error(IQ, Err)
end; end;
true -> true ->
IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]} exmpp_iq:error(IQ, 'not-allowed')
end; end;
get -> get ->
Host = To#jid.lserver, Host = To#jid.ldomain,
Node = xml:get_tag_attr_s("node", SubEl), Node = exmpp_xml:get_attribute(SubEl, 'node'),
Lang = exmpp_stanza:get_lang(IQ),
% XXX OLD FORMAT: From, To.
FromOld = jlib:to_old_jid(From),
ToOld = jlib:to_old_jid(To),
case ejabberd_hooks:run_fold(disco_sm_items, case ejabberd_hooks:run_fold(disco_sm_items,
Host, Host,
empty, empty,
[From, To, Node, Lang]) of [FromOld, ToOld, Node, Lang]) of
{result, Items} -> {result, Items} ->
ANode = case Node of ANode = case Node of
"" -> []; "" -> [];
_ -> [{"node", Node}] _ -> [#xmlattr{name = 'node', value = Node}]
end, end,
IQ#iq{type = result, Result = #xmlel{ns = ?NS_DISCO_ITEMS, name = 'query',
sub_el = [{xmlelement, "query", attrs = ANode, children = Items},
[{"xmlns", ?NS_DISCO_ITEMS} | ANode], exmpp_iq:result(IQ, Result);
Items
}]};
{error, Error} -> {error, Error} ->
IQ#iq{type = error, sub_el = [SubEl, Error]} exmpp_iq:error(IQ, Error)
end end
end. end.
@ -311,8 +333,8 @@ get_sm_items({error, _Error} = Acc, _From, _To, _Node, _Lang) ->
Acc; Acc;
get_sm_items(Acc, get_sm_items(Acc,
#jid{luser = LFrom, lserver = LSFrom}, #jid{lnode = LFrom, ldomain = LSFrom},
#jid{user = User, server = Server, luser = LTo, lserver = LSTo} = _To, #jid{node = User, domain = Server, lnode = LTo, ldomain = LSTo} = _To,
[], _Lang) -> [], _Lang) ->
Items = case Acc of Items = case Acc of
{result, Its} -> Its; {result, Its} -> Its;
@ -328,43 +350,48 @@ get_sm_items({result, _} = Acc, _From, _To, _Node, _Lang) ->
Acc; Acc;
get_sm_items(empty, From, To, _Node, _Lang) -> get_sm_items(empty, From, To, _Node, _Lang) ->
#jid{luser = LFrom, lserver = LSFrom} = From, #jid{lnode = LFrom, ldomain = LSFrom} = From,
#jid{luser = LTo, lserver = LSTo} = To, #jid{lnode = LTo, ldomain = LSTo} = To,
case {LFrom, LSFrom} of case {LFrom, LSFrom} of
{LTo, LSTo} -> {LTo, LSTo} ->
{error, ?ERR_ITEM_NOT_FOUND}; {error, 'item-not-found'};
_ -> _ ->
{error, ?ERR_NOT_ALLOWED} {error, 'not-allowed'}
end. end.
process_sm_iq_info(From, To, #iq{type = Type, lang = Lang, sub_el = SubEl} = IQ) -> process_sm_iq_info(From, To, IQ) ->
case Type of case exmpp_iq:get_type(IQ) of
set -> set ->
IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]}; exmpp_iq:error(IQ, 'not-allowed');
get -> get ->
Host = To#jid.lserver, Host = To#jid.ldomain,
Node = xml:get_tag_attr_s("node", SubEl), SubEl = exmpp_iq:get_request(IQ),
Node = exmpp_xml:get_attribute(SubEl, 'node'),
Lang = exmpp_stanza:get_lang(IQ),
% XXX OLD FORMAT: From, To.
FromOld = jlib:to_old_jid(From),
ToOld = jlib:to_old_jid(To),
% XXX OLD FORMAT: Identity might be an #xmlelement.
Identity = ejabberd_hooks:run_fold(disco_sm_identity, Identity = ejabberd_hooks:run_fold(disco_sm_identity,
Host, Host,
[], [],
[From, To, Node, Lang]), [FromOld, ToOld, Node, Lang]),
case ejabberd_hooks:run_fold(disco_sm_features, case ejabberd_hooks:run_fold(disco_sm_features,
Host, Host,
empty, empty,
[From, To, Node, Lang]) of [FromOld, ToOld, Node, Lang]) of
{result, Features} -> {result, Features} ->
ANode = case Node of ANode = case Node of
"" -> []; "" -> [];
_ -> [{"node", Node}] _ -> [#xmlattr{name = 'node', value = Node}]
end, end,
IQ#iq{type = result, Result = #xmlel{ns = ?NS_DISCO_INFO, name = 'query',
sub_el = [{xmlelement, "query", attrs = ANode,
[{"xmlns", ?NS_DISCO_INFO} | ANode], children = Identity ++ lists:map(fun feature_to_xml/1,
Identity ++ Features)},
lists:map(fun feature_to_xml/1, Features) exmpp_iq:result(IQ, Result);
}]};
{error, Error} -> {error, Error} ->
IQ#iq{type = error, sub_el = [SubEl, Error]} exmpp_iq:error(IQ, Error)
end end
end. end.
@ -372,13 +399,13 @@ get_sm_identity(Acc, _From, _To, _Node, _Lang) ->
Acc. Acc.
get_sm_features(empty, From, To, _Node, _Lang) -> get_sm_features(empty, From, To, _Node, _Lang) ->
#jid{luser = LFrom, lserver = LSFrom} = From, #jid{lnode = LFrom, ldomain = LSFrom} = From,
#jid{luser = LTo, lserver = LSTo} = To, #jid{lnode = LTo, ldomain = LSTo} = To,
case {LFrom, LSFrom} of case {LFrom, LSFrom} of
{LTo, LSTo} -> {LTo, LSTo} ->
{error, ?ERR_ITEM_NOT_FOUND}; {error, 'item-not-found'};
_ -> _ ->
{error, ?ERR_NOT_ALLOWED} {error, 'not-allowed'}
end; end;
get_sm_features(Acc, _From, _To, _Node, _Lang) -> get_sm_features(Acc, _From, _To, _Node, _Lang) ->
@ -389,15 +416,17 @@ get_sm_features(Acc, _From, _To, _Node, _Lang) ->
get_user_resources(User, Server) -> get_user_resources(User, Server) ->
Rs = ejabberd_sm:get_user_resources(User, Server), Rs = ejabberd_sm:get_user_resources(User, Server),
lists:map(fun(R) -> lists:map(fun(R) ->
{xmlelement, "item", #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [
[{"jid", User ++ "@" ++ Server ++ "/" ++ R}, #xmlattr{name = 'jid', value =
{"name", User}], []} exmpp_jid:jid_to_string(User, Server, R)},
#xmlattr{name = 'name', value = User}
]}
end, lists:sort(Rs)). end, lists:sort(Rs)).
get_publish_items(empty, get_publish_items(empty,
#jid{luser = LFrom, lserver = LSFrom}, #jid{lnode = LFrom, ldomain = LSFrom},
#jid{luser = LTo, lserver = LSTo} = _To, #jid{lnode = LTo, ldomain = LSTo} = _To,
Node, _Lang) -> Node, _Lang) ->
if if
(LFrom == LTo) and (LSFrom == LSTo) -> (LFrom == LTo) and (LSFrom == LSTo) ->
@ -411,11 +440,11 @@ get_publish_items(Acc, _From, _To, _Node, _Lang) ->
process_disco_publish(User, Node, Items) -> process_disco_publish(User, Node, Items) ->
F = fun() -> F = fun() ->
lists:foreach( lists:foreach(
fun({xmlelement, _Name, _Attrs, _SubEls} = Item) -> fun(#xmlel{} = Item) ->
Action = xml:get_tag_attr_s("action", Item), Action = exmpp_xml:get_attribute(Item, 'action'),
Jid = xml:get_tag_attr_s("jid", Item), Jid = exmpp_xml:get_attribute(Item, 'jid'),
PNode = xml:get_tag_attr_s("node", Item), PNode = exmpp_xml:get_attribute(Item, 'node'),
Name = xml:get_tag_attr_s("name", Item), Name = exmpp_xml:get_attribute(Item, 'name'),
?INFO_MSG("Disco publish: ~p ~p ~p ~p ~p ~p~n", ?INFO_MSG("Disco publish: ~p ~p ~p ~p ~p ~p~n",
[User, Action, Node, Jid, PNode, Name]), [User, Action, Node, Jid, PNode, Name]),
@ -442,7 +471,7 @@ process_disco_publish(User, Node, Items) ->
"remove" -> "remove" ->
case SupersededItems of case SupersededItems of
[] -> [] ->
mnesia:abort({error, ?ERR_ITEM_NOT_FOUND}); mnesia:abort({error, 'item-not-found'});
_ -> _ ->
lists:map( lists:map(
fun(O) -> fun(O) ->
@ -451,9 +480,9 @@ process_disco_publish(User, Node, Items) ->
end; end;
_ -> _ ->
%% invalid "action" attribute - return an error %% invalid "action" attribute - return an error
mnesia:abort({error, ?ERR_BAD_REQUEST}) mnesia:abort({error, 'bad-request'})
end; end;
({xmlcdata, _CDATA}) -> (#xmlcdata{}) ->
ok ok
end, Items) end, Items)
end, end,
@ -463,13 +492,13 @@ process_disco_publish(User, Node, Items) ->
{atomic, _} -> {atomic, _} ->
ok; ok;
_ -> _ ->
{error, ?ERR_INTERNAL_SERVER_ERROR} {error, 'internal-server-error'}
end. end.
retrieve_disco_publish(User, Node) -> retrieve_disco_publish(User, Node) ->
case catch mnesia:dirty_read({disco_publish, {User, Node}}) of case catch mnesia:dirty_read({disco_publish, {User, Node}}) of
{'EXIT', _Reason} -> {'EXIT', _Reason} ->
{error, ?ERR_INTERNAL_SERVER_ERROR}; {error, 'internal-server-error'};
[] -> [] ->
empty; empty;
Items -> Items ->
@ -478,20 +507,20 @@ retrieve_disco_publish(User, Node) ->
fun(#disco_publish{jid = Jid, fun(#disco_publish{jid = Jid,
name = Name, name = Name,
node = PNode}) -> node = PNode}) ->
{xmlelement, "item", #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
lists:append([[{"jid", Jid}], lists:append([[#xmlattr{name = 'jid', value = Jid}],
case Name of case Name of
"" -> "" ->
[]; [];
_ -> _ ->
[{"name", Name}] [#xmlattr{name = 'name', value = Name}]
end, end,
case PNode of case PNode of
"" -> "" ->
[]; [];
_ -> _ ->
[{"node", PNode}] [#xmlattr{name = 'node', value = PNode}]
end]), []} end])}
end, Items)} end, Items)}
end. end.