mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-28 16:34:13 +01:00
* src/mod_muc/: Support for discovering service and more
configuration options SVN Revision: 92
This commit is contained in:
parent
6d89957e06
commit
8efae60c04
@ -1,3 +1,8 @@
|
|||||||
|
2003-03-26 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
|
* src/mod_muc/: Support for discovering service and more
|
||||||
|
configuration options
|
||||||
|
|
||||||
2003-03-25 Alexey Shchepin <alexey@sevcom.net>
|
2003-03-25 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
* src/mod_muc/: Support for more configuration options and
|
* src/mod_muc/: Support for more configuration options and
|
||||||
|
@ -18,7 +18,8 @@
|
|||||||
room_destroyed/1,
|
room_destroyed/1,
|
||||||
store_room/2,
|
store_room/2,
|
||||||
restore_room/1,
|
restore_room/1,
|
||||||
forget_room/1]).
|
forget_room/1,
|
||||||
|
process_iq_disco_items/5]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
-include("jlib.hrl").
|
-include("jlib.hrl").
|
||||||
@ -76,10 +77,14 @@ do_route(Host, From, To, Packet) ->
|
|||||||
Res = {iq, ID, result, XMLNS,
|
Res = {iq, ID, result, XMLNS,
|
||||||
[{xmlelement, "query",
|
[{xmlelement, "query",
|
||||||
[{"xmlns", XMLNS}],
|
[{"xmlns", XMLNS}],
|
||||||
iq_disco()}]},
|
iq_disco_info()}]},
|
||||||
ejabberd_router:route(To,
|
ejabberd_router:route(To,
|
||||||
From,
|
From,
|
||||||
jlib:iq_to_xml(Res));
|
jlib:iq_to_xml(Res));
|
||||||
|
{iq, ID, get, ?NS_DISCO_ITEMS = XMLNS, SubEl} ->
|
||||||
|
spawn(?MODULE,
|
||||||
|
process_iq_disco_items,
|
||||||
|
[Host, From, To, ID, SubEl]);
|
||||||
_ ->
|
_ ->
|
||||||
Err = jlib:make_error_reply(
|
Err = jlib:make_error_reply(
|
||||||
Packet, ?ERR_SERVICE_UNAVAILABLE),
|
Packet, ?ERR_SERVICE_UNAVAILABLE),
|
||||||
@ -130,15 +135,6 @@ stop() ->
|
|||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
|
||||||
iq_disco() ->
|
|
||||||
[{xmlelement, "identity",
|
|
||||||
[{"category", "conference"},
|
|
||||||
{"type", "text"},
|
|
||||||
{"name", "ejabberd/mod_muc"}], []},
|
|
||||||
{xmlelement, "feature",
|
|
||||||
[{"var", ?NS_MUC}], []}].
|
|
||||||
|
|
||||||
|
|
||||||
store_room(Name, Opts) ->
|
store_room(Name, Opts) ->
|
||||||
F = fun() ->
|
F = fun() ->
|
||||||
mnesia:write(#muc_room{name = Name,
|
mnesia:write(#muc_room{name = Name,
|
||||||
@ -180,3 +176,40 @@ load_permanent_rooms(Host) ->
|
|||||||
end, Rs)
|
end, Rs)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
iq_disco_info() ->
|
||||||
|
[{xmlelement, "identity",
|
||||||
|
[{"category", "conference"},
|
||||||
|
{"type", "text"},
|
||||||
|
{"name", "ejabberd/mod_muc"}], []},
|
||||||
|
{xmlelement, "feature",
|
||||||
|
[{"var", ?NS_MUC}], []}].
|
||||||
|
|
||||||
|
|
||||||
|
process_iq_disco_items(Host, From, To, ID, SubEl) ->
|
||||||
|
Res = {iq, ID, result, ?NS_DISCO_ITEMS,
|
||||||
|
[{xmlelement, "query",
|
||||||
|
[{"xmlns", ?NS_DISCO_ITEMS}],
|
||||||
|
iq_disco_items(Host, From)}]},
|
||||||
|
ejabberd_router:route(To,
|
||||||
|
From,
|
||||||
|
jlib:iq_to_xml(Res)).
|
||||||
|
|
||||||
|
% TODO: ask more info from room processes
|
||||||
|
iq_disco_items(Host, From) ->
|
||||||
|
lists:zf(fun(#muc_online_room{name = Name, pid = Pid}) ->
|
||||||
|
case catch gen_fsm:sync_send_all_state_event(
|
||||||
|
Pid, get_disco_item, 100) of
|
||||||
|
{'EXIT', _} ->
|
||||||
|
false;
|
||||||
|
{item, Desc} ->
|
||||||
|
{true,
|
||||||
|
{xmlelement, "item",
|
||||||
|
[{"jid", jlib:jid_to_string({Name, Host, ""})},
|
||||||
|
{"name", Desc}], []}}
|
||||||
|
end
|
||||||
|
end, ets:tab2list(muc_online_room)).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,17 +35,17 @@
|
|||||||
|
|
||||||
-record(lqueue, {queue, len, max}).
|
-record(lqueue, {queue, len, max}).
|
||||||
|
|
||||||
-record(config, {allow_change_subj = true, % TODO
|
-record(config, {allow_change_subj = true,
|
||||||
allow_query_users = true,
|
allow_query_users = true,
|
||||||
allow_private_messages = true,
|
allow_private_messages = true,
|
||||||
public = true, % TODO
|
public = true, % TODO
|
||||||
persistent = false, % TODO
|
persistent = false,
|
||||||
moderated = false, % TODO
|
moderated = false, % TODO
|
||||||
members_by_default = true, % TODO
|
members_by_default = true,
|
||||||
members_only = false, % TODO
|
members_only = false, % TODO
|
||||||
allow_user_invites = false, % TODO
|
allow_user_invites = false, % TODO
|
||||||
password_protected = false, % TODO
|
password_protected = false, % TODO
|
||||||
anonymous = true, % TODO
|
anonymous = true,
|
||||||
logging = false % TODO
|
logging = false % TODO
|
||||||
}).
|
}).
|
||||||
|
|
||||||
@ -426,6 +426,14 @@ handle_event(Event, StateName, StateData) ->
|
|||||||
%% {stop, Reason, NewStateData} |
|
%% {stop, Reason, NewStateData} |
|
||||||
%% {stop, Reason, Reply, NewStateData}
|
%% {stop, Reason, Reply, NewStateData}
|
||||||
%%----------------------------------------------------------------------
|
%%----------------------------------------------------------------------
|
||||||
|
handle_sync_event(get_disco_item, From, StateName, StateData) ->
|
||||||
|
Reply = case (StateData#state.config)#config.public of
|
||||||
|
true ->
|
||||||
|
{item, StateData#state.room};
|
||||||
|
_ ->
|
||||||
|
false
|
||||||
|
end,
|
||||||
|
{reply, Reply, StateName, StateData};
|
||||||
handle_sync_event(Event, From, StateName, StateData) ->
|
handle_sync_event(Event, From, StateName, StateData) ->
|
||||||
Reply = ok,
|
Reply = ok,
|
||||||
{reply, Reply, StateName, StateData}.
|
{reply, Reply, StateName, StateData}.
|
||||||
@ -656,15 +664,17 @@ send_new_presence(NJID, StateData) ->
|
|||||||
SRole = role_to_list(Role),
|
SRole = role_to_list(Role),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun({LJID, Info}) ->
|
fun({LJID, Info}) ->
|
||||||
ItemAttrs = case Info#user.role of
|
ItemAttrs =
|
||||||
moderator ->
|
case (Info#user.role == moderator) orelse
|
||||||
[{"jid", jlib:jid_to_string(RealJID)},
|
((StateData#state.config)#config.anonymous == false) of
|
||||||
{"affiliation", SAffiliation},
|
true ->
|
||||||
{"role", SRole}];
|
[{"jid", jlib:jid_to_string(RealJID)},
|
||||||
_ ->
|
{"affiliation", SAffiliation},
|
||||||
[{"affiliation", SAffiliation},
|
{"role", SRole}];
|
||||||
{"role", SRole}]
|
_ ->
|
||||||
end,
|
[{"affiliation", SAffiliation},
|
||||||
|
{"role", SRole}]
|
||||||
|
end,
|
||||||
Packet = append_subtags(
|
Packet = append_subtags(
|
||||||
Presence,
|
Presence,
|
||||||
[{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}],
|
[{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}],
|
||||||
@ -692,19 +702,20 @@ send_existing_presences(ToJID, StateData) ->
|
|||||||
ok;
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
FromAffiliation = get_affiliation(LJID, StateData),
|
FromAffiliation = get_affiliation(LJID, StateData),
|
||||||
ItemAttrs = case Role of
|
ItemAttrs =
|
||||||
moderator ->
|
case (Role == moderator) orelse
|
||||||
[{"jid",
|
((StateData#state.config)#config.anonymous ==
|
||||||
jlib:jid_to_string(FromJID)},
|
false) of
|
||||||
{"affiliation",
|
true ->
|
||||||
affiliation_to_list(
|
[{"jid", jlib:jid_to_string(FromJID)},
|
||||||
FromAffiliation)},
|
{"affiliation",
|
||||||
{"role", role_to_list(FromRole)}];
|
affiliation_to_list(FromAffiliation)},
|
||||||
_ ->
|
{"role", role_to_list(FromRole)}];
|
||||||
[{"affiliation", affiliation_to_list(
|
_ ->
|
||||||
FromAffiliation)},
|
[{"affiliation",
|
||||||
{"role", role_to_list(FromRole)}]
|
affiliation_to_list(FromAffiliation)},
|
||||||
end,
|
{"role", role_to_list(FromRole)}]
|
||||||
|
end,
|
||||||
Packet = append_subtags(
|
Packet = append_subtags(
|
||||||
Presence,
|
Presence,
|
||||||
[{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}],
|
[{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}],
|
||||||
@ -746,26 +757,30 @@ send_nick_changing(JID, OldNick, StateData) ->
|
|||||||
SRole = role_to_list(Role),
|
SRole = role_to_list(Role),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun({LJID, Info}) ->
|
fun({LJID, Info}) ->
|
||||||
ItemAttrs1 = case Info#user.role of
|
ItemAttrs1 =
|
||||||
moderator ->
|
case (Info#user.role == moderator) orelse
|
||||||
[{"jid", jlib:jid_to_string(RealJID)},
|
((StateData#state.config)#config.anonymous == false) of
|
||||||
{"affiliation", SAffiliation},
|
true ->
|
||||||
{"role", SRole},
|
[{"jid", jlib:jid_to_string(RealJID)},
|
||||||
{"nick", Nick}];
|
{"affiliation", SAffiliation},
|
||||||
_ ->
|
{"role", SRole},
|
||||||
[{"affiliation", SAffiliation},
|
{"nick", Nick}];
|
||||||
{"role", SRole},
|
_ ->
|
||||||
{"nick", Nick}]
|
[{"affiliation", SAffiliation},
|
||||||
end,
|
{"role", SRole},
|
||||||
ItemAttrs2 = case Info#user.role of
|
{"nick", Nick}]
|
||||||
moderator ->
|
end,
|
||||||
[{"jid", jlib:jid_to_string(RealJID)},
|
ItemAttrs2 =
|
||||||
{"affiliation", SAffiliation},
|
case (Info#user.role == moderator) orelse
|
||||||
{"role", SRole}];
|
((StateData#state.config)#config.anonymous == false) of
|
||||||
_ ->
|
true ->
|
||||||
[{"affiliation", SAffiliation},
|
[{"jid", jlib:jid_to_string(RealJID)},
|
||||||
{"role", SRole}]
|
{"affiliation", SAffiliation},
|
||||||
end,
|
{"role", SRole}];
|
||||||
|
_ ->
|
||||||
|
[{"affiliation", SAffiliation},
|
||||||
|
{"role", SRole}]
|
||||||
|
end,
|
||||||
Packet1 =
|
Packet1 =
|
||||||
{xmlelement, "presence", [{"type", "unavailable"}],
|
{xmlelement, "presence", [{"type", "unavailable"}],
|
||||||
[{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}],
|
[{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}],
|
||||||
@ -871,7 +886,12 @@ send_join_messages_end(JID, StateData) ->
|
|||||||
Packet).
|
Packet).
|
||||||
|
|
||||||
can_change_subject(Role, StateData) ->
|
can_change_subject(Role, StateData) ->
|
||||||
(Role == moderator) orelse (Role == participant).
|
case (StateData#state.config)#config.allow_change_subj of
|
||||||
|
true ->
|
||||||
|
(Role == moderator) orelse (Role == participant);
|
||||||
|
_ ->
|
||||||
|
Role == moderator
|
||||||
|
end.
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
% Admin stuff
|
% Admin stuff
|
||||||
|
Loading…
Reference in New Issue
Block a user