Enlightenment CVS committal Author : stffrdhrn Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e_fileman_smart.c e_fileman_smart.h e_intl.c e_ipc_codec.h e_ipc_handlers.h Log Message: Cleanups, bug fixes (intl, ipc_handlers, fileman) * Dont segv when sending invalid path to e_remote * Add public codec function to .h file * Intl Error message cleanup * Only set env variables once the locales have been validated * Setup gettext for env locale if no locale configured in e * Comments and local var cleanups in fileman =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_smart.c,v retrieving revision 1.135 retrieving revision 1.136 diff -u -3 -r1.135 -r1.136 --- e_fileman_smart.c 18 Feb 2006 04:35:26 -0000 1.135 +++ e_fileman_smart.c 23 Feb 2006 15:17:52 -0000 1.136 @@ -697,8 +697,6 @@ if(sd->timer) { - if(sd->dir2) - closedir(sd->dir2); ecore_timer_del(sd->timer); sd->timer = NULL; } @@ -1435,13 +1433,13 @@ Ecore_Sheap *heap; char *f; int type; - DIR *dir2; - struct dirent *dp; + DIR *dir_handle; + struct dirent *dir_entry; if (!dir) return; if ((sd->dir) && (!strcmp(sd->dir, dir))) return; - if (!(dir2 = opendir(dir))) return; + if (!(dir_handle = opendir(dir))) return; /* save the old meta */ if(sd->meta) @@ -1451,17 +1449,19 @@ sd->meta = NULL; } + /* Get list of files for directory */ type = E_FM_FILE_TYPE_NORMAL; list = NULL; - while((dp = readdir(dir2))) + while((dir_entry = readdir(dir_handle))) { - if ((!strcmp(dp->d_name, ".") || (!strcmp (dp->d_name, "..")))) continue; - if ((dp->d_name[0] == '.') && (!(type & E_FM_FILE_TYPE_HIDDEN))) continue; - f = strdup(dp->d_name); + if ((!strcmp(dir_entry->d_name, ".") || (!strcmp (dir_entry->d_name, "..")))) continue; + if ((dir_entry->d_name[0] == '.') && (!(type & E_FM_FILE_TYPE_HIDDEN))) continue; + f = strdup(dir_entry->d_name); list = evas_list_append(list, f); } - closedir(dir2); + closedir(dir_handle); + /* Sort file list */ heap = ecore_sheap_new(ECORE_COMPARE_CB(strcasecmp), evas_list_count(list)); while (list) { @@ -1474,24 +1474,15 @@ sd->files_raw = evas_list_append(sd->files_raw, f); ecore_sheap_destroy(heap); + + /* Set new directory name */ if (sd->dir) free (sd->dir); sd->dir = strdup(dir); - + /* Load meta data for this directory and the Icons in the directory */ _e_fm_dir_meta_load(sd); - if(sd->meta) - { - /* FIXME whats the purpose of this */ - Evas_List *l; - - for(l = sd->meta->files; l; l = l->next) - { - E_Fm_Icon_Metadata *im; - im = l->data; - } - } - else + if (!sd->meta) e_icon_canvas_width_fix(sd->layout, sd->w); /* Reset position */ @@ -1539,7 +1530,6 @@ } } - sd->dir2 = dir2; if(sd->timer) ecore_timer_del(sd->timer); sd->timer = ecore_timer_add(sd->timer_int, _e_fm_dir_files_get, sd); @@ -1635,7 +1625,6 @@ if(!sd->files_raw) { sd->timer = NULL; - return 0; } else @@ -3638,6 +3627,7 @@ icon->sd->selector_hilite_func(icon->sd->object, strdup(icon->file->path), icon->sd->selector_data); } +/* Hash function based on directory stat information, Creates unique directory ID. */ static char * _e_fm_dir_meta_dir_id(char *dir) { @@ -3679,6 +3669,12 @@ return strdup(s); } +/* Read metadata from meta data file <meta_path>/<dir_hash>. Set meta data + * from file to sd->meta and create sd->meta->files_hash. + * + * @sd Smart Data for directory + * @return 1 if file found and loaded 0 if no data was loaded + */ static int _e_fm_dir_meta_load(E_Fm_Smart_Data *sd) { @@ -3691,10 +3687,13 @@ hash = _e_fm_dir_meta_dir_id(sd->dir); snprintf(buf, sizeof(buf), "%s/%s", meta_path, hash); + free(hash); ef = eet_open(buf, EET_FILE_MODE_READ); if (!ef) return 0; m = eet_data_read(ef, _e_fm_dir_meta_edd, "metadata"); eet_close(ef); + + /* Hash the metadata for quick access */ if (m) { Evas_List *l; @@ -3708,7 +3707,6 @@ m->files_hash = evas_hash_add(m->files_hash, im->name, im); } } - free(hash); sd->meta = m; return 1; } @@ -3782,11 +3780,11 @@ hash = _e_fm_dir_meta_dir_id(sd->dir); snprintf(buf, sizeof(buf), "%s/%s", meta_path, hash); + free(hash); ef = eet_open(buf, EET_FILE_MODE_WRITE); if (!ef) return 0; ret = eet_data_write(ef, _e_fm_dir_meta_edd, "metadata", sd->meta, 1); eet_close(ef); - free(hash); return ret; } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_smart.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -3 -r1.21 -r1.22 --- e_fileman_smart.h 16 Feb 2006 17:06:37 -0000 1.21 +++ e_fileman_smart.h 23 Feb 2006 15:17:52 -0000 1.22 @@ -145,7 +145,6 @@ Evas_Hash *mime_menu_hash; /* FIXME delete this */ char *dir; /* FIXME this could be actually a E_Fm_Dir */ - DIR *dir2; double timer_int; Ecore_Timer *timer; =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_intl.c,v retrieving revision 1.75 retrieving revision 1.76 diff -u -3 -r1.75 -r1.76 --- e_intl.c 21 Feb 2006 15:00:10 -0000 1.75 +++ e_intl.c 23 Feb 2006 15:17:52 -0000 1.76 @@ -61,24 +61,6 @@ e_intl_init(void) { char *s; - - /* supporeted languages - as we get translations - add them here - * - * if you add a language: - * - * NOTE: add a language NAME for this in e_intl_language_name_get() if - * there isn't one yet (use the english name - then we will add - * translations of the language names to the .po file) - * NOTE: add a translation logic list to take all possible ways to address - * a language locale and convert it to a simplified one that is in - * the list here below. languages can often have multiple ways of - * being addressed (same language spoken in multiple countries or - * many variants of the language). this translation allows all the - * variants to be used and mapped to a simple "single" name for that - * language. if the differences in variants are large (eg simplified - * vs. traditional chinese) we may refer to them as separate languages - * entirely. - */ _e_intl_input_method_config_edd = E_CONFIG_DD_NEW("input_method_config", E_Input_Method_Config); E_CONFIG_VAL(_e_intl_input_method_config_edd, E_Input_Method_Config, version, INT); @@ -125,6 +107,8 @@ { if ((e_config->language) && (e_config->language[0] != 0)) e_intl_language_set(e_config->language); + else + e_intl_language_set(NULL); if ((e_config->input_method) && (e_config->input_method[0] != 0)) e_intl_input_method_set(e_config->input_method); @@ -143,14 +127,15 @@ } e_intl_input_method_set(NULL); + e_intl_language_set(NULL); + E_EXE_STOP(_e_intl_input_method_exec); return 1; } /* * TODO - * - Set the env variables only after the locale has been validated * - Add error dialogs explaining any errors while setting the locale * * Locale aliases need to be configured * * Locale is invalid @@ -185,36 +170,28 @@ } if (lang) - { - _e_intl_language = strdup(lang); - /* Only set env vars is a non NULL locale was passed */ - if (set_envars) - { - /* FIXME: maybe we should set these anyway? */ - if (getenv("LANGUAGE")) - e_util_env_set("LANGUAGE", _e_intl_language); - if (getenv("LANG")) - e_util_env_set("LANG", _e_intl_language); - if (getenv("LC_ALL")) - e_util_env_set("LC_ALL", _e_intl_language); - if (getenv("LC_MESSAGES")) - e_util_env_set("LC_MESSAGES", _e_intl_language); - } - } + _e_intl_language = strdup(lang); else - { - _e_intl_language = NULL; - } + _e_intl_language = NULL; alias_locale = _e_intl_locale_alias_get(_e_intl_language); if (!_e_intl_locale_validate(alias_locale)) { - fprintf(stderr, "The locale %s cannot be found on your " + fprintf(stderr, "The locale '%s' cannot be found on your " "system. Please install this locale or try " "something else.\n", alias_locale); } else { + /* Only set env vars is a non NULL locale was passed */ + if (set_envars) + { + e_util_env_set("LANGUAGE", _e_intl_language); + e_util_env_set("LANG", _e_intl_language); + e_util_env_set("LC_ALL", _e_intl_language); + e_util_env_set("LC_MESSAGES", _e_intl_language); + } + setlocale(LC_ALL, _e_intl_language); if (_e_intl_language) { @@ -223,15 +200,32 @@ locale_path = _e_intl_language_path_find(alias_locale); if (locale_path == NULL) { - fprintf(stderr, "Can't find the " - "translation path for the locale %s. " - "Please make sure your messages " - "path is in order. If this locale " - "is an alias make sure you have your " - "locale.aliases file in the right place. Note: " - "If your locale is C, POSIX, en_US, en_GB, " - "en_US.utf8 etc. this is normal.\n", - alias_locale); + char * match_lang; + + match_lang = _e_intl_locale_canonic_get(alias_locale, E_LOC_LANG); + + /* If locale is C or some form of en don't report an error */ + if ( match_lang == NULL && strcmp (alias_locale, "C") ) + { + fprintf(stderr, "The locale you have chosen '%s' " + "appears to be an alias, however, it can not be " + "resloved. Please make sure you have a " + "'locale.aliases' file in your 'messages' path " + "which can resolve this alias.\n" + "\n" + "Enlightenment will not be translated.\n", + alias_locale); + } + else if ( match_lang != NULL && strcmp(match_lang, "en") ) + { + fprintf(stderr, "The translation files for the " + "locale you have chosen (%s) cannot be found in " + "your 'messages' path.\n" + "\n" + "Enlightenment will not be translated.\n", + alias_locale); + } + E_FREE(match_lang); } else { @@ -358,7 +352,7 @@ } } - /* Need to free up the directory listing */ + /* Free up the directory listing */ while (input_methods) { E_Input_Method_Config *imc; =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_ipc_codec.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- e_ipc_codec.h 12 Jan 2006 02:12:21 -0000 1.9 +++ e_ipc_codec.h 23 Feb 2006 15:17:52 -0000 1.10 @@ -144,8 +144,10 @@ EAPI void *e_ipc_codec_3int_3str_enc(int val1, int val2, int val3, char *str1, char *str2, char *str3, int *size_ret); EAPI int e_ipc_codec_3int_3str_list_dec(char *data, int bytes, Evas_List **dest); EAPI void *e_ipc_codec_3int_3str_list_enc(Evas_List *list, int *size_ret); + EAPI int e_ipc_codec_str_4int_dec(char *data, int bytes, E_Ipc_Str_4Int **dest); EAPI void *e_ipc_codec_str_4int_enc(char *str1, int val1, int val2, int val3, int val4, int *size_ret); - +EAPI int e_ipc_codec_str_4int_list_dec(char *data, int bytes, Evas_List **dest); +EAPI void *e_ipc_codec_str_4int_list_enc(Evas_List *list, int *size_ret); #endif #endif =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_ipc_handlers.h,v retrieving revision 1.119 retrieving revision 1.120 diff -u -3 -r1.119 -r1.120 --- e_ipc_handlers.h 15 Feb 2006 21:22:45 -0000 1.119 +++ e_ipc_handlers.h 23 Feb 2006 15:17:52 -0000 1.120 @@ -1538,7 +1538,8 @@ LIST_DATA() Evas_List *dir_list = NULL; E_PATH_GET(path, s); - dir_list = e_path_dir_list_get(path); + if (path) + dir_list = e_path_dir_list_get(path); E_Path_Dir *p; if (s) { @@ -1632,7 +1633,7 @@ STRING2(s1, s2, e_2str, HDL); { E_PATH_GET(path, s1) - e_path_user_path_append(path, s2); + if (path) e_path_user_path_append(path, s2); } SAVE; END_STRING2(e_2str) @@ -1651,7 +1652,7 @@ STRING2(s1, s2, e_2str, HDL); { E_PATH_GET(path, s1) - e_path_user_path_prepend(path, s2); + if (path) e_path_user_path_prepend(path, s2); } SAVE; END_STRING2(e_2str) @@ -1670,7 +1671,7 @@ STRING2(s1, s2, e_2str, HDL); { E_PATH_GET(path, s1) - e_path_user_path_remove(path, s2); + if (path) e_path_user_path_remove(path, s2); } SAVE; END_STRING2(e_2str) ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs