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

* src/msgs/ru.msg: Updated (thanks to Sergei Golovan)

* src/mod_irc/mod_irc.erl: Now uses "ejabber:config" namespace
(thanks to Sergei Golovan)

* src/mod_disco.erl: Fixed disco category and type (thanks to
Sergei Golovan)
* src/mod_pubsub/mod_pubsub.erl: Likewise

* src/jlib.hrl: Added "ejabber:config" namespace (thanks to Sergei
Golovan)

SVN Revision: 202
This commit is contained in:
Alexey Shchepin 2004-02-10 20:50:41 +00:00
parent 976e185a4a
commit b0b4b9a903
6 changed files with 134 additions and 82 deletions

View File

@ -1,3 +1,17 @@
2004-02-10 Alexey Shchepin <alexey@sevcom.net>
* src/msgs/ru.msg: Updated (thanks to Sergei Golovan)
* src/mod_irc/mod_irc.erl: Now uses "ejabber:config" namespace
(thanks to Sergei Golovan)
* src/mod_disco.erl: Fixed disco category and type (thanks to
Sergei Golovan)
* src/mod_pubsub/mod_pubsub.erl: Likewise
* src/jlib.hrl: Added "ejabber:config" namespace (thanks to Sergei
Golovan)
2004-01-27 Alexey Shchepin <alexey@sevcom.net>
* src/ejabberd_ctl.erl: Added command for log reopening

View File

@ -33,6 +33,8 @@
-define(NS_PUBSUB_OWNER, "http://jabber.org/protocol/pubsub#owner").
-define(NS_PUBSUB_NMI, "http://jabber.org/protocol/pubsub#node-meta-info").
-define(NS_EJABBERD_CONFIG, "ejabberd:config").
-define(NS_STREAM, "http://etherx.jabber.org/streams").
-define(NS_STANZAS, "urn:ietf:params:xml:ns:xmpp-stanzas").

View File

