]> granicus.if.org Git - ejabberd/commitdiff
* (all): Updated win32 stuff (thanks to Sergei Golovan)
authorAlexey Shchepin <alexey@process-one.net>
Sun, 21 Mar 2004 20:27:09 +0000 (20:27 +0000)
committerAlexey Shchepin <alexey@process-one.net>
Sun, 21 Mar 2004 20:27:09 +0000 (20:27 +0000)
* src/web/ejabberd_web.erl: Added interface for access rules
configuration

SVN Revision: 221

13 files changed:
ChangeLog
doc/guide.tex
src/Makefile.win32
src/eldap/Makefile.win32 [new file with mode: 0644]
src/expat_erl.c
src/mod_irc/Makefile.win32
src/mod_irc/iconv_erl.c
src/mod_muc/Makefile.win32
src/mod_pubsub/Makefile.win32
src/stringprep/Makefile.win32
src/stringprep/stringprep_drv.c
src/web/Makefile.win32 [new file with mode: 0644]
src/web/ejabberd_web.erl

index d53329461ceda066bf0465580b95e62697263764..0de59dd9525c502b74a99001e541101f23263e8d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index 2d552d6db476eddb4c9dfebf86813ee3733b09a9..a9ba8d3cc714d1358da8d20cbf5bf0d40e243ac9 100644 (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}
 
index fdf9a13245e35166f2c134fb1d89ad45fe2695bf..dff7f2151601ddad4352745429c8d60288432702 100644 (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)
diff --git a/src/eldap/Makefile.win32 b/src/eldap/Makefile.win32
new file mode 100644 (file)
index 0000000..bcffb01
--- /dev/null
@@ -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
index 82be23073e85c27065215d13d6abe25b0f129362..237295a93ff1e709874183847b75760ccf122826 100644 (file)
@@ -1,6 +1,7 @@
 /* $Id$ */
 
 #include <stdio.h>
+#include <string.h>
 #include <erl_driver.h>
 #include <ei.h>
 #include <expat.h>
index 515f5432ae0317d2b58e700504459a62738893ba..c87bb2869bc5cc6d41bf73b870da444ff8cacaf7 100644 (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)
index de9914184fe643da91ae313f27f68c868b64aefc..923f5cc6fcb9193b9b5ef8e81199a19ec7d423e1 100644 (file)
@@ -1,6 +1,7 @@
 /* $Id$ */
 
 #include <stdio.h>
+#include <string.h>
 #include <erl_driver.h>
 #include <ei.h>
 #include <iconv.h>
index 790032e8856352331f747c8f26d341aa88f91e08..67e6c430e0a8f931080744572c890f171d53441b 100644 (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
index f2421f5a558701cbf428d13dd03bd0f6cdcebb30..bb44dd77865750c7009689921ddf95b581448cd8 100644 (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
index 5339e3d2e0238dc05ba2ccfbfc6fd799c2f26f18..4f46efda29f59bf8fc5f33e7e3750901d28bb3e1 100644 (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
 
index 13aba69bcb6741e729718c47a054dded75d408ea..2ae83be80b35487406bfda32bfaff697d40df913 100644 (file)
@@ -1,6 +1,7 @@
 /* $Id$ */
 
 #include <stdio.h>
+#include <string.h>
 #include <erl_driver.h>
 #include <ei.h>
 
diff --git a/src/web/Makefile.win32 b/src/web/Makefile.win32
new file mode 100644 (file)
index 0000000..f9ee493
--- /dev/null
@@ -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
index d532f78f4c5c55599fdb920be25663e0cffe4208..ca89952da05779a018b88bba1027951b090bd3de 100644 (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.
+