PassRefPtr<cairo_surface_t> createSurfaceForImage(Evas_Object* image) { ASSERT(image); Evas_Coord width; Evas_Coord height; evas_object_image_size_get(image, &width, &height); ASSERT(width > 0 && height > 0); unsigned char* buffer = static_cast<unsigned char*>(const_cast<void*>(evas_object_image_data_get(image, true))); RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_ARGB32, width, height, width * 4)); cairo_status_t status = cairo_surface_status(surface.get()); if (status != CAIRO_STATUS_SUCCESS) { EINA_LOG_ERR("Could not create cairo surface: %s", cairo_status_to_string(status)); return 0; } return surface.release(); }
PassRefPtr<cairo_surface_t> createSurfaceForBackingStore(Ecore_Evas* ee) { ASSERT(ee); int width; int height; ecore_evas_geometry_get(ee, 0, 0, &width, &height); ASSERT(width > 0 && height > 0); unsigned char* buffer = static_cast<unsigned char*>(const_cast<void*>(ecore_evas_buffer_pixels_get(ee))); RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_ARGB32, width, height, width * 4)); cairo_status_t status = cairo_surface_status(surface.get()); if (status != CAIRO_STATUS_SUCCESS) { EINA_LOG_ERR("Could not create cairo surface: %s", cairo_status_to_string(status)); return 0; } return surface.release(); }
EAPI int eio_init(void) { if (++_eio_init_count != 1) return _eio_init_count; if (!eina_init()) { fprintf(stderr, "Eio can not initialize Eina\n"); return --_eio_init_count; } _eio_log_dom_global = eina_log_domain_register("eio", EIO_DEFAULT_LOG_COLOR); if (_eio_log_dom_global < 0) { EINA_LOG_ERR("Eio can not create a general log domain."); goto shutdown_eina; } if (!ecore_init()) { ERR("Can not initialize Eina\n"); goto unregister_log_domain; } EIO_MUTEX_INIT(progress_pool); EIO_MUTEX_INIT(direct_info_pool); EIO_MUTEX_INIT(char_pool); EIO_MUTEX_INIT(associate_pool); eio_monitor_init(); return _eio_init_count; unregister_log_domain: eina_log_domain_unregister(_eio_log_dom_global); _eio_log_dom_global = -1; shutdown_eina: eina_shutdown(); return --_eio_init_count; }
/** * @brief Initialize the Ecore_File library. * * @return 1 or greater on success, 0 on error. * * This function sets up Ecore_File and the services it will use * (monitoring, downloading, PATH related feature). It returns 0 on * failure, otherwise it returns the number of times it has already * been called. * * When Ecore_File is not used anymore, call ecore_file_shutdown() * to shut down the Ecore_File library. */ EAPI int ecore_file_init() { if (++_ecore_file_init_count != 1) return _ecore_file_init_count; if (!ecore_init()) return --_ecore_file_init_count; _ecore_file_log_dom = eina_log_domain_register ("ecore_file", ECORE_FILE_DEFAULT_LOG_COLOR); if(_ecore_file_log_dom < 0) { EINA_LOG_ERR("Impossible to create a log domain for the ecore file module."); return --_ecore_file_init_count; } ecore_file_path_init(); ecore_file_monitor_init(); ecore_file_download_init(); /* FIXME: were the tests disabled for a good reason ? */ /* if (!ecore_file_monitor_init()) goto shutdown_ecore_file_path; if (!ecore_file_download_init()) goto shutdown_ecore_file_monitor; */ return _ecore_file_init_count; /* shutdown_ecore_file_monitor: ecore_file_monitor_shutdown(); shutdown_ecore_file_path: ecore_file_path_shutdown(); return --_ecore_file_init_count; */ }
/** * Initializes the Enlightened Property Library. * * Either this function or @ref ecore_config_system_init must be run * before any other function in the Enlightened Property Library, even * if you have run @ref ecore_init . The name given is used to * determine the default configuration to load. * * @param name Application name * @return @c ECORE_CONFIG_ERR_SUCC if the library is successfully set up. * @c ECORE_CONFIG_ERR_FAIL otherwise. * @ingroup Ecore_Config_App_Lib_Group */ EAPI int ecore_config_init(const char *name) { char *path; Ecore_Config_Prop *list; _ecore_config_log_dom = eina_log_domain_register ("ecore_config", ECORE_CONFIG_DEFAULT_LOG_COLOR); if(_ecore_config_log_dom < 0) { EINA_LOG_ERR("Impossible to create a log domain for the Ecore config module."); return -1; } _ecore_config_system_init_no_load(); __ecore_config_app_name = strdup(name); __ecore_config_server_local = ecore_config_init_local(name); if (!__ecore_config_server_local) return ECORE_CONFIG_ERR_FAIL; list = __ecore_config_bundle_local->data; free( __ecore_config_bundle_local ); __ecore_config_bundle_local = ecore_config_bundle_new(__ecore_config_server_local, "config"); __ecore_config_bundle_local->data = list; path = ecore_config_theme_default_path_get(); ecore_config_string_default("/e/themes/search_path", path); if (path) free(path); list = ecore_config_get("/e/themes/search_path"); if (list) { list->flags |= ECORE_CONFIG_FLAG_SYSTEM; list->flags &= ~ECORE_CONFIG_FLAG_MODIFIED; } return _ecore_config_system_load(); }
/** * @brief Initialize the Ecore_Win32 Drag and Drop module. * * @return 1 or greater on success, 0 on error. * * This function initialize the Drag and Drop module. It returns 0 on * failure, otherwise it returns the number of times it has already * been called. * * When the Drag and Drop module is not used anymore, call * ecore_win32_dnd_shutdown() to shut down the module. */ EAPI int ecore_win32_dnd_init() { HRESULT res; if (_ecore_win32_dnd_init_count > 0) { _ecore_win32_dnd_init_count++; return _ecore_win32_dnd_init_count; } res = OleInitialize(NULL); if ((res != S_OK) && (res != S_FALSE)) { EINA_LOG_ERR("OleInitialize(NULL) returned %ld.", (long) res); return 0; } _ecore_win32_dnd_init_count++; return _ecore_win32_dnd_init_count; }
EOLIAN static Efl_Object * _xml_sax_base_parse_string(Eo *obj, Xml_Base_Data *pd, const char* document) { EINA_LOG_DBG("Parsing document: %s", document); const Efl_Class *current_class = efl_class_get(obj); EINA_LOG_DBG("obj-type referenced:'%s'\n", efl_class_name_get(current_class)); // Create a parser instance for this request. // TODO this currently is here as having one setup in the constructor // results in function references being lost in transit... xmlSAXHandler parser; memset(&parser, 0, sizeof(xmlSAXHandler)); parser.initialized = XML_SAX2_MAGIC; // Setup parser callbacks and start parsing parser.startDocument = _libxml2_document_start; parser.endDocument = _libxml2_document_end; parser.startElementNs = _libxml2_start; parser.endElementNs = _libxml2_end; parser.characters = _libxml2_char; // TODO fix get location issues in XInclude filter. // TODO Work out why this goes to town and kills the parser.... // parser.setDocumentLocator = _libxml2_set_document_locator; // Just in for debugging at the moment. parser.error = _error; parser.warning = _warning; parser.fatalError = _fatalError; if (xmlSAXUserParseMemory(&parser, obj, document, (int) strlen(document)) < 0 ) { EINA_LOG_ERR("Issue parsing XML document"); }; // Make sure we cleanup the current parser. xmlCleanupParser(); return NULL; //pd->result; }
/** * Remove node from list. * * @note this code is meant to be fast: appends are O(1) and do not * walk @a list. * * @note @a item is considered to be inside @a list, no checks are * done to confirm that and giving nodes from different lists * will lead to problems, especially if @a item is the head since * it will be different from @a list and the wrong new head will * be returned. * * @param list existing list head, must not be NULL. * @param item existing list node, must not be NULL. * * @return the new list head. Use it and not @a list anymore. */ EAPI Eina_Inlist * eina_inlist_remove(Eina_Inlist *list, Eina_Inlist *item) { Eina_Inlist *return_l; /* checkme */ EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(item, list); if (EINA_UNLIKELY((item != list) && (!item->prev) && (!item->next))) { eina_error_set(EINA_ERROR_SAFETY_FAILED); EINA_LOG_ERR("safety check failed: item %p does not appear to be part of an inlist!", item); return list; } if (item->next) item->next->prev = item->prev; if (item->prev) { item->prev->next = item->next; return_l = list; } else { return_l = item->next; if (return_l) return_l->last = list->last; } if (item == list->last) list->last = item->prev; item->next = NULL; item->prev = NULL; return return_l; }
static Evas_Object *create_my_group(Evas *canvas, const char *text) { Evas_Object *edje; edje = edje_object_add(canvas); if (!edje) { EINA_LOG_CRIT("could not create edje object!"); return NULL; } if (!edje_object_file_set(edje, PACKAGE_DATA_DIR"/edje_example.edj", "my_group")) { int err = edje_object_load_error_get(edje); const char *errmsg = edje_load_error_str(err); EINA_LOG_ERR("could not load 'my_group' from edje_example.edj: %s", errmsg); evas_object_del(edje); return NULL; } if (text) { if (!edje_object_part_text_set(edje, "text", text)) { EINA_LOG_WARN("could not set the text. " "Maybe part 'text' does not exist?"); } } evas_object_move(edje, 0, 0); evas_object_resize(edje, WIDTH, HEIGHT); evas_object_show(edje); return edje; }
/** * Initialises the Ecore_IMF library. * @return Number of times the library has been initialised without being * shut down. * @ingroup Ecore_IMF_Lib_Group */ EAPI int ecore_imf_init(void) { if (++_ecore_imf_init_count != 1) return _ecore_imf_init_count; if (!ecore_init()) return --_ecore_imf_init_count; _ecore_imf_log_dom = eina_log_domain_register ("ecore_imf", ECORE_IMF_DEFAULT_LOG_COLOR); if (_ecore_imf_log_dom < 0) { EINA_LOG_ERR("Impossible to create a log domain for the Ecore IMF module."); ecore_shutdown(); return --_ecore_imf_init_count; } ecore_imf_module_init(); ECORE_IMF_EVENT_PREEDIT_START = ecore_event_type_new(); ECORE_IMF_EVENT_PREEDIT_END = ecore_event_type_new(); ECORE_IMF_EVENT_PREEDIT_CHANGED = ecore_event_type_new(); ECORE_IMF_EVENT_COMMIT = ecore_event_type_new(); ECORE_IMF_EVENT_DELETE_SURROUNDING = ecore_event_type_new(); return _ecore_imf_init_count; }
/*----------------------------------------------------------------------------* * Module API * *----------------------------------------------------------------------------*/ static Eina_Bool _enesim_image_dom_init(void) { /* @todo * - Register svg specific errors */ egueb_dom_init(); _enesim_image_dom_log = eina_log_domain_register("enesim_image_dom", ENESIM_IMAGE_LOG_COLOR_DEFAULT); if (_enesim_image_dom_log < 0) { EINA_LOG_ERR("Enesim: Can not create a general log domain."); return EINA_FALSE; } /* TODO later we need to register the same provider with every mimetype found on the lib * that supports the render/window interface */ if (!enesim_image_provider_register(&_provider, ENESIM_PRIORITY_PRIMARY, "image/svg+xml")) return EINA_FALSE; if (!enesim_image_finder_register(&_finder)) { enesim_image_provider_unregister(&_provider, "image/svg+xml"); return EINA_FALSE; } return EINA_TRUE; }
EAPI int elm_main(int argc, char **argv) { Ethumb_Client *client; int r = 0; #if ENABLE_NLS setlocale(LC_ALL, ""); bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); #endif eio_init(); elm_need_efreet(); elm_need_ethumb(); elm_init(argc, argv); __log_domain = eina_log_domain_register("ephoto", EINA_COLOR_ORANGE); if (!__log_domain) { EINA_LOG_ERR("Could not register log domain: Ephoto"); r = 1; goto end_log_domain; } elm_theme_extension_add(NULL, PACKAGE_DATA_DIR"/themes/default/ephoto.edj"); if (!efreet_mime_init()) ERR("Could not init efreet_mime!"); client = elm_thumb_ethumb_client_get(); if (!client) { ERR("could not get ethumb_client"); r = 1; goto end; } ethumb_client_crop_align_set(client, 0.5, 0.5); ethumb_client_aspect_set(client, ETHUMB_THUMB_CROP); ethumb_client_orientation_set(client, ETHUMB_THUMB_ORIENT_ORIGINAL); elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); DBG("Logging initialized"); if (argc > 2) { printf("Too Many Arguments!\n"); _ephoto_display_usage(); r = 1; goto end; } else if (argc < 2) { Evas_Object *win = ephoto_window_add(NULL); if (!win) { r = 1; goto end; } } else if (!strncmp(argv[1], "--help", 6)) { _ephoto_display_usage(); r = 0; goto end; } else { char *real = ecore_file_realpath(argv[1]); if (!real) { printf("invalid file or directory: '%s'\n", argv[1]); r = 1; goto end; } Evas_Object *win = ephoto_window_add(real); free(real); if (!win) { r = 1; goto end; } } elm_run(); end: eina_log_domain_unregister(__log_domain); efreet_mime_shutdown(); end_log_domain: elm_shutdown(); eio_shutdown(); return r; }
static void _error(void *user_data, const char *msg, ...) { EINA_LOG_ERR("%s", msg); }
int main(int argc, char *argv[]) { char path[PATH_MAX + 128], buf[PATH_MAX]; FILE *log; int fd; const char *log_file_dir = NULL; const char *hostname_str = NULL; #ifdef HAVE_SYS_RESOURCE_H setpriority(PRIO_PROCESS, 0, 19); #elif _WIN32 SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS); #endif if (!eina_init()) return 1; efreetd_mp_stat = eina_mempool_add("chained_mempool", "struct stat", NULL, sizeof(struct stat), 10); if (!efreetd_mp_stat) return 1; if (!ecore_init()) goto ecore_error; ecore_app_args_set(argc, (const char **)argv); if (!ecore_file_init()) goto ecore_file_error; if (!ipc_init()) goto ipc_error; if (!cache_init()) goto cache_error; log_file_dir = eina_environment_tmp_get(); if (gethostname(buf, sizeof(buf)) < 0) hostname_str = ""; else hostname_str = buf; snprintf(path, sizeof(path), "%s/efreetd_%s_XXXXXX.log", log_file_dir, hostname_str); fd = eina_file_mkstemp(path, NULL); if (fd < 0) { ERR("Can't create log file '%s'\b", path); goto tmp_error; } log = fdopen(fd, "wb"); if (!log) goto tmp_error; eina_log_print_cb_set(eina_log_print_cb_file, log); efreetd_log_dom = eina_log_domain_register("efreetd", EFREETD_DEFAULT_LOG_COLOR); if (efreetd_log_dom < 0) { EINA_LOG_ERR("Efreet: Could not create a log domain for efreetd."); goto tmp_error; } ecore_main_loop_begin(); eina_mempool_del(efreetd_mp_stat); cache_shutdown(); ipc_shutdown(); ecore_file_shutdown(); ecore_shutdown(); eina_log_domain_unregister(efreetd_log_dom); efreetd_log_dom = -1; eina_shutdown(); return 0; tmp_error: cache_shutdown(); cache_error: ipc_shutdown(); ipc_error: ecore_file_shutdown(); ecore_file_error: ecore_shutdown(); ecore_error: if (efreetd_log_dom >= 0) eina_log_domain_unregister(efreetd_log_dom); efreetd_log_dom = -1; eina_shutdown(); return 1; }
EAPI int eio_init(void) { if (++_eio_init_count != 1) return _eio_init_count; if (!eina_init()) { fprintf(stderr, "Eio can not initialize Eina\n"); return --_eio_init_count; } _eio_log_dom_global = eina_log_domain_register("eio", EIO_DEFAULT_LOG_COLOR); if (_eio_log_dom_global < 0) { EINA_LOG_ERR("Eio can not create a general log domain."); goto shutdown_eina; } if (!ecore_init()) { ERR("Can not initialize Ecore\n"); goto unregister_log_domain; } memset(&progress_pool, 0, sizeof(progress_pool)); memset(&direct_info_pool, 0, sizeof(direct_info_pool)); memset(&char_pool, 0, sizeof(char_pool)); memset(&associate_pool, 0, sizeof(associate_pool)); eina_lock_new(&(progress_pool.lock)); progress_pool.mem_size = sizeof (Eio_Progress); eina_lock_new(&(direct_info_pool.lock)); direct_info_pool.mem_size = sizeof (Eio_File_Direct_Info); eina_lock_new(&(char_pool.lock)); char_pool.mem_size = sizeof (Eio_File_Char); eina_lock_new(&(associate_pool.lock)); associate_pool.mem_size = sizeof (Eio_File_Associate); eina_spinlock_new(&(memory_pool_lock)); eina_lock_new(&(memory_pool_mutex)); eina_condition_new(&(memory_pool_cond), &(memory_pool_mutex)); eio_monitor_init(); efreet_mime_init(); io_manager = efl_add(EFL_IO_MANAGER_CLASS, ecore_main_loop_get()); efl_loop_register(ecore_main_loop_get(), EFL_IO_MANAGER_CLASS, io_manager); eina_log_timing(_eio_log_dom_global, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT); return _eio_init_count; unregister_log_domain: eina_log_domain_unregister(_eio_log_dom_global); _eio_log_dom_global = -1; shutdown_eina: eina_shutdown(); return --_eio_init_count; }
static void _assert(Eina_Bool expr, const char* file, int line) { if (!expr) EINA_LOG_ERR("%s:%d ds failed miserably", file, line); }
EAPI int eeze_init(void) { if (++_eeze_init_count != 1) return _eeze_init_count; if (!eina_init()) return --_eeze_init_count; _eeze_udev_log_dom = eina_log_domain_register("eeze_udev", EINA_COLOR_CYAN); if (_eeze_udev_log_dom < 0) { EINA_LOG_ERR("Could not register 'eeze_udev' log domain."); goto eina_fail; } _eeze_net_log_dom = eina_log_domain_register("eeze_net", EINA_COLOR_GREEN); if (_eeze_net_log_dom < 0) { EINA_LOG_ERR("Could not register 'eeze_net' log domain."); goto eina_net_fail; } _eeze_sensor_log_dom = eina_log_domain_register("eeze_sensor", EINA_COLOR_BLUE); if (_eeze_sensor_log_dom < 0) { EINA_LOG_ERR("Could not register 'eeze_sensor' log domain."); goto eina_sensor_fail; } if (!ecore_init()) goto ecore_fail; #ifdef HAVE_EEZE_MOUNT if (!eeze_disk_init()) goto eeze_fail; #endif if (!(udev = udev_new())) { EINA_LOG_ERR("Could not initialize udev library!"); goto fail; } if (!eeze_net_init()) { EINA_LOG_ERR("Error initializing eeze_net subsystems!"); goto net_fail; } if (!eeze_sensor_init()) { EINA_LOG_ERR("Error initializing eeze_sensor subsystems!"); goto sensor_fail; } return _eeze_init_count; sensor_fail: eeze_net_shutdown(); net_fail: udev_unref(udev); fail: #ifdef HAVE_EEZE_MOUNT eeze_disk_shutdown(); eeze_fail: #endif ecore_shutdown(); ecore_fail: eina_log_domain_unregister(_eeze_sensor_log_dom); _eeze_sensor_log_dom = -1; eina_sensor_fail: eina_log_domain_unregister(_eeze_net_log_dom); _eeze_net_log_dom = -1; eina_net_fail: eina_log_domain_unregister(_eeze_udev_log_dom); _eeze_udev_log_dom = -1; eina_fail: eina_shutdown(); return --_eeze_init_count; }
int main(int argc, char **argv) { Edje_Part_Collection_Directory_Entry *ce; Old_Edje_File *oef; Edje_File *nef; Eina_Iterator *it; Eet_File *ef; setlocale(LC_NUMERIC, "C"); ecore_app_no_system_modules(); if (!eina_init()) return -1; _edje_cc_log_dom = eina_log_domain_register ("edje_convert", EDJE_CC_DEFAULT_LOG_COLOR); if (_edje_cc_log_dom < 0) { EINA_LOG_ERR("Enable to create a log domain."); exit(-1); } eet_init(); progname = argv[0]; if (argc > 2 || argc < 2 || !strcmp(argv[1], "-h")) { main_help(); return 0; } _edje_edd_old_init(); _edje_edd_init(); ef = eet_open(argv[1], EET_FILE_MODE_READ_WRITE); if (!ef) { EINA_LOG_ERR("Unable to open `%s'.", argv[1]); return -1; } oef = eet_data_read(ef, _edje_edd_old_edje_file, "edje_file"); if (!oef) { EINA_LOG_ERR("Unable to get edje_file section from old file format, are you sure it's an old file ?"); return -1; } nef = _edje_file_convert(ef, oef); _edje_file_set(nef); /* convert old structure to new one */ it = eina_hash_iterator_data_new(nef->collection); EINA_ITERATOR_FOREACH(it, ce) { Old_Edje_Part_Collection *opc; Edje_Part_Collection *npc; char buf[1024]; int bytes = 0; snprintf(buf, sizeof (buf), "collections/%i", ce->id); opc = eet_data_read(ef, _edje_edd_old_edje_part_collection, buf); if (!opc) { EINA_LOG_ERR("Unable to find collection `%s'[%i] in `%s'.", ce->entry, ce->id, argv[1]); return -1; } npc = _edje_collection_convert(ef, ce, opc); snprintf(buf, sizeof (buf), "edje/collections/%i", ce->id); bytes = eet_data_write(ef, _edje_edd_edje_part_collection, buf, npc, 1); if (bytes <= 0) { EINA_LOG_ERR("Unable to save `%s' in section `%s' of `%s'.", ce->entry, buf, argv[1]); return -1; } }
EAPI int eina_init(void) { const struct eina_desc_setup *itr, *itr_end; if (EINA_LIKELY(_eina_main_count > 0)) return ++_eina_main_count; srand(time(NULL)); while (eina_seed == 0) eina_seed = rand(); #ifdef MT if ((getenv("EINA_MTRACE")) && (getenv("MALLOC_TRACE"))) { _mt_enabled = 1; mtrace(); } #endif if (!eina_log_init()) { fprintf(stderr, "Could not initialize eina logging system.\n"); return 0; } _eina_log_dom = eina_log_domain_register("eina", EINA_LOG_COLOR_DEFAULT); if (_eina_log_dom < 0) { EINA_LOG_ERR("Could not register log domain: eina"); eina_log_shutdown(); return 0; } EINA_ERROR_NOT_MAIN_LOOP = eina_error_msg_static_register( EINA_ERROR_NOT_MAIN_LOOP_STR); #ifdef EFL_HAVE_THREADS # ifdef _WIN32 _eina_main_loop = GetCurrentThreadId(); # else _eina_main_loop = pthread_self(); # endif _eina_pid = getpid(); #endif #ifdef EINA_HAVE_DEBUG_THREADS pthread_mutex_init(&_eina_tracking_lock, NULL); if (getenv("EINA_DEBUG_THREADS")) _eina_threads_debug = atoi(getenv("EINA_DEBUG_THREADS")); #endif itr = _eina_desc_setup; itr_end = itr + _eina_desc_setup_len; for (; itr < itr_end; itr++) { if (!itr->init()) { ERR("Could not initialize eina module '%s'.", itr->name); _eina_shutdown_from_desc(itr); return 0; } } eina_cpu_count_internal(); _eina_main_count = 1; return 1; }
EAPI Eina_Bool eina_mmap_safety_enabled_set(Eina_Bool enabled) { #ifndef HAVE_SIGINFO_T (void) enabled; return EINA_FALSE; #else if (_eina_mmap_log_dom < 0) { _eina_mmap_log_dom = eina_log_domain_register("eina_mmap", EINA_LOG_COLOR_DEFAULT); if (_eina_mmap_log_dom < 0) { EINA_LOG_ERR("Could not register log domain: eina_mmap"); return EINA_FALSE; } } enabled = !!enabled; if (mmap_safe == enabled) return mmap_safe; if (enabled) { struct sigaction sa; /* find out system page size the cleanest way we can */ _eina_mmap_pagesize = eina_cpu_page_size(); /* no zero page device - open it */ if (_eina_mmap_zero_fd < 0) { _eina_mmap_zero_fd = open("/dev/zero", O_RDWR); /* if we don;'t have one - fail to set up mmap safety */ if (_eina_mmap_zero_fd < 0) return EINA_FALSE; eina_file_close_on_exec(_eina_mmap_zero_fd, EINA_TRUE); } /* set up signal handler for SIGBUS */ sa.sa_sigaction = _eina_mmap_safe_sigbus; sa.sa_flags = SA_RESTART | SA_SIGINFO; sigemptyset(&sa.sa_mask); if (sigaction(SIGBUS, &sa, &_eina_mmap_prev_sigaction) == 0) goto done; /* setup of SIGBUS handler failed, lets close zero page dev and fail */ close(_eina_mmap_zero_fd); _eina_mmap_zero_fd = -1; return EINA_FALSE; } else { /* reset signal handler to default for SIGBUS */ if (_eina_mmap_zero_fd >= 0) { close(_eina_mmap_zero_fd); _eina_mmap_zero_fd = -1; } signal(SIGBUS, SIG_DFL); } done: mmap_safe = enabled; return mmap_safe; #endif }
/** * @brief Download the given url to the given destination. * * @param url The complete url to download. * @param dst The local file to save the downloaded to. * @param completion_cb A callback called on download complete. * @param progress_cb A callback called during the download operation. * @param data User data passed to both callbacks. * @param job_ret Job used to abort the download. * @return EINA_TRUE if the download start or EINA_FALSE on failure * * This function starts the download of the URL @p url and saves it to * @p dst. @p url must provide the protocol, including 'http://', * 'ftp://' or 'file://'. Ecore_File must be compiled with CURL to * download using http and ftp protocols. If @p dst is ill-formed, or * if it already exists, the function returns EINA_FALSE. When the * download is complete, the callback @p completion_cb is called and * @p data is passed to it. The @p status parameter of @p completion_cb * will be filled with the status of the download (200, 404,...). The * @p progress_cb is called during the download operation, each time a * packet is received or when CURL wants. It can be used to display the * percentage of the downloaded file. Return 0 from this callback, if provided, * to continue the operation or anything else to abort the download. The only * operations that can be aborted are those with protocol 'http' or 'ftp'. In * that case @p job_ret can be filled. It can be used with * ecore_file_download_abort() or ecore_file_download_abort_all() to * respectively abort one or all download operations. This function returns * EINA_TRUE if the download starts, EINA_FALSE otherwise. */ EAPI Eina_Bool ecore_file_download(const char *url, const char *dst, Ecore_File_Download_Completion_Cb completion_cb, Ecore_File_Download_Progress_Cb progress_cb, void *data, Ecore_File_Download_Job **job_ret) { #ifdef BUILD_ECORE_CON char *dir = ecore_file_dir_get(dst); if (!ecore_file_is_dir(dir)) { EINA_LOG_ERR("%s is not a directory", dir); free(dir); return EINA_FALSE; } free(dir); if (ecore_file_exists(dst)) { EINA_LOG_ERR("%s already exists", dst); return EINA_FALSE; } if (!strncmp(url, "file://", 7)) { /* FIXME: Maybe fork? Might take a while to copy. * Check filesize? */ /* Just copy it */ url += 7; /* skip hostname */ url = strchr(url, '/'); return ecore_file_cp(url, dst); } # ifdef HAVE_CURL else if ((!strncmp(url, "http://", 7)) || (!strncmp(url, "https://", 8)) || (!strncmp(url, "ftp://", 6))) { /* download */ Ecore_File_Download_Job *job; job = _ecore_file_download_curl(url, dst, completion_cb, progress_cb, data); if(job_ret) *job_ret = job; if(job) return EINA_TRUE; else { EINA_LOG_ERR("no job returned\n"); return EINA_FALSE; } return job ? EINA_TRUE : EINA_FALSE; } # else else if ((!strncmp(url, "http://", 7)) || (!strncmp(url, "https://", 8)) || (!strncmp(url, "ftp://", 6))) { (void)completion_cb; (void)progress_cb; (void)data; (void)job_ret; return EINA_FALSE; } # endif else { return EINA_FALSE; } #else completion_cb = NULL; progress_cb = NULL; data = NULL; return EINA_FALSE; #endif /* BUILD_ECORE_CON */ }
Eina_Bool eina_mempool_init(void) { char *path; _eina_mempool_log_dom = eina_log_domain_register("eina_mempool", EINA_LOG_COLOR_DEFAULT); if (_eina_mempool_log_dom < 0) { EINA_LOG_ERR("Could not register log domain: eina_mempool"); return 0; } EINA_ERROR_NOT_MEMPOOL_MODULE = eina_error_msg_static_register( EINA_ERROR_NOT_MEMPOOL_MODULE_STR); _backends = eina_hash_string_superfast_new(NULL); /* dynamic backends */ _modules = eina_module_arch_list_get(NULL, PACKAGE_LIB_DIR "/eina/modules/mp", MODULE_ARCH); path = eina_module_environment_path_get("HOME", "/.eina/mp/modules/mp"); _modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH); if (path) free(path); path = eina_module_environment_path_get("EINA_MODULES_MEMPOOL_DIR", "/eina/modules/mp"); _modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH); if (path) free(path); path = eina_module_symbol_path_get((const void *)eina_init, "/eina/modules/mp"); _modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH); if (path) free(path); if (!_modules) { ERR("no mempool modules able to be loaded."); eina_hash_free(_backends); goto mempool_init_error; } eina_module_list_load(_modules); /* builtin backends */ #ifdef EINA_STATIC_BUILD_BUDDY buddy_init(); #endif #ifdef EINA_STATIC_BUILD_CHAINED_POOL chained_init(); #endif #ifdef EINA_STATIC_BUILD_EMEMOA_FIXED ememoa_fixed_init(); #endif #ifdef EINA_STATIC_BUILD_EMEMOA_UNKNOWN ememoa_unknown_init(); #endif #ifdef EINA_STATIC_BUILD_FIXED_BITMAP fixed_bitmap_init(); #endif #ifdef EINA_STATIC_BUILD_ONE_BIG one_big_init(); #endif #ifdef EINA_STATIC_BUILD_PASS_THROUGH pass_through_init(); #endif return EINA_TRUE; mempool_init_error: eina_log_domain_unregister(_eina_mempool_log_dom); _eina_mempool_log_dom = -1; return EINA_FALSE; }
int main(int argc, char **argv) { int i; struct stat st; #ifdef HAVE_REALPATH char rpath[PATH_MAX], rpath2[PATH_MAX]; #endif setlocale(LC_NUMERIC, "C"); ecore_app_no_system_modules(); if (!eina_init()) return -1; _edje_cc_log_dom = eina_log_domain_register ("edje_cc", EDJE_CC_DEFAULT_LOG_COLOR); if (_edje_cc_log_dom < 0) { EINA_LOG_ERR("Enable to create a log domain."); exit(-1); } if (!eina_log_domain_level_check(_edje_cc_log_dom, EINA_LOG_LEVEL_WARN)) eina_log_domain_level_set("edje_cc", EINA_LOG_LEVEL_WARN); progname = ecore_file_file_get(argv[0]); eina_log_print_cb_set(_edje_cc_log_cb, NULL); tmp_dir = getenv("TMPDIR"); img_dirs = eina_list_append(img_dirs, "."); /* add defines to epp so edc files can detect edje_cc version */ defines = eina_list_append(defines, mem_strdup("-DEDJE_VERSION_12=12")); for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-h")) { main_help(); exit(0); } else if ((!strcmp(argv[i], "-V")) || (!strcmp(argv[i], "--version"))) { printf("Version: %s\n", PACKAGE_VERSION); exit(0); } else if (!strcmp(argv[i], "-v")) { eina_log_domain_level_set("edje_cc", EINA_LOG_LEVEL_INFO); } else if (!strcmp(argv[i], "-no-lossy")) { no_lossy = 1; } else if (!strcmp(argv[i], "-no-comp")) { no_comp = 1; } else if (!strcmp(argv[i], "-no-raw")) { no_raw = 1; } else if (!strcmp(argv[i], "-no-etc1")) { no_etc1 = 1; } else if (!strcmp(argv[i], "-no-etc2")) { no_etc2 = 1; } else if (!strcmp(argv[i], "-no-save")) { no_save = 1; } else if ((!strcmp(argv[i], "-id") || !strcmp(argv[i], "--image_dir")) && (i < (argc - 1))) { i++; img_dirs = eina_list_append(img_dirs, argv[i]); } else if ((!strcmp(argv[i], "-fd") || !strcmp(argv[i], "--font_dir")) && (i < (argc - 1))) { i++; fnt_dirs = eina_list_append(fnt_dirs, argv[i]); } else if ((!strcmp(argv[i], "-sd") || !strcmp(argv[i], "--sound_dir")) && (i < (argc - 1))) { i++; snd_dirs = eina_list_append(snd_dirs, argv[i]); } else if ((!strcmp(argv[i], "-md") || !strcmp(argv[i], "--mo_dir")) && (i < (argc - 1))) { i++; mo_dirs = eina_list_append(mo_dirs, argv[i]); } else if ((!strcmp(argv[i], "-vd") || !strcmp(argv[i], "--vibration_dir")) && (i < (argc - 1))) { i++; vibration_dirs = eina_list_append(vibration_dirs, argv[i]); } else if ((!strcmp(argv[i], "-dd") || !strcmp(argv[i], "--data_dir")) && (i < (argc - 1))) { i++; data_dirs = eina_list_append(data_dirs, argv[i]); } else if ((!strcmp(argv[i], "-td") || !strcmp(argv[i], "--tmp_dir")) && (i < (argc - 1))) { i++; if (!tmp_dir) tmp_dir = argv[i]; } else if ((!strcmp(argv[i], "-l") || !strcmp(argv[i], "--license")) && (i < (argc - 1))) { i++; if (!license) license = argv[i]; else licenses = eina_list_append(licenses, argv[i]); } else if ((!strcmp(argv[i], "-a") || !strcmp(argv[i], "--authors")) && (i < (argc - 1))) { i++; if (!authors) authors = argv[i]; } else if ((!strcmp(argv[i], "-min-quality")) && (i < (argc - 1))) { i++; min_quality = atoi(argv[i]); if (min_quality < 0) min_quality = 0; if (min_quality > 100) min_quality = 100; } else if ((!strcmp(argv[i], "-max-quality")) && (i < (argc - 1))) { i++; max_quality = atoi(argv[i]); if (max_quality < 0) max_quality = 0; if (max_quality > 100) max_quality = 100; } else if (!strcmp(argv[i], "-fastcomp")) { compress_mode = EET_COMPRESSION_SUPERFAST; } else if (!strcmp(argv[i], "-fastdecomp")) { compress_mode = EET_COMPRESSION_VERYFAST; } else if (!strcmp(argv[i], "-threads")) { threads = 1; } else if (!strcmp(argv[i], "-nothreads")) { threads = 0; } else if (!strncmp(argv[i], "-D", 2)) { defines = eina_list_append(defines, mem_strdup(argv[i])); } else if ((!strcmp(argv[i], "-o")) && (i < (argc - 1))) { i++; file_out = argv[i]; } else if ((!strcmp(argv[i], "-w")) && (i < (argc - 1))) { i++; watchfile = argv[i]; unlink(watchfile); } else if (!strcmp(argv[i], "-annotate")) { annotate = 1; } else if ((!strcmp(argv[i], "-deps")) && (i < (argc - 1))) { i++; depfile = argv[i]; unlink(depfile); } else if (!file_in) file_in = argv[i]; else if (!file_out) file_out = argv[i]; } if (!file_in) { ERR("no input file specified."); main_help(); exit(-1); } pfx = eina_prefix_new(argv[0], /* argv[0] value (optional) */ main, /* an optional symbol to check path of */ "EDJE", /* env var prefix to use (XXX_PREFIX, XXX_BIN_DIR etc. */ "edje", /* dir to add after "share" (PREFIX/share/DIRNAME) */ "include/edje.inc", /* a magic file to check for in PREFIX/share/DIRNAME for success */ PACKAGE_BIN_DIR, /* package bin dir @ compile time */ PACKAGE_LIB_DIR, /* package lib dir @ compile time */ PACKAGE_DATA_DIR, /* package data dir @ compile time */ PACKAGE_DATA_DIR /* if locale needed use LOCALE_DIR */ ); /* check whether file_in exists */ #ifdef HAVE_REALPATH if (!realpath(file_in, rpath) || stat(rpath, &st) || !S_ISREG(st.st_mode)) #else if (stat(file_in, &st) || !S_ISREG(st.st_mode)) #endif { ERR("file not found: %s.", file_in); main_help(); exit(-1); } if (!file_out) { char *suffix; if ((suffix = strstr(file_in,".edc")) && (suffix[4] == 0)) { file_out = strdup(file_in); if (file_out) { suffix = strstr(file_out,".edc"); strcpy(suffix,".edj"); } } } if (!file_out) { ERR("no output file specified."); main_help(); exit(-1); } #ifdef HAVE_REALPATH if (realpath(file_out, rpath2) && !strcmp (rpath, rpath2)) #else if (!strcmp (file_in, file_out)) #endif { ERR("input file equals output file."); main_help(); exit(-1); } using_file(file_in, 'E'); if (annotate) using_file(file_out, 'O'); if (!edje_init()) exit(-1); edje_file = mem_alloc(SZ(Edje_File)); edje_file->compiler = strdup("edje_cc"); edje_file->version = EDJE_FILE_VERSION; edje_file->minor = EDJE_FILE_MINOR; edje_file->feature_ver = 1; /* increment this every time we add a field * or feature to the edje file format that * does not load nicely as a NULL or 0 value * and needs a special fallback initialization */ edje_file->base_scale = FROM_INT(1); source_edd(); source_fetch(); data_setup(); compile(); reorder_parts(); data_process_scripts(); data_process_lookups(); data_process_script_lookups(); data_write(); eina_prefix_free(pfx); pfx = NULL; edje_shutdown(); eina_log_domain_unregister(_edje_cc_log_dom); eina_shutdown(); return 0; }
/** * @return Returns > 0 if the initialization was successful, 0 otherwise * @brief Initializes the Efreet system */ EAPI int efreet_init(void) { if (++_efreet_init_count != 1) return _efreet_init_count; if (!eina_init()) return --_efreet_init_count; if (!eet_init()) goto shutdown_eina; if (!ecore_init()) goto shutdown_eet; if (!ecore_file_init()) goto shutdown_ecore; _efreet_log_domain_global = eina_log_domain_register("efreet", EFREET_DEFAULT_LOG_COLOR); if (_efreet_log_domain_global < 0) { EINA_LOG_ERR("Efreet could create a general log domain."); goto shutdown_ecore_file; } if (!efreet_base_init()) goto unregister_log_domain; if (!efreet_cache_init()) goto shutdown_efreet_base; if (!efreet_xml_init()) goto shutdown_efreet_cache; if (!efreet_icon_init()) goto shutdown_efreet_xml; if (!efreet_ini_init()) goto shutdown_efreet_icon; if (!efreet_desktop_init()) goto shutdown_efreet_ini; if (!efreet_menu_init()) goto shutdown_efreet_desktop; if (!efreet_util_init()) goto shutdown_efreet_menu; return _efreet_init_count; shutdown_efreet_menu: efreet_menu_shutdown(); shutdown_efreet_desktop: efreet_desktop_shutdown(); shutdown_efreet_ini: efreet_ini_shutdown(); shutdown_efreet_icon: efreet_icon_shutdown(); shutdown_efreet_xml: efreet_xml_shutdown(); shutdown_efreet_cache: efreet_cache_shutdown(); shutdown_efreet_base: efreet_base_shutdown(); unregister_log_domain: eina_log_domain_unregister(_efreet_log_domain_global); shutdown_ecore_file: ecore_file_shutdown(); shutdown_ecore: ecore_shutdown(); shutdown_eet: eet_shutdown(); shutdown_eina: eina_shutdown(); return --_efreet_init_count; }
int main(int argc, char **argv) { /* TODO: * - Add file monitor on files, so that we catch changes on files * during whilst this program runs. * - Maybe linger for a while to reduce number of cache re-creates. */ Efreet_Cache_Hash hash; Efreet_Cache_Version version; Eina_List *dirs = NULL; Eina_List *systemdirs = NULL; Eina_List *extra_dirs = NULL; Eina_List *l = NULL; Eina_Inarray *stack = NULL; int priority = 0; char *dir = NULL; char *path; int lockfd = -1, tmpfd; int changed = 0; int i; char file[PATH_MAX] = { '\0' }; char util_file[PATH_MAX] = { '\0' }; mode_t um; if (!eina_init()) goto eina_error; _efreet_desktop_cache_log_dom = eina_log_domain_register("efreet_desktop_cache", EFREET_DEFAULT_LOG_COLOR); if (_efreet_desktop_cache_log_dom < 0) { EINA_LOG_ERR("Efreet: Could not create a log domain for efreet_desktop_cache."); return -1; } for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-v")) eina_log_domain_level_set("efreet_desktop_cache", EINA_LOG_LEVEL_DBG); else if ((!strcmp(argv[i], "-h")) || (!strcmp(argv[i], "-help")) || (!strcmp(argv[i], "--h")) || (!strcmp(argv[i], "--help"))) { printf("Options:\n"); printf(" -v Verbose mode\n"); printf(" -d dir1 dir2 Extra dirs\n"); exit(0); } else if (!strcmp(argv[i], "-d")) { while ((i < (argc - 1)) && (argv[(i + 1)][0] != '-')) extra_dirs = eina_list_append(extra_dirs, argv[++i]); } } extra_dirs = eina_list_sort(extra_dirs, -1, EINA_COMPARE_CB(strcmp)); #ifdef HAVE_SYS_RESOURCE_H setpriority(PRIO_PROCESS, 0, 19); #elif _WIN32 SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS); #endif /* init external subsystems */ if (!eet_init()) goto eet_error; if (!ecore_init()) goto ecore_error; efreet_cache_update = 0; /* finish efreet init */ if (!efreet_init()) goto efreet_error; /* create homedir */ snprintf(file, sizeof(file), "%s/efreet", efreet_cache_home_get()); if (!ecore_file_exists(file)) { if (!ecore_file_mkpath(file)) goto efreet_error; efreet_setowner(file); } /* lock process, so that we only run one copy of this program */ lockfd = cache_lock_file(); if (lockfd == -1) goto efreet_error; edd = efreet_desktop_edd(); if (!edd) goto edd_error; /* read user dirs from old cache */ ef = eet_open(efreet_desktop_util_cache_file(), EET_FILE_MODE_READ); if (ef) { old_file_ids = eet_data_read(ef, efreet_hash_string_edd(), "file_id"); eet_close(ef); } /* create cache */ snprintf(file, sizeof(file), "%s.XXXXXX", efreet_desktop_cache_file()); /* set secure umask for temporary files */ um = umask(0077); tmpfd = mkstemp(file); umask(um); if (tmpfd < 0) goto error; close(tmpfd); ef = eet_open(file, EET_FILE_MODE_READ_WRITE); if (!ef) goto error; snprintf(util_file, sizeof(util_file), "%s.XXXXXX", efreet_desktop_util_cache_file()); /* set secure umask for temporary files */ um = umask(0077); tmpfd = mkstemp(util_file); umask(um); if (tmpfd < 0) goto error; close(tmpfd); util_ef = eet_open(util_file, EET_FILE_MODE_READ_WRITE); if (!util_ef) goto error; /* write cache version */ version.major = EFREET_DESKTOP_UTILS_CACHE_MAJOR; version.minor = EFREET_DESKTOP_UTILS_CACHE_MINOR; eet_data_write(util_ef, efreet_version_edd(), EFREET_CACHE_VERSION, &version, 1); version.major = EFREET_DESKTOP_CACHE_MAJOR; version.minor = EFREET_DESKTOP_CACHE_MINOR; eet_data_write(ef, efreet_version_edd(), EFREET_CACHE_VERSION, &version, 1); desktops = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_desktop_free)); file_ids = eina_hash_string_superfast_new(NULL); paths = eina_hash_string_superfast_new(NULL); mime_types = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); categories = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); startup_wm_class = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); name = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); generic_name = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); comment = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); exec = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); dirs = efreet_default_dirs_get(efreet_data_home_get(), efreet_data_dirs_get(), "applications"); if (!dirs) goto error; stack = eina_inarray_new(sizeof(struct stat), 16); if (!stack) goto error; EINA_LIST_FREE(dirs, path) { char file_id[PATH_MAX] = { '\0' }; eina_inarray_flush(stack); if (!cache_scan(stack, path, file_id, priority++, 1, &changed)) goto error; systemdirs = eina_list_append(systemdirs, path); }
int main(int argc, char *argv[]) { char path[PATH_MAX]; FILE *log; strcpy(path, "/tmp/efreetd_XXXXXX"); if (mkstemp(path) < 0) { perror("mkstemp"); return 1; } if (chmod(path, 0700) < 0) { perror("chmod"); return 1; } log = fopen(path, "wb"); if (!log) return 1; if (!eina_init()) return 1; eina_log_print_cb_set(eina_log_print_cb_file, log); efreetd_log_dom = eina_log_domain_register("efreetd", EFREETD_DEFAULT_LOG_COLOR); if (efreetd_log_dom < 0) { EINA_LOG_ERR("Efreet: Could not create a log domain for efreetd."); goto ecore_error; } if (!ecore_init()) goto ecore_error; ecore_app_args_set(argc, (const char **)argv); if (!ecore_file_init()) goto ecore_file_error; if (!dbus_init()) goto dbus_error; if (!cache_init()) goto cache_error; #ifdef HAVE_SYS_RESOURCE_H setpriority(PRIO_PROCESS, 0, 19); #elif _WIN32 SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS); #endif ecore_main_loop_begin(); cache_shutdown(); dbus_shutdown(); ecore_file_shutdown(); ecore_shutdown(); eina_log_domain_unregister(efreetd_log_dom); efreetd_log_dom = -1; eina_shutdown(); return 0; cache_error: dbus_shutdown(); dbus_error: ecore_file_shutdown(); ecore_file_error: ecore_shutdown(); ecore_error: if (efreetd_log_dom >= 0) eina_log_domain_unregister(efreetd_log_dom); efreetd_log_dom = -1; eina_shutdown(); return 1; }
EAPI void * e_modapi_init(E_Module *m) { Eina_List *l; Evry_Module *em; char buf[4096]; _e_module_evry_log_dom = eina_log_domain_register ("e_module_everything", EINA_LOG_DEFAULT_COLOR); if (_e_module_evry_log_dom < 0) { EINA_LOG_ERR ("impossible to create a log domain for everything module"); return NULL; } _mod_evry = m; /* add module supplied action */ act = e_action_add("everything"); if (act) { act->func.go = _e_mod_action_cb; act->func.go_edge = _e_mod_action_cb_edge; e_action_predef_name_set (_("Everything Launcher"), _("Show Everything Launcher"), "everything", "", NULL, 0); } maug = e_int_menus_menu_augmentation_add ("main/1", _e_mod_menu_add, NULL, NULL, NULL); e_configure_registry_category_add ("launcher", 80, _("Launcher"), NULL, "modules-launcher"); snprintf(buf, sizeof(buf), "%s/e-module-everything.edj", e_module_dir_get(m)); module_icon = eina_stringshare_add(buf); e_configure_registry_item_add ("launcher/run_everything", 40, _("Everything Configuration"), NULL, module_icon, evry_config_dialog); evry_init(); _evry_type_init("NONE"); _evry_type_init("FILE"); _evry_type_init("DIRECTORY"); _evry_type_init("APPLICATION"); _evry_type_init("ACTION"); _evry_type_init("PLUGIN"); _evry_type_init("BORDER"); _evry_type_init("TEXT"); _config_init(); _evry_events[EVRY_EVENT_ITEMS_UPDATE] = ecore_event_type_new(); _evry_events[EVRY_EVENT_ITEM_SELECTED] = ecore_event_type_new(); _evry_events[EVRY_EVENT_ITEM_CHANGED] = ecore_event_type_new(); _evry_events[EVRY_EVENT_ACTION_PERFORMED] = ecore_event_type_new(); _evry_events[EVRY_EVENT_PLUGIN_SELECTED] = ecore_event_type_new(); evry = E_NEW(Evry_API, 1); evry->log_dom = _e_module_evry_log_dom; #define SET(func) (evry->func = &evry_##func); SET(api_version_check); SET(item_new); SET(item_free); SET(item_ref); SET(plugin_new); SET(plugin_free); SET(plugin_register); SET(plugin_unregister); SET(plugin_update); SET(plugin_find); SET(action_new); SET(action_free); SET(action_register); SET(action_unregister); SET(action_find); SET(api_version_check); SET(type_register); SET(icon_theme_get); SET(fuzzy_match); SET(util_exec_app); SET(util_url_escape); SET(util_url_unescape); SET(util_file_detail_set); SET(util_plugin_items_add); SET(util_md5_sum); SET(util_icon_get); SET(item_changed); SET(file_path_get); SET(file_url_get); SET(history_item_add); SET(history_types_get); SET(history_item_usage_set); SET(event_handler_add); #undef SET evry_history_init(); evry_plug_actions_init(); evry_plug_apps_init(m); evry_plug_files_init(m); evry_plug_windows_init(m); evry_plug_settings_init(m); evry_plug_calc_init(m); e_datastore_set("evry_api", evry); EINA_LIST_FOREACH (e_datastore_get("evry_modules"), l, em) em->active = em->init(evry); evry_plug_collection_init(); evry_plug_clipboard_init(); evry_plug_text_init(); evry_view_init(); evry_view_help_init(); evry_gadget_init(); e_module_priority_set(m, -1000); e_module_delayed_set(m, 1); /* cleanup every hour :) */ cleanup_timer = ecore_timer_add(3600, _cleanup_history, NULL); return m; }
/** * Set up connections, signal handlers, sockets etc. * @return 1 or greater on success, 0 otherwise * * This function sets up all singal handlers and the basic event loop. If it * succeeds, 1 will be returned, otherwise 0 will be returned. * * @code * #include <Ecore.h> * * int main(int argc, char **argv) * { * if (!ecore_init()) * { * printf("ERROR: Cannot init Ecore!\n"); * return -1; * } * ecore_main_loop_begin(); * ecore_shutdown(); * } * @endcode */ EAPI int ecore_init(void) { if (++_ecore_init_count != 1) return _ecore_init_count; #ifdef HAVE_LOCALE_H setlocale(LC_CTYPE, ""); #endif /* if (strcmp(nl_langinfo(CODESET), "UTF-8")) { WRN("Not a utf8 locale!"); } */ #ifdef HAVE_EVIL if (!evil_init()) return --_ecore_init_count; #endif if (!eina_init()) goto shutdown_evil; _ecore_log_dom = eina_log_domain_register("ecore", ECORE_DEFAULT_LOG_COLOR); if (_ecore_log_dom < 0) { EINA_LOG_ERR("Ecore was unable to create a log domain."); goto shutdown_log_dom; } if (getenv("ECORE_FPS_DEBUG")) _ecore_fps_debug = 1; if (_ecore_fps_debug) _ecore_fps_debug_init(); if (!ecore_mempool_init()) goto shutdown_mempool; _ecore_main_loop_init(); _ecore_signal_init(); _ecore_thread_init(); _ecore_exe_init(); _ecore_glib_init(); _ecore_job_init(); _ecore_time_init(); eina_lock_new(&_thread_safety); eina_lock_new(&_thread_mutex); eina_condition_new(&_thread_cond, &_thread_mutex); eina_lock_new(&_thread_feedback_mutex); eina_condition_new(&_thread_feedback_cond, &_thread_feedback_mutex); _thread_call = ecore_pipe_add(_thread_callback, NULL); eina_lock_new(&_thread_id_lock); eina_lock_new(&_ecore_main_loop_lock); #if HAVE_MALLINFO if (getenv("ECORE_MEM_STAT")) { _ecore_memory_pid = getpid(); ecore_animator_add(_ecore_memory_statistic, NULL); } #endif #if defined(GLIB_INTEGRATION_ALWAYS) if (_ecore_glib_always_integrate) ecore_main_loop_glib_integrate(); #endif return _ecore_init_count; shutdown_mempool: ecore_mempool_shutdown(); shutdown_log_dom: eina_shutdown(); shutdown_evil: #ifdef HAVE_EVIL evil_shutdown(); #endif return --_ecore_init_count; }
int ecore_wince_init() { WNDCLASS wc; if (++_ecore_wince_init_count != 1) return _ecore_wince_init_count; if (!eina_init()) return --_ecore_wince_init_count; eina_log_print_cb_set(_ecore_wince_error_print_cb, NULL); _ecore_wince_log_dom_global = eina_log_domain_register("ecore_wince", ECORE_WINCE_DEFAULT_LOG_COLOR); if (_ecore_wince_log_dom_global < 0) { EINA_LOG_ERR("Ecore_WinCE: Could not register log domain"); goto shutdown_eina; } if (!ecore_event_init()) { ERR("Ecore_WinCE: Could not init ecore_event"); goto unregister_log_domain; } _ecore_wince_instance = GetModuleHandle(NULL); if (!_ecore_wince_instance) { ERR("GetModuleHandle() failed"); goto shutdown_ecore_event; } memset (&wc, 0, sizeof (wc)); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = _ecore_wince_window_procedure; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = _ecore_wince_instance; wc.hIcon = NULL; wc.hCursor = LoadCursor (NULL, IDC_ARROW); wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE); wc.lpszMenuName = NULL; wc.lpszClassName = ECORE_WINCE_WINDOW_CLASS; if(!RegisterClass(&wc)) { ERR("RegisterClass() failed"); goto free_library; } if (!ECORE_WINCE_EVENT_MOUSE_IN) { ECORE_WINCE_EVENT_MOUSE_IN = ecore_event_type_new(); ECORE_WINCE_EVENT_MOUSE_OUT = ecore_event_type_new(); ECORE_WINCE_EVENT_WINDOW_FOCUS_IN = ecore_event_type_new(); ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT = ecore_event_type_new(); ECORE_WINCE_EVENT_WINDOW_DAMAGE = ecore_event_type_new(); ECORE_WINCE_EVENT_WINDOW_CREATE = ecore_event_type_new(); ECORE_WINCE_EVENT_WINDOW_DESTROY = ecore_event_type_new(); ECORE_WINCE_EVENT_WINDOW_SHOW = ecore_event_type_new(); ECORE_WINCE_EVENT_WINDOW_HIDE = ecore_event_type_new(); ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST = ecore_event_type_new(); } return _ecore_wince_init_count; free_library: FreeLibrary(_ecore_wince_instance); shutdown_ecore_event: ecore_event_shutdown(); unregister_log_domain: eina_log_domain_unregister(_ecore_wince_log_dom_global); shutdown_eina: eina_shutdown(); return --_ecore_wince_init_count; }
EAPI int eldbus_init(void) { if (_eldbus_init_count++ > 0) return _eldbus_init_count; if (!eina_init()) { fputs("Eldbus: Unable to initialize eina\n", stderr); return 0; } _eldbus_log_dom = eina_log_domain_register("eldbus", EINA_COLOR_BLUE); if (_eldbus_log_dom < 0) { EINA_LOG_ERR("Unable to create an 'eldbus' log domain"); eina_shutdown(); return 0; } if (!ecore_init()) { ERR("Unable to initialize ecore"); eina_log_domain_unregister(_eldbus_log_dom); _eldbus_log_dom = -1; eina_shutdown(); return 0; } eina_magic_string_set(ELDBUS_CONNECTION_MAGIC, "Eldbus_Connection"); eina_magic_string_set(ELDBUS_MESSAGE_MAGIC, "Eldbus_Message"); eina_magic_string_set(ELDBUS_SIGNAL_HANDLER_MAGIC, "Eldbus_Signal_Handler"); eina_magic_string_set(ELDBUS_PENDING_MAGIC, "Eldbus_Pending"); eina_magic_string_set(ELDBUS_OBJECT_MAGIC, "Eldbus_Object"); eina_magic_string_set(ELDBUS_PROXY_MAGIC, "Eldbus_Proxy"); eina_magic_string_set(ELDBUS_MESSAGE_ITERATOR_MAGIC, "Eldbus_Message_Iterator"); eina_magic_string_set(ELDBUS_SERVICE_INTERFACE_MAGIC, "Eldbus_Service_Interface"); if (!eldbus_message_init()) goto message_failed; if (!eldbus_signal_handler_init()) goto signal_handler_failed; if (!eldbus_pending_init()) goto pending_failed; if (!eldbus_object_init()) goto object_failed; if (!eldbus_proxy_init()) goto proxy_failed; if (!eldbus_service_init()) goto service_failed; return _eldbus_init_count; service_failed: eldbus_proxy_shutdown(); proxy_failed: eldbus_object_shutdown(); object_failed: eldbus_pending_shutdown(); pending_failed: eldbus_signal_handler_shutdown(); signal_handler_failed: eldbus_message_shutdown(); message_failed: ecore_shutdown(); eina_log_domain_unregister(_eldbus_log_dom); _eldbus_log_dom = -1; eina_shutdown(); return 0; }