diff --git a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop.c b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop.c index b425a6aa02..43909b61e7 100644 --- a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop.c +++ b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop.c @@ -23,11 +23,11 @@ static int init_count = 0; static Ecore_Hash *desktop_cache; Ecore_Desktop *_ecore_desktop_get(const char *file, const char *lang); -void _ecore_desktop_destroy(Ecore_Desktop * desktop); +void _ecore_desktop_destroy(Ecore_Desktop * desktop); + #define IFGETDUP(src, key, dst) src = (char *)ecore_hash_get(result->group, key); if (src) dst = strdup(src); else dst = NULL; #define IFFREE(src) if (src) free(src); src = NULL; - /** * @defgroup Ecore_Desktop_Main_Group .desktop file Functions * @@ -106,8 +106,8 @@ ecore_desktop_ini_get(const char *file) } else if (current) /* key=value pair of current group. */ { - char *tv; - + char *tv; + key = c; /* Find trailing blanks or =. */ while ((*c != '=') && (*c != ' ') && (*c != '\t') @@ -133,9 +133,10 @@ ecore_desktop_ini_get(const char *file) *c++ = '\0'; /* FIXME: should strip space at end, then unescape value. */ tv = ecore_hash_remove(current, key); - if (tv) free(tv); + if (tv) + free(tv); if (value[0] != '\0') - ecore_hash_set(current, strdup(key), strdup(value)); + ecore_hash_set(current, strdup(key), strdup(value)); #ifdef DEBUG fprintf(stdout, " %s=%s\n", key, value); #endif @@ -167,16 +168,16 @@ ecore_desktop_get(const char *file, const char *lang) result = _ecore_desktop_get(file, lang); if (result) - { - /* Kill the hash, it takes up way too much memory. */ - if (result->data) - { - ecore_hash_destroy(result->data); - result->data = NULL; - } - result->group = NULL; - } - + { + /* Kill the hash, it takes up way too much memory. */ + if (result->data) + { + ecore_hash_destroy(result->data); + result->data = NULL; + } + result->group = NULL; + } + return result; } @@ -188,20 +189,20 @@ _ecore_desktop_get(const char *file, const char *lang) char *value; int stated = 0; - result = (Ecore_Desktop *) ecore_hash_get(desktop_cache, (char *) file); + result = (Ecore_Desktop *) ecore_hash_get(desktop_cache, (char *)file); /* Check if the cache is still valid. */ if (result) - { - if (stat(result->original_path, &st) >= 0) - { - if(st.st_mtime > result->mtime) - { - ecore_hash_remove(desktop_cache, result->original_path); - result = NULL; - stated = 1; - } - } - } + { + if (stat(result->original_path, &st) >= 0) + { + if (st.st_mtime > result->mtime) + { + ecore_hash_remove(desktop_cache, result->original_path); + result = NULL; + stated = 1; + } + } + } if (!result) { result = calloc(1, sizeof(Ecore_Desktop)); @@ -210,14 +211,14 @@ _ecore_desktop_get(const char *file, const char *lang) result->ondisk = 1; result->original_path = strdup(file); if (lang) - result->original_lang = strdup(lang); + result->original_lang = strdup(lang); result->data = ecore_desktop_ini_get(result->original_path); /* Timestamp the cache, and no need to stat the file twice if the cache was stale. */ - if ((stated) || (stat(result->original_path, &st) >= 0)) - { - result->mtime = st.st_mtime; - stated = 1; - } + if ((stated) || (stat(result->original_path, &st) >= 0)) + { + result->mtime = st.st_mtime; + stated = 1; + } if (result->data) { result->group = @@ -234,106 +235,120 @@ _ecore_desktop_get(const char *file, const char *lang) char *categories = NULL; int size = 0; - value = (char *) ecore_file_get_file(result->original_path); + value = + (char *)ecore_file_get_file(result->original_path); if (value) - { - char *temp = strrchr(value, '.'); - if (temp) - *temp = '\0'; - result->eap_name = malloc(strlen(value) + 5); - if (result->eap_name) - sprintf(result->eap_name, "%s.edj", value); - if (temp) - *temp = '.'; - } + { + char *temp = strrchr(value, '.'); + + if (temp) + *temp = '\0'; + result->eap_name = malloc(strlen(value) + 5); + if (result->eap_name) + sprintf(result->eap_name, "%s.edj", value); + if (temp) + *temp = '.'; + } eap_name = result->eap_name; - IFGETDUP(value, "Name", result->name); - IFGETDUP(value, "GenericName", result->generic); - IFGETDUP(value, "Comment", result->comment); - IFGETDUP(value, "Type", result->type); + IFGETDUP(value, "Name", result->name); + IFGETDUP(value, "GenericName", result->generic); + IFGETDUP(value, "Comment", result->comment); + IFGETDUP(value, "Type", result->type); - IFGETDUP(value, "Path", result->path); - IFGETDUP(value, "URL", result->URL); - IFGETDUP(value, "File", result->file); + IFGETDUP(value, "Path", result->path); + IFGETDUP(value, "URL", result->URL); + IFGETDUP(value, "File", result->file); - IFGETDUP(value, "Exec", result->exec); + IFGETDUP(value, "Exec", result->exec); if (result->exec) - { - exe = strchr(result->exec, ' '); - if (exe) - { - *exe = '\0'; - result->exec_params = ++exe; - } - exe = result->exec; - } + { + exe = strchr(result->exec, ' '); + if (exe) + { + *exe = '\0'; + result->exec_params = ++exe; + } + exe = result->exec; + } - IFGETDUP(value, "StartupWMClass", result->window_class); + IFGETDUP(value, "StartupWMClass", result->window_class); if ((!value) && (result->exec)) - { - char *tmp; + { + char *tmp; - /* Guess - exe name with first letter capitalized. */ - tmp = strdup(result->exec); - if (tmp) - { - char *p; + /* Guess - exe name with first letter capitalized. */ + tmp = strdup(result->exec); + if (tmp) + { + char *p; - value = (char *) ecore_file_get_file(tmp); /* In case the exe included a path. */ - p = value; - while ((*p != '\0') && (*p != ' ')) - { - *p = tolower(*p); - p++; - } - *p = '\0'; - *value = toupper(*value); - result->window_class = strdup(value); - free(tmp); - } - } - IFGETDUP(value, "X-Enlightenment-WindowName", result->window_name); - IFGETDUP(value, "X-Enlightenment-WindowTitle", result->window_title); - IFGETDUP(value, "X-Enlightenment-WindowRole", result->window_role); + value = (char *)ecore_file_get_file(tmp); /* In case the exe included a path. */ + p = value; + while ((*p != '\0') && (*p != ' ')) + { + *p = tolower(*p); + p++; + } + *p = '\0'; + *value = toupper(*value); + result->window_class = strdup(value); + free(tmp); + } + } + IFGETDUP(value, "X-Enlightenment-WindowName", + result->window_name); + IFGETDUP(value, "X-Enlightenment-WindowTitle", + result->window_title); + IFGETDUP(value, "X-Enlightenment-WindowRole", + result->window_role); - IFGETDUP(value, "Icon", result->icon); + IFGETDUP(value, "Icon", result->icon); if (result->icon) - result->original_icon = strdup(result->icon); - IFGETDUP(value, "X-Enlightenment-IconClass", result->icon_class); - IFGETDUP(value, "X-Enlightenment-IconPath", result->icon_path); + result->original_icon = strdup(result->icon); + IFGETDUP(value, "X-Enlightenment-IconClass", + result->icon_class); + IFGETDUP(value, "X-Enlightenment-IconPath", + result->icon_path); - if ((result->icon != NULL) && (result->icon_path == NULL) && (strchr(result->icon, '/') != NULL)) - { - if(result->icon[0] == '/') - { - result->icon_path = strdup(result->icon); - result->icon = NULL; - } - else /* It's a relative path. */ - { - char *temp; + if ((result->icon != NULL) && (result->icon_path == NULL) + && (strchr(result->icon, '/') != NULL)) + { + if (result->icon[0] == '/') + { + result->icon_path = strdup(result->icon); + result->icon = NULL; + } + else /* It's a relative path. */ + { + char *temp; - size = strlen(result->original_path) + strlen(result->icon) + 2; - temp = malloc(size); - if (temp) - { - char *dir; + size = + strlen(result->original_path) + + strlen(result->icon) + 2; + temp = malloc(size); + if (temp) + { + char *dir; - dir = ecore_file_get_dir(result->original_path); - if (dir) - { - sprintf(temp, "%s/%s", dir, result->icon); - result->icon_path = ecore_file_realpath(temp); - result->icon = NULL; - free(dir); - } - free(temp); - } - } - } + dir = + ecore_file_get_dir(result-> + original_path); + if (dir) + { + sprintf(temp, "%s/%s", dir, + result->icon); + result->icon_path = + ecore_file_realpath(temp); + result->icon = NULL; + free(dir); + } + free(temp); + } + } + } - IFGETDUP(value, "Categories", result->categories); + IFGETDUP(value, "Categories", result->categories); if (result->categories) result->Categories = ecore_desktop_paths_to_hash(result->categories); @@ -365,13 +380,10 @@ _ecore_desktop_get(const char *file, const char *lang) if (value) result->wait_exit = (strcmp(value, "true") == 0); value = - (char *)ecore_hash_get(result->group, - "NoDisplay"); + (char *)ecore_hash_get(result->group, "NoDisplay"); if (value) result->no_display = (strcmp(value, "true") == 0); - value = - (char *)ecore_hash_get(result->group, - "Hidden"); + value = (char *)ecore_hash_get(result->group, "Hidden"); if (value) result->hidden = (strcmp(value, "true") == 0); @@ -381,82 +393,86 @@ _ecore_desktop_get(const char *file, const char *lang) * It should be most specific to most generic. firefox,browser,internet for instance */ - /* If the icon in the file is not a full path, just put it first in the class, greatly simplifies things. - * Otherwise, put that full path into the icon_path member. - */ - if (!result->icon_class) - { - size = 0; - if ((result->icon) && (result->icon[0] != '/')) - size += strlen(result->icon) + 1; - if (eap_name) size += strlen(eap_name) + 1; - if (exe) size += strlen(exe) + 1; - if (categories) size += strlen(categories) + 1; - result->icon_class = malloc(size + 1); - if (result->icon_class) - { - char *p; - int done = 0; + /* If the icon in the file is not a full path, just put it first in the class, greatly simplifies things. + * Otherwise, put that full path into the icon_path member. + */ + if (!result->icon_class) + { + size = 0; + if ((result->icon) && (result->icon[0] != '/')) + size += strlen(result->icon) + 1; + if (eap_name) + size += strlen(eap_name) + 1; + if (exe) + size += strlen(exe) + 1; + if (categories) + size += strlen(categories) + 1; + result->icon_class = malloc(size + 1); + if (result->icon_class) + { + char *p; + int done = 0; - result->icon_class[0] = '\0'; - if ((result->icon) && (result->icon[0] != '/') && (result->icon[0] != '\0')) - { - strcat(result->icon_class, result->icon); - done = 1; - result->icon = NULL; - } - /* We do this here coz we don't want to lower case the result->icon part later. */ - p = result->icon_class; - p += strlen(result->icon_class); - if ((eap_name) && (eap_name[0] != '\0')) - { - if (done) - strcat(result->icon_class, ","); - strcat(result->icon_class, eap_name); - done = 1; - } - if ((exe) && (exe[0] != '\0')) - { - char *tmp; + result->icon_class[0] = '\0'; + if ((result->icon) && (result->icon[0] != '/') + && (result->icon[0] != '\0')) + { + strcat(result->icon_class, result->icon); + done = 1; + result->icon = NULL; + } + /* We do this here coz we don't want to lower case the result->icon part later. */ + p = result->icon_class; + p += strlen(result->icon_class); + if ((eap_name) && (eap_name[0] != '\0')) + { + if (done) + strcat(result->icon_class, ","); + strcat(result->icon_class, eap_name); + done = 1; + } + if ((exe) && (exe[0] != '\0')) + { + char *tmp; - tmp = strdup(ecore_file_get_file(exe)); - if (tmp) - { - char *p2; - - p2 = tmp; - while (*p2 != '\0') - { - if (*p2 == ' ') - { - *p2 = '\0'; - break; - } - p2++; - } - if (done) - strcat(result->icon_class, ","); - strcat(result->icon_class, tmp); - done = 1; - free(tmp); - } - } - if ((categories) && (categories[0] != '\0')) - { - if (done) - strcat(result->icon_class, ","); - strcat(result->icon_class, categories); - done = 1; - } - while (*p != '\0') - { - if (*p == ';') - *p = ','; - else - *p = tolower(*p); - p++; - } - } + tmp = strdup(ecore_file_get_file(exe)); + if (tmp) + { + char *p2; + + p2 = tmp; + while (*p2 != '\0') + { + if (*p2 == ' ') + { + *p2 = '\0'; + break; + } + p2++; + } + if (done) + strcat(result->icon_class, ","); + strcat(result->icon_class, tmp); + done = 1; + free(tmp); + } + } + if ((categories) && (categories[0] != '\0')) + { + if (done) + strcat(result->icon_class, ","); + strcat(result->icon_class, categories); + done = 1; + } + while (*p != '\0') + { + if (*p == ';') + *p = ','; + else + *p = tolower(*p); + p++; + } + } } } else @@ -467,12 +483,14 @@ _ecore_desktop_get(const char *file, const char *lang) "Trash Info"); if (result->group) { - IFGETDUP(value, "Path", result->path); - IFGETDUP(value, "DeletionDate", result->deletiondate); + IFGETDUP(value, "Path", result->path); + IFGETDUP(value, "DeletionDate", + result->deletiondate); } } - ecore_hash_set(desktop_cache, strdup(result->original_path), result); + ecore_hash_set(desktop_cache, strdup(result->original_path), + result); } else { @@ -487,130 +505,168 @@ _ecore_desktop_get(const char *file, const char *lang) void ecore_desktop_save(Ecore_Desktop * desktop) { - char *temp; - int trash = 0; + char *temp; + int trash = 0; if (!desktop->group) - { - if ((desktop->ondisk) && (desktop->original_path)) - { - desktop->data = ecore_desktop_ini_get(desktop->original_path); - desktop->group = (Ecore_Hash *) ecore_hash_get(desktop->data, "Desktop Entry"); - if (!desktop->group) - desktop->group = (Ecore_Hash *) ecore_hash_get(desktop->data, "KDE Desktop Entry"); - if (!desktop->group) - { - trash = 1; - desktop->group = (Ecore_Hash *) ecore_hash_get(desktop->data, "Trash Info"); - } - } - else - { - desktop->group = ecore_hash_new(ecore_str_hash, ecore_str_compare); - if (desktop->group) - { - ecore_hash_set_free_key(desktop->group, free); - ecore_hash_set_free_value(desktop->group, free); - } - } - } + { + if ((desktop->ondisk) && (desktop->original_path)) + { + desktop->data = ecore_desktop_ini_get(desktop->original_path); + desktop->group = + (Ecore_Hash *) ecore_hash_get(desktop->data, "Desktop Entry"); + if (!desktop->group) + desktop->group = + (Ecore_Hash *) ecore_hash_get(desktop->data, + "KDE Desktop Entry"); + if (!desktop->group) + { + trash = 1; + desktop->group = + (Ecore_Hash *) ecore_hash_get(desktop->data, "Trash Info"); + } + } + else + { + desktop->group = ecore_hash_new(ecore_str_hash, ecore_str_compare); + if (desktop->group) + { + ecore_hash_set_free_key(desktop->group, free); + ecore_hash_set_free_value(desktop->group, free); + } + } + } if (desktop->group) - { - if (desktop->original_path) - { - struct stat st; + { + if (desktop->original_path) + { + struct stat st; - if (stat(desktop->original_path, &st) >= 0) - { - char *real; + if (stat(desktop->original_path, &st) >= 0) + { + char *real; - real = ecore_file_readlink(desktop->original_path); - if (real) - ecore_hash_set(desktop->group, strdup("X-Enlightenment-OriginalPath"), real); - } - } + real = ecore_file_readlink(desktop->original_path); + if (real) + ecore_hash_set(desktop->group, + strdup("X-Enlightenment-OriginalPath"), + real); + } + } - temp = ecore_desktop_get_command(desktop, NULL, 0); - if (temp) - ecore_hash_set(desktop->group, strdup("Exec"), temp); - if (desktop->name) ecore_hash_set(desktop->group, strdup("Name"), strdup(desktop->name)); - if (desktop->generic) ecore_hash_set(desktop->group, strdup("GenericName"), strdup(desktop->generic)); - if (desktop->comment) ecore_hash_set(desktop->group, strdup("Comment"), strdup(desktop->comment)); - if (desktop->type) ecore_hash_set(desktop->group, strdup("Type"), strdup(desktop->type)); - if (desktop->URL) ecore_hash_set(desktop->group, strdup("URL"), strdup(desktop->URL)); - if (desktop->file) ecore_hash_set(desktop->group, strdup("File"), strdup(desktop->file)); - if (desktop->icon) ecore_hash_set(desktop->group, strdup("Icon"), strdup(desktop->icon)); - if (desktop->icon_class) ecore_hash_set(desktop->group, strdup("X-Enlightenment-IconClass"), strdup(desktop->icon_class)); - if (desktop->icon_path) ecore_hash_set(desktop->group, strdup("X-Enlightenment-IconPath"), strdup(desktop->icon_path)); - if (desktop->window_class) ecore_hash_set(desktop->group, strdup("StartupWMClass"), strdup(desktop->window_class)); - if (desktop->categories) ecore_hash_set(desktop->group, strdup("Categories"), strdup(desktop->categories)); - if (desktop->window_name) ecore_hash_set(desktop->group, strdup("X-Enlightenment-WindowName"), strdup(desktop->window_name)); - if (desktop->window_title) ecore_hash_set(desktop->group, strdup("X-Enlightenment-WindowTitle"), strdup(desktop->window_title)); - if (desktop->window_role) ecore_hash_set(desktop->group, strdup("X-Enlightenment-WindowRole"), strdup(desktop->window_role)); - ecore_hash_remove(desktop->group, "X-KDE-StartupNotify"); - if (desktop->wait_exit) - ecore_hash_set(desktop->group, strdup("X-Enlightenment-WaitExit"), strdup("true")); - else - ecore_hash_remove(desktop->group, "X-Enlightenment-WaitExit"); - if (desktop->startup) - ecore_hash_set(desktop->group, strdup("StartupNotify"), strdup("true")); - else - ecore_hash_remove(desktop->group, "StartupNotify"); - if (desktop->no_display) - ecore_hash_set(desktop->group, strdup("NoDisplay"), strdup("true")); - else - ecore_hash_remove(desktop->group, "NoDisplay"); - if (desktop->hidden) - ecore_hash_set(desktop->group, strdup("Hidden"), strdup("true")); - else - ecore_hash_remove(desktop->group, "Hidden"); + temp = ecore_desktop_get_command(desktop, NULL, 0); + if (temp) + ecore_hash_set(desktop->group, strdup("Exec"), temp); + if (desktop->name) + ecore_hash_set(desktop->group, strdup("Name"), + strdup(desktop->name)); + if (desktop->generic) + ecore_hash_set(desktop->group, strdup("GenericName"), + strdup(desktop->generic)); + if (desktop->comment) + ecore_hash_set(desktop->group, strdup("Comment"), + strdup(desktop->comment)); + if (desktop->type) + ecore_hash_set(desktop->group, strdup("Type"), + strdup(desktop->type)); + if (desktop->URL) + ecore_hash_set(desktop->group, strdup("URL"), strdup(desktop->URL)); + if (desktop->file) + ecore_hash_set(desktop->group, strdup("File"), + strdup(desktop->file)); + if (desktop->icon) + ecore_hash_set(desktop->group, strdup("Icon"), + strdup(desktop->icon)); + if (desktop->icon_class) + ecore_hash_set(desktop->group, strdup("X-Enlightenment-IconClass"), + strdup(desktop->icon_class)); + if (desktop->icon_path) + ecore_hash_set(desktop->group, strdup("X-Enlightenment-IconPath"), + strdup(desktop->icon_path)); + if (desktop->window_class) + ecore_hash_set(desktop->group, strdup("StartupWMClass"), + strdup(desktop->window_class)); + if (desktop->categories) + ecore_hash_set(desktop->group, strdup("Categories"), + strdup(desktop->categories)); + if (desktop->window_name) + ecore_hash_set(desktop->group, strdup("X-Enlightenment-WindowName"), + strdup(desktop->window_name)); + if (desktop->window_title) + ecore_hash_set(desktop->group, strdup("X-Enlightenment-WindowTitle"), + strdup(desktop->window_title)); + if (desktop->window_role) + ecore_hash_set(desktop->group, strdup("X-Enlightenment-WindowRole"), + strdup(desktop->window_role)); + ecore_hash_remove(desktop->group, "X-KDE-StartupNotify"); + if (desktop->wait_exit) + ecore_hash_set(desktop->group, strdup("X-Enlightenment-WaitExit"), + strdup("true")); + else + ecore_hash_remove(desktop->group, "X-Enlightenment-WaitExit"); + if (desktop->startup) + ecore_hash_set(desktop->group, strdup("StartupNotify"), + strdup("true")); + else + ecore_hash_remove(desktop->group, "StartupNotify"); + if (desktop->no_display) + ecore_hash_set(desktop->group, strdup("NoDisplay"), strdup("true")); + else + ecore_hash_remove(desktop->group, "NoDisplay"); + if (desktop->hidden) + ecore_hash_set(desktop->group, strdup("Hidden"), strdup("true")); + else + ecore_hash_remove(desktop->group, "Hidden"); - /* FIXME: deal with the ShowIn's. */ + /* FIXME: deal with the ShowIn's. */ - if (desktop->path) ecore_hash_set(desktop->group, strdup("Path"), strdup(desktop->path)); - if (desktop->deletiondate) ecore_hash_set(desktop->group, strdup("DeletionDate"), strdup(desktop->deletiondate)); + if (desktop->path) + ecore_hash_set(desktop->group, strdup("Path"), + strdup(desktop->path)); + if (desktop->deletiondate) + ecore_hash_set(desktop->group, strdup("DeletionDate"), + strdup(desktop->deletiondate)); - if (desktop->original_path) - { - FILE *f; - Ecore_List *list; - char *key; + if (desktop->original_path) + { + FILE *f; + Ecore_List *list; + char *key; - ecore_file_unlink(desktop->original_path); - f = fopen(desktop->original_path, "wb"); - list = ecore_hash_keys(desktop->group); - if ((!f) || (!list)) return; + ecore_file_unlink(desktop->original_path); + f = fopen(desktop->original_path, "wb"); + list = ecore_hash_keys(desktop->group); + if ((!f) || (!list)) + return; - if (trash) - fprintf(f, "[Trash Info]\n"); - else - fprintf(f, "[Desktop Entry]\n"); - ecore_list_goto_first(list); - while ((key = (char *) ecore_list_next(list))) - { - char *value; + if (trash) + fprintf(f, "[Trash Info]\n"); + else + fprintf(f, "[Desktop Entry]\n"); + ecore_list_goto_first(list); + while ((key = (char *)ecore_list_next(list))) + { + char *value; - value = (char *) ecore_hash_get(desktop->group, key); - if ((value) && (value[0] != '\0')) - fprintf(f, "%s=%s\n", key, value); - } - fclose(f); - } + value = (char *)ecore_hash_get(desktop->group, key); + if ((value) && (value[0] != '\0')) + fprintf(f, "%s=%s\n", key, value); + } + fclose(f); + } - if (desktop->data) - { - ecore_hash_destroy(desktop->data); - desktop->data = NULL; - } - else - ecore_hash_destroy(desktop->group); - desktop->group = NULL; - } + if (desktop->data) + { + ecore_hash_destroy(desktop->data); + desktop->data = NULL; + } + else + ecore_hash_destroy(desktop->group); + desktop->group = NULL; + } } - - /** * Setup what ever needs to be setup to support Ecore_Desktop. * @@ -622,9 +678,11 @@ ecore_desktop_save(Ecore_Desktop * desktop) EAPI int ecore_desktop_init() { - if (++init_count != 1) return init_count; + if (++init_count != 1) + return init_count; - if (!ecore_desktop_paths_init()) return --init_count; + if (!ecore_desktop_paths_init()) + return --init_count; if (!desktop_cache) { @@ -637,9 +695,10 @@ ecore_desktop_init() } } - if (!ecore_desktop_icon_init()) return --init_count; + if (!ecore_desktop_icon_init()) + return --init_count; - return init_count; + return init_count; } /** @@ -653,7 +712,8 @@ ecore_desktop_init() EAPI int ecore_desktop_shutdown() { - if (--init_count != 0) return init_count; + if (--init_count != 0) + return init_count; ecore_desktop_icon_shutdown(); @@ -665,7 +725,7 @@ ecore_desktop_shutdown() ecore_desktop_paths_shutdown(); - return init_count; + return init_count; } /** @@ -680,43 +740,41 @@ ecore_desktop_shutdown() void ecore_desktop_destroy(Ecore_Desktop * desktop) { - /* This is just a dummy, because these structures are cached. */ - /* Later versions of the cache may reference count, then this will be useful. */ + /* This is just a dummy, because these structures are cached. */ + /* Later versions of the cache may reference count, then this will be useful. */ } void _ecore_desktop_destroy(Ecore_Desktop * desktop) { IFFREE(desktop->original_path) - IFFREE(desktop->original_lang) - IFFREE(desktop->eap_name) - IFFREE(desktop->name) - IFFREE(desktop->generic) - IFFREE(desktop->comment) - IFFREE(desktop->type) - IFFREE(desktop->exec) - IFFREE(desktop->exec_params) - IFFREE(desktop->categories) - IFFREE(desktop->icon) - IFFREE(desktop->original_icon) - IFFREE(desktop->icon_class) - IFFREE(desktop->icon_path) - IFFREE(desktop->path) - IFFREE(desktop->URL) - IFFREE(desktop->file) - IFFREE(desktop->deletiondate) - IFFREE(desktop->window_class) - IFFREE(desktop->window_name) - IFFREE(desktop->window_title) - IFFREE(desktop->window_role) - IFFREE(desktop->NotShowIn) - IFFREE(desktop->OnlyShowIn) - IFFREE(desktop->Categories) - if (desktop->data) - { - ecore_hash_destroy(desktop->data); - desktop->data = NULL; - } + IFFREE(desktop->original_lang) + IFFREE(desktop->eap_name) + IFFREE(desktop->name) + IFFREE(desktop->generic) + IFFREE(desktop->comment) + IFFREE(desktop->type) + IFFREE(desktop->exec) + IFFREE(desktop->exec_params) + IFFREE(desktop->categories) + IFFREE(desktop->icon) + IFFREE(desktop->original_icon) + IFFREE(desktop->icon_class) + IFFREE(desktop->icon_path) + IFFREE(desktop->path) + IFFREE(desktop->URL) + IFFREE(desktop->file) + IFFREE(desktop->deletiondate) + IFFREE(desktop->window_class) + IFFREE(desktop->window_name) + IFFREE(desktop->window_title) + IFFREE(desktop->window_role) + IFFREE(desktop->NotShowIn) + IFFREE(desktop->OnlyShowIn) IFFREE(desktop->Categories) if (desktop->data) + { + ecore_hash_destroy(desktop->data); + desktop->data = NULL; + } desktop->group = NULL; free(desktop); } @@ -729,17 +787,17 @@ _ecore_desktop_destroy(Ecore_Desktop * desktop) * @return The users howe directory. * @ingroup Ecore_Desktop_Main_Group */ -char * +char * ecore_desktop_home_get() { - char home[PATH_MAX]; - int len; + char home[PATH_MAX]; + int len; /* Get Home Dir, check for trailing '/', strip it */ if (getenv("HOME")) - strncpy(home, getenv("HOME"), PATH_MAX); + strncpy(home, getenv("HOME"), PATH_MAX); else - strcpy(home, "/"); + strcpy(home, "/"); len = strlen(home) - 1; while ((len >= 0) && (home[len] == '/')) { @@ -750,129 +808,130 @@ ecore_desktop_home_get() return strdup(home); } -EAPI char * -ecore_desktop_get_command(Ecore_Desktop *desktop, Ecore_List *files, int fill) +EAPI char * +ecore_desktop_get_command(Ecore_Desktop * desktop, Ecore_List * files, int fill) { - char *result = NULL, *params = NULL; + char *result = NULL, *params = NULL; if (fill && (desktop->exec_params)) - { - params = strdup(desktop->exec_params); - if (params) - { - Ecore_DList *command; + { + params = strdup(desktop->exec_params); + if (params) + { + Ecore_DList *command; - command = ecore_dlist_new(); - if (command) - { - char *p, *t, buf[PATH_MAX + 10]; - int len = 0; + command = ecore_dlist_new(); + if (command) + { + char *p, *t, buf[PATH_MAX + 10]; + int len = 0; - ecore_dlist_set_free_cb(command, free); - t = params; - for (p = params; *p; p++) - { - if (*p == '%') - { - *p = '\0'; - ecore_dlist_append(command, strdup(t)); - *p = '%'; - t = p; - } - } - if (t < p) - { - ecore_dlist_append(command, strdup(t)); - } - if (!ecore_dlist_is_empty(command)) - { - ecore_dlist_goto_first(command); - while ((p = ecore_dlist_next(command)) != NULL) - { - t = NULL; - /* FIXME: implement the rest of these when EFM can pass us files. */ - if (p[0] == '%') - switch (p[1]) - { - case 'f' : /* Single file name, multiple invokations if multiple files. If the file is on the net, download first and point to temp file. */ - break; + ecore_dlist_set_free_cb(command, free); + t = params; + for (p = params; *p; p++) + { + if (*p == '%') + { + *p = '\0'; + ecore_dlist_append(command, strdup(t)); + *p = '%'; + t = p; + } + } + if (t < p) + { + ecore_dlist_append(command, strdup(t)); + } + if (!ecore_dlist_is_empty(command)) + { + ecore_dlist_goto_first(command); + while ((p = ecore_dlist_next(command)) != NULL) + { + t = NULL; + /* FIXME: implement the rest of these when EFM can pass us files. */ + if (p[0] == '%') + switch (p[1]) + { + case 'f': /* Single file name, multiple invokations if multiple files. If the file is on the net, download first and point to temp file. */ + break; - case 'u' : /* Single URL, multiple invokations if multiple URLs. */ - break; + case 'u': /* Single URL, multiple invokations if multiple URLs. */ + break; - case 'c' : /* Translated Name field frem .desktop file. */ - t = desktop->name; - break; + case 'c': /* Translated Name field frem .desktop file. */ + t = desktop->name; + break; - case 'k' : /* Location of the .desktop file, may be a URL, or empty. */ - t = desktop->original_path; - break; + case 'k': /* Location of the .desktop file, may be a URL, or empty. */ + t = desktop->original_path; + break; - case 'F' : /* Multiple file names. If the files are on the net, download first and point to temp files. */ - break; + case 'F': /* Multiple file names. If the files are on the net, download first and point to temp files. */ + break; - case 'U' : /* Multiple URLs. */ - break; + case 'U': /* Multiple URLs. */ + break; - case 'd' : /* Directory of the file in %f. */ - break; + case 'd': /* Directory of the file in %f. */ + break; - case 'D' : /* Directories of the files in %F. */ - break; + case 'D': /* Directories of the files in %F. */ + break; - case 'n' : /* Single filename without path. */ - break; + case 'n': /* Single filename without path. */ + break; - case 'N' : /* Multiple filenames without paths. */ - break; + case 'N': /* Multiple filenames without paths. */ + break; - case 'i' : /* "--icon Icon" field from .desktop file, or empty. */ - if (desktop->original_icon) - { - snprintf(buf, sizeof(buf), "--icon %s", desktop->original_icon); - t = buf; - } - break; + case 'i': /* "--icon Icon" field from .desktop file, or empty. */ + if (desktop->original_icon) + { + snprintf(buf, sizeof(buf), "--icon %s", + desktop->original_icon); + t = buf; + } + break; - case 'v' : /* Device field from .desktop file. */ - break; + case 'v': /* Device field from .desktop file. */ + break; - case '%' : /* A '%' character. */ - t = "%"; - break; + case '%': /* A '%' character. */ + t = "%"; + break; - default : - break; - } - if (t) - { - len += strlen(t); - ecore_dlist_previous(command); - ecore_dlist_insert(command, strdup(t)); - ecore_dlist_next(command); - ecore_dlist_next(command); - } - len += strlen(p); - } - free(params); - params = malloc(len + 1); - if (params) + default: + break; + } + if (t) { - params[0] = '\0'; - ecore_dlist_goto_first(command); - while ((p = ecore_dlist_next(command)) != NULL) - { - if (p[0] == '%') - strcat(params, &p[2]); - else - strcat(params, p); - } + len += strlen(t); + ecore_dlist_previous(command); + ecore_dlist_insert(command, strdup(t)); + ecore_dlist_next(command); + ecore_dlist_next(command); } - } - ecore_list_destroy(command); - } - } - } + len += strlen(p); + } + free(params); + params = malloc(len + 1); + if (params) + { + params[0] = '\0'; + ecore_dlist_goto_first(command); + while ((p = ecore_dlist_next(command)) != NULL) + { + if (p[0] == '%') + strcat(params, &p[2]); + else + strcat(params, p); + } + } + } + ecore_list_destroy(command); + } + } + } else if (desktop->exec_params) params = strdup(desktop->exec_params); @@ -883,32 +942,31 @@ ecore_desktop_get_command(Ecore_Desktop *desktop, Ecore_List *files, int fill) return result; } - -EAPI char * +EAPI char * ecore_desktop_merge_command(char *exec, char *params) { - int size; - char *end, *result = NULL; + int size; + char *end, *result = NULL; if ((exec) && (params)) - { - size = strlen(exec); - end = exec + size; - /* Two possibilities, it was just split at the space, or it was setup seperatly. */ - if (params == (end + 1)) - { - *end = ' '; - result = strdup(exec); - *end = '\0'; - } - else - { - size += strlen(params) + 2; - result = malloc(size); - if (result) - sprintf(result, "%s %s", exec, params); - } - } + { + size = strlen(exec); + end = exec + size; + /* Two possibilities, it was just split at the space, or it was setup seperatly. */ + if (params == (end + 1)) + { + *end = ' '; + result = strdup(exec); + *end = '\0'; + } + else + { + size += strlen(params) + 2; + result = malloc(size); + if (result) + sprintf(result, "%s %s", exec, params); + } + } else if (exec) result = strdup(exec); diff --git a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_menu.c b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_menu.c index d90370bf8f..a9ea1ae292 100644 --- a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_menu.c +++ b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_menu.c @@ -55,58 +55,61 @@ struct _ecore_desktop_menu_legacy_data int length, menu_length, level; }; -static int _ecore_desktop_menu_make_apps(const void *data, Ecore_Desktop_Tree * tree, int element, int level); -static Ecore_Desktop_Tree *_ecore_desktop_menu_get0(char *file, Ecore_Desktop_Tree * merge_stack, int level); -static Ecore_Desktop_Tree *_ecore_desktop_menu_create_menu(); -static int _ecore_desktop_menu_unxml(const void *data, - Ecore_Desktop_Tree * tree, - int element, int level); -static int _ecore_desktop_menu_check_directory(void *data, - const char *path); -static int _ecore_desktop_menu_check_menu(void *data, - const char *path); -static int _ecore_desktop_menu_legacy_menu_dir(void *data, - const char *path); -static int _ecore_desktop_menu_legacy_menu(void *data, - const char *path); -static void _ecore_desktop_menu_unxml_rules(Ecore_Desktop_Tree * rules, - Ecore_Desktop_Tree * tree, - char type, char sub_type); -static void _ecore_desktop_menu_unxml_moves(Ecore_Desktop_Tree * menu, - Ecore_Desktop_Tree * tree); -static void _ecore_desktop_menu_add_dirs(Ecore_Desktop_Tree * tree, - Ecore_List * paths, char *pre, - char *post, char *extra, - int element); -static int _ecore_desktop_menu_expand_apps(struct - _ecore_desktop_menu_unxml_data - *unxml_data, char *app_dir, - Ecore_Hash * pool); -static int _ecore_desktop_menu_check_app(void *data, - const char *path); - -static int _ecore_desktop_menu_merge(const void *data, - Ecore_Desktop_Tree * tree, - int element, int level); -static int _ecore_desktop_menu_expand_default_dirs(const void *data, - Ecore_Desktop_Tree - * tree, - int element, - int level); - -static int _ecore_desktop_menu_generate(const void *data, +static int _ecore_desktop_menu_make_apps(const void *data, Ecore_Desktop_Tree * tree, int element, int level); +static Ecore_Desktop_Tree *_ecore_desktop_menu_get0(char *file, + Ecore_Desktop_Tree * + merge_stack, int level); +static Ecore_Desktop_Tree *_ecore_desktop_menu_create_menu(); +static int _ecore_desktop_menu_unxml(const void *data, + Ecore_Desktop_Tree * tree, + int element, int level); +static int _ecore_desktop_menu_check_directory(void *data, + const char *path); +static int _ecore_desktop_menu_check_menu(void *data, + const char *path); +static int _ecore_desktop_menu_legacy_menu_dir(void *data, + const char *path); +static int _ecore_desktop_menu_legacy_menu(void *data, + const char *path); +static void _ecore_desktop_menu_unxml_rules(Ecore_Desktop_Tree * rules, + Ecore_Desktop_Tree * tree, + char type, char sub_type); +static void _ecore_desktop_menu_unxml_moves(Ecore_Desktop_Tree * menu, + Ecore_Desktop_Tree * tree); +static void _ecore_desktop_menu_add_dirs(Ecore_Desktop_Tree * tree, + Ecore_List * paths, char *pre, + char *post, char *extra, + int element); +static int _ecore_desktop_menu_expand_apps(struct + _ecore_desktop_menu_unxml_data + *unxml_data, char *app_dir, + Ecore_Hash * pool); +static int _ecore_desktop_menu_check_app(void *data, const char *path); + +static int _ecore_desktop_menu_merge(const void *data, + Ecore_Desktop_Tree * tree, + int element, int level); +static int _ecore_desktop_menu_expand_default_dirs(const void *data, + Ecore_Desktop_Tree + * tree, + int element, + int level); + +static int _ecore_desktop_menu_generate(const void *data, + Ecore_Desktop_Tree * tree, + int element, int level); static void _ecore_desktop_menu_inherit_apps(void *value, - void *user_data); + void *user_data); static void _ecore_desktop_menu_select_app(void *value, - void *user_data); + void *user_data); static int _ecore_desktop_menu_apply_rules(struct - _ecore_desktop_menu_generate_data - *generate_data, - Ecore_Desktop_Tree * rule, - char *key, - Ecore_Desktop * desktop); + _ecore_desktop_menu_generate_data + *generate_data, + Ecore_Desktop_Tree * rule, + char *key, + Ecore_Desktop * desktop); /** * @defgroup Ecore_Desktop_Menu_Group menu Functions @@ -114,70 +117,74 @@ static int _ecore_desktop_menu_apply_rules(struct * Functions that deal with freedesktop.org menus. */ - EAPI void -ecore_desktop_menu_for_each(void (*func)(char *name, char *path, Ecore_Hash *apps)) +ecore_desktop_menu_for_each(void (*func) + (char *name, char *path, Ecore_Hash * apps)) { - char *menu_file; - + char *menu_file; + /* Find the main menu file. */ - menu_file = ecore_desktop_paths_file_find(ecore_desktop_paths_menus, - "applications.menu", -1, NULL, NULL); + menu_file = ecore_desktop_paths_file_find(ecore_desktop_paths_menus, + "applications.menu", -1, NULL, + NULL); if (!menu_file) - { - /* Try various quirks of various systems. */ - menu_file = ecore_desktop_paths_file_find(ecore_desktop_paths_menus, - "debian-menu.menu", -1, NULL, NULL); - /* FIXME: If all else fails, run debians funky menu generator shit. */ - } + { + /* Try various quirks of various systems. */ + menu_file = ecore_desktop_paths_file_find(ecore_desktop_paths_menus, + "debian-menu.menu", -1, NULL, + NULL); + /* FIXME: If all else fails, run debians funky menu generator shit. */ + } if (menu_file) - { - Ecore_Desktop_Tree *menus; - - /* convert the xml into menus */ - menus = ecore_desktop_menu_get(menu_file); - if (menus) - { - /* create the .desktop and order files from the menu */ - ecore_desktop_tree_foreach(menus, 0, _ecore_desktop_menu_make_apps, func); + { + Ecore_Desktop_Tree *menus; + + /* convert the xml into menus */ + menus = ecore_desktop_menu_get(menu_file); + if (menus) + { + /* create the .desktop and order files from the menu */ + ecore_desktop_tree_foreach(menus, 0, _ecore_desktop_menu_make_apps, + func); // FIXME: Can't free this just yet, causes major memory corruption. -// ecore_desktop_tree_del(menus); - } - free(menu_file); - } +// ecore_desktop_tree_del(menus); + } + free(menu_file); + } } static int -_ecore_desktop_menu_make_apps(const void *data, Ecore_Desktop_Tree * tree, int element, int level) +_ecore_desktop_menu_make_apps(const void *data, Ecore_Desktop_Tree * tree, + int element, int level) { if (tree->elements[element].type == ECORE_DESKTOP_TREE_ELEMENT_TYPE_STRING) { - if (strncmp((char *)tree->elements[element].element, "elements[element].element, "elements[element].element; - path = (char *)tree->elements[element + 1].element; + func = data; + name = (char *)tree->elements[element].element; + path = (char *)tree->elements[element + 1].element; #ifdef DEBUG - printf("MAKING MENU - %s \t\t%s\n", path, name); + printf("MAKING MENU - %s \t\t%s\n", path, name); #endif // pool = (Ecore_Hash *) tree->elements[element + 2].element; - apps = (Ecore_Hash *) tree->elements[element + 4].element; + apps = (Ecore_Hash *) tree->elements[element + 4].element; path = &path[11]; - if (func) - func(name, path, apps); - } + if (func) + func(name, path, apps); + } } return 0; } - /** * Decode a freedesktop.org menu XML jungle. * @@ -192,11 +199,12 @@ _ecore_desktop_menu_make_apps(const void *data, Ecore_Desktop_Tree * tree, int e Ecore_Desktop_Tree * ecore_desktop_menu_get(char *file) { - return _ecore_desktop_menu_get0(file, NULL, 0); + return _ecore_desktop_menu_get0(file, NULL, 0); } static Ecore_Desktop_Tree * -_ecore_desktop_menu_get0(char *file, Ecore_Desktop_Tree * merge_stack, int level) +_ecore_desktop_menu_get0(char *file, Ecore_Desktop_Tree * merge_stack, + int level) { Ecore_Desktop_Tree *menu_xml; struct _ecore_desktop_menu_unxml_data data; @@ -314,7 +322,7 @@ _ecore_desktop_menu_get0(char *file, Ecore_Desktop_Tree * merge_stack, int level static int _ecore_desktop_menu_unxml(const void *data, Ecore_Desktop_Tree * tree, - int element, int level) + int element, int level) { struct _ecore_desktop_menu_unxml_data *unxml_data; @@ -517,9 +525,8 @@ _ecore_desktop_menu_unxml(const void *data, Ecore_Desktop_Tree * tree, "elements[1]. element)[0] != '<')) { - char - temp[PATH_MAX]; + char + + temp[PATH_MAX]; sprintf(temp, "%s %s", (char *)sub-> @@ -717,48 +725,50 @@ _ecore_desktop_menu_legacy_menu_dir(void *data, const char *path) count = 0; temp_path = strdup(path); if (temp_path) - { - for (i = legacy_data->length; temp_path[i] != '\0'; i++) - { - if (temp_path[i] == '/') - { - if (count >= legacy_data->level) - { - temp_path[i] = '\0'; - menu = _ecore_desktop_menu_create_menu(); - if (menu) - { - char temp[PATH_MAX]; + { + for (i = legacy_data->length; temp_path[i] != '\0'; i++) + { + if (temp_path[i] == '/') + { + if (count >= legacy_data->level) + { + temp_path[i] = '\0'; + menu = _ecore_desktop_menu_create_menu(); + if (menu) + { + char temp[PATH_MAX]; - sprintf(temp, " <%s> <>", &temp_path[start]); - menu->elements[0].element = strdup(temp); - ecore_desktop_tree_track(menu, - menu->elements[0].element); - sprintf(temp, "menu, - &temp_path[legacy_data->length]); - menu->elements[1].element = strdup(temp); - ecore_desktop_tree_track(menu, - menu->elements[1].element); + sprintf(temp, " <%s> <>", + &temp_path[start]); + menu->elements[0].element = strdup(temp); + ecore_desktop_tree_track(menu, + menu->elements[0].element); + sprintf(temp, "menu, + &temp_path[legacy_data->length]); + menu->elements[1].element = strdup(temp); + ecore_desktop_tree_track(menu, + menu->elements[1].element); - ecore_desktop_tree_add_child(legacy_data->current, menu); - /* This is not needed, but if it was, this is where it would go. - * sprintf(temp, "current, + menu); + /* This is not needed, but if it was, this is where it would go. + * sprintf(temp, "current = menu; - legacy_data->level++; - } - temp_path[i] = '/'; - } - start = i + 1; - count++; - } - } - free(temp_path); - } + legacy_data->current = menu; + legacy_data->level++; + } + temp_path[i] = '/'; + } + start = i + 1; + count++; + } + } + free(temp_path); + } legacy_data->level = count; @@ -828,7 +838,7 @@ _ecore_desktop_menu_legacy_menu(void *data, const char *path) menu_count = strlen(menu_path); if (menu_count) menu_count++; - file = (char *) &path[legacy_data->length + menu_count]; + file = (char *)&path[legacy_data->length + menu_count]; count = strlen(file); if (strcmp(".directory", file) == 0) @@ -860,7 +870,9 @@ _ecore_desktop_menu_legacy_menu(void *data, const char *path) sprintf(temp, "%s%s", legacy_data->prefix, file); ecore_hash_set(pool, strdup(temp), strdup(path)); #ifdef DEBUG - printf("POOLING - _ecore_desktop_menu_legacy_menu(void *data, %s) - %s - %s\n", path, file, temp); + printf + ("POOLING - _ecore_desktop_menu_legacy_menu(void *data, %s) - %s - %s\n", + path, file, temp); #endif if (rules->size > 0) { @@ -871,7 +883,8 @@ _ecore_desktop_menu_legacy_menu(void *data, const char *path) } #ifdef DEBUG else - printf("PROBLEM - _ecore_desktop_menu_legacy_menu(void *data, %s) - %s\n", path, file); + printf("PROBLEM - _ecore_desktop_menu_legacy_menu(void *data, %s) - %s\n", + path, file); #endif return 0; @@ -879,8 +892,8 @@ _ecore_desktop_menu_legacy_menu(void *data, const char *path) static void _ecore_desktop_menu_unxml_rules(Ecore_Desktop_Tree * rules, - Ecore_Desktop_Tree * tree, char type, - char sub_type) + Ecore_Desktop_Tree * tree, char type, + char sub_type) { int i; char temp[PATH_MAX]; @@ -911,9 +924,9 @@ _ecore_desktop_menu_unxml_rules(Ecore_Desktop_Tree * rules, else if (strcmp((char *)tree->elements[i].element, " - elements[i + 1].element, - type, sub_type); + (Ecore_Desktop_Tree *) tree-> + elements[i + 1].element, + type, sub_type); } else if ((strcmp((char *)tree->elements[i].element, "elements[i].element, "elements[i].type == ECORE_DESKTOP_TREE_ELEMENT_TYPE_TREE) _ecore_desktop_menu_unxml_rules(sub, - (Ecore_Desktop_Tree - *) tree-> - elements[i]. - element, type, - this_type); + (Ecore_Desktop_Tree + *) tree-> + elements[i]. + element, type, + this_type); } } } @@ -944,16 +957,16 @@ _ecore_desktop_menu_unxml_rules(Ecore_Desktop_Tree * rules, else if (tree->elements[i].type == ECORE_DESKTOP_TREE_ELEMENT_TYPE_TREE) { _ecore_desktop_menu_unxml_rules(rules, - (Ecore_Desktop_Tree *) tree-> - elements[i].element, type, - sub_type); + (Ecore_Desktop_Tree *) tree-> + elements[i].element, type, + sub_type); } } } static void _ecore_desktop_menu_unxml_moves(Ecore_Desktop_Tree * menu, - Ecore_Desktop_Tree * tree) + Ecore_Desktop_Tree * tree) { int i; char *old = NULL; @@ -996,7 +1009,7 @@ _ecore_desktop_menu_unxml_moves(Ecore_Desktop_Tree * menu, static void _ecore_desktop_menu_add_dirs(Ecore_Desktop_Tree * tree, Ecore_List * paths, - char *pre, char *post, char *extra, int element) + char *pre, char *post, char *extra, int element) { char t[PATH_MAX], *this_path; @@ -1015,7 +1028,7 @@ _ecore_desktop_menu_add_dirs(Ecore_Desktop_Tree * tree, Ecore_List * paths, static int _ecore_desktop_menu_expand_apps(struct _ecore_desktop_menu_unxml_data - *unxml_data, char *app_dir, Ecore_Hash * pool) + *unxml_data, char *app_dir, Ecore_Hash * pool) { if (pool) { @@ -1029,7 +1042,9 @@ _ecore_desktop_menu_expand_apps(struct _ecore_desktop_menu_unxml_data our_data.path = dir; our_data.length = strlen(dir); #ifdef DEBUG - printf("EXPANDING - _ecore_desktop_menu_expand_apps(unxml_data, %s) - %s\n", app_dir, dir); + printf + ("EXPANDING - _ecore_desktop_menu_expand_apps(unxml_data, %s) - %s\n", + app_dir, dir); #endif ecore_desktop_paths_recursive_search(dir, NULL, -1, NULL, _ecore_desktop_menu_check_app, @@ -1061,13 +1076,16 @@ _ecore_desktop_menu_check_app(void *data, const char *path) file[i] = '-'; ecore_hash_set(our_data->pool, file, strdup(path)); #ifdef DEBUG - printf("POOLING - _ecore_desktop_menu_check_app(void *data, %s) - %s\n", path, file); + printf + ("POOLING - _ecore_desktop_menu_check_app(void *data, %s) - %s\n", + path, file); #endif } } #ifdef DEBUG - else - printf("PROBLEM - _ecore_desktop_menu_check_app(void *data, %s)\n", path); + else + printf("PROBLEM - _ecore_desktop_menu_check_app(void *data, %s)\n", + path); #endif } @@ -1076,7 +1094,7 @@ _ecore_desktop_menu_check_app(void *data, const char *path) static int _ecore_desktop_menu_merge(const void *data, Ecore_Desktop_Tree * tree, - int element, int level) + int element, int level) { struct _ecore_desktop_menu_unxml_data *unxml_data; Ecore_Desktop_Tree *merge; @@ -1093,16 +1111,16 @@ _ecore_desktop_menu_merge(const void *data, Ecore_Desktop_Tree * tree, { if (unxml_data->base) _ecore_desktop_menu_add_dirs(merge, ecore_desktop_paths_menus, - "base, element); + "base, element); result = 1; } else if (strcmp(string, "merge_stack, - level + 1); + unxml_data->merge_stack, + level + 1); if (new_menu) { if (new_menu->size > 1) @@ -1288,8 +1307,8 @@ _ecore_desktop_menu_merge(const void *data, Ecore_Desktop_Tree * tree, static int _ecore_desktop_menu_expand_default_dirs(const void *data, - Ecore_Desktop_Tree * tree, int element, - int level) + Ecore_Desktop_Tree * tree, int element, + int level) { struct _ecore_desktop_menu_unxml_data *unxml_data; Ecore_Desktop_Tree *merge; @@ -1305,16 +1324,15 @@ _ecore_desktop_menu_expand_default_dirs(const void *data, if (strcmp(string, "unallocated) && (desktop->allocated)) - return; + { + if ((generate_data->unallocated) && (desktop->allocated)) + return; - if (_ecore_desktop_menu_apply_rules - (generate_data, generate_data->rule, key, desktop)) - { - desktop->allocated = TRUE; - if (generate_data->include) - { - ecore_hash_set(generate_data->apps, key, strdup(app)); + if (_ecore_desktop_menu_apply_rules + (generate_data, generate_data->rule, key, desktop)) + { + desktop->allocated = TRUE; + if (generate_data->include) + { + ecore_hash_set(generate_data->apps, key, strdup(app)); #ifdef DEBUG - printf("INCLUDING %s%s - %s\n", - ((generate_data->unallocated) ? "UNALLOCATED " : ""), app, key); + printf("INCLUDING %s%s - %s\n", + ((generate_data->unallocated) ? "UNALLOCATED " : ""), + app, key); #endif - } - else - { - ecore_hash_remove(generate_data->apps, key); + } + else + { + ecore_hash_remove(generate_data->apps, key); #ifdef DEBUG - printf("EXCLUDING %s%s - %s\n", - ((generate_data->unallocated) ? "UNALLOCATED " : ""), app, key); + printf("EXCLUDING %s%s - %s\n", + ((generate_data->unallocated) ? "UNALLOCATED " : ""), + app, key); #endif - } - } - } + } + } + } } static int _ecore_desktop_menu_apply_rules(struct _ecore_desktop_menu_generate_data - *generate_data, Ecore_Desktop_Tree * rule, - char *key, Ecore_Desktop * desktop) + *generate_data, Ecore_Desktop_Tree * rule, + char *key, Ecore_Desktop * desktop) { char type = 'O'; int result = FALSE; @@ -1598,9 +1618,9 @@ _ecore_desktop_menu_apply_rules(struct _ecore_desktop_menu_generate_data { result = _ecore_desktop_menu_apply_rules(generate_data, - (Ecore_Desktop_Tree *) rule-> - elements[i].element, key, - desktop); + (Ecore_Desktop_Tree *) rule-> + elements[i].element, key, + desktop); } else { diff --git a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_paths.c b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_paths.c index a3a2c1da4b..4556cc9d04 100644 --- a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_paths.c +++ b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_paths.c @@ -16,10 +16,8 @@ #include #include - /* FIXME: Add functions to add paths before the user paths, after the user but before the system paths, and at the end. */ - /* This really slows things down and no doubt drags in some KDE bloat at start up. * To work around this, I add a few extra things to try in the _ecore_desktop_paths_get() * calls below. @@ -38,10 +36,8 @@ * and correct those guesses. */ - - -static Ecore_List *_ecore_desktop_paths_get(Ecore_Desktop_Paths_Type path_type, - char *before, char *env_home, +static Ecore_List *_ecore_desktop_paths_get(Ecore_Desktop_Paths_Type path_type, + char *before, char *env_home, char *env, char *env_home_default, char *env_default, char *type, char *gnome_extra, char *kde); @@ -53,13 +49,13 @@ static void _ecore_desktop_paths_check_and_add(Ecore_List * paths, static void _ecore_desktop_paths_create(); static void _ecore_desktop_paths_destroy(); -static Ecore_List *gnome_data = NULL; -static Ecore_List *prepend_user_paths[ECORE_DESKTOP_PATHS_MAX]; -static Ecore_List *prepend_system_paths[ECORE_DESKTOP_PATHS_MAX]; -static Ecore_List *append_user_paths[ECORE_DESKTOP_PATHS_MAX]; -static Ecore_List *append_system_paths[ECORE_DESKTOP_PATHS_MAX]; -static char *home; -static int init_count = 0; +static Ecore_List *gnome_data = NULL; +static Ecore_List *prepend_user_paths[ECORE_DESKTOP_PATHS_MAX]; +static Ecore_List *prepend_system_paths[ECORE_DESKTOP_PATHS_MAX]; +static Ecore_List *append_user_paths[ECORE_DESKTOP_PATHS_MAX]; +static Ecore_List *append_system_paths[ECORE_DESKTOP_PATHS_MAX]; +static char *home; +static int init_count = 0; #if defined GNOME_SUPPORT || defined KDE_SUPPORT struct _config_exe_data @@ -80,11 +76,11 @@ static int _ecore_desktop_paths_cb_exe_exit(void *data, int type, static Ecore_Event_Handler *exit_handler = NULL; #endif - EAPI int ecore_desktop_paths_init(void) { - if (++init_count != 1) return init_count; + if (++init_count != 1) + return init_count; #if defined GNOME_SUPPORT || defined KDE_SUPPORT exit_handler = @@ -97,34 +93,33 @@ ecore_desktop_paths_init(void) home = ecore_desktop_home_get(); if (gnome_data) - { + { #ifdef GNOME_SUPPORT - if (exit_handler) - { - ecore_list_set_free_cb(gnome_data, free); - _ecore_desktop_paths_exec_config(gnome_data, home, NULL, - "gnome-config --datadir"); - } + if (exit_handler) + { + ecore_list_set_free_cb(gnome_data, free); + _ecore_desktop_paths_exec_config(gnome_data, home, NULL, + "gnome-config --datadir"); + } #else - Ecore_List *config_list; + Ecore_List *config_list; - config_list = ecore_desktop_paths_to_list("/opt/gnome/share"); - if (config_list) + config_list = ecore_desktop_paths_to_list("/opt/gnome/share"); + if (config_list) + { + char *this_config; + char path[PATH_MAX]; + + ecore_list_goto_first(config_list); + while ((this_config = ecore_list_next(config_list)) != NULL) { - char *this_config; - char path[PATH_MAX]; - ecore_list_goto_first(config_list); - while ((this_config = ecore_list_next(config_list)) != NULL) - { - - _ecore_desktop_paths_massage_path(path, home, - this_config, - NULL); - _ecore_desktop_paths_check_and_add(gnome_data, path); - } - E_FN_DEL(ecore_list_destroy, config_list); + _ecore_desktop_paths_massage_path(path, home, + this_config, NULL); + _ecore_desktop_paths_check_and_add(gnome_data, path); } + E_FN_DEL(ecore_list_destroy, config_list); + } #endif } @@ -135,7 +130,8 @@ ecore_desktop_paths_init(void) EAPI int ecore_desktop_paths_shutdown(void) { - if (--init_count != 0) return init_count; + if (--init_count != 0) + return init_count; _ecore_desktop_paths_destroy(); E_FN_DEL(ecore_list_destroy, gnome_data); @@ -161,12 +157,13 @@ _ecore_desktop_paths_create(void) if (!ecore_desktop_paths_desktops) { ecore_desktop_paths_desktops = - _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_DESKTOPS, NULL, "XDG_DATA_HOME", "XDG_DATA_DIRS", - "~/.local/share:~/.kde/share", - "/usr/local/share:/usr/share", - "applications:applnk:applications/kde", - "dist/desktop-files:dist/short-menu:gnome/apps", - "xdgdata-apps:apps"); + _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_DESKTOPS, NULL, + "XDG_DATA_HOME", "XDG_DATA_DIRS", + "~/.local/share:~/.kde/share", + "/usr/local/share:/usr/share", + "applications:applnk:applications/kde", + "dist/desktop-files:dist/short-menu:gnome/apps", + "xdgdata-apps:apps"); _ecore_desktop_paths_check_and_add(ecore_desktop_paths_desktops, "/usr/local/share/update-desktop-files/templates"); _ecore_desktop_paths_check_and_add(ecore_desktop_paths_desktops, @@ -176,22 +173,21 @@ _ecore_desktop_paths_create(void) { #ifdef KDE_SUPPORT ecore_desktop_paths_kde_legacy = - _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_KDE_LEGACY, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - "apps"); + _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_KDE_LEGACY, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, "apps"); #else ecore_desktop_paths_kde_legacy = - _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_KDE_LEGACY, NULL, "XDG_DATA_HOME", "XDG_DATA_DIRS", + _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_KDE_LEGACY, NULL, + "XDG_DATA_HOME", "XDG_DATA_DIRS", "~/.local/share:~/.kde/share", - "/usr/local/share:/usr/share", - "applnk", - NULL, - "apps"); + "/usr/local/share:/usr/share", "applnk", + NULL, "apps"); #endif if (ecore_desktop_paths_kde_legacy) { char temp[PATH_MAX], *path; Ecore_List *temp_list; - + /* Copy it, cause Ecore_List walks can not be nested. */ temp_list = ecore_list_new(); if (temp_list) @@ -226,10 +222,12 @@ _ecore_desktop_paths_create(void) char *gnome; ecore_desktop_paths_icons = - _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_ICONS, "~/.icons", "XDG_DATA_HOME", - "XDG_DATA_DIRS", "~/.local/share:~/.kde/share", - "/usr/local/share:/usr/share:/usr/X11R6/share", "icons:pixmaps", - "dist/icons", "icon:pixmap"); + _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_ICONS, "~/.icons", + "XDG_DATA_HOME", "XDG_DATA_DIRS", + "~/.local/share:~/.kde/share", + "/usr/local/share:/usr/share:/usr/X11R6/share", + "icons:pixmaps", "dist/icons", + "icon:pixmap"); _ecore_desktop_paths_check_and_add(ecore_desktop_paths_icons, "/usr/local/share/pixmaps/"); _ecore_desktop_paths_check_and_add(ecore_desktop_paths_icons, @@ -242,27 +240,30 @@ _ecore_desktop_paths_create(void) } if (!ecore_desktop_paths_menus) ecore_desktop_paths_menus = - _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_MENUS, NULL, "XDG_CONFIG_HOME", "XDG_CONFIG_DIRS", - "~/.config", "/etc/xdg:/var/lib/menu-xdg", "menus", NULL, - "xdgconf-menu"); + _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_MENUS, NULL, + "XDG_CONFIG_HOME", "XDG_CONFIG_DIRS", + "~/.config", "/etc/xdg:/var/lib/menu-xdg", + "menus", NULL, "xdgconf-menu"); if (!ecore_desktop_paths_directories) ecore_desktop_paths_directories = - _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_DIRECTORIES, NULL, "XDG_DATA_HOME", "XDG_DATA_DIRS", + _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_DIRECTORIES, NULL, + "XDG_DATA_HOME", "XDG_DATA_DIRS", "~/.local/share:~/.kde/share", "/usr/local/share:/usr/share", "desktop-directories", "gnome/vfolders", "xdgdata-dirs"); if (!ecore_desktop_paths_config) ecore_desktop_paths_config = - _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_CONFIG, NULL, "XDG_CONFIG_HOME", "XDG_CONFIG_DIRS", + _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_CONFIG, NULL, + "XDG_CONFIG_HOME", "XDG_CONFIG_DIRS", "~/.config", "/etc/xdg", "", NULL, NULL); if (!ecore_desktop_paths_xsessions) ecore_desktop_paths_xsessions = - _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_XSESSIONS, NULL, "XDG_DATA_HOME", "XDG_DATA_DIRS", + _ecore_desktop_paths_get(ECORE_DESKTOP_PATHS_XSESSIONS, NULL, + "XDG_DATA_HOME", "XDG_DATA_DIRS", "~/.local/share:~/.kde/share", - "/usr/local/share:/usr/share", - "xsessions", NULL, - NULL); + "/usr/local/share:/usr/share", "xsessions", + NULL, NULL); } static void @@ -280,55 +281,55 @@ _ecore_desktop_paths_destroy(void) EAPI void ecore_desktop_paths_extras_clear(void) { - int i; + int i; for (i = 0; i < ECORE_DESKTOP_PATHS_MAX; i++) - { - E_FN_DEL(ecore_list_destroy, prepend_user_paths[i]); - E_FN_DEL(ecore_list_destroy, prepend_system_paths[i]); - E_FN_DEL(ecore_list_destroy, append_user_paths[i]); - E_FN_DEL(ecore_list_destroy, append_system_paths[i]); - prepend_user_paths[i] = ecore_list_new(); - if (prepend_user_paths[i]) - ecore_list_set_free_cb(prepend_user_paths[i], free); - prepend_system_paths[i] = ecore_list_new(); - if (prepend_system_paths[i]) - ecore_list_set_free_cb(prepend_system_paths[i], free); - append_user_paths[i] = ecore_list_new(); - if (append_user_paths[i]) - ecore_list_set_free_cb(append_user_paths[i], free); - append_system_paths[i] = ecore_list_new(); - if (append_system_paths[i]) - ecore_list_set_free_cb(append_system_paths[i], free); - } + { + E_FN_DEL(ecore_list_destroy, prepend_user_paths[i]); + E_FN_DEL(ecore_list_destroy, prepend_system_paths[i]); + E_FN_DEL(ecore_list_destroy, append_user_paths[i]); + E_FN_DEL(ecore_list_destroy, append_system_paths[i]); + prepend_user_paths[i] = ecore_list_new(); + if (prepend_user_paths[i]) + ecore_list_set_free_cb(prepend_user_paths[i], free); + prepend_system_paths[i] = ecore_list_new(); + if (prepend_system_paths[i]) + ecore_list_set_free_cb(prepend_system_paths[i], free); + append_user_paths[i] = ecore_list_new(); + if (append_user_paths[i]) + ecore_list_set_free_cb(append_user_paths[i], free); + append_system_paths[i] = ecore_list_new(); + if (append_system_paths[i]) + ecore_list_set_free_cb(append_system_paths[i], free); + } } EAPI void ecore_desktop_paths_prepend_user(Ecore_Desktop_Paths_Type type, char *paths) { if (prepend_user_paths[type]) - ecore_list_append(prepend_user_paths[type], strdup(paths)); + ecore_list_append(prepend_user_paths[type], strdup(paths)); } EAPI void ecore_desktop_paths_prepend_system(Ecore_Desktop_Paths_Type type, char *paths) { if (prepend_system_paths[type]) - ecore_list_append(prepend_system_paths[type], strdup(paths)); + ecore_list_append(prepend_system_paths[type], strdup(paths)); } EAPI void ecore_desktop_paths_append_user(Ecore_Desktop_Paths_Type type, char *paths) { if (append_user_paths[type]) - ecore_list_append(append_user_paths[type], strdup(paths)); + ecore_list_append(append_user_paths[type], strdup(paths)); } EAPI void ecore_desktop_paths_append_system(Ecore_Desktop_Paths_Type type, char *paths) { if (append_system_paths[type]) - ecore_list_append(append_system_paths[type], strdup(paths)); + ecore_list_append(append_system_paths[type], strdup(paths)); } /** Search for a file in fdo compatible locations. @@ -348,13 +349,13 @@ ecore_desktop_paths_append_system(Ecore_Desktop_Paths_Type type, char *paths) */ char * ecore_desktop_paths_file_find(Ecore_List * paths, const char *file, int sub, - int (*func) (void *data, const char *path), - void *data) + int (*func) (void *data, const char *path), + void *data) { char *path = NULL, *this_path; char temp[PATH_MAX]; struct stat path_stat; - + if (paths) { ecore_list_goto_first(paths); @@ -372,15 +373,15 @@ ecore_desktop_paths_file_find(Ecore_List * paths, const char *file, int sub, if (func) { if (func(data, temp)) - break; + break; } } else if (sub != 0) - path = - ecore_desktop_paths_recursive_search(this_path, file, sub, NULL, - func, data); + path = + ecore_desktop_paths_recursive_search(this_path, file, sub, + NULL, func, data); if (path && (!func)) - break; + break; } } @@ -396,14 +397,15 @@ icons=pathlist */ static Ecore_List * -_ecore_desktop_paths_get(Ecore_Desktop_Paths_Type path_type, - char *before, char *env_home, char *env, +_ecore_desktop_paths_get(Ecore_Desktop_Paths_Type path_type, + char *before, char *env_home, char *env, char *env_home_default, char *env_default, char *type, char *gnome_extra, char *kde) { Ecore_List *paths = NULL; Ecore_List *types = NULL; Ecore_List *gnome_extras = NULL; + #ifdef KDE_SUPPORT Ecore_List *kdes = NULL; #endif @@ -448,17 +450,19 @@ _ecore_desktop_paths_get(Ecore_Desktop_Paths_Type path_type, } } - if (prepend_user_paths[path_type]) - { + if (prepend_user_paths[path_type]) + { char *this_path; ecore_list_goto_first(prepend_user_paths[path_type]); - while ((this_path = ecore_list_next(prepend_user_paths[path_type])) != NULL) - { - _ecore_desktop_paths_massage_path(path, home, this_path, NULL); - _ecore_desktop_paths_check_and_add(paths, path); - } - } + while ((this_path = + ecore_list_next(prepend_user_paths[path_type])) != NULL) + { + _ecore_desktop_paths_massage_path(path, home, this_path, + NULL); + _ecore_desktop_paths_check_and_add(paths, path); + } + } if (env_home) { @@ -488,29 +492,33 @@ _ecore_desktop_paths_get(Ecore_Desktop_Paths_Type path_type, } } - if (append_user_paths[path_type]) - { + if (append_user_paths[path_type]) + { char *this_path; ecore_list_goto_first(append_user_paths[path_type]); - while ((this_path = ecore_list_next(append_user_paths[path_type])) != NULL) - { - _ecore_desktop_paths_massage_path(path, home, this_path, NULL); - _ecore_desktop_paths_check_and_add(paths, path); - } - } + while ((this_path = + ecore_list_next(append_user_paths[path_type])) != NULL) + { + _ecore_desktop_paths_massage_path(path, home, this_path, + NULL); + _ecore_desktop_paths_check_and_add(paths, path); + } + } - if (prepend_system_paths[path_type]) - { + if (prepend_system_paths[path_type]) + { char *this_path; ecore_list_goto_first(prepend_system_paths[path_type]); - while ((this_path = ecore_list_next(prepend_system_paths[path_type])) != NULL) - { - _ecore_desktop_paths_massage_path(path, home, this_path, NULL); - _ecore_desktop_paths_check_and_add(paths, path); - } - } + while ((this_path = + ecore_list_next(prepend_system_paths[path_type])) != NULL) + { + _ecore_desktop_paths_massage_path(path, home, this_path, + NULL); + _ecore_desktop_paths_check_and_add(paths, path); + } + } if (env) { @@ -540,17 +548,19 @@ _ecore_desktop_paths_get(Ecore_Desktop_Paths_Type path_type, } } - if (append_system_paths[path_type]) - { + if (append_system_paths[path_type]) + { char *this_path; ecore_list_goto_first(append_system_paths[path_type]); - while ((this_path = ecore_list_next(append_system_paths[path_type])) != NULL) - { - _ecore_desktop_paths_massage_path(path, home, this_path, NULL); - _ecore_desktop_paths_check_and_add(paths, path); - } - } + while ((this_path = + ecore_list_next(append_system_paths[path_type])) != NULL) + { + _ecore_desktop_paths_massage_path(path, home, this_path, + NULL); + _ecore_desktop_paths_check_and_add(paths, path); + } + } /* * Get the pathlist from the config file - type=pathlist @@ -682,18 +692,18 @@ _ecore_desktop_paths_check_and_add(Ecore_List * paths, char *path) } char * -ecore_desktop_paths_recursive_search(const char *path, const char *file, int sub, - int (*dir_func) (void *data, - const char *path), +ecore_desktop_paths_recursive_search(const char *path, const char *file, + int sub, int (*dir_func) (void *data, + const char + *path), int (*func) (void *data, const char *path), void *data) { char *fpath = NULL; DIR *dir = NULL; - if ((sub != 0) && (sub != -1)) - sub -= 1; + sub -= 1; dir = opendir(path); @@ -714,16 +724,15 @@ ecore_desktop_paths_recursive_search(const char *path, const char *file, int sub if ((strcmp(basename(info_text), ".") != 0) && (strcmp(basename(info_text), "..") != 0)) { - snprintf(info_text, PATH_MAX, "%s%s/", path, script->d_name); + snprintf(info_text, PATH_MAX, "%s%s/", path, + script->d_name); if (dir_func) if (dir_func(data, info_text)) break; if (sub != 0) fpath = - ecore_desktop_paths_recursive_search(info_text, - file, sub, - dir_func, - func, data); + ecore_desktop_paths_recursive_search + (info_text, file, sub, dir_func, func, data); } } else @@ -732,7 +741,7 @@ ecore_desktop_paths_recursive_search(const char *path, const char *file, int sub { if (strcmp(basename(info_text), file) == 0) { - if (fpath) + if (fpath) free(fpath); fpath = strdup(info_text); if (func) @@ -890,30 +899,30 @@ ecore_desktop_paths_to_hash(const char *paths) path = strdup(paths); if (path) - { - end = path; - while (!finished) - { - start = end; - do /* FIXME: There is probably a better way to do this. */ - { - while ((*end != ';') && (*end != ':') && (*end != ',') - && (*end != '\0')) - end++; - } - while ((end != path) && (*(end - 1) == '\\') && (*end != '\0')); /* Ignore any escaped ;:, */ - /* FIXME: We still need to unescape it now. */ - temp = *end; - if (*end == '\0') - finished = 1; - else - *end = '\0'; - ecore_hash_set(result, strdup(start), strdup(start)); - if ((*end) != temp) - *end = temp; - end++; - } - free(path); + { + end = path; + while (!finished) + { + start = end; + do /* FIXME: There is probably a better way to do this. */ + { + while ((*end != ';') && (*end != ':') + && (*end != ',') && (*end != '\0')) + end++; + } + while ((end != path) && (*(end - 1) == '\\') && (*end != '\0')); /* Ignore any escaped ;:, */ + /* FIXME: We still need to unescape it now. */ + temp = *end; + if (*end == '\0') + finished = 1; + else + *end = '\0'; + ecore_hash_set(result, strdup(start), strdup(start)); + if ((*end) != temp) + *end = temp; + end++; + } + free(path); } } } @@ -948,52 +957,68 @@ ecore_desktop_paths_to_list(const char *paths) path = strdup(paths); if (path) - { - end = path; - while (!finished) - { - start = end; - do /* FIXME: There is probably a better way to do this. */ - { - while ((*end != ';') && (*end != ':') && (*end != ',') - && (*end != '\0')) - end++; - } - while ((end != path) && (*(end - 1) == '\\') && (*end != '\0')); /* Ignore any escaped ;:, */ - /* FIXME: We still need to unescape it now. */ - temp = *end; - if (*end == '\0') - finished = 1; - else - *end = '\0'; - ecore_list_append(result, strdup(start)); - if ((*end) != temp) - *end = temp; - end++; - } - free(path); - } + { + end = path; + while (!finished) + { + start = end; + do /* FIXME: There is probably a better way to do this. */ + { + while ((*end != ';') && (*end != ':') + && (*end != ',') && (*end != '\0')) + end++; + } + while ((end != path) && (*(end - 1) == '\\') && (*end != '\0')); /* Ignore any escaped ;:, */ + /* FIXME: We still need to unescape it now. */ + temp = *end; + if (*end == '\0') + finished = 1; + else + *end = '\0'; + ecore_list_append(result, strdup(start)); + if ((*end) != temp) + *end = temp; + end++; + } + free(path); + } } } return result; } -EAPI int -ecore_desktop_paths_for_each(Ecore_Desktop_Paths_Type type, Ecore_For_Each function, void *user_data) +EAPI int +ecore_desktop_paths_for_each(Ecore_Desktop_Paths_Type type, + Ecore_For_Each function, void *user_data) { - Ecore_List *list = NULL; + Ecore_List *list = NULL; switch (type) - { - case ECORE_DESKTOP_PATHS_CONFIG : list = ecore_desktop_paths_config; break; - case ECORE_DESKTOP_PATHS_MENUS : list = ecore_desktop_paths_menus; break; - case ECORE_DESKTOP_PATHS_DIRECTORIES : list = ecore_desktop_paths_directories; break; - case ECORE_DESKTOP_PATHS_DESKTOPS : list = ecore_desktop_paths_desktops; break; - case ECORE_DESKTOP_PATHS_ICONS : list = ecore_desktop_paths_icons; break; - case ECORE_DESKTOP_PATHS_KDE_LEGACY : list = ecore_desktop_paths_kde_legacy; break; - case ECORE_DESKTOP_PATHS_XSESSIONS : list = ecore_desktop_paths_xsessions; break; - case ECORE_DESKTOP_PATHS_MAX : break; - } + { + case ECORE_DESKTOP_PATHS_CONFIG: + list = ecore_desktop_paths_config; + break; + case ECORE_DESKTOP_PATHS_MENUS: + list = ecore_desktop_paths_menus; + break; + case ECORE_DESKTOP_PATHS_DIRECTORIES: + list = ecore_desktop_paths_directories; + break; + case ECORE_DESKTOP_PATHS_DESKTOPS: + list = ecore_desktop_paths_desktops; + break; + case ECORE_DESKTOP_PATHS_ICONS: + list = ecore_desktop_paths_icons; + break; + case ECORE_DESKTOP_PATHS_KDE_LEGACY: + list = ecore_desktop_paths_kde_legacy; + break; + case ECORE_DESKTOP_PATHS_XSESSIONS: + list = ecore_desktop_paths_xsessions; + break; + case ECORE_DESKTOP_PATHS_MAX: + break; + } if (list) return ecore_list_for_each(list, function, user_data); return 0; diff --git a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_private.h b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_private.h index faac63f5c6..b09a745315 100644 --- a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_private.h +++ b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_private.h @@ -15,13 +15,13 @@ #define E_NEW_BIG(s, n) (s *)malloc(n * sizeof(s)) #define E_FREE(p) { if (p) {free(p); p = NULL;} } -extern Ecore_List *ecore_desktop_paths_config; -extern Ecore_List *ecore_desktop_paths_menus; -extern Ecore_List *ecore_desktop_paths_directories; -extern Ecore_List *ecore_desktop_paths_desktops; -extern Ecore_List *ecore_desktop_paths_icons; -extern Ecore_List *ecore_desktop_paths_kde_legacy; -extern Ecore_List *ecore_desktop_paths_xsessions; +extern Ecore_List *ecore_desktop_paths_config; +extern Ecore_List *ecore_desktop_paths_menus; +extern Ecore_List *ecore_desktop_paths_directories; +extern Ecore_List *ecore_desktop_paths_desktops; +extern Ecore_List *ecore_desktop_paths_icons; +extern Ecore_List *ecore_desktop_paths_kde_legacy; +extern Ecore_List *ecore_desktop_paths_xsessions; # ifdef __cplusplus extern "C" diff --git a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_xmlame.c b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_xmlame.c index 0bcbbdbce3..82162cc35a 100644 --- a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_xmlame.c +++ b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_xmlame.c @@ -5,7 +5,6 @@ #include #include - /** xmlame.c Extensively Mocked Language Approximately Mangled for Enlightenment. * * This is NOT a real XML parser. There were a few ways we could go when it came