]> granicus.if.org Git - ejabberd/commitdiff
Always build eimp dependency
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Mon, 15 Jan 2018 09:54:57 +0000 (12:54 +0300)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Mon, 15 Jan 2018 09:54:57 +0000 (12:54 +0300)
Even if no suitable C graphics libraries are detected
at compile time, the package is still usable because it
provides `eimp:get_type/1` which is used by mod_avatar.

configure.ac
ejabberd.yml.example
rebar.config
src/ejabberd_app.erl
src/misc.erl
src/mod_avatar.erl
src/mod_http_upload.erl
vars.config.in

index 17d32ac18740430ab5dc2f6dc68b3cec2adad60c..f09287ed0126337f8b3eddb6d502b97eb3d576dd 100644 (file)
@@ -244,14 +244,6 @@ AC_ARG_ENABLE(sip,
   *) AC_MSG_ERROR(bad value ${enableval} for --enable-sip) ;;
 esac],[if test "x$sip" = "x"; then sip=false; fi])
 
-AC_ARG_ENABLE(graphics,
-[AC_HELP_STRING([--enable-graphics], [enable support for graphic images manipulation (default: yes)])],
-[case "${enableval}" in
-  yes) graphics=true ;;
-  no)  graphics=false ;;
-  *) AC_MSG_ERROR(bad value ${enableval} for --enable-graphics) ;;
-esac],[if test "x$graphics" = "x"; then graphics=true; fi])
-
 AC_CONFIG_FILES([Makefile
                 vars.config
                 src/ejabberd.app.src])
@@ -297,7 +289,6 @@ AC_SUBST(iconv)
 AC_SUBST(stun)
 AC_SUBST(sip)
 AC_SUBST(debug)
-AC_SUBST(graphics)
 AC_SUBST(tools)
 AC_SUBST(latest_deps)
 AC_SUBST(system_deps)
index 4fea180e613d85cb5e1e6d6c61621fa6e474ded0..49506ed9c4a1d1ce3f85995704d451a08296cec5 100644 (file)
@@ -818,10 +818,7 @@ modules:
   mod_vcard:
     search: false
   mod_vcard_xupdate: {}
-  ## Convert all avatars posted by Android clients from WebP to JPEG
-  ## mod_avatar:  # this module needs compile option --enable-graphics
-  ##   convert:
-  ##     webp: jpeg
+  mod_avatar: {}
   mod_version: {}
   mod_stream_mgmt: {}
   ##   Non-SASL Authentication (XEP-0078) is now disabled by default
index e852bf430ce3c8be17da923d8dac39fa72efd1a7..0b40ade57bb81901aa6509701f27badbec1c7f77 100644 (file)
@@ -32,6 +32,7 @@
         {luerl, ".*", {git, "https://github.com/rvirding/luerl", {tag, "v0.2"}}},
         {jose, ".*", {git, "https://github.com/potatosalad/erlang-jose", {tag, "1.8.4"}}},
         {fs, ".*", {git, "https://github.com/synrc/fs", "bed9467"}},
