1/* 2 Copyright (C) 2009-2010 ProFUSION embedded systems 3 Copyright (C) 2009-2011 Samsung Electronics 4 Copyright (C) 2012 Intel Corporation 5 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. 10 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. 15 16 You should have received a copy of the GNU Library General Public License 17 along with this library; see the file COPYING.LIB. If not, write to 18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 Boston, MA 02110-1301, USA. 20*/ 21 22#include "config.h" 23#include "ewk_main.h" 24 25#include "ewk_private.h" 26#include <Ecore.h> 27#include <Ecore_Evas.h> 28#include <Ecore_IMF.h> 29#include <Edje.h> 30#include <Efreet.h> 31#include <Eina.h> 32#include <Evas.h> 33#include <glib-object.h> 34#include <glib.h> 35 36#ifdef HAVE_ECORE_X 37#include <Ecore_X.h> 38#endif 39 40static int _ewkInitCount = 0; 41 42/** 43 * \var _ewk_log_dom 44 * @brief the log domain identifier that is used with EINA's macros 45 */ 46int _ewk_log_dom = -1; 47 48int ewk_init(void) 49{ 50 if (_ewkInitCount) 51 return ++_ewkInitCount; 52 53 if (!eina_init()) 54 goto error_eina; 55 56 _ewk_log_dom = eina_log_domain_register("ewebkit2", EINA_COLOR_ORANGE); 57 if (_ewk_log_dom < 0) { 58 EINA_LOG_CRIT("could not register log domain 'ewebkit2'"); 59 goto error_log_domain; 60 } 61 62 if (!evas_init()) { 63 CRITICAL("could not init evas."); 64 goto error_evas; 65 } 66 67 if (!ecore_init()) { 68 CRITICAL("could not init ecore."); 69 goto error_ecore; 70 } 71 72 if (!ecore_evas_init()) { 73 CRITICAL("could not init ecore_evas."); 74 goto error_ecore_evas; 75 } 76 77 if (!ecore_imf_init()) { 78 CRITICAL("could not init ecore_imf."); 79 goto error_ecore_imf; 80 } 81 82 if (!efreet_init()) { 83 CRITICAL("could not init efreet."); 84 goto error_efreet; 85 } 86 87#ifdef HAVE_ECORE_X 88 if (!ecore_x_init(0)) { 89 CRITICAL("could not init ecore_x."); 90 goto error_ecore_x; 91 } 92#endif 93 94 if (!edje_init()) { 95 CRITICAL("Could not init edje."); 96 goto error_edje; 97 } 98 99#if !GLIB_CHECK_VERSION(2, 35, 0) 100 g_type_init(); 101#endif 102 103 if (!ecore_main_loop_glib_integrate()) { 104 WARN("Ecore was not compiled with GLib support, some plugins will not " 105 "work (ie: Adobe Flash)"); 106 } 107 108 return ++_ewkInitCount; 109 110error_edje: 111#ifdef HAVE_ECORE_X 112 ecore_x_shutdown(); 113error_ecore_x: 114#else 115 efreet_shutdown(); 116#endif 117error_efreet: 118 ecore_imf_shutdown(); 119error_ecore_imf: 120 ecore_evas_shutdown(); 121error_ecore_evas: 122 ecore_shutdown(); 123error_ecore: 124 evas_shutdown(); 125error_evas: 126 eina_log_domain_unregister(_ewk_log_dom); 127 _ewk_log_dom = -1; 128error_log_domain: 129 eina_shutdown(); 130error_eina: 131 return 0; 132} 133 134int ewk_shutdown(void) 135{ 136 if (--_ewkInitCount) 137 return _ewkInitCount; 138 139 edje_shutdown(); 140#ifdef HAVE_ECORE_X 141 ecore_x_shutdown(); 142#endif 143 efreet_shutdown(); 144 ecore_imf_shutdown(); 145 ecore_evas_shutdown(); 146 ecore_shutdown(); 147 evas_shutdown(); 148 eina_log_domain_unregister(_ewk_log_dom); 149 _ewk_log_dom = -1; 150 eina_shutdown(); 151 152 return 0; 153} 154