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

* (all): Updated win32 stuff (thanks to Sergei Golovan)

* src/web/ejabberd_web.erl: Added interface for access rules
configuration

SVN Revision: 221
This commit is contained in:
Alexey Shchepin 2004-03-21 20:27:09 +00:00
parent 2f47b7edd9
commit b75fb79677
13 changed files with 253 additions and 57 deletions

View File

@ -1,3 +1,10 @@
2004-03-21 Alexey Shchepin <alexey@sevcom.net>
* (all): Updated win32 stuff (thanks to Sergei Golovan)
* src/web/ejabberd_web.erl: Added interface for access rules
configuration
2004-03-20 Alexey Shchepin <alexey@sevcom.net>
* doc/guide.tex: Updated

View File

@ -127,14 +127,17 @@ To compile \ejabberd{} in MS Windows environment, you will need the following
packages:
\begin{itemize}
\item MS Visual C++~6.0 Compiler
\item \footahref{http://www.erlang.org/download/otp_win32_R8B-2.exe}{Erlang
emulator version~5.1.2}
\item \footahref{http://www.erlang.org/download/otp_win32_R9C-0.exe}{Erlang emulator version~5.3}
\item \footahref{http://prdownloads.sourceforge.net/expat/expat_win32bin_1_95_6.exe?download}{Expat~1.95.6}
\item \footahref{http://prdownloads.sourceforge.net/gnuwin32/libiconv-1.8-1-lib.exe?download}{Iconv~1.8} (optional)
\item
\footahref{http://prdownloads.sourceforge.net/gnuwin32/libiconv-1.8-1-bin.exe?download}{Iconv~1.8
binaries} and
\footahref{http://prdownloads.sourceforge.net/gnuwin32/libiconv-1.8-1-lib.exe?download}{Iconv~1.8
development libraries}
(optional)
\end{itemize}
\subsection{Obtaining}
\label{sec:obtaining}

View File

@ -3,10 +3,29 @@ include Makefile.inc
EXPAT_DIR="c:\progra~1\expat-1.95.6"
ALL : expat_erl.dll
ALL : expat_erl.dll compile-beam all-recursive
all-recursive :
cd eldap
nmake -nologo -f Makefile.win32
cd ..\mod_irc
nmake -nologo -f Makefile.win32
cd ..\mod_muc
nmake -nologo -f Makefile.win32
cd ..\mod_pubsub
nmake -nologo -f Makefile.win32
cd ..\stringprep
nmake -nologo -f Makefile.win32
cd ..\web
nmake -nologo -f Makefile.win32
cd ..
compile-beam :
erl -s make all report -noinput -s erlang halt
CLEAN :
CLEAN : clean-recursive clean-local
clean-local :
-@erase expat_erl.obj
-@erase vc60.idb
-@erase expat_erl.dll
@ -15,8 +34,23 @@ CLEAN :
-@erase expat_erl.pch
-@erase *.beam
clean-recursive :
cd eldap
nmake -nologo -f Makefile.win32 clean
cd ..\mod_irc
nmake -nologo -f Makefile.win32 clean
cd ..\mod_muc
nmake -nologo -f Makefile.win32 clean
cd ..\mod_pubsub
nmake -nologo -f Makefile.win32 clean
cd ..\stringprep
nmake -nologo -f Makefile.win32 clean
cd ..\web
nmake -nologo -f Makefile.win32 clean
cd ..
CPP=cl.exe
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\include" /I "$(EXPAT_DIR)\source\lib" /D "WIN32" /D "NDEBUG" /D "_USRDLL" /D "_MBCS" /Fpexpat_erl.pch /YX /FD /c
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\include" /I "$(EXPAT_DIR)\source\lib" /D "__WIN32__" /D "WIN32" /D "NDEBUG" /D "_USRDLL" /D "_MBCS" /Fpexpat_erl.pch /YX /FD /c
.c.obj::
$(CPP) @<<
@ -24,7 +58,7 @@ CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\in
<<
LINK32=link.exe
LINK32_FLAGS=kernel32.lib "$(ERLANG_DIR)\usr\lib\erl_dll.lib" "$(EI_DIR)\lib\ei.lib" "$(EI_DIR)\lib\erl_interface.lib" "$(EXPAT_DIR)\libs\libexpat.lib" /nologo /subsystem:console /dll /pdb:none /machine:I386 /out:expat_erl.dll
LINK32_FLAGS=kernel32.lib "$(EI_DIR)\lib\ei.lib" "$(EI_DIR)\lib\erl_interface.lib" "$(EXPAT_DIR)\libs\libexpat.lib" /nologo /subsystem:console /dll /pdb:none /machine:I386 /out:expat_erl.dll /nodefaultlib:libcmt
LINK32_OBJS=expat_erl.obj
expat_erl.dll : $(LINK32_OBJS)

24
src/eldap/Makefile.win32 Normal file
View File

@ -0,0 +1,24 @@
include ..\Makefile.inc
OUTDIR = ..
EFLAGS = -I .. -pz ..
OBJS = \
$(OUTDIR)\eldap.beam \
$(OUTDIR)\ELDAPv3.beam
ALL : $(OBJS)
CLEAN :
-@erase ELDAPv3.asn1db ELDAPv3.erl ELDAPv3.hrl
-@erase $(OBJS)
ELDAPv3.erl : ELDAPv3.asn
erlc -bber_bin -W $(EFLAGS) ELDAPv3.asn
$(OUTDIR)\eldap.beam : eldap.erl ELDAPv3.erl
erlc -W $(EFLAGS) -o $(OUTDIR) eldap.erl
$(OUTDIR)\ELDAPv3.beam : ELDAPv3.erl
erlc -W $(EFLAGS) -o $(OUTDIR) ELDAPv3.erl

View File

@ -1,6 +1,7 @@
/* $Id$ */
#include <stdio.h>
#include <string.h>
#include <erl_driver.h>
#include <ei.h>
#include <expat.h>

View File

@ -20,7 +20,7 @@ CLEAN :
-@erase iconv_erl.obj
-@erase iconv_erl.pch
-@erase vc60.idb
-@erase *.beam
-@erase $(OBJS)
$(OUTDIR)\iconv.beam : iconv.erl
erlc -W $(EFLAGS) -o $(OUTDIR) iconv.erl
@ -32,7 +32,7 @@ $(OUTDIR)\mod_irc_connection.beam : mod_irc_connection.erl
erlc -W $(EFLAGS) -o $(OUTDIR) mod_irc_connection.erl
CPP=cl.exe
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\include" /I "$(GNUWIN_DIR)\include" /D "WIN32" /D "NDEBUG" /D "_USRDLL" /D "_MBCS" /Fpiconv_erl.pch /YX /FD /c
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\include" /I "$(GNUWIN_DIR)\include" /D "__WIN32__" /D "WIN32" /D "NDEBUG" /D "_USRDLL" /D "_MBCS" /Fpiconv_erl.pch /YX /FD /c
.c.obj::
$(CPP) @<<
@ -40,7 +40,7 @@ CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\in
<<
LINK32=link.exe
LINK32_FLAGS=kernel32.lib "$(ERLANG_DIR)\usr\lib\erl_dll.lib" "$(EI_DIR)\lib\ei.lib" "$(EI_DIR)\lib\erl_interface.lib" "$(GNUWIN_DIR)\lib\libiconv.lib" /nologo /subsystem:console /dll /pdb:none /machine:I386 /out:$(OUTDIR)\iconv_erl.dll
LINK32_FLAGS=kernel32.lib "$(EI_DIR)\lib\ei.lib" "$(EI_DIR)\lib\erl_interface.lib" "$(GNUWIN_DIR)\lib\libiconv.lib" /nologo /subsystem:console /dll /pdb:none /machine:I386 /out:$(OUTDIR)\iconv_erl.dll /nodefaultlib:libcmt
LINK32_OBJS=iconv_erl.obj
$(OUTDIR)\iconv_erl.dll : $(LINK32_OBJS)

View File

@ -1,6 +1,7 @@
/* $Id$ */
#include <stdio.h>
#include <string.h>
#include <erl_driver.h>
#include <ei.h>
#include <iconv.h>

View File

@ -11,7 +11,7 @@ OBJS = \
ALL : $(OBJS)
CLEAN :
-@erase *.beam
-@erase $(OBJS)
$(OUTDIR)\mod_muc.beam : mod_muc.erl
erlc -W $(EFLAGS) -o $(OUTDIR) mod_muc.erl

View File

@ -10,7 +10,7 @@ OBJS = \
ALL : $(OBJS)
CLEAN :
-@erase *.beam
-@erase $(OBJS)
$(OUTDIR)\mod_pubsub.beam : mod_pubsub.erl
erlc -W $(EFLAGS) -o $(OUTDIR) mod_pubsub.erl

View File

@ -19,7 +19,7 @@ $(OUTDIR)\stringprep.beam : stringprep.erl
erlc -W $(EFLAGS) -o $(OUTDIR) stringprep.erl
CPP=cl.exe
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\include" /D "WIN32" /D "NDEBUG" /D "_USRDLL" /D "_MBCS" /Fpstringprep_drv.pch /YX /FD /c
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\include" /D "__WIN32__" /D "WIN32" /D "NDEBUG" /D "_USRDLL" /D "_MBCS" /Fpstringprep_drv.pch /YX /FD /c
.c.obj::
$(CPP) @<<
@ -27,7 +27,7 @@ CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\in
<<
LINK32=link.exe
LINK32_FLAGS=kernel32.lib "$(ERLANG_DIR)\usr\lib\erl_dll.lib" "$(EI_DIR)\lib\ei.lib" "$(EI_DIR)\lib\erl_interface.lib" /nologo /subsystem:console /dll /pdb:none /machine:I386 /out:$(OUTDIR)\stringprep_drv.dll
LINK32_FLAGS=kernel32.lib "$(EI_DIR)\lib\ei.lib" "$(EI_DIR)\lib\erl_interface.lib" /nologo /subsystem:console /dll /pdb:none /machine:I386 /out:$(OUTDIR)\stringprep_drv.dll /nodefaultlib:libcmt
LINK32_OBJS=stringprep_drv.obj

View File

@ -1,6 +1,7 @@
/* $Id$ */
#include <stdio.h>
#include <string.h>
#include <erl_driver.h>
#include <ei.h>

24
src/web/Makefile.win32 Normal file
View File

@ -0,0 +1,24 @@
include ..\Makefile.inc
OUTDIR = ..
EFLAGS = -I .. -pz ..
OBJS = \
$(OUTDIR)\ejabberd_http.beam \
$(OUTDIR)\ejabberd_web.beam \
$(OUTDIR)\ejabberd_http_poll.beam
ALL : $(OBJS)
CLEAN :
-@erase $(OBJS)
$(OUTDIR)\ejabberd_http.beam : ejabberd_http.erl
erlc -W $(EFLAGS) -o $(OUTDIR) ejabberd_http.erl
$(OUTDIR)\ejabberd_web.beam : ejabberd_web.erl
erlc -W $(EFLAGS) -o $(OUTDIR) ejabberd_web.erl
$(OUTDIR)\ejabberd_http_poll.beam : ejabberd_http_poll.erl
erlc -W $(EFLAGS) -o $(OUTDIR) ejabberd_http_poll.erl

View File

@ -43,7 +43,10 @@ make_xhtml(Els) ->
-define(AC(URL, Text), ?A(URL, [?C(Text)])).
-define(P, ?X("p")).
-define(BR, ?X("br")).
-define(INPUT(Type, Name, Value),
?XA("input", [{"type", Type},
{"name", Name},
{"value", Value}])).
process_get(#request{user = User,
@ -130,7 +133,7 @@ process_admin(#request{user = User,
{"cols", "80"}],
ACLs),
?BR,
?XA("input", [{"type", "submit"}])
?INPUT("submit", "", "")
])
]);
@ -168,13 +171,9 @@ process_admin(#request{method = Method,
[?XAE("form", [{"method", "post"}],
[acls_to_xhtml(ACLs),
?BR,
?XA("input", [{"type", "submit"},
{"name", "delete"},
{"value", "Delete Selected"}]),
?INPUT("submit", "delete", "Delete Selected"),
?C(" "),
?XA("input", [{"type", "submit"},
{"name", "submit"},
{"value", "Submit"}])
?INPUT("submit", "submit", "Submit")
])
]);
@ -241,17 +240,27 @@ process_admin(#request{user = User,
{"cols", "80"}],
Access),
?BR,
?XA("input", [{"type", "submit"}])
?INPUT("submit", "", "")
])
]);
process_admin(#request{method = Method,
user = User,
path = ["access"],
q = Query,
lang = Lang} = Request) ->
user = User,
path = ["access"],
q = Query,
lang = Lang} = Request) ->
?INFO_MSG("query: ~p", [Query]),
Res = nothing,
Res = case Method of
'POST' ->
case catch access_parse_query(Query) of
{'EXIT', _} ->
error;
ok ->
ok
end;
_ ->
nothing
end,
AccessRules =
ets:select(config,
[{{config, {access, '$1'}, '$2'},
@ -266,9 +275,47 @@ process_admin(#request{method = Method,
[?XAE("form", [{"method", "post"}],
[access_rules_to_xhtml(AccessRules),
?BR,
?XA("input", [{"type", "submit"},
{"name", "delete"},
{"value", "Delete Selected"}])
?INPUT("submit", "delete", "Delete Selected")
])
]);
process_admin(#request{method = Method,
user = User,
path = ["access", SName],
q = Query,
lang = Lang} = Request) ->
?INFO_MSG("query: ~p", [Query]),
Name = list_to_atom(SName),
Res = case lists:keysearch("rules", 1, Query) of
{value, {_, String}} ->
case parse_access_rule(String) of
{ok, Rs} ->
ejabberd_config:add_global_option(
{access, Name}, Rs),
ok;
_ ->
error
end;
_ ->
nothing
end,
Rules = case ejabberd_config:get_global_option({access, Name}) of
undefined ->
[];
Rs1 ->
Rs1
end,
make_xhtml([?XC("h1",
"ejabberd access rule '" ++ SName ++ "' configuration")] ++
case Res of
ok -> [?C("submited"), ?P];
error -> [?C("bad format"), ?P];
nothing -> []
end ++
[?XAE("form", [{"method", "post"}],
[access_rule_to_xhtml(Rules),
?BR,
?INPUT("submit", "submit", "")
])
]);
@ -306,28 +353,20 @@ acls_to_xhtml(ACLs) ->
SName = atom_to_list(Name),
ID = term_to_id(ACL),
?XE("tr",
[?XE("td",
[?XA("input", [{"type", "checkbox"},
{"name", "selected"},
{"value", ID}])]),
[?XE("td", [?INPUT("checkbox", "selected", ID)]),
?XC("td", SName)] ++
acl_spec_to_xhtml(ID, Spec)
)
end, ACLs) ++
[?XE("tr",
[?X("td"),
?XE("td",
[?XA("input", [{"type", "text"},
{"name", "namenew"},
{"value", ""}])]
)] ++
?XE("td", [?INPUT("text", "namenew", "")])
] ++
acl_spec_to_xhtml("new", {user, ""})
)]
)]).
-define(ACLINPUT(Text), ?XE("td", [?XA("input", [{"type", "text"},
{"name", "value" ++ ID},
{"value", Text}])])).
-define(ACLINPUT(Text), ?XE("td", [?INPUT("text", "value" ++ ID, Text)])).
acl_spec_to_text({user, U}) ->
{user, U};
@ -445,10 +484,7 @@ access_rules_to_xhtml(AccessRules) ->
SName = atom_to_list(Name),
ID = term_to_id(Access),
?XE("tr",
[?XE("td",
[?XA("input", [{"type", "checkbox"},
{"name", "selected"},
{"value", ID}])]),
[?XE("td", [?INPUT("checkbox", "selected", ID)]),
?XE("td", [?AC(SName ++ "/", SName)]),
?XC("td", term_to_string(Rules))
]
@ -456,19 +492,84 @@ access_rules_to_xhtml(AccessRules) ->
end, AccessRules) ++
[?XE("tr",
[?X("td"),
?XE("td",
[?XA("input", [{"type", "text"},
{"name", "namenew"},
{"value", ""}])]
),
?XE("td",
[?XA("input", [{"type", "submit"},
{"name", "addnew"},
{"value", "Add New"}])])
?XE("td", [?INPUT("text", "namenew", "")]),
?XE("td", [?INPUT("submit", "addnew", "Add New")])
]
)]
)]).
access_parse_query(Query) ->
AccessRules =
ets:select(config,
[{{config, {access, '$1'}, '$2'},
[],
[{{access, '$1', '$2'}}]}]),
case lists:keysearch("addnew", 1, Query) of
{value, _} ->
access_parse_addnew(AccessRules, Query);
_ ->
case lists:keysearch("delete", 1, Query) of
{value, _} ->
access_parse_delete(AccessRules, Query)
end
end.
access_parse_addnew(AccessRules, Query) ->
case lists:keysearch("namenew", 1, Query) of
{value, {_, String}} when String /= "" ->
Name = list_to_atom(String),
ejabberd_config:add_global_option({access, Name}, []),
ok
end.
access_parse_delete(AccessRules, Query) ->
lists:foreach(
fun({access, Name, _Rules} = AccessRule) ->
ID = term_to_id(AccessRule),
case lists:member({"selected", ID}, Query) of
true ->
mnesia:transaction(
fun() ->
mnesia:delete({config, {access, Name}})
end);
_ ->
ok
end
end, AccessRules),
ok.
access_rule_to_xhtml(Rules) ->
Text = lists:flatmap(
fun({Access, ACL} = Rule) ->
SAccess = atom_to_list(Access),
SACL = atom_to_list(ACL),
SAccess ++ "\t" ++ SACL ++ "\n"
end, Rules),
?XAC("textarea", [{"name", "rules"},
{"rows", "16"},
{"cols", "80"}],
Text).
parse_access_rule(Text) ->
Strings = string:tokens(Text, "\r\n"),
case catch lists:flatmap(
fun(String) ->
case string:tokens(String, "\s\t") of
[Access, ACL] ->
[{list_to_atom(Access), list_to_atom(ACL)}];
[] ->
[]
end
end, Strings) of
{'EXIT', _Reason} ->
error;
Rs ->
{ok, Rs}
end.