mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
* src/mod_muc/: MUC support (not completed yet)
SVN Revision: 90
This commit is contained in:
parent
9921b1c1d8
commit
bc756c3737
@ -1,3 +1,7 @@
|
||||
2003-03-23 Alexey Shchepin <alexey@sevcom.net>
|
||||
|
||||
* src/mod_muc/: MUC support (not completed yet)
|
||||
|
||||
2003-03-15 Alexey Shchepin <alexey@sevcom.net>
|
||||
|
||||
* src/xml_stream.erl: Removed "link" which cause not improper
|
||||
|
@ -104,7 +104,7 @@ Currently no stable version has been released.
|
||||
|
||||
The latest alpha version can be retrieved from CVS\@.
|
||||
\begin{itemize}
|
||||
\item \texttt{export CVSROOT=:pserver:cvs@www.jabber.ru:/var/spool/cvs}
|
||||
\item \texttt{export CVSROOT=:pserver:anonymous@jabberstudio.org:/home/cvs}
|
||||
\item \texttt{cvs login}
|
||||
\item Press Enter when asked for a password
|
||||
\item \texttt{cvs -z3 co ejabberd}
|
||||
|
@ -59,6 +59,7 @@
|
||||
{mod_echo, [{host, "echo.localhost"}]},
|
||||
{mod_private, []},
|
||||
{mod_irc, []},
|
||||
{mod_muc, []},
|
||||
{mod_time, [{iqdisc, no_queue}]},
|
||||
{mod_version, []}
|
||||
]}.
|
||||
|
@ -47,7 +47,7 @@
|
||||
pres_timestamp,
|
||||
pres_invis = false}).
|
||||
|
||||
-define(DBGFSM, true).
|
||||
%-define(DBGFSM, true).
|
||||
|
||||
-ifdef(DBGFSM).
|
||||
-define(FSMOPTS, [{debug, [trace]}]).
|
||||
|
29
src/mod_muc/Makefile
Normal file
29
src/mod_muc/Makefile
Normal file
@ -0,0 +1,29 @@
|
||||
# $Id$
|
||||
|
||||
include ../Makefile.inc
|
||||
|
||||
INCLUDES = -I/usr/lib/erlang/usr/include \
|
||||
-I$(EI_DIR)/include \
|
||||
-I/usr/local/include
|
||||
|
||||
LIBDIRS = -L$(EI_DIR)/lib -L/usr/local/lib
|
||||
|
||||
|
||||
OUTDIR = ..
|
||||
EFLAGS = -I .. -pz ..
|
||||
OBJS = \
|
||||
$(OUTDIR)/mod_muc.beam \
|
||||
$(OUTDIR)/mod_muc_room.beam
|
||||
|
||||
all: $(OBJS)
|
||||
|
||||
$(OUTDIR)/%.beam: %.erl
|
||||
erlc -W $(EFLAGS) -o $(OUTDIR) $<
|
||||
|
||||
|
||||
clean:
|
||||
rm -f *.beam
|
||||
|
||||
TAGS:
|
||||
etags *.erl
|
||||
|
142
src/mod_muc/mod_muc.erl
Normal file
142
src/mod_muc/mod_muc.erl
Normal file
@ -0,0 +1,142 @@
|
||||
%%%----------------------------------------------------------------------
|
||||
%%% File : mod_muc.erl
|
||||
%%% Author : Alexey Shchepin <alexey@sevcom.net>
|
||||
%%% Purpose : MUC support (JEP-0045)
|
||||
%%% Created : 19 Mar 2003 by Alexey Shchepin <alexey@sevcom.net>
|
||||
%%% Id : $Id$
|
||||
%%%----------------------------------------------------------------------
|
||||
|
||||
-module(mod_muc).
|
||||
-author('alexey@sevcom.net').
|
||||
-vsn('$Revision$ ').
|
||||
|
||||
-behaviour(gen_mod).
|
||||
|
||||
-export([start/1,
|
||||
init/1,
|
||||
stop/0,
|
||||
room_destroyed/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("jlib.hrl").
|
||||
|
||||
|
||||
-record(muc_room, {name, opts}).
|
||||
-record(muc_online_room, {name, pid}).
|
||||
|
||||
start(Opts) ->
|
||||
mnesia:create_table(muc_room,
|
||||
[{disc_copies, [node()]},
|
||||
{attributes, record_info(fields, muc_room)}]),
|
||||
Host = gen_mod:get_opt(host, Opts, "conference." ++ ?MYNAME),
|
||||
register(ejabberd_mod_muc, spawn(?MODULE, init, [Host])).
|
||||
|
||||
|
||||
|
||||
init(Host) ->
|
||||
catch ets:new(muc_online_room, [named_table,
|
||||
public,
|
||||
{keypos, #muc_online_room.name}]),
|
||||
ejabberd_router:register_route(Host),
|
||||
% TODO: load permanent groups
|
||||
loop(Host).
|
||||
|
||||
loop(Host) ->
|
||||
receive
|
||||
{route, From, To, Packet} ->
|
||||
case catch do_route(Host, From, To, Packet) of
|
||||
{'EXIT', Reason} ->
|
||||
?ERROR_MSG("~p", [Reason]);
|
||||
_ ->
|
||||
ok
|
||||
end,
|
||||
loop(Host);
|
||||
{room_destroyed, Room} ->
|
||||
ets:delete(muc_online_room, Room);
|
||||
stop ->
|
||||
% TODO
|
||||
ejabberd_router:unregister_global_route(Host),
|
||||
ok;
|
||||
_ ->
|
||||
loop(Host)
|
||||
end.
|
||||
|
||||
|
||||
do_route(Host, From, To, Packet) ->
|
||||
{Room, _, Nick} = To,
|
||||
case Room of
|
||||
"" ->
|
||||
case Nick of
|
||||
"" ->
|
||||
case jlib:iq_query_info(Packet) of
|
||||
{iq, ID, get, ?NS_DISCO_INFO = XMLNS, SubEl} ->
|
||||
Res = {iq, ID, result, XMLNS,
|
||||
[{xmlelement, "query",
|
||||
[{"xmlns", XMLNS}],
|
||||
iq_disco()}]},
|
||||
ejabberd_router:route(To,
|
||||
From,
|
||||
jlib:iq_to_xml(Res));
|
||||
_ ->
|
||||
Err = jlib:make_error_reply(
|
||||
Packet, ?ERR_SERVICE_UNAVAILABLE),
|
||||
ejabberd_router:route(To, From, Err)
|
||||
end;
|
||||
_ ->
|
||||
Err = jlib:make_error_reply(Packet,
|
||||
?ERR_JID_NOT_FOUND),
|
||||
ejabberd_router:route(To, From, Err)
|
||||
end;
|
||||
_ ->
|
||||
case ets:lookup(muc_online_room, Room) of
|
||||
[] ->
|
||||
{xmlelement, Name, Attrs, Els} = Packet,
|
||||
Type = xml:get_attr_s("type", Attrs),
|
||||
case {Name, Type} of
|
||||
{"presence", ""} ->
|
||||
io:format("MUC: open new room '~s'~n", [Room]),
|
||||
{ok, Pid} = mod_muc_room:start(
|
||||
Host, Room, From, Nick),
|
||||
ets:insert(
|
||||
muc_online_room,
|
||||
#muc_online_room{name = Room, pid = Pid}),
|
||||
mod_muc_room:route(Pid, From, Nick, Packet),
|
||||
ok;
|
||||
_ ->
|
||||
Err = jlib:make_error_reply(
|
||||
Packet, ?ERR_SERVICE_UNAVAILABLE),
|
||||
ejabberd_router:route(To, From, Err)
|
||||
end;
|
||||
[R] ->
|
||||
Pid = R#muc_online_room.pid,
|
||||
io:format("MUC: send to process ~p~n", [Pid]),
|
||||
mod_muc_room:route(Pid, From, Nick, Packet),
|
||||
ok
|
||||
end
|
||||
end.
|
||||
|
||||
|
||||
|
||||
|
||||
room_destroyed(Room) ->
|
||||
ejabberd_mod_muc ! {room_destroyed, Room},
|
||||
ok.
|
||||
|
||||
stop() ->
|
||||
ejabberd_mod_muc ! stop,
|
||||
ok.
|
||||
|
||||
|
||||
iq_disco() ->
|
||||
[{xmlelement, "identity",
|
||||
[{"category", "conference"},
|
||||
{"type", "text"},
|
||||
{"name", "ejabberd/mod_muc"}], []},
|
||||
{xmlelement, "feature",
|
||||
[{"var", ?NS_MUC}], []}].
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
1187
src/mod_muc/mod_muc_room.erl
Normal file
1187
src/mod_muc/mod_muc_room.erl
Normal file
File diff suppressed because it is too large
Load Diff
@ -103,7 +103,7 @@ process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
||||
[{xmlcdata, "ejabberd"}]},
|
||||
{xmlelement, "URL", [],
|
||||
[{xmlcdata,
|
||||
"http://www.jabber.ru/projects/ejabberd/"}]},
|
||||
"http://ejabberd.jabberstudio.org/"}]},
|
||||
{xmlelement, "DESC", [],
|
||||
[{xmlcdata, "Erlang Jabber Server\n"
|
||||
"Copyright (c) 2002, 2003 Alexey Shchepin"}]},
|
||||
|
Loading…
Reference in New Issue
Block a user