summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorSebastian Dransfeld <sd@tango.flipp.net>2011-02-28 10:50:27 +0000
committerSebastian Dransfeld <sd@tango.flipp.net>2011-02-28 10:50:27 +0000
commit284c85240a195a5beedd63dffb616ff2011f79b7 (patch)
tree937115934f16f930c735955c0c41c73c192eefad /legacy
parent494c6c6d4fea23fb3fed8d3724dab409c317fec4 (diff)
Efreet: Separate desktop dirs to add
Keep desktop dirs to add to cache process in separate list, so we can free data after they are passed to cache process. SVN revision: 57408
Diffstat (limited to 'legacy')
-rw-r--r--legacy/efreet/src/lib/efreet_cache.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/legacy/efreet/src/lib/efreet_cache.c b/legacy/efreet/src/lib/efreet_cache.c
index a54dce6c74..514f4bc35b 100644
--- a/legacy/efreet/src/lib/efreet_cache.c
+++ b/legacy/efreet/src/lib/efreet_cache.c
@@ -67,6 +67,7 @@ static Eet_Data_Descriptor *hash_string_edd = NULL;
67 67
68static Eina_Hash *desktops = NULL; 68static Eina_Hash *desktops = NULL;
69static Efreet_Cache_Array_String *desktop_dirs = NULL; 69static Efreet_Cache_Array_String *desktop_dirs = NULL;
70static Eina_List *desktop_dirs_add = NULL;
70static Eet_File *desktop_cache = NULL; 71static Eet_File *desktop_cache = NULL;
71static const char *desktop_cache_file = NULL; 72static const char *desktop_cache_file = NULL;
72 73
@@ -108,6 +109,8 @@ static void icon_cache_update_free(void *data, void *ev);
108 109
109static void *hash_array_string_add(void *hash, const char *key, void *data); 110static void *hash_array_string_add(void *hash, const char *key, void *data);
110 111
112static int strcmplen(const void *data1, const void *data2);
113
111EAPI int EFREET_EVENT_ICON_CACHE_UPDATE = 0; 114EAPI int EFREET_EVENT_ICON_CACHE_UPDATE = 0;
112EAPI int EFREET_EVENT_DESKTOP_CACHE_UPDATE = 0; 115EAPI int EFREET_EVENT_DESKTOP_CACHE_UPDATE = 0;
113 116
@@ -173,6 +176,7 @@ void
173efreet_cache_shutdown(void) 176efreet_cache_shutdown(void)
174{ 177{
175 Efreet_Old_Cache *d; 178 Efreet_Old_Cache *d;
179 void *data;
176 180
177 IF_RELEASE(theme_name); 181 IF_RELEASE(theme_name);
178 182
@@ -186,6 +190,8 @@ efreet_cache_shutdown(void)
186 IF_FREE_HASH_CB(desktops, EINA_FREE_CB(efreet_cache_desktop_free)); 190 IF_FREE_HASH_CB(desktops, EINA_FREE_CB(efreet_cache_desktop_free));
187 efreet_cache_array_string_free(desktop_dirs); 191 efreet_cache_array_string_free(desktop_dirs);
188 desktop_dirs = NULL; 192 desktop_dirs = NULL;
193 EINA_LIST_FREE(desktop_dirs_add, data)
194 eina_stringshare_del(data);
189 desktop_cache = efreet_cache_close(desktop_cache); 195 desktop_cache = efreet_cache_close(desktop_cache);
190 IF_RELEASE(desktop_cache_file); 196 IF_RELEASE(desktop_cache_file);
191 197
@@ -846,9 +852,8 @@ void
846efreet_cache_desktop_add(Efreet_Desktop *desktop) 852efreet_cache_desktop_add(Efreet_Desktop *desktop)
847{ 853{
848 char buf[PATH_MAX]; 854 char buf[PATH_MAX];
849 char *p; 855 char *dir;
850 Efreet_Cache_Array_String *arr; 856 Efreet_Cache_Array_String *arr;
851 const char **tmp;
852 857
853 /* 858 /*
854 * Read file from disk, save path in cache so it will be included in next 859 * Read file from disk, save path in cache so it will be included in next
@@ -856,7 +861,7 @@ efreet_cache_desktop_add(Efreet_Desktop *desktop)
856 */ 861 */
857 strncpy(buf, desktop->orig_path, PATH_MAX); 862 strncpy(buf, desktop->orig_path, PATH_MAX);
858 buf[PATH_MAX - 1] = '\0'; 863 buf[PATH_MAX - 1] = '\0';
859 p = dirname(buf); 864 dir = dirname(buf);
860 arr = efreet_cache_desktop_dirs(); 865 arr = efreet_cache_desktop_dirs();
861 if (arr) 866 if (arr)
862 { 867 {
@@ -865,17 +870,12 @@ efreet_cache_desktop_add(Efreet_Desktop *desktop)
865 for (i = 0; i < arr->array_count; i++) 870 for (i = 0; i < arr->array_count; i++)
866 { 871 {
867 /* Check if we already have this dir in cache */ 872 /* Check if we already have this dir in cache */
868 if (!strncmp(p, arr->array[i], strlen(arr->array[i]))) 873 if (!strncmp(dir, arr->array[i], strlen(arr->array[i])))
869 return; 874 return;
870 } 875 }
871 } 876 }
872 /* TODO: We leak this data, remember and clean up on shutdown */ 877 if (!eina_list_search_unsorted_list(desktop_dirs_add, strcmplen, dir))
873 if (!arr) 878 desktop_dirs_add = eina_list_append(desktop_dirs_add, eina_stringshare_add(dir));
874 desktop_dirs = arr = NEW(Efreet_Cache_Array_String, 1);
875 tmp = realloc(arr->array, sizeof (char *) * (arr->array_count + 1));
876 if (!tmp) return;
877 arr->array = tmp;
878 arr->array[arr->array_count++] = strdup(p);
879 879
880 efreet_cache_desktop_update(); 880 efreet_cache_desktop_update();
881} 881}
@@ -1077,6 +1077,7 @@ cache_update_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__,
1077 util_cache = efreet_cache_close(util_cache); 1077 util_cache = efreet_cache_close(util_cache);
1078 1078
1079 ecore_event_add(EFREET_EVENT_DESKTOP_CACHE_UPDATE, ev, desktop_cache_update_free, d); 1079 ecore_event_add(EFREET_EVENT_DESKTOP_CACHE_UPDATE, ev, desktop_cache_update_free, d);
1080 /* TODO: Check if desktop_dirs_add exists, and rebuild cache if */
1080 } 1081 }
1081 else if (!strcmp(file, "icon_data.update")) 1082 else if (!strcmp(file, "icon_data.update"))
1082 { 1083 {
@@ -1148,15 +1149,16 @@ desktop_cache_update_cache_cb(void *data __UNUSED__)
1148 prio = ecore_exe_run_priority_get(); 1149 prio = ecore_exe_run_priority_get();
1149 ecore_exe_run_priority_set(19); 1150 ecore_exe_run_priority_set(19);
1150 eina_strlcpy(file, PACKAGE_LIB_DIR "/efreet/efreet_desktop_cache_create", sizeof(file)); 1151 eina_strlcpy(file, PACKAGE_LIB_DIR "/efreet/efreet_desktop_cache_create", sizeof(file));
1151 if (desktop_dirs && desktop_dirs->array_count > 0) 1152 if (desktop_dirs_add)
1152 { 1153 {
1153 unsigned int i; 1154 const char *str;
1154 1155
1155 eina_strlcat(file, " -d", sizeof(file)); 1156 eina_strlcat(file, " -d", sizeof(file));
1156 for (i = 0; i < desktop_dirs->array_count; i++) 1157 EINA_LIST_FREE(desktop_dirs_add, str)
1157 { 1158 {
1158 eina_strlcat(file, " ", sizeof(file)); 1159 eina_strlcat(file, " ", sizeof(file));
1159 eina_strlcat(file, desktop_dirs->array[i], sizeof(file)); 1160 eina_strlcat(file, str, sizeof(file));
1161 eina_stringshare_del(str);
1160 } 1162 }
1161 } 1163 }
1162 printf("Run desktop cache creation: %s\n", file); 1164 printf("Run desktop cache creation: %s\n", file);
@@ -1318,3 +1320,10 @@ hash_array_string_add(void *hash, const char *key, void *data)
1318 eina_hash_add(hash, key, data); 1320 eina_hash_add(hash, key, data);
1319 return hash; 1321 return hash;
1320} 1322}
1323
1324static int
1325strcmplen(const void *data1, const void *data2)
1326{
1327 return strncmp(data1, data2, strlen(data1));
1328}
1329