2 * Copyright (C) 2009-2010 ProFUSION embedded systems
3 * Copyright (C) 2009-2013 Samsung Electronics. All rights reserved.
4 * Copyright (C) 2012 Intel Corporation
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
26 #include <Ecore_Evas.h>
27 #include <Ecore_IMF.h>
32 #include "command_line_efl.h"
33 #include "eweb_context.h"
34 #include "ewk_global_data.h"
35 #include "public/ewk_log.h"
36 #include "public/ewk_view.h"
37 #include "private/webview_delegate_ewk.h"
38 #include "private/ewk_context_private.h"
39 #include "private/ewk_private.h"
40 #include "private/ewk_main_private.h"
42 #include "ecore_x_wayland_wrapper.h"
44 static int _ewkInitCount = 0;
46 /////////////////////////////////////////////////////////////////////////////
47 //private function declaration here
48 static void _ewk_init_web_engine(void);
49 static void _ewk_shutdown_web_engine(void);
51 extern std::string g_homeDirectory;
55 * @brief the log domain identifier that is used with EINA's macros
57 int _ewk_log_dom = -1;
58 #if defined(USE_WAYLAND) && TIZEN_VERSION_AT_LEAST(5, 0, 0)
59 Ecore_Wl2_Display* _ecore_wl2_display = NULL;
65 return ++_ewkInitCount;
70 _ewk_log_dom = eina_log_domain_register("ewebview-blink", EINA_COLOR_ORANGE);
71 if (_ewk_log_dom < 0) {
72 EINA_LOG_CRIT("could not register log domain 'ewebview-blink'");
73 goto error_log_domain;
77 CRITICAL("could not init evas.");
82 CRITICAL("could not init ecore.");
86 if (!ecore_evas_init()) {
87 CRITICAL("could not init ecore_evas.");
88 goto error_ecore_evas;
91 if (!ecore_imf_init()) {
92 CRITICAL("could not init ecore_imf.");
96 #if defined(USE_WAYLAND)
97 #if TIZEN_VERSION_AT_LEAST(5, 0, 0)
98 if (!ecore_wl2_init()) {
100 if (!ecore_wl_init(0)) {
101 #endif // TIZEN_VERSION_AT_LEAST(5, 0, 0)
102 ERR("could not init ecore_wl.");
105 #if TIZEN_VERSION_AT_LEAST(5, 0, 0)
106 if (!_ecore_wl2_display)
107 _ecore_wl2_display = ecore_wl2_display_connect(NULL);
108 #endif // TIZEN_VERSION_AT_LEAST(5, 0, 0)
110 if (!ecore_x_init(0)) {
111 CRITICAL("could not init ecore_x.");
117 CRITICAL("Could not init edje.");
121 // FIXME: do we need glib integration like WebKit?
123 #if !GLIB_CHECK_VERSION(2, 35, 0)
127 if (!ecore_main_loop_glib_integrate()) {
128 WARN("Ecore was not compiled with GLib support, some plugins will not "
129 "work (ie: Adobe Flash)");
133 _ewk_init_web_engine();
134 return ++_ewkInitCount;
137 #if defined(USE_WAYLAND)
138 #if TIZEN_VERSION_AT_LEAST(5, 0, 0)
139 if (_ecore_wl2_display) {
140 ecore_wl2_display_disconnect(_ecore_wl2_display);
141 _ecore_wl2_display = NULL;
142 ecore_wl2_shutdown();
146 #endif // TIZEN_VERSION_AT_LEAST(5, 0, 0)
152 ecore_imf_shutdown();
154 ecore_evas_shutdown();
160 eina_log_domain_unregister(_ewk_log_dom);
168 int ewk_shutdown(void)
170 if (!_ewkInitCount || --_ewkInitCount)
171 return _ewkInitCount;
173 _ewk_shutdown_web_engine();
176 #if defined(USE_WAYLAND)
177 #if TIZEN_VERSION_AT_LEAST(5, 0, 0)
178 if (_ecore_wl2_display) {
179 ecore_wl2_display_disconnect(_ecore_wl2_display);
180 _ecore_wl2_display = NULL;
181 ecore_wl2_shutdown();
185 #endif // TIZEN_VERSION_AT_LEAST(5, 0, 0)
189 ecore_imf_shutdown();
190 ecore_evas_shutdown();
193 eina_log_domain_unregister(_ewk_log_dom);
200 void ewk_set_arguments(int argc, char** argv)
202 CommandLineEfl::Init(argc, argv);
205 void ewk_home_directory_set(const char* path)
208 g_homeDirectory.clear();
210 g_homeDirectory = path;
213 /////////////////////////////////////////////////////////////////////////////////////////////
214 //Private functions implementations for ewk_main module
216 //Initialize web engine
217 void _ewk_init_web_engine()
221 void _ewk_shutdown_web_engine(void)
223 //TODO: any web engine destroy to be done here
224 CommandLineEfl::Shutdown();
225 Ewk_Context::DefaultContextRelease();
226 EwkGlobalData::Delete();