%%----------------------------------------------------------------------
wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
- DefaultLang = case ?MYLANG of
- undefined -> <<"en">>;
- DL -> DL
- end,
+ DefaultLang = ?MYLANG,
case xml:get_attr_s(<<"xmlns:stream">>, Attrs) of
?NS_STREAM ->
Server = jlib:nameprep(xml:get_attr_s(<<"to">>, Attrs)),
undefined -> http;
_ -> httph
end,
- case erlang:decode_packet(PktType, Data) of
+ case erlang:decode_packet(PktType, Data, []) of
{ok, Pkt, Rest} ->
NewState = process_header(State#state{trail = Rest}, {ok, Pkt}),
case NewState#state.end_of_request of
reset_stream(Pid) -> do_call(Pid, reset_stream).
--spec starttls(pid(), iodata()) -> {ok, p1_tls:tls_socket()} | {error, any()}.
+-spec starttls(pid(), p1_tls:tls_socket()) -> ok.
starttls(Pid, TLSSocket) ->
do_call(Pid, {starttls, TLSSocket}).
%% once a server is temporarly blocked, it stay blocked for 60 seconds
--record(s2s, {fromto = {<<"">>, <<"">>} :: {binary(), binary()},
- pid = self() :: pid() | '_',
+-record(s2s, {fromto = {<<"">>, <<"">>} :: {binary(), binary()} | '_',
+ pid = self() :: pid() | '_' | '$1',
key = <<"">> :: binary() | '_'}).
-record(state, {}).
opts = [] :: list() | '_'}).
-record(muc_online_room,
- {name_host = {<<"">>, <<"">>} :: {binary(), binary()} | '$1',
- pid = self() :: pid() | '$2' | '_'}).
+ {name_host = {<<"">>, <<"">>} :: {binary(), binary()} | '$1' |
+ {'_', binary()} | '_',
+ pid = self() :: pid() | '$2' | '_' | '$1'}).
-record(muc_registered,
{us_host = {{<<"">>, <<"">>}, <<"">>} :: {{binary(), binary()}, binary()} | '$1',
update_muc_room_table(Host),
update_muc_registered_table(Host).
-update_muc_room_table(Host) ->
+update_muc_room_table(_Host) ->
Fields = record_info(fields, muc_room),
case mnesia:table_info(muc_room, attributes) of
Fields ->
mnesia:transform_table(muc_room, ignore, Fields)
end.
-update_muc_registered_table(Host) ->
+update_muc_registered_table(_Host) ->
Fields = record_info(fields, muc_registered),
case mnesia:table_info(muc_registered, attributes) of
Fields ->
remove_old_messages/2,
remove_user/2,
get_queue_length/2,
+ get_offline_els/2,
webadmin_page/3,
webadmin_user/4,
webadmin_user_parse_query/5]).
Res = user_queue(U, Host, Query, Lang), {stop, Res};
webadmin_page(Acc, _, _) -> Acc.
+get_offline_els(LUser, LServer) ->
+ get_offline_els(LUser, LServer, gen_mod:db_type(LServer, ?MODULE)).
+
+get_offline_els(LUser, LServer, mnesia) ->
+ Msgs = read_all_msgs(LUser, LServer, mnesia),
+ lists:map(
+ fun(Msg) ->
+ {route, From, To, Packet} = offline_msg_to_route(LServer, Msg),
+ jlib:replace_from_to(From, To, Packet)
+ end, Msgs);
+get_offline_els(LUser, LServer, odbc) ->
+ Username = ejabberd_odbc:escape(LUser),
+ case catch ejabberd_odbc:sql_query(LServer,
+ [<<"select xml from spool where username='">>,
+ Username, <<"' order by seq;">>]) of
+ {selected, [<<"xml">>], Rs} ->
+ lists:flatmap(
+ fun([XML]) ->
+ case xml_stream:parse_element(XML) of
+ #xmlel{} = El ->
+ case offline_msg_to_route(LServer, El) of
+ {route, _, _, NewEl} ->
+ [NewEl];
+ error ->
+ []
+ end;
+ _ ->
+ []
+ end
+ end, Rs);
+ _ ->
+ []
+ end.
+
offline_msg_to_route(LServer, #offline_msg{} = R) ->
El = #xmlel{children = Els} = R#offline_msg.packet,
{route, R#offline_msg.from, R#offline_msg.to,