25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

*** empty log message ***

SVN Revision: 41
This commit is contained in:
Alexey Shchepin 2003-01-16 20:24:53 +00:00
parent 5645292526
commit 23e1914e94
9 changed files with 139 additions and 60 deletions

9
TODO
View File

@ -1,8 +1,5 @@
S2S timeouts
...
iq:browse
iq:disco
...
services support
JUD
iq:browse(?)
SVR DNS records
karma
SSL

View File

@ -136,10 +136,10 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
end;
_ ->
case jlib:iq_query_info(El) of
{iq, ID, Type, "jabber:iq:register", SubEl} ->
{iq, ID, Type, ?NS_REGISTER, SubEl} ->
ResIQ = mod_register:process_iq(
{"", "", ""}, {"", ?MYNAME, ""},
{iq, ID, Type, "jabber:iq:register", SubEl}),
{iq, ID, Type, ?NS_REGISTER, SubEl}),
Res1 = jlib:replace_from_to({"", ?MYNAME, ""},
{"", "", ""},
jlib:iq_to_xml(ResIQ)),
@ -388,26 +388,16 @@ new_id() ->
randoms:get_string().
is_auth_packet({xmlelement, Name, Attrs, Els}) when Name == "iq" ->
case xml:get_attr_s("type", Attrs) of
"set" ->
case xml:remove_cdata(Els) of
[{xmlelement, "query", Attrs2, Els2}] ->
case xml:get_attr_s("xmlns", Attrs2) of
"jabber:iq:auth" ->
{auth,
xml:get_attr_s("id", Attrs),
get_auth_tags(Els2, "", "", "", "")};
_ -> false
end;
is_auth_packet(El) ->
case jlib:iq_query_info(El) of
{iq, ID, Type, ?NS_AUTH, SubEl} ->
{xmlelement, _, _, Els} = SubEl,
{auth, ID,
get_auth_tags(Els, "", "", "", "")};
_ ->
false
end;
true ->
false
end;
is_auth_packet(_) ->
false.
end.
get_auth_tags([{xmlelement, Name, Attrs, Els}| L], U, P, D, R) ->
CData = xml:get_cdata(Els),

View File

@ -20,23 +20,16 @@ start() ->
load_file(File) ->
{ok, Bin} = file:read_file(File),
Content = binary_to_list(Bin),
parse(Content).
parse(String) ->
case erl_scan:tokens([], String, 0) of
{done, Result, Left} ->
{ok, Tokens, _} = Result,
{ok, Term} = erl_parse:parse_term(Tokens),
{Opt, Val} = Term,
ets:insert(ejabberd_config, {Opt, Val}),
parse(Left);
_ ->
ok
case file:consult(File) of
{ok, Terms} ->
lists:foreach(fun({Opt, Val}) ->
ets:insert(ejabberd_config, {Opt, Val})
end, Terms);
{error, Reason} ->
exit(file:format_error(Reason))
end.
get_option(Opt) ->
case ets:lookup(ejabberd_config, Opt) of
[{_, Val}] ->

View File

@ -27,6 +27,7 @@ start() ->
mod_vcard:start(),
mod_offline:start(),
mod_echo:start(),
mod_private:start(),
ok.
init() ->

View File

@ -142,8 +142,15 @@ do_route(From, To, Packet) ->
ejabberd_s2s ! {route, From, To, Packet};
[R] ->
Node = R#route.node,
case node() of
Node ->
Pid = R#local_route.pid,
?DEBUG("routed to process ~p~n", [Pid]),
Pid ! {route, From, To, Packet};
_ ->
?DEBUG("routed to node ~p~n", [Node]),
{ejabberd_router, Node} ! {route, From, To, Packet}
end
end;
[R] ->
Pid = R#local_route.pid,

95
src/mod_private.erl Normal file
View File

