25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-20 17:27:00 +01:00

* src/ejabberd_socket.erl: Support for non-xml sockets

* src/ejabberd_c2s.erl: Likewise
* src/ejabberd_s2s_in.erl: Likewise
* src/ejabberd_service.erl: Likewise
* src/web/ejabberd_http.erl: Likewise

SVN Revision: 629
This commit is contained in:
Alexey Shchepin 2006-09-25 03:51:11 +00:00
parent 9ababf2a1d
commit aa478100d8
6 changed files with 65 additions and 28 deletions

View File

@ -1,20 +1,29 @@
2006-09-25 Alexey Shchepin <alexey@sevcom.net>
* src/ejabberd_socket.erl: Support for non-xml sockets
* src/ejabberd_c2s.erl: Likewise
* src/ejabberd_s2s_in.erl: Likewise
* src/ejabberd_service.erl: Likewise
* src/web/ejabberd_http.erl: Likewise
2006-09-24 Mickael Remond <mickael.remond@process-one.net> 2006-09-24 Mickael Remond <mickael.remond@process-one.net>
* src/msgs/es.msg: Updated Spanish translation (thanks to Badlop). * src/msgs/es.msg: Updated Spanish translation (thanks to Badlop).
* src/mod_muc/mod_muc_room.erl: Strings update (thanks to Serguei * src/mod_muc/mod_muc_room.erl: Strings update (thanks to Sergei
Golovan). Golovan).
* src/msgs/ru.msg: Updated Russian translation (thanks to Serguei * src/msgs/ru.msg: Updated Russian translation (thanks to Sergei
Golovan). Golovan).
* src/msgs/uk.msg: Updated Ukrainian translation (thanks to Serguei * src/msgs/uk.msg: Updated Ukrainian translation (thanks to Sergei
Golovan). Golovan).
* src/msgs/fr.msg: Update French translation. * src/msgs/fr.msg: Update French translation.
* src/doc/guide.html: Minor W3C compliance fix in an Hevea * src/doc/guide.html: Minor W3C compliance fix in an Hevea
generated URL. generated URL.
* src/doc/features.html: Added to be consistent (guide.html is in the * src/doc/features.html: Added to be consistent (guide.html is in
repository to make Latex optional, but still allow access to the doc). the repository to make Latex optional, but still allow access to
the doc).
2006-09-23 Mickael Remond <mickael.remond@process-one.net> 2006-09-23 Mickael Remond <mickael.remond@process-one.net>

View File

@ -17,6 +17,7 @@
start_link/2, start_link/2,
send_text/2, send_text/2,
send_element/2, send_element/2,
socket_type/0,
get_presence/1]). get_presence/1]).
%% gen_fsm callbacks %% gen_fsm callbacks
@ -98,6 +99,9 @@ start(SockData, Opts) ->
start_link(SockData, Opts) -> start_link(SockData, Opts) ->
gen_fsm:start_link(ejabberd_c2s, [SockData, Opts], ?FSMOPTS). gen_fsm:start_link(ejabberd_c2s, [SockData, Opts], ?FSMOPTS).
socket_type() ->
xml_stream.
%% Return Username, Resource and presence information %% Return Username, Resource and presence information
get_presence(FsmRef) -> get_presence(FsmRef) ->
gen_fsm:sync_send_all_state_event(FsmRef, {get_presence}, 1000). gen_fsm:sync_send_all_state_event(FsmRef, {get_presence}, 1000).

View File

