/** * @internal * @returns the number of initializations left for this system * @brief Attempts to shut down the subsystem if nothing else is using it */ void efreet_desktop_shutdown(void) { Efreet_Desktop_Type_Info *info; char *dir; if (efreet_desktop_exe_handler) ecore_event_handler_del(efreet_desktop_exe_handler); IF_RELEASE(desktop_environment); IF_FREE_HASH(efreet_desktop_cache); while (efreet_desktop_types) { info = eina_list_data_get(efreet_desktop_types); efreet_desktop_type_info_free(info); efreet_desktop_types = eina_list_remove_list(efreet_desktop_types, efreet_desktop_types); } EINA_LIST_FREE(efreet_desktop_dirs, dir) eina_stringshare_del(dir); if (cache_monitor) ecore_file_monitor_del(cache_monitor); if (change_monitors) eina_hash_free(change_monitors); if (cache) eet_close(cache); efreet_desktop_edd_shutdown(desktop_edd); ecore_file_shutdown(); eina_log_domain_unregister(_efreet_desktop_log_dom); IF_RELEASE(cache_file); IF_RELEASE(cache_dirs); if (efreet_desktop_job) ecore_job_del(efreet_desktop_job); efreet_desktop_job = NULL; }
/** * @return Returns the number of times the init function as been called * minus the corresponding init call. * @brief Shuts down Efreet if a balanced number of init/shutdown calls have * been made */ EAPI int efreet_shutdown(void) { if (--_efreet_init_count != 0) return _efreet_init_count; efreet_util_shutdown(); efreet_menu_shutdown(); efreet_desktop_shutdown(); efreet_ini_shutdown(); efreet_icon_shutdown(); efreet_xml_shutdown(); efreet_cache_shutdown(); efreet_base_shutdown(); eina_log_domain_unregister(_efreet_log_domain_global); IF_RELEASE(efreet_lang); IF_RELEASE(efreet_lang_country); IF_RELEASE(efreet_lang_modifier); efreet_parsed_locale = 0; /* reset this in case they init efreet again */ ecore_file_shutdown(); ecore_shutdown(); eet_shutdown(); eina_shutdown(); return _efreet_init_count; }
EAPI int efreet_mime_shutdown(void) { if (--_efreet_mime_init_count != 0) return _efreet_mime_init_count; efreet_mime_icons_debug(); IF_RELEASE(_mime_inode_symlink); IF_RELEASE(_mime_inode_fifo); IF_RELEASE(_mime_inode_chardevice); IF_RELEASE(_mime_inode_blockdevice); IF_RELEASE(_mime_inode_socket); IF_RELEASE(_mime_inode_mountpoint); IF_RELEASE(_mime_inode_directory); IF_RELEASE(_mime_application_x_executable); IF_RELEASE(_mime_application_octet_stream); IF_RELEASE(_mime_text_plain); IF_FREE_LIST(globs, efreet_mime_glob_free); IF_FREE_LIST(magics, efreet_mime_magic_free); IF_FREE_HASH(monitors); IF_FREE_HASH(wild); IF_FREE_HASH(mime_icons); eina_log_domain_unregister(_efreet_mime_log_dom); _efreet_mime_log_dom = -1; efreet_shutdown(); ecore_file_shutdown(); ecore_shutdown(); return _efreet_mime_init_count; }
void efreet_cache_shutdown(void) { Efreet_Old_Cache *d; IF_RELEASE(theme_name); icon_cache = efreet_cache_close(icon_cache); icon_theme_cache = efreet_cache_close(icon_theme_cache); IF_FREE_HASH(themes); IF_FREE_HASH(icons); IF_FREE_HASH(fallbacks); IF_FREE_HASH_CB(desktops, EINA_FREE_CB(efreet_cache_desktop_free)); desktop_cache = efreet_cache_close(desktop_cache); IF_RELEASE(desktop_cache_file); efreet_cache_edd_shutdown(); IF_RELEASE(icon_theme_cache_file); if (old_desktop_caches) ERR("This application has not properly closed all its desktop references!"); EINA_LIST_FREE(old_desktop_caches, d) { eina_hash_free(d->hash); eet_close(d->ef); free(d); }
EAPI int efreet_shutdown(void) { if (_efreet_init_count <= 0) { EINA_LOG_ERR("Init count not greater than 0 in shutdown."); return 0; } if (--_efreet_init_count != 0) return _efreet_init_count; efreet_util_shutdown(); efreet_menu_shutdown(); efreet_desktop_shutdown(); efreet_ini_shutdown(); efreet_icon_shutdown(); efreet_xml_shutdown(); efreet_cache_shutdown(); efreet_base_shutdown(); IF_RELEASE(efreet_lang); IF_RELEASE(efreet_lang_country); IF_RELEASE(efreet_lang_modifier); IF_RELEASE(efreet_language); efreet_parsed_locale = 0; /* reset this in case they init efreet again */ ecore_file_shutdown(); ecore_shutdown(); eet_shutdown(); eina_shutdown(); return _efreet_init_count; }
/** * @internal * @return Returns no value * @brief Shuts down the icon system */ void efreet_icon_shutdown(void) { IF_RELEASE(efreet_icon_user_dir); IF_RELEASE(efreet_icon_deprecated_user_dir); IF_FREE_LIST(efreet_icon_extensions, eina_stringshare_del); efreet_extra_icon_dirs = eina_list_free(efreet_extra_icon_dirs); eina_log_domain_unregister(_efreet_icon_log_dom); _efreet_icon_log_dom = -1; }
EAPI void efreet_lang_reset(void) { IF_RELEASE(efreet_lang); IF_RELEASE(efreet_lang_country); IF_RELEASE(efreet_lang_modifier); IF_RELEASE(efreet_language); efreet_parsed_locale = 0; /* reset this in case they init efreet again */ efreet_dirs_reset(); efreet_parse_locale(); efreet_cache_desktop_close(); efreet_cache_desktop_build(); }
/** * @internal * @param tx: The context to work with * @return Returns the number of references left on this context * @brief Releases a reference on the given context. * Do not use the context after this as it will be deallocated if it's * reference count drops to zero. */ int ewl_text_context_release(Ewl_Text_Context *tx) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET(tx, 0); tx->ref_count --; if (tx->ref_count > 0) DRETURN_INT(tx->ref_count, DLEVEL_STABLE); ecore_hash_remove(context_hash, tx); IF_RELEASE(tx->font); IF_RELEASE(tx->font_source); IF_RELEASE(tx->format); FREE(tx); DRETURN_INT(0, DLEVEL_STABLE); }
int efreet_util_shutdown(void) { if (--init) return init; eina_log_domain_unregister(_efreet_utils_log_dom); IF_FREE_HASH(file_id_by_desktop_path); cache = efreet_cache_close(cache); IF_RELEASE(cache_file); return init; }
/** * @return Returns no value * @brief Cleans up the efreet trash system */ EAPI int efreet_trash_shutdown(void) { if (--_efreet_trash_init_count != 0) return _efreet_trash_init_count; IF_RELEASE(efreet_trash_dir); eina_log_domain_unregister(_efreet_trash_log_dom); eina_shutdown(); return _efreet_trash_init_count; }
/** * @internal * @returns the number of initializations left for this system * @brief Attempts to shut down the subsystem if nothing else is using it */ void efreet_desktop_shutdown(void) { Efreet_Desktop_Type_Info *info; IF_RELEASE(desktop_environment); EINA_LIST_FREE(efreet_desktop_types, info) efreet_desktop_type_info_free(info); #ifdef HAVE_EVIL evil_sockets_shutdown(); #endif eina_log_domain_unregister(_efreet_desktop_log_dom); _efreet_desktop_log_dom = -1; }
/** * @return Returns the XDG Trash local directory or NULL on errors * return value must be freed with eina_stringshare_del. * @brief Retrieves the XDG Trash local directory */ EAPI const char* efreet_trash_dir_get(const char *file) { char buf[PATH_MAX]; struct stat s_dest; struct stat s_src; const char *trash_dir = NULL; if (file) { if (stat(efreet_data_home_get(), &s_dest) != 0) return NULL; if (stat(file, &s_src) != 0) return NULL; } if (!file || s_src.st_dev == s_dest.st_dev) { if (efreet_trash_dir && ecore_file_exists(efreet_trash_dir)) { eina_stringshare_ref(efreet_trash_dir); return efreet_trash_dir; } snprintf(buf, sizeof(buf), "%s/Trash", efreet_data_home_get()); if (!ecore_file_exists(buf) && !ecore_file_mkpath(buf)) return NULL; IF_RELEASE(efreet_trash_dir); efreet_trash_dir = eina_stringshare_add(buf); trash_dir = eina_stringshare_ref(efreet_trash_dir); } else { char *dir; char path[PATH_MAX]; strncpy(buf, file, PATH_MAX); buf[PATH_MAX - 1] = 0; path[0] = 0; while (strlen(buf) > 1) { strncpy(path, buf, PATH_MAX); dir = dirname(buf); if (stat(dir, &s_dest) == 0) { if (s_src.st_dev == s_dest.st_dev){ strncpy(buf, dir, PATH_MAX); continue; } else { /* other device */ break; } } path[0] = 0; break; } if (path[0]) { snprintf(buf, sizeof(buf), "%s/.Trash-%d", path, getuid()); if (!ecore_file_exists(buf) && !ecore_file_mkpath(buf)) return NULL; trash_dir = eina_stringshare_add(buf); } } if (trash_dir) { snprintf(buf, sizeof(buf), "%s/files", trash_dir); if (!ecore_file_exists(buf) && !ecore_file_mkpath(buf)) { eina_stringshare_del(trash_dir); return NULL; } snprintf(buf, sizeof(buf), "%s/info", trash_dir); if (!ecore_file_exists(buf) && !ecore_file_mkpath(buf)) { eina_stringshare_del(trash_dir); return NULL; } } return trash_dir; }
/** * @param uri: The local uri to move in the trash * @param force_delete: If you set this to 1 than files on different filesystems * will be deleted permanently * @return Return 1 on success, 0 on failure or -1 in case the uri is not on the * same filesystem and force_delete is not set. * @brief This function try to move the given uri to the trash. Files on * different filesystem can't be moved to trash. If force_delete * is 0 than non-local files will be ignored and -1 is returned, if you set * force_delete to 1 non-local files will be deleted without asking. */ EAPI int efreet_trash_delete_uri(Efreet_Uri *uri, int force_delete) { char dest[PATH_MAX]; char times[64]; const char *fname; const char *escaped; const char *trash_dir; int i = 1; time_t now; FILE *f; if (!uri || !uri->path || !ecore_file_can_write(uri->path)) return 0; fname = ecore_file_file_get(uri->path); trash_dir = efreet_trash_dir_get(uri->path); if (!trash_dir) { ERR("EFREET TRASH ERROR: No trash directory."); return 0; } snprintf(dest, sizeof(dest), "%s/files/%s", trash_dir, fname); /* search for a free filename */ while (ecore_file_exists(dest) && (i < 100)) snprintf(dest, sizeof(dest), "%s/files/%s$%d", trash_dir, fname, i++); fname = ecore_file_file_get(dest); /* move file to trash dir */ if (rename(uri->path, dest)) { if (errno == EXDEV) { if (!force_delete) { eina_stringshare_del(trash_dir); return -1; } if (!ecore_file_recursive_rm(uri->path)) { ERR("EFREET TRASH ERROR: Can't delete file."); eina_stringshare_del(trash_dir); return 0; } } else { ERR("EFREET TRASH ERROR: Can't move file to trash."); eina_stringshare_del(trash_dir); return 0; } } /* create info file */ snprintf(dest, sizeof(dest), "%s/info/%s.trashinfo", trash_dir, fname); if ((f = fopen(dest, "w"))) { fputs("[Trash Info]\n", f); //TODO is '\n' right?? (or \r\c??) fputs("Path=", f); escaped = efreet_uri_encode(uri); fputs(escaped + 7, f); // +7 == don't write 'file://' IF_RELEASE(escaped); time(&now); strftime(times, sizeof(times), "%Y-%m-%dT%H:%M:%S", localtime(&now)); fputs("\nDeletionDate=", f); fputs(times, f); fputs("\n", f); fclose(f); } else { ERR("EFREET TRASH ERROR: Can't create trash info file."); return 0; } return 1; }
/** * @internal * @return Returns no value * @brief Cleans up the efreet base settings system */ void efreet_base_shutdown(void) { IF_RELEASE(efreet_home_dir); IF_RELEASE(xdg_desktop_dir); IF_RELEASE(xdg_download_dir); IF_RELEASE(xdg_templates_dir); IF_RELEASE(xdg_publicshare_dir); IF_RELEASE(xdg_documents_dir); IF_RELEASE(xdg_music_dir); IF_RELEASE(xdg_pictures_dir); IF_RELEASE(xdg_videos_dir); IF_RELEASE(xdg_data_home); IF_RELEASE(xdg_config_home); IF_RELEASE(xdg_cache_home); IF_RELEASE(xdg_runtime_dir); IF_FREE_LIST(xdg_data_dirs, eina_stringshare_del); IF_FREE_LIST(xdg_config_dirs, eina_stringshare_del); IF_RELEASE(hostname); eina_log_domain_unregister(_efreet_base_log_dom); _efreet_base_log_dom = -1; }
/** * @internal * @param tx: The context to search for * @param context_mask the mask of differences * @param tx_changes: the set of differences to the given context to use * @return Returns the desired context * @brief Retrieves, or creates, the needed context */ Ewl_Text_Context * ewl_text_context_find(Ewl_Text_Context *tx, unsigned int context_mask, Ewl_Text_Context *tx_change) { Ewl_Text_Context tmp_tx; Ewl_Text_Context *new_tx; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET(tx, NULL); /* only need the tx_change if we have a context mask */ if (context_mask > 0) DCHECK_PARAM_PTR_RET(tx_change, NULL); memcpy(&tmp_tx, tx, sizeof(Ewl_Text_Context)); ewl_text_context_merge(&tmp_tx, context_mask, tx_change); new_tx = ecore_hash_get(context_hash, &tmp_tx); if (!new_tx) { if ((new_tx = ewl_text_context_dup(tx))) { if (context_mask & EWL_TEXT_CONTEXT_MASK_FONT) { IF_RELEASE(new_tx->font); new_tx->font = ecore_string_instance( tx_change->font); IF_RELEASE(new_tx->font_source); if (tx_change->font_source) new_tx->font_source = ecore_string_instance(tx_change->font_source); } if (context_mask & EWL_TEXT_CONTEXT_MASK_SIZE) new_tx->size = tx_change->size; if (context_mask & EWL_TEXT_CONTEXT_MASK_STYLES) new_tx->styles = tx_change->styles; if (context_mask & EWL_TEXT_CONTEXT_MASK_ALIGN) new_tx->align = tx_change->align; if (context_mask & EWL_TEXT_CONTEXT_MASK_WRAP) new_tx->wrap = tx_change->wrap; if (context_mask & EWL_TEXT_CONTEXT_MASK_COLOR) memcpy(&(new_tx->color), &(tx_change->color), sizeof(Ewl_Color_Set)); if (context_mask & EWL_TEXT_CONTEXT_MASK_BG_COLOR) memcpy(&(new_tx->style_colors.bg), &(tx_change->style_colors.bg), sizeof(Ewl_Color_Set)); if (context_mask & EWL_TEXT_CONTEXT_MASK_GLOW_COLOR) memcpy(&(new_tx->style_colors.glow), &(tx_change->style_colors.glow), sizeof(Ewl_Color_Set)); if (context_mask & EWL_TEXT_CONTEXT_MASK_OUTLINE_COLOR) memcpy(&(new_tx->style_colors.outline), &(tx_change->style_colors.outline), sizeof(Ewl_Color_Set)); if (context_mask & EWL_TEXT_CONTEXT_MASK_SHADOW_COLOR) memcpy(&(new_tx->style_colors.shadow), &(tx_change->style_colors.shadow), sizeof(Ewl_Color_Set)); if (context_mask & EWL_TEXT_CONTEXT_MASK_STRIKETHROUGH_COLOR) memcpy(&(new_tx->style_colors.strikethrough), &(tx_change->style_colors.strikethrough), sizeof(Ewl_Color_Set)); if (context_mask & EWL_TEXT_CONTEXT_MASK_UNDERLINE_COLOR) memcpy(&(new_tx->style_colors.underline), &(tx_change->style_colors.underline), sizeof(Ewl_Color_Set)); if (context_mask & EWL_TEXT_CONTEXT_MASK_DOUBLE_UNDERLINE_COLOR) memcpy(&(new_tx->style_colors.double_underline), &(tx_change->style_colors.double_underline), sizeof(Ewl_Color_Set)); IF_RELEASE(new_tx->format); ecore_hash_set(context_hash, new_tx, new_tx); } } if (new_tx) ewl_text_context_acquire(new_tx); DRETURN_PTR(new_tx, DLEVEL_STABLE); }
static void ewl_text_context_merge(Ewl_Text_Context *tx, unsigned int context_mask, Ewl_Text_Context *tx_change) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR(tx); if (context_mask & EWL_TEXT_CONTEXT_MASK_FONT) { IF_RELEASE(tx->font); IF_RELEASE(tx->font_source); tx->font = ecore_string_instance(tx_change->font); tx->font = ecore_string_instance(tx_change->font); } tx->size = ((context_mask & EWL_TEXT_CONTEXT_MASK_SIZE) ? tx_change->size : tx->size); tx->styles = ((context_mask & EWL_TEXT_CONTEXT_MASK_STYLES) ? tx_change->styles : tx->styles), tx->align = ((context_mask & EWL_TEXT_CONTEXT_MASK_ALIGN) ? tx_change->align : tx->align); tx->wrap = ((context_mask & EWL_TEXT_CONTEXT_MASK_WRAP) ? tx_change->wrap : tx->wrap); tx->color.r = ((context_mask & EWL_TEXT_CONTEXT_MASK_COLOR) ? tx_change->color.r : tx->color.r); tx->color.g = ((context_mask & EWL_TEXT_CONTEXT_MASK_COLOR) ? tx_change->color.g : tx->color.g); tx->color.b = ((context_mask & EWL_TEXT_CONTEXT_MASK_COLOR) ? tx_change->color.b : tx->color.b); tx->color.a = ((context_mask & EWL_TEXT_CONTEXT_MASK_COLOR) ? tx_change->color.a : tx->color.a); tx->style_colors.bg.r = ((context_mask & EWL_TEXT_CONTEXT_MASK_BG_COLOR) ? tx_change->style_colors.bg.r : tx->style_colors.bg.r); tx->style_colors.bg.g = ((context_mask & EWL_TEXT_CONTEXT_MASK_BG_COLOR) ? tx_change->style_colors.bg.g : tx->style_colors.bg.g); tx->style_colors.bg.b = ((context_mask & EWL_TEXT_CONTEXT_MASK_BG_COLOR) ? tx_change->style_colors.bg.b : tx->style_colors.bg.b); tx->style_colors.bg.a = ((context_mask & EWL_TEXT_CONTEXT_MASK_BG_COLOR) ? tx_change->style_colors.bg.a : tx->style_colors.bg.a); tx->style_colors.glow.r = ((context_mask & EWL_TEXT_CONTEXT_MASK_GLOW_COLOR) ? tx_change->style_colors.glow.r : tx->style_colors.glow.r); tx->style_colors.glow.g = ((context_mask & EWL_TEXT_CONTEXT_MASK_GLOW_COLOR) ? tx_change->style_colors.glow.g : tx->style_colors.glow.g); tx->style_colors.glow.b = ((context_mask & EWL_TEXT_CONTEXT_MASK_GLOW_COLOR) ? tx_change->style_colors.glow.b : tx->style_colors.glow.b); tx->style_colors.glow.a = ((context_mask & EWL_TEXT_CONTEXT_MASK_GLOW_COLOR) ? tx_change->style_colors.glow.a : tx->style_colors.glow.a); tx->style_colors.outline.r = ((context_mask & EWL_TEXT_CONTEXT_MASK_OUTLINE_COLOR) ? tx_change->style_colors.outline.r : tx->style_colors.outline.r); tx->style_colors.outline.g = ((context_mask & EWL_TEXT_CONTEXT_MASK_OUTLINE_COLOR) ? tx_change->style_colors.outline.g : tx->style_colors.outline.g); tx->style_colors.outline.b = ((context_mask & EWL_TEXT_CONTEXT_MASK_OUTLINE_COLOR) ? tx_change->style_colors.outline.b : tx->style_colors.outline.b); tx->style_colors.outline.a = ((context_mask & EWL_TEXT_CONTEXT_MASK_OUTLINE_COLOR) ? tx_change->style_colors.outline.a : tx->style_colors.outline.a); tx->style_colors.shadow.r = ((context_mask & EWL_TEXT_CONTEXT_MASK_SHADOW_COLOR) ? tx_change->style_colors.shadow.r : tx->style_colors.shadow.r); tx->style_colors.shadow.g = ((context_mask & EWL_TEXT_CONTEXT_MASK_SHADOW_COLOR) ? tx_change->style_colors.shadow.g : tx->style_colors.shadow.g); tx->style_colors.shadow.b = ((context_mask & EWL_TEXT_CONTEXT_MASK_SHADOW_COLOR) ? tx_change->style_colors.shadow.b : tx->style_colors.shadow.b); tx->style_colors.shadow.a = ((context_mask & EWL_TEXT_CONTEXT_MASK_SHADOW_COLOR) ? tx_change->style_colors.shadow.a : tx->style_colors.shadow.a); tx->style_colors.strikethrough.r = ((context_mask & EWL_TEXT_CONTEXT_MASK_STRIKETHROUGH_COLOR) ? tx_change->style_colors.strikethrough.r : tx->style_colors.strikethrough.r); tx->style_colors.strikethrough.g = ((context_mask & EWL_TEXT_CONTEXT_MASK_STRIKETHROUGH_COLOR) ? tx_change->style_colors.strikethrough.g : tx->style_colors.strikethrough.g); tx->style_colors.strikethrough.b = ((context_mask & EWL_TEXT_CONTEXT_MASK_STRIKETHROUGH_COLOR) ? tx_change->style_colors.strikethrough.b : tx->style_colors.strikethrough.b); tx->style_colors.strikethrough.a = ((context_mask & EWL_TEXT_CONTEXT_MASK_STRIKETHROUGH_COLOR) ? tx_change->style_colors.strikethrough.a : tx->style_colors.strikethrough.a); tx->style_colors.underline.r = ((context_mask & EWL_TEXT_CONTEXT_MASK_UNDERLINE_COLOR) ? tx_change->style_colors.underline.r : tx->style_colors.underline.r), tx->style_colors.underline.g = ((context_mask & EWL_TEXT_CONTEXT_MASK_UNDERLINE_COLOR) ? tx_change->style_colors.underline.g : tx->style_colors.underline.g), tx->style_colors.underline.b = ((context_mask & EWL_TEXT_CONTEXT_MASK_UNDERLINE_COLOR) ? tx_change->style_colors.underline.b : tx->style_colors.underline.b), tx->style_colors.underline.a = ((context_mask & EWL_TEXT_CONTEXT_MASK_UNDERLINE_COLOR) ? tx_change->style_colors.underline.a : tx->style_colors.underline.a), tx->style_colors.double_underline.r = ((context_mask & EWL_TEXT_CONTEXT_MASK_DOUBLE_UNDERLINE_COLOR) ? tx_change->style_colors.double_underline.r : tx->style_colors.double_underline.r), tx->style_colors.double_underline.g = ((context_mask & EWL_TEXT_CONTEXT_MASK_DOUBLE_UNDERLINE_COLOR) ? tx_change->style_colors.double_underline.g : tx->style_colors.double_underline.g), tx->style_colors.double_underline.b = ((context_mask & EWL_TEXT_CONTEXT_MASK_DOUBLE_UNDERLINE_COLOR) ? tx_change->style_colors.double_underline.b : tx->style_colors.double_underline.b), tx->style_colors.double_underline.a = ((context_mask & EWL_TEXT_CONTEXT_MASK_DOUBLE_UNDERLINE_COLOR) ? tx_change->style_colors.double_underline.a : tx->style_colors.double_underline.a); DLEAVE_FUNCTION(DLEVEL_STABLE); }