summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-01-31 21:03:48 +0100
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-02-01 21:12:29 +0100
commit2dfd1b47338d44fb1aa86a36008b8ff7886f289a (patch)
treeebf773d6a2a537c7dedb61b9fe826146fa93b201
parentc32bfdb14494643ed2cb09ff2b2087c7b8228173 (diff)
extra: stop spreading error messages about progressbars
this is done by stopping emitting the progress callbacks.
-rw-r--r--src/bin/extra_private.h2
-rw-r--r--src/bin/extra_util.c16
-rw-r--r--src/lib/extra.c78
-rw-r--r--src/lib/extra.h11
-rw-r--r--src/lib/extra_api_helper.c30
-rw-r--r--src/lib/extra_private.h7
6 files changed, 105 insertions, 39 deletions
diff --git a/src/bin/extra_private.h b/src/bin/extra_private.h
index 5869ca3..4e52522 100644
--- a/src/bin/extra_private.h
+++ b/src/bin/extra_private.h
@@ -19,7 +19,7 @@ void extra_ui_theme_ask_for_default(Extra_Theme *theme);
19Extra_Progress* extra_ui_progress_popup_show(const char *title, Extra_Done_Cb done, void *data); 19Extra_Progress* extra_ui_progress_popup_show(const char *title, Extra_Done_Cb done, void *data);
20 20
21typedef char *(Extra_ui_preview_get)(void *obj); 21typedef char *(Extra_ui_preview_get)(void *obj);
22typedef char *(Extra_ui_preview_download)(Extra_Progress *progress, void *obj); 22typedef Extra_Request *(Extra_ui_preview_download)(Extra_Progress *progress, void *obj);
23 23
24typedef struct { 24typedef struct {
25 Extra_ui_preview_get *preview_get; 25 Extra_ui_preview_get *preview_get;
diff --git a/src/bin/extra_util.c b/src/bin/extra_util.c
index 5c6a1d0..c6a90a6 100644
--- a/src/bin/extra_util.c
+++ b/src/bin/extra_util.c
@@ -136,6 +136,7 @@ typedef struct {
136 Extra_Progress p; 136 Extra_Progress p;
137 void *data; 137 void *data;
138 Extra_Ui_Small_Preview_Accessor acc; 138 Extra_Ui_Small_Preview_Accessor acc;
139 Extra_Request *req;
139} Small_Preview; 140} Small_Preview;
140 141
141static void 142static void
@@ -166,6 +167,18 @@ _small_preview_done_cb(void *data)
166 evas_object_hide(p->progress); 167 evas_object_hide(p->progress);
167} 168}
168 169
170static void
171_small_preview_deleted(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
172{
173 Small_Preview *small;
174
175 small = data;
176
177 extra_request_mute(small->req);
178
179 free(small);
180}
181
169Evas_Object* 182Evas_Object*
170extra_ui_small_preview_new(Extra_Ui_Small_Preview_Accessor acc, Evas_Object *par, void *data) 183extra_ui_small_preview_new(Extra_Ui_Small_Preview_Accessor acc, Evas_Object *par, void *data)
171{ 184{
@@ -178,6 +191,7 @@ extra_ui_small_preview_new(Extra_Ui_Small_Preview_Accessor acc, Evas_Object *par
178 small->acc = acc; 191 small->acc = acc;
179 small->data = data; 192 small->data = data;
180 table = elm_table_add(par); 193 table = elm_table_add(par);
194 evas_object_event_callback_add(table, EVAS_CALLBACK_DEL, _small_preview_deleted, small);
181 evas_object_size_hint_weight_set(table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 195 evas_object_size_hint_weight_set(table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
182 evas_object_size_hint_align_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL); 196 evas_object_size_hint_align_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL);
183 evas_object_show(table); 197 evas_object_show(table);
@@ -216,7 +230,7 @@ extra_ui_small_preview_new(Extra_Ui_Small_Preview_Accessor acc, Evas_Object *par
216 small->p.data = small; 230 small->p.data = small;
217 small->p.done_cb = _small_preview_done_cb; 231 small->p.done_cb = _small_preview_done_cb;
218 small->p.progress_cb = _small_preview_progress_cb; 232 small->p.progress_cb = _small_preview_progress_cb;
219 acc.preview_download(&small->p, data); 233 small->req = acc.preview_download(&small->p, data);
220 evas_object_hide(small->image); 234 evas_object_hide(small->image);
221 evas_object_show(small->progress); 235 evas_object_show(small->progress);
222 } 236 }
diff --git a/src/lib/extra.c b/src/lib/extra.c
index 337a031..bd0b771 100644
--- a/src/lib/extra.c
+++ b/src/lib/extra.c
@@ -27,8 +27,8 @@ void _extra_theme_cache_load();
27 27
28typedef struct { 28typedef struct {
29 Extra_Theme theme; 29 Extra_Theme theme;
30 char preview_state; //indicates if some downloads are in progress 30 Extra_Request *preview;
31 char main_state; //indicates if some downloads are in progress 31 Extra_Request *main;
32} Extra_Theme_Private; 32} Extra_Theme_Private;
33 33
34typedef struct { 34typedef struct {
@@ -84,8 +84,8 @@ _fill_themes(Eina_Strbuf *buf)
84 84
85typedef struct { 85typedef struct {
86 Extra_Background background; 86 Extra_Background background;
87 char preview_state; //indicates if some downloads are in progress 87 Extra_Request *preview;
88 char main_state; //indicates if some downloads are in progress 88 Extra_Request *main;
89} Extra_Background_Private; 89} Extra_Background_Private;
90 90
91typedef struct { 91typedef struct {
@@ -395,7 +395,7 @@ extra_theme_preview_get(Extra_Theme *theme)
395 Extra_Theme_Private *priv = ((Extra_Theme_Private*) theme); 395 Extra_Theme_Private *priv = ((Extra_Theme_Private*) theme);
396 396
397 //download is in progress do not return the path 397 //download is in progress do not return the path
398 if (priv->preview_state & EXTRA_STATE_DOWNLOAD_IN_PROGRESS) return NULL; 398 if (priv->preview) return NULL;
399 399
400 local = _extra_preview_local_generate("themes", theme->id, theme->version); 400 local = _extra_preview_local_generate("themes", theme->id, theme->version);
401 if (!ecore_file_exists(local)) 401 if (!ecore_file_exists(local))
@@ -407,19 +407,26 @@ extra_theme_preview_get(Extra_Theme *theme)
407 return local; 407 return local;
408} 408}
409 409
410EAPI void 410EAPI Extra_Request*
411extra_theme_preview_download(Extra_Progress *progress, Extra_Theme *theme) 411extra_theme_preview_download(Extra_Progress *progress, Extra_Theme *theme)
412{ 412{
413 char *remote, *dst; 413 char *remote, *dst;
414 Extra_Theme_Private *priv = ((Extra_Theme_Private*) theme); 414 Extra_Theme_Private *priv = ((Extra_Theme_Private*) theme);
415 415
416 if (priv->preview)
417 {
418 priv->preview->progress = *progress;
419 }
420
416 remote = _extra_preview_remote_generate("themes", theme->id); 421 remote = _extra_preview_remote_generate("themes", theme->id);
417 dst = _extra_preview_local_generate("themes", theme->id, theme->version); 422 dst = _extra_preview_local_generate("themes", theme->id, theme->version);
418 423
419 extra_file_download(progress, remote, dst, &priv->preview_state); 424 extra_file_download(progress, remote, dst, &priv->preview);
420 425
421 free(remote); 426 free(remote);
422 free(dst); 427 free(dst);
428
429 return priv->preview;
423} 430}
424 431
425EAPI char * 432EAPI char *
@@ -440,22 +447,30 @@ extra_theme_download_url_get(Extra_Theme *theme)
440 return url; 447 return url;
441} 448}
442 449
443EAPI void 450EAPI Extra_Request*
444extra_theme_download(Extra_Progress *progress, Extra_Theme *theme) 451extra_theme_download(Extra_Progress *progress, Extra_Theme *theme)
445{ 452{
446 char *path, *urlstr = NULL; 453 char *path, *urlstr = NULL;
447 Extra_Theme_Private *priv = ((Extra_Theme_Private*) theme); 454 Extra_Theme_Private *priv = ((Extra_Theme_Private*) theme);
448 455
449 EINA_SAFETY_ON_NULL_RETURN(progress); 456 EINA_SAFETY_ON_NULL_RETURN_VAL(progress, NULL);
450 EINA_SAFETY_ON_NULL_RETURN(theme); 457 EINA_SAFETY_ON_NULL_RETURN_VAL(theme, NULL);
458
459 if (priv->main)
460 {
461 priv->main->progress = *progress;
462 return priv->main;
463 }
451 464
452 urlstr = extra_theme_download_url_get(theme); 465 urlstr = extra_theme_download_url_get(theme);
453 path = extra_theme_install_path_get(theme); 466 path = extra_theme_install_path_get(theme);
454 467
455 extra_file_download(progress, urlstr, path, &priv->main_state); 468 extra_file_download(progress, urlstr, path, &priv->main);
456 469
457 free(urlstr); 470 free(urlstr);
458 free(path); 471 free(path);
472
473 return priv->main;
459} 474}
460 475
461void 476void
@@ -656,31 +671,40 @@ extra_background_installed(Extra_Background *background)
656 return exists; 671 return exists;
657} 672}
658 673
659EAPI void 674EAPI Extra_Request*
660extra_background_download(Extra_Progress *progress, Extra_Background *background) 675extra_background_download(Extra_Progress *progress, Extra_Background *background)
661{ 676{
662 char *path, *urlstr = NULL; 677 char *path, *urlstr = NULL;
663 Extra_Background_Private *priv = ((Extra_Background_Private*) background); 678 Extra_Background_Private *priv = ((Extra_Background_Private*) background);
664 679
665 EINA_SAFETY_ON_NULL_RETURN(progress); 680 EINA_SAFETY_ON_NULL_RETURN_VAL(progress, NULL);
666 EINA_SAFETY_ON_NULL_RETURN(background); 681 EINA_SAFETY_ON_NULL_RETURN_VAL(background, NULL);
682
683 if (priv->main)
684 {
685 memcpy(&priv->preview->progress, progress, sizeof(Extra_Progress));
686 return priv->main;
687 }
667 688
668 urlstr = extra_background_download_url_get(background); 689 urlstr = extra_background_download_url_get(background);
669 path = extra_background_install_path_get(background); 690 path = extra_background_install_path_get(background);
670 691
671 extra_file_download(progress, urlstr, path, &priv->main_state); 692 extra_file_download(progress, urlstr, path, &priv->main);
672 693
673 free(urlstr); 694 free(urlstr);
674 free(path); 695 free(path);
696
697 return priv->main;
675} 698}
676 699
700
677EAPI char* 701EAPI char*
678extra_background_preview_get(Extra_Background *background) 702extra_background_preview_get(Extra_Background *background)
679{ 703{
680 char *local; 704 char *local;
681 Extra_Background_Private *priv = (Extra_Background_Private*) background; 705 Extra_Background_Private *priv = (Extra_Background_Private*) background;
682 706
683 if (priv->preview_state & EXTRA_STATE_DOWNLOAD_IN_PROGRESS) return NULL; 707 if (priv->preview) return NULL;
684 708
685 local = _extra_preview_local_generate("backgrounds", background->id, background->version); 709 local = _extra_preview_local_generate("backgrounds", background->id, background->version);
686 if (!ecore_file_exists(local)) 710 if (!ecore_file_exists(local))
@@ -692,19 +716,27 @@ extra_background_preview_get(Extra_Background *background)
692 return local; 716 return local;
693} 717}
694 718
695EAPI void 719EAPI Extra_Request*
696extra_background_preview_download(Extra_Progress *progress, Extra_Background *background) 720extra_background_preview_download(Extra_Progress *progress, Extra_Background *background)
697{ 721{
698 char *remote, *local; 722 char *remote, *local;
699 Extra_Background_Private *priv = (Extra_Background_Private*) background; 723 Extra_Background_Private *priv = (Extra_Background_Private*) background;
700 724
725 if (priv->preview)
726 {
727 memcpy(&priv->preview->progress, progress, sizeof(Extra_Progress));
728 return priv->preview;
729 }
730
701 remote = _extra_preview_remote_generate("backgrounds", background->id); 731 remote = _extra_preview_remote_generate("backgrounds", background->id);
702 local = _extra_preview_local_generate("backgrounds", background->id, background->version); 732 local = _extra_preview_local_generate("backgrounds", background->id, background->version);
703 733
704 extra_file_download(progress, remote, local, &priv->preview_state); 734 extra_file_download(progress, remote, local, &priv->preview);
705 735
706 free(local); 736 free(local);
707 free(remote); 737 free(remote);
738
739 return priv->preview;
708} 740}
709 741
710EAPI void 742EAPI void
@@ -718,3 +750,13 @@ extra_background_delete(Extra_Background *b)
718 750
719 free(path); 751 free(path);
720} 752}
753
754EAPI void
755extra_request_mute(Extra_Request *req)
756{
757 if(!req) return;
758
759 req->progress.data = NULL;
760 req->progress.progress_cb = NULL;
761 req->progress.done_cb = NULL;
762}
diff --git a/src/lib/extra.h b/src/lib/extra.h
index 7111d64..2bcbbcb 100644
--- a/src/lib/extra.h
+++ b/src/lib/extra.h
@@ -65,6 +65,8 @@ typedef struct _Extra_Progress
65 void *data; 65 void *data;
66} Extra_Progress; 66} Extra_Progress;
67 67
68typedef struct _Extra_Request Extra_Request;
69
68/** 70/**
69 * @brief Init / shutdown functions. 71 * @brief Init / shutdown functions.
70 * @defgroup Init Init / Shutdown 72 * @defgroup Init Init / Shutdown
@@ -151,7 +153,7 @@ EAPI Eina_Bool extra_theme_installed(Extra_Theme *theme);
151EAPI char *extra_theme_install_path_get(Extra_Theme *theme); 153EAPI char *extra_theme_install_path_get(Extra_Theme *theme);
152 154
153EAPI char *extra_theme_preview_get(Extra_Theme *theme); 155EAPI char *extra_theme_preview_get(Extra_Theme *theme);
154EAPI void extra_theme_preview_download(Extra_Progress *progress, Extra_Theme *theme); 156EAPI Extra_Request* extra_theme_preview_download(Extra_Progress *progress, Extra_Theme *theme);
155 157
156EAPI char *extra_theme_download_url_get(Extra_Theme *theme); 158EAPI char *extra_theme_download_url_get(Extra_Theme *theme);
157 159
@@ -160,7 +162,7 @@ EAPI char *extra_theme_download_url_get(Extra_Theme *theme);
160 * 162 *
161 * @ingroup Themes 163 * @ingroup Themes
162 */ 164 */
163EAPI void extra_theme_download(Extra_Progress *progress, Extra_Theme *theme); 165EAPI Extra_Request* extra_theme_download(Extra_Progress *progress, Extra_Theme *theme);
164 166
165/** 167/**
166 * @brief Set the theme as default and restart e 168 * @brief Set the theme as default and restart e
@@ -180,12 +182,13 @@ EAPI Eina_List* extra_backgrounds_list(void);
180EAPI Extra_Background* extra_background_get(const char *id); 182EAPI Extra_Background* extra_background_get(const char *id);
181 183
182EAPI Eina_Bool extra_background_installed(Extra_Background *b); 184EAPI Eina_Bool extra_background_installed(Extra_Background *b);
183EAPI void extra_background_download(Extra_Progress *progress, Extra_Background *b); 185EAPI Extra_Request* extra_background_download(Extra_Progress *progress, Extra_Background *b);
184EAPI void extra_background_delete(Extra_Background *b); 186EAPI void extra_background_delete(Extra_Background *b);
185 187
186EAPI char* extra_background_preview_get(Extra_Background *background); 188EAPI char* extra_background_preview_get(Extra_Background *background);
187EAPI void extra_background_preview_download(Extra_Progress *progress, Extra_Background *background); 189EAPI Extra_Request* extra_background_preview_download(Extra_Progress *progress, Extra_Background *background);
188 190
191EAPI void extra_request_mute(Extra_Request *req);
189 192
190#ifdef __cplusplus 193#ifdef __cplusplus
191} 194}
diff --git a/src/lib/extra_api_helper.c b/src/lib/extra_api_helper.c
index 96ebd61..b99da27 100644
--- a/src/lib/extra_api_helper.c
+++ b/src/lib/extra_api_helper.c
@@ -192,8 +192,8 @@ extra_json_to_list(Extra_Json_To_List_Template *tmp, Eina_Strbuf *buf)
192} 192}
193 193
194typedef struct { 194typedef struct {
195 char *state; 195 Extra_Request req;
196 Extra_Progress *progress; 196 Extra_Request **clean_up;
197} Extra_Download_Job; 197} Extra_Download_Job;
198 198
199static void 199static void
@@ -201,13 +201,15 @@ _download_complete_cb(void *data, const char *file EINA_UNUSED, int status EINA_
201{ 201{
202 Extra_Download_Job *job = data; 202 Extra_Download_Job *job = data;
203 203
204 *(job->state) &= (~EXTRA_STATE_DOWNLOAD_IN_PROGRESS);
205
206 if (status != 200) 204 if (status != 200)
207 ecore_file_remove(file); 205 ecore_file_remove(file);
208 206
209 if (job->progress->done_cb) 207 *job->clean_up = NULL;
210 job->progress->done_cb(job->progress->data); 208
209 if (job->req.progress.done_cb)
210 job->req.progress.done_cb(job->req.progress.data);
211
212 free(job);
211} 213}
212 214
213static int 215static int
@@ -221,18 +223,17 @@ _download_progress_cb(void *data EINA_UNUSED, const char *file EINA_UNUSED,
221 if (dlnow > 0.f) 223 if (dlnow > 0.f)
222 percent = ((double)(double)dlnow / (double)dltotal); 224 percent = ((double)(double)dlnow / (double)dltotal);
223 225
224 if (job->progress->progress_cb) 226 if (job->req.progress.progress_cb)
225 job->progress->progress_cb(job->progress->data, percent); 227 job->req.progress.progress_cb(job->req.progress.data, percent);
226 228
227 return ECORE_FILE_PROGRESS_CONTINUE; 229 return ECORE_FILE_PROGRESS_CONTINUE;
228} 230}
229 231
230void 232void
231extra_file_download(Extra_Progress *progress, const char *from, const char *to, char* state) 233extra_file_download(Extra_Progress *progress, const char *from, const char *to, Extra_Request **req)
232{ 234{
233 Extra_Download_Job *job; 235 Extra_Download_Job *job;
234 236
235 if (*state & EXTRA_STATE_DOWNLOAD_IN_PROGRESS) return;
236 if (ecore_file_exists(to)) 237 if (ecore_file_exists(to))
237 { 238 {
238 //TODO better check the header and handle that sanely 239 //TODO better check the header and handle that sanely
@@ -240,9 +241,10 @@ extra_file_download(Extra_Progress *progress, const char *from, const char *to,
240 } 241 }
241 242
242 job = calloc(1, sizeof(Extra_Download_Job)); 243 job = calloc(1, sizeof(Extra_Download_Job));
243 job->progress = progress; 244 job->req.progress = *progress;
244 job->state = state; 245 job->clean_up = req;
245 *state |= EXTRA_STATE_DOWNLOAD_IN_PROGRESS;
246 246
247 ecore_file_download(from, to, _download_complete_cb, _download_progress_cb, job, NULL); 247 ecore_file_download(from, to, _download_complete_cb, _download_progress_cb, job, NULL);
248 } \ No newline at end of file 248
249 *req = &job->req;
250 }
diff --git a/src/lib/extra_private.h b/src/lib/extra_private.h
index 83baf27..9412489 100644
--- a/src/lib/extra_private.h
+++ b/src/lib/extra_private.h
@@ -38,6 +38,11 @@ typedef struct {
38 size_t tuples_size; 38 size_t tuples_size;
39} Extra_Json_To_List_Template; 39} Extra_Json_To_List_Template;
40 40
41struct _Extra_Request
42{
43 Extra_Progress progress;
44};
45
41#define EXTRA_STATE_DOWNLOAD_IN_PROGRESS 2 46#define EXTRA_STATE_DOWNLOAD_IN_PROGRESS 2
42 47
43 48
@@ -54,6 +59,6 @@ Extra_Json_To_List_Template v = { \
54Eina_List* extra_json_to_list(Extra_Json_To_List_Template *tmp, Eina_Strbuf *buf); 59Eina_List* extra_json_to_list(Extra_Json_To_List_Template *tmp, Eina_Strbuf *buf);
55void extra_json_list_part_free(Extra_Json_To_List_Template *tmp, void *data); 60void extra_json_list_part_free(Extra_Json_To_List_Template *tmp, void *data);
56 61
57void extra_file_download(Extra_Progress *progress, const char *from, const char *to, char* state); 62void extra_file_download(Extra_Progress *progress, const char *from, const char *to, Extra_Request **req);
58 63
59#endif 64#endif