@ -0,0 +1,95 @@
%%%----------------------------------------------------------------------
%%% File : mod_private.erl
%%% Author : Alexey Shchepin <alexey@sevcom.net>
%%% Purpose :
%%% Created : 16 Jan 2003 by Alexey Shchepin <alexey@sevcom.net>
%%% Id : $Id$
%%%----------------------------------------------------------------------
-module(mod_private).
-author('alexey@sevcom.net').
-vsn('$Revision$ ').
-export([start/0,
process_local_iq/3]).
-include("ejabberd.hrl").
-include("namespaces.hrl").
-record(private_storage, {userns, xml}).
start() ->
mnesia:create_table(private_storage,
[{disc_only_copies, [node()]},
{attributes, record_info(fields, private_storage)}]),
ejabberd_local:register_iq_handler(?NS_PRIVATE, ?MODULE, process_local_iq).
process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
{User, Server, _} = From,
LUser = jlib:tolower(User),
LServer = jlib:tolower(Server),
case ?MYNAME of
Server ->
{xmlelement, Name, Attrs, Els} = SubEl,
case Type of
set ->
F = fun() ->
lists:foreach(
fun(El) ->
set_data(LUser, El)
end, Els)
end,
mnesia:transaction(F),
{iq, ID, result, XMLNS, [{xmlelement, Name, Attrs, []}]};
get ->
case catch get_data(LUser, Els) of
{'EXIT', Reason} ->
{iq, ID, error, XMLNS,
[SubEl, {xmlelement, "error",
[{"code", "500"}],
[{xmlcdata, "Internal Server Error"}]}]};
Res ->
{iq, ID, error, XMLNS,
[{xmlelement, Name, Attrs, Res}]}
end
end;
_ ->
{iq, ID, error, XMLNS, [SubEl, {xmlelement, "error",
[{"code", "405"}],
[{xmlcdata, "Not Allowed"}]}]}
end.
set_data(LUser, El) ->
case El of
{xmlelement, Name, Attrs, Els} ->
XMLNS = xml:get_attr_s("xmlns", Attrs),
case XMLNS of
"" ->
ignore;
_ ->
mnesia:write(#private_storage{userns = {LUser, XMLNS},
xml = El})
end;
_ ->
ignore
end.
get_data(LUser, Els) ->
get_data(LUser, Els, []).
get_data(LUser, [], Res) ->
lists:reverse(Res);
get_data(LUser, [El | Els], Res) ->
case El of
{xmlelement, Name, Attrs, _} ->
XMLNS = xml:get_attr_s("xmlns", Attrs),
case mnesia:dirty_read(private_storage, {LUser, XMLNS}) of
[R] ->
get_data(LUser, Els, [R#private_storage.xml | Res]);
[] ->
get_data(LUser, Els, [El | Res])
end;
_ ->
get_data(LUser, Els, Res)
end.

View File

@ -53,13 +53,13 @@ start() ->
mnesia:add_table_index(vcard_search, lorgname),
mnesia:add_table_index(vcard_search, lorgunit),
ejabberd_local:register_iq_handler(?NS_VCARD,
?MODULE, process_local_iq),
ejabberd_sm:register_iq_handler(?NS_VCARD,
?MODULE, process_sm_iq),
spawn(?MODULE, init, []).
init() ->
ejabberd_router:register_local_route("vjud." ++ ?MYNAME),
loop().

View File

@ -8,8 +8,11 @@
-define(NS_DISCO_ITEMS, "http://jabber.org/protocol/disco#items").
-define(NS_DISCO_INFO, "http://jabber.org/protocol/disco#info").
-define(NS_VCARD, "vcard-temp").
-define(NS_AUTH, "jabber:iq:auth").
-define(NS_REGISTER, "jabber:iq:register").
-define(NS_SEARCH, "jabber:iq:search").
-define(NS_ROSTER, "jabber:iq:roster").
-define(NS_PRIVATE, "jabber:iq:private").
-define(NS_XDATA, "jabber:x:data").
-define(NS_DELAY, "jabber:x:delay").
-define(NS_EVENT, "jabber:x:event").

View File

@ -41,21 +41,14 @@ load_dir(Dir) ->
ok.
load_file(Lang, File) ->
{ok, Bin} = file:read_file(File),
Content = binary_to_list(Bin),
parse(Lang, Content).
parse(Lang, String) ->
case erl_scan:tokens([], String, 0) of
{done, Result, Left} ->
{ok, Tokens, _} = Result,
{ok, Term} = erl_parse:parse_term(Tokens),
{Orig, Trans} = Term,
ets:insert(translations, {{Lang, Orig}, Trans}),
parse(Lang, Left);
_ ->
ok
case file:consult(File) of
{ok, Terms} ->
lists:foreach(fun({Orig, Trans}) ->
ets:insert(translations,
{{Lang, Orig}, Trans})
end, Terms);
{error, Reason} ->
exit(file:format_error(Reason))
end.
translate(Lang, Msg) ->