+       {eimp, ".*", {git, "https://github.com/processone/eimp", "4ba6363"}},
         {if_var_true, stun, {stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.20"}}}},
         {if_var_true, sip, {esip, ".*", {git, "https://github.com/processone/esip", {tag, "1.0.21"}}}},
         {if_var_true, mysql, {p1_mysql, ".*", {git, "https://github.com/processone/p1_mysql",
@@ -46,7 +47,6 @@
                                            {tag, "1.0.3"}}}},
         {if_var_true, riak, {riakc, ".*", {git, "https://github.com/processone/riak-erlang-client",
                                            {tag, {if_version_above, "19", "develop", "2.5.3"}}}}},
-        {if_var_true, graphics, {eimp, ".*", {git, "https://github.com/processone/eimp", {tag, "1.0.2"}}}},
         %% Elixir support, needed to run tests
         {if_var_true, elixir, {elixir, ".*", {git, "https://github.com/elixir-lang/elixir",
                                               {tag, {if_version_above, "17", "v1.4.4", "v1.1.1"}}}}},
@@ -93,7 +93,6 @@
             {if_var_true, debug, debug_info},
             {if_var_true, sip, {d, 'SIP'}},
             {if_var_true, stun, {d, 'STUN'}},
-            {if_var_true, graphics, {d, 'GRAPHICS'}},
             {if_var_true, roster_gateway_workaround, {d, 'ROSTER_GATWAY_WORKAROUND'}},
             {if_var_match, db_type, mssql, {d, 'mssql'}},
             {if_var_true, elixir, {d, 'ELIXIR_ENABLED'}},
 {post_hook_configure, [{"fast_tls", []},
                        {"stringprep", []},
                        {"fast_yaml", []},
+                      {"eimp", []},
                        {if_var_true, sip, {"esip", []}},
                        {"fast_xml", [{if_var_true, full_xml, "--enable-full-xml"}]},
                        {if_var_true, pam, {"epam", []}},
                        {if_var_true, zlib, {"ezlib", []}},
-                       {if_var_true, graphics, {"eimp", []}},
                        {if_var_true, iconv, {"iconv", []}}]}.
 
 {port_env, [{"CFLAGS", "-g -O2 -Wall"}]}.
index 0790c416888297c618762845cac0b331862e544c..a7e03d990949f5c8d2299e0d805004a6f44ec52c 100644 (file)
@@ -150,7 +150,7 @@ start_apps() ->
     ejabberd:start_app(fast_tls),
     ejabberd:start_app(xmpp),
     ejabberd:start_app(cache_tab),
-    start_eimp().
+    ejabberd:start_app(eimp).
 
 setup_if_elixir_conf_used() ->
   case ejabberd_config:is_using_elixir_config() of
@@ -174,11 +174,3 @@ start_elixir_application() ->
        _ ->
            ok
     end.
-
--ifdef(GRAPHICS).
-start_eimp() ->
-    ejabberd:start_app(eimp).
--else.
-start_eimp() ->
-    ok.
--endif.
index b7654cbea0fefadae7cb30c3821e48f5f24aaf73..9f3210d5e063174f93d99a01a210db53ec8d5a26 100644 (file)
@@ -33,7 +33,7 @@
         atom_to_binary/1, binary_to_atom/1, tuple_to_binary/1,
         l2i/1, i2l/1, i2l/2, expr_to_term/1, term_to_expr/1,
         now_to_usec/1, usec_to_now/1, encode_pid/1, decode_pid/2,
-        compile_exprs/2, join_atoms/2, try_read_file/1, have_eimp/0,
+        compile_exprs/2, join_atoms/2, try_read_file/1,
         css_dir/0, img_dir/0, js_dir/0, read_css/1, read_img/1, read_js/1]).
 
 %% Deprecated functions
@@ -214,12 +214,6 @@ try_read_file(Path) ->
            erlang:error(badarg)
     end.
 
--ifdef(GRAPHICS).
-have_eimp() -> true.
--else.
-have_eimp() -> false.
--endif.
-
 -spec css_dir() -> file:filename().
 css_dir() ->
     case os:getenv("EJABBERD_CSS_PATH") of
index c11c687796c1571fb234f94ecccc733e1b26058c..b72946df44648cd4add6c9efbb0c0cc611df0044 100644 (file)
 %%% API
 %%%===================================================================
 start(Host, _Opts) ->