@ -124,7 +124,7 @@ process_local_iq_info(From, _To, #iq{type = Type, xmlns = XMLNS,
"query",
[{"xmlns", ?NS_DISCO_INFO}],
[{xmlelement, "identity",
[{"category", "service"},
[{"category", "server"},
{"type", "im"},
{"name", "ejabberd"}], []}] ++
Features

View File

@ -72,9 +72,9 @@ do_route(Host, From, To, Packet) ->
ejabberd_router:route(To,
From,
jlib:iq_to_xml(Res));
#iq{type = Type, xmlns = ?NS_IQDATA,
#iq{type = Type, xmlns = ?NS_EJABBERD_CONFIG,
sub_el = SubEl} = IQ ->
iq_data(From, To, IQ);
ejabberd_config(From, To, IQ);
#iq{} = IQ ->
Err = jlib:make_error_reply(
Packet, ?ERR_FEATURE_NOT_IMPLEMENTED),
@ -155,12 +155,12 @@ iq_disco() ->
{xmlelement, "feature",
[{"var", ?NS_MUC}], []},
{xmlelement, "feature",
[{"var", ?NS_IQDATA}], []}].
[{"var", ?NS_EJABBERD_CONFIG}], []}].
iq_data(From, To, #iq{type = Type} = IQ) ->
case catch process_iq_data(From, To, IQ) of
ejabberd_config(From, To, #iq{type = Type} = IQ) ->
case catch process_ejabberd_config(From, To, IQ) of
{'EXIT', Reason} ->
?ERROR_MSG("~p", [Reason]);
ResIQ ->
@ -173,42 +173,64 @@ iq_data(From, To, #iq{type = Type} = IQ) ->
end
end.
find_xdata_el({xmlelement, _Name, _Attrs, SubEls}) ->
find_xdata_el1(SubEls).
process_iq_data(From, To,
find_xdata_el1([]) ->
false;
find_xdata_el1([{xmlelement, Name, Attrs, SubEls} | Els]) ->
case xml:get_attr_s("xmlns", Attrs) of
?NS_XDATA ->
{xmlelement, Name, Attrs, SubEls};
_ ->
find_xdata_el1(Els)
end;
find_xdata_el1([_ | Els]) ->
find_xdata_el1(Els).
process_ejabberd_config(From, To,
#iq{type = Type, xmlns = XMLNS, sub_el = SubEl} = IQ) ->
Lang = xml:get_tag_attr_s("xml:lang", SubEl),
case Type of
set ->
case xml:get_tag_attr_s("type", SubEl) of
"cancel" ->
IQ#iq{type = result,
sub_el = [{xmlelement, "query",
[{"xmlns", XMLNS}], []}]};
"submit" ->
XData = jlib:parse_xdata_submit(SubEl),
case XData of
invalid ->
IQ#iq{type = error,
sub_el = [SubEl, ?ERR_BAD_REQUEST]};
_ ->
Node =
string:tokens(
xml:get_tag_attr_s("node", SubEl),
"/"),
case set_form(From, Node, Lang, XData) of
{result, Res} ->
IQ#iq{type = result,
sub_el = [{xmlelement, "query",
[{"xmlns", XMLNS}],
Res
}]};
{error, Error} ->
XDataEl = find_xdata_el(SubEl),
case XDataEl of
false ->
IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ACCEPTABLE]};
{xmlelement, _Name, Attrs, SubEls} ->
case xml:get_attr_s("type", Attrs) of
"cancel" ->
IQ#iq{type = result,
sub_el = [{xmlelement, "query",
[{"xmlns", XMLNS}], []}]};
"submit" ->
XData = jlib:parse_xdata_submit(XDataEl),
case XData of
invalid ->
IQ#iq{type = error,
sub_el = [SubEl, Error]}
end
end;
_ ->
IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]}
sub_el = [SubEl, ?ERR_BAD_REQUEST]};
_ ->
Node = string:tokens(
xml:get_tag_attr_s("node", SubEl),
"/"),
case set_form(From, Node, Lang, XData) of
{result, Res} ->
IQ#iq{type = result,
sub_el = [{xmlelement, "query",
[{"xmlns", XMLNS}],
Res
}]};
{error, Error} ->
IQ#iq{type = error,
sub_el = [SubEl, Error]}
end
end;
_ ->
IQ#iq{type = error,
sub_el = [SubEl, ?ERR_BAD_REQUEST]}
end
end;
get ->
Node =
@ -246,54 +268,61 @@ get_form(From, [], Lang) ->
Customs;
{Username, Encodings} ->
{result,
[{xmlelement, "title", [],
[{xmlelement, "instructions", [],
[{xmlcdata,
User ++ "@" ++ Server ++ " " ++
translate:translate(Lang, "Configuration")}]},
translate:translate(
Lang,
"You need an x:data capable client "
"to configure mod_irc settings")}]},
{xmlelement, "x", [{"xmlns", ?NS_XDATA}],
[{xmlelement, "title", [],
[{xmlcdata,
translate:translate(Lang, "mod_irc configuration for") ++
" " ++ User ++ "@" ++ Server}]},
%{xmlelement, "instructions", [],
% [{xmlcdata,
% translate:translate(
% Lang, "")}]},
{xmlelement, "field", [{"type", "text-single"},
{"label",
translate:translate(
Lang, "IRC Username")},
{"var", "username"}],
[{xmlelement, "value", [], [{xmlcdata, Username}]}]},
{xmlelement, "field", [{"type", "fixed"}],
[{xmlelement, "value", [],
[{xmlcdata,
lists:flatten(
io_lib:format(
translate:translate(
Lang,
"If you want to specify different encodings "
"for IRC servers, fill this list with values "
"in format '{\"irc server\", \"encoding\"}'. "
"By default this service use \"~s\" encoding."),
[?DEFAULT_IRC_ENCODING]))}]}]},
{xmlelement, "field", [{"type", "fixed"}],
[{xmlelement, "value", [],
[{xmlcdata,
translate:translate(
Lang,
"Example: [{\"irc.lucky.net\", \"koi8-r\"}, "
"{\"vendetta.fef.net\", \"iso8859-1\"}]."
)}]}]},
{xmlelement, "field", [{"type", "text-multi"},
{"label",
translate:translate(Lang, "Encodings")},
{"var", "encodings"}],
lists:map(
fun(S) ->
{xmlelement, "value", [], [{xmlcdata, S}]}
end,
string:tokens(
lists:flatten(
io_lib:format("~p.", [Encodings])),
"\n"))
}
]}
{xmlelement, "field", [{"type", "text-single"},
{"label",
translate:translate(
Lang, "IRC Username")},
{"var", "username"}],
[{xmlelement, "value", [], [{xmlcdata, Username}]}]},
{xmlelement, "field", [{"type", "fixed"}],
[{xmlelement, "value", [],
[{xmlcdata,
lists:flatten(
io_lib:format(
translate:translate(
Lang,
"If you want to specify different encodings "
"for IRC servers, fill this list with values "
"in format '{\"irc server\", \"encoding\"}'. "
"By default this service use \"~s\" encoding."),
[?DEFAULT_IRC_ENCODING]))}]}]},
{xmlelement, "field", [{"type", "fixed"}],
[{xmlelement, "value", [],
[{xmlcdata,
translate:translate(
Lang,
"Example: [{\"irc.lucky.net\", \"koi8-r\"}, "
"{\"vendetta.fef.net\", \"iso8859-1\"}]."
)}]}]},
{xmlelement, "field", [{"type", "text-multi"},
{"label",
translate:translate(Lang, "Encodings")},
{"var", "encodings"}],
lists:map(
fun(S) ->
{xmlelement, "value", [], [{xmlcdata, S}]}
end,
string:tokens(
lists:flatten(
io_lib:format("~p.", [Encodings])),
"\n"))
}
]}]}
end;

View File

@ -213,8 +213,8 @@ iq_disco_info(SNode) ->
case Node of
[] ->
[{xmlelement, "identity",
[{"category", "service"},
{"type", "pubsub"},
[{"category", "pubsub"},
{"type", "generic"},
{"name", "ejabberd/mod_pubsub"}], []},
%{xmlelement, "feature", [{"var", ?NS_REGISTER}], []},
{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []},

View File

@ -90,7 +90,14 @@
{"Make room anonymous?", "Сделать комнату анонимной?"}.
{"Enable logging?", "Включить журналирование?"}.
% mod_irc/mod_irc.erl
{"You need an x:data capable client to configure mod_irc settings",
"Чтобы настроить параметры mod_irc, нужен x:data-совместимый клиент"}.
{"mod_irc configuration for", "Конфигурация mod_irc для"}.
{"IRC Username", "Имя пользователя IRC"}.
{"If you want to specify different encodings for IRC servers, fill this list with values in format '{\"irc server\", \"encoding\"}'. By default this service use \"~s\" encoding.", "Чтобы указать различные кодировки для разных серверов IRC, заполните список значениями в формате '{\"irc server\", \"encoding\"}'. По умолчанию эта служба использует кодировку \"~s\"."}.
{"Example: [{\"irc.lucky.net\", \"koi8-r\"}, {\"vendetta.fef.net\", \"iso8859-1\"}].", "Примеры: [{\"irc.lucky.net\", \"koi8-r\"}, {\"vendetta.fef.net\", \"iso8859-1\"}]."}.
{"Encodings", "Кодировки"}.
% Local Variables:
% mode: erlang