@ -14,7 +14,8 @@
%% External exports %% External exports
-export([start/2, -export([start/2,
start_link/2, start_link/2,
match_domain/2]). match_domain/2,
socket_type/0]).
%% gen_fsm callbacks %% gen_fsm callbacks
-export([init/1, -export([init/1,
@ -84,6 +85,9 @@ start(SockData, Opts) ->
start_link(SockData, Opts) -> start_link(SockData, Opts) ->
gen_fsm:start_link(ejabberd_s2s_in, [SockData, Opts], ?FSMOPTS). gen_fsm:start_link(ejabberd_s2s_in, [SockData, Opts], ?FSMOPTS).
socket_type() ->
xml_stream.
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% Callback functions from gen_fsm %%% Callback functions from gen_fsm
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------

View File

@ -16,7 +16,8 @@
-export([start/2, -export([start/2,
start_link/2, start_link/2,
send_text/2, send_text/2,
send_element/2]). send_element/2,
socket_type/0]).
%% gen_fsm callbacks %% gen_fsm callbacks
-export([init/1, -export([init/1,
@ -78,6 +79,9 @@ start(SockData, Opts) ->
start_link(SockData, Opts) -> start_link(SockData, Opts) ->
gen_fsm:start_link(ejabberd_service, [SockData, Opts], ?FSMOPTS). gen_fsm:start_link(ejabberd_service, [SockData, Opts], ?FSMOPTS).
socket_type() ->
xml_stream.
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% Callback functions from gen_fsm %%% Callback functions from gen_fsm
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------

View File

@ -32,23 +32,35 @@
%% Description: %% Description:
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
start(Module, SockMod, Socket, Opts) -> start(Module, SockMod, Socket, Opts) ->
MaxStanzaSize = case Module:socket_type() of
case lists:keysearch(max_stanza_size, 1, Opts) of xml_stream ->
{value, {_, Size}} -> Size; MaxStanzaSize =
_ -> infinity case lists:keysearch(max_stanza_size, 1, Opts) of
end, {value, {_, Size}} -> Size;
Receiver = ejabberd_receiver:start(Socket, SockMod, none, MaxStanzaSize), _ -> infinity
SocketData = #socket_state{sockmod = SockMod, end,
socket = Socket, Receiver = ejabberd_receiver:start(Socket, SockMod, none, MaxStanzaSize),
receiver = Receiver}, SocketData = #socket_state{sockmod = SockMod,
{ok, Pid} = Module:start(SocketData, Opts), socket = Socket,
case SockMod:controlling_process(Socket, Receiver) of receiver = Receiver},
ok -> {ok, Pid} = Module:start(SocketData, Opts),
ok; case SockMod:controlling_process(Socket, Receiver) of
{error, _Reason} -> ok ->
SockMod:close(Socket) ok;
end, {error, _Reason} ->
ejabberd_receiver:become_controller(Receiver, Pid). SockMod:close(Socket)
end,
ejabberd_receiver:become_controller(Receiver, Pid);
raw ->
{ok, Pid} = Module:start({SockMod, Socket}, Opts),
case SockMod:controlling_process(Socket, Pid) of
ok ->
ok;
{error, _Reason} ->
SockMod:close(Socket)
end,
ejabberd_receiver:become_controller(Pid)
end.
connect(Addr, Port, Opts) -> connect(Addr, Port, Opts) ->
case gen_tcp:connect(Addr, Port, Opts) of case gen_tcp:connect(Addr, Port, Opts) of
@ -66,7 +78,7 @@ connect(Addr, Port, Opts) ->
gen_tcp:close(Socket), gen_tcp:close(Socket),
Error Error
end; end;
{error, Reason} = Error -> {error, _Reason} = Error ->
Error Error
end. end.

View File

@ -14,6 +14,7 @@
-export([start/2, -export([start/2,
start_link/2, start_link/2,
become_controller/1, become_controller/1,
socket_type/0,
receive_headers/1, receive_headers/1,
url_encode/1]). url_encode/1]).
@ -85,6 +86,9 @@ start_link({SockMod, Socket}, Opts) ->
become_controller(_Pid) -> become_controller(_Pid) ->
ok. ok.
socket_type() ->
raw.
send_text(State, Text) -> send_text(State, Text) ->
(State#state.sockmod):send(State#state.socket, Text). (State#state.sockmod):send(State#state.socket, Text).