mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
A lot of bug fixes regarding attribute values type:
o Fix some bugs by getting attributes as list() instead of binary(). o Instead creating #xmlattr directly, use the new ?XMLATTR macro; it'll take care of the anything-to-binary() conversion. o Fix a bug where recipient and sender were used as binary() instead of list(), which is required by the rest of the S2S code. o Fix a bug where binary_to_list/1 was called on a list(). Now concerning JIDs : o Now that #jid{} isn't part of the API of Exmppp anymore, replace remaining direct usages by calls to exmpp_jid. o Replace exmpp_jid:make_bare_jid() by exmpp_jid:make_jid(). o Replace exmpp_jid:*_to_jid/1 by exmpp_jid:parse_jid/1. PR: EJABP-1 SVN Revision: 1841
This commit is contained in:
parent
376ee2ed90
commit
842ebfcca0
37
ChangeLog
37
ChangeLog
@ -13,6 +13,43 @@
|
|||||||
binary() version of LUser and LServer.
|
binary() version of LUser and LServer.
|
||||||
(convert_to_exmpp2/2): User and server are stored as binary().
|
(convert_to_exmpp2/2): User and server are stored as binary().
|
||||||
|
|
||||||
|
* src/adhoc.erl, src/ejabberd_c2s.erl, src/ejabberd_s2s.erl,
|
||||||
|
src/ejabberd_s2s_in.erl, src/ejabberd_s2s_out.erl,
|
||||||
|
src/ejabberd_service.erl, src/ejabberd_sm.erl,
|
||||||
|
src/ejabberd_system_monitor.erl, src/jd2ejd.erl, src/jlib.erl,
|
||||||
|
src/mod_adhoc.erl, src/mod_announce.erl, src/mod_caps.erl,
|
||||||
|
src/mod_configure.erl, src/mod_configure2.erl, src/mod_disco.erl,
|
||||||
|
src/mod_irc/mod_irc.erl, src/mod_irc/mod_irc_connection.erl,
|
||||||
|
src/mod_last.erl, src/mod_last_odbc.erl, src/mod_muc/mod_muc.erl,
|
||||||
|
src/mod_muc/mod_muc_log.erl, src/mod_muc/mod_muc_room.erl,
|
||||||
|
src/mod_offline.erl, src/mod_offline_odbc.erl, src/mod_privacy.erl,
|
||||||
|
src/mod_privacy_odbc.erl, src/mod_proxy65/mod_proxy65_service.erl,
|
||||||
|
src/mod_pubsub/mod_pubsub.erl, src/mod_register.erl,
|
||||||
|
src/mod_roster.erl, src/mod_roster_odbc.erl, src/mod_service_log.erl,
|
||||||
|
src/mod_shared_roster.erl, src/mod_stats.erl, src/mod_vcard.erl,
|
||||||
|
src/mod_vcard_ldap.erl, src/mod_vcard_odbc.erl,
|
||||||
|
src/web/ejabberd_http_poll.erl, src/web/ejabberd_web.erl,
|
||||||
|
src/web/ejabberd_web_admin.erl: Now that #jid{} isn't part of the API
|
||||||
|
of Exmppp anymore, replace remaining direct usages by calls to
|
||||||
|
exmpp_jid. Replace exmpp_jid:make_bare_jid() by exmpp_jid:make_jid().
|
||||||
|
Replace exmpp_jid:*_to_jid/1 by exmpp_jid:parse_jid/1. Instead
|
||||||
|
creating #xmlattr directly, use the new ?XMLATTR macro; it'll take
|
||||||
|
care of the anything-to-binary() conversion.
|
||||||
|
|
||||||
|
* src/adhoc.erl, src/mod_caps.erl (read_caps/2), src/mod_offline.erl
|
||||||
|
(find_x_expire/2), src/mod_offline_odbc.erl, src/jd2ejd.erl,
|
||||||
|
src/mod_muc/mod_muc.erl, src/mod_irc/mod_irc_connection.erl,
|
||||||
|
src/mod_privacy_odbc.erl, src/mod_privacy.erl, src/jlib.erl,
|
||||||
|
src/mod_pubsub/mod_pubsub.erl, src/mod_stats.erl: Fix some bugs by
|
||||||
|
getting attributes as list() instead of binary().
|
||||||
|
|
||||||
|
* src/mod_muc/mod_muc.erl (terminate/2): Fix a bug where
|
||||||
|
binary_to_list/1 was called on a list().
|
||||||
|
|
||||||
|
* src/ejabberd_s2s_in.erl (is_packet_key/1): Fix a bug where recipient
|
||||||
|
and sender were used as binary() instead of list(), which is required
|
||||||
|
by the rest of the S2S code.
|
||||||
|
|
||||||
2009-01-19 Pablo Polvorin <pablo.polvorin@process-one.net>
|
2009-01-19 Pablo Polvorin <pablo.polvorin@process-one.net>
|
||||||
|
|
||||||
* src/cyrsasl_digest.erl: Typo (prolists -> proplists).
|
* src/cyrsasl_digest.erl: Typo (prolists -> proplists).
|
||||||
|
@ -43,9 +43,9 @@ parse_request(#iq{type = Type, ns = NS, payload = SubEl, lang = Lang}) ->
|
|||||||
case {Type, NS} of
|
case {Type, NS} of
|
||||||
{set, ?NS_ADHOC} ->
|
{set, ?NS_ADHOC} ->
|
||||||
?DEBUG("entering parse_request...", []),
|
?DEBUG("entering parse_request...", []),
|
||||||
Node = exmpp_xml:get_attribute(SubEl, 'node', ""),
|
Node = exmpp_xml:get_attribute_as_list(SubEl, 'node', ""),
|
||||||
SessionID = exmpp_xml:get_attribute(SubEl, 'sessionid', ""),
|
SessionID = exmpp_xml:get_attribute_as_list(SubEl, 'sessionid', ""),
|
||||||
Action = exmpp_xml:get_attribute(SubEl, 'action', ""),
|
Action = exmpp_xml:get_attribute_as_list(SubEl, 'action', ""),
|
||||||
XData = find_xdata_el(SubEl),
|
XData = find_xdata_el(SubEl),
|
||||||
AllEls = exmpp_xml:get_child_elements(SubEl),
|
AllEls = exmpp_xml:get_child_elements(SubEl),
|
||||||
if XData ->
|
if XData ->
|
||||||
@ -113,7 +113,7 @@ produce_response(#adhoc_response{lang = _Lang,
|
|||||||
"" ->
|
"" ->
|
||||||
ActionsElAttrs = [];
|
ActionsElAttrs = [];
|
||||||
_ ->
|
_ ->
|
||||||
ActionsElAttrs = [#xmlattr{name = 'execute', value = list_to_binary(DefaultAction)}]
|
ActionsElAttrs = [?XMLATTR('execute', DefaultAction)]
|
||||||
end,
|
end,
|
||||||
ActionsEls = [#xmlel{ns = ?NS_ADHOC, name = 'actions', attrs =
|
ActionsEls = [#xmlel{ns = ?NS_ADHOC, name = 'actions', attrs =
|
||||||
ActionsElAttrs, children =
|
ActionsElAttrs, children =
|
||||||
@ -121,11 +121,11 @@ produce_response(#adhoc_response{lang = _Lang,
|
|||||||
end,
|
end,
|
||||||
NotesEls = lists:map(fun({Type, Text}) ->
|
NotesEls = lists:map(fun({Type, Text}) ->
|
||||||
#xmlel{ns = ?NS_ADHOC, name = 'note', attrs =
|
#xmlel{ns = ?NS_ADHOC, name = 'note', attrs =
|
||||||
[#xmlattr{name = 'type', value = list_to_binary(Type)}],
|
[?XMLATTR('type', Type)],
|
||||||
children = [#xmlcdata{cdata = list_to_binary(Text)}]}
|
children = [#xmlcdata{cdata = list_to_binary(Text)}]}
|
||||||
end, Notes),
|
end, Notes),
|
||||||
#xmlel{ns = ?NS_ADHOC, name = 'command', attrs =
|
#xmlel{ns = ?NS_ADHOC, name = 'command', attrs =
|
||||||
[#xmlattr{name = 'sessionid', value = list_to_binary(SessionID)},
|
[?XMLATTR('sessionid', SessionID),
|
||||||
#xmlattr{name = 'node', value = list_to_binary(Node)},
|
?XMLATTR('node', Node),
|
||||||
#xmlattr{name = 'status', value = list_to_binary(atom_to_list(Status))}], children =
|
?XMLATTR('status', Status)], children =
|
||||||
ActionsEls ++ NotesEls ++ Elements}.
|
ActionsEls ++ NotesEls ++ Elements}.
|
||||||
|
@ -241,7 +241,7 @@ wait_for_stream({xmlstreamstart, #xmlel{ns = NS} = Opening}, StateData) ->
|
|||||||
true ->
|
true ->
|
||||||
Lang = exmpp_stream:get_lang(Opening),
|
Lang = exmpp_stream:get_lang(Opening),
|
||||||
change_shaper(StateData,
|
change_shaper(StateData,
|
||||||
exmpp_jid:make_bare_jid(Server)),
|
exmpp_jid:make_jid(Server)),
|
||||||
case exmpp_stream:get_version(Opening) of
|
case exmpp_stream:get_version(Opening) of
|
||||||
{1, 0} ->
|
{1, 0} ->
|
||||||
send_element(StateData, Header),
|
send_element(StateData, Header),
|
||||||
@ -398,7 +398,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
|
|||||||
{auth, _ID, set, {U, P, D, R}} ->
|
{auth, _ID, set, {U, P, D, R}} ->
|
||||||
try
|
try
|
||||||
JID = exmpp_jid:make_jid(U, StateData#state.server, R),
|
JID = exmpp_jid:make_jid(U, StateData#state.server, R),
|
||||||
UBinary = exmpp_jid:lnode(JID),
|
UBinary = exmpp_jid:lnode(JID),
|
||||||
case acl:match_rule(ServerString,
|
case acl:match_rule(ServerString,
|
||||||
StateData#state.access, JID) of
|
StateData#state.access, JID) of
|
||||||
allow ->
|
allow ->
|
||||||
@ -506,7 +506,7 @@ wait_for_feature_request({xmlstreamelement, #xmlel{ns = NS, name = Name} = El},
|
|||||||
{?NS_SASL, 'auth'} when not ((SockMod == gen_tcp) and TLSRequired) ->
|
{?NS_SASL, 'auth'} when not ((SockMod == gen_tcp) and TLSRequired) ->
|
||||||
{auth, Mech, ClientIn} = exmpp_server_sasl:next_step(El),
|
{auth, Mech, ClientIn} = exmpp_server_sasl:next_step(El),
|
||||||
case cyrsasl:server_start(StateData#state.sasl_state,
|
case cyrsasl:server_start(StateData#state.sasl_state,
|
||||||
Mech,
|
binary_to_list(Mech),
|
||||||
ClientIn) of
|
ClientIn) of
|
||||||
{ok, Props} ->
|
{ok, Props} ->
|
||||||
(StateData#state.sockmod):reset_stream(
|
(StateData#state.sockmod):reset_stream(
|
||||||
@ -833,7 +833,7 @@ session_established2(El, StateData) ->
|
|||||||
undefined ->
|
undefined ->
|
||||||
exmpp_jid:jid_to_bare_jid(StateData#state.jid);
|
exmpp_jid:jid_to_bare_jid(StateData#state.jid);
|
||||||
_ ->
|
_ ->
|
||||||
exmpp_jid:binary_to_jid(To)
|
exmpp_jid:parse_jid(To)
|
||||||
end,
|
end,
|
||||||
NewEl = case exmpp_stanza:get_lang(El) of
|
NewEl = case exmpp_stanza:get_lang(El) of
|
||||||
undefined ->
|
undefined ->
|
||||||
@ -1848,7 +1848,7 @@ process_unauthenticated_stanza(StateData, El) when ?IS_IQ(El) ->
|
|||||||
ResIQ = exmpp_iq:error_without_original(El,
|
ResIQ = exmpp_iq:error_without_original(El,
|
||||||
'service-unavailable'),
|
'service-unavailable'),
|
||||||
Res1 = exmpp_stanza:set_sender(ResIQ,
|
Res1 = exmpp_stanza:set_sender(ResIQ,
|
||||||
exmpp_jid:make_bare_jid(StateData#state.server)),
|
exmpp_jid:make_jid(StateData#state.server)),
|
||||||
Res2 = exmpp_stanza:remove_recipient(Res1),
|
Res2 = exmpp_stanza:remove_recipient(Res1),
|
||||||
send_element(StateData, Res2);
|
send_element(StateData, Res2);
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -406,14 +406,14 @@ new_connection(MyServer, Server, From, FromTo,
|
|||||||
|
|
||||||
max_s2s_connections_number({From, To}) ->
|
max_s2s_connections_number({From, To}) ->
|
||||||
case acl:match_rule(
|
case acl:match_rule(
|
||||||
From, max_s2s_connections, exmpp_jid:make_bare_jid(To)) of
|
From, max_s2s_connections, exmpp_jid:make_jid(To)) of
|
||||||
Max when is_integer(Max) -> Max;
|
Max when is_integer(Max) -> Max;
|
||||||
_ -> ?DEFAULT_MAX_S2S_CONNECTIONS_NUMBER
|
_ -> ?DEFAULT_MAX_S2S_CONNECTIONS_NUMBER
|
||||||
end.
|
end.
|
||||||
|
|
||||||
max_s2s_connections_number_per_node({From, To}) ->
|
max_s2s_connections_number_per_node({From, To}) ->
|
||||||
case acl:match_rule(
|
case acl:match_rule(
|
||||||
From, max_s2s_connections_per_node, exmpp_jid:make_bare_jid(To)) of
|
From, max_s2s_connections_per_node, exmpp_jid:make_jid(To)) of
|
||||||
Max when is_integer(Max) -> Max;
|
Max when is_integer(Max) -> Max;
|
||||||
_ -> ?DEFAULT_MAX_S2S_CONNECTIONS_NUMBER_PER_NODE
|
_ -> ?DEFAULT_MAX_S2S_CONNECTIONS_NUMBER_PER_NODE
|
||||||
end.
|
end.
|
||||||
|
@ -346,7 +346,7 @@ stream_established({xmlstreamelement, El}, StateData) ->
|
|||||||
Conns = ?DICT:store({LFrom, LTo}, wait_for_verification,
|
Conns = ?DICT:store({LFrom, LTo}, wait_for_verification,
|
||||||
StateData#state.connections),
|
StateData#state.connections),
|
||||||
change_shaper(StateData, LTo,
|
change_shaper(StateData, LTo,
|
||||||
exmpp_jid:make_bare_jid(LFrom)),
|
exmpp_jid:make_jid(LFrom)),
|
||||||
{next_state,
|
{next_state,
|
||||||
stream_established,
|
stream_established,
|
||||||
StateData#state{connections = Conns,
|
StateData#state{connections = Conns,
|
||||||
@ -371,7 +371,7 @@ stream_established({xmlstreamelement, El}, StateData) ->
|
|||||||
error;
|
error;
|
||||||
F ->
|
F ->
|
||||||
try
|
try
|
||||||
exmpp_jid:binary_to_jid(F)
|
exmpp_jid:parse_jid(F)
|
||||||
catch
|
catch
|
||||||
_Exception1 -> error
|
_Exception1 -> error
|
||||||
end
|
end
|
||||||
@ -381,7 +381,7 @@ stream_established({xmlstreamelement, El}, StateData) ->
|
|||||||
error;
|
error;
|
||||||
T ->
|
T ->
|
||||||
try
|
try
|
||||||
exmpp_jid:binary_to_jid(T)
|
exmpp_jid:parse_jid(T)
|
||||||
catch
|
catch
|
||||||
_Exception2 -> error
|
_Exception2 -> error
|
||||||
end
|
end
|
||||||
@ -580,15 +580,15 @@ cancel_timer(Timer) ->
|
|||||||
is_key_packet(#xmlel{ns = ?NS_DIALBACK, name = 'result',
|
is_key_packet(#xmlel{ns = ?NS_DIALBACK, name = 'result',
|
||||||
attrs = Attrs} = El) ->
|
attrs = Attrs} = El) ->
|
||||||
{key,
|
{key,
|
||||||
exmpp_stanza:get_recipient_from_attrs(Attrs),
|
binary_to_list(exmpp_stanza:get_recipient_from_attrs(Attrs)),
|
||||||
exmpp_stanza:get_sender_from_attrs(Attrs),
|
binary_to_list(exmpp_stanza:get_sender_from_attrs(Attrs)),
|
||||||
exmpp_stanza:get_id_from_attrs(Attrs),
|
exmpp_stanza:get_id_from_attrs(Attrs),
|
||||||
exmpp_xml:get_cdata_as_list(El)};
|
exmpp_xml:get_cdata_as_list(El)};
|
||||||
is_key_packet(#xmlel{ns = ?NS_DIALBACK, name = 'verify',
|
is_key_packet(#xmlel{ns = ?NS_DIALBACK, name = 'verify',
|
||||||
attrs = Attrs} = El) ->
|
attrs = Attrs} = El) ->
|
||||||
{verify,
|
{verify,
|
||||||
exmpp_stanza:get_recipient_from_attrs(Attrs),
|
binary_to_list(exmpp_stanza:get_recipient_from_attrs(Attrs)),
|
||||||
exmpp_stanza:get_sender_from_attrs(Attrs),
|
binary_to_list(exmpp_stanza:get_sender_from_attrs(Attrs)),
|
||||||
exmpp_stanza:get_id_from_attrs(Attrs),
|
exmpp_stanza:get_id_from_attrs(Attrs),
|
||||||
exmpp_xml:get_cdata_as_list(El)};
|
exmpp_xml:get_cdata_as_list(El)};
|
||||||
is_key_packet(_) ->
|
is_key_packet(_) ->
|
||||||
@ -612,7 +612,7 @@ get_cert_domains(Cert) ->
|
|||||||
end,
|
end,
|
||||||
if
|
if
|
||||||
D /= error ->
|
D /= error ->
|
||||||
JID = exmpp_jid:list_to_jid(D),
|
JID = exmpp_jid:parse_jid(D),
|
||||||
case {exmpp_jid:lnode_as_list(JID),
|
case {exmpp_jid:lnode_as_list(JID),
|
||||||
exmpp_jid:ldomain_as_list(JID),
|
exmpp_jid:ldomain_as_list(JID),
|
||||||
exmpp_jid:lresource_as_list(JID)} of
|
exmpp_jid:lresource_as_list(JID)} of
|
||||||
@ -648,7 +648,7 @@ get_cert_domains(Cert) ->
|
|||||||
case 'XmppAddr':decode(
|
case 'XmppAddr':decode(
|
||||||
'XmppAddr', XmppAddr) of
|
'XmppAddr', XmppAddr) of
|
||||||
{ok, D} when is_binary(D) ->
|
{ok, D} when is_binary(D) ->
|
||||||
JID2 = exmpp_jid:list_to_jid(binary_to_list(D)),
|
JID2 = exmpp_jid:parse_jid(binary_to_list(D)),
|
||||||
case {exmpp_jid:lnode_as_list(JID2),
|
case {exmpp_jid:lnode_as_list(JID2),
|
||||||
exmpp_jid:ldomain_as_list(JID2),
|
exmpp_jid:ldomain_as_list(JID2),
|
||||||
exmpp_jid:lresource_as_list(JID2)} of
|
exmpp_jid:lresource_as_list(JID2)} of
|
||||||
@ -666,7 +666,7 @@ get_cert_domains(Cert) ->
|
|||||||
[]
|
[]
|
||||||
end;
|
end;
|
||||||
({dNSName, D}) when is_list(D) ->
|
({dNSName, D}) when is_list(D) ->
|
||||||
JID3 = exmpp_jid:list_to_jid(D),
|
JID3 = exmpp_jid:parse_jid(D),
|
||||||
case {exmpp_jid:lnode_as_list(JID3),
|
case {exmpp_jid:lnode_as_list(JID3),
|
||||||
exmpp_jid:ldomain_as_list(JID3),
|
exmpp_jid:ldomain_as_list(JID3),
|
||||||
exmpp_jid:lresource_as_list(JID3)} of
|
exmpp_jid:lresource_as_list(JID3)} of
|
||||||
|
@ -819,8 +819,8 @@ bounce_element(El, Condition) ->
|
|||||||
<<"result">> -> ok;
|
<<"result">> -> ok;
|
||||||
_ ->
|
_ ->
|
||||||
Err = exmpp_stanza:reply_with_error(El, Condition),
|
Err = exmpp_stanza:reply_with_error(El, Condition),
|
||||||
From = exmpp_jid:binary_to_jid(exmpp_stanza:get_sender(El)),
|
From = exmpp_jid:parse_jid(exmpp_stanza:get_sender(El)),
|
||||||
To = exmpp_jid:binary_to_jid(exmpp_stanza:get_recipient(El)),
|
To = exmpp_jid:parse_jid(exmpp_stanza:get_recipient(El)),
|
||||||
% No namespace conversion (:server <-> :client) is done.
|
% No namespace conversion (:server <-> :client) is done.
|
||||||
% This is handled by C2S and S2S send_element functions.
|
% This is handled by C2S and S2S send_element functions.
|
||||||
ejabberd_router:route(To, From, Err)
|
ejabberd_router:route(To, From, Err)
|
||||||
|
@ -227,10 +227,10 @@ stream_established({xmlstreamelement, El}, StateData) ->
|
|||||||
%% when accept packets from any address.
|
%% when accept packets from any address.
|
||||||
%% In this case, the component can send packet of
|
%% In this case, the component can send packet of
|
||||||
%% behalf of the server users.
|
%% behalf of the server users.
|
||||||
false -> exmpp_jid:binary_to_jid(From);
|
false -> exmpp_jid:parse_jid(From);
|
||||||
%% The default is the standard behaviour in XEP-0114
|
%% The default is the standard behaviour in XEP-0114
|
||||||
_ ->
|
_ ->
|
||||||
FromJID1 = exmpp_jid:binary_to_jid(From),
|
FromJID1 = exmpp_jid:parse_jid(From),
|
||||||
Server = exmpp_jid:ldomain_as_list(FromJID1),
|
Server = exmpp_jid:ldomain_as_list(FromJID1),
|
||||||
case lists:member(Server, StateData#state.hosts) of
|
case lists:member(Server, StateData#state.hosts) of
|
||||||
true -> FromJID1;
|
true -> FromJID1;
|
||||||
|
@ -142,7 +142,7 @@ bounce_offline_message(From, To, Packet) ->
|
|||||||
|
|
||||||
disconnect_removed_user(User, Server) ->
|
disconnect_removed_user(User, Server) ->
|
||||||
ejabberd_sm:route(exmpp_jid:make_jid(),
|
ejabberd_sm:route(exmpp_jid:make_jid(),
|
||||||
exmpp_jid:make_bare_jid(User,
|
exmpp_jid:make_jid(User,
|
||||||
Server),
|
Server),
|
||||||
#xmlel{name = 'broadcast',
|
#xmlel{name = 'broadcast',
|
||||||
children = [{exit, "User removed"}]}).
|
children = [{exit, "User removed"}]}).
|
||||||
|
@ -174,7 +174,7 @@ process_large_heap(Pid, Info) ->
|
|||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(S) ->
|
fun(S) ->
|
||||||
try
|
try
|
||||||
JID = exmpp_jid:list_to_jid(S),
|
JID = exmpp_jid:parse_jid(S),
|
||||||
send_message(From, JID, Body)
|
send_message(From, JID, Body)
|
||||||
catch
|
catch
|
||||||
_ ->
|
_ ->
|
||||||
@ -196,7 +196,7 @@ get_admin_jids() ->
|
|||||||
lists:flatmap(
|
lists:flatmap(
|
||||||
fun(S) ->
|
fun(S) ->
|
||||||
try
|
try
|
||||||
JID = exmpp_jid:list_to_jid(S),
|
JID = exmpp_jid:parse_jid(S),
|
||||||
[{exmpp_jid:lnode(JID),
|
[{exmpp_jid:lnode(JID),
|
||||||
exmpp_jid:ldomain(JID),
|
exmpp_jid:ldomain(JID),
|
||||||
exmpp_jid:lresource(JID)}]
|
exmpp_jid:lresource(JID)}]
|
||||||
|
@ -115,7 +115,7 @@ process_xdb(_User, _Server, _El) ->
|
|||||||
xdb_data(_User, _Server, #xmlcdata{}) ->
|
xdb_data(_User, _Server, #xmlcdata{}) ->
|
||||||
ok;
|
ok;
|
||||||
xdb_data(User, Server, #xmlel{ns = NS} = El) ->
|
xdb_data(User, Server, #xmlel{ns = NS} = El) ->
|
||||||
From = exmpp_jid:make_bare_jid(User, Server),
|
From = exmpp_jid:make_jid(User, Server),
|
||||||
LServer = exmpp_stringprep:nameprep(Server),
|
LServer = exmpp_stringprep:nameprep(Server),
|
||||||
case NS of
|
case NS of
|
||||||
?NS_LEGACY_AUTH ->
|
?NS_LEGACY_AUTH ->
|
||||||
@ -132,7 +132,7 @@ xdb_data(User, Server, #xmlel{ns = NS} = El) ->
|
|||||||
end,
|
end,
|
||||||
ok;
|
ok;
|
||||||
?NS_LAST_ACTIVITY ->
|
?NS_LAST_ACTIVITY ->
|
||||||
TimeStamp = exmpp_xml:get_attribute(El, 'last', ""),
|
TimeStamp = exmpp_xml:get_attribute_as_list(El, 'last', ""),
|
||||||
Status = exmpp_xml:get_cdata(El),
|
Status = exmpp_xml:get_cdata(El),
|
||||||
case lists:member(mod_last_odbc,
|
case lists:member(mod_last_odbc,
|
||||||
gen_mod:loaded_modules(LServer)) of
|
gen_mod:loaded_modules(LServer)) of
|
||||||
@ -156,12 +156,12 @@ xdb_data(User, Server, #xmlel{ns = NS} = El) ->
|
|||||||
true ->
|
true ->
|
||||||
catch mod_vcard_odbc:process_sm_iq(
|
catch mod_vcard_odbc:process_sm_iq(
|
||||||
From,
|
From,
|
||||||
exmpp_jid:make_bare_jid(Server),
|
exmpp_jid:make_jid(Server),
|
||||||
#iq{kind = request, type = set, ns = ?NS_VCARD, payload = El, iq_ns = ?NS_JABBER_CLIENT});
|
#iq{kind = request, type = set, ns = ?NS_VCARD, payload = El, iq_ns = ?NS_JABBER_CLIENT});
|
||||||
false ->
|
false ->
|
||||||
catch mod_vcard:process_sm_iq(
|
catch mod_vcard:process_sm_iq(
|
||||||
From,
|
From,
|
||||||
exmpp_jid:make_bare_jid(Server),
|
exmpp_jid:make_jid(Server),
|
||||||
#iq{kind = request, type = set, ns = ?NS_VCARD, payload = El, iq_ns = ?NS_JABBER_CLIENT})
|
#iq{kind = request, type = set, ns = ?NS_VCARD, payload = El, iq_ns = ?NS_JABBER_CLIENT})
|
||||||
end,
|
end,
|
||||||
ok;
|
ok;
|
||||||
@ -169,11 +169,11 @@ xdb_data(User, Server, #xmlel{ns = NS} = El) ->
|
|||||||
process_offline(Server, From, El),
|
process_offline(Server, From, El),
|
||||||
ok;
|
ok;
|
||||||
XMLNS ->
|
XMLNS ->
|
||||||
case exmpp_xml:get_attribute(El, "j_private_flag", "") of
|
case exmpp_xml:get_attribute_as_list(El, "j_private_flag", "") of
|
||||||
"1" ->
|
"1" ->
|
||||||
catch mod_private:process_sm_iq(
|
catch mod_private:process_sm_iq(
|
||||||
From,
|
From,
|
||||||
exmpp_jid:make_bare_jid(Server),
|
exmpp_jid:make_jid(Server),
|
||||||
#iq{kind = request, type = set, ns = ?NS_PRIVATE,
|
#iq{kind = request, type = set, ns = ?NS_PRIVATE,
|
||||||
iq_ns = ?NS_JABBER_CLIENT,
|
iq_ns = ?NS_JABBER_CLIENT,
|
||||||
payload = #xmlel{name = 'query', children =
|
payload = #xmlel{name = 'query', children =
|
||||||
@ -192,10 +192,10 @@ process_offline(Server, To, #xmlel{children = Els}) ->
|
|||||||
FromS = exmpp_stanza:get_sender(El),
|
FromS = exmpp_stanza:get_sender(El),
|
||||||
From = case FromS of
|
From = case FromS of
|
||||||
undefined ->
|
undefined ->
|
||||||
exmpp_jid:make_bare_jid(Server);
|
exmpp_jid:make_jid(Server);
|
||||||
_ ->
|
_ ->
|
||||||
try
|
try
|
||||||
exmpp_jid:list_to_jid(FromS)
|
exmpp_jid:parse_jid(FromS)
|
||||||
catch
|
catch
|
||||||
_ ->
|
_ ->
|
||||||
error
|
error
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
|
|
||||||
|
|
||||||
parse_xdata_submit(#xmlel{attrs = Attrs, children = Els}) ->
|
parse_xdata_submit(#xmlel{attrs = Attrs, children = Els}) ->
|
||||||
case exmpp_xml:get_attribute_from_list(Attrs, 'type', "") of
|
case exmpp_xml:get_attribute_from_list_as_list(Attrs, 'type', "") of
|
||||||
"submit" ->
|
"submit" ->
|
||||||
lists:reverse(parse_xdata_fields(Els, []));
|
lists:reverse(parse_xdata_fields(Els, []));
|
||||||
_ ->
|
_ ->
|
||||||
@ -62,7 +62,7 @@ parse_xdata_fields([], Res) ->
|
|||||||
Res;
|
Res;
|
||||||
parse_xdata_fields([#xmlel{name = 'field', attrs = Attrs, children = SubEls} |
|
parse_xdata_fields([#xmlel{name = 'field', attrs = Attrs, children = SubEls} |
|
||||||
Els], Res) ->
|
Els], Res) ->
|
||||||
case exmpp_xml:get_attribute_from_list(Attrs, 'var', "") of
|
case exmpp_xml:get_attribute_from_list_as_list(Attrs, 'var', "") of
|
||||||
"" ->
|
"" ->
|
||||||
parse_xdata_fields(Els, Res);
|
parse_xdata_fields(Els, Res);
|
||||||
Var ->
|
Var ->
|
||||||
@ -132,7 +132,7 @@ rsm_encode_first(undefined, undefined, Arr) ->
|
|||||||
rsm_encode_first(First, undefined, Arr) ->
|
rsm_encode_first(First, undefined, Arr) ->
|
||||||
[#xmlel{ns = ?NS_RSM, name = 'first', children = [#xmlcdata{cdata = list_to_binary(First)}]}|Arr];
|
[#xmlel{ns = ?NS_RSM, name = 'first', children = [#xmlcdata{cdata = list_to_binary(First)}]}|Arr];
|
||||||
rsm_encode_first(First, Index, Arr) ->
|
rsm_encode_first(First, Index, Arr) ->
|
||||||
[#xmlel{ns = ?NS_RSM, name = 'first', attrs = [#xmlattr{name = 'index', value = i2b(Index)}], children = [#xmlcdata{cdata = list_to_binary(First)}]}|Arr].
|
[#xmlel{ns = ?NS_RSM, name = 'first', attrs = [?XMLATTR('index', Index)], children = [#xmlcdata{cdata = list_to_binary(First)}]}|Arr].
|
||||||
|
|
||||||
rsm_encode_last(undefined, Arr) -> Arr;
|
rsm_encode_last(undefined, Arr) -> Arr;
|
||||||
rsm_encode_last(Last, Arr) ->
|
rsm_encode_last(Last, Arr) ->
|
||||||
|
@ -95,10 +95,9 @@ get_local_commands(Acc, _From, To, <<>>, Lang) ->
|
|||||||
end,
|
end,
|
||||||
Nodes = [#xmlel{ns = ?NS_DISCO_ITEMS,
|
Nodes = [#xmlel{ns = ?NS_DISCO_ITEMS,
|
||||||
name = 'item', attrs =
|
name = 'item', attrs =
|
||||||
[#xmlattr{name = 'jid', value = Server},
|
[?XMLATTR('jid', Server),
|
||||||
#xmlattr{name = 'node', value = list_to_binary(?NS_ADHOC_s)},
|
?XMLATTR('node', ?NS_ADHOC_s),
|
||||||
#xmlattr{name = 'name',
|
?XMLATTR('name', translate:translate(Lang, "Commands"))]
|
||||||
value = list_to_binary(translate:translate(Lang, "Commands"))}]
|
|
||||||
}],
|
}],
|
||||||
{result, Items ++ Nodes}
|
{result, Items ++ Nodes}
|
||||||
end;
|
end;
|
||||||
@ -127,9 +126,9 @@ get_sm_commands(Acc, _From, To, <<>>, Lang) ->
|
|||||||
end,
|
end,
|
||||||
Nodes = [#xmlel{ns = ?NS_DISCO_ITEMS,
|
Nodes = [#xmlel{ns = ?NS_DISCO_ITEMS,
|
||||||
name = 'item', attrs =
|
name = 'item', attrs =
|
||||||
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_binary(To)},
|
[?XMLATTR('jid', exmpp_jid:jid_to_binary(To)),
|
||||||
#xmlattr{name = 'node', value = list_to_binary(?NS_ADHOC_s)},
|
?XMLATTR('node', ?NS_ADHOC_s),
|
||||||
#xmlattr{name = 'name', value = list_to_binary(translate:translate(Lang, "Commands"))}]
|
?XMLATTR('name', translate:translate(Lang, "Commands"))]
|
||||||
}],
|
}],
|
||||||
{result, Items ++ Nodes}
|
{result, Items ++ Nodes}
|
||||||
end;
|
end;
|
||||||
@ -145,15 +144,15 @@ get_sm_commands(Acc, _From, _To, _Node, _Lang) ->
|
|||||||
%% On disco info request to the ad-hoc node, return automation/command-list.
|
%% On disco info request to the ad-hoc node, return automation/command-list.
|
||||||
get_local_identity(Acc, _From, _To, ?NS_ADHOC_b, Lang) ->
|
get_local_identity(Acc, _From, _To, ?NS_ADHOC_b, Lang) ->
|
||||||
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
|
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
|
||||||
[#xmlattr{name = 'category', value = <<"automation">>},
|
[?XMLATTR('category', <<"automation">>),
|
||||||
#xmlattr{name = 'type', value = <<"command-list">>},
|
?XMLATTR('type', <<"command-list">>),
|
||||||
#xmlattr{name = 'name', value = list_to_binary(translate:translate(Lang, "Commands"))}]} | Acc];
|
?XMLATTR('name', translate:translate(Lang, "Commands"))]} | Acc];
|
||||||
|
|
||||||
get_local_identity(Acc, _From, _To, <<"ping">>, Lang) ->
|
get_local_identity(Acc, _From, _To, <<"ping">>, Lang) ->
|
||||||
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
|
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
|
||||||
[#xmlattr{name = 'category', value = <<"automation">>},
|
[?XMLATTR('category', <<"automation">>),
|
||||||
#xmlattr{name = 'type', value = <<"command-node">>},
|
?XMLATTR('type', <<"command-node">>),
|
||||||
#xmlattr{name = 'name', value = list_to_binary(translate:translate(Lang, "Ping"))}]} | Acc];
|
?XMLATTR('name', translate:translate(Lang, "Ping"))]} | Acc];
|
||||||
|
|
||||||
get_local_identity(Acc, _From, _To, _Node, _Lang) ->
|
get_local_identity(Acc, _From, _To, _Node, _Lang) ->
|
||||||
Acc.
|
Acc.
|
||||||
@ -163,9 +162,9 @@ get_local_identity(Acc, _From, _To, _Node, _Lang) ->
|
|||||||
%% On disco info request to the ad-hoc node, return automation/command-list.
|
%% On disco info request to the ad-hoc node, return automation/command-list.
|
||||||
get_sm_identity(Acc, _From, _To, ?NS_ADHOC_s, Lang) ->
|
get_sm_identity(Acc, _From, _To, ?NS_ADHOC_s, Lang) ->
|
||||||
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
|
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
|
||||||
[#xmlattr{name = 'category', value = <<"automation">>},
|
[?XMLATTR('category', <<"automation">>),
|
||||||
#xmlattr{name = 'type', value = <<"command-list">>},
|
?XMLATTR('type', <<"command-list">>),
|
||||||
#xmlattr{name = 'name', value = list_to_binary(translate:translate(Lang, "Commands"))}]} | Acc];
|
?XMLATTR('name', translate:translate(Lang, "Commands"))]} | Acc];
|
||||||
|
|
||||||
get_sm_identity(Acc, _From, _To, _Node, _Lang) ->
|
get_sm_identity(Acc, _From, _To, _Node, _Lang) ->
|
||||||
Acc.
|
Acc.
|
||||||
@ -245,9 +244,9 @@ ping_item(Acc, _From, To, Lang) ->
|
|||||||
[]
|
[]
|
||||||
end,
|
end,
|
||||||
Nodes = [#xmlel{ns = ?NS_DISCO_INFO, name = 'item', attrs =
|
Nodes = [#xmlel{ns = ?NS_DISCO_INFO, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'jid', value = Server},
|
[?XMLATTR('jid', Server),
|
||||||
#xmlattr{name = 'node', value = <<"ping">>},
|
?XMLATTR('node', <<"ping">>),
|
||||||
#xmlattr{name = 'name', value = list_to_binary(translate:translate(Lang, "Ping"))}]}],
|
?XMLATTR('name', translate:translate(Lang, "Ping"))]}],
|
||||||
{result, Items ++ Nodes}.
|
{result, Items ++ Nodes}.
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,9 +179,9 @@ announce(From, To, Packet) ->
|
|||||||
%% Announcing via ad-hoc commands
|
%% Announcing via ad-hoc commands
|
||||||
-define(INFO_COMMAND(Lang, Node),
|
-define(INFO_COMMAND(Lang, Node),
|
||||||
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
|
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
|
||||||
[#xmlattr{name = 'category', value = <<"automation">>},
|
[?XMLATTR('category', <<"automation">>),
|
||||||
#xmlattr{name = 'type', value = <<"command-node">>},
|
?XMLATTR('type', <<"command-node">>),
|
||||||
#xmlattr{name = 'name', value = list_to_binary(get_title(Lang, Node))}]}]).
|
?XMLATTR('name', get_title(Lang, Node))]}]).
|
||||||
|
|
||||||
disco_identity(Acc, _From, _To, Node, Lang) ->
|
disco_identity(Acc, _From, _To, Node, Lang) ->
|
||||||
LNode = tokenize(binary_to_list(Node)),
|
LNode = tokenize(binary_to_list(Node)),
|
||||||
@ -277,9 +277,9 @@ disco_features(Acc, From, To, Node, _Lang) ->
|
|||||||
|
|
||||||
-define(NODE_TO_ITEM(Lang, Server, Node),
|
-define(NODE_TO_ITEM(Lang, Server, Node),
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'jid', value = Server},
|
[?XMLATTR('jid', Server),
|
||||||
#xmlattr{name = 'node', value = Node},
|
?XMLATTR('node', Node),
|
||||||
#xmlattr{name = 'name', value = list_to_binary(get_title(Lang, Node))}]}).
|
?XMLATTR('name', get_title(Lang, Node))]}).
|
||||||
|
|
||||||
-define(ITEMS_RESULT(Allow, Items),
|
-define(ITEMS_RESULT(Allow, Items),
|
||||||
case Allow of
|
case Allow of
|
||||||
@ -488,8 +488,8 @@ announce_commands(From, To,
|
|||||||
_ -> [?VVALUE(Val)]
|
_ -> [?VVALUE(Val)]
|
||||||
end).
|
end).
|
||||||
-define(TVFIELD(Type, Var, Val),
|
-define(TVFIELD(Type, Var, Val),
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [#xmlattr{name = 'type', value = Type},
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', Type),
|
||||||
#xmlattr{name = 'var', value = Var}], children =
|
?XMLATTR('var', Var)], children =
|
||||||
?VVALUEL(Val)}).
|
?VVALUEL(Val)}).
|
||||||
-define(HFIELD(), ?TVFIELD(<<"hidden">>, <<"FORM_TYPE">>, list_to_binary(?NS_ADMIN_s))).
|
-define(HFIELD(), ?TVFIELD(<<"hidden">>, <<"FORM_TYPE">>, list_to_binary(?NS_ADMIN_s))).
|
||||||
|
|
||||||
@ -502,28 +502,28 @@ generate_adhoc_form(Lang, Node, ServerHost) ->
|
|||||||
{[], []}
|
{[], []}
|
||||||
end,
|
end,
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"form">>}], children =
|
[?XMLATTR('type', <<"form">>)], children =
|
||||||
[?HFIELD(),
|
[?HFIELD(),
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children = [#xmlcdata{cdata = list_to_binary(get_title(Lang, Node))}]}]
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children = [#xmlcdata{cdata = list_to_binary(get_title(Lang, Node))}]}]
|
||||||
++
|
++
|
||||||
if (LNode == ?NS_ADMINL("delete-motd"))
|
if (LNode == ?NS_ADMINL("delete-motd"))
|
||||||
or (LNode == ?NS_ADMINL("delete-motd-allhosts")) ->
|
or (LNode == ?NS_ADMINL("delete-motd-allhosts")) ->
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'var', value = <<"confirm">>},
|
[?XMLATTR('var', <<"confirm">>),
|
||||||
#xmlattr{name = 'type', value = <<"boolean">>},
|
?XMLATTR('type', <<"boolean">>),
|
||||||
#xmlattr{name = 'label', value = list_to_binary(translate:translate(Lang, "Really delete message of the day?"))}], children =
|
?XMLATTR('label', translate:translate(Lang, "Really delete message of the day?"))], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
|
||||||
[#xmlcdata{cdata = <<"true">>}]}]}];
|
[#xmlcdata{cdata = <<"true">>}]}]}];
|
||||||
true ->
|
true ->
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'var', value = <<"subject">>},
|
[?XMLATTR('var', <<"subject">>),
|
||||||
#xmlattr{name = 'type', value = <<"text-single">>},
|
?XMLATTR('type', <<"text-single">>),
|
||||||
#xmlattr{name = 'label', value = list_to_binary(translate:translate(Lang, "Subject"))}], children =
|
?XMLATTR('label', translate:translate(Lang, "Subject"))], children =
|
||||||
?VVALUEL(list_to_binary(OldSubject))},
|
?VVALUEL(list_to_binary(OldSubject))},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'var', value = <<"body">>},
|
[?XMLATTR('var', <<"body">>),
|
||||||
#xmlattr{name = 'type', value = <<"text-multi">>},
|
?XMLATTR('type', <<"text-multi">>),
|
||||||
#xmlattr{name = 'label', value = list_to_binary(translate:translate(Lang, "Message body"))}], children =
|
?XMLATTR('label', translate:translate(Lang, "Message body"))], children =
|
||||||
?VVALUEL(list_to_binary(OldBody))}]
|
?VVALUEL(list_to_binary(OldBody))}]
|
||||||
end}.
|
end}.
|
||||||
|
|
||||||
@ -569,7 +569,7 @@ handle_adhoc_form(From, To,
|
|||||||
node = Node,
|
node = Node,
|
||||||
sessionid = SessionID,
|
sessionid = SessionID,
|
||||||
status = completed},
|
status = completed},
|
||||||
Packet = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', attrs = [#xmlattr{name = 'type', value = <<"normal">>}], children =
|
Packet = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', attrs = [?XMLATTR('type', <<"normal">>)], children =
|
||||||
if Subject /= [] ->
|
if Subject /= [] ->
|
||||||
[#xmlel{ns = ?NS_JABBER_CLIENT, name = 'subject', children =
|
[#xmlel{ns = ?NS_JABBER_CLIENT, name = 'subject', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(Subject)}]}];
|
[#xmlcdata{cdata = list_to_binary(Subject)}]}];
|
||||||
|
@ -74,9 +74,9 @@
|
|||||||
read_caps(Els) ->
|
read_caps(Els) ->
|
||||||
read_caps(Els, nothing).
|
read_caps(Els, nothing).
|
||||||
read_caps([#xmlel{ns = ?NS_CAPS, name = 'c'} = El | Tail], _Result) ->
|
read_caps([#xmlel{ns = ?NS_CAPS, name = 'c'} = El | Tail], _Result) ->
|
||||||
Node = exmpp_xml:get_attribute(El, 'node', ""),
|
Node = exmpp_xml:get_attribute_as_list(El, 'node', ""),
|
||||||
Version = exmpp_xml:get_attribute(El, 'ver', ""),
|
Version = exmpp_xml:get_attribute_as_list(El, 'ver', ""),
|
||||||
Exts = string:tokens(exmpp_xml:get_attribute(El, 'ext', ""), " "),
|
Exts = string:tokens(exmpp_xml:get_attribute_as_list(El, 'ext', ""), " "),
|
||||||
read_caps(Tail, #caps{node = Node, version = Version, exts = Exts});
|
read_caps(Tail, #caps{node = Node, version = Version, exts = Exts});
|
||||||
read_caps([#xmlel{ns = ?NS_MUC_USER, name = 'x'} | _Tail], _Result) ->
|
read_caps([#xmlel{ns = ?NS_MUC_USER, name = 'x'} | _Tail], _Result) ->
|
||||||
nothing;
|
nothing;
|
||||||
@ -263,7 +263,7 @@ handle_cast({note_caps, From,
|
|||||||
Stanza = exmpp_iq:get(?NS_JABBER_CLIENT, Query, ID),
|
Stanza = exmpp_iq:get(?NS_JABBER_CLIENT, Query, ID),
|
||||||
ejabberd_local:register_iq_response_handler
|
ejabberd_local:register_iq_response_handler
|
||||||
(list_to_binary(Host), ID, ?MODULE, handle_disco_response),
|
(list_to_binary(Host), ID, ?MODULE, handle_disco_response),
|
||||||
ejabberd_router:route(exmpp_jid:make_bare_jid(Host),
|
ejabberd_router:route(exmpp_jid:make_jid(Host),
|
||||||
From, Stanza),
|
From, Stanza),
|
||||||
timer:send_after(?CAPS_QUERY_TIMEOUT, self(), {disco_timeout, ID}),
|
timer:send_after(?CAPS_QUERY_TIMEOUT, self(), {disco_timeout, ID}),
|
||||||
?DICT:store(ID, {Node, SubNode}, Dict)
|
?DICT:store(ID, {Node, SubNode}, Dict)
|
||||||
@ -281,7 +281,7 @@ handle_cast({disco_response, From, _To, #iq{id = ID, type = Type, payload = Payl
|
|||||||
{ok, {Node, SubNode}} ->
|
{ok, {Node, SubNode}} ->
|
||||||
Features =
|
Features =
|
||||||
lists:flatmap(fun(#xmlel{name = 'feature'} = F) ->
|
lists:flatmap(fun(#xmlel{name = 'feature'} = F) ->
|
||||||
[exmpp_xml:get_attribute(F, 'var', "")];
|
[exmpp_xml:get_attribute_as_list(F, 'var', "")];
|
||||||
(_) ->
|
(_) ->
|
||||||
[]
|
[]
|
||||||
end, Els),
|
end, Els),
|
||||||
|
@ -91,24 +91,24 @@ stop(Host) ->
|
|||||||
|
|
||||||
-define(INFO_IDENTITY(Category, Type, Name, Lang),
|
-define(INFO_IDENTITY(Category, Type, Name, Lang),
|
||||||
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
|
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
|
||||||
[#xmlattr{name = 'category', value = Category},
|
[?XMLATTR('category', Category),
|
||||||
#xmlattr{name = 'type', value = Type},
|
?XMLATTR('type', Type),
|
||||||
#xmlattr{name = 'name', value = ?T(Lang, Name)}]}]).
|
?XMLATTR('name', ?T(Lang, Name))]}]).
|
||||||
|
|
||||||
-define(INFO_COMMAND(Name, Lang),
|
-define(INFO_COMMAND(Name, Lang),
|
||||||
?INFO_IDENTITY(<<"automation">>, <<"command-node">>, Name, Lang)).
|
?INFO_IDENTITY(<<"automation">>, <<"command-node">>, Name, Lang)).
|
||||||
|
|
||||||
-define(NODEJID(To, Name, Node),
|
-define(NODEJID(To, Name, Node),
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_binary(To)},
|
[?XMLATTR('jid', exmpp_jid:jid_to_binary(To)),
|
||||||
#xmlattr{name = 'name', value = ?T(Lang, Name)},
|
?XMLATTR('name', ?T(Lang, Name)),
|
||||||
#xmlattr{name = 'node', value = Node}]}).
|
?XMLATTR('node', Node)]}).
|
||||||
|
|
||||||
-define(NODE(Name, Node),
|
-define(NODE(Name, Node),
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'jid', value = Server},
|
[?XMLATTR('jid', Server),
|
||||||
#xmlattr{name = 'name', value = ?T(Lang, Name)},
|
?XMLATTR('name', ?T(Lang, Name)),
|
||||||
#xmlattr{name = 'node', value = Node}]}).
|
?XMLATTR('node', Node)]}).
|
||||||
|
|
||||||
-define(NS_ADMINX(Sub), <<?NS_ADMIN_s,"#", Sub/binary>>).
|
-define(NS_ADMINX(Sub), <<?NS_ADMIN_s,"#", Sub/binary>>).
|
||||||
-define(NS_ADMINL(Sub), ["http:","jabber.org","protocol","admin", Sub]).
|
-define(NS_ADMINL(Sub), ["http:","jabber.org","protocol","admin", Sub]).
|
||||||
@ -263,9 +263,9 @@ adhoc_sm_items(Acc, From, To, Lang) ->
|
|||||||
empty -> []
|
empty -> []
|
||||||
end,
|
end,
|
||||||
Nodes = [#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
Nodes = [#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'jid', value = exmpp_jid:jid_binary(To)},
|
[?XMLATTR('jid', exmpp_jid:jid_to_binary(To)),
|
||||||
#xmlattr{name = 'name', value = ?T(Lang, "Configuration")},
|
?XMLATTR('name', ?T(Lang, "Configuration")),
|
||||||
#xmlattr{name = 'node', value = <<"config">>}]}],
|
?XMLATTR('node', <<"config">>)]}],
|
||||||
{result, Items ++ Nodes};
|
{result, Items ++ Nodes};
|
||||||
_ ->
|
_ ->
|
||||||
Acc
|
Acc
|
||||||
@ -302,11 +302,11 @@ get_user_resources(BareJID) ->
|
|||||||
exmpp_jid:ldomain(BareJID)),
|
exmpp_jid:ldomain(BareJID)),
|
||||||
lists:map(fun(R) ->
|
lists:map(fun(R) ->
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'jid',
|
[?XMLATTR('jid',
|
||||||
value = exmpp_jid:jid_to_binary(
|
exmpp_jid:jid_to_binary(
|
||||||
exmpp_jid:bare_jid_to_jid(BareJID, R))},
|
exmpp_jid:bare_jid_to_jid(BareJID, R))),
|
||||||
#xmlattr{name = 'name',
|
?XMLATTR('name',
|
||||||
value = exmpp_jid:lnode(BareJID)}]}
|
exmpp_jid:lnode(BareJID))]}
|
||||||
end, lists:sort(Rs)).
|
end, lists:sort(Rs)).
|
||||||
|
|
||||||
%%%-----------------------------------------------------------------------
|
%%%-----------------------------------------------------------------------
|
||||||
@ -325,7 +325,7 @@ adhoc_local_items(Acc, From, To, Lang) ->
|
|||||||
Lang),
|
Lang),
|
||||||
Nodes1 = lists:filter(
|
Nodes1 = lists:filter(
|
||||||
fun(N) ->
|
fun(N) ->
|
||||||
Nd = exmpp_xml:get_attribute(N, 'node', ""),
|
Nd = exmpp_xml:get_attribute_as_list(N, 'node', ""),
|
||||||
F = get_local_features([], From, To, Nd, Lang),
|
F = get_local_features([], From, To, Nd, Lang),
|
||||||
case F of
|
case F of
|
||||||
{result, [?NS_ADHOC_s]} ->
|
{result, [?NS_ADHOC_s]} ->
|
||||||
@ -356,8 +356,8 @@ recursively_get_local_items(PermLev, LServer, Node, Server, Lang) ->
|
|||||||
Nodes = lists:flatten(
|
Nodes = lists:flatten(
|
||||||
lists:map(
|
lists:map(
|
||||||
fun(N) ->
|
fun(N) ->
|
||||||
S = exmpp_xml:get_attribute(N, 'jid', ""),
|
S = exmpp_xml:get_attribute_as_list(N, 'jid', ""),
|
||||||
Nd = exmpp_xml:get_attribute(N, 'node', ""),
|
Nd = exmpp_xml:get_attribute_as_list(N, 'node', ""),
|
||||||
if (S /= Server) or (Nd == "") ->
|
if (S /= Server) or (Nd == "") ->
|
||||||
[];
|
[];
|
||||||
true ->
|
true ->
|
||||||
@ -530,8 +530,8 @@ get_local_items({_, Host}, ["all users", [$@ | Diap]], _Server, _Lang) ->
|
|||||||
Sub = lists:sublist(SUsers, N1, N2 - N1 + 1),
|
Sub = lists:sublist(SUsers, N1, N2 - N1 + 1),
|
||||||
lists:map(fun({S, U}) ->
|
lists:map(fun({S, U}) ->
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_binary(U, S)},
|
[?XMLATTR('jid', exmpp_jid:jid_to_binary(U, S)),
|
||||||
#xmlattr{name = 'name', value = exmpp_jid:jid_to_binary(U, S)}]}
|
?XMLATTR('name', exmpp_jid:jid_to_binary(U, S))]}
|
||||||
end, Sub)
|
end, Sub)
|
||||||
end of
|
end of
|
||||||
{'EXIT', _Reason} ->
|
{'EXIT', _Reason} ->
|
||||||
@ -623,8 +623,8 @@ get_online_vh_users(Host) ->
|
|||||||
SURs = lists:sort([{S, U, R} || {U, S, R} <- USRs]),
|
SURs = lists:sort([{S, U, R} || {U, S, R} <- USRs]),
|
||||||
lists:map(fun({S, U, R}) ->
|
lists:map(fun({S, U, R}) ->
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'jid', value = exmpp_jid:jid_binary(U, S, R)},
|
[?XMLATTR('jid', exmpp_jid:jid_to_binary(U, S, R)),
|
||||||
#xmlattr{name = 'name', value = exmpp_jid:jid_to_binary(U, S)}]}
|
?XMLATTR('name', exmpp_jid:jid_to_binary(U, S))]}
|
||||||
end, SURs)
|
end, SURs)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -638,8 +638,8 @@ get_all_vh_users(Host) ->
|
|||||||
N when N =< 100 ->
|
N when N =< 100 ->
|
||||||
lists:map(fun({S, U}) ->
|
lists:map(fun({S, U}) ->
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_binary(U, S)},
|
[?XMLATTR('jid', exmpp_jid:jid_to_binary(U, S)),
|
||||||
#xmlattr{name = 'name', value = exmpp_jid:jid_to_binary(U, S)}]}
|
?XMLATTR('name', exmpp_jid:jid_to_binary(U, S))]}
|
||||||
end, SUsers);
|
end, SUsers);
|
||||||
N ->
|
N ->
|
||||||
NParts = trunc(math:sqrt(N * 0.618)) + 1,
|
NParts = trunc(math:sqrt(N * 0.618)) + 1,
|
||||||
@ -658,9 +658,9 @@ get_all_vh_users(Host) ->
|
|||||||
<<(list_to_binary(FU))/binary, "@", (list_to_binary(FS))/binary,
|
<<(list_to_binary(FU))/binary, "@", (list_to_binary(FS))/binary,
|
||||||
" -- ", (list_to_binary(LU))/binary, "@", (list_to_binary(LS))/binary>>,
|
" -- ", (list_to_binary(LU))/binary, "@", (list_to_binary(LS))/binary>>,
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'jid', value = list_to_binary(Host)},
|
[?XMLATTR('jid', Host),
|
||||||
#xmlattr{name = 'node', value = <<"all users/", Node/binary>>},
|
?XMLATTR('node', <<"all users/", Node/binary>>),
|
||||||
#xmlattr{name = 'name', value = Name}]}
|
?XMLATTR('name', Name)]}
|
||||||
end, lists:seq(1, N, M))
|
end, lists:seq(1, N, M))
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
@ -676,12 +676,10 @@ get_outgoing_s2s(Host, Lang) ->
|
|||||||
lists:map(
|
lists:map(
|
||||||
fun(T) ->
|
fun(T) ->
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'jid', value = list_to_binary(Host)},
|
[?XMLATTR('jid', Host),
|
||||||
#xmlattr{name = 'node', value = <<"outgoing s2s/", (list_to_binary(T))/binary>>},
|
?XMLATTR('node', <<"outgoing s2s/", (list_to_binary(T))/binary>>),
|
||||||
#xmlattr{name = 'name', value =
|
?XMLATTR('name',
|
||||||
list_to_binary(
|
io_lib:format(?T(Lang, "To ~s"), [T]))]}
|
||||||
io_lib:format(
|
|
||||||
?T(Lang, "To ~s"), [T]))}]}
|
|
||||||
end, lists:usort(TConns))
|
end, lists:usort(TConns))
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -693,12 +691,10 @@ get_outgoing_s2s(Host, Lang, To) ->
|
|||||||
lists:map(
|
lists:map(
|
||||||
fun({F, _T}) ->
|
fun({F, _T}) ->
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'jid', value = list_to_binary(Host)},
|
[?XMLATTR('jid', Host),
|
||||||
#xmlattr{name = 'node', value = <<"outgoing s2s/", (list_to_binary(To))/binary, "/", (list_to_binary(F))/binary>>},
|
?XMLATTR('node', <<"outgoing s2s/", (list_to_binary(To))/binary, "/", (list_to_binary(F))/binary>>),
|
||||||
#xmlattr{name = 'name', value =
|
?XMLATTR('name',
|
||||||
list_to_binary(
|
io_lib:format(?T(Lang, "From ~s"), [F]))]}
|
||||||
io_lib:format(
|
|
||||||
?T(Lang, "From ~s"), [F]))}]}
|
|
||||||
end, lists:keysort(1, lists:filter(fun(E) ->
|
end, lists:keysort(1, lists:filter(fun(E) ->
|
||||||
element(2, E) == To
|
element(2, E) == To
|
||||||
end, Connections)))
|
end, Connections)))
|
||||||
@ -714,9 +710,9 @@ get_running_nodes(Server, _Lang) ->
|
|||||||
fun(N) ->
|
fun(N) ->
|
||||||
S = list_to_binary(atom_to_list(N)),
|
S = list_to_binary(atom_to_list(N)),
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'jid', value = list_to_binary(Server)},
|
[?XMLATTR('jid', Server),
|
||||||
#xmlattr{name = 'node', value = <<"running nodes/", (list_to_binary(S))/binary>>},
|
?XMLATTR('node', <<"running nodes/", (list_to_binary(S))/binary>>),
|
||||||
#xmlattr{name = 'name', value = S}]}
|
?XMLATTR('name', S)]}
|
||||||
end, lists:sort(DBNodes))
|
end, lists:sort(DBNodes))
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -731,9 +727,9 @@ get_stopped_nodes(_Lang) ->
|
|||||||
fun(N) ->
|
fun(N) ->
|
||||||
S = list_to_binary(atom_to_list(N)),
|
S = list_to_binary(atom_to_list(N)),
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'jid', value = list_to_binary(?MYNAME)},
|
[?XMLATTR('jid', ?MYNAME),
|
||||||
#xmlattr{name = 'node', value = <<"stopped nodes/", S/binary>>},
|
?XMLATTR('node', <<"stopped nodes/", S/binary>>),
|
||||||
#xmlattr{name = 'name', value = S}]}
|
?XMLATTR('name', S)]}
|
||||||
end, lists:sort(DBNodes))
|
end, lists:sort(DBNodes))
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -832,46 +828,46 @@ adhoc_local_commands(From, To,
|
|||||||
|
|
||||||
|
|
||||||
-define(TVFIELD(Type, Var, Val),
|
-define(TVFIELD(Type, Var, Val),
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [#xmlattr{name = 'type', value = Type},
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', Type),
|
||||||
#xmlattr{name = 'var', value = Var}],
|
?XMLATTR('var', Var)],
|
||||||
children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = Val}]}]}).
|
children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = Val}]}]}).
|
||||||
-define(HFIELD(), ?TVFIELD(<<"hidden">>, <<"FORM_TYPE">>, list_to_binary(?NS_ADMIN_s))).
|
-define(HFIELD(), ?TVFIELD(<<"hidden">>, <<"FORM_TYPE">>, list_to_binary(?NS_ADMIN_s))).
|
||||||
|
|
||||||
-define(TLFIELD(Type, Label, Var),
|
-define(TLFIELD(Type, Label, Var),
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [#xmlattr{name = 'type', value = Type},
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', Type),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, Label)},
|
?XMLATTR('label', ?T(Lang, Label)),
|
||||||
#xmlattr{name = 'var', value = Var}]}).
|
?XMLATTR('var', Var)]}).
|
||||||
|
|
||||||
-define(XFIELD(Type, Label, Var, Val),
|
-define(XFIELD(Type, Label, Var, Val),
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [#xmlattr{name = 'type', value = Type},
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', Type),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, Label)},
|
?XMLATTR('label', ?T(Lang, Label)),
|
||||||
#xmlattr{name = 'var', value = Var}],
|
?XMLATTR('var', Var)],
|
||||||
children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = Val}]}]}).
|
children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = Val}]}]}).
|
||||||
|
|
||||||
-define(XMFIELD(Type, Label, Var, Vals),
|
-define(XMFIELD(Type, Label, Var, Vals),
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [#xmlattr{name = 'type', value = Type},
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', Type),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, Label)},
|
?XMLATTR('label', ?T(Lang, Label)),
|
||||||
#xmlattr{name = 'var', value = Var}],
|
?XMLATTR('var', Var)],
|
||||||
children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Val)}]} || Val <- Vals]}).
|
children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Val)}]} || Val <- Vals]}).
|
||||||
|
|
||||||
-define(TABLEFIELD(Table, Val),
|
-define(TABLEFIELD(Table, Val),
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [#xmlattr{name = 'type', value = <<"list-single">>},
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', <<"list-single">>),
|
||||||
#xmlattr{name = 'label', value = list_to_binary(atom_to_list(Table))},
|
?XMLATTR('label', Table),
|
||||||
#xmlattr{name = 'var', value = list_to_binary(atom_to_list(Table))}],
|
?XMLATTR('var', Table)],
|
||||||
children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(atom_to_list(Val))}]},
|
children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(atom_to_list(Val))}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = [#xmlattr{name = 'label', value =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = [?XMLATTR('label',
|
||||||
?T(Lang, "RAM copy")}],
|
?T(Lang, "RAM copy"))],
|
||||||
children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"ram_copies">>}]}]},
|
children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"ram_copies">>}]}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = [#xmlattr{name = 'label', value =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = [?XMLATTR('label',
|
||||||
?T(Lang,
|
?T(Lang,
|
||||||
"RAM and disc copy")}],
|
"RAM and disc copy"))],
|
||||||
children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"disc_copies">>}]}]},
|
children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"disc_copies">>}]}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = [#xmlattr{name = 'label', value =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = [?XMLATTR('label',
|
||||||
?T(Lang,
|
?T(Lang,
|
||||||
"Disc only copy")}],
|
"Disc only copy"))],
|
||||||
children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"disc_only_copies">>}]}]},
|
children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"disc_only_copies">>}]}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = [#xmlattr{name = 'label', value =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = [?XMLATTR('label',
|
||||||
?T(Lang, "Remote copy")}],
|
?T(Lang, "Remote copy"))],
|
||||||
children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"unknown">>}]}]}
|
children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"unknown">>}]}]}
|
||||||
]}).
|
]}).
|
||||||
|
|
||||||
@ -1031,7 +1027,7 @@ get_form(_Host, ["running nodes", _ENode, "restart"], Lang) ->
|
|||||||
Make_option =
|
Make_option =
|
||||||
fun(LabelNum, LabelUnit, Value)->
|
fun(LabelNum, LabelUnit, Value)->
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs =
|
||||||
[#xmlattr{name = 'label', value = <<(list_to_binary(LabelNum))/binary, (?T(Lang, LabelUnit))/binary>>}], children =
|
[?XMLATTR('label', LabelNum ++ ?T(Lang, LabelUnit))], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Value)}]}]}
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Value)}]}]}
|
||||||
end,
|
end,
|
||||||
{result, [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', children =
|
{result, [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', children =
|
||||||
@ -1039,9 +1035,9 @@ get_form(_Host, ["running nodes", _ENode, "restart"], Lang) ->
|
|||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(?T(Lang, "Restart Service"))}]},
|
[#xmlcdata{cdata = list_to_binary(?T(Lang, "Restart Service"))}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"list-single">>},
|
[?XMLATTR('type', <<"list-single">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Time delay")},
|
?XMLATTR('label', ?T(Lang, "Time delay")),
|
||||||
#xmlattr{name = 'var', value = <<"delay">>}], children =
|
?XMLATTR('var', <<"delay">>)], children =
|
||||||
[Make_option("", "immediately", "1"),
|
[Make_option("", "immediately", "1"),
|
||||||
Make_option("15 ", "seconds", "15"),
|
Make_option("15 ", "seconds", "15"),
|
||||||
Make_option("30 ", "seconds", "30"),
|
Make_option("30 ", "seconds", "30"),
|
||||||
@ -1057,23 +1053,23 @@ get_form(_Host, ["running nodes", _ENode, "restart"], Lang) ->
|
|||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}
|
||||||
]},
|
]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"fixed">>},
|
[?XMLATTR('type', <<"fixed">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Send announcement to all online users on all hosts")}]},
|
?XMLATTR('label', ?T(Lang, "Send announcement to all online users on all hosts"))]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'var', value = <<"subject">>},
|
[?XMLATTR('var', <<"subject">>),
|
||||||
#xmlattr{name = 'type', value = <<"text-single">>},
|
?XMLATTR('type', <<"text-single">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Subject")}]},
|
?XMLATTR('label', ?T(Lang, "Subject"))]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'var', value = <<"announcement">>},
|
[?XMLATTR('var', <<"announcement">>),
|
||||||
#xmlattr{name = 'type', value = <<"text-multi">>},
|
?XMLATTR('type', <<"text-multi">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Message body")}]}
|
?XMLATTR('label', ?T(Lang, "Message body"))]}
|
||||||
]}]};
|
]}]};
|
||||||
|
|
||||||
get_form(_Host, ["running nodes", _ENode, "shutdown"], Lang) ->
|
get_form(_Host, ["running nodes", _ENode, "shutdown"], Lang) ->
|
||||||
Make_option =
|
Make_option =
|
||||||
fun(LabelNum, LabelUnit, Value)->
|
fun(LabelNum, LabelUnit, Value)->
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs =
|
||||||
[#xmlattr{name = 'label', value = <<(list_to_binary(LabelNum))/binary, (?T(Lang, LabelUnit))/binary>>}], children =
|
[?XMLATTR('label', LabelNum ++ ?T(Lang, LabelUnit))], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Value)}]}]}
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Value)}]}]}
|
||||||
end,
|
end,
|
||||||
{result, [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', children =
|
{result, [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', children =
|
||||||
@ -1081,9 +1077,9 @@ get_form(_Host, ["running nodes", _ENode, "shutdown"], Lang) ->
|
|||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(?T(Lang, "Shut Down Service"))}]},
|
[#xmlcdata{cdata = list_to_binary(?T(Lang, "Shut Down Service"))}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"list-single">>},
|
[?XMLATTR('type', <<"list-single">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Time delay")},
|
?XMLATTR('label', ?T(Lang, "Time delay")),
|
||||||
#xmlattr{name = 'var', value = <<"delay">>}], children =
|
?XMLATTR('var', <<"delay">>)], children =
|
||||||
[Make_option("", "immediately", "1"),
|
[Make_option("", "immediately", "1"),
|
||||||
Make_option("15 ", "seconds", "15"),
|
Make_option("15 ", "seconds", "15"),
|
||||||
Make_option("30 ", "seconds", "30"),
|
Make_option("30 ", "seconds", "30"),
|
||||||
@ -1099,16 +1095,16 @@ get_form(_Host, ["running nodes", _ENode, "shutdown"], Lang) ->
|
|||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}
|
||||||
]},
|
]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"fixed">>},
|
[?XMLATTR('type', <<"fixed">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Send announcement to all online users on all hosts")}]},
|
?XMLATTR('label', ?T(Lang, "Send announcement to all online users on all hosts"))]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'var', value = <<"subject">>},
|
[?XMLATTR('var', <<"subject">>),
|
||||||
#xmlattr{name = 'type', value = <<"text-single">>},
|
?XMLATTR('type', <<"text-single">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Subject")}]},
|
?XMLATTR('label', ?T(Lang, "Subject"))]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'var', value = <<"announcement">>},
|
[?XMLATTR('var', <<"announcement">>),
|
||||||
#xmlattr{name = 'type', value = <<"text-multi">>},
|
?XMLATTR('type', <<"text-multi">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Message body")}]}
|
?XMLATTR('label', ?T(Lang, "Message body"))]}
|
||||||
]}]};
|
]}]};
|
||||||
|
|
||||||
get_form(Host, ["config", "acls"], Lang) ->
|
get_form(Host, ["config", "acls"], Lang) ->
|
||||||
@ -1118,11 +1114,11 @@ get_form(Host, ["config", "acls"], Lang) ->
|
|||||||
[#xmlcdata{cdata =
|
[#xmlcdata{cdata =
|
||||||
list_to_binary(?T(
|
list_to_binary(?T(
|
||||||
Lang, "Access Control List Configuration"))}]},
|
Lang, "Access Control List Configuration"))}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [#xmlattr{name = 'type', value = <<"text-multi">>},
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', <<"text-multi">>),
|
||||||
#xmlattr{name = 'label', value =
|
?XMLATTR('label',
|
||||||
?T(
|
?T(
|
||||||
Lang, "Access control lists")},
|
Lang, "Access control lists")),
|
||||||
#xmlattr{name = 'var', value = <<"acls">>}],
|
?XMLATTR('var', <<"acls">>)],
|
||||||
children = lists:map(fun(S) ->
|
children = lists:map(fun(S) ->
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(S)}]}
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(S)}]}
|
||||||
end,
|
end,
|
||||||
@ -1146,11 +1142,11 @@ get_form(Host, ["config", "access"], Lang) ->
|
|||||||
[#xmlcdata{cdata =
|
[#xmlcdata{cdata =
|
||||||
list_to_binary(?T(
|
list_to_binary(?T(
|
||||||
Lang, "Access Configuration"))}]},
|
Lang, "Access Configuration"))}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =[#xmlattr{name = 'type', value = <<"text-multi">>},
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =[?XMLATTR('type', <<"text-multi">>),
|
||||||
#xmlattr{name = 'label', value =
|
?XMLATTR('label',
|
||||||
?T(
|
?T(
|
||||||
Lang, "Access rules")},
|
Lang, "Access rules")),
|
||||||
#xmlattr{name = 'var', value = <<"access">>}],
|
?XMLATTR('var', <<"access">>)],
|
||||||
children = lists:map(fun(S) ->
|
children = lists:map(fun(S) ->
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =[#xmlcdata{cdata = list_to_binary(S)}]}
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =[#xmlcdata{cdata = list_to_binary(S)}]}
|
||||||
end,
|
end,
|
||||||
@ -1173,19 +1169,19 @@ get_form(_Host, ?NS_ADMINL("add-user"), Lang) ->
|
|||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(?T(Lang, "Add User"))}]},
|
[#xmlcdata{cdata = list_to_binary(?T(Lang, "Add User"))}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"jid-single">>},
|
[?XMLATTR('type', <<"jid-single">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Jabber ID")},
|
?XMLATTR('label', ?T(Lang, "Jabber ID")),
|
||||||
#xmlattr{name = 'var', value = <<"accountjid">>}], children =
|
?XMLATTR('var', <<"accountjid">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]},
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"text-private">>},
|
[?XMLATTR('type', <<"text-private">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Password")},
|
?XMLATTR('label', ?T(Lang, "Password")),
|
||||||
#xmlattr{name = 'var', value = <<"password">>}], children =
|
?XMLATTR('var', <<"password">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]},
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"text-private">>},
|
[?XMLATTR('type', <<"text-private">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Password Verification")},
|
?XMLATTR('label', ?T(Lang, "Password Verification")),
|
||||||
#xmlattr{name = 'var', value = <<"password-verify">>}], children =
|
?XMLATTR('var', <<"password-verify">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]}
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]}
|
||||||
]}]};
|
]}]};
|
||||||
|
|
||||||
@ -1195,9 +1191,9 @@ get_form(_Host, ?NS_ADMINL("delete-user"), Lang) ->
|
|||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(?T(Lang, "Delete User"))}]},
|
[#xmlcdata{cdata = list_to_binary(?T(Lang, "Delete User"))}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"jid-multi">>},
|
[?XMLATTR('type', <<"jid-multi">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Jabber ID")},
|
?XMLATTR('label', ?T(Lang, "Jabber ID")),
|
||||||
#xmlattr{name = 'var', value = <<"accountjids">>}], children =
|
?XMLATTR('var', <<"accountjids">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]}
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]}
|
||||||
]}]};
|
]}]};
|
||||||
|
|
||||||
@ -1207,9 +1203,9 @@ get_form(_Host, ?NS_ADMINL("end-user-session"), Lang) ->
|
|||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(?T(Lang, "End User Session"))}]},
|
[#xmlcdata{cdata = list_to_binary(?T(Lang, "End User Session"))}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"jid-single">>},
|
[?XMLATTR('type', <<"jid-single">>),
|
||||||
#xmlattr{name = 'label', value = list_to_binary(?T(Lang, "Jabber ID"))},
|
?XMLATTR('label', ?T(Lang, "Jabber ID")),
|
||||||
#xmlattr{name = 'var', value = <<"accountjid">>}], children =
|
?XMLATTR('var', <<"accountjid">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]}
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]}
|
||||||
]}]};
|
]}]};
|
||||||
|
|
||||||
@ -1219,9 +1215,9 @@ get_form(_Host, ?NS_ADMINL("get-user-password"), Lang) ->
|
|||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(?T(Lang, "Get User Password"))}]},
|
[#xmlcdata{cdata = list_to_binary(?T(Lang, "Get User Password"))}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"jid-single">>},
|
[?XMLATTR('type', <<"jid-single">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Jabber ID")},
|
?XMLATTR('label', ?T(Lang, "Jabber ID")),
|
||||||
#xmlattr{name = 'var', value = <<"accountjid">>}], children =
|
?XMLATTR('var', <<"accountjid">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]}
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]}
|
||||||
]}]};
|
]}]};
|
||||||
|
|
||||||
@ -1231,14 +1227,14 @@ get_form(_Host, ?NS_ADMINL("change-user-password"), Lang) ->
|
|||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(?T(Lang, "Get User Password"))}]},
|
[#xmlcdata{cdata = list_to_binary(?T(Lang, "Get User Password"))}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"jid-single">>},
|
[?XMLATTR('type', <<"jid-single">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Jabber ID")},
|
?XMLATTR('label', ?T(Lang, "Jabber ID")),
|
||||||
#xmlattr{name = 'var', value = <<"accountjid">>}], children =
|
?XMLATTR('var', <<"accountjid">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]},
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"text-private">>},
|
[?XMLATTR('type', <<"text-private">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Password")},
|
?XMLATTR('label', ?T(Lang, "Password")),
|
||||||
#xmlattr{name = 'var', value = <<"password">>}], children =
|
?XMLATTR('var', <<"password">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]}
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]}
|
||||||
]}]};
|
]}]};
|
||||||
|
|
||||||
@ -1248,9 +1244,9 @@ get_form(_Host, ?NS_ADMINL("get-user-lastlogin"), Lang) ->
|
|||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(?T(Lang, "Get User Last Login Time"))}]},
|
[#xmlcdata{cdata = list_to_binary(?T(Lang, "Get User Last Login Time"))}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"jid-single">>},
|
[?XMLATTR('type', <<"jid-single">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Jabber ID")},
|
?XMLATTR('label', ?T(Lang, "Jabber ID")),
|
||||||
#xmlattr{name = 'var', value = <<"accountjid">>}], children =
|
?XMLATTR('var', <<"accountjid">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]}
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]}
|
||||||
]}]};
|
]}]};
|
||||||
|
|
||||||
@ -1260,9 +1256,9 @@ get_form(_Host, ?NS_ADMINL("user-stats"), Lang) ->
|
|||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(?T(Lang, "Get User Statistics"))}]},
|
[#xmlcdata{cdata = list_to_binary(?T(Lang, "Get User Statistics"))}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"jid-single">>},
|
[?XMLATTR('type', <<"jid-single">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Jabber ID")},
|
?XMLATTR('label', ?T(Lang, "Jabber ID")),
|
||||||
#xmlattr{name = 'var', value = <<"accountjid">>}], children =
|
?XMLATTR('var', <<"accountjid">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]}
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]}
|
||||||
]}]};
|
]}]};
|
||||||
|
|
||||||
@ -1272,9 +1268,9 @@ get_form(Host, ?NS_ADMINL("get-registered-users-num"), Lang) ->
|
|||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'x', children =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'x', children =
|
||||||
[?HFIELD(),
|
[?HFIELD(),
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"text-single">>},
|
[?XMLATTR('type', <<"text-single">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Number of registered users")},
|
?XMLATTR('label', ?T(Lang, "Number of registered users")),
|
||||||
#xmlattr{name = 'var', value = <<"registeredusersnum">>}], children =
|
?XMLATTR('var', <<"registeredusersnum">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Num)}]}]
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Num)}]}]
|
||||||
}]}]};
|
}]}]};
|
||||||
|
|
||||||
@ -1284,9 +1280,9 @@ get_form(Host, ?NS_ADMINL("get-online-users-num"), Lang) ->
|
|||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'x', children =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'x', children =
|
||||||
[?HFIELD(),
|
[?HFIELD(),
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"text-single">>},
|
[?XMLATTR('type', <<"text-single">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Number of online users")},
|
?XMLATTR('label', ?T(Lang, "Number of online users")),
|
||||||
#xmlattr{name = 'var', value = <<"onlineusersnum">>}], children =
|
?XMLATTR('var', <<"onlineusersnum">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Num)}]}]
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Num)}]}]
|
||||||
}]}]};
|
}]}]};
|
||||||
|
|
||||||
@ -1566,7 +1562,7 @@ set_form(From, Host, ?NS_ADMINL("add-user"), _Lang, XData) ->
|
|||||||
AccountString = get_value("accountjid", XData),
|
AccountString = get_value("accountjid", XData),
|
||||||
Password = get_value("password", XData),
|
Password = get_value("password", XData),
|
||||||
Password = get_value("password-verify", XData),
|
Password = get_value("password-verify", XData),
|
||||||
AccountJID = exmpp_jid:list_to_jid(AccountString),
|
AccountJID = exmpp_jid:parse_jid(AccountString),
|
||||||
User = exmpp_jid:lnode_as_list(AccountJID),
|
User = exmpp_jid:lnode_as_list(AccountJID),
|
||||||
Server = exmpp_jid:ldomain_as_list(AccountJID),
|
Server = exmpp_jid:ldomain_as_list(AccountJID),
|
||||||
true = lists:member(Server, ?MYHOSTS),
|
true = lists:member(Server, ?MYHOSTS),
|
||||||
@ -1592,7 +1588,7 @@ set_form(From, Host, ?NS_ADMINL("delete-user"), _Lang, XData) ->
|
|||||||
|
|
||||||
set_form(From, Host, ?NS_ADMINL("end-user-session"), _Lang, XData) ->
|
set_form(From, Host, ?NS_ADMINL("end-user-session"), _Lang, XData) ->
|
||||||
AccountString = get_value("accountjid", XData),
|
AccountString = get_value("accountjid", XData),
|
||||||
JID = exmpp_jid:list_to_jid(AccountString),
|
JID = exmpp_jid:parse_jid(AccountString),
|
||||||
LUser = [_|_] = exmpp_jid:lnode_as_list(JID),
|
LUser = [_|_] = exmpp_jid:lnode_as_list(JID),
|
||||||
LServer = exmpp_jid:ldomain_as_list(JID),
|
LServer = exmpp_jid:ldomain_as_list(JID),
|
||||||
true = (LServer == Host) orelse (get_permission_level(From) == global),
|
true = (LServer == Host) orelse (get_permission_level(From) == global),
|
||||||
@ -1611,7 +1607,7 @@ set_form(From, Host, ?NS_ADMINL("end-user-session"), _Lang, XData) ->
|
|||||||
|
|
||||||
set_form(From, Host, ?NS_ADMINL("get-user-password"), Lang, XData) ->
|
set_form(From, Host, ?NS_ADMINL("get-user-password"), Lang, XData) ->
|
||||||
AccountString = get_value("accountjid", XData),
|
AccountString = get_value("accountjid", XData),
|
||||||
JID = exmpp_jid:list_to_jid(AccountString),
|
JID = exmpp_jid:parse_jid(AccountString),
|
||||||
User = [_|_] = exmpp_jid:lnode_as_list(JID),
|
User = [_|_] = exmpp_jid:lnode_as_list(JID),
|
||||||
Server = exmpp_jid:ldomain_as_list(JID),
|
Server = exmpp_jid:ldomain_as_list(JID),
|
||||||
true = (Server == Host) orelse (get_permission_level(From) == global),
|
true = (Server == Host) orelse (get_permission_level(From) == global),
|
||||||
@ -1626,7 +1622,7 @@ set_form(From, Host, ?NS_ADMINL("get-user-password"), Lang, XData) ->
|
|||||||
set_form(From, Host, ?NS_ADMINL("change-user-password"), _Lang, XData) ->
|
set_form(From, Host, ?NS_ADMINL("change-user-password"), _Lang, XData) ->
|
||||||
AccountString = get_value("accountjid", XData),
|
AccountString = get_value("accountjid", XData),
|
||||||
Password = get_value("password", XData),
|
Password = get_value("password", XData),
|
||||||
JID = exmpp_jid:list_to_jid(AccountString),
|
JID = exmpp_jid:parse_jid(AccountString),
|
||||||
User = [_|_] = exmpp_jid:lnode_as_list(JID),
|
User = [_|_] = exmpp_jid:lnode_as_list(JID),
|
||||||
Server = exmpp_jid:ldomain_as_list(JID),
|
Server = exmpp_jid:ldomain_as_list(JID),
|
||||||
true = (Server == Host) orelse (get_permission_level(From) == global),
|
true = (Server == Host) orelse (get_permission_level(From) == global),
|
||||||
@ -1636,7 +1632,7 @@ set_form(From, Host, ?NS_ADMINL("change-user-password"), _Lang, XData) ->
|
|||||||
|
|
||||||
set_form(From, Host, ?NS_ADMINL("get-user-lastlogin"), Lang, XData) ->
|
set_form(From, Host, ?NS_ADMINL("get-user-lastlogin"), Lang, XData) ->
|
||||||
AccountString = get_value("accountjid", XData),
|
AccountString = get_value("accountjid", XData),
|
||||||
JID = exmpp_jid:list_to_jid(AccountString),
|
JID = exmpp_jid:parse_jid(AccountString),
|
||||||
User = [_|_] = exmpp_jid:lnode_as_list(JID),
|
User = [_|_] = exmpp_jid:lnode_as_list(JID),
|
||||||
Server = exmpp_jid:ldomain_as_list(JID),
|
Server = exmpp_jid:ldomain_as_list(JID),
|
||||||
true = (Server == Host) orelse (get_permission_level(From) == global),
|
true = (Server == Host) orelse (get_permission_level(From) == global),
|
||||||
@ -1666,7 +1662,7 @@ set_form(From, Host, ?NS_ADMINL("get-user-lastlogin"), Lang, XData) ->
|
|||||||
_ ->
|
_ ->
|
||||||
?T(Lang, "Online")
|
?T(Lang, "Online")
|
||||||
end,
|
end,
|
||||||
{result, [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [#xmlattr{name = 'type', value = <<"result">>}], children =
|
{result, [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR('type', <<"result">>)], children =
|
||||||
[?HFIELD(),
|
[?HFIELD(),
|
||||||
?XFIELD(<<"jid-single">>, "Jabber ID", <<"accountjid">>, list_to_binary(AccountString)),
|
?XFIELD(<<"jid-single">>, "Jabber ID", <<"accountjid">>, list_to_binary(AccountString)),
|
||||||
?XFIELD(<<"text-single">>, "Last login", <<"lastlogin">>, list_to_binary(FLast))
|
?XFIELD(<<"text-single">>, "Last login", <<"lastlogin">>, list_to_binary(FLast))
|
||||||
@ -1674,7 +1670,7 @@ set_form(From, Host, ?NS_ADMINL("get-user-lastlogin"), Lang, XData) ->
|
|||||||
|
|
||||||
set_form(From, Host, ?NS_ADMINL("user-stats"), Lang, XData) ->
|
set_form(From, Host, ?NS_ADMINL("user-stats"), Lang, XData) ->
|
||||||
AccountString = get_value("accountjid", XData),
|
AccountString = get_value("accountjid", XData),
|
||||||
JID = exmpp_jid:list_to_jid(AccountString),
|
JID = exmpp_jid:parse_jid(AccountString),
|
||||||
User = [_|_] = exmpp_jid:lnode_as_list(JID),
|
User = [_|_] = exmpp_jid:lnode_as_list(JID),
|
||||||
Server = exmpp_jid:ldomain_as_list(JID),
|
Server = exmpp_jid:ldomain_as_list(JID),
|
||||||
true = (Server == Host) orelse (get_permission_level(From) == global),
|
true = (Server == Host) orelse (get_permission_level(From) == global),
|
||||||
@ -1726,12 +1722,12 @@ stop_node(From, Host, ENode, Action, XData) ->
|
|||||||
Delay = list_to_integer(get_value("delay", XData)),
|
Delay = list_to_integer(get_value("delay", XData)),
|
||||||
Subject = case get_value("subject", XData) of
|
Subject = case get_value("subject", XData) of
|
||||||
[] -> [];
|
[] -> [];
|
||||||
S -> [#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [#xmlattr{name = 'var', value = <<"subject">>}], children =
|
S -> [#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('var', <<"subject">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(S)}]}]}]
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(S)}]}]}]
|
||||||
end,
|
end,
|
||||||
Announcement = case get_values("announcement", XData) of
|
Announcement = case get_values("announcement", XData) of
|
||||||
[] -> [];
|
[] -> [];
|
||||||
As -> [#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [#xmlattr{name = 'var', value = <<"body">>}], children =
|
As -> [#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('var', <<"body">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Line)}]} || Line <- As] }]
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Line)}]} || Line <- As] }]
|
||||||
end,
|
end,
|
||||||
case Subject ++ Announcement of
|
case Subject ++ Announcement of
|
||||||
@ -1741,10 +1737,10 @@ stop_node(From, Host, ENode, Action, XData) ->
|
|||||||
node = binary_to_list(?NS_ADMINX(<<"announce-allhosts">>)),
|
node = binary_to_list(?NS_ADMINX(<<"announce-allhosts">>)),
|
||||||
action = "complete",
|
action = "complete",
|
||||||
xdata = #xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs =
|
xdata = #xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"submit">>}], children =
|
[?XMLATTR('type', <<"submit">>)], children =
|
||||||
SubEls},
|
SubEls},
|
||||||
others= [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs =
|
others= [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"submit">>}], children =
|
[?XMLATTR('type', <<"submit">>)], children =
|
||||||
SubEls}]
|
SubEls}]
|
||||||
},
|
},
|
||||||
To = exmpp_jid:make_jid(Host),
|
To = exmpp_jid:make_jid(Host),
|
||||||
@ -1826,15 +1822,15 @@ get_sm_form(User, Server, "config", Lang) ->
|
|||||||
list_to_binary(?T(
|
list_to_binary(?T(
|
||||||
Lang, "Administration of ") ++ User)}]},
|
Lang, "Administration of ") ++ User)}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"list-single">>},
|
[?XMLATTR('type', <<"list-single">>),
|
||||||
#xmlattr{name = 'label', value = ?T(Lang, "Action on user")},
|
?XMLATTR('label', ?T(Lang, "Action on user")),
|
||||||
#xmlattr{name = 'var', value = <<"action">>}], children =
|
?XMLATTR('var', <<"action">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"edit">>}]},
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"edit">>}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs =
|
||||||
[#xmlattr{name = 'label', value = ?T(Lang, "Edit Properties")}], children =
|
[?XMLATTR('label', ?T(Lang, "Edit Properties"))], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"edit">>}]}]},
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"edit">>}]}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs =
|
||||||
[#xmlattr{name = 'label', value = ?T(Lang, "Remove User")}], children =
|
[?XMLATTR('label', ?T(Lang, "Remove User"))], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"remove">>}]}]}
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"remove">>}]}]}
|
||||||
]},
|
]},
|
||||||
?XFIELD(<<"text-private">>, "Password", <<"password">>,
|
?XFIELD(<<"text-private">>, "Password", <<"password">>,
|
||||||
|
@ -45,8 +45,8 @@ start(Host, Opts) ->
|
|||||||
gen_iq_handler:add_iq_handler(ejabberd_local, list_to_binary(Host), ?NS_ECONFIGURE,
|
gen_iq_handler:add_iq_handler(ejabberd_local, list_to_binary(Host), ?NS_ECONFIGURE,
|
||||||
?MODULE, process_local_iq, IQDisc),
|
?MODULE, process_local_iq, IQDisc),
|
||||||
% Add nss/names/attrs used by this module to the known lists of Exmpp.
|
% Add nss/names/attrs used by this module to the known lists of Exmpp.
|
||||||
exmpp_xml:add_autoload_known_nss([?NS_ECONFIGURE]),
|
exmpp_xml:add_known_nss(xmpp, [?NS_ECONFIGURE]),
|
||||||
exmpp_xml:add_autoload_known_names([
|
exmpp_xml:add_known_elems(xmpp, [
|
||||||
'access',
|
'access',
|
||||||
'acls',
|
'acls',
|
||||||
'body',
|
'body',
|
||||||
@ -57,7 +57,7 @@ start(Host, Opts) ->
|
|||||||
'subject',
|
'subject',
|
||||||
'welcome-message'
|
'welcome-message'
|
||||||
]),
|
]),
|
||||||
exmpp_xml:add_autoload_known_attrs([
|
exmpp_xml:add_known_attrs(xmpp, [
|
||||||
'online-users',
|
'online-users',
|
||||||
'outgoing-s2s-servers',
|
'outgoing-s2s-servers',
|
||||||
'registered-users',
|
'registered-users',
|
||||||
@ -124,19 +124,16 @@ process_local_iq(From, To, #iq{type = Type, payload = Request} = IQ_Rec) ->
|
|||||||
process_get(#xmlel{ns = ?NS_ECONFIGURE, name = 'info'}) ->
|
process_get(#xmlel{ns = ?NS_ECONFIGURE, name = 'info'}) ->
|
||||||
S2SConns = ejabberd_s2s:dirty_get_connections(),
|
S2SConns = ejabberd_s2s:dirty_get_connections(),
|
||||||
TConns = lists:usort([element(2, C) || C <- S2SConns]),
|
TConns = lists:usort([element(2, C) || C <- S2SConns]),
|
||||||
Attrs = [#xmlattr{name = 'registered-users', value =
|
Attrs = [?XMLATTR('registered-users', mnesia:table_info(passwd, size)),
|
||||||
list_to_binary(integer_to_list(mnesia:table_info(passwd, size)))},
|
?XMLATTR('online-users', mnesia:table_info(presence, size)),
|
||||||
#xmlattr{name = 'online-users', value =
|
?XMLATTR('running-nodes',
|
||||||
list_to_binary(integer_to_list(mnesia:table_info(presence, size)))},
|
length(mnesia:system_info(running_db_nodes))),
|
||||||
#xmlattr{name = 'running-nodes', value =
|
?XMLATTR('stopped-nodes',
|
||||||
list_to_binary(integer_to_list(length(mnesia:system_info(running_db_nodes))))},
|
length(lists:usort(mnesia:system_info(db_nodes) ++
|
||||||
#xmlattr{name = 'stopped-nodes', value =
|
mnesia:system_info(extra_db_nodes)) --
|
||||||
list_to_binary(integer_to_list(
|
mnesia:system_info(running_db_nodes))),
|
||||||
length(lists:usort(mnesia:system_info(db_nodes) ++
|
?XMLATTR('outgoing-s2s-servers',
|
||||||
mnesia:system_info(extra_db_nodes)) --
|
length(TConns))],
|
||||||
mnesia:system_info(running_db_nodes))))},
|
|
||||||
#xmlattr{name = 'outgoing-s2s-servers', value =
|
|
||||||
list_to_binary(integer_to_list(length(TConns)))}],
|
|
||||||
{result, #xmlel{ns = ?NS_ECONFIGURE, name = 'info', attrs = Attrs}};
|
{result, #xmlel{ns = ?NS_ECONFIGURE, name = 'info', attrs = Attrs}};
|
||||||
process_get(#xmlel{ns = ?NS_ECONFIGURE, name = 'welcome-message', attrs = Attrs}) ->
|
process_get(#xmlel{ns = ?NS_ECONFIGURE, name = 'welcome-message', attrs = Attrs}) ->
|
||||||
{Subj, Body} = case ejabberd_config:get_local_option(welcome_message) of
|
{Subj, Body} = case ejabberd_config:get_local_option(welcome_message) of
|
||||||
|
@ -139,7 +139,7 @@ process_local_iq_items(From, To, #iq{type = get, payload = SubEl,
|
|||||||
{result, Items} ->
|
{result, Items} ->
|
||||||
ANode = case Node of
|
ANode = case Node of
|
||||||
<<>> -> [];
|
<<>> -> [];
|
||||||
_ -> [#xmlattr{name = 'node', value = Node}]
|
_ -> [?XMLATTR('node', Node)]
|
||||||
end,
|
end,
|
||||||
Result = #xmlel{ns = ?NS_DISCO_ITEMS, name = 'query',
|
Result = #xmlel{ns = ?NS_DISCO_ITEMS, name = 'query',
|
||||||
attrs = ANode, children = Items},
|
attrs = ANode, children = Items},
|
||||||
@ -165,7 +165,7 @@ process_local_iq_info(From, To, #iq{type = get, payload = SubEl,
|
|||||||
{result, Features} ->
|
{result, Features} ->
|
||||||
ANode = case Node of
|
ANode = case Node of
|
||||||
<<>> -> [];
|
<<>> -> [];
|
||||||
_ -> [#xmlattr{name = 'node', value = Node}]
|
_ -> [?XMLATTR('node', Node)]
|
||||||
end,
|
end,
|
||||||
Result = #xmlel{ns = ?NS_DISCO_INFO, name = 'query',
|
Result = #xmlel{ns = ?NS_DISCO_INFO, name = 'query',
|
||||||
attrs = ANode,
|
attrs = ANode,
|
||||||
@ -180,9 +180,9 @@ process_local_iq_info(_From, _To, #iq{type = set} = IQ_Rec) ->
|
|||||||
|
|
||||||
get_local_identity(Acc, _From, _To, <<>>, _Lang) ->
|
get_local_identity(Acc, _From, _To, <<>>, _Lang) ->
|
||||||
Acc ++ [#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = [
|
Acc ++ [#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = [
|
||||||
#xmlattr{name = 'category', value = <<"server">>},
|
?XMLATTR('category', <<"server">>),
|
||||||
#xmlattr{name = 'type', value = <<"im">>},
|
?XMLATTR('type', <<"im">>),
|
||||||
#xmlattr{name = 'name', value = <<"ejabberd">>}
|
?XMLATTR('name', <<"ejabberd">>)
|
||||||
]}];
|
]}];
|
||||||
|
|
||||||
get_local_identity(Acc, _From, _To, _Node, _Lang) ->
|
get_local_identity(Acc, _From, _To, _Node, _Lang) ->
|
||||||
@ -214,7 +214,7 @@ feature_to_xml({{Feature, _Host}}) ->
|
|||||||
|
|
||||||
feature_to_xml(Feature) when is_binary(Feature) ->
|
feature_to_xml(Feature) when is_binary(Feature) ->
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [
|
||||||
#xmlattr{name = 'var', value = Feature}
|
?XMLATTR('var', Feature)
|
||||||
]};
|
]};
|
||||||
|
|
||||||
feature_to_xml(Feature) when is_list(Feature) ->
|
feature_to_xml(Feature) when is_list(Feature) ->
|
||||||
@ -226,7 +226,7 @@ domain_to_xml({Domain}) ->
|
|||||||
domain_to_xml(Domain);
|
domain_to_xml(Domain);
|
||||||
domain_to_xml(Domain) when is_binary(Domain)->
|
domain_to_xml(Domain) when is_binary(Domain)->
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [
|
||||||
#xmlattr{name = 'jid', value = Domain}
|
?XMLATTR('jid', Domain)
|
||||||
]};
|
]};
|
||||||
domain_to_xml(Domain) when is_list(Domain) ->
|
domain_to_xml(Domain) when is_list(Domain) ->
|
||||||
domain_to_xml(list_to_binary(Domain)).
|
domain_to_xml(list_to_binary(Domain)).
|
||||||
@ -280,7 +280,7 @@ process_sm_iq_items(From, To, #iq{type = get, payload = SubEl,
|
|||||||
{result, Items} ->
|
{result, Items} ->
|
||||||
ANode = case Node of
|
ANode = case Node of
|
||||||
<<>> -> [];
|
<<>> -> [];
|
||||||
_ -> [#xmlattr{name = 'node', value = Node}]
|
_ -> [?XMLATTR('node', Node)]
|
||||||
end,
|
end,
|
||||||
Result = #xmlel{ns = ?NS_DISCO_ITEMS, name = 'query',
|
Result = #xmlel{ns = ?NS_DISCO_ITEMS, name = 'query',
|
||||||
attrs = ANode, children = Items},
|
attrs = ANode, children = Items},
|
||||||
@ -294,7 +294,7 @@ process_sm_iq_items(From, To, #iq{type = set, payload = SubEl} = IQ_Rec) ->
|
|||||||
LFrom = exmpp_jid:lnode_as_list(From),
|
LFrom = exmpp_jid:lnode_as_list(From),
|
||||||
LServer = exmpp_jid:ldomain_as_list(From),
|
LServer = exmpp_jid:ldomain_as_list(From),
|
||||||
Self = (LTo == LFrom) andalso (ToServer == LServer),
|
Self = (LTo == LFrom) andalso (ToServer == LServer),
|
||||||
Node = exmpp_xml:get_attribute(SubEl, 'node', ""),
|
Node = exmpp_xml:get_attribute_as_list(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.
|
||||||
@ -358,7 +358,7 @@ process_sm_iq_info(From, To, #iq{type = get, payload = SubEl,
|
|||||||
{result, Features} ->
|
{result, Features} ->
|
||||||
ANode = case Node of
|
ANode = case Node of
|
||||||
<<>> -> [];
|
<<>> -> [];
|
||||||
_ -> [#xmlattr{name = 'node', value = Node}]
|
_ -> [?XMLATTR('node', Node)]
|
||||||
end,
|
end,
|
||||||
Result = #xmlel{ns = ?NS_DISCO_INFO, name = 'query',
|
Result = #xmlel{ns = ?NS_DISCO_INFO, name = 'query',
|
||||||
attrs = ANode,
|
attrs = ANode,
|
||||||
@ -396,9 +396,9 @@ get_user_resources(JID) ->
|
|||||||
exmpp_jid:ldomain(JID)),
|
exmpp_jid:ldomain(JID)),
|
||||||
lists:map(fun(R) ->
|
lists:map(fun(R) ->
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [
|
||||||
#xmlattr{name = 'jid', value =
|
?XMLATTR('jid',
|
||||||
exmpp_jid:jid_to_binary(exmpp_jid:bare_jid_to_jid(JID, R))},
|
exmpp_jid:jid_to_binary(exmpp_jid:bare_jid_to_jid(JID, R))),
|
||||||
#xmlattr{name = 'name', value = exmpp_jid:lnode(JID)}
|
?XMLATTR('name', exmpp_jid:lnode(JID))
|
||||||
]}
|
]}
|
||||||
end, lists:sort(Rs)).
|
end, lists:sort(Rs)).
|
||||||
|
|
||||||
@ -421,10 +421,10 @@ process_disco_publish(User, Node, Items) ->
|
|||||||
F = fun() ->
|
F = fun() ->
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(#xmlel{} = Item) ->
|
fun(#xmlel{} = Item) ->
|
||||||
Action = exmpp_xml:get_attribute(Item, 'action', ""),
|
Action = exmpp_xml:get_attribute_as_list(Item, 'action', ""),
|
||||||
Jid = exmpp_xml:get_attribute(Item, 'jid', ""),
|
Jid = exmpp_xml:get_attribute_as_list(Item, 'jid', ""),
|
||||||
PNode = exmpp_xml:get_attribute(Item, 'node', ""),
|
PNode = exmpp_xml:get_attribute_as_list(Item, 'node', ""),
|
||||||
Name = exmpp_xml:get_attribute(Item, 'name', ""),
|
Name = exmpp_xml:get_attribute_as_list(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]),
|
||||||
|
|
||||||
@ -488,18 +488,18 @@ retrieve_disco_publish(User, Node) ->
|
|||||||
name = Name,
|
name = Name,
|
||||||
node = PNode}) ->
|
node = PNode}) ->
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
||||||
lists:append([[#xmlattr{name = 'jid', value = list_to_binary(Jid)}],
|
lists:append([[?XMLATTR('jid', Jid)],
|
||||||
case Name of
|
case Name of
|
||||||
"" ->
|
"" ->
|
||||||
[];
|
[];
|
||||||
_ ->
|
_ ->
|
||||||
[#xmlattr{name = 'name', value = list_to_binary(Name)}]
|
[?XMLATTR('name', Name)]
|
||||||
end,
|
end,
|
||||||
case PNode of
|
case PNode of
|
||||||
"" ->
|
"" ->
|
||||||
[];
|
[];
|
||||||
_ ->
|
_ ->
|
||||||
[#xmlattr{name = 'node', value = list_to_binary(PNode)}]
|
[?XMLATTR('node', PNode)]
|
||||||
end])}
|
end])}
|
||||||
end, Items)}
|
end, Items)}
|
||||||
end.
|
end.
|
||||||
|
@ -303,17 +303,17 @@ closed_connection(Host, From, Server) ->
|
|||||||
|
|
||||||
iq_disco(Lang) ->
|
iq_disco(Lang) ->
|
||||||
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
|
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
|
||||||
[#xmlattr{name = 'category', value = <<"conference">>},
|
[?XMLATTR('category', <<"conference">>),
|
||||||
#xmlattr{name = 'type', value = <<"irc">>},
|
?XMLATTR('type', <<"irc">>),
|
||||||
#xmlattr{name = 'name', value = list_to_binary(translate:translate(Lang, "IRC Transport"))}]},
|
?XMLATTR('name', translate:translate(Lang, "IRC Transport"))]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
||||||
[#xmlattr{name = 'var', value = list_to_binary(?NS_DISCO_INFO_s)}]},
|
[?XMLATTR('var', ?NS_DISCO_INFO_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
||||||
[#xmlattr{name = 'var', value = list_to_binary(?NS_MUC_s)}]},
|
[?XMLATTR('var', ?NS_MUC_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
||||||
[#xmlattr{name = 'var', value = list_to_binary(?NS_INBAND_REGISTER_s)}]},
|
[?XMLATTR('var', ?NS_INBAND_REGISTER_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
||||||
[#xmlattr{name = 'var', value = list_to_binary(?NS_VCARD_s)}]}].
|
[?XMLATTR('var', ?NS_VCARD_s)]}].
|
||||||
|
|
||||||
iq_get_vcard(Lang) ->
|
iq_get_vcard(Lang) ->
|
||||||
[#xmlel{ns = ?NS_VCARD, name = 'FN', children =
|
[#xmlel{ns = ?NS_VCARD, name = 'FN', children =
|
||||||
@ -354,7 +354,7 @@ process_irc_register(Host, From, _To, DefEnc,
|
|||||||
#iq{type = get, ns = XMLNS,
|
#iq{type = get, ns = XMLNS,
|
||||||
lang = Lang, payload = SubEl} = IQ_Rec) ->
|
lang = Lang, payload = SubEl} = IQ_Rec) ->
|
||||||
Node =
|
Node =
|
||||||
string:tokens(exmpp_xml:get_attribute(SubEl, 'node', ""), "/"),
|
string:tokens(exmpp_xml:get_attribute_as_list(SubEl, 'node', ""), "/"),
|
||||||
case get_form(Host, From, Node, Lang ,DefEnc) of
|
case get_form(Host, From, Node, Lang ,DefEnc) of
|
||||||
{result, Res} ->
|
{result, Res} ->
|
||||||
Result = #xmlel{ns = XMLNS, name = 'query', children = Res},
|
Result = #xmlel{ns = XMLNS, name = 'query', children = Res},
|
||||||
@ -381,7 +381,7 @@ process_irc_register(Host, From, _To, _DefEnc,
|
|||||||
exmpp_iq:error(IQ_Rec, 'bad-request');
|
exmpp_iq:error(IQ_Rec, 'bad-request');
|
||||||
_ ->
|
_ ->
|
||||||
Node = string:tokens(
|
Node = string:tokens(
|
||||||
exmpp_xml:get_attribute(SubEl, "node", ""),
|
exmpp_xml:get_attribute_as_list(SubEl, "node", ""),
|
||||||
"/"),
|
"/"),
|
||||||
case set_form(
|
case set_form(
|
||||||
Host, From, Node, Lang, XData) of
|
Host, From, Node, Lang, XData) of
|
||||||
@ -439,13 +439,13 @@ get_form(Host, From, [], Lang, DefEnc) ->
|
|||||||
Lang,
|
Lang,
|
||||||
"Enter username and encodings you wish to use for "
|
"Enter username and encodings you wish to use for "
|
||||||
"connecting to IRC servers"))}]},
|
"connecting to IRC servers"))}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [#xmlattr{name = 'type', value = <<"text-single">>},
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', <<"text-single">>),
|
||||||
#xmlattr{name = 'label', value =
|
?XMLATTR('label',
|
||||||
list_to_binary(translate:translate(
|
translate:translate(
|
||||||
Lang, "IRC Username"))},
|
Lang, "IRC Username")),
|
||||||
#xmlattr{name = 'var', value = <<"username">>}], children =
|
?XMLATTR('var', <<"username">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Username)}]}]},
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Username)}]}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [#xmlattr{name = 'type', value = <<"fixed">>}], children =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', <<"fixed">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(
|
[#xmlcdata{cdata = list_to_binary(
|
||||||
lists:flatten(
|
lists:flatten(
|
||||||
@ -457,7 +457,7 @@ get_form(Host, From, [], Lang, DefEnc) ->
|
|||||||
"in format '{\"irc server\", \"encoding\"}'. "
|
"in format '{\"irc server\", \"encoding\"}'. "
|
||||||
"By default this service use \"~s\" encoding."),
|
"By default this service use \"~s\" encoding."),
|
||||||
[DefEnc])))}]}]},
|
[DefEnc])))}]}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [#xmlattr{name = 'type', value = <<"fixed">>}], children =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', <<"fixed">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(
|
[#xmlcdata{cdata = list_to_binary(
|
||||||
translate:translate(
|
translate:translate(
|
||||||
@ -465,10 +465,10 @@ get_form(Host, From, [], Lang, DefEnc) ->
|
|||||||
"Example: [{\"irc.lucky.net\", \"koi8-r\"}, "
|
"Example: [{\"irc.lucky.net\", \"koi8-r\"}, "
|
||||||
"{\"vendetta.fef.net\", \"iso8859-1\"}]."
|
"{\"vendetta.fef.net\", \"iso8859-1\"}]."
|
||||||
))}]}]},
|
))}]}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [#xmlattr{name = 'type', value = <<"text-multi">>},
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', <<"text-multi">>),
|
||||||
#xmlattr{name = 'label', value =
|
?XMLATTR('label',
|
||||||
list_to_binary(translate:translate(Lang, "Encodings"))},
|
translate:translate(Lang, "Encodings")),
|
||||||
#xmlattr{name = 'var', value = <<"encodings">>}], children =
|
?XMLATTR('var', <<"encodings">>)], children =
|
||||||
lists:map(
|
lists:map(
|
||||||
fun(S) ->
|
fun(S) ->
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(S)}]}
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(S)}]}
|
||||||
|
@ -590,8 +590,8 @@ terminate(_Reason, _StateName, StateData) ->
|
|||||||
lists:concat([Chan, "%", StateData#state.server]),
|
lists:concat([Chan, "%", StateData#state.server]),
|
||||||
StateData#state.host, StateData#state.nick),
|
StateData#state.host, StateData#state.nick),
|
||||||
StateData#state.user,
|
StateData#state.user,
|
||||||
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', attrs = [#xmlattr{name = 'type', value = <<"error">>}], children =
|
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', attrs = [?XMLATTR('type', <<"error">>)], children =
|
||||||
[#xmlel{ns = ?NS_JABBER_CLIENT, name = 'error', attrs = [#xmlattr{name = 'code', value = <<"502">>}], children =
|
[#xmlel{ns = ?NS_JABBER_CLIENT, name = 'error', attrs = [?XMLATTR('code', <<"502">>)], children =
|
||||||
[#xmlcdata{cdata = <<"Server Connect Failed">>}]}]})
|
[#xmlcdata{cdata = <<"Server Connect Failed">>}]}]})
|
||||||
end, dict:fetch_keys(StateData#state.channels)),
|
end, dict:fetch_keys(StateData#state.channels)),
|
||||||
case StateData#state.socket of
|
case StateData#state.socket of
|
||||||
@ -629,11 +629,11 @@ bounce_messages(Reason) ->
|
|||||||
ok;
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
Error = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'error',
|
Error = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'error',
|
||||||
attrs = [#xmlattr{name = 'code', value = <<"502">>}],
|
attrs = [?XMLATTR('code', <<"502">>)],
|
||||||
children = [#xmlcdata{cdata = Reason}]},
|
children = [#xmlcdata{cdata = Reason}]},
|
||||||
Err = exmpp_stanza:reply_with_error(El, Error),
|
Err = exmpp_stanza:reply_with_error(El, Error),
|
||||||
From = exmpp_jid:binary_to_jid(exmpp_stanza:get_sender(El)),
|
From = exmpp_jid:parse_jid(exmpp_stanza:get_sender(El)),
|
||||||
To = exmpp_jid:binary_to_jid(exmpp_stanza:get_recipient(El)),
|
To = exmpp_jid:parse_jid(exmpp_stanza:get_recipient(El)),
|
||||||
ejabberd_router:route(To, From, Err)
|
ejabberd_router:route(To, From, Err)
|
||||||
end,
|
end,
|
||||||
bounce_messages(Reason)
|
bounce_messages(Reason)
|
||||||
@ -692,8 +692,8 @@ process_channel_list_user(StateData, Chan, User) ->
|
|||||||
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', children =
|
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', children =
|
||||||
[#xmlel{ns = ?NS_MUC_USER, name = 'x', children =
|
[#xmlel{ns = ?NS_MUC_USER, name = 'x', children =
|
||||||
[#xmlel{ns = ?NS_MUC_USER, name = 'item', attrs =
|
[#xmlel{ns = ?NS_MUC_USER, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'affiliation', value = Affiliation},
|
[?XMLATTR('affiliation', Affiliation),
|
||||||
#xmlattr{name = 'role', value = Role}]}]}]}),
|
?XMLATTR('role', Role)]}]}]}),
|
||||||
case catch dict:update(Chan,
|
case catch dict:update(Chan,
|
||||||
fun(Ps) ->
|
fun(Ps) ->
|
||||||
?SETS:add_element(User2, Ps)
|
?SETS:add_element(User2, Ps)
|
||||||
@ -893,11 +893,11 @@ process_part(StateData, Chan, From, String) ->
|
|||||||
exmpp_jid:make_jid(lists:concat([Chan, "%", StateData#state.server]),
|
exmpp_jid:make_jid(lists:concat([Chan, "%", StateData#state.server]),
|
||||||
StateData#state.host, FromUser),
|
StateData#state.host, FromUser),
|
||||||
StateData#state.user,
|
StateData#state.user,
|
||||||
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', attrs = [#xmlattr{name = 'type', value = <<"unavailable">>}], children =
|
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', attrs = [?XMLATTR('type', <<"unavailable">>)], children =
|
||||||
[#xmlel{ns = ?NS_MUC_USER, name = 'x', children =
|
[#xmlel{ns = ?NS_MUC_USER, name = 'x', children =
|
||||||
[#xmlel{ns = ?NS_MUC_USER, name = 'item', attrs =
|
[#xmlel{ns = ?NS_MUC_USER, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'affiliation', value = <<"member">>},
|
[?XMLATTR('affiliation', <<"member">>),
|
||||||
#xmlattr{name = 'role', value = <<"none">>}]}]},
|
?XMLATTR('role', <<"none">>)]}]},
|
||||||
#xmlel{ns = ?NS_MUC_USER, name = 'status', children =
|
#xmlel{ns = ?NS_MUC_USER, name = 'status', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(Msg1 ++ " (" ++ FromIdent ++ ")")}]}]
|
[#xmlcdata{cdata = list_to_binary(Msg1 ++ " (" ++ FromIdent ++ ")")}]}]
|
||||||
}),
|
}),
|
||||||
@ -927,11 +927,11 @@ process_quit(StateData, From, String) ->
|
|||||||
lists:concat([Chan, "%", StateData#state.server]),
|
lists:concat([Chan, "%", StateData#state.server]),
|
||||||
StateData#state.host, FromUser),
|
StateData#state.host, FromUser),
|
||||||
StateData#state.user,
|
StateData#state.user,
|
||||||
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', attrs = [#xmlattr{name = 'type', value = <<"unavailable">>}], children =
|
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', attrs = [?XMLATTR('type', <<"unavailable">>)], children =
|
||||||
[#xmlel{ns = ?NS_MUC_USER, name = 'x', children =
|
[#xmlel{ns = ?NS_MUC_USER, name = 'x', children =
|
||||||
[#xmlel{ns = ?NS_MUC_USER, name = 'item', attrs =
|
[#xmlel{ns = ?NS_MUC_USER, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'affiliation', value = <<"member">>},
|
[?XMLATTR('affiliation', <<"member">>),
|
||||||
#xmlattr{name = 'role', value = <<"none">>}]}]},
|
?XMLATTR('role', <<"none">>)]}]},
|
||||||
#xmlel{ns = ?NS_MUC_USER, name = 'status', children =
|
#xmlel{ns = ?NS_MUC_USER, name = 'status', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(Msg1 ++ " (" ++ FromIdent ++ ")")}]}
|
[#xmlcdata{cdata = list_to_binary(Msg1 ++ " (" ++ FromIdent ++ ")")}]}
|
||||||
]}),
|
]}),
|
||||||
@ -953,8 +953,8 @@ process_join(StateData, Channel, From, _String) ->
|
|||||||
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', children =
|
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', children =
|
||||||
[#xmlel{ns = ?NS_MUC_USER, name = 'x', children =
|
[#xmlel{ns = ?NS_MUC_USER, name = 'x', children =
|
||||||
[#xmlel{ns = ?NS_MUC_USER, name = 'item', attrs =
|
[#xmlel{ns = ?NS_MUC_USER, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'affiliation', value = <<"member">>},
|
[?XMLATTR('affiliation', <<"member">>),
|
||||||
#xmlattr{name = 'role', value = <<"participant">>}]}]},
|
?XMLATTR('role', <<"participant">>)]}]},
|
||||||
#xmlel{ns = ?NS_MUC_USER, name = 'status', children =
|
#xmlel{ns = ?NS_MUC_USER, name = 'status', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(FromIdent)}]}]}),
|
[#xmlcdata{cdata = list_to_binary(FromIdent)}]}]}),
|
||||||
|
|
||||||
@ -979,8 +979,8 @@ process_mode_o(StateData, Chan, _From, Nick, Affiliation, Role) ->
|
|||||||
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', children =
|
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', children =
|
||||||
[#xmlel{ns = ?NS_MUC_USER, name = 'x', children =
|
[#xmlel{ns = ?NS_MUC_USER, name = 'x', children =
|
||||||
[#xmlel{ns = ?NS_MUC_USER, name = 'item', attrs =
|
[#xmlel{ns = ?NS_MUC_USER, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'affiliation', value = list_to_binary(Affiliation)},
|
[?XMLATTR('affiliation', Affiliation),
|
||||||
#xmlattr{name = 'role', value = list_to_binary(Role)}]}]}]}).
|
?XMLATTR('role', Role)]}]}]}).
|
||||||
|
|
||||||
process_kick(StateData, Chan, From, Nick, String) ->
|
process_kick(StateData, Chan, From, Nick, String) ->
|
||||||
Msg = lists:last(string:tokens(String, ":")),
|
Msg = lists:last(string:tokens(String, ":")),
|
||||||
@ -994,12 +994,12 @@ process_kick(StateData, Chan, From, Nick, String) ->
|
|||||||
exmpp_jid:make_jid(lists:concat([Chan, "%", StateData#state.server]),
|
exmpp_jid:make_jid(lists:concat([Chan, "%", StateData#state.server]),
|
||||||
StateData#state.host, Nick),
|
StateData#state.host, Nick),
|
||||||
StateData#state.user,
|
StateData#state.user,
|
||||||
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', attrs = [#xmlattr{name = 'type', value = <<"unavailable">>}], children =
|
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', attrs = [?XMLATTR('type', <<"unavailable">>)], children =
|
||||||
[#xmlel{ns = ?NS_MUC_USER, name = 'x', children =
|
[#xmlel{ns = ?NS_MUC_USER, name = 'x', children =
|
||||||
[#xmlel{ns = ?NS_MUC_USER, name = 'item', attrs =
|
[#xmlel{ns = ?NS_MUC_USER, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'affiliation', value = <<"none">>},
|
[?XMLATTR('affiliation', <<"none">>),
|
||||||
#xmlattr{name = 'role', value = <<"none">>}]},
|
?XMLATTR('role', <<"none">>)]},
|
||||||
#xmlel{ns = ?NS_MUC_USER, name = 'status', attrs = [#xmlattr{name = 'code', value = <<"307">>}]}
|
#xmlel{ns = ?NS_MUC_USER, name = 'status', attrs = [?XMLATTR('code', <<"307">>)]}
|
||||||
]}]}).
|
]}]}).
|
||||||
|
|
||||||
process_nick(StateData, From, NewNick) ->
|
process_nick(StateData, From, NewNick) ->
|
||||||
@ -1015,13 +1015,13 @@ process_nick(StateData, From, NewNick) ->
|
|||||||
lists:concat([Chan, "%", StateData#state.server]),
|
lists:concat([Chan, "%", StateData#state.server]),
|
||||||
StateData#state.host, FromUser),
|
StateData#state.host, FromUser),
|
||||||
StateData#state.user,
|
StateData#state.user,
|
||||||
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', attrs = [#xmlattr{name = 'type', value = <<"unavailable">>}], children =
|
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', attrs = [?XMLATTR('type', <<"unavailable">>)], children =
|
||||||
[#xmlel{ns = ?NS_MUC_USER, name = 'x', children =
|
[#xmlel{ns = ?NS_MUC_USER, name = 'x', children =
|
||||||
[#xmlel{ns = ?NS_MUC_USER, name = 'item', attrs =
|
[#xmlel{ns = ?NS_MUC_USER, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'affiliation', value = <<"member">>},
|
[?XMLATTR('affiliation', <<"member">>),
|
||||||
#xmlattr{name = 'role', value = <<"participant">>},
|
?XMLATTR('role', <<"participant">>),
|
||||||
#xmlattr{name = 'nick', value = list_to_binary(Nick)}]},
|
?XMLATTR('nick', Nick)]},
|
||||||
#xmlel{ns = ?NS_MUC_USER, name = 'status', attrs = [#xmlattr{name = 'code', value = <<"303">>}]}
|
#xmlel{ns = ?NS_MUC_USER, name = 'status', attrs = [?XMLATTR('code', <<"303">>)]}
|
||||||
]}]}),
|
]}]}),
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
exmpp_jid:make_jid(
|
exmpp_jid:make_jid(
|
||||||
@ -1031,8 +1031,8 @@ process_nick(StateData, From, NewNick) ->
|
|||||||
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', children =
|
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', children =
|
||||||
[#xmlel{ns = ?NS_MUC_USER, name = 'x', children =
|
[#xmlel{ns = ?NS_MUC_USER, name = 'x', children =
|
||||||
[#xmlel{ns = ?NS_MUC_USER, name = 'item', attrs =
|
[#xmlel{ns = ?NS_MUC_USER, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'affiliation', value = <<"member">>},
|
[?XMLATTR('affiliation', <<"member">>),
|
||||||
#xmlattr{name = 'role', value = <<"participant">>}]}
|
?XMLATTR('role', <<"participant">>)]}
|
||||||
]}]}),
|
]}]}),
|
||||||
?SETS:add_element(Nick,
|
?SETS:add_element(Nick,
|
||||||
remove_element(FromUser, Ps));
|
remove_element(FromUser, Ps));
|
||||||
@ -1051,8 +1051,8 @@ process_error(StateData, String) ->
|
|||||||
lists:concat([Chan, "%", StateData#state.server]),
|
lists:concat([Chan, "%", StateData#state.server]),
|
||||||
StateData#state.host, StateData#state.nick),
|
StateData#state.host, StateData#state.nick),
|
||||||
StateData#state.user,
|
StateData#state.user,
|
||||||
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', attrs = [#xmlattr{name = 'type', value = <<"error">>}], children =
|
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', attrs = [?XMLATTR('type', <<"error">>)], children =
|
||||||
[#xmlel{ns = ?NS_JABBER_CLIENT, name = 'error', attrs = [#xmlattr{name = 'code', value = <<"502">>}], children =
|
[#xmlel{ns = ?NS_JABBER_CLIENT, name = 'error', attrs = [?XMLATTR('code', <<"502">>)], children =
|
||||||
[#xmlcdata{cdata = list_to_binary(String)}]}]})
|
[#xmlcdata{cdata = list_to_binary(String)}]}]})
|
||||||
end, dict:fetch_keys(StateData#state.channels)).
|
end, dict:fetch_keys(StateData#state.channels)).
|
||||||
|
|
||||||
@ -1098,9 +1098,9 @@ process_iq_admin(StateData, Channel, set, SubEl) ->
|
|||||||
false ->
|
false ->
|
||||||
{error, 'bad-request'};
|
{error, 'bad-request'};
|
||||||
ItemEl ->
|
ItemEl ->
|
||||||
Nick = exmpp_xml:get_attribute(ItemEl, 'nick', ""),
|
Nick = exmpp_xml:get_attribute_as_list(ItemEl, 'nick', ""),
|
||||||
Affiliation = exmpp_xml:get_attribute(ItemEl, 'affiliation', ""),
|
Affiliation = exmpp_xml:get_attribute_as_list(ItemEl, 'affiliation', ""),
|
||||||
Role = exmpp_xml:get_attribute(ItemEl, 'role', ""),
|
Role = exmpp_xml:get_attribute_as_list(ItemEl, 'role', ""),
|
||||||
Reason = exmpp_xml:get_path(ItemEl, [{element, 'reason'}, cdata_as_list]),
|
Reason = exmpp_xml:get_path(ItemEl, [{element, 'reason'}, cdata_as_list]),
|
||||||
process_admin(StateData, Channel, Nick, Affiliation, Role, Reason)
|
process_admin(StateData, Channel, Nick, Affiliation, Role, Reason)
|
||||||
end;
|
end;
|
||||||
|
@ -78,7 +78,7 @@ stop(Host) ->
|
|||||||
process_local_iq(_From, _To, #iq{type = get} = IQ_Rec) ->
|
process_local_iq(_From, _To, #iq{type = get} = IQ_Rec) ->
|
||||||
Sec = get_node_uptime(),
|
Sec = get_node_uptime(),
|
||||||
Response = #xmlel{ns = ?NS_LAST_ACTIVITY, name = 'query', attrs =
|
Response = #xmlel{ns = ?NS_LAST_ACTIVITY, name = 'query', attrs =
|
||||||
[#xmlattr{name = 'seconds', value = list_to_binary(integer_to_list(Sec))}]},
|
[?XMLATTR('seconds', Sec)]},
|
||||||
exmpp_iq:result(IQ_Rec, Response);
|
exmpp_iq:result(IQ_Rec, Response);
|
||||||
process_local_iq(_From, _To, #iq{type = set} = IQ_Rec) ->
|
process_local_iq(_From, _To, #iq{type = set} = IQ_Rec) ->
|
||||||
exmpp_iq:error(IQ_Rec, 'not-allowed').
|
exmpp_iq:error(IQ_Rec, 'not-allowed').
|
||||||
@ -142,7 +142,7 @@ get_last(IQ_Rec, LUser, LServer) ->
|
|||||||
TimeStamp2 = now_to_seconds(now()),
|
TimeStamp2 = now_to_seconds(now()),
|
||||||
Sec = TimeStamp2 - TimeStamp,
|
Sec = TimeStamp2 - TimeStamp,
|
||||||
Response = #xmlel{ns = ?NS_LAST_ACTIVITY, name = 'query',
|
Response = #xmlel{ns = ?NS_LAST_ACTIVITY, name = 'query',
|
||||||
attrs = [#xmlattr{name = 'seconds', value = list_to_binary(integer_to_list(Sec))}],
|
attrs = [?XMLATTR('seconds', Sec)],
|
||||||
children = [#xmlcdata{cdata = Status}]},
|
children = [#xmlcdata{cdata = Status}]},
|
||||||
exmpp_iq:result(IQ_Rec, Response)
|
exmpp_iq:result(IQ_Rec, Response)
|
||||||
end.
|
end.
|
||||||
|
@ -71,7 +71,7 @@ stop(Host) ->
|
|||||||
process_local_iq(_From, _To, #iq{type = get} = IQ_Rec) ->
|
process_local_iq(_From, _To, #iq{type = get} = IQ_Rec) ->
|
||||||
Sec = get_node_uptime(),
|
Sec = get_node_uptime(),
|
||||||
Response = #xmlel{ns = ?NS_LAST_ACTIVITY, name = 'query', attrs =
|
Response = #xmlel{ns = ?NS_LAST_ACTIVITY, name = 'query', attrs =
|
||||||
[#xmlattr{name = 'seconds', value = list_to_binary(integer_to_list(Sec))}]},
|
[?XMLATTR('seconds', Sec)]},
|
||||||
exmpp_iq:result(IQ_Rec, Response);
|
exmpp_iq:result(IQ_Rec, Response);
|
||||||
process_local_iq(_From, _To, #iq{type = set} = IQ_Rec) ->
|
process_local_iq(_From, _To, #iq{type = set} = IQ_Rec) ->
|
||||||
exmpp_iq:error(IQ_Rec, 'not-allowed').
|
exmpp_iq:error(IQ_Rec, 'not-allowed').
|
||||||
@ -137,7 +137,7 @@ get_last(IQ_Rec, LUser, LServer) ->
|
|||||||
TimeStamp2 = now_to_seconds(now()),
|
TimeStamp2 = now_to_seconds(now()),
|
||||||
Sec = TimeStamp2 - TimeStamp,
|
Sec = TimeStamp2 - TimeStamp,
|
||||||
Response = #xmlel{ns = ?NS_LAST_ACTIVITY, name = 'query',
|
Response = #xmlel{ns = ?NS_LAST_ACTIVITY, name = 'query',
|
||||||
attrs = [#xmlattr{name = 'seconds', value = list_to_binary(integer_to_list(Sec))}],
|
attrs = [?XMLATTR('seconds', Sec)],
|
||||||
children = [#xmlcdata{cdata = list_to_binary(Status)}]},
|
children = [#xmlcdata{cdata = list_to_binary(Status)}]},
|
||||||
exmpp_iq:result(IQ_Rec, Response);
|
exmpp_iq:result(IQ_Rec, Response);
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -265,7 +265,7 @@ handle_info(_Info, State) ->
|
|||||||
%% The return value is ignored.
|
%% The return value is ignored.
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
terminate(_Reason, State) ->
|
terminate(_Reason, State) ->
|
||||||
ejabberd_router:unregister_route(State#state.host),
|
ejabberd_router:unregister_route(binary_to_list(State#state.host)),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
@ -378,7 +378,7 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
|
|||||||
ok
|
ok
|
||||||
end;
|
end;
|
||||||
'message' ->
|
'message' ->
|
||||||
case exmpp_xml:get_attribute(Packet,type, "chat") of
|
case exmpp_xml:get_attribute_as_list(Packet,type, "chat") of
|
||||||
"error" ->
|
"error" ->
|
||||||
ok;
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
@ -496,30 +496,30 @@ register_room(Host, Room, Pid) when is_binary(Host), is_binary(Room) ->
|
|||||||
|
|
||||||
iq_disco_info(Lang) ->
|
iq_disco_info(Lang) ->
|
||||||
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity',
|
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity',
|
||||||
attrs = [#xmlattr{name = 'category',
|
attrs = [?XMLATTR('category',
|
||||||
value = "conference"},
|
<<"conference">>),
|
||||||
#xmlattr{name = 'type',
|
?XMLATTR('type',
|
||||||
value = "text"},
|
<<"text">>),
|
||||||
#xmlattr{name = 'name',
|
?XMLATTR('name',
|
||||||
value = translate:translate(Lang, "Chatrooms")}]},
|
translate:translate(Lang, "Chatrooms"))]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
||||||
[#xmlattr{name = 'var',
|
[?XMLATTR('var',
|
||||||
value = ?NS_DISCO_INFO_s}]},
|
?NS_DISCO_INFO_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
||||||
[#xmlattr{name = 'var',
|
[?XMLATTR('var',
|
||||||
value = ?NS_DISCO_ITEMS_s}]},
|
?NS_DISCO_ITEMS_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
||||||
[#xmlattr{name = 'var',
|
[?XMLATTR('var',
|
||||||
value = ?NS_MUC_s}]},
|
?NS_MUC_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
||||||
[#xmlattr{name = 'var',
|
[?XMLATTR('var',
|
||||||
value = ?NS_INBAND_REGISTER_s}]},
|
?NS_INBAND_REGISTER_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
||||||
[#xmlattr{name = 'var',
|
[?XMLATTR('var',
|
||||||
value = ?NS_RSM_s}]},
|
?NS_RSM_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs =
|
||||||
[#xmlattr{name = 'var',
|
[?XMLATTR('var',
|
||||||
value = ?NS_VCARD_s}]}].
|
?NS_VCARD_s)]}].
|
||||||
|
|
||||||
|
|
||||||
iq_disco_items(Host, From, Lang, none) when is_binary(Host) ->
|
iq_disco_items(Host, From, Lang, none) when is_binary(Host) ->
|
||||||
@ -530,11 +530,11 @@ iq_disco_items(Host, From, Lang, none) when is_binary(Host) ->
|
|||||||
flush(),
|
flush(),
|
||||||
{true,
|
{true,
|
||||||
#xmlel{name = 'item',
|
#xmlel{name = 'item',
|
||||||
attrs = [#xmlattr{name = 'jid',
|
attrs = [?XMLATTR('jid',
|
||||||
value = exmpp_jid:jid_to_binary(Name,
|
exmpp_jid:jid_to_binary(Name,
|
||||||
Host)},
|
Host)),
|
||||||
#xmlattr{name = 'name',
|
?XMLATTR('name',
|
||||||
value = Desc}]}};
|
Desc)]}};
|
||||||
_ ->
|
_ ->
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
@ -615,10 +615,10 @@ flush() ->
|
|||||||
|
|
||||||
-define(XFIELD(Type, Label, Var, Val),
|
-define(XFIELD(Type, Label, Var, Val),
|
||||||
#xmlel{name = "field",
|
#xmlel{name = "field",
|
||||||
attrs = [#xmlattr{name = 'type', value = Type},
|
attrs = [?XMLATTR('type', Type),
|
||||||
#xmlattr{name = 'label',
|
?XMLATTR('label',
|
||||||
value = translate:translate(Lang, Label)},
|
translate:translate(Lang, Label)),
|
||||||
#xmlattr{name = 'var', value = Var}],
|
?XMLATTR('var', Var)],
|
||||||
children = [#xmlel{name = 'value',
|
children = [#xmlel{name = 'value',
|
||||||
children = [#xmlcdata{cdata = Val}]}]}).
|
children = [#xmlcdata{cdata = Val}]}]}).
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ build_filename_string(TimeStamp, OutDir, RoomJID, DirType, DirName, FileFormat)
|
|||||||
{Fd, Fn, Fnrel}.
|
{Fd, Fn, Fnrel}.
|
||||||
|
|
||||||
get_room_name(RoomJID) ->
|
get_room_name(RoomJID) ->
|
||||||
JID = exmpp_jid:list_to_jid(RoomJID),
|
JID = exmpp_jid:parse_jid(RoomJID),
|
||||||
exmpp_jid:node_as_list(JID).
|
exmpp_jid:node_as_list(JID).
|
||||||
|
|
||||||
%% calculate day before
|
%% calculate day before
|
||||||
|
@ -554,7 +554,7 @@ normal_state(_Event, StateData) ->
|
|||||||
%%----------------------------------------------------------------------
|
%%----------------------------------------------------------------------
|
||||||
handle_event({service_message, Msg}, _StateName, StateData) ->
|
handle_event({service_message, Msg}, _StateName, StateData) ->
|
||||||
MessagePkt = #xmlel{name = 'message',
|
MessagePkt = #xmlel{name = 'message',
|
||||||
attrs = [#xmlattr{name = 'type', value = "groupchat"}],
|
attrs = [?XMLATTR('type', <<"groupchat">>)],
|
||||||
children = [#xmlel{name = 'body',
|
children = [#xmlel{name = 'body',
|
||||||
children = [#xmlcdata{cdata = Msg}]}]},
|
children = [#xmlcdata{cdata = Msg}]}]},
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
@ -1523,7 +1523,7 @@ add_new_user(From, Nick, Packet, StateData) ->
|
|||||||
if not (NewState#state.config)#config.anonymous ->
|
if not (NewState#state.config)#config.anonymous ->
|
||||||
WPacket =
|
WPacket =
|
||||||
#xmlel{name = 'message',
|
#xmlel{name = 'message',
|
||||||
attrs = [#xmlattr{name = 'type', value = "groupchat"}],
|
attrs = [?XMLATTR('type', <<"groupchat">>)],
|
||||||
children = [
|
children = [
|
||||||
#xmlel{name = 'body',
|
#xmlel{name = 'body',
|
||||||
children = [#xmlcdata{cdata =
|
children = [#xmlcdata{cdata =
|
||||||
@ -1766,12 +1766,12 @@ send_new_presence(NJID, Reason, StateData) ->
|
|||||||
case (Info#user.role == moderator) orelse
|
case (Info#user.role == moderator) orelse
|
||||||
((StateData#state.config)#config.anonymous == false) of
|
((StateData#state.config)#config.anonymous == false) of
|
||||||
true ->
|
true ->
|
||||||
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_binary(RealJID)},
|
[?XMLATTR('jid', exmpp_jid:jid_to_binary(RealJID)),
|
||||||
#xmlattr{name = 'affiliation', value = SAffiliation},
|
?XMLATTR('affiliation', SAffiliation),
|
||||||
#xmlattr{name = 'role', value = SRole}];
|
?XMLATTR('role', SRole)];
|
||||||
_ ->
|
_ ->
|
||||||
[#xmlattr{name = 'affiliation', value = SAffiliation},
|
[?XMLATTR('affiliation', SAffiliation),
|
||||||
#xmlattr{name = 'role', value = SRole}]
|
?XMLATTR('role', SRole)]
|
||||||
end,
|
end,
|
||||||
ItemEls = case Reason of
|
ItemEls = case Reason of
|
||||||
<<>> ->
|
<<>> ->
|
||||||
@ -1783,7 +1783,7 @@ send_new_presence(NJID, Reason, StateData) ->
|
|||||||
Status = case StateData#state.just_created of
|
Status = case StateData#state.just_created of
|
||||||
true ->
|
true ->
|
||||||
[#xmlel{name = 'status',
|
[#xmlel{name = 'status',
|
||||||
attrs = [#xmlattr{name = 'code', value = "201"}]}];
|
attrs = [?XMLATTR('code', <<"201">>)]}];
|
||||||
false ->
|
false ->
|
||||||
[]
|
[]
|
||||||
end,
|
end,
|
||||||
@ -1822,14 +1822,14 @@ send_existing_presences(ToJID, StateData) ->
|
|||||||
((StateData#state.config)#config.anonymous ==
|
((StateData#state.config)#config.anonymous ==
|
||||||
false) of
|
false) of
|
||||||
true ->
|
true ->
|
||||||
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_binary(FromJID)},
|
[?XMLATTR('jid', exmpp_jid:jid_to_binary(FromJID)),
|
||||||
#xmlattr{name = 'affiliation',
|
?XMLATTR('affiliation',
|
||||||
value = affiliation_to_binary(FromAffiliation)},
|
affiliation_to_binary(FromAffiliation)),
|
||||||
#xmlattr{name = 'role', value = role_to_binary(FromRole)}];
|
?XMLATTR('role', role_to_binary(FromRole))];
|
||||||
_ ->
|
_ ->
|
||||||
[#xmlattr{name = 'affiliation',
|
[?XMLATTR('affiliation',
|
||||||
value = affiliation_to_binary(FromAffiliation)},
|
affiliation_to_binary(FromAffiliation)),
|
||||||
#xmlattr{name = 'role', value = role_to_binary(FromRole)}]
|
?XMLATTR('role', role_to_binary(FromRole))]
|
||||||
end,
|
end,
|
||||||
Packet = exmpp_xml:append_child(Presence,
|
Packet = exmpp_xml:append_child(Presence,
|
||||||
#xmlel{ns = ?NS_MUC_USER, name = 'x',
|
#xmlel{ns = ?NS_MUC_USER, name = 'x',
|
||||||
@ -1879,37 +1879,37 @@ send_nick_changing(JID, OldNick, StateData) ->
|
|||||||
case (Info#user.role == moderator) orelse
|
case (Info#user.role == moderator) orelse
|
||||||
((StateData#state.config)#config.anonymous == false) of
|
((StateData#state.config)#config.anonymous == false) of
|
||||||
true ->
|
true ->
|
||||||
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_binary(RealJID)},
|
[?XMLATTR('jid', exmpp_jid:jid_to_binary(RealJID)),
|
||||||
#xmlattr{name = 'affiliation', value = SAffiliation},
|
?XMLATTR('affiliation', SAffiliation),
|
||||||
#xmlattr{name = 'role', value = SRole},
|
?XMLATTR('role', SRole),
|
||||||
#xmlattr{name = 'nick', value = Nick}];
|
?XMLATTR('nick', Nick)];
|
||||||
_ ->
|
_ ->
|
||||||
[#xmlattr{name = 'affiliation', value = SAffiliation},
|
[?XMLATTR('affiliation', SAffiliation),
|
||||||
#xmlattr{name = 'role', value = SRole},
|
?XMLATTR('role', SRole),
|
||||||
#xmlattr{name = 'nick', value = Nick}]
|
?XMLATTR('nick', Nick)]
|
||||||
end,
|
end,
|
||||||
ItemAttrs2 =
|
ItemAttrs2 =
|
||||||
case (Info#user.role == moderator) orelse
|
case (Info#user.role == moderator) orelse
|
||||||
((StateData#state.config)#config.anonymous == false) of
|
((StateData#state.config)#config.anonymous == false) of
|
||||||
true ->
|
true ->
|
||||||
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_binary(RealJID)},
|
[?XMLATTR('jid', exmpp_jid:jid_to_binary(RealJID)),
|
||||||
#xmlattr{name = 'affiliation', value = SAffiliation},
|
?XMLATTR('affiliation', SAffiliation),
|
||||||
#xmlattr{name = 'role', value = SRole}];
|
?XMLATTR('role', SRole)];
|
||||||
_ ->
|
_ ->
|
||||||
[#xmlattr{name = 'affiliation', value = SAffiliation},
|
[?XMLATTR('affiliation', SAffiliation),
|
||||||
#xmlattr{name = 'role', value = SRole}]
|
?XMLATTR('role', SRole)]
|
||||||
end,
|
end,
|
||||||
Packet1 =
|
Packet1 =
|
||||||
#xmlel{ns = ?NS_JABBER_CLIENT,
|
#xmlel{ns = ?NS_JABBER_CLIENT,
|
||||||
name = 'presence',
|
name = 'presence',
|
||||||
attrs = [#xmlattr{name = 'type', value = <<"unavailable">>}],
|
attrs = [?XMLATTR('type', <<"unavailable">>)],
|
||||||
children = [#xmlel{ns = ?NS_MUC_USER, name = 'x',
|
children = [#xmlel{ns = ?NS_MUC_USER, name = 'x',
|
||||||
children = [
|
children = [
|
||||||
#xmlel{ns = ?NS_MUC_USER, name = 'item',
|
#xmlel{ns = ?NS_MUC_USER, name = 'item',
|
||||||
attrs = ItemAttrs1},
|
attrs = ItemAttrs1},
|
||||||
#xmlel{ns = ?NS_MUC_USER, name = 'status',
|
#xmlel{ns = ?NS_MUC_USER, name = 'status',
|
||||||
attrs = [#xmlattr{name = 'code',
|
attrs = [?XMLATTR('code',
|
||||||
value = "303"}]}]}]},
|
<<"303">>)]}]}]},
|
||||||
|
|
||||||
Packet2 = exmpp_xml:append_child(
|
Packet2 = exmpp_xml:append_child(
|
||||||
Presence,
|
Presence,
|
||||||
@ -2081,20 +2081,20 @@ items_with_affiliation(SAffiliation, StateData) ->
|
|||||||
fun({JID, {Affiliation, Reason}}) ->
|
fun({JID, {Affiliation, Reason}}) ->
|
||||||
{N, D, R} = JID,
|
{N, D, R} = JID,
|
||||||
#xmlel{name = 'item',
|
#xmlel{name = 'item',
|
||||||
attrs = [#xmlattr{name = 'affiliation',
|
attrs = [?XMLATTR('affiliation',
|
||||||
value = affiliation_to_binary(Affiliation)},
|
affiliation_to_binary(Affiliation)),
|
||||||
#xmlattr{name = 'jid',
|
?XMLATTR('jid',
|
||||||
value = exmpp_jid:jid_to_binary(N, D, R)}],
|
exmpp_jid:jid_to_binary(N, D, R))],
|
||||||
children = [ #xmlel{name = 'reason',
|
children = [ #xmlel{name = 'reason',
|
||||||
children = [#xmlcdata{cdata = Reason}]}]};
|
children = [#xmlcdata{cdata = Reason}]}]};
|
||||||
|
|
||||||
({JID, Affiliation}) ->
|
({JID, Affiliation}) ->
|
||||||
{N, D, R} = JID,
|
{N, D, R} = JID,
|
||||||
#xmlel{name = 'item',
|
#xmlel{name = 'item',
|
||||||
attrs = [#xmlattr{name = 'affiliation',
|
attrs = [?XMLATTR('affiliation',
|
||||||
value = affiliation_to_binary(Affiliation)},
|
affiliation_to_binary(Affiliation)),
|
||||||
#xmlattr{name = 'jid',
|
?XMLATTR('jid',
|
||||||
value = exmpp_jid:jid_to_binary(N, D, R)}]}
|
exmpp_jid:jid_to_binary(N, D, R))]}
|
||||||
end, search_affiliation(SAffiliation, StateData)).
|
end, search_affiliation(SAffiliation, StateData)).
|
||||||
|
|
||||||
user_to_item(#user{role = Role,
|
user_to_item(#user{role = Role,
|
||||||
@ -2104,10 +2104,10 @@ user_to_item(#user{role = Role,
|
|||||||
Affiliation = get_affiliation(JID, StateData),
|
Affiliation = get_affiliation(JID, StateData),
|
||||||
#xmlel{name = 'item',
|
#xmlel{name = 'item',
|
||||||
attrs = [
|
attrs = [
|
||||||
#xmlattr{name = 'role', value = role_to_binary(Role)},
|
?XMLATTR('role', role_to_binary(Role)),
|
||||||
#xmlattr{name = 'affiliation', value = affiliation_to_binary(Affiliation)},
|
?XMLATTR('affiliation', affiliation_to_binary(Affiliation)),
|
||||||
#xmlattr{name = 'nick', value = Nick},
|
?XMLATTR('nick', Nick),
|
||||||
#xmlattr{name = 'jid', value = exmpp_jid:jid_to_binary(JID)}]
|
?XMLATTR('jid', exmpp_jid:jid_to_binary(JID))]
|
||||||
}.
|
}.
|
||||||
|
|
||||||
search_role(Role, StateData) ->
|
search_role(Role, StateData) ->
|
||||||
@ -2227,7 +2227,7 @@ find_changed_items(UJID, UAffiliation, URole,
|
|||||||
Lang, StateData, Res) ->
|
Lang, StateData, Res) ->
|
||||||
TJID = case exmpp_xml:get_attribute_as_binary(Item, 'jid',false) of
|
TJID = case exmpp_xml:get_attribute_as_binary(Item, 'jid',false) of
|
||||||
S when S =/= false ->
|
S when S =/= false ->
|
||||||
try exmpp_jid:binary_to_jid(S) of
|
try exmpp_jid:parse_jid(S) of
|
||||||
J ->
|
J ->
|
||||||
{value, J}
|
{value, J}
|
||||||
catch
|
catch
|
||||||
@ -2239,7 +2239,7 @@ find_changed_items(UJID, UAffiliation, URole,
|
|||||||
{error, ?ERR(Item, 'not-acceptable', Lang, ErrText)}
|
{error, ?ERR(Item, 'not-acceptable', Lang, ErrText)}
|
||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
case exmpp_xml:get_attribute(Item, 'nick', false) of
|
case exmpp_xml:get_attribute_as_list(Item, 'nick', false) of
|
||||||
N when N =/= false ->
|
N when N =/= false ->
|
||||||
case find_jid_by_nick(N, StateData) of
|
case find_jid_by_nick(N, StateData) of
|
||||||
false ->
|
false ->
|
||||||
@ -2569,8 +2569,8 @@ send_kickban_presence1(UJID, Reason, Code, StateData) ->
|
|||||||
SAffiliation = affiliation_to_binary(Affiliation),
|
SAffiliation = affiliation_to_binary(Affiliation),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun({_LJID, Info}) ->
|
fun({_LJID, Info}) ->
|
||||||
ItemAttrs = [#xmlattr{name = 'affiliation', value = SAffiliation},
|
ItemAttrs = [?XMLATTR('affiliation', SAffiliation),
|
||||||
#xmlattr{name = 'role', value = "none"}],
|
?XMLATTR('role', <<"none">>)],
|
||||||
ItemEls = case Reason of
|
ItemEls = case Reason of
|
||||||
<<>> ->
|
<<>> ->
|
||||||
[];
|
[];
|
||||||
@ -2581,15 +2581,15 @@ send_kickban_presence1(UJID, Reason, Code, StateData) ->
|
|||||||
Packet =
|
Packet =
|
||||||
#xmlel{ns = ?NS_JABBER_CLIENT,
|
#xmlel{ns = ?NS_JABBER_CLIENT,
|
||||||
name = 'presence',
|
name = 'presence',
|
||||||
attrs = [#xmlattr{name = 'type', value = "unavailable"}],
|
attrs = [?XMLATTR('type', <<"unavailable">>)],
|
||||||
children = [#xmlel{ns = ?NS_MUC_USER, name = 'x',
|
children = [#xmlel{ns = ?NS_MUC_USER, name = 'x',
|
||||||
children = [
|
children = [
|
||||||
#xmlel{ns = ?NS_MUC_USER, name = 'item',
|
#xmlel{ns = ?NS_MUC_USER, name = 'item',
|
||||||
attrs = ItemAttrs,
|
attrs = ItemAttrs,
|
||||||
children = ItemEls},
|
children = ItemEls},
|
||||||
#xmlel{ns = ?NS_MUC_USER, name = 'status',
|
#xmlel{ns = ?NS_MUC_USER, name = 'status',
|
||||||
attrs = [#xmlattr{name='code',
|
attrs = [?XMLATTR('code',
|
||||||
value = Code}]}]}]},
|
Code)]}]}]},
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
jid_replace_resource(StateData#state.jid, Nick),
|
jid_replace_resource(StateData#state.jid, Nick),
|
||||||
Info#user.jid,
|
Info#user.jid,
|
||||||
@ -2688,9 +2688,9 @@ check_allowed_persistent_change(XEl, StateData, From) ->
|
|||||||
|
|
||||||
-define(XFIELD(Type, Label, Var, Val),
|
-define(XFIELD(Type, Label, Var, Val),
|
||||||
#xmlel{name = 'field',
|
#xmlel{name = 'field',
|
||||||
attrs = [#xmlattr{name = 'type', value = Type},
|
attrs = [?XMLATTR('type', Type),
|
||||||
#xmlattr{name = 'label', value = translate:translate(Lang, Label)},
|
?XMLATTR('label', translate:translate(Lang, Label)),
|
||||||
#xmlattr{name = 'var', value = Var}],
|
?XMLATTR('var', Var)],
|
||||||
children = [#xmlel{name = 'value',
|
children = [#xmlel{name = 'value',
|
||||||
children = [#xmlcdata{cdata = Val} ]}]}).
|
children = [#xmlcdata{cdata = Val} ]}]}).
|
||||||
|
|
||||||
@ -2729,8 +2729,8 @@ get_config(Lang, StateData, From) ->
|
|||||||
[#xmlel{name = 'title', children = [ #xmlcdata{cdata =
|
[#xmlel{name = 'title', children = [ #xmlcdata{cdata =
|
||||||
translate:translate(Lang, "Configuration for ") ++
|
translate:translate(Lang, "Configuration for ") ++
|
||||||
exmpp_jid:jid_to_list(StateData#state.jid)}]},
|
exmpp_jid:jid_to_list(StateData#state.jid)}]},
|
||||||
#xmlel{name = 'field', attrs = [#xmlattr{name = 'type', value = "hidden"},
|
#xmlel{name = 'field', attrs = [?XMLATTR('type', <<"hidden">>),
|
||||||
#xmlattr{name = 'var', value = "FORM_TYPE"}],
|
?XMLATTR('var', <<"FORM_TYPE">>)],
|
||||||
children = [#xmlel{name = 'value', children = [#xmlcdata{cdata =
|
children = [#xmlel{name = 'value', children = [#xmlcdata{cdata =
|
||||||
<<"http://jabber.org/protocol/muc#roomconfig">>
|
<<"http://jabber.org/protocol/muc#roomconfig">>
|
||||||
}]}]},
|
}]}]},
|
||||||
@ -2765,46 +2765,45 @@ get_config(Lang, StateData, From) ->
|
|||||||
false -> ""
|
false -> ""
|
||||||
end),
|
end),
|
||||||
#xmlel{name = 'field', attrs = [
|
#xmlel{name = 'field', attrs = [
|
||||||
#xmlattr{name = 'type', value = "list-single"},
|
?XMLATTR('type', <<"list-single">>),
|
||||||
#xmlattr{name = 'label', value = translate:translate(Lang,
|
?XMLATTR('label', translate:translate(Lang,
|
||||||
"Maximum Number of Occupants")},
|
"Maximum Number of Occupants")),
|
||||||
#xmlattr{name = 'var', value = "muc#roomconfig_maxusers"}],
|
?XMLATTR('var', <<"muc#roomconfig_maxusers">>)],
|
||||||
children = [#xmlel{name = 'value',
|
children = [#xmlel{name = 'value',
|
||||||
children = [#xmlcdata{cdata =
|
children = [#xmlcdata{cdata =
|
||||||
MaxUsersRoomString}]}] ++
|
MaxUsersRoomString}]}] ++
|
||||||
if
|
if
|
||||||
is_integer(ServiceMaxUsers) -> [];
|
is_integer(ServiceMaxUsers) -> [];
|
||||||
true ->
|
true ->
|
||||||
[#xmlel{name = 'option', attrs = [#xmlattr{name = 'label',
|
[#xmlel{name = 'option', attrs = [?XMLATTR('label',
|
||||||
value = translate:translate(Lang, "No limit")}],
|
translate:translate(Lang, "No limit"))],
|
||||||
children = [#xmlel{name = 'value', children = [#xmlcdata{
|
children = [#xmlel{name = 'value', children = [#xmlcdata{
|
||||||
cdata = <<"none">>}]}]}]
|
cdata = <<"none">>}]}]}]
|
||||||
end ++
|
end ++
|
||||||
[#xmlel{name = 'option', attrs = [#xmlattr{name = 'label',
|
[#xmlel{name = 'option', attrs = [?XMLATTR('label', N)],
|
||||||
value = erlang:integer_to_list(N)}],
|
|
||||||
children = [#xmlel{name = 'value', children = [
|
children = [#xmlel{name = 'value', children = [
|
||||||
#xmlcdata{cdata = erlang:integer_to_list(N)}]}]} ||
|
#xmlcdata{cdata = erlang:integer_to_list(N)}]}]} ||
|
||||||
N <- lists:usort([ServiceMaxUsers, DefaultRoomMaxUsers, MaxUsersRoomInteger |
|
N <- lists:usort([ServiceMaxUsers, DefaultRoomMaxUsers, MaxUsersRoomInteger |
|
||||||
?MAX_USERS_DEFAULT_LIST]), N =< ServiceMaxUsers]},
|
?MAX_USERS_DEFAULT_LIST]), N =< ServiceMaxUsers]},
|
||||||
#xmlel{name = 'field', attrs = [
|
#xmlel{name = 'field', attrs = [
|
||||||
#xmlattr{name = 'type', value = "list-single"},
|
?XMLATTR('type', <<"list-single">>),
|
||||||
#xmlattr{name = 'label',
|
?XMLATTR('label',
|
||||||
value = translate:translate(Lang, "Present real Jabber IDs to")},
|
translate:translate(Lang, "Present real Jabber IDs to")),
|
||||||
#xmlattr{name = 'var', value = "muc#roomconfig_whois"}],
|
?XMLATTR('var', <<"muc#roomconfig_whois">>)],
|
||||||
children = [#xmlel{name = 'value',
|
children = [#xmlel{name = 'value',
|
||||||
children = [#xmlcdata{cdata =
|
children = [#xmlcdata{cdata =
|
||||||
if Config#config.anonymous -> <<"moderators">>;
|
if Config#config.anonymous -> <<"moderators">>;
|
||||||
true -> <<"anyone">>
|
true -> <<"anyone">>
|
||||||
end}]},
|
end}]},
|
||||||
#xmlel{name = 'option', attrs = [
|
#xmlel{name = 'option', attrs = [
|
||||||
#xmlattr{name = 'label', value =
|
?XMLATTR('label',
|
||||||
translate:translate(Lang, "moderators only")}],
|
translate:translate(Lang, "moderators only"))],
|
||||||
children = [#xmlel{name = 'value',
|
children = [#xmlel{name = 'value',
|
||||||
children = [#xmlcdata{cdata =
|
children = [#xmlcdata{cdata =
|
||||||
<<"moderators">>}]}]},
|
<<"moderators">>}]}]},
|
||||||
#xmlel{name = 'option', attrs = [
|
#xmlel{name = 'option', attrs = [
|
||||||
#xmlattr{name = 'label', value =
|
?XMLATTR('label',
|
||||||
translate:translate(Lang, "anyone")}],
|
translate:translate(Lang, "anyone"))],
|
||||||
children = [#xmlel{name = 'value',
|
children = [#xmlel{name = 'value',
|
||||||
children = [#xmlcdata{cdata =
|
children = [#xmlcdata{cdata =
|
||||||
<<"anyone">>}]}]}]},
|
<<"anyone">>}]}]}]},
|
||||||
@ -2851,7 +2850,7 @@ get_config(Lang, StateData, From) ->
|
|||||||
#xmlcdata{cdata = translate:translate(Lang,
|
#xmlcdata{cdata = translate:translate(Lang,
|
||||||
"You need an x:data capable client to configure room")}]},
|
"You need an x:data capable client to configure room")}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'x',
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'x',
|
||||||
attrs = [#xmlattr{name = 'type', value = "form"}],
|
attrs = [?XMLATTR('type', <<"form">>)],
|
||||||
children = Res}],
|
children = Res}],
|
||||||
StateData}.
|
StateData}.
|
||||||
|
|
||||||
@ -3072,12 +3071,12 @@ destroy_room(DEl, StateData) ->
|
|||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun({_LJID, Info}) ->
|
fun({_LJID, Info}) ->
|
||||||
Nick = Info#user.nick,
|
Nick = Info#user.nick,
|
||||||
ItemAttrs = [#xmlattr{name = 'affiliation', value = "none"},
|
ItemAttrs = [?XMLATTR('affiliation', <<"none">>),
|
||||||
#xmlattr{name = 'role', value = "none"}],
|
?XMLATTR('role', <<"none">>)],
|
||||||
Packet = #xmlel{ns = ?NS_JABBER_CLIENT,
|
Packet = #xmlel{ns = ?NS_JABBER_CLIENT,
|
||||||
name = 'presence',
|
name = 'presence',
|
||||||
attrs = [#xmlattr{name = 'type',
|
attrs = [?XMLATTR('type',
|
||||||
value = "unavailable"}],
|
<<"unavailable">>)],
|
||||||
children = [
|
children = [
|
||||||
#xmlel{ns = ?NS_MUC_USER, name = 'x', children =
|
#xmlel{ns = ?NS_MUC_USER, name = 'x', children =
|
||||||
[#xmlel{name = 'item', attrs = ItemAttrs},
|
[#xmlel{name = 'item', attrs = ItemAttrs},
|
||||||
@ -3102,7 +3101,7 @@ destroy_room(DEl, StateData) ->
|
|||||||
% Disco
|
% Disco
|
||||||
|
|
||||||
-define(FEATURE(Var), #xmlel{name = 'feature',
|
-define(FEATURE(Var), #xmlel{name = 'feature',
|
||||||
attrs = [#xmlattr{name = 'var', value = Var}]}).
|
attrs = [?XMLATTR('var', Var)]}).
|
||||||
|
|
||||||
-define(CONFIG_OPT_TO_FEATURE(Opt, Fiftrue, Fiffalse),
|
-define(CONFIG_OPT_TO_FEATURE(Opt, Fiftrue, Fiffalse),
|
||||||
case Opt of
|
case Opt of
|
||||||
@ -3118,13 +3117,13 @@ process_iq_disco_info(_From, set, _Lang, _StateData) ->
|
|||||||
process_iq_disco_info(_From, get, Lang, StateData) ->
|
process_iq_disco_info(_From, get, Lang, StateData) ->
|
||||||
Config = StateData#state.config,
|
Config = StateData#state.config,
|
||||||
{result, [ #xmlel{name = 'identity',
|
{result, [ #xmlel{name = 'identity',
|
||||||
attrs = [#xmlattr{name = 'category',
|
attrs = [?XMLATTR('category',
|
||||||
value = "conference"},
|
<<"conference">>),
|
||||||
#xmlattr{name = 'type', value = "text"},
|
?XMLATTR('type', <<"text">>),
|
||||||
#xmlattr{name = 'name',
|
?XMLATTR('name',
|
||||||
value = get_title(StateData)}]},
|
get_title(StateData))]},
|
||||||
#xmlel{name = 'feature',
|
#xmlel{name = 'feature',
|
||||||
attrs = [#xmlattr{name = 'var', value = ?NS_MUC_s}]},
|
attrs = [?XMLATTR('var', ?NS_MUC_s)]},
|
||||||
|
|
||||||
?CONFIG_OPT_TO_FEATURE(Config#config.public,
|
?CONFIG_OPT_TO_FEATURE(Config#config.public,
|
||||||
"muc_public", "muc_hidden"),
|
"muc_public", "muc_hidden"),
|
||||||
@ -3141,15 +3140,15 @@ process_iq_disco_info(_From, get, Lang, StateData) ->
|
|||||||
] ++ iq_disco_info_extras(Lang, StateData), StateData}.
|
] ++ iq_disco_info_extras(Lang, StateData), StateData}.
|
||||||
|
|
||||||
-define(RFIELDT(Type, Var, Val),
|
-define(RFIELDT(Type, Var, Val),
|
||||||
#xmlel{name = 'field', attrs = [#xmlattr{name = 'type', value = Type},
|
#xmlel{name = 'field', attrs = [?XMLATTR('type', Type),
|
||||||
#xmlattr{name = 'var', value = Var}],
|
?XMLATTR('var', Var)],
|
||||||
children = [#xmlel{name = 'value',
|
children = [#xmlel{name = 'value',
|
||||||
children = [#xmlcdata{cdata = Val}]}]}).
|
children = [#xmlcdata{cdata = Val}]}]}).
|
||||||
|
|
||||||
-define(RFIELD(Label, Var, Val),
|
-define(RFIELD(Label, Var, Val),
|
||||||
#xmlel{name = 'field', attrs = [#xmlattr{name = 'label', value =
|
#xmlel{name = 'field', attrs = [?XMLATTR('label',
|
||||||
translate:translate(Lang, Label)},
|
translate:translate(Lang, Label)),
|
||||||
#xmlattr{name = 'var', value = Var}],
|
?XMLATTR('var', Var)],
|
||||||
children = [#xmlel{name = 'value', children = [
|
children = [#xmlel{name = 'value', children = [
|
||||||
#xmlcdata{cdata = Val}]}]}).
|
#xmlcdata{cdata = Val}]}]}).
|
||||||
|
|
||||||
@ -3157,7 +3156,7 @@ iq_disco_info_extras(Lang, StateData) ->
|
|||||||
Len = length(?DICT:to_list(StateData#state.users)),
|
Len = length(?DICT:to_list(StateData#state.users)),
|
||||||
RoomDescription = (StateData#state.config)#config.description,
|
RoomDescription = (StateData#state.config)#config.description,
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'x',
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'x',
|
||||||
attrs = [#xmlattr{name = 'type', value = "result"}],
|
attrs = [?XMLATTR('type', <<"result">>)],
|
||||||
children =
|
children =
|
||||||
[?RFIELDT("hidden", "FORM_TYPE",
|
[?RFIELDT("hidden", "FORM_TYPE",
|
||||||
"http://jabber.org/protocol/muc#roominfo"),
|
"http://jabber.org/protocol/muc#roominfo"),
|
||||||
@ -3182,13 +3181,13 @@ process_iq_disco_items(From, get, _Lang, StateData) ->
|
|||||||
lists:map(
|
lists:map(
|
||||||
fun({_LJID, Info}) ->
|
fun({_LJID, Info}) ->
|
||||||
Nick = Info#user.nick,
|
Nick = Info#user.nick,
|
||||||
#xmlel{name = 'item', attrs = [#xmlattr{name = 'jid',
|
#xmlel{name = 'item', attrs = [?XMLATTR('jid',
|
||||||
value = exmpp_jid:jid_to_binary(
|
exmpp_jid:jid_to_binary(
|
||||||
StateData#state.room,
|
StateData#state.room,
|
||||||
StateData#state.host,
|
StateData#state.host,
|
||||||
Nick)},
|
Nick)),
|
||||||
#xmlattr{name = 'name',
|
?XMLATTR('name',
|
||||||
value = Nick}]}
|
Nick)]}
|
||||||
end,
|
end,
|
||||||
?DICT:to_list(StateData#state.users)),
|
?DICT:to_list(StateData#state.users)),
|
||||||
{result, UList, StateData};
|
{result, UList, StateData};
|
||||||
@ -3227,7 +3226,7 @@ check_invitation(From, Els, Lang, StateData) ->
|
|||||||
_ ->
|
_ ->
|
||||||
throw({error, 'bad-request'})
|
throw({error, 'bad-request'})
|
||||||
end,
|
end,
|
||||||
JID = try exmpp_jid:binary_to_jid(exmpp_xml:get_attribute_as_binary(InviteEl,
|
JID = try exmpp_jid:parse_jid(exmpp_xml:get_attribute_as_binary(InviteEl,
|
||||||
'to',
|
'to',
|
||||||
false)) of
|
false)) of
|
||||||
JID1 -> JID1
|
JID1 -> JID1
|
||||||
@ -3253,8 +3252,8 @@ check_invitation(From, Els, Lang, StateData) ->
|
|||||||
IEl =
|
IEl =
|
||||||
[#xmlel{ns = ?NS_MUC_USER,
|
[#xmlel{ns = ?NS_MUC_USER,
|
||||||
name = 'invite',
|
name = 'invite',
|
||||||
attrs = [#xmlattr{name = 'from',
|
attrs = [?XMLATTR('from',
|
||||||
value = exmpp_jid:jid_to_binary(From)}],
|
exmpp_jid:jid_to_binary(From))],
|
||||||
children = [#xmlel{ns =?NS_MUC_USER, name = 'reason',
|
children = [#xmlel{ns =?NS_MUC_USER, name = 'reason',
|
||||||
children = [#xmlcdata{cdata = Reason} ]}]
|
children = [#xmlcdata{cdata = Reason} ]}]
|
||||||
++ ContinueEl}],
|
++ ContinueEl}],
|
||||||
@ -3295,15 +3294,15 @@ check_invitation(From, Els, Lang, StateData) ->
|
|||||||
%%TODO: always NS_JABBER_CLIENT?
|
%%TODO: always NS_JABBER_CLIENT?
|
||||||
Msg =
|
Msg =
|
||||||
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'message',
|
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'message',
|
||||||
attrs = [#xmlattr{name = 'type', value = "normal"}],
|
attrs = [?XMLATTR('type', <<"normal">>)],
|
||||||
children = [#xmlel{ns = ?NS_MUC_USER, name = 'x',
|
children = [#xmlel{ns = ?NS_MUC_USER, name = 'x',
|
||||||
children = IEl ++ PasswdEl},
|
children = IEl ++ PasswdEl},
|
||||||
#xmlel{ns = 'jabber:x:conference', name = 'x',
|
#xmlel{ns = 'jabber:x:conference', name = 'x',
|
||||||
attrs = [#xmlattr{name = 'jid',
|
attrs = [?XMLATTR('jid',
|
||||||
value = exmpp_jid:jid_to_binary(
|
exmpp_jid:jid_to_binary(
|
||||||
StateData#state.room,
|
StateData#state.room,
|
||||||
StateData#state.host)
|
StateData#state.host)
|
||||||
}],
|
)],
|
||||||
children = [#xmlcdata{cdata = Reason}]},
|
children = [#xmlcdata{cdata = Reason}]},
|
||||||
Body]},
|
Body]},
|
||||||
ejabberd_router:route(StateData#state.jid, JID, Msg),
|
ejabberd_router:route(StateData#state.jid, JID, Msg),
|
||||||
@ -3330,7 +3329,7 @@ check_decline_invitation(Packet) ->
|
|||||||
#xmlel{ns = ?NS_MUC_USER} = XEl = exmpp_xml:get_element(Packet, 'x'),
|
#xmlel{ns = ?NS_MUC_USER} = XEl = exmpp_xml:get_element(Packet, 'x'),
|
||||||
DEl = exmpp_xml:get_element(XEl, 'decline'),
|
DEl = exmpp_xml:get_element(XEl, 'decline'),
|
||||||
ToString = exmpp_xml:get_attribute_as_binary(DEl, 'to', false),
|
ToString = exmpp_xml:get_attribute_as_binary(DEl, 'to', false),
|
||||||
ToJID = exmpp_jid:binary_to_jid(ToString),
|
ToJID = exmpp_jid:parse_jid(ToString),
|
||||||
{true, {Packet, XEl, DEl, ToJID}}.
|
{true, {Packet, XEl, DEl, ToJID}}.
|
||||||
|
|
||||||
%% Send the decline to the inviter user.
|
%% Send the decline to the inviter user.
|
||||||
|
@ -220,7 +220,7 @@ find_x_event([_ | Els]) ->
|
|||||||
find_x_expire(_, []) ->
|
find_x_expire(_, []) ->
|
||||||
never;
|
never;
|
||||||
find_x_expire(TimeStamp, [#xmlel{ns = ?NS_MESSAGE_EXPIRE} = El | _Els]) ->
|
find_x_expire(TimeStamp, [#xmlel{ns = ?NS_MESSAGE_EXPIRE} = El | _Els]) ->
|
||||||
Val = exmpp_xml:get_attribute(El, 'seconds', ""),
|
Val = exmpp_xml:get_attribute_as_list(El, 'seconds', ""),
|
||||||
case catch list_to_integer(Val) of
|
case catch list_to_integer(Val) of
|
||||||
{'EXIT', _} ->
|
{'EXIT', _} ->
|
||||||
never;
|
never;
|
||||||
|
@ -198,7 +198,7 @@ check_event(From, To, Packet) ->
|
|||||||
undefined ->
|
undefined ->
|
||||||
true;
|
true;
|
||||||
_ ->
|
_ ->
|
||||||
ID = case exmpp_xml:get_attribute(Packet, 'id', "") of
|
ID = case exmpp_xml:get_attribute_as_list(Packet, 'id', "") of
|
||||||
"" ->
|
"" ->
|
||||||
#xmlel{ns = ?NS_MESSAGE_EVENT, name = 'id'};
|
#xmlel{ns = ?NS_MESSAGE_EVENT, name = 'id'};
|
||||||
S ->
|
S ->
|
||||||
@ -226,7 +226,7 @@ find_x_event([_ | Els]) ->
|
|||||||
find_x_expire(_, []) ->
|
find_x_expire(_, []) ->
|
||||||
never;
|
never;
|
||||||
find_x_expire(TimeStamp, [#xmlel{ns = ?NS_MESSAGE_EXPIRE} = El | _Els]) ->
|
find_x_expire(TimeStamp, [#xmlel{ns = ?NS_MESSAGE_EXPIRE} = El | _Els]) ->
|
||||||
Val = exmpp_xml:get_attribute(El, 'seconds', ""),
|
Val = exmpp_xml:get_attribute_as_list(El, 'seconds', ""),
|
||||||
case catch list_to_integer(Val) of
|
case catch list_to_integer(Val) of
|
||||||
{'EXIT', _} ->
|
{'EXIT', _} ->
|
||||||
never;
|
never;
|
||||||
@ -257,9 +257,9 @@ pop_offline_messages(Ls, User, Server)
|
|||||||
[El] = exmpp_xml:parse_document(XML,
|
[El] = exmpp_xml:parse_document(XML,
|
||||||
[names_as_atom, {check_elems, xmpp},
|
[names_as_atom, {check_elems, xmpp},
|
||||||
{check_nss,xmpp}, {check_attrs,xmpp}]),
|
{check_nss,xmpp}, {check_attrs,xmpp}]),
|
||||||
To = exmpp_jid:binary_to_jid(
|
To = exmpp_jid:parse_jid(
|
||||||
exmpp_stanza:get_recipient(El)),
|
exmpp_stanza:get_recipient(El)),
|
||||||
From = exmpp_jid:binary_to_jid(
|
From = exmpp_jid:parse_jid(
|
||||||
exmpp_stanza:get_sender(El)),
|
exmpp_stanza:get_sender(El)),
|
||||||
[{route, From, To, El}]
|
[{route, From, To, El}]
|
||||||
catch
|
catch
|
||||||
|
@ -95,7 +95,7 @@ process_iq_get(_, From, _To, #iq{payload = SubEl},
|
|||||||
[#xmlel{name = Name} = Child] ->
|
[#xmlel{name = Name} = Child] ->
|
||||||
case Name of
|
case Name of
|
||||||
list ->
|
list ->
|
||||||
ListName = exmpp_xml:get_attribute(Child, name, false),
|
ListName = exmpp_xml:get_attribute_as_list(Child, name, false),
|
||||||
process_list_get(LUser, LServer, ListName);
|
process_list_get(LUser, LServer, ListName);
|
||||||
_ ->
|
_ ->
|
||||||
{error, 'bad-request'}
|
{error, 'bad-request'}
|
||||||
@ -161,14 +161,14 @@ process_list_get(LUser, LServer, Name) ->
|
|||||||
|
|
||||||
|
|
||||||
item_to_xml(Item) ->
|
item_to_xml(Item) ->
|
||||||
Attrs1 = [#xmlattr{name = 'action', value = action_to_binary(Item#listitem.action)},
|
Attrs1 = [?XMLATTR('action', action_to_binary(Item#listitem.action)),
|
||||||
#xmlattr{name = 'order', value = order_to_binary(Item#listitem.order)}],
|
?XMLATTR('order', order_to_binary(Item#listitem.order))],
|
||||||
Attrs2 = case Item#listitem.type of
|
Attrs2 = case Item#listitem.type of
|
||||||
none ->
|
none ->
|
||||||
Attrs1;
|
Attrs1;
|
||||||
Type ->
|
Type ->
|
||||||
[#xmlattr{name = 'type', value = type_to_binary(Item#listitem.type)},
|
[?XMLATTR('type', type_to_binary(Item#listitem.type)),
|
||||||
#xmlattr{name = 'value', value = value_to_binary(Type, Item#listitem.value)} |
|
?XMLATTR('value', value_to_binary(Type, Item#listitem.value)) |
|
||||||
Attrs1]
|
Attrs1]
|
||||||
end,
|
end,
|
||||||
SubEls = case Item#listitem.match_all of
|
SubEls = case Item#listitem.match_all of
|
||||||
@ -250,7 +250,7 @@ process_iq_set(_, From, _To, #iq{payload = SubEl}) ->
|
|||||||
LServer = exmpp_jid:ldomain_as_list(From),
|
LServer = exmpp_jid:ldomain_as_list(From),
|
||||||
case exmpp_xml:get_child_elements(SubEl) of
|
case exmpp_xml:get_child_elements(SubEl) of
|
||||||
[#xmlel{name = Name} = Child] ->
|
[#xmlel{name = Name} = Child] ->
|
||||||
ListName = exmpp_xml:get_attribute(Child, 'name', false),
|
ListName = exmpp_xml:get_attribute_as_list(Child, 'name', false),
|
||||||
case Name of
|
case Name of
|
||||||
list ->
|
list ->
|
||||||
process_list_set(LUser, LServer, ListName,
|
process_list_set(LUser, LServer, ListName,
|
||||||
@ -362,8 +362,8 @@ process_list_set(LUser, LServer, Name, Els) ->
|
|||||||
Error;
|
Error;
|
||||||
{atomic, {result, _} = Res} ->
|
{atomic, {result, _} = Res} ->
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
exmpp_jid:make_bare_jid(LUser, LServer),
|
exmpp_jid:make_jid(LUser, LServer),
|
||||||
exmpp_jid:make_bare_jid(LUser, LServer),
|
exmpp_jid:make_jid(LUser, LServer),
|
||||||
#xmlel{name = 'broadcast',
|
#xmlel{name = 'broadcast',
|
||||||
children=[{privacy_list,
|
children=[{privacy_list,
|
||||||
#userlist{name = Name, list = []},
|
#userlist{name = Name, list = []},
|
||||||
@ -393,8 +393,8 @@ process_list_set(LUser, LServer, Name, Els) ->
|
|||||||
Error;
|
Error;
|
||||||
{atomic, {result, _} = Res} ->
|
{atomic, {result, _} = Res} ->
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
exmpp_jid:make_bare_jid(LUser, LServer),
|
exmpp_jid:make_jid(LUser, LServer),
|
||||||
exmpp_jid:make_bare_jid(LUser, LServer),
|
exmpp_jid:make_jid(LUser, LServer),
|
||||||
#xmlel{name = 'broadcast',
|
#xmlel{name = 'broadcast',
|
||||||
children=[{privacy_list,
|
children=[{privacy_list,
|
||||||
#userlist{name = Name, list = List},
|
#userlist{name = Name, list = List},
|
||||||
@ -420,10 +420,10 @@ parse_items([], Res) ->
|
|||||||
%% record_info(fields, listitem))),
|
%% record_info(fields, listitem))),
|
||||||
lists:keysort(5, Res);
|
lists:keysort(5, Res);
|
||||||
parse_items([El = #xmlel{name = item} | Els], Res) ->
|
parse_items([El = #xmlel{name = item} | Els], Res) ->
|
||||||
Type = exmpp_xml:get_attribute(El, type, false),
|
Type = exmpp_xml:get_attribute_as_list(El, type, false),
|
||||||
Value = exmpp_xml:get_attribute(El, value, false),
|
Value = exmpp_xml:get_attribute_as_list(El, value, false),
|
||||||
SAction =exmpp_xml:get_attribute(El, action, false),
|
SAction =exmpp_xml:get_attribute_as_list(El, action, false),
|
||||||
SOrder = exmpp_xml:get_attribute(El, order, false),
|
SOrder = exmpp_xml:get_attribute_as_list(El, order, false),
|
||||||
Action = case catch list_to_action(SAction) of
|
Action = case catch list_to_action(SAction) of
|
||||||
{'EXIT', _} -> false;
|
{'EXIT', _} -> false;
|
||||||
Val -> Val
|
Val -> Val
|
||||||
@ -447,7 +447,7 @@ parse_items([El = #xmlel{name = item} | Els], Res) ->
|
|||||||
case T of
|
case T of
|
||||||
"jid" ->
|
"jid" ->
|
||||||
try
|
try
|
||||||
JID = exmpp_jid:list_to_jid(V),
|
JID = exmpp_jid:parse_jid(V),
|
||||||
I1#listitem{
|
I1#listitem{
|
||||||
type = jid,
|
type = jid,
|
||||||
value = jlib:short_prepd_jid(JID)}
|
value = jlib:short_prepd_jid(JID)}
|
||||||
|
@ -91,7 +91,7 @@ process_iq_get(_, From, _To, #iq{payload = SubEl},
|
|||||||
[#xmlel{name = Name} = Child] ->
|
[#xmlel{name = Name} = Child] ->
|
||||||
case Name of
|
case Name of
|
||||||
list ->
|
list ->
|
||||||
ListName = exmpp_xml:get_attribute(Child, name, false),
|
ListName = exmpp_xml:get_attribute_as_list(Child, name, false),
|
||||||
process_list_get(LUser, LServer, ListName);
|
process_list_get(LUser, LServer, ListName);
|
||||||
_ ->
|
_ ->
|
||||||
{error, 'bad-request'}
|
{error, 'bad-request'}
|
||||||
@ -167,14 +167,14 @@ process_list_get(LUser, LServer, Name) ->
|
|||||||
|
|
||||||
|
|
||||||
item_to_xml(Item) ->
|
item_to_xml(Item) ->
|
||||||
Attrs1 = [#xmlattr{name = 'action', value = action_to_binary(Item#listitem.action)},
|
Attrs1 = [?XMLATTR('action', action_to_binary(Item#listitem.action)),
|
||||||
#xmlattr{name = 'order', value = order_to_binary(Item#listitem.order)}],
|
?XMLATTR('order', order_to_binary(Item#listitem.order))],
|
||||||
Attrs2 = case Item#listitem.type of
|
Attrs2 = case Item#listitem.type of
|
||||||
none ->
|
none ->
|
||||||
Attrs1;
|
Attrs1;
|
||||||
Type ->
|
Type ->
|
||||||
[#xmlattr{name = 'type', value = type_to_binary(Item#listitem.type)},
|
[?XMLATTR('type', type_to_binary(Item#listitem.type)),
|
||||||
#xmlattr{name = 'value', value = value_to_binary(Type, Item#listitem.value)} |
|
?XMLATTR('value', value_to_binary(Type, Item#listitem.value)) |
|
||||||
Attrs1]
|
Attrs1]
|
||||||
end,
|
end,
|
||||||
SubEls = case Item#listitem.match_all of
|
SubEls = case Item#listitem.match_all of
|
||||||
@ -256,7 +256,7 @@ process_iq_set(_, From, _To, #iq{payload = SubEl}) ->
|
|||||||
LServer = exmpp_jid:ldomain_as_list(From),
|
LServer = exmpp_jid:ldomain_as_list(From),
|
||||||
case exmpp_xml:get_child_elements(SubEl) of
|
case exmpp_xml:get_child_elements(SubEl) of
|
||||||
[#xmlel{name = Name} = Child] ->
|
[#xmlel{name = Name} = Child] ->
|
||||||
ListName = exmpp_xml:get_attribute(Child, 'name', false),
|
ListName = exmpp_xml:get_attribute_as_list(Child, 'name', false),
|
||||||
case Name of
|
case Name of
|
||||||
list ->
|
list ->
|
||||||
process_list_set(LUser, LServer, ListName,
|
process_list_set(LUser, LServer, ListName,
|
||||||
@ -362,8 +362,8 @@ process_list_set(LUser, LServer, Name, Els) ->
|
|||||||
Error;
|
Error;
|
||||||
{atomic, {result, _} = Res} ->
|
{atomic, {result, _} = Res} ->
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
exmpp_jid:make_bare_jid(LUser, LServer),
|
exmpp_jid:make_jid(LUser, LServer),
|
||||||
exmpp_jid:make_bare_jid(LUser, LServer),
|
exmpp_jid:make_jid(LUser, LServer),
|
||||||
#xmlel{name = 'broadcast',
|
#xmlel{name = 'broadcast',
|
||||||
children=[{privacy_list,
|
children=[{privacy_list,
|
||||||
#userlist{name = Name, list = []},
|
#userlist{name = Name, list = []},
|
||||||
@ -394,8 +394,8 @@ process_list_set(LUser, LServer, Name, Els) ->
|
|||||||
Error;
|
Error;
|
||||||
{atomic, {result, _} = Res} ->
|
{atomic, {result, _} = Res} ->
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
exmpp_jid:make_bare_jid(LUser, LServer),
|
exmpp_jid:make_jid(LUser, LServer),
|
||||||
exmpp_jid:make_bare_jid(LUser, LServer),
|
exmpp_jid:make_jid(LUser, LServer),
|
||||||
#xmlel{name = 'broadcast',
|
#xmlel{name = 'broadcast',
|
||||||
children=[{privacy_list,
|
children=[{privacy_list,
|
||||||
#userlist{name = Name, list = List},
|
#userlist{name = Name, list = List},
|
||||||
@ -421,10 +421,10 @@ parse_items([], Res) ->
|
|||||||
%% record_info(fields, listitem))),
|
%% record_info(fields, listitem))),
|
||||||
lists:keysort(5, Res);
|
lists:keysort(5, Res);
|
||||||
parse_items([El = #xmlel{name = item} | Els], Res) ->
|
parse_items([El = #xmlel{name = item} | Els], Res) ->
|
||||||
Type = exmpp_xml:get_attribute(El, type, false),
|
Type = exmpp_xml:get_attribute_as_list(El, type, false),
|
||||||
Value = exmpp_xml:get_attribute(El, value, false),
|
Value = exmpp_xml:get_attribute_as_list(El, value, false),
|
||||||
SAction =exmpp_xml:get_attribute(El, action, false),
|
SAction =exmpp_xml:get_attribute_as_list(El, action, false),
|
||||||
SOrder = exmpp_xml:get_attribute(El, order, false),
|
SOrder = exmpp_xml:get_attribute_as_list(El, order, false),
|
||||||
Action = case catch list_to_action(SAction) of
|
Action = case catch list_to_action(SAction) of
|
||||||
{'EXIT', _} -> false;
|
{'EXIT', _} -> false;
|
||||||
Val -> Val
|
Val -> Val
|
||||||
@ -448,7 +448,7 @@ parse_items([El = #xmlel{name = item} | Els], Res) ->
|
|||||||
case T of
|
case T of
|
||||||
"jid" ->
|
"jid" ->
|
||||||
try
|
try
|
||||||
JID = exmpp_jid:list_to_jid(V),
|
JID = exmpp_jid:parse_jid(V),
|
||||||
I1#listitem{
|
I1#listitem{
|
||||||
type = jid,
|
type = jid,
|
||||||
value = jlib:short_prepd_jid(JID)}
|
value = jlib:short_prepd_jid(JID)}
|
||||||
@ -700,7 +700,7 @@ raw_to_item({SType, SValue, SAction, SOrder, SMatchAll, SMatchIQ,
|
|||||||
"n" ->
|
"n" ->
|
||||||
{none, none};
|
{none, none};
|
||||||
"j" ->
|
"j" ->
|
||||||
JID = exmpp_jid:list_to_jid(SValue),
|
JID = exmpp_jid:parse_jid(SValue),
|
||||||
{jid, jlib:short_prepd_jid(JID)};
|
{jid, jlib:short_prepd_jid(JID)};
|
||||||
"g" ->
|
"g" ->
|
||||||
{group, SValue};
|
{group, SValue};
|
||||||
|
@ -159,8 +159,8 @@ process_iq(InitiatorJID, #iq{type = set, payload = SubEl, ns = ?NS_BYTESTREAMS}
|
|||||||
case acl:match_rule(ServerHost, ACL, InitiatorJID) of
|
case acl:match_rule(ServerHost, ACL, InitiatorJID) of
|
||||||
allow ->
|
allow ->
|
||||||
ActivateEl = exmpp_xml:get_path(SubEl, [{element, 'activate'}]),
|
ActivateEl = exmpp_xml:get_path(SubEl, [{element, 'activate'}]),
|
||||||
SID = exmpp_xml:get_attribute(SubEl, 'sid', ""),
|
SID = exmpp_xml:get_attribute_as_list(SubEl, 'sid', ""),
|
||||||
case catch exmpp_jid:list_to_jid(exmpp_xml:get_cdata_as_string(ActivateEl)) of
|
case catch exmpp_jid:parse_jid(exmpp_xml:get_cdata_as_string(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:prepd_jid_to_list(TargetJID),
|
Target = exmpp_jid:prepd_jid_to_list(TargetJID),
|
||||||
@ -197,13 +197,13 @@ process_iq(_, _, _) ->
|
|||||||
%%% Auxiliary functions.
|
%%% Auxiliary functions.
|
||||||
%%%-------------------------
|
%%%-------------------------
|
||||||
-define(FEATURE(Feat), #xmlel{ns = ?NS_DISCO_INFO, name = 'feature',
|
-define(FEATURE(Feat), #xmlel{ns = ?NS_DISCO_INFO, name = 'feature',
|
||||||
attrs = [#xmlattr{name = 'var', value = Feat}]}).
|
attrs = [?XMLATTR('var', Feat)]}).
|
||||||
|
|
||||||
iq_disco_info(Lang, Name) ->
|
iq_disco_info(Lang, Name) ->
|
||||||
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
|
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
|
||||||
[#xmlattr{name = 'category', value = "proxy"},
|
[?XMLATTR('category', <<"proxy">>),
|
||||||
#xmlattr{name = 'type', value = "bytestreams"},
|
?XMLATTR('type', <<"bytestreams">>),
|
||||||
#xmlattr{name = 'name', value = translate:translate(Lang, Name)}]},
|
?XMLATTR('name', translate:translate(Lang, Name))]},
|
||||||
?FEATURE(?NS_DISCO_INFO_s),
|
?FEATURE(?NS_DISCO_INFO_s),
|
||||||
?FEATURE(?NS_VCARD_s),
|
?FEATURE(?NS_VCARD_s),
|
||||||
?FEATURE(?NS_BYTESTREAMS_s)].
|
?FEATURE(?NS_BYTESTREAMS_s)].
|
||||||
@ -227,7 +227,7 @@ parse_options(ServerHost, Opts) ->
|
|||||||
Addr -> Addr
|
Addr -> Addr
|
||||||
end,
|
end,
|
||||||
StrIP = inet_parse:ntoa(IP),
|
StrIP = inet_parse:ntoa(IP),
|
||||||
StreamAddr = [#xmlattr{name = 'jid', value = MyHost}, #xmlattr{name = 'host', value = StrIP}, #xmlattr{name = 'port', value = integer_to_list(Port)}],
|
StreamAddr = [?XMLATTR('jid', MyHost), ?XMLATTR('host', StrIP), ?XMLATTR('port', Port)],
|
||||||
#state{myhost = MyHost,
|
#state{myhost = MyHost,
|
||||||
serverhost = ServerHost,
|
serverhost = ServerHost,
|
||||||
name = Name,
|
name = Name,
|
||||||
|
@ -311,18 +311,18 @@ update_database(Host) ->
|
|||||||
|
|
||||||
identity(Host) ->
|
identity(Host) ->
|
||||||
Identity = case lists:member(?PEPNODE, plugins(Host)) of
|
Identity = case lists:member(?PEPNODE, plugins(Host)) of
|
||||||
true -> [#xmlattr{name = 'category', value = "pubsub"}, #xmlattr{name = 'type', value = "pep"}];
|
true -> [?XMLATTR('category', <<"pubsub">>), ?XMLATTR('type', <<"pep">>)];
|
||||||
false -> [#xmlattr{name = 'category', value = "pubsub"}, #xmlattr{name = 'type', value = "service"}]
|
false -> [?XMLATTR('category', <<"pubsub">>), ?XMLATTR('type', <<"service">>)]
|
||||||
end,
|
end,
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = Identity}.
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = Identity}.
|
||||||
|
|
||||||
disco_local_identity(Acc, _From, To, <<>>, _Lang) ->
|
disco_local_identity(Acc, _From, To, <<>>, _Lang) ->
|
||||||
Acc ++ [identity(To#jid.ldomain)];
|
Acc ++ [identity(exmpp_jid:ldomain_as_list(To))];
|
||||||
disco_local_identity(Acc, _From, _To, _Node, _Lang) ->
|
disco_local_identity(Acc, _From, _To, _Node, _Lang) ->
|
||||||
Acc.
|
Acc.
|
||||||
|
|
||||||
disco_local_features(Acc, _From, To, <<>>, _Lang) ->
|
disco_local_features(Acc, _From, To, <<>>, _Lang) ->
|
||||||
Host = To#jid.ldomain,
|
Host = exmpp_jid:ldomain_as_list(To),
|
||||||
Feats = case Acc of
|
Feats = case Acc of
|
||||||
{result, I} -> I;
|
{result, I} -> I;
|
||||||
_ -> []
|
_ -> []
|
||||||
@ -339,7 +339,7 @@ disco_local_items(Acc, _From, _To, _Node, _Lang) ->
|
|||||||
Acc.
|
Acc.
|
||||||
|
|
||||||
disco_sm_identity(Acc, _From, To, <<>>, _Lang) ->
|
disco_sm_identity(Acc, _From, To, <<>>, _Lang) ->
|
||||||
Acc ++ [identity(To#jid.ldomain)];
|
Acc ++ [identity(exmpp_jid:ldomain_as_list(To))];
|
||||||
disco_sm_identity(Acc, From, To, Node, _Lang) ->
|
disco_sm_identity(Acc, From, To, Node, _Lang) ->
|
||||||
LOwner = jlib:short_prepd_bare_jid(To),
|
LOwner = jlib:short_prepd_bare_jid(To),
|
||||||
Acc ++ case node_disco_identity(LOwner, From, Node) of
|
Acc ++ case node_disco_identity(LOwner, From, Node) of
|
||||||
@ -363,7 +363,7 @@ disco_sm_features(Acc, From, To, Node, _Lang) ->
|
|||||||
|
|
||||||
disco_sm_items(Acc, From, To, <<>>, _Lang) ->
|
disco_sm_items(Acc, From, To, <<>>, _Lang) ->
|
||||||
%% TODO, use iq_disco_items(Host, [], From)
|
%% TODO, use iq_disco_items(Host, [], From)
|
||||||
Host = To#jid.ldomain,
|
Host = exmpp_jid:ldomain_as_list(To),
|
||||||
LJID = jlib:short_prepd_bare_jid(To),
|
LJID = jlib:short_prepd_bare_jid(To),
|
||||||
case tree_action(Host, get_nodes, [Host, From]) of
|
case tree_action(Host, get_nodes, [Host, From]) of
|
||||||
[] ->
|
[] ->
|
||||||
@ -376,8 +376,8 @@ disco_sm_items(Acc, From, To, <<>>, _Lang) ->
|
|||||||
NodeItems = lists:map(
|
NodeItems = lists:map(
|
||||||
fun(Node) ->
|
fun(Node) ->
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_list(LJID)},
|
[?XMLATTR('jid', exmpp_jid:jid_to_binary(LJID)),
|
||||||
#xmlattr{name = 'node', value = node_to_string(Node)}]}
|
?XMLATTR('node', node_to_string(Node))]}
|
||||||
end, Nodes),
|
end, Nodes),
|
||||||
{result, NodeItems ++ Items}
|
{result, NodeItems ++ Items}
|
||||||
end;
|
end;
|
||||||
@ -385,7 +385,7 @@ disco_sm_items(Acc, From, To, <<>>, _Lang) ->
|
|||||||
disco_sm_items(Acc, From, To, NodeB, _Lang) ->
|
disco_sm_items(Acc, From, To, NodeB, _Lang) ->
|
||||||
Node = binary_to_list(NodeB),
|
Node = binary_to_list(NodeB),
|
||||||
%% TODO, use iq_disco_items(Host, Node, From)
|
%% TODO, use iq_disco_items(Host, Node, From)
|
||||||
Host = To#jid.ldomain,
|
Host = exmpp_jid:ldomain_as_list(To),
|
||||||
LJID = jlib:short_prepd_bare_jid(To),
|
LJID = jlib:short_prepd_bare_jid(To),
|
||||||
case get_items(Host, Node, From) of
|
case get_items(Host, Node, From) of
|
||||||
[] ->
|
[] ->
|
||||||
@ -401,8 +401,8 @@ disco_sm_items(Acc, From, To, NodeB, _Lang) ->
|
|||||||
%% "node" is forbidden by XEP-0060.
|
%% "node" is forbidden by XEP-0060.
|
||||||
{result, Name} = node_action(Host, Node, get_item_name, [Host, Node, Id]),
|
{result, Name} = node_action(Host, Node, get_item_name, [Host, Node, Id]),
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
|
||||||
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_list(LJID)},
|
[?XMLATTR('jid', exmpp_jid:jid_to_binary(LJID)),
|
||||||
#xmlattr{name = 'name', value = Name}]}
|
?XMLATTR('name', Name)]}
|
||||||
end, AllItems),
|
end, AllItems),
|
||||||
{result, NodeItems ++ Items}
|
{result, NodeItems ++ Items}
|
||||||
end.
|
end.
|
||||||
@ -522,7 +522,7 @@ handle_cast({presence, JID, Pid}, State) ->
|
|||||||
|
|
||||||
handle_cast({remove_user, LUser, LServer}, State) ->
|
handle_cast({remove_user, LUser, LServer}, State) ->
|
||||||
Host = State#state.host,
|
Host = State#state.host,
|
||||||
Owner = exmpp_jid:make_bare_jid(LUser, LServer),
|
Owner = exmpp_jid:make_jid(LUser, LServer),
|
||||||
%% remove user's subscriptions
|
%% remove user's subscriptions
|
||||||
lists:foreach(fun(Type) ->
|
lists:foreach(fun(Type) ->
|
||||||
{result, Subscriptions} = node_action(Type, get_entity_subscriptions, [Host, Owner]),
|
{result, Subscriptions} = node_action(Type, get_entity_subscriptions, [Host, Owner]),
|
||||||
@ -555,7 +555,7 @@ handle_info({route, From, To, Packet},
|
|||||||
#state{server_host = ServerHost,
|
#state{server_host = ServerHost,
|
||||||
access = Access,
|
access = Access,
|
||||||
plugins = Plugins} = State) ->
|
plugins = Plugins} = State) ->
|
||||||
case catch do_route(ServerHost, Access, Plugins, To#jid.ldomain, From, To, Packet) of
|
case catch do_route(ServerHost, Access, Plugins, exmpp_jid:ldomain_as_list(To), From, To, Packet) of
|
||||||
{'EXIT', Reason} -> ?ERROR_MSG("~p", [Reason]);
|
{'EXIT', Reason} -> ?ERROR_MSG("~p", [Reason]);
|
||||||
_ -> ok
|
_ -> ok
|
||||||
end,
|
end,
|
||||||
@ -608,15 +608,17 @@ code_change(_OldVsn, State, _Extra) ->
|
|||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
do_route(ServerHost, Access, Plugins, Host, From, To, Packet) ->
|
do_route(ServerHost, Access, Plugins, Host, From, To, Packet) ->
|
||||||
#xmlel{name = Name} = Packet,
|
#xmlel{name = Name} = Packet,
|
||||||
case To of
|
LNode = exmpp_jid:lnode(To),
|
||||||
#jid{lnode = undefined, lresource = undefined} ->
|
LRes = exmpp_jid:lresource(To),
|
||||||
|
case {LNode, LRes} of
|
||||||
|
{undefined, undefined} ->
|
||||||
case Name of
|
case Name of
|
||||||
'iq' ->
|
'iq' ->
|
||||||
case exmpp_iq:xmlel_to_iq(Packet) of
|
case exmpp_iq:xmlel_to_iq(Packet) of
|
||||||
#iq{type = get, ns = ?NS_DISCO_INFO,
|
#iq{type = get, ns = ?NS_DISCO_INFO,
|
||||||
payload = SubEl, lang = Lang} ->
|
payload = SubEl, lang = Lang} ->
|
||||||
QAttrs = SubEl#xmlel.attrs,
|
QAttrs = SubEl#xmlel.attrs,
|
||||||
Node = exmpp_xml:get_attribute_from_list(QAttrs,
|
Node = exmpp_xml:get_attribute_from_list_as_list(QAttrs,
|
||||||
'node', ""),
|
'node', ""),
|
||||||
Res = case iq_disco_info(Host, Node, From, Lang) of
|
Res = case iq_disco_info(Host, Node, From, Lang) of
|
||||||
{result, IQRes} ->
|
{result, IQRes} ->
|
||||||
@ -631,7 +633,7 @@ do_route(ServerHost, Access, Plugins, Host, From, To, Packet) ->
|
|||||||
#iq{type = get, ns = ?NS_DISCO_ITEMS,
|
#iq{type = get, ns = ?NS_DISCO_ITEMS,
|
||||||
payload = SubEl} ->
|
payload = SubEl} ->
|
||||||
QAttrs = SubEl#xmlel.attrs,
|
QAttrs = SubEl#xmlel.attrs,
|
||||||
Node = exmpp_xml:get_attribute_from_list(QAttrs,
|
Node = exmpp_xml:get_attribute_from_list_as_list(QAttrs,
|
||||||
'node', ""),
|
'node', ""),
|
||||||
Res = case iq_disco_items(Host, Node, From) of
|
Res = case iq_disco_items(Host, Node, From) of
|
||||||
{result, IQRes} ->
|
{result, IQRes} ->
|
||||||
@ -732,17 +734,17 @@ node_disco_info(Host, Node, From, Identity, Features) ->
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
lists:map(fun(T) ->
|
lists:map(fun(T) ->
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = [#xmlattr{name = 'category', value = "pubsub"},
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = [?XMLATTR('category', <<"pubsub">>),
|
||||||
#xmlattr{name = 'type', value = T}]}
|
?XMLATTR('type', T)]}
|
||||||
end, Types)
|
end, Types)
|
||||||
end,
|
end,
|
||||||
F = case Features of
|
F = case Features of
|
||||||
false ->
|
false ->
|
||||||
[];
|
[];
|
||||||
true ->
|
true ->
|
||||||
[#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [#xmlattr{name = 'var', value = ?NS_PUBSUB_s}]} |
|
[#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]} |
|
||||||
lists:map(fun(T) ->
|
lists:map(fun(T) ->
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [#xmlattr{name = 'var', value = ?NS_PUBSUB_s++"#"++T}]}
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s++"#"++T)]}
|
||||||
end, features(Type))]
|
end, features(Type))]
|
||||||
end,
|
end,
|
||||||
%% TODO: add meta-data info (spec section 5.4)
|
%% TODO: add meta-data info (spec section 5.4)
|
||||||
@ -756,15 +758,15 @@ iq_disco_info(Host, SNode, From, Lang) ->
|
|||||||
[] ->
|
[] ->
|
||||||
{result,
|
{result,
|
||||||
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
|
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
|
||||||
[#xmlattr{name = 'category', value = "pubsub"},
|
[?XMLATTR('category', "pubsub"),
|
||||||
#xmlattr{name = 'type', value = "service"},
|
?XMLATTR('type', "service"),
|
||||||
#xmlattr{name = 'name', value = translate:translate(Lang, "Publish-Subscribe")}]},
|
?XMLATTR('name', translate:translate(Lang, "Publish-Subscribe"))]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [#xmlattr{name = 'var', value = ?NS_DISCO_INFO_s}]},
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_DISCO_INFO_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [#xmlattr{name = 'var', value = ?NS_DISCO_ITEMS_s}]},
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_DISCO_ITEMS_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [#xmlattr{name = 'var', value = ?NS_PUBSUB_s}]},
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [#xmlattr{name = 'var', value = ?NS_VCARD_s}]}] ++
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_VCARD_s)]}] ++
|
||||||
lists:map(fun(Feature) ->
|
lists:map(fun(Feature) ->
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [#xmlattr{name = 'var', value = ?NS_PUBSUB_s++"#"++Feature}]}
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s++"#"++Feature)]}
|
||||||
end, features(Host, SNode))};
|
end, features(Host, SNode))};
|
||||||
_ ->
|
_ ->
|
||||||
node_disco_info(Host, Node, From)
|
node_disco_info(Host, Node, From)
|
||||||
@ -776,9 +778,9 @@ iq_disco_items(Host, [], From) ->
|
|||||||
SN = node_to_string(SubNode),
|
SN = node_to_string(SubNode),
|
||||||
RN = lists:last(SubNode),
|
RN = lists:last(SubNode),
|
||||||
%% remove name attribute
|
%% remove name attribute
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [#xmlattr{name = 'jid', value = Host},
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [?XMLATTR('jid', Host),
|
||||||
#xmlattr{name = 'node', value = SN},
|
?XMLATTR('node', SN),
|
||||||
#xmlattr{name = 'name', value = RN}]}
|
?XMLATTR('name', RN)]}
|
||||||
end, tree_action(Host, get_subnodes, [Host, [], From]))};
|
end, tree_action(Host, get_subnodes, [Host, [], From]))};
|
||||||
iq_disco_items(Host, Item, From) ->
|
iq_disco_items(Host, Item, From) ->
|
||||||
case string:tokens(Item, "!") of
|
case string:tokens(Item, "!") of
|
||||||
@ -800,15 +802,15 @@ iq_disco_items(Host, Item, From) ->
|
|||||||
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
||||||
SN = node_to_string(SubNode),
|
SN = node_to_string(SubNode),
|
||||||
RN = lists:last(SubNode),
|
RN = lists:last(SubNode),
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [#xmlattr{name = 'jid', value = Host}, #xmlattr{name = 'node', value = SN},
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [?XMLATTR('jid', Host), ?XMLATTR('node', SN),
|
||||||
#xmlattr{name = 'name', value = RN}]}
|
?XMLATTR('name', RN)]}
|
||||||
end, tree_call(Host, get_subnodes, [Host, Node, From])),
|
end, tree_call(Host, get_subnodes, [Host, Node, From])),
|
||||||
Items = lists:map(
|
Items = lists:map(
|
||||||
fun(#pubsub_item{itemid = {RN, _}}) ->
|
fun(#pubsub_item{itemid = {RN, _}}) ->
|
||||||
SN = node_to_string(Node) ++ "!" ++ RN,
|
SN = node_to_string(Node) ++ "!" ++ RN,
|
||||||
{result, Name} = node_call(Type, get_item_name, [Host, Node, RN]),
|
{result, Name} = node_call(Type, get_item_name, [Host, Node, RN]),
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [#xmlattr{name = 'jid', value = Host}, #xmlattr{name = 'node', value = SN},
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [?XMLATTR('jid', Host), ?XMLATTR('node', SN),
|
||||||
#xmlattr{name = 'name', value = Name}]}
|
?XMLATTR('name', Name)]}
|
||||||
end, NodeItems),
|
end, NodeItems),
|
||||||
{result, Nodes ++ Items}
|
{result, Nodes ++ Items}
|
||||||
end,
|
end,
|
||||||
@ -819,10 +821,11 @@ iq_local(From, To, #iq{type = Type,
|
|||||||
payload = SubEl,
|
payload = SubEl,
|
||||||
ns = XMLNS,
|
ns = XMLNS,
|
||||||
lang = Lang} = IQ_Rec) ->
|
lang = Lang} = IQ_Rec) ->
|
||||||
ServerHost = To#jid.ldomain,
|
ServerHost = exmpp_jid:ldomain_as_list(To),
|
||||||
|
FromHost = exmpp_jid:ldomain_as_list(To),
|
||||||
%% Accept IQs to server only from our own users.
|
%% Accept IQs to server only from our own users.
|
||||||
if
|
if
|
||||||
From#jid.ldomain /= ServerHost ->
|
FromHost /= ServerHost ->
|
||||||
exmpp_iq:error(IQ_Rec, 'forbidden');
|
exmpp_iq:error(IQ_Rec, 'forbidden');
|
||||||
true ->
|
true ->
|
||||||
LOwner = jlib:short_prepd_bare_jid(From),
|
LOwner = jlib:short_prepd_bare_jid(From),
|
||||||
@ -838,7 +841,7 @@ iq_local(From, To, #iq{type = Type,
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
iq_sm(From, To, #iq{type = Type, payload = SubEl, ns = XMLNS, lang = Lang} = IQ_Rec) ->
|
iq_sm(From, To, #iq{type = Type, payload = SubEl, ns = XMLNS, lang = Lang} = IQ_Rec) ->
|
||||||
ServerHost = To#jid.ldomain,
|
ServerHost = exmpp_jid:ldomain_as_list(To),
|
||||||
LOwner = jlib:short_prepd_bare_jid(To),
|
LOwner = jlib:short_prepd_bare_jid(To),
|
||||||
Res = case XMLNS of
|
Res = case XMLNS of
|
||||||
?NS_PUBSUB -> iq_pubsub(LOwner, ServerHost, From, Type, SubEl, Lang);
|
?NS_PUBSUB -> iq_pubsub(LOwner, ServerHost, From, Type, SubEl, Lang);
|
||||||
@ -871,15 +874,15 @@ iq_pubsub(Host, ServerHost, From, IQType, SubEl, _Lang, Access, Plugins) ->
|
|||||||
case Action of
|
case Action of
|
||||||
[#xmlel{name = Name, attrs = Attrs, children = Els}] ->
|
[#xmlel{name = Name, attrs = Attrs, children = Els}] ->
|
||||||
Node = case Host of
|
Node = case Host of
|
||||||
{_, _, _} -> exmpp_xml:get_attribute_from_list(Attrs, 'node', false);
|
{_, _, _} -> exmpp_xml:get_attribute_from_list_as_list(Attrs, 'node', false);
|
||||||
_ -> string_to_node(exmpp_xml:get_attribute_from_list(Attrs, 'node', false))
|
_ -> string_to_node(exmpp_xml:get_attribute_from_list_as_list(Attrs, 'node', false))
|
||||||
end,
|
end,
|
||||||
case {IQType, Name} of
|
case {IQType, Name} of
|
||||||
{set, 'create'} ->
|
{set, 'create'} ->
|
||||||
case Configuration of
|
case Configuration of
|
||||||
[#xmlel{name = 'configure', children = Config}] ->
|
[#xmlel{name = 'configure', children = Config}] ->
|
||||||
%% Get the type of the node
|
%% Get the type of the node
|
||||||
Type = case exmpp_xml:get_attribute_from_list(Attrs, 'type', "") of
|
Type = case exmpp_xml:get_attribute_from_list_as_list(Attrs, 'type', "") of
|
||||||
[] -> hd(Plugins);
|
[] -> hd(Plugins);
|
||||||
T -> T
|
T -> T
|
||||||
end,
|
end,
|
||||||
@ -904,7 +907,7 @@ iq_pubsub(Host, ServerHost, From, IQType, SubEl, _Lang, Access, Plugins) ->
|
|||||||
{set, 'publish'} ->
|
{set, 'publish'} ->
|
||||||
case exmpp_xml:remove_cdata_from_list(Els) of
|
case exmpp_xml:remove_cdata_from_list(Els) of
|
||||||
[#xmlel{name = 'item', attrs = ItemAttrs, children = Payload}] ->
|
[#xmlel{name = 'item', attrs = ItemAttrs, children = Payload}] ->
|
||||||
ItemId = exmpp_xml:get_attribute_from_list(ItemAttrs, 'id', ""),
|
ItemId = exmpp_xml:get_attribute_from_list_as_list(ItemAttrs, 'id', ""),
|
||||||
publish_item(Host, ServerHost, Node, From, ItemId, Payload);
|
publish_item(Host, ServerHost, Node, From, ItemId, Payload);
|
||||||
[] ->
|
[] ->
|
||||||
%% Publisher attempts to publish to persistent node with no item
|
%% Publisher attempts to publish to persistent node with no item
|
||||||
@ -916,14 +919,14 @@ iq_pubsub(Host, ServerHost, From, IQType, SubEl, _Lang, Access, Plugins) ->
|
|||||||
"invalid-payload")}
|
"invalid-payload")}
|
||||||
end;
|
end;
|
||||||
{set, 'retract'} ->
|
{set, 'retract'} ->
|
||||||
ForceNotify = case exmpp_xml:get_attribute_from_list(Attrs, 'notify', "") of
|
ForceNotify = case exmpp_xml:get_attribute_from_list_as_list(Attrs, 'notify', "") of
|
||||||
"1" -> true;
|
"1" -> true;
|
||||||
"true" -> true;
|
"true" -> true;
|
||||||
_ -> false
|
_ -> false
|
||||||
end,
|
end,
|
||||||
case exmpp_xml:remove_cdata_from_list(Els) of
|
case exmpp_xml:remove_cdata_from_list(Els) of
|
||||||
[#xmlel{name = 'item', attrs = ItemAttrs}] ->
|
[#xmlel{name = 'item', attrs = ItemAttrs}] ->
|
||||||
ItemId = exmpp_xml:get_attribute_from_list(ItemAttrs, 'id', ""),
|
ItemId = exmpp_xml:get_attribute_from_list_as_list(ItemAttrs, 'id', ""),
|
||||||
delete_item(Host, Node, From, ItemId, ForceNotify);
|
delete_item(Host, Node, From, ItemId, ForceNotify);
|
||||||
_ ->
|
_ ->
|
||||||
%% Request does not specify an item
|
%% Request does not specify an item
|
||||||
@ -931,18 +934,18 @@ iq_pubsub(Host, ServerHost, From, IQType, SubEl, _Lang, Access, Plugins) ->
|
|||||||
"item-required")}
|
"item-required")}
|
||||||
end;
|
end;
|
||||||
{set, 'subscribe'} ->
|
{set, 'subscribe'} ->
|
||||||
JID = exmpp_xml:get_attribute_from_list(Attrs, 'jid', ""),
|
JID = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'jid', ""),
|
||||||
subscribe_node(Host, Node, From, JID);
|
subscribe_node(Host, Node, From, JID);
|
||||||
{set, 'unsubscribe'} ->
|
{set, 'unsubscribe'} ->
|
||||||
JID = exmpp_xml:get_attribute_from_list(Attrs, 'jid', ""),
|
JID = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'jid', ""),
|
||||||
SubId = exmpp_xml:get_attribute_from_list(Attrs, 'subid', ""),
|
SubId = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'subid', ""),
|
||||||
unsubscribe_node(Host, Node, From, JID, SubId);
|
unsubscribe_node(Host, Node, From, JID, SubId);
|
||||||
{get, 'items'} ->
|
{get, 'items'} ->
|
||||||
MaxItems = exmpp_xml:get_attribute_from_list(Attrs, 'max_items', ""),
|
MaxItems = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'max_items', ""),
|
||||||
SubId = exmpp_xml:get_attribute_from_list(Attrs, 'subid', ""),
|
SubId = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'subid', ""),
|
||||||
ItemIDs = lists:foldl(fun
|
ItemIDs = lists:foldl(fun
|
||||||
(#xmlel{name = 'item', attrs = ItemAttrs}, Acc) ->
|
(#xmlel{name = 'item', attrs = ItemAttrs}, Acc) ->
|
||||||
case exmpp_xml:get_attribute_from_list(ItemAttrs, 'id', "") of
|
case exmpp_xml:get_attribute_from_list_as_list(ItemAttrs, 'id', "") of
|
||||||
"" -> Acc;
|
"" -> Acc;
|
||||||
ItemID -> [ItemID|Acc]
|
ItemID -> [ItemID|Acc]
|
||||||
end;
|
end;
|
||||||
@ -972,8 +975,8 @@ iq_pubsub_owner(Host, From, IQType, SubEl, Lang) ->
|
|||||||
case Action of
|
case Action of
|
||||||
[#xmlel{name = Name, attrs = Attrs, children = Els}] ->
|
[#xmlel{name = Name, attrs = Attrs, children = Els}] ->
|
||||||
Node = case Host of
|
Node = case Host of
|
||||||
{_, _, _} -> exmpp_xml:get_attribute_from_list(Attrs, 'node', "");
|
{_, _, _} -> exmpp_xml:get_attribute_from_list_as_list(Attrs, 'node', "");
|
||||||
_ -> string_to_node(exmpp_xml:get_attribute_from_list(Attrs, 'node', ""))
|
_ -> string_to_node(exmpp_xml:get_attribute_from_list_as_list(Attrs, 'node', ""))
|
||||||
end,
|
end,
|
||||||
case {IQType, Name} of
|
case {IQType, Name} of
|
||||||
{get, 'configure'} ->
|
{get, 'configure'} ->
|
||||||
@ -1008,28 +1011,28 @@ send_authorization_request(Host, Node, Subscriber) ->
|
|||||||
Lang = "en", %% TODO fix
|
Lang = "en", %% TODO fix
|
||||||
{U, S, R} = Subscriber,
|
{U, S, R} = Subscriber,
|
||||||
Stanza = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', children =
|
Stanza = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [#xmlattr{name = 'type', value = "form"}], children =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR('type', <<"form">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "PubSub subscriber request"))}]},
|
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "PubSub subscriber request"))}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'instructions', children =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'instructions', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "Choose whether to approve this entity's subscription."))}]},
|
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "Choose whether to approve this entity's subscription."))}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'var', value = "FORM_TYPE"}, #xmlattr{name = 'type', value = "hidden"}], children =
|
[?XMLATTR('var', <<"FORM_TYPE">>), ?XMLATTR('type', <<"hidden">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(?NS_PUBSUB_SUBSCRIBE_AUTH_s)}]}]},
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(?NS_PUBSUB_SUBSCRIBE_AUTH_s)}]}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'var', value = "pubsub#node"}, #xmlattr{name = 'type', value = "text-single"},
|
[?XMLATTR('var', <<"pubsub#node">>), ?XMLATTR('type', <<"text-single">>),
|
||||||
#xmlattr{name = 'label', value = translate:translate(Lang, "Node ID")}], children =
|
?XMLATTR('label', translate:translate(Lang, "Node ID"))], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
|
||||||
[#xmlcdata{cdata = node_to_string(Node)}]}]},
|
[#xmlcdata{cdata = node_to_string(Node)}]}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [#xmlattr{name = 'var', value = "pubsub#subscriber_jid"},
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('var', <<"pubsub#subscriber_jid">>),
|
||||||
#xmlattr{name = 'type', value = "jid-single"},
|
?XMLATTR('type', <<"jid-single">>),
|
||||||
#xmlattr{name = 'label', value = translate:translate(Lang, "Subscriber Address")}], children =
|
?XMLATTR('label', translate:translate(Lang, "Subscriber Address"))], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
|
||||||
[#xmlcdata{cdata = exmpp_jid:jid_to_binary(U, S, R)}]}]},
|
[#xmlcdata{cdata = exmpp_jid:jid_to_binary(U, S, R)}]}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'var', value = "pubsub#allow"},
|
[?XMLATTR('var', <<"pubsub#allow">>),
|
||||||
#xmlattr{name = 'type', value = "boolean"},
|
?XMLATTR('type', <<"boolean">>),
|
||||||
#xmlattr{name = 'label', value = translate:translate(Lang, "Allow this Jabber ID to subscribe to this pubsub node?")}], children =
|
?XMLATTR('label', translate:translate(Lang, "Allow this Jabber ID to subscribe to this pubsub node?"))], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"false">>}]}]}]}]},
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"false">>}]}]}]}]},
|
||||||
case tree_action(Host, get_node, [Host, Node, Subscriber]) of
|
case tree_action(Host, get_node, [Host, Node, Subscriber]) of
|
||||||
#pubsub_node{owners = Owners} ->
|
#pubsub_node{owners = Owners} ->
|
||||||
@ -1045,7 +1048,7 @@ send_authorization_request(Host, Node, Subscriber) ->
|
|||||||
find_authorization_response(Packet) ->
|
find_authorization_response(Packet) ->
|
||||||
Els = Packet#xmlel.children,
|
Els = Packet#xmlel.children,
|
||||||
XData1 = lists:map(fun(#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = XAttrs} = XEl) ->
|
XData1 = lists:map(fun(#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = XAttrs} = XEl) ->
|
||||||
case exmpp_xml:get_attribute_from_list(XAttrs, 'type', "") of
|
case exmpp_xml:get_attribute_from_list_as_list(XAttrs, 'type', "") of
|
||||||
"cancel" ->
|
"cancel" ->
|
||||||
none;
|
none;
|
||||||
_ ->
|
_ ->
|
||||||
@ -1077,9 +1080,9 @@ find_authorization_response(Packet) ->
|
|||||||
send_authorization_approval(Host, JID, Node, Subscription) ->
|
send_authorization_approval(Host, JID, Node, Subscription) ->
|
||||||
Stanza = event_stanza(
|
Stanza = event_stanza(
|
||||||
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'subscription', attrs =
|
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'subscription', attrs =
|
||||||
[#xmlattr{name = 'node', value = Node},
|
[?XMLATTR('node', Node),
|
||||||
#xmlattr{name = 'jid', value = exmpp_jid:jid_to_list(JID)},
|
?XMLATTR('jid', exmpp_jid:jid_to_binary(JID)),
|
||||||
#xmlattr{name = 'subscription', value = subscription_to_string(Subscription)}]}]),
|
?XMLATTR('subscription', subscription_to_string(Subscription))]}]),
|
||||||
ejabberd_router ! {route, service_jid(Host), JID, Stanza}.
|
ejabberd_router ! {route, service_jid(Host), JID, Stanza}.
|
||||||
|
|
||||||
handle_authorization_response(Host, From, To, Packet, XFields) ->
|
handle_authorization_response(Host, From, To, Packet, XFields) ->
|
||||||
@ -1092,7 +1095,7 @@ handle_authorization_response(Host, From, To, Packet, XFields) ->
|
|||||||
{_, _, _} -> [SNode];
|
{_, _, _} -> [SNode];
|
||||||
_ -> string:tokens(SNode, "/")
|
_ -> string:tokens(SNode, "/")
|
||||||
end,
|
end,
|
||||||
Subscriber = exmpp_jid:list_to_jid(SSubscriber),
|
Subscriber = exmpp_jid:parse_jid(SSubscriber),
|
||||||
Allow = case SAllow of
|
Allow = case SAllow of
|
||||||
"1" -> true;
|
"1" -> true;
|
||||||
"true" -> true;
|
"true" -> true;
|
||||||
@ -1137,9 +1140,9 @@ handle_authorization_response(Host, From, To, Packet, XFields) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
-define(XFIELD(Type, Label, Var, Val),
|
-define(XFIELD(Type, Label, Var, Val),
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [#xmlattr{name = 'type', value = Type},
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', Type),
|
||||||
#xmlattr{name = 'label', value = translate:translate(Lang, Label)},
|
?XMLATTR('label', translate:translate(Lang, Label)),
|
||||||
#xmlattr{name = 'var', value = Var}], children =
|
?XMLATTR('var', Var)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Val)}]}]}).
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Val)}]}]}).
|
||||||
|
|
||||||
-define(BOOLXFIELD(Label, Var, Val),
|
-define(BOOLXFIELD(Label, Var, Val),
|
||||||
@ -1153,9 +1156,9 @@ handle_authorization_response(Host, From, To, Packet, XFields) ->
|
|||||||
?XFIELD("text-single", Label, Var, Val)).
|
?XFIELD("text-single", Label, Var, Val)).
|
||||||
|
|
||||||
-define(XFIELDOPT(Type, Label, Var, Val, Opts),
|
-define(XFIELDOPT(Type, Label, Var, Val, Opts),
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [#xmlattr{name = 'type', value = Type},
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', Type),
|
||||||
#xmlattr{name = 'label', value = translate:translate(Lang, Label)},
|
?XMLATTR('label', translate:translate(Lang, Label)),
|
||||||
#xmlattr{name = 'var', value = Var}], children =
|
?XMLATTR('var', Var)], children =
|
||||||
lists:map(fun(Opt) ->
|
lists:map(fun(Opt) ->
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'option', children =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'option', children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
|
||||||
@ -1202,7 +1205,7 @@ create_node(Host, ServerHost, [], Owner, Type, Access, Configuration) ->
|
|||||||
{result, []} ->
|
{result, []} ->
|
||||||
{result,
|
{result,
|
||||||
[#xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
[#xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||||
[#xmlel{ns = ?NS_PUBSUB, name = 'create', attrs = [#xmlattr{name = 'node', value = node_to_string(NewNode)}]}]}]};
|
[#xmlel{ns = ?NS_PUBSUB, name = 'create', attrs = [?XMLATTR('node', node_to_string(NewNode))]}]}]};
|
||||||
Error -> Error
|
Error -> Error
|
||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
@ -1254,7 +1257,7 @@ create_node(Host, ServerHost, Node, Owner, GivenType, Access, Configuration) ->
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
Reply = [#xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
Reply = [#xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||||
[#xmlel{ns = ?NS_PUBSUB, name = 'create', attrs = [#xmlattr{name = 'node', value = node_to_string(Node)}]}]}],
|
[#xmlel{ns = ?NS_PUBSUB, name = 'create', attrs = [?XMLATTR('node', node_to_string(Node))]}]}],
|
||||||
case transaction(CreateNode, transaction) of
|
case transaction(CreateNode, transaction) of
|
||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
%% in case we change transaction to sync_dirty...
|
%% in case we change transaction to sync_dirty...
|
||||||
@ -1359,7 +1362,7 @@ delete_node(Host, Node, Owner) ->
|
|||||||
%%</ul>
|
%%</ul>
|
||||||
subscribe_node(Host, Node, From, JID) ->
|
subscribe_node(Host, Node, From, JID) ->
|
||||||
Subscriber = try
|
Subscriber = try
|
||||||
jlib:short_prepd_jid(exmpp_jid:list_to_jid(JID))
|
jlib:short_prepd_jid(exmpp_jid:parse_jid(JID))
|
||||||
catch
|
catch
|
||||||
_:_ ->
|
_:_ ->
|
||||||
{undefined, undefined, undefined}
|
{undefined, undefined, undefined}
|
||||||
@ -1397,13 +1400,13 @@ subscribe_node(Host, Node, From, JID) ->
|
|||||||
Reply = fun(Subscription) ->
|
Reply = fun(Subscription) ->
|
||||||
%% TODO, this is subscription-notification, should depends on node features
|
%% TODO, this is subscription-notification, should depends on node features
|
||||||
Fields =
|
Fields =
|
||||||
[#xmlattr{name = 'node', value = node_to_string(Node)},
|
[?XMLATTR('node', node_to_string(Node)),
|
||||||
#xmlattr{name = 'jid', value = exmpp_jid:jid_to_list(Subscriber)},
|
?XMLATTR('jid', exmpp_jid:jid_to_binary(Subscriber)),
|
||||||
#xmlattr{name = 'subscription', value = subscription_to_string(Subscription)}],
|
?XMLATTR('subscription', subscription_to_string(Subscription))],
|
||||||
[#xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
[#xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||||
[#xmlel{ns = ?NS_PUBSUB, name = 'subscription', attrs =
|
[#xmlel{ns = ?NS_PUBSUB, name = 'subscription', attrs =
|
||||||
case Subscription of
|
case Subscription of
|
||||||
subscribed -> [#xmlattr{name = 'subid', value = SubId}|Fields];
|
subscribed -> [?XMLATTR('subid', SubId)|Fields];
|
||||||
_ -> Fields
|
_ -> Fields
|
||||||
end}]}]
|
end}]}]
|
||||||
end,
|
end,
|
||||||
@ -1447,7 +1450,7 @@ subscribe_node(Host, Node, From, JID) ->
|
|||||||
%%<li>The request specifies a subscription ID that is not valid or current.</li>
|
%%<li>The request specifies a subscription ID that is not valid or current.</li>
|
||||||
%%</ul>
|
%%</ul>
|
||||||
unsubscribe_node(Host, Node, From, JID, SubId) when is_list(JID) ->
|
unsubscribe_node(Host, Node, From, JID, SubId) when is_list(JID) ->
|
||||||
Subscriber = try jlib:short_prepd_jid(exmpp_jid:list_to_jid(JID))
|
Subscriber = try jlib:short_prepd_jid(exmpp_jid:parse_jid(JID))
|
||||||
catch
|
catch
|
||||||
_:_ ->
|
_:_ ->
|
||||||
{undefined, undefined, undefined}
|
{undefined, undefined, undefined}
|
||||||
@ -1725,12 +1728,12 @@ get_items(Host, Node, From, SubId, SMaxItems, ItemIDs) ->
|
|||||||
payload = Payload}) ->
|
payload = Payload}) ->
|
||||||
ItemAttrs = case ItemId of
|
ItemAttrs = case ItemId of
|
||||||
"" -> [];
|
"" -> [];
|
||||||
_ -> [#xmlattr{name = 'id', value = ItemId}]
|
_ -> [?XMLATTR('id', ItemId)]
|
||||||
end,
|
end,
|
||||||
#xmlel{ns = ?NS_PUBSUB, name = 'item', attrs = ItemAttrs, children = Payload}
|
#xmlel{ns = ?NS_PUBSUB, name = 'item', attrs = ItemAttrs, children = Payload}
|
||||||
end, lists:sublist(SendItems, MaxItems)),
|
end, lists:sublist(SendItems, MaxItems)),
|
||||||
{result, [#xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
{result, [#xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||||
[#xmlel{ns = ?NS_PUBSUB, name = 'items', attrs = [#xmlattr{name = 'node', value = node_to_string(Node)}], children =
|
[#xmlel{ns = ?NS_PUBSUB, name = 'items', attrs = [?XMLATTR('node', node_to_string(Node))], children =
|
||||||
ItemsEls}]}]}
|
ItemsEls}]}]}
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
@ -1785,12 +1788,12 @@ send_items(Host, Node, {LU, LS, LR} = LJID, Number) ->
|
|||||||
fun(#pubsub_item{itemid = {ItemId, _}, payload = Payload}) ->
|
fun(#pubsub_item{itemid = {ItemId, _}, payload = Payload}) ->
|
||||||
ItemAttrs = case ItemId of
|
ItemAttrs = case ItemId of
|
||||||
"" -> [];
|
"" -> [];
|
||||||
_ -> [#xmlattr{name = 'id', value = ItemId}]
|
_ -> [?XMLATTR('id', ItemId)]
|
||||||
end,
|
end,
|
||||||
#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'item', attrs = ItemAttrs, children = Payload}
|
#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'item', attrs = ItemAttrs, children = Payload}
|
||||||
end, ToSend),
|
end, ToSend),
|
||||||
Stanza = event_stanza(
|
Stanza = event_stanza(
|
||||||
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'items', attrs = [#xmlattr{name = 'node', value = node_to_string(Node)}], children =
|
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'items', attrs = [?XMLATTR('node', node_to_string(Node))], children =
|
||||||
ItemsEls}]),
|
ItemsEls}]),
|
||||||
ejabberd_router ! {route, service_jid(Host), exmpp_jid:make_jid(LU, LS, LR), Stanza}.
|
ejabberd_router ! {route, service_jid(Host), exmpp_jid:make_jid(LU, LS, LR), Stanza}.
|
||||||
|
|
||||||
@ -1821,8 +1824,8 @@ get_affiliations(Host, JID, Plugins) when is_list(Plugins) ->
|
|||||||
fun({_, none}) -> [];
|
fun({_, none}) -> [];
|
||||||
({Node, Affiliation}) ->
|
({Node, Affiliation}) ->
|
||||||
[#xmlel{ns = ?NS_PUBSUB, name = 'affiliation', attrs =
|
[#xmlel{ns = ?NS_PUBSUB, name = 'affiliation', attrs =
|
||||||
[#xmlattr{name = 'node', value = node_to_string(Node)},
|
[?XMLATTR('node', node_to_string(Node)),
|
||||||
#xmlattr{name = 'affiliation', value = affiliation_to_string(Affiliation)}]}]
|
?XMLATTR('affiliation', affiliation_to_string(Affiliation))]}]
|
||||||
end, lists:usort(lists:flatten(Affiliations))),
|
end, lists:usort(lists:flatten(Affiliations))),
|
||||||
{result, [#xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
{result, [#xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||||
[#xmlel{ns = ?NS_PUBSUB, name = 'affiliations', children =
|
[#xmlel{ns = ?NS_PUBSUB, name = 'affiliations', children =
|
||||||
@ -1856,11 +1859,11 @@ get_affiliations(Host, Node, JID) ->
|
|||||||
fun({_, none}) -> [];
|
fun({_, none}) -> [];
|
||||||
({{AU, AS, AR}, Affiliation}) ->
|
({{AU, AS, AR}, Affiliation}) ->
|
||||||
[#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'affiliation', attrs =
|
[#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'affiliation', attrs =
|
||||||
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_list(AU, AS, AR)},
|
[?XMLATTR('jid', exmpp_jid:jid_to_binary(AU, AS, AR)),
|
||||||
#xmlattr{name = 'affiliation', value = affiliation_to_string(Affiliation)}]}]
|
?XMLATTR('affiliation', affiliation_to_string(Affiliation))]}]
|
||||||
end, Affiliations),
|
end, Affiliations),
|
||||||
{result, [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'pubsub', children =
|
{result, [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'pubsub', children =
|
||||||
[#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'affiliations', attrs = [#xmlattr{name = 'node', value = node_to_string(Node)}], children =
|
[#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'affiliations', attrs = [?XMLATTR('node', node_to_string(Node))], children =
|
||||||
Entities}]}]}
|
Entities}]}]}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -1876,13 +1879,13 @@ set_affiliations(Host, Node, From, EntitiesEls) ->
|
|||||||
case El of
|
case El of
|
||||||
#xmlel{name = 'affiliation', attrs = Attrs} ->
|
#xmlel{name = 'affiliation', attrs = Attrs} ->
|
||||||
JID = try
|
JID = try
|
||||||
exmpp_jid:list_to_jid(
|
exmpp_jid:parse_jid(
|
||||||
exmpp_xml:get_attribute_from_list(Attrs, 'jid', ""))
|
exmpp_xml:get_attribute_from_list_as_list(Attrs, 'jid', ""))
|
||||||
catch
|
catch
|
||||||
_:_ -> error
|
_:_ -> error
|
||||||
end,
|
end,
|
||||||
Affiliation = string_to_affiliation(
|
Affiliation = string_to_affiliation(
|
||||||
exmpp_xml:get_attribute_from_list(Attrs, 'affiliation', false)),
|
exmpp_xml:get_attribute_from_list_as_list(Attrs, 'affiliation', false)),
|
||||||
if
|
if
|
||||||
(JID == error) or
|
(JID == error) or
|
||||||
(Affiliation == false) ->
|
(Affiliation == false) ->
|
||||||
@ -1958,14 +1961,14 @@ get_subscriptions(Host, JID, Plugins) when is_list(Plugins) ->
|
|||||||
fun({_, none}) -> [];
|
fun({_, none}) -> [];
|
||||||
({Node, Subscription}) ->
|
({Node, Subscription}) ->
|
||||||
[#xmlel{ns = ?NS_PUBSUB, name = 'subscription', attrs =
|
[#xmlel{ns = ?NS_PUBSUB, name = 'subscription', attrs =
|
||||||
[#xmlattr{name = 'node', value = node_to_string(Node)},
|
[?XMLATTR('node', node_to_string(Node)),
|
||||||
#xmlattr{name = 'subscription', value = subscription_to_string(Subscription)}]}];
|
?XMLATTR('subscription', subscription_to_string(Subscription))]}];
|
||||||
({_, none, _}) -> [];
|
({_, none, _}) -> [];
|
||||||
({Node, Subscription, SubJID}) ->
|
({Node, Subscription, SubJID}) ->
|
||||||
[#xmlel{ns = ?NS_PUBSUB, name = 'subscription', attrs =
|
[#xmlel{ns = ?NS_PUBSUB, name = 'subscription', attrs =
|
||||||
[#xmlattr{name = 'node', value = node_to_string(Node)},
|
[?XMLATTR('node', node_to_string(Node)),
|
||||||
#xmlattr{name = 'jid', value = exmpp_jid:jid_to_list(SubJID)},
|
?XMLATTR('jid', exmpp_jid:jid_to_binary(SubJID)),
|
||||||
#xmlattr{name = 'subscription', value = subscription_to_string(Subscription)}]}]
|
?XMLATTR('subscription', subscription_to_string(Subscription))]}]
|
||||||
end, lists:usort(lists:flatten(Subscriptions))),
|
end, lists:usort(lists:flatten(Subscriptions))),
|
||||||
{result, [#xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
{result, [#xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||||
[#xmlel{ns = ?NS_PUBSUB, name = 'subscriptions', children =
|
[#xmlel{ns = ?NS_PUBSUB, name = 'subscriptions', children =
|
||||||
@ -1999,16 +2002,16 @@ get_subscriptions(Host, Node, JID) ->
|
|||||||
fun({_, none}) -> [];
|
fun({_, none}) -> [];
|
||||||
({{AU, AS, AR}, Subscription}) ->
|
({{AU, AS, AR}, Subscription}) ->
|
||||||
[#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'subscription', attrs =
|
[#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'subscription', attrs =
|
||||||
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_list(AU, AS, AR)},
|
[?XMLATTR('jid', exmpp_jid:jid_to_binary(AU, AS, AR)),
|
||||||
#xmlattr{name = 'subscription', value = subscription_to_string(Subscription)}]}];
|
?XMLATTR('subscription', subscription_to_string(Subscription))]}];
|
||||||
({{AU, AS, AR}, Subscription, SubId}) ->
|
({{AU, AS, AR}, Subscription, SubId}) ->
|
||||||
[#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'subscription', attrs =
|
[#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'subscription', attrs =
|
||||||
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_list(AU, AS, AR)},
|
[?XMLATTR('jid', exmpp_jid:jid_to_binary(AU, AS, AR)),
|
||||||
#xmlattr{name = 'subscription', value = subscription_to_string(Subscription)},
|
?XMLATTR('subscription', subscription_to_string(Subscription)),
|
||||||
#xmlattr{name = 'subid', value =SubId}]}]
|
?XMLATTR('subid', SubId)]}]
|
||||||
end, Subscriptions),
|
end, Subscriptions),
|
||||||
{result, [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'pubsub', children =
|
{result, [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'pubsub', children =
|
||||||
[#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'subscriptions', attrs = [#xmlattr{name = 'node', value = node_to_string(Node)}], children =
|
[#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'subscriptions', attrs = [?XMLATTR('node', node_to_string(Node))], children =
|
||||||
Entities}]}]}
|
Entities}]}]}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -2024,14 +2027,14 @@ set_subscriptions(Host, Node, From, EntitiesEls) ->
|
|||||||
case El of
|
case El of
|
||||||
#xmlel{name = 'subscription', attrs = Attrs} ->
|
#xmlel{name = 'subscription', attrs = Attrs} ->
|
||||||
JID = try
|
JID = try
|
||||||
exmpp_jid:list_to_jid(
|
exmpp_jid:parse_jid(
|
||||||
exmpp_xml:get_attribute_from_list(Attrs, 'jid', ""))
|
exmpp_xml:get_attribute_from_list_as_list(Attrs, 'jid', ""))
|
||||||
catch
|
catch
|
||||||
_:_ ->
|
_:_ ->
|
||||||
error
|
error
|
||||||
end,
|
end,
|
||||||
Subscription = string_to_subscription(
|
Subscription = string_to_subscription(
|
||||||
exmpp_xml:get_attribute_from_list(Attrs, 'subscription', false)),
|
exmpp_xml:get_attribute_from_list_as_list(Attrs, 'subscription', false)),
|
||||||
if
|
if
|
||||||
(JID == error) or
|
(JID == error) or
|
||||||
(Subscription == false) ->
|
(Subscription == false) ->
|
||||||
@ -2137,8 +2140,8 @@ string_to_node(SNode) ->
|
|||||||
%% @doc <p>Generate pubsub service JID.</p>
|
%% @doc <p>Generate pubsub service JID.</p>
|
||||||
service_jid(Host) ->
|
service_jid(Host) ->
|
||||||
case Host of
|
case Host of
|
||||||
{U,S,_} -> #jid{node = U, domain = S, lnode = U, ldomain = S};
|
{U,S,_} -> exmpp_jid:make_jid(U, S);
|
||||||
_ -> #jid{domain = Host, ldomain = Host}
|
_ -> exmpp_jid:make_jid(Host)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @spec (LJID, Subscription, PresenceDelivery) -> boolean()
|
%% @spec (LJID, Subscription, PresenceDelivery) -> boolean()
|
||||||
@ -2188,10 +2191,10 @@ broadcast_publish_item(Host, Node, ItemId, _From, Payload) ->
|
|||||||
end,
|
end,
|
||||||
ItemAttrs = case ItemId of
|
ItemAttrs = case ItemId of
|
||||||
"" -> [];
|
"" -> [];
|
||||||
_ -> [#xmlattr{name = 'id', value = ItemId}]
|
_ -> [?XMLATTR('id', ItemId)]
|
||||||
end,
|
end,
|
||||||
Stanza = event_stanza(
|
Stanza = event_stanza(
|
||||||
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'items', attrs = [#xmlattr{name = 'node', value = node_to_string(Node)}], children =
|
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'items', attrs = [?XMLATTR('node', node_to_string(Node))], children =
|
||||||
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'item', attrs = ItemAttrs, children = Content}]}]),
|
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'item', attrs = ItemAttrs, children = Content}]}]),
|
||||||
broadcast_stanza(Host, Options, States, Stanza),
|
broadcast_stanza(Host, Options, States, Stanza),
|
||||||
broadcast_by_caps(Host, Node, Type, Stanza),
|
broadcast_by_caps(Host, Node, Type, Stanza),
|
||||||
@ -2217,12 +2220,12 @@ broadcast_retract_items(Host, Node, ItemIds, ForceNotify) ->
|
|||||||
fun(ItemId) ->
|
fun(ItemId) ->
|
||||||
ItemAttrs = case ItemId of
|
ItemAttrs = case ItemId of
|
||||||
"" -> [];
|
"" -> [];
|
||||||
_ -> [#xmlattr{name = 'id', value = ItemId}]
|
_ -> [?XMLATTR('id', ItemId)]
|
||||||
end,
|
end,
|
||||||
#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'retract', attrs = ItemAttrs}
|
#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'retract', attrs = ItemAttrs}
|
||||||
end, ItemIds),
|
end, ItemIds),
|
||||||
Stanza = event_stanza(
|
Stanza = event_stanza(
|
||||||
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'items', attrs = [#xmlattr{name = 'node', value = node_to_string(Node)}],
|
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'items', attrs = [?XMLATTR('node', node_to_string(Node))],
|
||||||
children = RetractEls}]),
|
children = RetractEls}]),
|
||||||
broadcast_stanza(Host, Options, States, Stanza),
|
broadcast_stanza(Host, Options, States, Stanza),
|
||||||
broadcast_by_caps(Host, Node, Type, Stanza),
|
broadcast_by_caps(Host, Node, Type, Stanza),
|
||||||
@ -2246,7 +2249,7 @@ broadcast_purge_node(Host, Node) ->
|
|||||||
{result, false};
|
{result, false};
|
||||||
{result, States} ->
|
{result, States} ->
|
||||||
Stanza = event_stanza(
|
Stanza = event_stanza(
|
||||||
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'purge', attrs = [#xmlattr{name = 'node', value = node_to_string(Node)}]}]),
|
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'purge', attrs = [?XMLATTR('node', node_to_string(Node))]}]),
|
||||||
broadcast_stanza(Host, Options, States, Stanza),
|
broadcast_stanza(Host, Options, States, Stanza),
|
||||||
broadcast_by_caps(Host, Node, Type, Stanza),
|
broadcast_by_caps(Host, Node, Type, Stanza),
|
||||||
{result, true};
|
{result, true};
|
||||||
@ -2269,7 +2272,7 @@ broadcast_removed_node(Host, Node) ->
|
|||||||
{result, false};
|
{result, false};
|
||||||
{result, States} ->
|
{result, States} ->
|
||||||
Stanza = event_stanza(
|
Stanza = event_stanza(
|
||||||
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'delete', attrs = [#xmlattr{name = 'node', value = node_to_string(Node)}]}]),
|
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'delete', attrs = [?XMLATTR('node', node_to_string(Node))]}]),
|
||||||
broadcast_stanza(Host, Options, States, Stanza),
|
broadcast_stanza(Host, Options, States, Stanza),
|
||||||
broadcast_by_caps(Host, Node, Type, Stanza),
|
broadcast_by_caps(Host, Node, Type, Stanza),
|
||||||
{result, true};
|
{result, true};
|
||||||
@ -2293,14 +2296,14 @@ broadcast_config_notification(Host, Node, Lang) ->
|
|||||||
{result, States} ->
|
{result, States} ->
|
||||||
Content = case get_option(Options, deliver_payloads) of
|
Content = case get_option(Options, deliver_payloads) of
|
||||||
true ->
|
true ->
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [#xmlattr{name = 'type', value = "form"}], children =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR('type', <<"form">>)], children =
|
||||||
get_configure_xfields(Type, Options, Lang, Owners)}];
|
get_configure_xfields(Type, Options, Lang, Owners)}];
|
||||||
false ->
|
false ->
|
||||||
[]
|
[]
|
||||||
end,
|
end,
|
||||||
Stanza = event_stanza(
|
Stanza = event_stanza(
|
||||||
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'items', attrs = [#xmlattr{name = 'node', value = node_to_string(Node)}], children =
|
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'items', attrs = [?XMLATTR('node', node_to_string(Node))], children =
|
||||||
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'item', attrs = [#xmlattr{name = 'id', value = "configuration"}], children =
|
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'item', attrs = [?XMLATTR('id', <<"configuration">>)], children =
|
||||||
Content}]}]),
|
Content}]}]),
|
||||||
broadcast_stanza(Host, Options, States, Stanza),
|
broadcast_stanza(Host, Options, States, Stanza),
|
||||||
broadcast_by_caps(Host, Node, Type, Stanza),
|
broadcast_by_caps(Host, Node, Type, Stanza),
|
||||||
@ -2404,9 +2407,9 @@ get_configure(Host, Node, From, Lang) ->
|
|||||||
{result,
|
{result,
|
||||||
[#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'pubsub', children =
|
[#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'pubsub', children =
|
||||||
[#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'configure', attrs =
|
[#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'configure', attrs =
|
||||||
[#xmlattr{name = 'node', value = node_to_string(Node)}], children =
|
[?XMLATTR('node', node_to_string(Node))], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs =
|
||||||
[#xmlattr{name = 'type', value = "form"}], children =
|
[?XMLATTR('type', <<"form">>)], children =
|
||||||
get_configure_xfields(Type, Options, Lang, Owners)
|
get_configure_xfields(Type, Options, Lang, Owners)
|
||||||
}]}]}]};
|
}]}]}]};
|
||||||
_ ->
|
_ ->
|
||||||
@ -2420,7 +2423,7 @@ get_default(Host, Node, _From, Lang) ->
|
|||||||
Options = node_options(Type),
|
Options = node_options(Type),
|
||||||
{result, [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'pubsub', children =
|
{result, [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'pubsub', children =
|
||||||
[#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'default', children =
|
[#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'default', children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [#xmlattr{name = 'type', value = "form"}], children =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR('type', <<"form">>)], children =
|
||||||
get_configure_xfields(Type, Options, Lang, [])
|
get_configure_xfields(Type, Options, Lang, [])
|
||||||
}]}]}]}.
|
}]}]}]}.
|
||||||
|
|
||||||
@ -2507,9 +2510,9 @@ get_configure_xfields(_Type, Options, Lang, _Owners) ->
|
|||||||
?ALIST_CONFIG_FIELD("Specify the access model", access_model,
|
?ALIST_CONFIG_FIELD("Specify the access model", access_model,
|
||||||
[open, authorize, presence, roster, whitelist]),
|
[open, authorize, presence, roster, whitelist]),
|
||||||
%% XXX: change to list-multi, include current roster groups as options
|
%% XXX: change to list-multi, include current roster groups as options
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [#xmlattr{name = 'type', value = "text-multi"},
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', <<"text-multi">>),
|
||||||
#xmlattr{name = 'label', value = translate:translate(Lang, "Roster groups allowed to subscribe")},
|
?XMLATTR('label', translate:translate(Lang, "Roster groups allowed to subscribe")),
|
||||||
#xmlattr{name = 'var', value = "pubsub#roster_groups_allowed"}], children =
|
?XMLATTR('var', <<"pubsub#roster_groups_allowed">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Value)}]} ||
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Value)}]} ||
|
||||||
Value <- get_option(Options, roster_groups_allowed, [])]},
|
Value <- get_option(Options, roster_groups_allowed, [])]},
|
||||||
?ALIST_CONFIG_FIELD("Specify the publisher model", publish_model,
|
?ALIST_CONFIG_FIELD("Specify the publisher model", publish_model,
|
||||||
@ -2531,7 +2534,7 @@ get_configure_xfields(_Type, Options, Lang, _Owners) ->
|
|||||||
set_configure(Host, Node, From, Els, Lang) ->
|
set_configure(Host, Node, From, Els, Lang) ->
|
||||||
case exmpp_xml:remove_cdata_from_list(Els) of
|
case exmpp_xml:remove_cdata_from_list(Els) of
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'x'} = XEl] ->
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'x'} = XEl] ->
|
||||||
case exmpp_xml:get_attribute(XEl, 'type', undefined) of
|
case exmpp_xml:get_attribute_as_list(XEl, 'type', undefined) of
|
||||||
"cancel" ->
|
"cancel" ->
|
||||||
{result, []};
|
{result, []};
|
||||||
"submit" ->
|
"submit" ->
|
||||||
@ -2660,9 +2663,8 @@ set_xoption([_ | Opts], NewOpts) ->
|
|||||||
|
|
||||||
%%%% plugin handling
|
%%%% plugin handling
|
||||||
|
|
||||||
plugins(Host) when is_binary(Host) ->
|
plugins(Host) ->
|
||||||
HostL = binary_to_list(Host),
|
case ets:lookup(gen_mod:get_module_proc(Host, pubsub_state), plugins) of
|
||||||
case ets:lookup(gen_mod:get_module_proc(HostL, pubsub_state), plugins) of
|
|
||||||
[{plugins, PL}] -> PL;
|
[{plugins, PL}] -> PL;
|
||||||
_ -> [?STDNODE]
|
_ -> [?STDNODE]
|
||||||
end.
|
end.
|
||||||
@ -2812,7 +2814,7 @@ extended_error(Error, Ext) ->
|
|||||||
extended_error(Error, Ext, []).
|
extended_error(Error, Ext, []).
|
||||||
extended_error(Error, unsupported, Feature) ->
|
extended_error(Error, unsupported, Feature) ->
|
||||||
extended_error(Error, unsupported,
|
extended_error(Error, unsupported,
|
||||||
[#xmlattr{name = 'feature', value = Feature}]);
|
[?XMLATTR('feature', Feature)]);
|
||||||
extended_error(Error, Ext, ExtAttrs) ->
|
extended_error(Error, Ext, ExtAttrs) ->
|
||||||
Pubsub_Err = #xmlel{ns = ?NS_PUBSUB_ERRORS, name = Ext, attrs = ExtAttrs},
|
Pubsub_Err = #xmlel{ns = ?NS_PUBSUB_ERRORS, name = Ext, attrs = ExtAttrs},
|
||||||
exmpp_xml:append_child(exmpp_stanza:error(?NS_JABBER_CLIENT, Error),
|
exmpp_xml:append_child(exmpp_stanza:error(?NS_JABBER_CLIENT, Error),
|
||||||
|
@ -76,7 +76,7 @@ unauthenticated_iq_register(_Acc,
|
|||||||
{A, _Port} -> A;
|
{A, _Port} -> A;
|
||||||
_ -> undefined
|
_ -> undefined
|
||||||
end,
|
end,
|
||||||
BareJID = exmpp_jid:make_bare_jid(Server),
|
BareJID = exmpp_jid:make_jid(Server),
|
||||||
ResIQ = process_iq(exmpp_jid:make_jid(),
|
ResIQ = process_iq(exmpp_jid:make_jid(),
|
||||||
BareJID,
|
BareJID,
|
||||||
IQ_Rec,
|
IQ_Rec,
|
||||||
@ -204,7 +204,7 @@ try_register(User, Server, Password, Source, Lang) ->
|
|||||||
false ->
|
false ->
|
||||||
{error, 'bad-request'};
|
{error, 'bad-request'};
|
||||||
_ ->
|
_ ->
|
||||||
JID = exmpp_jid:make_bare_jid(User,
|
JID = exmpp_jid:make_jid(User,
|
||||||
Server),
|
Server),
|
||||||
Access = gen_mod:get_module_opt(Server, ?MODULE, access, all),
|
Access = gen_mod:get_module_opt(Server, ?MODULE, access, all),
|
||||||
case acl:match_rule(Server, Access, JID) of
|
case acl:match_rule(Server, Access, JID) of
|
||||||
@ -247,7 +247,7 @@ send_welcome_message(JID) ->
|
|||||||
ok;
|
ok;
|
||||||
{Subj, Body} ->
|
{Subj, Body} ->
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
exmpp_jid:make_bare_jid(Host),
|
exmpp_jid:make_jid(Host),
|
||||||
JID,
|
JID,
|
||||||
exmpp_message:normal(Subj, Body));
|
exmpp_message:normal(Subj, Body));
|
||||||
_ ->
|
_ ->
|
||||||
@ -266,9 +266,9 @@ send_registration_notifications(UJID) ->
|
|||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(S) ->
|
fun(S) ->
|
||||||
try
|
try
|
||||||
JID = exmpp_jid:list_to_jid(S),
|
JID = exmpp_jid:parse_jid(S),
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
exmpp_jid:make_bare_jid(Host),
|
exmpp_jid:make_jid(Host),
|
||||||
JID,
|
JID,
|
||||||
exmpp_message:chat(Body))
|
exmpp_message:chat(Body))
|
||||||
catch
|
catch
|
||||||
|
@ -190,7 +190,7 @@ process_iq_set(From, To, #iq{payload = Request} = IQ_Rec) ->
|
|||||||
|
|
||||||
process_item_set(From, To, #xmlel{} = El) ->
|
process_item_set(From, To, #xmlel{} = El) ->
|
||||||
try
|
try
|
||||||
JID1 = exmpp_jid:binary_to_jid(exmpp_xml:get_attribute_as_binary(El, 'jid', <<>>)),
|
JID1 = exmpp_jid:parse_jid(exmpp_xml:get_attribute_as_binary(El, 'jid', <<>>)),
|
||||||
User = exmpp_jid:node(From),
|
User = exmpp_jid:node(From),
|
||||||
LUser = exmpp_jid:lnode(From),
|
LUser = exmpp_jid:lnode(From),
|
||||||
LServer = exmpp_jid:ldomain(From),
|
LServer = exmpp_jid:ldomain(From),
|
||||||
@ -311,7 +311,7 @@ process_item_els(Item, []) ->
|
|||||||
|
|
||||||
push_item(User, Server, From, Item) when is_binary(User), is_binary(Server) ->
|
push_item(User, Server, From, Item) when is_binary(User), is_binary(Server) ->
|
||||||
ejabberd_sm:route(exmpp_jid:make_jid(),
|
ejabberd_sm:route(exmpp_jid:make_jid(),
|
||||||
exmpp_jid:make_bare_jid(User, Server),
|
exmpp_jid:make_jid(User, Server),
|
||||||
#xmlel{name = 'broadcast', children =
|
#xmlel{name = 'broadcast', children =
|
||||||
[{item,
|
[{item,
|
||||||
Item#roster.jid,
|
Item#roster.jid,
|
||||||
@ -438,7 +438,7 @@ process_subscription(Direction, User, Server, JID1, Type, Reason)
|
|||||||
ok;
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
exmpp_jid:make_bare_jid(User, Server), JID1,
|
exmpp_jid:make_jid(User, Server), JID1,
|
||||||
exmpp_presence:AutoReply())
|
exmpp_presence:AutoReply())
|
||||||
end,
|
end,
|
||||||
case Push of
|
case Push of
|
||||||
@ -449,7 +449,7 @@ process_subscription(Direction, User, Server, JID1, Type, Reason)
|
|||||||
ok;
|
ok;
|
||||||
true ->
|
true ->
|
||||||
push_item(User, Server,
|
push_item(User, Server,
|
||||||
exmpp_jid:make_bare_jid(User, Server), Item)
|
exmpp_jid:make_jid(User, Server), Item)
|
||||||
end,
|
end,
|
||||||
true;
|
true;
|
||||||
none ->
|
none ->
|
||||||
@ -596,7 +596,7 @@ set_items(User, Server, #xmlel{children = Els}) ->
|
|||||||
|
|
||||||
process_item_set_t(LUser, LServer, #xmlel{} = El) ->
|
process_item_set_t(LUser, LServer, #xmlel{} = El) ->
|
||||||
try
|
try
|
||||||
JID1 = exmpp_jid:binary_to_jid(exmpp_xml:get_attribute(El, 'jid', <<>>)),
|
JID1 = exmpp_jid:parse_jid(exmpp_xml:get_attribute_as_list(El, 'jid', <<>>)),
|
||||||
JID = jlib:short_jid(JID1),
|
JID = jlib:short_jid(JID1),
|
||||||
LJID = jlib:short_prepd_jid(JID1),
|
LJID = jlib:short_prepd_jid(JID1),
|
||||||
Item = #roster{usj = {LUser, LServer, LJID},
|
Item = #roster{usj = {LUser, LServer, LJID},
|
||||||
@ -651,7 +651,7 @@ process_item_attrs_ws(Item, []) ->
|
|||||||
|
|
||||||
get_in_pending_subscriptions(Ls, User, Server)
|
get_in_pending_subscriptions(Ls, User, Server)
|
||||||
when is_binary(User), is_binary(Server) ->
|
when is_binary(User), is_binary(Server) ->
|
||||||
JID = exmpp_jid:make_bare_jid(User, Server),
|
JID = exmpp_jid:make_jid(User, Server),
|
||||||
US = {exmpp_jid:lnode(JID), exmpp_jid:ldomain(JID)},
|
US = {exmpp_jid:lnode(JID), exmpp_jid:ldomain(JID)},
|
||||||
case mnesia:dirty_index_read(roster, US, #roster.us) of
|
case mnesia:dirty_index_read(roster, US, #roster.us) of
|
||||||
Result when list(Result) ->
|
Result when list(Result) ->
|
||||||
@ -948,9 +948,9 @@ build_contact_jid_td({U, S, R}) ->
|
|||||||
end,
|
end,
|
||||||
case JIDURI of
|
case JIDURI of
|
||||||
[] ->
|
[] ->
|
||||||
?XAC('td', [#xmlattr{name = 'class', value = <<"valign">>}], exmpp_jid:jid_to_list(ContactJID));
|
?XAC('td', [?XMLATTR('class', <<"valign">>)], exmpp_jid:jid_to_list(ContactJID));
|
||||||
URI when is_list(URI) ->
|
URI when is_list(URI) ->
|
||||||
?XAE('td', [#xmlattr{name = 'class', value = <<"valign">>}], [?AC(JIDURI, exmpp_jid:jid_to_list(ContactJID))])
|
?XAE('td', [?XMLATTR('class', <<"valign">>)], [?AC(JIDURI, exmpp_jid:jid_to_list(ContactJID))])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
user_roster_parse_query(User, Server, Items, Query) ->
|
user_roster_parse_query(User, Server, Items, Query) ->
|
||||||
@ -961,7 +961,7 @@ user_roster_parse_query(User, Server, Items, Query) ->
|
|||||||
error;
|
error;
|
||||||
{value, {_, SJID}} ->
|
{value, {_, SJID}} ->
|
||||||
try
|
try
|
||||||
JID = exmpp_jid:list_to_jid(SJID),
|
JID = exmpp_jid:parse_jid(SJID),
|
||||||
user_roster_subscribe_jid(User, Server, JID),
|
user_roster_subscribe_jid(User, Server, JID),
|
||||||
ok
|
ok
|
||||||
catch
|
catch
|
||||||
@ -986,7 +986,7 @@ user_roster_parse_query(User, Server, Items, Query) ->
|
|||||||
|
|
||||||
user_roster_subscribe_jid(User, Server, JID) ->
|
user_roster_subscribe_jid(User, Server, JID) ->
|
||||||
out_subscription(User, Server, JID, subscribe),
|
out_subscription(User, Server, JID, subscribe),
|
||||||
UJID = exmpp_jid:make_bare_jid(User, Server),
|
UJID = exmpp_jid:make_jid(User, Server),
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
UJID, JID, exmpp_presence:subscribe()).
|
UJID, JID, exmpp_presence:subscribe()).
|
||||||
|
|
||||||
@ -1001,7 +1001,7 @@ user_roster_item_parse_query(User, Server, Items, Query) ->
|
|||||||
JID1 = exmpp_jid:make_jid(U, S, R),
|
JID1 = exmpp_jid:make_jid(U, S, R),
|
||||||
out_subscription(
|
out_subscription(
|
||||||
User, Server, JID1, subscribed),
|
User, Server, JID1, subscribed),
|
||||||
UJID = exmpp_jid:make_bare_jid(User, Server),
|
UJID = exmpp_jid:make_jid(User, Server),
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
UJID, JID1, exmpp_presence:subscribed()),
|
UJID, JID1, exmpp_presence:subscribed()),
|
||||||
throw(submitted);
|
throw(submitted);
|
||||||
@ -1009,7 +1009,7 @@ user_roster_item_parse_query(User, Server, Items, Query) ->
|
|||||||
case lists:keysearch(
|
case lists:keysearch(
|
||||||
"remove" ++ ejabberd_web_admin:term_to_id(JID), 1, Query) of
|
"remove" ++ ejabberd_web_admin:term_to_id(JID), 1, Query) of
|
||||||
{value, _} ->
|
{value, _} ->
|
||||||
UJID = exmpp_jid:make_bare_jid(User, Server),
|
UJID = exmpp_jid:make_jid(User, Server),
|
||||||
Attrs1 = exmpp_xml:set_attribute_in_list([],
|
Attrs1 = exmpp_xml:set_attribute_in_list([],
|
||||||
'jid', exmpp_jid:jid_to_list(JID)),
|
'jid', exmpp_jid:jid_to_list(JID)),
|
||||||
Attrs2 = exmpp_xml:set_attribute_in_list(Attrs1,
|
Attrs2 = exmpp_xml:set_attribute_in_list(Attrs1,
|
||||||
|
@ -216,7 +216,7 @@ process_iq_set(From, To, #iq{payload = Request} = IQ_Rec) ->
|
|||||||
|
|
||||||
process_item_set(From, To, #xmlel{} = El) ->
|
process_item_set(From, To, #xmlel{} = El) ->
|
||||||
try
|
try
|
||||||
JID1 = exmpp_jid:binary_to_jid(exmpp_xml:get_attribute_as_binary(El, 'jid', <<>>)),
|
JID1 = exmpp_jid:parse_jid(exmpp_xml:get_attribute_as_binary(El, 'jid', <<>>)),
|
||||||
LUser = exmpp_jid:lnode_as_list(From),
|
LUser = exmpp_jid:lnode_as_list(From),
|
||||||
LServer = exmpp_jid:ldomain_as_list(From),
|
LServer = exmpp_jid:ldomain_as_list(From),
|
||||||
{U0, S0, R0} = LJID = jlib:short_prepd_jid(JID1),
|
{U0, S0, R0} = LJID = jlib:short_prepd_jid(JID1),
|
||||||
@ -346,7 +346,7 @@ process_item_els(Item, []) ->
|
|||||||
|
|
||||||
push_item(User, Server, From, Item) when is_binary(User), is_binary(Server) ->
|
push_item(User, Server, From, Item) when is_binary(User), is_binary(Server) ->
|
||||||
ejabberd_sm:route(exmpp_jid:make_jid(),
|
ejabberd_sm:route(exmpp_jid:make_jid(),
|
||||||
exmpp_jid:make_bare_jid(User, Server),
|
exmpp_jid:make_jid(User, Server),
|
||||||
#xmlel{name = 'broadcast', children =
|
#xmlel{name = 'broadcast', children =
|
||||||
[{item,
|
[{item,
|
||||||
Item#roster.jid,
|
Item#roster.jid,
|
||||||
@ -503,7 +503,7 @@ process_subscription(Direction, User, Server, JID1, Type, Reason)
|
|||||||
ok;
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
exmpp_jid:make_bare_jid(User, Server), JID1,
|
exmpp_jid:make_jid(User, Server), JID1,
|
||||||
exmpp_presence:AutoReply())
|
exmpp_presence:AutoReply())
|
||||||
end,
|
end,
|
||||||
case Push of
|
case Push of
|
||||||
@ -514,7 +514,7 @@ process_subscription(Direction, User, Server, JID1, Type, Reason)
|
|||||||
ok;
|
ok;
|
||||||
true ->
|
true ->
|
||||||
push_item(User, Server,
|
push_item(User, Server,
|
||||||
exmpp_jid:make_bare_jid(User, Server), Item)
|
exmpp_jid:make_jid(User, Server), Item)
|
||||||
end,
|
end,
|
||||||
true;
|
true;
|
||||||
none ->
|
none ->
|
||||||
@ -650,7 +650,7 @@ set_items(User, Server, #xmlel{children = Els}) ->
|
|||||||
|
|
||||||
process_item_set_t(LUser, LServer, #xmlel{} = El) ->
|
process_item_set_t(LUser, LServer, #xmlel{} = El) ->
|
||||||
try
|
try
|
||||||
JID1 = exmpp_jid:binary_to_jid(exmpp_xml:get_attribute_as_binary(El, 'jid', <<>>)),
|
JID1 = exmpp_jid:parse_jid(exmpp_xml:get_attribute_as_binary(El, 'jid', <<>>)),
|
||||||
{U0, S0, R0} = LJID = jlib:short_prepd_jid(JID1),
|
{U0, S0, R0} = LJID = jlib:short_prepd_jid(JID1),
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_odbc:escape(LUser),
|
||||||
SJID = ejabberd_odbc:escape(exmpp_jid:jid_to_list(U0, S0, R0)),
|
SJID = ejabberd_odbc:escape(exmpp_jid:jid_to_list(U0, S0, R0)),
|
||||||
@ -708,7 +708,7 @@ process_item_attrs_ws(Item, []) ->
|
|||||||
|
|
||||||
get_in_pending_subscriptions(Ls, User, Server)
|
get_in_pending_subscriptions(Ls, User, Server)
|
||||||
when is_binary(User), is_binary(Server) ->
|
when is_binary(User), is_binary(Server) ->
|
||||||
JID = exmpp_jid:make_bare_jid(User, Server),
|
JID = exmpp_jid:make_jid(User, Server),
|
||||||
LUser = exmpp_jid:lnode_as_list(JID),
|
LUser = exmpp_jid:lnode_as_list(JID),
|
||||||
LServer = exmpp_jid:ldomain_as_list(JID),
|
LServer = exmpp_jid:ldomain_as_list(JID),
|
||||||
Username = ejabberd_odbc:escape(LUser),
|
Username = ejabberd_odbc:escape(LUser),
|
||||||
@ -809,7 +809,7 @@ get_jid_info(_, User, Server, JID) when is_binary(User), is_binary(Server) ->
|
|||||||
raw_to_record(LServer, {User, SJID, Nick, SSubscription, SAsk, SAskMessage,
|
raw_to_record(LServer, {User, SJID, Nick, SSubscription, SAsk, SAskMessage,
|
||||||
_SServer, _SSubscribe, _SType}) when is_binary(LServer) ->
|
_SServer, _SSubscribe, _SType}) when is_binary(LServer) ->
|
||||||
try
|
try
|
||||||
JID = exmpp_jid:list_to_jid(SJID),
|
JID = exmpp_jid:parse_jid(SJID),
|
||||||
LJID = jlib:short_prepd_jid(JID),
|
LJID = jlib:short_prepd_jid(JID),
|
||||||
Subscription = case SSubscription of
|
Subscription = case SSubscription of
|
||||||
"B" -> both;
|
"B" -> both;
|
||||||
@ -987,9 +987,9 @@ build_contact_jid_td({U, S, R}) ->
|
|||||||
end,
|
end,
|
||||||
case JIDURI of
|
case JIDURI of
|
||||||
[] ->
|
[] ->
|
||||||
?XAC('td', [#xmlattr{name = 'class', value = <<"valign">>}], exmpp_jid:jid_to_list(ContactJID));
|
?XAC('td', [?XMLATTR('class', <<"valign">>)], exmpp_jid:jid_to_list(ContactJID));
|
||||||
URI when is_list(URI) ->
|
URI when is_list(URI) ->
|
||||||
?XAE('td', [#xmlattr{name = 'class', value = <<"valign">>}], [?AC(JIDURI, exmpp_jid:jid_to_list(ContactJID))])
|
?XAE('td', [?XMLATTR('class', <<"valign">>)], [?AC(JIDURI, exmpp_jid:jid_to_list(ContactJID))])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
user_roster_parse_query(User, Server, Items, Query) ->
|
user_roster_parse_query(User, Server, Items, Query) ->
|
||||||
@ -1000,7 +1000,7 @@ user_roster_parse_query(User, Server, Items, Query) ->
|
|||||||
error;
|
error;
|
||||||
{value, {_, SJID}} ->
|
{value, {_, SJID}} ->
|
||||||
try
|
try
|
||||||
JID = exmpp_jid:list_to_jid(SJID),
|
JID = exmpp_jid:parse_jid(SJID),
|
||||||
user_roster_subscribe_jid(User, Server, JID),
|
user_roster_subscribe_jid(User, Server, JID),
|
||||||
ok
|
ok
|
||||||
catch
|
catch
|
||||||
@ -1025,7 +1025,7 @@ user_roster_parse_query(User, Server, Items, Query) ->
|
|||||||
|
|
||||||
user_roster_subscribe_jid(User, Server, JID) ->
|
user_roster_subscribe_jid(User, Server, JID) ->
|
||||||
out_subscription(User, Server, JID, subscribe),
|
out_subscription(User, Server, JID, subscribe),
|
||||||
UJID = exmpp_jid:make_bare_jid(User, Server),
|
UJID = exmpp_jid:make_jid(User, Server),
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
UJID, JID, exmpp_presence:subscribe()).
|
UJID, JID, exmpp_presence:subscribe()).
|
||||||
|
|
||||||
@ -1040,7 +1040,7 @@ user_roster_item_parse_query(User, Server, Items, Query) ->
|
|||||||
JID1 = exmpp_jid:make_jid(U, S, R),
|
JID1 = exmpp_jid:make_jid(U, S, R),
|
||||||
out_subscription(
|
out_subscription(
|
||||||
User, Server, JID1, subscribed),
|
User, Server, JID1, subscribed),
|
||||||
UJID = exmpp_jid:make_bare_jid(User, Server),
|
UJID = exmpp_jid:make_jid(User, Server),
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
UJID, JID1, exmpp_presence:subscribed()),
|
UJID, JID1, exmpp_presence:subscribed()),
|
||||||
throw(submitted);
|
throw(submitted);
|
||||||
@ -1048,7 +1048,7 @@ user_roster_item_parse_query(User, Server, Items, Query) ->
|
|||||||
case lists:keysearch(
|
case lists:keysearch(
|
||||||
"remove" ++ ejabberd_web_admin:term_to_id(JID), 1, Query) of
|
"remove" ++ ejabberd_web_admin:term_to_id(JID), 1, Query) of
|
||||||
{value, _} ->
|
{value, _} ->
|
||||||
UJID = exmpp_jid:make_bare_jid(User, Server),
|
UJID = exmpp_jid:make_jid(User, Server),
|
||||||
Attrs1 = exmpp_xml:set_attribute_in_list([],
|
Attrs1 = exmpp_xml:set_attribute_in_list([],
|
||||||
'jid', exmpp_jid:jid_to_list(JID)),
|
'jid', exmpp_jid:jid_to_list(JID)),
|
||||||
Attrs2 = exmpp_xml:set_attribute_in_list(Attrs1,
|
Attrs2 = exmpp_xml:set_attribute_in_list(Attrs1,
|
||||||
|
@ -63,13 +63,13 @@ log_user_receive(_JID, From, To, Packet) ->
|
|||||||
|
|
||||||
log_packet(From, To, Packet, Host) ->
|
log_packet(From, To, Packet, Host) ->
|
||||||
Loggers = gen_mod:get_module_opt(Host, ?MODULE, loggers, []),
|
Loggers = gen_mod:get_module_opt(Host, ?MODULE, loggers, []),
|
||||||
ServerJID = exmpp_jid:make_bare_jid(Host),
|
ServerJID = exmpp_jid:make_jid(Host),
|
||||||
FixedPacket = exmpp_stanza:set_jids(Packet, From, To),
|
FixedPacket = exmpp_stanza:set_jids(Packet, From, To),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(Logger) ->
|
fun(Logger) ->
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
ServerJID,
|
ServerJID,
|
||||||
exmpp_jid:make_bare_jid(Logger),
|
exmpp_jid:make_jid(Logger),
|
||||||
#xmlel{name = 'route', children = [FixedPacket]})
|
#xmlel{name = 'route', children = [FixedPacket]})
|
||||||
end, Loggers).
|
end, Loggers).
|
||||||
|
|
||||||
|
@ -224,9 +224,9 @@ set_new_rosteritems(UserFrom, ServerFrom,
|
|||||||
RIFrom = build_roster_record(UserFrom, ServerFrom,
|
RIFrom = build_roster_record(UserFrom, ServerFrom,
|
||||||
UserTo, ServerTo, NameTo, GroupsFrom),
|
UserTo, ServerTo, NameTo, GroupsFrom),
|
||||||
set_item(UserFrom, ServerFrom, ResourceTo, RIFrom),
|
set_item(UserFrom, ServerFrom, ResourceTo, RIFrom),
|
||||||
JIDTo = exmpp_jid:make_bare_jid(UserTo, ServerTo),
|
JIDTo = exmpp_jid:make_jid(UserTo, ServerTo),
|
||||||
|
|
||||||
JIDFrom = exmpp_jid:make_bare_jid(UserFrom, ServerFrom),
|
JIDFrom = exmpp_jid:make_jid(UserFrom, ServerFrom),
|
||||||
RITo = build_roster_record(UserTo, ServerTo,
|
RITo = build_roster_record(UserTo, ServerTo,
|
||||||
UserFrom, ServerFrom, UserFrom,[]),
|
UserFrom, ServerFrom, UserFrom,[]),
|
||||||
set_item(UserTo, ServerTo, undefined, RITo),
|
set_item(UserTo, ServerTo, undefined, RITo),
|
||||||
@ -256,7 +256,7 @@ set_item(User, Server, Resource, Item) ->
|
|||||||
"push" ++ randoms:get_string()),
|
"push" ++ randoms:get_string()),
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
exmpp_jid:make_jid(User, Server, Resource),
|
exmpp_jid:make_jid(User, Server, Resource),
|
||||||
exmpp_jid:make_bare_jid(Server),
|
exmpp_jid:make_jid(Server),
|
||||||
ResIQ).
|
ResIQ).
|
||||||
|
|
||||||
|
|
||||||
@ -634,7 +634,7 @@ push_item(User, Server, From, Item) ->
|
|||||||
%% ejabberd_sm:route(jlib:make_jid("", "", ""),
|
%% ejabberd_sm:route(jlib:make_jid("", "", ""),
|
||||||
%% jlib:make_jid(User, Server, "")
|
%% jlib:make_jid(User, Server, "")
|
||||||
%% why?
|
%% why?
|
||||||
ejabberd_sm:route(From, exmpp_jid:make_bare_jid(User, Server),
|
ejabberd_sm:route(From, exmpp_jid:make_jid(User, Server),
|
||||||
#xmlel{name = 'broadcast', children =
|
#xmlel{name = 'broadcast', children =
|
||||||
[{item,
|
[{item,
|
||||||
Item#roster.jid,
|
Item#roster.jid,
|
||||||
@ -890,7 +890,7 @@ shared_roster_group_parse_query(Host, Group, Query) ->
|
|||||||
USs;
|
USs;
|
||||||
_ ->
|
_ ->
|
||||||
try
|
try
|
||||||
JID = exmpp_jid:list_to_jid(SJID),
|
JID = exmpp_jid:parse_jid(SJID),
|
||||||
[{exmpp_jid:lnode_as_list(JID), exmpp_jid:ldomain_as_list(JID)} | USs]
|
[{exmpp_jid:lnode_as_list(JID), exmpp_jid:ldomain_as_list(JID)} | USs]
|
||||||
catch
|
catch
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -46,7 +46,7 @@ stop(Host) ->
|
|||||||
|
|
||||||
process_local_iq(_From, To, #iq{type = get,
|
process_local_iq(_From, To, #iq{type = get,
|
||||||
ns = XMLNS, payload = SubEl} = IQ_Rec) ->
|
ns = XMLNS, payload = SubEl} = IQ_Rec) ->
|
||||||
Node = string:tokens(exmpp_xml:get_attribute(SubEl, 'node', ""), "/"),
|
Node = string:tokens(exmpp_xml:get_attribute_as_list(SubEl, 'node', ""), "/"),
|
||||||
Names = get_names(exmpp_xml:get_child_elements(SubEl), []),
|
Names = get_names(exmpp_xml:get_child_elements(SubEl), []),
|
||||||
|
|
||||||
case get_local_stats(exmpp_jid:domain_as_list(To), Node, Names) of
|
case get_local_stats(exmpp_jid:domain_as_list(To), Node, Names) of
|
||||||
@ -74,7 +74,7 @@ get_names([_ | Els], Res) ->
|
|||||||
get_names(Els, Res).
|
get_names(Els, Res).
|
||||||
|
|
||||||
|
|
||||||
-define(STAT(Name), #xmlel{ns = ?NS_STATS, name = 'stat', attrs = [#xmlattr{name = 'name', value = Name}]}).
|
-define(STAT(Name), #xmlel{ns = ?NS_STATS, name = 'stat', attrs = [?XMLATTR('name', Name)]}).
|
||||||
|
|
||||||
get_local_stats(_Server, [], []) ->
|
get_local_stats(_Server, [], []) ->
|
||||||
{result,
|
{result,
|
||||||
@ -116,16 +116,16 @@ get_local_stats(_Server, _, _) ->
|
|||||||
|
|
||||||
-define(STATVAL(Val, Unit),
|
-define(STATVAL(Val, Unit),
|
||||||
#xmlel{ns = ?NS_STATS, name = 'stat', attrs =
|
#xmlel{ns = ?NS_STATS, name = 'stat', attrs =
|
||||||
[#xmlattr{name = 'name', value = Name},
|
[?XMLATTR('name', Name),
|
||||||
#xmlattr{name = 'units', value = Unit},
|
?XMLATTR('units', Unit),
|
||||||
#xmlattr{name = 'value', value = Val}
|
?XMLATTR('value', Val)
|
||||||
]}).
|
]}).
|
||||||
|
|
||||||
-define(STATERR(Code, Desc),
|
-define(STATERR(Code, Desc),
|
||||||
#xmlel{ns = ?NS_STATS, name = 'stat', attrs=
|
#xmlel{ns = ?NS_STATS, name = 'stat', attrs=
|
||||||
[#xmlattr{name = 'name', value = Name}], children =
|
[?XMLATTR('name', Name)], children =
|
||||||
[#xmlel{ns = ?NS_STATS, name = 'error', attrs =
|
[#xmlel{ns = ?NS_STATS, name = 'error', attrs =
|
||||||
[#xmlattr{name = 'code', value = Code}], children =
|
[?XMLATTR('code', Code)], children =
|
||||||
[#xmlcdata{cdata = Desc}]}]}).
|
[#xmlcdata{cdata = Desc}]}]}).
|
||||||
|
|
||||||
|
|
||||||
|
@ -275,16 +275,16 @@ set_vcard(User, LServer, VCARD) ->
|
|||||||
|
|
||||||
-define(TLFIELD(Type, Label, Var),
|
-define(TLFIELD(Type, Label, Var),
|
||||||
#xmlel{ns = ?NS_VCARD, name = 'field', attrs = [
|
#xmlel{ns = ?NS_VCARD, name = 'field', attrs = [
|
||||||
#xmlattr{name = 'type', value = Type},
|
?XMLATTR('type', Type),
|
||||||
#xmlattr{name = 'label', value = translate:translate(Lang, Label)},
|
?XMLATTR('label', translate:translate(Lang, Label)),
|
||||||
#xmlattr{name = 'var', value = Var}]}).
|
?XMLATTR('var', Var)]}).
|
||||||
|
|
||||||
|
|
||||||
-define(FORM(JID),
|
-define(FORM(JID),
|
||||||
[#xmlel{ns = ?NS_SEARCH, name = 'instructions', children =
|
[#xmlel{ns = ?NS_SEARCH, name = 'instructions', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "You need an x:data capable client to search"))}]},
|
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "You need an x:data capable client to search"))}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"form">>}], children =
|
[?XMLATTR('type', <<"form">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "Search users in ") ++ exmpp_jid:jid_to_list(JID))}]},
|
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "Search users in ") ++ exmpp_jid:jid_to_list(JID))}]},
|
||||||
#xmlel{ns = ?NS_SEARCH, name = 'instructions', children =
|
#xmlel{ns = ?NS_SEARCH, name = 'instructions', children =
|
||||||
@ -345,8 +345,8 @@ do_route(ServerHost, From, To, Packet) ->
|
|||||||
#xmlel{
|
#xmlel{
|
||||||
ns = ?NS_DATA_FORMS,
|
ns = ?NS_DATA_FORMS,
|
||||||
name = 'x',
|
name = 'x',
|
||||||
attrs = [#xmlattr{name = 'type',
|
attrs = [?XMLATTR('type',
|
||||||
value = <<"result">>}],
|
<<"result">>)],
|
||||||
children = search_result(Lang,
|
children = search_result(Lang,
|
||||||
To, ServerHost, XData)}]},
|
To, ServerHost, XData)}]},
|
||||||
ResIQ = exmpp_iq:result(Packet,
|
ResIQ = exmpp_iq:result(Packet,
|
||||||
@ -370,25 +370,19 @@ do_route(ServerHost, From, To, Packet) ->
|
|||||||
children = [
|
children = [
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'identity',
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'identity',
|
||||||
attrs = [
|
attrs = [
|
||||||
#xmlattr{name = 'category',
|
?XMLATTR('category', <<"directory">>),
|
||||||
value = <<"directory">>},
|
?XMLATTR('type', <<"user">>),
|
||||||
#xmlattr{name = 'type',
|
?XMLATTR('name', translate:translate(Lang,
|
||||||
value = <<"user">>},
|
"vCard User Search"))]},
|
||||||
#xmlattr{name = 'name',
|
|
||||||
value = list_to_binary(translate:translate(Lang,
|
|
||||||
"vCard User Search"))}]},
|
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature',
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature',
|
||||||
attrs = [
|
attrs = [
|
||||||
#xmlattr{name = 'var',
|
?XMLATTR('var', ?NS_DISCO_INFO_s)]},
|
||||||
value = list_to_binary(?NS_DISCO_INFO_s)}]},
|
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature',
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature',
|
||||||
attrs = [
|
attrs = [
|
||||||
#xmlattr{name = 'var',
|
?XMLATTR('var', ?NS_SEARCH_s)]},
|
||||||
value = list_to_binary(?NS_SEARCH_s)}]},
|
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature',
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature',
|
||||||
attrs = [
|
attrs = [
|
||||||
#xmlattr{name = 'var',
|
?XMLATTR('var', ?NS_VCARD_s)]}
|
||||||
value = list_to_binary(?NS_VCARD_s)}]}
|
|
||||||
]},
|
]},
|
||||||
ResIQ = exmpp_iq:result(Packet, Result),
|
ResIQ = exmpp_iq:result(Packet, Result),
|
||||||
ejabberd_router:route(To,
|
ejabberd_router:route(To,
|
||||||
@ -465,7 +459,7 @@ search_result(Lang, JID, ServerHost, Data) ->
|
|||||||
|
|
||||||
-define(FIELD(Var, Val),
|
-define(FIELD(Var, Val),
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'var', value = Var}], children =
|
[?XMLATTR('var', Var)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
|
||||||
[#xmlcdata{cdata = Val}]}]}).
|
[#xmlcdata{cdata = Val}]}]}).
|
||||||
|
|
||||||
|
@ -385,15 +385,15 @@ ldap_attribute_to_vcard(_, _) ->
|
|||||||
|
|
||||||
-define(TLFIELD(Type, Label, Var),
|
-define(TLFIELD(Type, Label, Var),
|
||||||
#xmlel{ns = ?NS_VCARD, name = 'field', attrs = [
|
#xmlel{ns = ?NS_VCARD, name = 'field', attrs = [
|
||||||
#xmlattr{name = 'type', value = Type},
|
?XMLATTR('type', Type),
|
||||||
#xmlattr{name = 'label', value = translate:translate(Lang, Label)},
|
?XMLATTR('label', translate:translate(Lang, Label)),
|
||||||
#xmlattr{name = 'var', value = Var}]}).
|
?XMLATTR('var', Var)]}).
|
||||||
|
|
||||||
-define(FORM(JID, SearchFields),
|
-define(FORM(JID, SearchFields),
|
||||||
[#xmlel{ns = ?NS_SEARCH, name = 'instructions', children =
|
[#xmlel{ns = ?NS_SEARCH, name = 'instructions', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "You need an x:data capable client to search"))}]},
|
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "You need an x:data capable client to search"))}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"form">>}], children =
|
[?XMLATTR('type', <<"form">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "Search users in ") ++
|
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "Search users in ") ++
|
||||||
exmpp_jid:jid_to_list(JID))}]},
|
exmpp_jid:jid_to_list(JID))}]},
|
||||||
@ -440,8 +440,8 @@ route(State, From, To, Packet) ->
|
|||||||
#xmlel{
|
#xmlel{
|
||||||
ns = ?NS_DATA_FORMS,
|
ns = ?NS_DATA_FORMS,
|
||||||
name = 'x',
|
name = 'x',
|
||||||
attrs = [#xmlattr{name = 'type',
|
attrs = [?XMLATTR('type',
|
||||||
value = <<"result">>}],
|
<<"result">>)],
|
||||||
children = search_result(Lang, To, State, XData)}]},
|
children = search_result(Lang, To, State, XData)}]},
|
||||||
ResIQ = exmpp_iq:result(Packet,
|
ResIQ = exmpp_iq:result(Packet,
|
||||||
Result),
|
Result),
|
||||||
@ -465,21 +465,16 @@ route(State, From, To, Packet) ->
|
|||||||
children = [
|
children = [
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'identity',
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'identity',
|
||||||
attrs = [
|
attrs = [
|
||||||
#xmlattr{name = 'category',
|
?XMLATTR('category', <<"directory">>),
|
||||||
value = <<"directory">>},
|
?XMLATTR('type', <<"user">>),
|
||||||
#xmlattr{name = 'type',
|
?XMLATTR('name', translate:translate(Lang,
|
||||||
value = <<"user">>},
|
"vCard User Search"))]},
|
||||||
#xmlattr{name = 'name',
|
|
||||||
value = list_to_binary(translate:translate(Lang,
|
|
||||||
"vCard User Search"))}]},
|
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature',
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature',
|
||||||
attrs = [
|
attrs = [
|
||||||
#xmlattr{name = 'var',
|
?XMLATTR('var', ?NS_SEARCH_s)]},
|
||||||
value = list_to_binary(?NS_SEARCH_s)}]},
|
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature',
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature',
|
||||||
attrs = [
|
attrs = [
|
||||||
#xmlattr{name = 'var',
|
?XMLATTR('var', ?NS_VCARD_s)]}
|
||||||
value = list_to_binary(?NS_VCARD_s)}]}
|
|
||||||
]},
|
]},
|
||||||
ResIQ = exmpp_iq:result(Packet, Result),
|
ResIQ = exmpp_iq:result(Packet, Result),
|
||||||
ejabberd_router:route(To,
|
ejabberd_router:route(To,
|
||||||
@ -544,7 +539,7 @@ search_result(Lang, JID, State, Data) ->
|
|||||||
|
|
||||||
-define(FIELD(Var, Val),
|
-define(FIELD(Var, Val),
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'var', value = Var}], children =
|
[?XMLATTR('var', Var)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
|
||||||
[#xmlcdata{cdata = Val}]}]}).
|
[#xmlcdata{cdata = Val}]}]}).
|
||||||
|
|
||||||
|
@ -249,16 +249,16 @@ set_vcard(User, LServer, VCARD) ->
|
|||||||
|
|
||||||
-define(TLFIELD(Type, Label, Var),
|
-define(TLFIELD(Type, Label, Var),
|
||||||
#xmlel{ns = ?NS_VCARD, name = 'field', attrs = [
|
#xmlel{ns = ?NS_VCARD, name = 'field', attrs = [
|
||||||
#xmlattr{name = 'type', value = Type},
|
?XMLATTR('type', Type),
|
||||||
#xmlattr{name = 'label', value = list_to_binary(translate:translate(Lang, Label))},
|
?XMLATTR('label', translate:translate(Lang, Label)),
|
||||||
#xmlattr{name = 'var', value = Var}]}).
|
?XMLATTR('var', Var)]}).
|
||||||
|
|
||||||
|
|
||||||
-define(FORM(JID),
|
-define(FORM(JID),
|
||||||
[#xmlel{ns = ?NS_SEARCH, name = 'instructions', children =
|
[#xmlel{ns = ?NS_SEARCH, name = 'instructions', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "You need an x:data capable client to search"))}]},
|
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "You need an x:data capable client to search"))}]},
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs =
|
||||||
[#xmlattr{name = 'type', value = <<"form">>}], children =
|
[?XMLATTR('type', <<"form">>)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
|
||||||
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "Search users in ") ++ exmpp_jid:jid_to_list(JID))}]},
|
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "Search users in ") ++ exmpp_jid:jid_to_list(JID))}]},
|
||||||
#xmlel{ns = ?NS_SEARCH, name = 'instructions', children =
|
#xmlel{ns = ?NS_SEARCH, name = 'instructions', children =
|
||||||
@ -313,8 +313,8 @@ do_route(ServerHost, From, To, Packet) ->
|
|||||||
#xmlel{ns = ?NS_DATA_FORMS,
|
#xmlel{ns = ?NS_DATA_FORMS,
|
||||||
name = 'x',
|
name = 'x',
|
||||||
attrs = [
|
attrs = [
|
||||||
#xmlattr{name = 'type',
|
?XMLATTR('type',
|
||||||
value = <<"result">>}],
|
<<"result">>)],
|
||||||
children = search_result(Lang,
|
children = search_result(Lang,
|
||||||
To, ServerHost, XData)}]},
|
To, ServerHost, XData)}]},
|
||||||
ResIQ = exmpp_iq:result(Packet, Result),
|
ResIQ = exmpp_iq:result(Packet, Result),
|
||||||
@ -337,21 +337,16 @@ do_route(ServerHost, From, To, Packet) ->
|
|||||||
children = [
|
children = [
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'identity',
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'identity',
|
||||||
attrs = [
|
attrs = [
|
||||||
#xmlattr{name = 'category',
|
?XMLATTR('category', <<"directory">>),
|
||||||
value = <<"directory">>},
|
?XMLATTR('type', <<"user">>),
|
||||||
#xmlattr{name = 'type',
|
?XMLATTR('name', translate:translate(Lang,
|
||||||
value = <<"user">>},
|
"vCard User Search"))]},
|
||||||
#xmlattr{name = 'name',
|
|
||||||
value = list_to_binary(translate:translate(Lang,
|
|
||||||
"vCard User Search"))}]},
|
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature',
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature',
|
||||||
attrs = [
|
attrs = [
|
||||||
#xmlattr{name = 'var',
|
?XMLATTR('var', ?NS_SEARCH_s)]},
|
||||||
value = list_to_binary(?NS_SEARCH_s)}]},
|
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature',
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature',
|
||||||
attrs = [
|
attrs = [
|
||||||
#xmlattr{name = 'var',
|
?XMLATTR('var', ?NS_VCARD_s)]}
|
||||||
value = list_to_binary(?NS_VCARD_s)}]}
|
|
||||||
]},
|
]},
|
||||||
ResIQ = exmpp_iq:result(Packet, Result),
|
ResIQ = exmpp_iq:result(Packet, Result),
|
||||||
ejabberd_router:route(To,
|
ejabberd_router:route(To,
|
||||||
@ -429,7 +424,7 @@ search_result(Lang, JID, ServerHost, Data) ->
|
|||||||
|
|
||||||
-define(FIELD(Var, Val),
|
-define(FIELD(Var, Val),
|
||||||
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
|
||||||
[#xmlattr{name = 'var', value = Var}], children =
|
[?XMLATTR('var', Var)], children =
|
||||||
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
|
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
|
||||||
[#xmlcdata{cdata = Val}]}]}).
|
[#xmlcdata{cdata = Val}]}]}).
|
||||||
|
|
||||||
|
@ -414,14 +414,14 @@ resend_message(Packet) ->
|
|||||||
get_jid("from", ParsedPacket) ->
|
get_jid("from", ParsedPacket) ->
|
||||||
case exmpp_stanza:get_sender(ParsedPacket) of
|
case exmpp_stanza:get_sender(ParsedPacket) of
|
||||||
undefined ->
|
undefined ->
|
||||||
#jid{};
|
exmpp_jid:make_jid();
|
||||||
From ->
|
From ->
|
||||||
exmpp_jid:binary_to_jid(From)
|
exmpp_jid:parse_jid(From)
|
||||||
end;
|
end;
|
||||||
get_jid("to", ParsedPacket) ->
|
get_jid("to", ParsedPacket) ->
|
||||||
case exmpp_stanza:get_recipient(ParsedPacket) of
|
case exmpp_stanza:get_recipient(ParsedPacket) of
|
||||||
undefined ->
|
undefined ->
|
||||||
#jid{};
|
exmpp_jid:make_jid();
|
||||||
From ->
|
From ->
|
||||||
exmpp_jid:binary_to_jid(From)
|
exmpp_jid:parse_jid(From)
|
||||||
end.
|
end.
|
||||||
|
@ -47,12 +47,12 @@ make_xhtml(Els) ->
|
|||||||
|
|
||||||
make_xhtml(HeadEls, Els) ->
|
make_xhtml(HeadEls, Els) ->
|
||||||
#xmlel{ns = ?NS_XHTML, name = 'html', attrs = [
|
#xmlel{ns = ?NS_XHTML, name = 'html', attrs = [
|
||||||
#xmlattr{ns = ?NS_XML, name = 'lang', value = "en"},
|
exmpp_xml:attribute(?NS_XML, 'lang', <<"en">>),
|
||||||
#xmlattr{name = 'lang', value = "en"}], children = [
|
?XMLATTR('lang', <<"en">>)], children = [
|
||||||
#xmlel{ns = ?NS_XHTML, name = 'head', children = [
|
#xmlel{ns = ?NS_XHTML, name = 'head', children = [
|
||||||
#xmlel{ns = ?NS_XHTML, name = 'meta', attrs = [
|
#xmlel{ns = ?NS_XHTML, name = 'meta', attrs = [
|
||||||
#xmlattr{name = 'http-equiv', value = "Content-Type"},
|
?XMLATTR('http-equiv', <<"Content-Type">>),
|
||||||
#xmlattr{name = 'content', value = "text/html; charset=utf-8"}
|
?XMLATTR('content', <<"text/html; charset=utf-8">>)
|
||||||
]}
|
]}
|
||||||
| HeadEls
|
| HeadEls
|
||||||
]},
|
]},
|
||||||
@ -70,14 +70,14 @@ make_xhtml(HeadEls, Els) ->
|
|||||||
-define(XAC(Name, Attrs, Text), ?XAE(Name, Attrs, [?C(Text)])).
|
-define(XAC(Name, Attrs, Text), ?XAE(Name, Attrs, [?C(Text)])).
|
||||||
|
|
||||||
-define(LI(Els), ?XE('li', Els)).
|
-define(LI(Els), ?XE('li', Els)).
|
||||||
-define(A(URL, Els), ?XAE('a', [#xmlattr{name = 'href', value = URL}], Els)).
|
-define(A(URL, Els), ?XAE('a', [?XMLATTR('href', URL)], Els)).
|
||||||
-define(AC(URL, Text), ?A(URL, [?C(Text)])).
|
-define(AC(URL, Text), ?A(URL, [?C(Text)])).
|
||||||
-define(P, ?X('p')).
|
-define(P, ?X('p')).
|
||||||
-define(BR, ?X('br')).
|
-define(BR, ?X('br')).
|
||||||
-define(INPUT(Type, Name, Value),
|
-define(INPUT(Type, Name, Value),
|
||||||
?XA('input', [#xmlattr{name = 'type', value = Type},
|
?XA('input', [?XMLATTR('type', Type),
|
||||||
#xmlattr{name = 'name', value = Name},
|
?XMLATTR('name', Name),
|
||||||
#xmlattr{name = 'value', value = Value}])).
|
?XMLATTR('value', Value)])).
|
||||||
|
|
||||||
error(not_found) ->
|
error(not_found) ->
|
||||||
{404, [], make_xhtml([?XC('h1', "404 Not Found")])};
|
{404, [], make_xhtml([?XC('h1', "404 Not Found")])};
|
||||||
|
@ -71,7 +71,7 @@ process(["server", SHost | RPath], #request{auth = Auth} = Request) ->
|
|||||||
case get_auth(Auth) of
|
case get_auth(Auth) of
|
||||||
{User, Server} ->
|
{User, Server} ->
|
||||||
case acl:match_rule(
|
case acl:match_rule(
|
||||||
Host, configure, exmpp_jid:make_bare_jid(User, Server)) of
|
Host, configure, exmpp_jid:make_jid(User, Server)) of
|
||||||
deny ->
|
deny ->
|
||||||
ejabberd_web:error(not_allowed);
|
ejabberd_web:error(not_allowed);
|
||||||
allow ->
|
allow ->
|
||||||
@ -93,7 +93,7 @@ process(RPath, #request{auth = Auth} = Request) ->
|
|||||||
case get_auth(Auth) of
|
case get_auth(Auth) of
|
||||||
{User, Server} ->
|
{User, Server} ->
|
||||||
case acl:match_rule(
|
case acl:match_rule(
|
||||||
global, configure, exmpp_jid:make_bare_jid(User, Server)) of
|
global, configure, exmpp_jid:make_jid(User, Server)) of
|
||||||
deny ->
|
deny ->
|
||||||
ejabberd_web:error(not_allowed);
|
ejabberd_web:error(not_allowed);
|
||||||
allow ->
|
allow ->
|
||||||
@ -114,7 +114,9 @@ get_auth(Auth) ->
|
|||||||
case Auth of
|
case Auth of
|
||||||
{SJID, P} ->
|
{SJID, P} ->
|
||||||
try
|
try
|
||||||
#jid{node = U, domain = S} = exmpp_jid:list_to_jid(SJID),
|
JID = exmpp_jid:parse_jid(SJID),
|
||||||
|
U = exmpp_jid:node_as_list(JID),
|
||||||
|
S = exmpp_jid:domain_as_list(JID),
|
||||||
case ejabberd_auth:check_password(U, S, P) of
|
case ejabberd_auth:check_password(U, S, P) of
|
||||||
true ->
|
true ->
|
||||||
{U, S};
|
{U, S};
|
||||||
@ -140,44 +142,44 @@ make_xhtml(Els, Host, Node, Lang) ->
|
|||||||
MenuItems = make_navigation(Host, Node, Lang),
|
MenuItems = make_navigation(Host, Node, Lang),
|
||||||
{200, [html],
|
{200, [html],
|
||||||
#xmlel{ns = ?NS_XHTML, name = 'html', attrs = [
|
#xmlel{ns = ?NS_XHTML, name = 'html', attrs = [
|
||||||
#xmlattr{ns = ?NS_XML, name = 'lang', value = Lang},
|
exmpp_xml:attribute(?NS_XML, 'lang', Lang),
|
||||||
#xmlattr{name = 'lang', value = Lang}], children =
|
?XMLATTR('lang', Lang)], children =
|
||||||
[#xmlel{ns = ?NS_XHTML, name = 'head', children =
|
[#xmlel{ns = ?NS_XHTML, name = 'head', children =
|
||||||
[?XCT('title', "ejabberd Web Admin"),
|
[?XCT('title', "ejabberd Web Admin"),
|
||||||
#xmlel{ns = ?NS_XHTML, name = 'meta', attrs = [
|
#xmlel{ns = ?NS_XHTML, name = 'meta', attrs = [
|
||||||
#xmlattr{name = 'http-equiv', value = "Content-Type"},
|
?XMLATTR('http-equiv', <<"Content-Type">>),
|
||||||
#xmlattr{name = 'content', value = "text/html; charset=utf-8"}]},
|
?XMLATTR('content', <<"text/html; charset=utf-8">>)]},
|
||||||
#xmlel{ns = ?NS_XHTML, name = 'link', attrs = [
|
#xmlel{ns = ?NS_XHTML, name = 'link', attrs = [
|
||||||
#xmlattr{name = 'href', value = Base ++ "favicon.ico"},
|
?XMLATTR('href', Base ++ "favicon.ico"),
|
||||||
#xmlattr{name = 'type', value = "image/x-icon"},
|
?XMLATTR('type', <<"image/x-icon">>),
|
||||||
#xmlattr{name = 'rel', value = "shortcut icon"}]},
|
?XMLATTR('rel', <<"shortcut icon">>)]},
|
||||||
#xmlel{ns = ?NS_XHTML, name = 'link', attrs = [
|
#xmlel{ns = ?NS_XHTML, name = 'link', attrs = [
|
||||||
#xmlattr{name = 'href', value = Base ++ "style.css"},
|
?XMLATTR('href', Base ++ "style.css"),
|
||||||
#xmlattr{name = 'type', value = "text/css"},
|
?XMLATTR('type', <<"text/css">>),
|
||||||
#xmlattr{name = 'rel', value = "stylesheet"}]}]},
|
?XMLATTR('rel', <<"stylesheet">>)]}]},
|
||||||
?XE('body',
|
?XE('body',
|
||||||
[?XAE('div',
|
[?XAE('div',
|
||||||
[#xmlattr{name = 'id', value = "container"}],
|
[?XMLATTR('id', <<"container">>)],
|
||||||
[?XAE('div',
|
[?XAE('div',
|
||||||
[#xmlattr{name = 'id', value = "header"}],
|
[?XMLATTR('id', <<"header">>)],
|
||||||
[?XE('h1',
|
[?XE('h1',
|
||||||
[?ACT("/admin/", "ejabberd Web Admin")]
|
[?ACT("/admin/", "ejabberd Web Admin")]
|
||||||
)]),
|
)]),
|
||||||
?XAE('div',
|
?XAE('div',
|
||||||
[#xmlattr{name = 'id', value = "navigation"}],
|
[?XMLATTR('id', <<"navigation">>)],
|
||||||
[?XE('ul',
|
[?XE('ul',
|
||||||
MenuItems
|
MenuItems
|
||||||
)]),
|
)]),
|
||||||
?XAE('div',
|
?XAE('div',
|
||||||
[#xmlattr{name = 'id', value = "content"}],
|
[?XMLATTR('id', <<"content">>)],
|
||||||
Els),
|
Els),
|
||||||
?XAE('div',
|
?XAE('div',
|
||||||
[#xmlattr{name = 'id', value = "clearcopyright"}],
|
[?XMLATTR('id', <<"clearcopyright">>)],
|
||||||
[#xmlcdata{cdata = <<>>}])]),
|
[#xmlcdata{cdata = <<>>}])]),
|
||||||
?XAE('div',
|
?XAE('div',
|
||||||
[#xmlattr{name = 'id', value = "copyrightouter"}],
|
[?XMLATTR('id', <<"copyrightouter">>)],
|
||||||
[?XAE('div',
|
[?XAE('div',
|
||||||
[#xmlattr{name = 'id', value = "copyright"}],
|
[?XMLATTR('id', <<"copyright">>)],
|
||||||
[?XC('p',
|
[?XC('p',
|
||||||
"ejabberd (c) 2002-2009 ProcessOne")
|
"ejabberd (c) 2002-2009 ProcessOne")
|
||||||
])])])
|
])])])
|
||||||
@ -678,7 +680,7 @@ process_admin(Host,
|
|||||||
error -> [?XREST("Bad format")];
|
error -> [?XREST("Bad format")];
|
||||||
nothing -> []
|
nothing -> []
|
||||||
end ++
|
end ++
|
||||||
[?XAE('form', [#xmlattr{name = 'action', value = ""}, #xmlattr{name = 'method', value = "post"}],
|
[?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)],
|
||||||
[?TEXTAREA("acls", integer_to_list(lists:max([16, NumLines])), "80", ACLsP++"."),
|
[?TEXTAREA("acls", integer_to_list(lists:max([16, NumLines])), "80", ACLsP++"."),
|
||||||
?BR,
|
?BR,
|
||||||
?INPUTT("submit", "submit", "Submit")
|
?INPUTT("submit", "submit", "Submit")
|
||||||
@ -719,7 +721,7 @@ process_admin(Host,
|
|||||||
nothing -> []
|
nothing -> []
|
||||||
end ++
|
end ++
|
||||||
[?XE('p', [?ACT("../acls-raw/", "Raw")])] ++
|
[?XE('p', [?ACT("../acls-raw/", "Raw")])] ++
|
||||||
[?XAE('form', [#xmlattr{name = 'action', value = ""}, #xmlattr{name = 'method', value = "post"}],
|
[?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)],
|
||||||
[acls_to_xhtml(ACLs),
|
[acls_to_xhtml(ACLs),
|
||||||
?BR,
|
?BR,
|
||||||
?INPUTT("submit", "delete", "Delete Selected"),
|
?INPUTT("submit", "delete", "Delete Selected"),
|
||||||
@ -785,7 +787,7 @@ process_admin(Host,
|
|||||||
error -> [?XREST("Bad format")];
|
error -> [?XREST("Bad format")];
|
||||||
nothing -> []
|
nothing -> []
|
||||||
end ++
|
end ++
|
||||||
[?XAE('form', [#xmlattr{name = 'action', value = ""}, #xmlattr{name = 'method', value = "post"}],
|
[?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)],
|
||||||
[?TEXTAREA("access", integer_to_list(lists:max([16, NumLines])), "80", AccessP++"."),
|
[?TEXTAREA("access", integer_to_list(lists:max([16, NumLines])), "80", AccessP++"."),
|
||||||
?BR,
|
?BR,
|
||||||
?INPUTT("submit", "submit", "Submit")
|
?INPUTT("submit", "submit", "Submit")
|
||||||
@ -821,7 +823,7 @@ process_admin(Host,
|
|||||||
nothing -> []
|
nothing -> []
|
||||||
end ++
|
end ++
|
||||||
[?XE('p', [?ACT("../access-raw/", "Raw")])] ++
|
[?XE('p', [?ACT("../access-raw/", "Raw")])] ++
|
||||||
[?XAE('form', [#xmlattr{name = 'action', value = ""}, #xmlattr{name = 'method', value = "post"}],
|
[?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)],
|
||||||
[access_rules_to_xhtml(AccessRules, Lang),
|
[access_rules_to_xhtml(AccessRules, Lang),
|
||||||
?BR,
|
?BR,
|
||||||
?INPUTT("submit", "delete", "Delete Selected")
|
?INPUTT("submit", "delete", "Delete Selected")
|
||||||
@ -860,7 +862,7 @@ process_admin(Host,
|
|||||||
error -> [?XREST("Bad format")];
|
error -> [?XREST("Bad format")];
|
||||||
nothing -> []
|
nothing -> []
|
||||||
end ++
|
end ++
|
||||||
[?XAE('form', [#xmlattr{name = 'action', value = ""}, #xmlattr{name = 'method', value = "post"}],
|
[?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)],
|
||||||
[access_rule_to_xhtml(Rules),
|
[access_rule_to_xhtml(Rules),
|
||||||
?BR,
|
?BR,
|
||||||
?INPUTT("submit", "submit", "Submit")
|
?INPUTT("submit", "submit", "Submit")
|
||||||
@ -911,17 +913,17 @@ process_admin(Host,
|
|||||||
list_last_activity(Host, Lang, true, Month)
|
list_last_activity(Host, Lang, true, Month)
|
||||||
end,
|
end,
|
||||||
make_xhtml([?XCT('h1', "Users Last Activity")] ++
|
make_xhtml([?XCT('h1', "Users Last Activity")] ++
|
||||||
[?XAE('form', [#xmlattr{name = 'action', value = ""}, #xmlattr{name = 'method', value = "post"}],
|
[?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)],
|
||||||
[?CT("Period: "),
|
[?CT("Period: "),
|
||||||
?XAE('select', [#xmlattr{name = 'name', value = "period"}],
|
?XAE('select', [?XMLATTR('name', <<"period">>)],
|
||||||
lists:map(
|
lists:map(
|
||||||
fun({O, V}) ->
|
fun({O, V}) ->
|
||||||
Sel = if
|
Sel = if
|
||||||
O == Month -> [#xmlattr{name = 'selected', value = "selected"}];
|
O == Month -> [?XMLATTR('selected', <<"selected">>)];
|
||||||
true -> []
|
true -> []
|
||||||
end,
|
end,
|
||||||
?XAC('option',
|
?XAC('option',
|
||||||
Sel ++ [#xmlattr{name = 'value', value = O}], V)
|
Sel ++ [?XMLATTR('value', O)], V)
|
||||||
end, [{"month", ?T("Last month")},
|
end, [{"month", ?T("Last month")},
|
||||||
{"year", ?T("Last year")},
|
{"year", ?T("Last year")},
|
||||||
{"all", ?T("All activity")}])),
|
{"all", ?T("All activity")}])),
|
||||||
@ -1046,15 +1048,15 @@ acl_spec_to_xhtml(ID, Spec) ->
|
|||||||
|
|
||||||
acl_spec_select(ID, Opt) ->
|
acl_spec_select(ID, Opt) ->
|
||||||
?XE('td',
|
?XE('td',
|
||||||
[?XAE('select', [#xmlattr{name = 'name', value = "type" ++ ID}],
|
[?XAE('select', [?XMLATTR('name', "type" ++ ID)],
|
||||||
lists:map(
|
lists:map(
|
||||||
fun(O) ->
|
fun(O) ->
|
||||||
Sel = if
|
Sel = if
|
||||||
O == Opt -> [#xmlattr{name = 'selected', value = "selected"}];
|
O == Opt -> [?XMLATTR('selected', <<"selected">>)];
|
||||||
true -> []
|
true -> []
|
||||||
end,
|
end,
|
||||||
?XAC('option',
|
?XAC('option',
|
||||||
Sel ++ [#xmlattr{name = 'value', value = atom_to_list(O)}],
|
Sel ++ [?XMLATTR('value', O)],
|
||||||
atom_to_list(O))
|
atom_to_list(O))
|
||||||
end, [user, server, user_regexp, server_regexp,
|
end, [user, server, user_regexp, server_regexp,
|
||||||
node_regexp, user_glob, server_glob, node_glob, all, raw]))]).
|
node_regexp, user_glob, server_glob, node_glob, all, raw]))]).
|
||||||
@ -1135,14 +1137,20 @@ string_to_spec("user_regexp", Val) ->
|
|||||||
string_to_spec("server_regexp", Val) ->
|
string_to_spec("server_regexp", Val) ->
|
||||||
{server_regexp, Val};
|
{server_regexp, Val};
|
||||||
string_to_spec("node_regexp", Val) ->
|
string_to_spec("node_regexp", Val) ->
|
||||||
#jid{lnode = U, ldomain = S, resource = undefined} = exmpp_jid:list_to_jid(Val),
|
JID = exmpp_jid:parse_jid(Val),
|
||||||
|
U = exmpp_jid:lnode_as_list(JID),
|
||||||
|
S = exmpp_jid:ldomain_as_list(JID),
|
||||||
|
undefined = exmpp_jid:resource(JID),
|
||||||
{node_regexp, U, S};
|
{node_regexp, U, S};
|
||||||
string_to_spec("user_glob", Val) ->
|
string_to_spec("user_glob", Val) ->
|
||||||
string_to_spec2(user_glob, Val);
|
string_to_spec2(user_glob, Val);
|
||||||
string_to_spec("server_glob", Val) ->
|
string_to_spec("server_glob", Val) ->
|
||||||
{server_glob, Val};
|
{server_glob, Val};
|
||||||
string_to_spec("node_glob", Val) ->
|
string_to_spec("node_glob", Val) ->
|
||||||
#jid{lnode = U, ldomain = S, resource = undefined} = exmpp_jid:list_to_jid(Val),
|
JID = exmpp_jid:parse_jid(Val),
|
||||||
|
U = exmpp_jid:lnode_as_list(JID),
|
||||||
|
S = exmpp_jid:ldomain_as_list(JID),
|
||||||
|
undefined = exmpp_jid:resource(JID),
|
||||||
{node_glob, U, S};
|
{node_glob, U, S};
|
||||||
string_to_spec("all", _) ->
|
string_to_spec("all", _) ->
|
||||||
all;
|
all;
|
||||||
@ -1152,9 +1160,12 @@ string_to_spec("raw", Val) ->
|
|||||||
NewSpec.
|
NewSpec.
|
||||||
|
|
||||||
string_to_spec2(ACLName, Val) ->
|
string_to_spec2(ACLName, Val) ->
|
||||||
#jid{lnode = U, ldomain = S, resource = undefined} = exmpp_jid:list_to_jid(Val),
|
JID = exmpp_jid:parse_jid(Val),
|
||||||
|
U = exmpp_jid:lnode_as_list(JID),
|
||||||
|
S = exmpp_jid:ldomain_as_list(JID),
|
||||||
|
undefined = exmpp_jid:resource(JID),
|
||||||
case U of
|
case U of
|
||||||
"" ->
|
undefined ->
|
||||||
{ACLName, S};
|
{ACLName, S};
|
||||||
_ ->
|
_ ->
|
||||||
{ACLName, U, S}
|
{ACLName, U, S}
|
||||||
@ -1322,7 +1333,7 @@ list_users(Host, Query, Lang, URLFunc) ->
|
|||||||
error -> [?XREST("Bad format")];
|
error -> [?XREST("Bad format")];
|
||||||
nothing -> []
|
nothing -> []
|
||||||
end ++
|
end ++
|
||||||
[?XAE('form', [#xmlattr{name = 'action', value = ""}, #xmlattr{name = 'method', value = "post"}],
|
[?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)],
|
||||||
[?XE('table',
|
[?XE('table',
|
||||||
[?XE('tr',
|
[?XE('tr',
|
||||||
[?XC('td', ?T("User") ++ ":"),
|
[?XC('td', ?T("User") ++ ":"),
|
||||||
@ -1336,7 +1347,7 @@ list_users(Host, Query, Lang, URLFunc) ->
|
|||||||
]),
|
]),
|
||||||
?XE('tr',
|
?XE('tr',
|
||||||
[?X('td'),
|
[?X('td'),
|
||||||
?XAE('td', [#xmlattr{name = 'class', value = "alignright"}],
|
?XAE('td', [?XMLATTR('class', <<"alignright">>)],
|
||||||
[?INPUTT("submit", "addnewuser", "Add User")]),
|
[?INPUTT("submit", "addnewuser", "Add User")]),
|
||||||
?X('td')
|
?X('td')
|
||||||
])]),
|
])]),
|
||||||
@ -1352,7 +1363,9 @@ list_users_parse_query(Query, Host) ->
|
|||||||
{value, {_, Password}} =
|
{value, {_, Password}} =
|
||||||
lists:keysearch("newuserpassword", 1, Query),
|
lists:keysearch("newuserpassword", 1, Query),
|
||||||
try
|
try
|
||||||
#jid{node = User, domain = Server} = exmpp_jid:list_to_jid(Username++"@"++Host),
|
JID = exmpp_jid:parse_jid(Username++"@"++Host),
|
||||||
|
User = exmpp_jid:node(JID),
|
||||||
|
Server = exmpp_jid:domain(JID),
|
||||||
case ejabberd_auth:try_register(User, Server, Password) of
|
case ejabberd_auth:try_register(User, Server, Password) of
|
||||||
{error, _Reason} ->
|
{error, _Reason} ->
|
||||||
error;
|
error;
|
||||||
@ -1519,7 +1532,7 @@ user_info(User, Server, Query, Lang) ->
|
|||||||
error -> [?XREST("Bad format")];
|
error -> [?XREST("Bad format")];
|
||||||
nothing -> []
|
nothing -> []
|
||||||
end ++
|
end ++
|
||||||
[?XAE('form', [#xmlattr{name = 'action', value = ""}, #xmlattr{name = 'method', value = "post"}],
|
[?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)],
|
||||||
[?XCT('h3', "Connected Resources:")] ++ FResources ++
|
[?XCT('h3', "Connected Resources:")] ++ FResources ++
|
||||||
[?XCT('h3', "Password:")] ++ FPassword ++
|
[?XCT('h3', "Password:")] ++ FPassword ++
|
||||||
UserItems ++
|
UserItems ++
|
||||||
@ -1598,11 +1611,11 @@ list_last_activity(Host, Lang, Integral, Period) ->
|
|||||||
end,
|
end,
|
||||||
Max = lists:max(Hist),
|
Max = lists:max(Hist),
|
||||||
[?XAE('ol',
|
[?XAE('ol',
|
||||||
[#xmlattr{name = 'id', value = "lastactivity"}, #xmlattr{name = 'start', value = "0"}],
|
[?XMLATTR('id', <<"lastactivity">>), ?XMLATTR('start', <<"0">>)],
|
||||||
[?XAE('li',
|
[?XAE('li',
|
||||||
[#xmlattr{name = 'style', value =
|
[?XMLATTR('style',
|
||||||
"width:" ++ integer_to_list(
|
"width:" ++ integer_to_list(
|
||||||
trunc(90 * V / Max)) ++ "%;"}],
|
trunc(90 * V / Max)) ++ "%;")],
|
||||||
[#xmlcdata{cdata = list_to_binary(integer_to_list(V))}])
|
[#xmlcdata{cdata = list_to_binary(integer_to_list(V))}])
|
||||||
|| V <- Hist ++ Tail])]
|
|| V <- Hist ++ Tail])]
|
||||||
end
|
end
|
||||||
@ -1694,7 +1707,7 @@ get_node(global, Node, [], Query, Lang) ->
|
|||||||
?LI([?ACT(Base ++ "stats/", "Statistics")]),
|
?LI([?ACT(Base ++ "stats/", "Statistics")]),
|
||||||
?LI([?ACT(Base ++ "update/", "Update")])
|
?LI([?ACT(Base ++ "update/", "Update")])
|
||||||
] ++ MenuItems2),
|
] ++ MenuItems2),
|
||||||
?XAE('form', [#xmlattr{name = 'action', value = ""}, #xmlattr{name = 'method', value = "post"}],
|
?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)],
|
||||||
[?INPUTT('submit', "restart", "Restart"),
|
[?INPUTT('submit', "restart", "Restart"),
|
||||||
?C(" "),
|
?C(" "),
|
||||||
?INPUTT('submit', "stop", "Stop")])
|
?INPUTT('submit', "stop", "Stop")])
|
||||||
@ -1746,15 +1759,15 @@ get_node(global, Node, ["db"], Query, Lang) ->
|
|||||||
[?XC('td', STable),
|
[?XC('td', STable),
|
||||||
?XE('td', [db_storage_select(
|
?XE('td', [db_storage_select(
|
||||||
STable, Type, Lang)]),
|
STable, Type, Lang)]),
|
||||||
?XAC('td', [#xmlattr{name = 'class', value = "alignright"}],
|
?XAC('td', [?XMLATTR('class', <<"alignright">>)],
|
||||||
integer_to_list(Size)),
|
integer_to_list(Size)),
|
||||||
?XAC('td', [#xmlattr{name = 'class', value = "alignright"}],
|
?XAC('td', [?XMLATTR('class', <<"alignright">>)],
|
||||||
integer_to_list(Memory))
|
integer_to_list(Memory))
|
||||||
])
|
])
|
||||||
end, STables),
|
end, STables),
|
||||||
[?XC('h1', ?T("Database Tables at ") ++ atom_to_list(Node))] ++
|
[?XC('h1', ?T("Database Tables at ") ++ atom_to_list(Node))] ++
|
||||||
ResS ++
|
ResS ++
|
||||||
[?XAE('form', [#xmlattr{name = 'action', value = ""}, #xmlattr{name = 'method', value = "post"}],
|
[?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)],
|
||||||
[?XAE('table', [],
|
[?XAE('table', [],
|
||||||
[?XE('thead',
|
[?XE('thead',
|
||||||
[?XE('tr',
|
[?XE('tr',
|
||||||
@ -1766,8 +1779,8 @@ get_node(global, Node, ["db"], Query, Lang) ->
|
|||||||
?XE('tbody',
|
?XE('tbody',
|
||||||
Rows ++
|
Rows ++
|
||||||
[?XE('tr',
|
[?XE('tr',
|
||||||
[?XAE('td', [#xmlattr{name = 'colspan', value = "4"},
|
[?XAE('td', [?XMLATTR('colspan', <<"4">>),
|
||||||
#xmlattr{name = 'class', value = "alignright"}],
|
?XMLATTR('class', <<"alignright">>)],
|
||||||
[?INPUTT("submit", "submit",
|
[?INPUTT("submit", "submit",
|
||||||
"Submit")])
|
"Submit")])
|
||||||
])]
|
])]
|
||||||
@ -1783,7 +1796,7 @@ get_node(global, Node, ["backup"], Query, Lang) ->
|
|||||||
[?XC('h1', ?T("Backup of ") ++ atom_to_list(Node))] ++
|
[?XC('h1', ?T("Backup of ") ++ atom_to_list(Node))] ++
|
||||||
ResS ++
|
ResS ++
|
||||||
[?XCT('p', "Remark that these options will only backup the builtin Mnesia database. If you are using the ODBC module, you also need to backup your SQL database separately."),
|
[?XCT('p', "Remark that these options will only backup the builtin Mnesia database. If you are using the ODBC module, you also need to backup your SQL database separately."),
|
||||||
?XAE('form', [#xmlattr{name = 'action', value = <<>>}, #xmlattr{name = 'method', value = <<"post">>}],
|
?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)],
|
||||||
[?XAE('table', [],
|
[?XAE('table', [],
|
||||||
[?XE('tbody',
|
[?XE('tbody',
|
||||||
[?XE('tr',
|
[?XE('tr',
|
||||||
@ -1850,7 +1863,7 @@ get_node(global, Node, ["ports"], Query, Lang) ->
|
|||||||
{error, ReasonT} -> [?XRES(?T("Error") ++ ": " ++ ReasonT)];
|
{error, ReasonT} -> [?XRES(?T("Error") ++ ": " ++ ReasonT)];
|
||||||
nothing -> []
|
nothing -> []
|
||||||
end ++
|
end ++
|
||||||
[?XAE('form', [#xmlattr{name = 'action', value = ""}, #xmlattr{name = 'method', value = "post"}],
|
[?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)],
|
||||||
[node_ports_to_xhtml(NewPorts, Lang)])
|
[node_ports_to_xhtml(NewPorts, Lang)])
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -1874,7 +1887,7 @@ get_node(Host, Node, ["modules"], Query, Lang) when is_list(Host) ->
|
|||||||
error -> [?XREST("Bad format")];
|
error -> [?XREST("Bad format")];
|
||||||
nothing -> []
|
nothing -> []
|
||||||
end ++
|
end ++
|
||||||
[?XAE('form', [#xmlattr{name = 'action', value = ""}, #xmlattr{name = 'method', value = "post"}],
|
[?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)],
|
||||||
[node_modules_to_xhtml(NewModules, Lang)])
|
[node_modules_to_xhtml(NewModules, Lang)])
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -1897,25 +1910,25 @@ get_node(global, Node, ["stats"], _Query, Lang) ->
|
|||||||
?XAE('table', [],
|
?XAE('table', [],
|
||||||
[?XE('tbody',
|
[?XE('tbody',
|
||||||
[?XE('tr', [?XCT('td', "Uptime:"),
|
[?XE('tr', [?XCT('td', "Uptime:"),
|
||||||
?XAC('td', [#xmlattr{name = 'class', value = "alignright"}],
|
?XAC('td', [?XMLATTR('class', <<"alignright">>)],
|
||||||
UpTimeS)]),
|
UpTimeS)]),
|
||||||
?XE('tr', [?XCT('td', "CPU Time:"),
|
?XE('tr', [?XCT('td', "CPU Time:"),
|
||||||
?XAC('td', [#xmlattr{name = 'class', value = "alignright"}],
|
?XAC('td', [?XMLATTR('class', <<"alignright">>)],
|
||||||
CPUTimeS)]),
|
CPUTimeS)]),
|
||||||
?XE('tr', [?XCT('td', "Online Users:"),
|
?XE('tr', [?XCT('td', "Online Users:"),
|
||||||
?XAC('td', [#xmlattr{name = 'class', value = "alignright"}],
|
?XAC('td', [?XMLATTR('class', <<"alignright">>)],
|
||||||
integer_to_list(OnlineUsers))]),
|
integer_to_list(OnlineUsers))]),
|
||||||
?XE('tr', [?XCT('td', "Transactions Committed:"),
|
?XE('tr', [?XCT('td', "Transactions Committed:"),
|
||||||
?XAC('td', [#xmlattr{name = 'class', value = "alignright"}],
|
?XAC('td', [?XMLATTR('class', <<"alignright">>)],
|
||||||
integer_to_list(TransactionsCommitted))]),
|
integer_to_list(TransactionsCommitted))]),
|
||||||
?XE('tr', [?XCT('td', "Transactions Aborted:"),
|
?XE('tr', [?XCT('td', "Transactions Aborted:"),
|
||||||
?XAC('td', [#xmlattr{name = 'class', value = "alignright"}],
|
?XAC('td', [?XMLATTR('class', <<"alignright">>)],
|
||||||
integer_to_list(TransactionsAborted))]),
|
integer_to_list(TransactionsAborted))]),
|
||||||
?XE('tr', [?XCT('td', "Transactions Restarted:"),
|
?XE('tr', [?XCT('td', "Transactions Restarted:"),
|
||||||
?XAC('td', [#xmlattr{name = 'class', value = "alignright"}],
|
?XAC('td', [?XMLATTR('class', <<"alignright">>)],
|
||||||
integer_to_list(TransactionsRestarted))]),
|
integer_to_list(TransactionsRestarted))]),
|
||||||
?XE('tr', [?XCT('td', "Transactions Logged:"),
|
?XE('tr', [?XCT('td', "Transactions Logged:"),
|
||||||
?XAC('td', [#xmlattr{name = 'class', value = "alignright"}],
|
?XAC('td', [?XMLATTR('class', <<"alignright">>)],
|
||||||
integer_to_list(TransactionsLogged))])
|
integer_to_list(TransactionsLogged))])
|
||||||
])
|
])
|
||||||
])];
|
])];
|
||||||
@ -1943,7 +1956,7 @@ get_node(global, Node, ["update"], Query, Lang) ->
|
|||||||
error -> [?XREST("Bad format")];
|
error -> [?XREST("Bad format")];
|
||||||
nothing -> []
|
nothing -> []
|
||||||
end ++
|
end ++
|
||||||
[?XAE('form', [#xmlattr{name = 'action', value = ""}, #xmlattr{name = 'method', value = "post"}],
|
[?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)],
|
||||||
[
|
[
|
||||||
?XCT('h2', "Update plan"),
|
?XCT('h2', "Update plan"),
|
||||||
?XCT('h3', "Modified modules"), Mods,
|
?XCT('h3', "Modified modules"), Mods,
|
||||||
@ -1991,15 +2004,15 @@ node_parse_query(Node, Query) ->
|
|||||||
|
|
||||||
|
|
||||||
db_storage_select(ID, Opt, Lang) ->
|
db_storage_select(ID, Opt, Lang) ->
|
||||||
?XAE('select', [#xmlattr{name = 'name', value = "table" ++ ID}],
|
?XAE('select', [?XMLATTR('name', "table" ++ ID)],
|
||||||
lists:map(
|
lists:map(
|
||||||
fun({O, Desc}) ->
|
fun({O, Desc}) ->
|
||||||
Sel = if
|
Sel = if
|
||||||
O == Opt -> [#xmlattr{name = 'selected', value = "selected"}];
|
O == Opt -> [?XMLATTR('selected', <<"selected">>)];
|
||||||
true -> []
|
true -> []
|
||||||
end,
|
end,
|
||||||
?XACT('option',
|
?XACT('option',
|
||||||
Sel ++ [#xmlattr{name = 'value', value = atom_to_list(O)}],
|
Sel ++ [?XMLATTR('value', O)],
|
||||||
Desc)
|
Desc)
|
||||||
end, [{ram_copies, "RAM copy"},
|
end, [{ram_copies, "RAM copy"},
|
||||||
{disc_copies, "RAM and disc copy"},
|
{disc_copies, "RAM and disc copy"},
|
||||||
@ -2088,7 +2101,7 @@ node_backup_parse_query(Node, Query) ->
|
|||||||
|
|
||||||
|
|
||||||
node_ports_to_xhtml(Ports, Lang) ->
|
node_ports_to_xhtml(Ports, Lang) ->
|
||||||
?XAE('table', [#xmlattr{name = 'class', value = <<"withtextareas">>}],
|
?XAE('table', [?XMLATTR('class', <<"withtextareas">>)],
|
||||||
[?XE('thead',
|
[?XE('thead',
|
||||||
[?XE('tr',
|
[?XE('tr',
|
||||||
[?XCT('td', "Port"),
|
[?XCT('td', "Port"),
|
||||||
@ -2105,8 +2118,8 @@ node_ports_to_xhtml(Ports, Lang) ->
|
|||||||
{NumLines, SOptsClean} = term_to_paragraph(OptsClean, 40),
|
{NumLines, SOptsClean} = term_to_paragraph(OptsClean, 40),
|
||||||
%%ID = term_to_id(E),
|
%%ID = term_to_id(E),
|
||||||
?XE('tr',
|
?XE('tr',
|
||||||
[?XAE('td', [#xmlattr{name = 'size', value = <<"6">>}], [?C(SPort)]),
|
[?XAE('td', [?XMLATTR('size', <<"6">>)], [?C(SPort)]),
|
||||||
?XAE('td', [#xmlattr{name = 'size', value = <<"15">>}], [?C(SIP)]),
|
?XAE('td', [?XMLATTR('size', <<"15">>)], [?C(SIP)]),
|
||||||
?XE('td', [?INPUTS("text", "module" ++ SSPort,
|
?XE('td', [?INPUTS("text", "module" ++ SSPort,
|
||||||
SModule, "15")]),
|
SModule, "15")]),
|
||||||
?XE('td', [?TEXTAREA("opts" ++ SSPort, integer_to_list(NumLines), "35", SOptsClean)]),
|
?XE('td', [?TEXTAREA("opts" ++ SSPort, integer_to_list(NumLines), "35", SOptsClean)]),
|
||||||
@ -2199,7 +2212,7 @@ node_ports_parse_query(Node, Ports, Query) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
node_modules_to_xhtml(Modules, Lang) ->
|
node_modules_to_xhtml(Modules, Lang) ->
|
||||||
?XAE('table', [#xmlattr{name = 'class', value = <<"withtextareas">>}],
|
?XAE('table', [?XMLATTR('class', <<"withtextareas">>)],
|
||||||
[?XE('thead',
|
[?XE('thead',
|
||||||
[?XE('tr',
|
[?XE('tr',
|
||||||
[?XCT('td', "Module"),
|
[?XCT('td', "Module"),
|
||||||
@ -2424,14 +2437,14 @@ make_menu_items2(Lang, Deep, {MURI, MName, [Item | Items]}, Res) ->
|
|||||||
make_menu_items2(Lang, Deep, {MURI, MName, Items}, Res2).
|
make_menu_items2(Lang, Deep, {MURI, MName, Items}, Res2).
|
||||||
|
|
||||||
make_menu_item(header, 1, URI, Name, _Lang) ->
|
make_menu_item(header, 1, URI, Name, _Lang) ->
|
||||||
?LI([?XAE('div', [#xmlattr{name = 'id', value = <<"navhead">>}], [?AC(URI, Name)] )]);
|
?LI([?XAE('div', [?XMLATTR('id', <<"navhead">>)], [?AC(URI, Name)] )]);
|
||||||
make_menu_item(header, 2, URI, Name, _Lang) ->
|
make_menu_item(header, 2, URI, Name, _Lang) ->
|
||||||
?LI([?XAE('div', [#xmlattr{name = 'id', value = <<"navheadsub">>}], [?AC(URI, Name)] )]);
|
?LI([?XAE('div', [?XMLATTR('id', <<"navheadsub">>)], [?AC(URI, Name)] )]);
|
||||||
make_menu_item(header, 3, URI, Name, _Lang) ->
|
make_menu_item(header, 3, URI, Name, _Lang) ->
|
||||||
?LI([?XAE('div', [#xmlattr{name = 'id', value = <<"navheadsubsub">>}], [?AC(URI, Name)] )]);
|
?LI([?XAE('div', [?XMLATTR('id', <<"navheadsubsub">>)], [?AC(URI, Name)] )]);
|
||||||
make_menu_item(item, 1, URI, Name, Lang) ->
|
make_menu_item(item, 1, URI, Name, Lang) ->
|
||||||
?LI([?XAE('div', [#xmlattr{name = 'id', value = "navitem"}], [?ACT(URI, Name)] )]);
|
?LI([?XAE('div', [?XMLATTR('id', <<"navitem">>)], [?ACT(URI, Name)] )]);
|
||||||
make_menu_item(item, 2, URI, Name, Lang) ->
|
make_menu_item(item, 2, URI, Name, Lang) ->
|
||||||
?LI([?XAE('div', [#xmlattr{name = 'id', value = "navitemsub"}], [?ACT(URI, Name)] )]);
|
?LI([?XAE('div', [?XMLATTR('id', <<"navitemsub">>)], [?ACT(URI, Name)] )]);
|
||||||
make_menu_item(item, 3, URI, Name, Lang) ->
|
make_menu_item(item, 3, URI, Name, Lang) ->
|
||||||
?LI([?XAE('div', [#xmlattr{name = 'id', value = "navitemsubsub"}], [?ACT(URI, Name)] )]).
|
?LI([?XAE('div', [?XMLATTR('id', <<"navitemsubsub">>)], [?ACT(URI, Name)] )]).
|
||||||
|
Loading…
Reference in New Issue
Block a user