mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
More binary conversions
This commit is contained in:
parent
949705b04a
commit
5c0a1dde1c
@ -219,22 +219,22 @@ commands() ->
|
|||||||
#ejabberd_commands{name = kick_session, tags = [session],
|
#ejabberd_commands{name = kick_session, tags = [session],
|
||||||
desc = "Kick a user session",
|
desc = "Kick a user session",
|
||||||
module = ?MODULE, function = kick_session,
|
module = ?MODULE, function = kick_session,
|
||||||
args = [{user, string}, {host, string}, {resource, string}, {reason, string}],
|
args = [{user, binary}, {host, binary}, {resource, binary}, {reason, binary}],
|
||||||
result = {res, rescode}},
|
result = {res, rescode}},
|
||||||
#ejabberd_commands{name = status_num_host, tags = [session, stats],
|
#ejabberd_commands{name = status_num_host, tags = [session, stats],
|
||||||
desc = "Number of logged users with this status in host",
|
desc = "Number of logged users with this status in host",
|
||||||
module = ?MODULE, function = status_num,
|
module = ?MODULE, function = status_num,
|
||||||
args = [{host, string}, {status, string}],
|
args = [{host, binary}, {status, binary}],
|
||||||
result = {users, integer}},
|
result = {users, integer}},
|
||||||
#ejabberd_commands{name = status_num, tags = [session, stats],
|
#ejabberd_commands{name = status_num, tags = [session, stats],
|
||||||
desc = "Number of logged users with this status",
|
desc = "Number of logged users with this status",
|
||||||
module = ?MODULE, function = status_num,
|
module = ?MODULE, function = status_num,
|
||||||
args = [{status, string}],
|
args = [{status, binary}],
|
||||||
result = {users, integer}},
|
result = {users, integer}},
|
||||||
#ejabberd_commands{name = status_list_host, tags = [session],
|
#ejabberd_commands{name = status_list_host, tags = [session],
|
||||||
desc = "List of users logged in host with their statuses",
|
desc = "List of users logged in host with their statuses",
|
||||||
module = ?MODULE, function = status_list,
|
module = ?MODULE, function = status_list,
|
||||||
args = [{host, string}, {status, string}],
|
args = [{host, binary}, {status, binary}],
|
||||||
result = {users, {list,
|
result = {users, {list,
|
||||||
{userstatus, {tuple, [
|
{userstatus, {tuple, [
|
||||||
{user, string},
|
{user, string},
|
||||||
@ -247,7 +247,7 @@ commands() ->
|
|||||||
#ejabberd_commands{name = status_list, tags = [session],
|
#ejabberd_commands{name = status_list, tags = [session],
|
||||||
desc = "List of logged users with this status",
|
desc = "List of logged users with this status",
|
||||||
module = ?MODULE, function = status_list,
|
module = ?MODULE, function = status_list,
|
||||||
args = [{status, string}],
|
args = [{status, binary}],
|
||||||
result = {users, {list,
|
result = {users, {list,
|
||||||
{userstatus, {tuple, [
|
{userstatus, {tuple, [
|
||||||
{user, string},
|
{user, string},
|
||||||
@ -809,20 +809,20 @@ kick_session(User, Server, Resource, ReasonText) ->
|
|||||||
|
|
||||||
kick_this_session(User, Server, Resource, Reason) ->
|
kick_this_session(User, Server, Resource, Reason) ->
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
jlib:make_jid("", "", ""),
|
jlib:make_jid(<<>>, <<>>, <<>>),
|
||||||
jlib:make_jid(User, Server, Resource),
|
jlib:make_jid(User, Server, Resource),
|
||||||
{xmlelement, "broadcast", [], [{exit, Reason}]}).
|
{xmlel, <<"broadcast">>, [], [{exit, Reason}]}).
|
||||||
|
|
||||||
|
|
||||||
status_num(Host, Status) ->
|
status_num(Host, Status) ->
|
||||||
length(get_status_list(Host, Status)).
|
length(get_status_list(Host, Status)).
|
||||||
status_num(Status) ->
|
status_num(Status) ->
|
||||||
status_num("all", Status).
|
status_num(<<"all">>, Status).
|
||||||
status_list(Host, Status) ->
|
status_list(Host, Status) ->
|
||||||
Res = get_status_list(Host, Status),
|
Res = get_status_list(Host, Status),
|
||||||
[{U, S, R, P, St} || {U, S, R, P, St} <- Res].
|
[{U, S, R, P, St} || {U, S, R, P, St} <- Res].
|
||||||
status_list(Status) ->
|
status_list(Status) ->
|
||||||
status_list("all", Status).
|
status_list(<<"all">>, Status).
|
||||||
|
|
||||||
|
|
||||||
get_status_list(Host, Status_required) ->
|
get_status_list(Host, Status_required) ->
|
||||||
@ -831,7 +831,7 @@ get_status_list(Host, Status_required) ->
|
|||||||
%% Reformat the list
|
%% Reformat the list
|
||||||
Sessions2 = [ {Session#session.usr, Session#session.sid, Session#session.priority} || Session <- Sessions],
|
Sessions2 = [ {Session#session.usr, Session#session.sid, Session#session.priority} || Session <- Sessions],
|
||||||
Fhost = case Host of
|
Fhost = case Host of
|
||||||
"all" ->
|
<<"all">> ->
|
||||||
%% All hosts are requested, so dont filter at all
|
%% All hosts are requested, so dont filter at all
|
||||||
fun(_, _) -> true end;
|
fun(_, _) -> true end;
|
||||||
_ ->
|
_ ->
|
||||||
@ -843,7 +843,7 @@ get_status_list(Host, Status_required) ->
|
|||||||
Sessions4 = [ {ejabberd_c2s:get_presence(Pid), Server, Priority} || {Pid, Server, Priority} <- Sessions3],
|
Sessions4 = [ {ejabberd_c2s:get_presence(Pid), Server, Priority} || {Pid, Server, Priority} <- Sessions3],
|
||||||
%% Filter by status
|
%% Filter by status
|
||||||
Fstatus = case Status_required of
|
Fstatus = case Status_required of
|
||||||
"all" ->
|
<<"all">> ->
|
||||||
fun(_, _) -> true end;
|
fun(_, _) -> true end;
|
||||||
_ ->
|
_ ->
|
||||||
fun(A, B) -> A == B end
|
fun(A, B) -> A == B end
|
||||||
@ -882,18 +882,18 @@ dirty_get_sessions_list2() ->
|
|||||||
%% Make string more print-friendly
|
%% Make string more print-friendly
|
||||||
stringize(String) ->
|
stringize(String) ->
|
||||||
%% Replace newline characters with other code
|
%% Replace newline characters with other code
|
||||||
ejabberd_regexp:greplace(String, "\n", "\\n").
|
ejabberd_regexp:greplace(String, <<"\n">>, <<"\\n">>).
|
||||||
|
|
||||||
set_presence(User, Host, Resource, Type, Show, Status, Priority) ->
|
set_presence(User, Host, Resource, Type, Show, Status, Priority) ->
|
||||||
Pid = ejabberd_sm:get_session_pid(User, Host, Resource),
|
Pid = ejabberd_sm:get_session_pid(User, Host, Resource),
|
||||||
USR = User ++ "@" ++ Host ++ "/" ++ Resource,
|
USR = User ++ "@" ++ Host ++ "/" ++ Resource,
|
||||||
US = User ++ "@" ++ Host,
|
US = User ++ "@" ++ Host,
|
||||||
Message = {route_xmlstreamelement,
|
Message = {route_xmlstreamelement,
|
||||||
{xmlelement, "presence",
|
{xmlel, <<"presence">>,
|
||||||
[{"from", USR}, {"to", US}, {"type", Type}],
|
[{<<"from">>, USR}, {<<"to">>, US}, {<<"type">>, Type}],
|
||||||
[{xmlelement, "show", [], [{xmlcdata, Show}]},
|
[{xmlel, <<"show">>, [], [{xmlcdata, Show}]},
|
||||||
{xmlelement, "status", [], [{xmlcdata, Status}]},
|
{xmlel, <<"status">>, [], [{xmlcdata, Status}]},
|
||||||
{xmlelement, "priority", [], [{xmlcdata, Priority}]}]}},
|
{xmlel, <<"priority">>, [], [{xmlcdata, Priority}]}]}},
|
||||||
Pid ! Message.
|
Pid ! Message.
|
||||||
|
|
||||||
user_sessions_info(User, Host) ->
|
user_sessions_info(User, Host) ->
|
||||||
@ -929,14 +929,14 @@ user_sessions_info(User, Host) ->
|
|||||||
|
|
||||||
set_nickname(User, Host, Nickname) ->
|
set_nickname(User, Host, Nickname) ->
|
||||||
R = mod_vcard:process_sm_iq(
|
R = mod_vcard:process_sm_iq(
|
||||||
{jid, User, Host, "", User, Host, ""},
|
{jid, User, Host, <<>>, User, Host, <<>>},
|
||||||
{jid, User, Host, "", User, Host, ""},
|
{jid, User, Host, <<>>, User, Host, <<>>},
|
||||||
{iq, "", set, "", "en",
|
{iq, <<>>, set, <<>>, <<"en">>,
|
||||||
{xmlelement, "vCard",
|
{xmlel, <<"vCard">>, [
|
||||||
[{"xmlns", "vcard-temp"}], [
|
{<<"xmlns">>, <<"vcard-temp">>}], [
|
||||||
{xmlelement, "NICKNAME", [], [{xmlcdata, Nickname}]}
|
{xmlel, <<"NICKNAME">>, [], [{xmlcdata, Nickname}]}
|
||||||
]
|
]
|
||||||
}}),
|
}}),
|
||||||
case R of
|
case R of
|
||||||
{iq, [], result, [], _L, []} ->
|
{iq, [], result, [], _L, []} ->
|
||||||
ok;
|
ok;
|
||||||
@ -1046,7 +1046,7 @@ update_vcard_els(Data, ContentList, Els1) ->
|
|||||||
[D2] ->
|
[D2] ->
|
||||||
OldEl = case lists:keysearch(Data1, 2, Els2) of
|
OldEl = case lists:keysearch(Data1, 2, Els2) of
|
||||||
{value, A} -> A;
|
{value, A} -> A;
|
||||||
false -> {xmlelement, Data1, [], []}
|
false -> {xmlel, Data1, [], []}
|
||||||
end,
|
end,
|
||||||
{xmlel, _, _, ContentOld1} = OldEl,
|
{xmlel, _, _, ContentOld1} = OldEl,
|
||||||
Content2 = [{xmlel, D2, [], [{xmlcdata,Content}]} || Content <- ContentList],
|
Content2 = [{xmlel, D2, [], [{xmlcdata,Content}]} || Content <- ContentList],
|
||||||
@ -1118,7 +1118,7 @@ make_roster_xmlrpc(Roster) ->
|
|||||||
Subs = atom_to_list(Item#roster.subscription),
|
Subs = atom_to_list(Item#roster.subscription),
|
||||||
Ask = atom_to_list(Item#roster.ask),
|
Ask = atom_to_list(Item#roster.ask),
|
||||||
Groups = case Item#roster.groups of
|
Groups = case Item#roster.groups of
|
||||||
[] -> [""];
|
[] -> [<<>>];
|
||||||
Gs -> Gs
|
Gs -> Gs
|
||||||
end,
|
end,
|
||||||
ItemsX = [{JIDS, Nick, Subs, Ask, Group} || Group <- Groups],
|
ItemsX = [{JIDS, Nick, Subs, Ask, Group} || Group <- Groups],
|
||||||
@ -1134,7 +1134,7 @@ make_roster_xmlrpc(Roster) ->
|
|||||||
|
|
||||||
push_roster(File, User, Server) ->
|
push_roster(File, User, Server) ->
|
||||||
{ok, [Roster]} = file:consult(File),
|
{ok, [Roster]} = file:consult(File),
|
||||||
subscribe_roster({User, Server, "", User}, Roster).
|
subscribe_roster({User, Server, <<>>, User}, Roster).
|
||||||
|
|
||||||
push_roster_all(File) ->
|
push_roster_all(File) ->
|
||||||
{ok, [Roster]} = file:consult(File),
|
{ok, [Roster]} = file:consult(File),
|
||||||
@ -1202,7 +1202,7 @@ build_roster_item(U, S, remove) ->
|
|||||||
|
|
||||||
build_iq_roster_push(Item) ->
|
build_iq_roster_push(Item) ->
|
||||||
{xmlel, <<"iq">>,
|
{xmlel, <<"iq">>,
|
||||||
[{<<"type">>, <<"set">>}, {<<"id">>, <<"pushaaa">>}],
|
[{<<"type">>, <<"set">>}, {<<"id">>, <<"push">>}],
|
||||||
[{xmlel, <<"query">>,
|
[{xmlel, <<"query">>,
|
||||||
[{<<"xmlns">>, ?NS_ROSTER}],
|
[{<<"xmlns">>, ?NS_ROSTER}],
|
||||||
[Item]
|
[Item]
|
||||||
@ -1214,11 +1214,10 @@ build_broadcast(U, S, {add, _Nick, Subs, _Group}) ->
|
|||||||
build_broadcast(U, S, list_to_atom(binary_to_list(Subs)));
|
build_broadcast(U, S, list_to_atom(binary_to_list(Subs)));
|
||||||
build_broadcast(U, S, remove) ->
|
build_broadcast(U, S, remove) ->
|
||||||
build_broadcast(U, S, none);
|
build_broadcast(U, S, none);
|
||||||
%% @spec (U::string(), S::string(), Subs::atom()) -> any()
|
%% @spec (U::binary(), S::binary(), Subs::atom()) -> any()
|
||||||
%% Subs = both | from | to | none
|
%% Subs = both | from | to | none
|
||||||
build_broadcast(U, S, SubsAtom) when is_atom(SubsAtom) ->
|
build_broadcast(U, S, SubsAtom) when is_atom(SubsAtom) ->
|
||||||
{broadcast, {item, {U, S, <<>>}, SubsAtom}
|
{broadcast, {item, {U, S, <<>>}, SubsAtom}}.
|
||||||
}.
|
|
||||||
|
|
||||||
%%%
|
%%%
|
||||||
%%% Last Activity
|
%%% Last Activity
|
||||||
@ -1260,15 +1259,15 @@ set_last(User, Server, Timestamp, Status) ->
|
|||||||
%% <aa xmlns='bb'>Cluth</aa>
|
%% <aa xmlns='bb'>Cluth</aa>
|
||||||
|
|
||||||
private_get(Username, Host, Element, Ns) ->
|
private_get(Username, Host, Element, Ns) ->
|
||||||
From = jlib:make_jid(Username, Host, ""),
|
From = jlib:make_jid(Username, Host, <<>>),
|
||||||
To = jlib:make_jid(Username, Host, ""),
|
To = jlib:make_jid(Username, Host, <<>>),
|
||||||
IQ = {iq, "", get, ?NS_PRIVATE, "",
|
IQ = {iq, <<>>, get, ?NS_PRIVATE, <<>>,
|
||||||
{xmlelement,"query",
|
{xmlel, <<"query">>,
|
||||||
[{"xmlns",?NS_PRIVATE}],
|
[{<<"xmlns">>,?NS_PRIVATE}],
|
||||||
[{xmlelement, Element, [{"xmlns", Ns}], []}]}},
|
[{xmlel, Element, [{<<"xmlns">>, Ns}], []}]}},
|
||||||
ResIq = mod_private:process_sm_iq(From, To, IQ),
|
ResIq = mod_private:process_sm_iq(From, To, IQ),
|
||||||
[{xmlelement,"query",
|
[{xmlel, <<"query">>,
|
||||||
[{"xmlns","jabber:iq:private"}],
|
[{<<"xmlns">>, <<"jabber:iq:private">>}],
|
||||||
[SubEl]}] = ResIq#iq.sub_el,
|
[SubEl]}] = ResIq#iq.sub_el,
|
||||||
xml:element_to_string(SubEl).
|
xml:element_to_string(SubEl).
|
||||||
|
|
||||||
@ -1283,11 +1282,11 @@ private_set(Username, Host, ElementString) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
private_set2(Username, Host, Xml) ->
|
private_set2(Username, Host, Xml) ->
|
||||||
From = jlib:make_jid(Username, Host, ""),
|
From = jlib:make_jid(Username, Host, <<>>),
|
||||||
To = jlib:make_jid(Username, Host, ""),
|
To = jlib:make_jid(Username, Host, <<>>),
|
||||||
IQ = {iq, "", set, ?NS_PRIVATE, "",
|
IQ = {iq, <<>>, set, ?NS_PRIVATE, <<>>,
|
||||||
{xmlelement,"query",
|
{xmlel, <<"query">>,
|
||||||
[{"xmlns",?NS_PRIVATE}],
|
[{<<"xmlns">>, ?NS_PRIVATE}],
|
||||||
[Xml]}},
|
[Xml]}},
|
||||||
mod_private:process_sm_iq(From, To, IQ),
|
mod_private:process_sm_iq(From, To, IQ),
|
||||||
ok.
|
ok.
|
||||||
@ -1324,7 +1323,7 @@ srg_get_info(Group, Host) ->
|
|||||||
|
|
||||||
srg_get_members(Group, Host) ->
|
srg_get_members(Group, Host) ->
|
||||||
Members = mod_shared_roster:get_group_explicit_users(Host,Group),
|
Members = mod_shared_roster:get_group_explicit_users(Host,Group),
|
||||||
[jlib:jid_to_string(jlib:make_jid(MUser, MServer, <<"">>))
|
[jlib:jid_to_string(jlib:make_jid(MUser, MServer, <<>>))
|
||||||
|| {MUser, MServer} <- Members].
|
|| {MUser, MServer} <- Members].
|
||||||
|
|
||||||
srg_user_add(User, Host, Group, GroupHost) ->
|
srg_user_add(User, Host, Group, GroupHost) ->
|
||||||
@ -1366,7 +1365,7 @@ send_packet_all_resources(FromJIDString, ToJIDString, Packet) ->
|
|||||||
ToUser = ToJID#jid.user,
|
ToUser = ToJID#jid.user,
|
||||||
ToServer = ToJID#jid.server,
|
ToServer = ToJID#jid.server,
|
||||||
case ToJID#jid.resource of
|
case ToJID#jid.resource of
|
||||||
"" ->
|
<<>> ->
|
||||||
send_packet_all_resources(FromJID, ToUser, ToServer, Packet);
|
send_packet_all_resources(FromJID, ToUser, ToServer, Packet);
|
||||||
Res ->
|
Res ->
|
||||||
send_packet_all_resources(FromJID, ToUser, ToServer, Res, Packet)
|
send_packet_all_resources(FromJID, ToUser, ToServer, Res, Packet)
|
||||||
@ -1375,7 +1374,7 @@ send_packet_all_resources(FromJIDString, ToJIDString, Packet) ->
|
|||||||
send_packet_all_resources(FromJID, ToUser, ToServer, Packet) ->
|
send_packet_all_resources(FromJID, ToUser, ToServer, Packet) ->
|
||||||
case ejabberd_sm:get_user_resources(ToUser, ToServer) of
|
case ejabberd_sm:get_user_resources(ToUser, ToServer) of
|
||||||
[] ->
|
[] ->
|
||||||
send_packet_all_resources(FromJID, ToUser, ToServer, "", Packet);
|
send_packet_all_resources(FromJID, ToUser, ToServer, <<>>, Packet);
|
||||||
ToResources ->
|
ToResources ->
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(ToResource) ->
|
fun(ToResource) ->
|
||||||
@ -1391,15 +1390,15 @@ send_packet_all_resources(FromJID, ToU, ToS, ToR, Packet) ->
|
|||||||
|
|
||||||
|
|
||||||
build_packet(message_chat, [Body]) ->
|
build_packet(message_chat, [Body]) ->
|
||||||
{xmlelement, "message",
|
{xmlel, <<"message">>,
|
||||||
[{"type", "chat"}, {"id", randoms:get_string()}],
|
[{<<"type">>, <<"chat">>}, {<<"id">>, randoms:get_string()}],
|
||||||
[{xmlelement, "body", [], [{xmlcdata, Body}]}]
|
[{xmlel, <<"body">>, [], [{xmlcdata, Body}]}]
|
||||||
};
|
};
|
||||||
build_packet(message_headline, [Subject, Body]) ->
|
build_packet(message_headline, [Subject, Body]) ->
|
||||||
{xmlelement, "message",
|
{xmlel, <<"message">>,
|
||||||
[{"type", "headline"}, {"id", randoms:get_string()}],
|
[{<<"type">>, <<"headline">>}, {<<"id">>, randoms:get_string()}],
|
||||||
[{xmlelement, "subject", [], [{xmlcdata, Subject}]},
|
[{xmlel, <<"subject">>, [], [{xmlcdata, Subject}]},
|
||||||
{xmlelement, "body", [], [{xmlcdata, Body}]}
|
{xmlel, <<"body">>, [], [{xmlcdata, Body}]}
|
||||||
]
|
]
|
||||||
}.
|
}.
|
||||||
|
|
||||||
@ -1412,7 +1411,7 @@ privacy_set(Username, Host, QueryS) ->
|
|||||||
From = jlib:string_to_jid(Username ++ "@" ++ Host),
|
From = jlib:string_to_jid(Username ++ "@" ++ Host),
|
||||||
To = jlib:string_to_jid(Host),
|
To = jlib:string_to_jid(Host),
|
||||||
QueryEl = xml_stream:parse_element(QueryS),
|
QueryEl = xml_stream:parse_element(QueryS),
|
||||||
StanzaEl = {xmlelement, "iq", [{"type", "set"}], [QueryEl]},
|
StanzaEl = {xmlel, <<"iq">>, [{<<"type">>, <<"set">>}], [QueryEl]},
|
||||||
IQ = jlib:iq_query_info(StanzaEl),
|
IQ = jlib:iq_query_info(StanzaEl),
|
||||||
ejabberd_hooks:run_fold(
|
ejabberd_hooks:run_fold(
|
||||||
privacy_iq_set,
|
privacy_iq_set,
|
||||||
|
Loading…
Reference in New Issue
Block a user