* 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>
* src/msgs/es.msg: Updated Spanish translation (thanks to Badlop).
* src/mod_muc/mod_muc_room.erl: Strings update (thanks to Serguei
Golovan).
* src/msgs/ru.msg: Updated Russian translation (thanks to Serguei
Golovan).
* src/msgs/uk.msg: Updated Ukrainian translation (thanks to Serguei
Golovan).
* src/mod_muc/mod_muc_room.erl: Strings update (thanks to Sergei
Golovan).
* src/msgs/ru.msg: Updated Russian translation (thanks to Sergei
Golovan).
* src/msgs/uk.msg: Updated Ukrainian translation (thanks to Sergei
Golovan).
* src/msgs/fr.msg: Update French translation.
* src/doc/guide.html: Minor W3C compliance fix in an Hevea
generated URL.
* src/doc/features.html: Added to be consistent (guide.html is in the
repository to make Latex optional, but still allow access to the doc).
* src/doc/features.html: Added to be consistent (guide.html is in
the repository to make Latex optional, but still allow access to
the doc).
2006-09-23 Mickael Remond <mickael.remond@process-one.net>

View File

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

View File

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

View File

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

View File

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

View File

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