-    case misc:have_eimp() of
-       true ->
-           ejabberd_hooks:add(pubsub_publish_item, Host, ?MODULE,
-                              pubsub_publish_item, 50),
-           ejabberd_hooks:add(vcard_iq_set, Host, ?MODULE,
-                              vcard_iq_convert, 30),
-           ejabberd_hooks:add(vcard_iq_set, Host, ?MODULE,
-                              vcard_iq_publish, 100);
-       false ->
-           ?CRITICAL_MSG("ejabberd is built without "
-                         "graphics support: reconfigure it with "
-                         "--enable-graphics or disable '~s'",
-                         [?MODULE]),
-           {error, graphics_not_compiled}
-    end.
+    ejabberd_hooks:add(pubsub_publish_item, Host, ?MODULE,
+                      pubsub_publish_item, 50),
+    ejabberd_hooks:add(vcard_iq_set, Host, ?MODULE,
+                      vcard_iq_convert, 30),
+    ejabberd_hooks:add(vcard_iq_set, Host, ?MODULE,
+                      vcard_iq_publish, 100).
 
 stop(Host) ->
     ejabberd_hooks:delete(pubsub_publish_item, Host, ?MODULE,
@@ -416,35 +407,21 @@ decode_mime_type(MimeType) ->
 encode_mime_type(Type) ->
     <<"image/", (atom_to_binary(Type, latin1))/binary>>.
 
-mod_opt_type({convert, png}) ->
-    fun(jpeg) -> jpeg;
-       (webp) -> webp;
-       (gif) -> gif
-    end;
-mod_opt_type({convert, webp}) ->
-    fun(jpeg) -> jpeg;
-       (png) -> png;
-       (gif) -> gif
-    end;
-mod_opt_type({convert, jpeg}) ->
-    fun(png) -> png;
-       (webp) -> webp;
-       (gif) -> gif
-    end;
-mod_opt_type({convert, gif}) ->
-    fun(png) -> png;
-       (jpeg) -> jpeg;
-       (webp) -> webp
-    end;
-mod_opt_type({convert, default}) ->
-    fun(png) -> png;
-       (webp) -> webp;
-       (jpeg) -> jpeg;
-       (gif) -> gif
+warn(Format) ->
+    ?WARNING_MSG("ejabberd is not compiled with ~p support", [Format]).
+
+mod_opt_type({convert, From}) when From == webp; From == jpeg;
+                                  From == png; From == gif ->
+    fun(To) when is_atom(To), To /= From ->
+           case eimp:is_supported(From) of
+               false ->
+                   warn(From);
+               true ->
+                   case eimp:is_supported(To) of
+                       false -> warn(To);
+                       true -> To
+                   end
+           end
     end;
 mod_opt_type(_) ->
-    [{convert, default},
-     {convert, webp},
-     {convert, png},
-     {convert, gif},
-     {convert, jpeg}].
+    [{convert, T} || T <- [default|eimp:supported_formats()]].
index f7ff56b0b3c760ed72b3bd3653afdd9dcef838bc..df8362d4f4dc2d8f159c466f2b6a1d0341b121f2 100644 (file)
@@ -196,7 +196,19 @@ mod_opt_type(custom_headers) ->
 mod_opt_type(rm_on_unregister) ->
     fun(B) when is_boolean(B) -> B end;
 mod_opt_type(thumbnail) ->
-    fun(B) when is_boolean(B) -> B end;
+    fun(true) ->
+           case eimp:supported_formats() of
+               [] ->
+                   ?WARNING_MSG("ejabberd is built without image converter "
+                                "support, option '~s' is ignored",
+                                [thumbnail]),
+                   erlang:error(badarg);
+               _ ->
+                   true
+           end;
+       (false) ->
+           false
+    end;
 mod_opt_type(_) ->
     [host, hosts, name, access, max_size, secret_length, jid_in_url, file_mode,
      dir_mode, docroot, put_url, get_url, service_url, custom_headers,
@@ -237,20 +249,6 @@ init([ServerHost, Opts]) ->
        Mode ->
            file:change_mode(DocRoot2, Mode)
     end,
-    case Thumbnail of
-       true ->
-           case misc:have_eimp() of
-               false ->
-                   ?ERROR_MSG("ejabberd is built without graphics support, "
-                              "please rebuild it with --enable-graphics or "
-                              "set 'thumbnail: false' for module '~s' in "
-                              "ejabberd.yml", [?MODULE]);
-               _ ->
-                   ok
-           end;
-       false ->
-           ok
-    end,
     lists:foreach(
       fun(Host) ->
              ejabberd_router:register_route(Host, ServerHost)
index ff549242ddc20fbda63dcee0de40e5a54b1d8689..44dd40c1c6a947194b3ef5de990877816f23f8e6 100644 (file)
@@ -43,7 +43,6 @@
 {iconv, @iconv@}.
 {stun, @stun@}.
 {sip, @sip@}.
-{graphics, @graphics@}.
 
 %% Version
 {vsn, "@PACKAGE_VERSION@"}.