mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
*** empty log message ***
SVN Revision: 15
This commit is contained in:
parent
534b6925a3
commit
727795239a
@ -113,7 +113,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
|
||||
{next_state, session_established,
|
||||
StateData#state{user = U, resource = R}};
|
||||
_ ->
|
||||
Err = jlib:make_error_reply(El, "404", "Unauthorized"),
|
||||
Err = jlib:make_error_reply(El, "401", "Unauthorized"),
|
||||
send_element(StateData#state.sender, Err),
|
||||
{next_state, wait_for_auth, StateData}
|
||||
end;
|
||||
@ -164,6 +164,9 @@ session_established({xmlstreamelement, El}, StateData) ->
|
||||
end,
|
||||
{next_state, session_established, StateData};
|
||||
|
||||
session_established({xmlstreamend, Name}, StateData) ->
|
||||
{stop, normal, StateData};
|
||||
|
||||
session_established(closed, StateData) ->
|
||||
% TODO
|
||||
{stop, normal, StateData}.
|
||||
|
@ -10,36 +10,100 @@
|
||||
-author('alexey@sevcom.net').
|
||||
-vsn('$Revision$ ').
|
||||
|
||||
%%-export([Function/Arity, ...]).
|
||||
-export([start/0, init/0]).
|
||||
|
||||
-export([start/0,init/0]).
|
||||
-export([register_iq_handler/3]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
|
||||
-record(state, {mydomain, iqtable}).
|
||||
|
||||
start() ->
|
||||
spawn(ejabberd_local, init, []).
|
||||
register(ejabberd_local, spawn(ejabberd_local, init, [])),
|
||||
mod_register:start(),
|
||||
ok.
|
||||
|
||||
init() ->
|
||||
ejabberd_router:register_local_route(?MYNAME),
|
||||
loop().
|
||||
MyDomain = ?MYNAME,
|
||||
ejabberd_router:register_local_route(MyDomain),
|
||||
loop(#state{mydomain = MyDomain,
|
||||
iqtable = ets:new(iqtable, [])}).
|
||||
|
||||
loop() ->
|
||||
loop(State) ->
|
||||
receive
|
||||
{route, From, To, Packet} ->
|
||||
do_route(From, To, Packet),
|
||||
loop()
|
||||
do_route(State, From, To, Packet),
|
||||
loop(State);
|
||||
{register_iq_handler, XMLNS, Module, Function} ->
|
||||
ets:insert(State#state.iqtable, {XMLNS, Module, Function}),
|
||||
loop(State)
|
||||
end.
|
||||
|
||||
|
||||
do_route(From, To, Packet) ->
|
||||
do_route(State, From, To, Packet) ->
|
||||
?DEBUG("local route~n\tfrom ~p~n\tto ~p~n\tpacket ~P~n",
|
||||
[From, To, Packet, 8]),
|
||||
case To of
|
||||
{"", _, ""} ->
|
||||
{xmlelement, Name, Attrs, Els} = Packet,
|
||||
case Name of
|
||||
"iq" ->
|
||||
process_iq(State, From, To, Packet);
|
||||
"message" ->
|
||||
ok;
|
||||
"presence" ->
|
||||
% TODO
|
||||
ok;
|
||||
_ ->
|
||||
% DROP
|
||||
ok
|
||||
end;
|
||||
{"", _, _} ->
|
||||
Err = jlib:make_error_reply(Packet, "404", "Not Found"),
|
||||
ejabberd_router ! {route,
|
||||
{"", State#state.mydomain, ""}, From, Err},
|
||||
ok;
|
||||
_ ->
|
||||
ejabberd_sm ! {route, From, To, Packet}
|
||||
end,
|
||||
ok.
|
||||
end.
|
||||
|
||||
process_iq(State, From, To, Packet) ->
|
||||
IQ = jlib:iq_query_info(Packet),
|
||||
case IQ of
|
||||
{iq, ID, Type, XMLNS, SubEl} ->
|
||||
case jlib:is_iq_request_type(Type) of
|
||||
true ->
|
||||
% TODO
|
||||
case ets:lookup(State#state.iqtable, XMLNS) of
|
||||
[{_, Module, Function}] ->
|
||||
ResIQ = apply(Module, Function, [From, To, IQ]),
|
||||
if
|
||||
ResIQ /= ignore ->
|
||||
ejabberd_router ! {route,
|
||||
To,
|
||||
From,
|
||||
jlib:iq_to_xml(ResIQ)};
|
||||
true ->
|
||||
ok
|
||||
end;
|
||||
[] ->
|
||||
Err = jlib:make_error_reply(
|
||||
Packet, "501", "Not Implemented"),
|
||||
ejabberd_router ! {route,
|
||||
{"", State#state.mydomain, ""},
|
||||
From,
|
||||
Err}
|
||||
end;
|
||||
_ ->
|
||||
% TODO
|
||||
ok
|
||||
end;
|
||||
_ ->
|
||||
Err = jlib:make_error_reply(Packet, "400", "Bad Request"),
|
||||
ejabberd_router ! {route,
|
||||
{"", State#state.mydomain, ""}, From, Err},
|
||||
ok
|
||||
end.
|
||||
|
||||
register_iq_handler(XMLNS, Module, Fun) ->
|
||||
ejabberd_local ! {register_iq_handler, XMLNS, Module, Fun}.
|
||||
|
@ -21,6 +21,7 @@
|
||||
tolower/1,
|
||||
get_iq_namespace/1,
|
||||
iq_query_info/1,
|
||||
is_iq_request_type/1,
|
||||
iq_to_xml/1,
|
||||
get_subtag/2]).
|
||||
|
||||
@ -206,6 +207,10 @@ iq_query_info({xmlelement, Name, Attrs, Els}) when Name == "iq" ->
|
||||
iq_query_info(_) ->
|
||||
not_iq.
|
||||
|
||||
is_iq_request_type(set) -> true;
|
||||
is_iq_request_type(get) -> true;
|
||||
is_iq_request_type(_) -> false.
|
||||
|
||||
iq_type_to_string(set) -> "set";
|
||||
iq_type_to_string(get) -> "get";
|
||||
iq_type_to_string(result) -> "result";
|
||||
|
@ -10,10 +10,18 @@
|
||||
-author('alexey@sevcom.net').
|
||||
-vsn('$Revision$ ').
|
||||
|
||||
-export([process_iq/3]).
|
||||
-export([start/0, init/0, process_iq/3]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
|
||||
start() ->
|
||||
ejabberd_local:register_iq_handler("jabber:iq:register",
|
||||
?MODULE, process_iq),
|
||||
ok.
|
||||
|
||||
init() ->
|
||||
ok.
|
||||
|
||||
process_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
||||
case Type of
|
||||
set ->
|
||||
|
47
src/mod_roster.erl
Normal file
47
src/mod_roster.erl
Normal file
@ -0,0 +1,47 @@
|
||||
%%%----------------------------------------------------------------------
|
||||
%%% File : mod_roster.erl
|
||||
%%% Author : Alexey Shchepin <alexey@sevcom.net>
|
||||
%%% Purpose :
|
||||
%%% Created : 11 Dec 2002 by Alexey Shchepin <alexey@sevcom.net>
|
||||
%%% Id : $Id$
|
||||
%%%----------------------------------------------------------------------
|
||||
|
||||
-module(mod_roster).
|
||||
-author('alexey@sevcom.net').
|
||||
-vsn('$Revision$ ').
|
||||
|
||||
-export([]).
|
||||
|
||||
-export([start/0]).
|
||||
|
||||
-record(roster, {user, jid, name, subscription, groups, xs}).
|
||||
|
||||
|
||||
start() ->
|
||||
mnesia:create_table(roster,[{disc_copies, [node()]},
|
||||
{type, bag},
|
||||
{attributes, record_info(fields, roster)}]),
|
||||
ejabberd_local:register_iq_handler("jabber:iq:roster",
|
||||
?MODULE, process_iq).
|
||||
%spawn(mod_roster, init, []).
|
||||
|
||||
%init() ->
|
||||
% loop().
|
||||
%
|
||||
%loop() ->
|
||||
% receive
|
||||
% _ ->
|
||||
% loop()
|
||||
% end.
|
||||
|
||||
|
||||
% TODO
|
||||
process_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
||||
case Type of
|
||||
set ->
|
||||
{iq, ID, error, XMLNS, []};
|
||||
get ->
|
||||
{iq, ID, error, XMLNS, []}
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user