2 * Copyright (C) 2009-2010 ProFUSION embedded systems
3 * Copyright (C) 2009-2016 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 Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 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 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this library; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "ewk_main_internal.h"
24 #include <Ecore_Evas.h>
25 #include <Ecore_IMF.h>
30 #include "command_line_efl.h"
31 #include "eweb_context.h"
32 #include "ewk_global_data.h"
33 #include "ewk_log_internal.h"
35 #include "private/webview_delegate_ewk.h"
36 #include "private/ewk_context_private.h"
37 #include "private/ewk_private.h"
38 #include "private/ewk_main_private.h"
40 #include "ecore_x_wayland_wrapper.h"
42 static int _ewkInitCount = 0;
44 /////////////////////////////////////////////////////////////////////////////
45 //private function declaration here
46 static void _ewk_init_web_engine(void);
47 static void _ewk_shutdown_web_engine(void);
49 extern std::string g_homeDirectory;
53 * @brief the log domain identifier that is used with EINA's macros
55 int _ewk_log_dom = -1;
56 #if defined(USE_WAYLAND) && TIZEN_VERSION_AT_LEAST(5, 0, 0)
57 Ecore_Wl2_Display* _ecore_wl2_display = NULL;
63 return ++_ewkInitCount;
66 ERR("could not init eina.");
70 _ewk_log_dom = eina_log_domain_register("ewebview-blink", EINA_COLOR_ORANGE);
71 if (_ewk_log_dom < 0) {
72 EINA_LOG_ERR("could not register log domain 'ewebview-blink'");
73 goto error_log_domain;
77 ERR("could not init evas.");
82 ERR("could not init ecore.");
86 if (!ecore_evas_init()) {
87 ERR("could not init ecore_evas.");
88 goto error_ecore_evas;
91 if (!ecore_imf_init()) {
92 ERR("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 ERR("could not init ecore_x.");
117 ERR("Could not init edje.");
121 _ewk_init_web_engine();
122 return ++_ewkInitCount;
125 #if defined(USE_WAYLAND)
126 #if TIZEN_VERSION_AT_LEAST(5, 0, 0)
127 if (_ecore_wl2_display) {
128 ecore_wl2_display_disconnect(_ecore_wl2_display);
129 _ecore_wl2_display = NULL;
130 ecore_wl2_shutdown();
134 #endif // TIZEN_VERSION_AT_LEAST(5, 0, 0)
140 ecore_imf_shutdown();
142 ecore_evas_shutdown();
148 eina_log_domain_unregister(_ewk_log_dom);
156 int ewk_shutdown(void)
158 if (!_ewkInitCount || --_ewkInitCount)
159 return _ewkInitCount;
161 _ewk_shutdown_web_engine();
164 #if defined(USE_WAYLAND)
165 #if TIZEN_VERSION_AT_LEAST(5, 0, 0)
166 if (_ecore_wl2_display) {
167 ecore_wl2_display_disconnect(_ecore_wl2_display);
168 _ecore_wl2_display = NULL;
169 ecore_wl2_shutdown();
173 #endif // TIZEN_VERSION_AT_LEAST(5, 0, 0)
177 ecore_imf_shutdown();
178 ecore_evas_shutdown();
181 eina_log_domain_unregister(_ewk_log_dom);
188 void ewk_set_arguments(int argc, char** argv)
190 CommandLineEfl::Init(argc, argv);
193 void ewk_process_model_set(Ewk_Process_Model process_model)
195 LOG_EWK_API_MOCKUP();
198 void ewk_memory_optimization_mode_enable(void)
200 LOG_EWK_API_MOCKUP();
203 void ewk_home_directory_set(const char* path)
206 g_homeDirectory.clear();
208 g_homeDirectory = path;
211 /////////////////////////////////////////////////////////////////////////////////////////////
212 //Private functions implementations for ewk_main module
214 //Initialize web engine
215 void _ewk_init_web_engine()
219 void _ewk_shutdown_web_engine(void)
221 //TODO: any web engine destroy to be done here
222 CommandLineEfl::Shutdown();
223 Ewk_Context::DefaultContextRelease();
224 EwkGlobalData::Delete();