summaryrefslogtreecommitdiff
path: root/legacy/ethumb
diff options
context:
space:
mode:
authorDaniel Juyung Seo <seojuyung2@gmail.com>2012-10-01 04:43:39 +0000
committerDaniel Juyung Seo <seojuyung2@gmail.com>2012-10-01 04:43:39 +0000
commite430627e7ee903cd8d1dcf38249b05c83249c56b (patch)
tree74eb570643a6678a6095679178156177c7bfc952 /legacy/ethumb
parent1e38f04bfcea52fbe8607653ff2f388cb4fa3e04 (diff)
ethumb ethumb.c: Fixed indentation.
SVN revision: 77233
Diffstat (limited to 'legacy/ethumb')
-rw-r--r--legacy/ethumb/src/lib/ethumb.c690
1 files changed, 345 insertions, 345 deletions
diff --git a/legacy/ethumb/src/lib/ethumb.c b/legacy/ethumb/src/lib/ethumb.c
index a78ecf55ac..ec7f44c828 100644
--- a/legacy/ethumb/src/lib/ethumb.c
+++ b/legacy/ethumb/src/lib/ethumb.c
@@ -108,33 +108,33 @@ _ethumb_plugin_list_cb(Eina_Module *m, void *data __UNUSED__)
108 file = eina_module_file_get(m); 108 file = eina_module_file_get(m);
109 if (!eina_module_load(m)) 109 if (!eina_module_load(m))
110 { 110 {
111 ERR("could not load module \"%s\": %s", 111 ERR("could not load module \"%s\": %s",
112 file, eina_error_msg_get(eina_error_get())); 112 file, eina_error_msg_get(eina_error_get()));
113 return EINA_FALSE; 113 return EINA_FALSE;
114 } 114 }
115 115
116 plugin_get = eina_module_symbol_get(m, "ethumb_plugin_get"); 116 plugin_get = eina_module_symbol_get(m, "ethumb_plugin_get");
117 if (!plugin_get) 117 if (!plugin_get)
118 { 118 {
119 ERR("could not find ethumb_plugin_get() in module \"%s\": %s", 119 ERR("could not find ethumb_plugin_get() in module \"%s\": %s",
120 file, eina_error_msg_get(eina_error_get())); 120 file, eina_error_msg_get(eina_error_get()));
121 eina_module_unload(m); 121 eina_module_unload(m);
122 return EINA_FALSE; 122 return EINA_FALSE;
123 } 123 }
124 124
125 plugin = plugin_get(); 125 plugin = plugin_get();
126 if (!plugin) 126 if (!plugin)
127 { 127 {
128 ERR("plugin \"%s\" failed to init.", file); 128 ERR("plugin \"%s\" failed to init.", file);
129 eina_module_unload(m); 129 eina_module_unload(m);
130 return EINA_FALSE; 130 return EINA_FALSE;
131 } 131 }
132 132
133 DBG("loaded plugin \"%s\" (%p) with extensions:", file, plugin); 133 DBG("loaded plugin \"%s\" (%p) with extensions:", file, plugin);
134 for (ext = plugin->extensions; *ext; ext++) 134 for (ext = plugin->extensions; *ext; ext++)
135 { 135 {
136 DBG(" extension \"%s\"", *ext); 136 DBG(" extension \"%s\"", *ext);
137 eina_hash_add(_plugins_ext, *ext, plugin); 137 eina_hash_add(_plugins_ext, *ext, plugin);
138 } 138 }
139 139
140 return EINA_TRUE; 140 return EINA_TRUE;
@@ -147,7 +147,7 @@ _ethumb_plugins_load(void)
147 EINA_SAFETY_ON_NULL_RETURN(_plugins_ext); 147 EINA_SAFETY_ON_NULL_RETURN(_plugins_ext);
148 148
149 _plugins = eina_module_list_get(_plugins, PLUGINSDIR, 1, 149 _plugins = eina_module_list_get(_plugins, PLUGINSDIR, 1,
150 &_ethumb_plugin_list_cb, NULL); 150 &_ethumb_plugin_list_cb, NULL);
151} 151}
152 152
153static void 153static void
@@ -172,15 +172,15 @@ ethumb_init(void)
172 172
173 if (!eina_init()) 173 if (!eina_init())
174 { 174 {
175 fprintf(stderr, "ERROR: Could not initialize eina.\n"); 175 fprintf(stderr, "ERROR: Could not initialize eina.\n");
176 return 0; 176 return 0;
177 } 177 }
178 _log_dom = eina_log_domain_register("ethumb", EINA_COLOR_GREEN); 178 _log_dom = eina_log_domain_register("ethumb", EINA_COLOR_GREEN);
179 if (_log_dom < 0) 179 if (_log_dom < 0)
180 { 180 {
181 EINA_LOG_ERR("Could not register log domain: ethumb"); 181 EINA_LOG_ERR("Could not register log domain: ethumb");
182 eina_shutdown(); 182 eina_shutdown();
183 return 0; 183 return 0;
184 } 184 }
185 185
186 evas_init(); 186 evas_init();
@@ -210,17 +210,17 @@ ethumb_shutdown(void)
210 initcount--; 210 initcount--;
211 if (initcount == 0) 211 if (initcount == 0)
212 { 212 {
213 _ethumb_plugins_unload(); 213 _ethumb_plugins_unload();
214 eina_stringshare_del(_home_thumb_dir); 214 eina_stringshare_del(_home_thumb_dir);
215 eina_stringshare_del(_thumb_category_normal); 215 eina_stringshare_del(_thumb_category_normal);
216 eina_stringshare_del(_thumb_category_large); 216 eina_stringshare_del(_thumb_category_large);
217 evas_shutdown(); 217 evas_shutdown();
218 ecore_shutdown(); 218 ecore_shutdown();
219 ecore_evas_shutdown(); 219 ecore_evas_shutdown();
220 edje_shutdown(); 220 edje_shutdown();
221 eina_log_domain_unregister(_log_dom); 221 eina_log_domain_unregister(_log_dom);
222 _log_dom = -1; 222 _log_dom = -1;
223 eina_shutdown(); 223 eina_shutdown();
224 } 224 }
225 225
226 return initcount; 226 return initcount;
@@ -255,9 +255,9 @@ ethumb_new(void)
255 e = ecore_evas_get(ee); 255 e = ecore_evas_get(ee);
256 if (!e) 256 if (!e)
257 { 257 {
258 ERR("could not create ecore evas buffer"); 258 ERR("could not create ecore evas buffer");
259 free(ethumb); 259 free(ethumb);
260 return NULL; 260 return NULL;
261 } 261 }
262 262
263 evas_image_cache_set(e, 0); 263 evas_image_cache_set(e, 0);
@@ -266,10 +266,10 @@ ethumb_new(void)
266 o = ecore_evas_object_image_new(ee); 266 o = ecore_evas_object_image_new(ee);
267 if (!o) 267 if (!o)
268 { 268 {
269 ERR("could not create sub ecore evas buffer"); 269 ERR("could not create sub ecore evas buffer");
270 ecore_evas_free(ee); 270 ecore_evas_free(ee);
271 free(ethumb); 271 free(ethumb);
272 return NULL; 272 return NULL;
273 } 273 }
274 274
275 sub_ee = ecore_evas_object_ecore_evas_get(o); 275 sub_ee = ecore_evas_object_ecore_evas_get(o);
@@ -282,10 +282,10 @@ ethumb_new(void)
282 img = evas_object_image_add(sub_e); 282 img = evas_object_image_add(sub_e);
283 if (!img) 283 if (!img)
284 { 284 {
285 ERR("could not create source objects."); 285 ERR("could not create source objects.");
286 ecore_evas_free(ee); 286 ecore_evas_free(ee);
287 free(ethumb); 287 free(ethumb);
288 return NULL; 288 return NULL;
289 } 289 }
290 290
291 ethumb->ee = ee; 291 ethumb->ee = ee;
@@ -310,9 +310,9 @@ _ethumb_frame_free(Ethumb_Frame *frame)
310 310
311 if (frame->swallow && frame->edje) 311 if (frame->swallow && frame->edje)
312 { 312 {
313 o = edje_object_part_swallow_get(frame->edje, frame->swallow); 313 o = edje_object_part_swallow_get(frame->edje, frame->swallow);
314 if (o) 314 if (o)
315 edje_object_part_unswallow(frame->edje, o); 315 edje_object_part_unswallow(frame->edje, o);
316 } 316 }
317 eina_stringshare_del(frame->file); 317 eina_stringshare_del(frame->file);
318 eina_stringshare_del(frame->group); 318 eina_stringshare_del(frame->group);
@@ -348,18 +348,18 @@ ethumb_thumb_fdo_set(Ethumb *e, Ethumb_Thumb_FDO_Size s)
348{ 348{
349 EINA_SAFETY_ON_NULL_RETURN(e); 349 EINA_SAFETY_ON_NULL_RETURN(e);
350 EINA_SAFETY_ON_FALSE_RETURN(s == ETHUMB_THUMB_NORMAL || 350 EINA_SAFETY_ON_FALSE_RETURN(s == ETHUMB_THUMB_NORMAL ||
351 s == ETHUMB_THUMB_LARGE); 351 s == ETHUMB_THUMB_LARGE);
352 DBG("ethumb=%p, size=%d", e, s); 352 DBG("ethumb=%p, size=%d", e, s);
353 353
354 if (s == ETHUMB_THUMB_NORMAL) 354 if (s == ETHUMB_THUMB_NORMAL)
355 { 355 {
356 e->tw = THUMB_SIZE_NORMAL; 356 e->tw = THUMB_SIZE_NORMAL;
357 e->th = THUMB_SIZE_NORMAL; 357 e->th = THUMB_SIZE_NORMAL;
358 } 358 }
359 else 359 else
360 { 360 {
361 e->tw = THUMB_SIZE_LARGE; 361 e->tw = THUMB_SIZE_LARGE;
362 e->th = THUMB_SIZE_LARGE; 362 e->th = THUMB_SIZE_LARGE;
363 } 363 }
364 364
365 e->format = ETHUMB_THUMB_FDO; 365 e->format = ETHUMB_THUMB_FDO;
@@ -399,8 +399,8 @@ ethumb_thumb_format_set(Ethumb *e, Ethumb_Thumb_Format f)
399{ 399{
400 EINA_SAFETY_ON_NULL_RETURN(e); 400 EINA_SAFETY_ON_NULL_RETURN(e);
401 EINA_SAFETY_ON_FALSE_RETURN(f == ETHUMB_THUMB_FDO || 401 EINA_SAFETY_ON_FALSE_RETURN(f == ETHUMB_THUMB_FDO ||
402 f == ETHUMB_THUMB_JPEG || 402 f == ETHUMB_THUMB_JPEG ||
403 f == ETHUMB_THUMB_EET); 403 f == ETHUMB_THUMB_EET);
404 404
405 DBG("ethumb=%p, format=%d", e, f); 405 DBG("ethumb=%p, format=%d", e, f);
406 e->format = f; 406 e->format = f;
@@ -418,8 +418,8 @@ ethumb_thumb_aspect_set(Ethumb *e, Ethumb_Thumb_Aspect a)
418{ 418{
419 EINA_SAFETY_ON_NULL_RETURN(e); 419 EINA_SAFETY_ON_NULL_RETURN(e);
420 EINA_SAFETY_ON_FALSE_RETURN(a == ETHUMB_THUMB_KEEP_ASPECT || 420 EINA_SAFETY_ON_FALSE_RETURN(a == ETHUMB_THUMB_KEEP_ASPECT ||
421 a == ETHUMB_THUMB_IGNORE_ASPECT || 421 a == ETHUMB_THUMB_IGNORE_ASPECT ||
422 a == ETHUMB_THUMB_CROP); 422 a == ETHUMB_THUMB_CROP);
423 423
424 DBG("ethumb=%p, aspect=%d", e, a); 424 DBG("ethumb=%p, aspect=%d", e, a);
425 e->aspect = a; 425 e->aspect = a;
@@ -437,14 +437,14 @@ ethumb_thumb_orientation_set(Ethumb *e, Ethumb_Thumb_Orientation o)
437{ 437{
438 EINA_SAFETY_ON_NULL_RETURN(e); 438 EINA_SAFETY_ON_NULL_RETURN(e);
439 EINA_SAFETY_ON_FALSE_RETURN(o == ETHUMB_THUMB_ORIENT_NONE || 439 EINA_SAFETY_ON_FALSE_RETURN(o == ETHUMB_THUMB_ORIENT_NONE ||
440 o == ETHUMB_THUMB_ROTATE_90_CW || 440 o == ETHUMB_THUMB_ROTATE_90_CW ||
441 o == ETHUMB_THUMB_ROTATE_180 || 441 o == ETHUMB_THUMB_ROTATE_180 ||
442 o == ETHUMB_THUMB_ROTATE_90_CCW || 442 o == ETHUMB_THUMB_ROTATE_90_CCW ||
443 o == ETHUMB_THUMB_FLIP_HORIZONTAL || 443 o == ETHUMB_THUMB_FLIP_HORIZONTAL ||
444 o == ETHUMB_THUMB_FLIP_VERTICAL || 444 o == ETHUMB_THUMB_FLIP_VERTICAL ||
445 o == ETHUMB_THUMB_FLIP_TRANSPOSE || 445 o == ETHUMB_THUMB_FLIP_TRANSPOSE ||
446 o == ETHUMB_THUMB_FLIP_TRANSVERSE || 446 o == ETHUMB_THUMB_FLIP_TRANSVERSE ||
447 o == ETHUMB_THUMB_ORIENT_ORIGINAL); 447 o == ETHUMB_THUMB_ORIENT_ORIGINAL);
448 448
449 DBG("ethumb=%p, orientation=%d", e, o); 449 DBG("ethumb=%p, orientation=%d", e, o);
450 e->orientation = o; 450 e->orientation = o;
@@ -522,51 +522,51 @@ ethumb_frame_set(Ethumb *e, const char *theme_file, const char *group, const cha
522 522
523 if (frame) 523 if (frame)
524 { 524 {
525 edje_object_part_unswallow(frame->edje, e->img); 525 edje_object_part_unswallow(frame->edje, e->img);
526 if (!theme_file) 526 if (!theme_file)
527 _ethumb_frame_free(frame); 527 _ethumb_frame_free(frame);
528 } 528 }
529 529
530 if (!theme_file) 530 if (!theme_file)
531 { 531 {
532 e->frame = NULL; 532 e->frame = NULL;
533 return EINA_FALSE; 533 return EINA_FALSE;
534 } 534 }
535 535
536 if (!frame) 536 if (!frame)
537 { 537 {
538 frame = calloc(1, sizeof(Ethumb_Frame)); 538 frame = calloc(1, sizeof(Ethumb_Frame));
539 if (!frame) 539 if (!frame)
540 { 540 {
541 ERR("could not allocate Ethumb_Frame structure."); 541 ERR("could not allocate Ethumb_Frame structure.");
542 return EINA_FALSE; 542 return EINA_FALSE;
543 } 543 }
544 544
545 frame->edje = edje_object_add(e->sub_e); 545 frame->edje = edje_object_add(e->sub_e);
546 if (!frame->edje) 546 if (!frame->edje)
547 { 547 {
548 ERR("could not create edje frame object."); 548 ERR("could not create edje frame object.");
549 _ethumb_frame_free(frame); 549 _ethumb_frame_free(frame);
550 e->frame = NULL; 550 e->frame = NULL;
551 return EINA_FALSE; 551 return EINA_FALSE;
552 } 552 }
553 } 553 }
554 554
555 if (!edje_object_file_set(frame->edje, theme_file, group)) 555 if (!edje_object_file_set(frame->edje, theme_file, group))
556 { 556 {
557 ERR("could not load frame theme."); 557 ERR("could not load frame theme.");
558 _ethumb_frame_free(frame); 558 _ethumb_frame_free(frame);
559 e->frame = NULL; 559 e->frame = NULL;
560 return EINA_FALSE; 560 return EINA_FALSE;
561 } 561 }
562 562
563 edje_object_part_swallow(frame->edje, swallow, e->img); 563 edje_object_part_swallow(frame->edje, swallow, e->img);
564 if (!edje_object_part_swallow_get(frame->edje, swallow)) 564 if (!edje_object_part_swallow_get(frame->edje, swallow))
565 { 565 {
566 ERR("could not swallow image to edje frame."); 566 ERR("could not swallow image to edje frame.");
567 _ethumb_frame_free(frame); 567 _ethumb_frame_free(frame);
568 e->frame = NULL; 568 e->frame = NULL;
569 return EINA_FALSE; 569 return EINA_FALSE;
570 } 570 }
571 571
572 eina_stringshare_replace(&frame->file, theme_file); 572 eina_stringshare_replace(&frame->file, theme_file);
@@ -585,15 +585,15 @@ ethumb_frame_get(const Ethumb *e, const char **theme_file, const char **group, c
585 585
586 if (e->frame) 586 if (e->frame)
587 { 587 {
588 if (theme_file) *theme_file = e->frame->file; 588 if (theme_file) *theme_file = e->frame->file;
589 if (group) *group = e->frame->group; 589 if (group) *group = e->frame->group;
590 if (swallow) *swallow = e->frame->swallow; 590 if (swallow) *swallow = e->frame->swallow;
591 } 591 }
592 else 592 else
593 { 593 {
594 if (theme_file) *theme_file = NULL; 594 if (theme_file) *theme_file = NULL;
595 if (group) *group = NULL; 595 if (group) *group = NULL;
596 if (swallow) *swallow = NULL; 596 if (swallow) *swallow = NULL;
597 } 597 }
598} 598}
599 599
@@ -612,25 +612,25 @@ _ethumb_build_absolute_path(const char *path, char buf[PATH_MAX])
612 strcpy(p, path); 612 strcpy(p, path);
613 else if (path[0] == '~') 613 else if (path[0] == '~')
614 { 614 {
615 const char *home = getenv("HOME"); 615 const char *home = getenv("HOME");
616 if (!home) 616 if (!home)
617 return NULL; 617 return NULL;
618 strcpy(p, home); 618 strcpy(p, home);
619 len = strlen(p); 619 len = strlen(p);
620 p += len; 620 p += len;
621 p[0] = '/'; 621 p[0] = '/';
622 p++; 622 p++;
623 strcpy(p, path + 2); 623 strcpy(p, path + 2);
624 } 624 }
625 else 625 else
626 { 626 {
627 if (!getcwd(p, PATH_MAX)) 627 if (!getcwd(p, PATH_MAX))
628 return NULL; 628 return NULL;
629 len = strlen(p); 629 len = strlen(p);
630 p += len; 630 p += len;
631 p[0] = '/'; 631 p[0] = '/';
632 p++; 632 p++;
633 strcpy(p, path); 633 strcpy(p, path);
634 } 634 }
635 635
636 return buf; 636 return buf;
@@ -790,8 +790,8 @@ ethumb_file_set(Ethumb *e, const char *path, const char *key)
790 DBG("ethumb=%p, path=%s, key=%s", e, path ? path : "", key ? key : ""); 790 DBG("ethumb=%p, path=%s, key=%s", e, path ? path : "", key ? key : "");
791 if (path && access(path, R_OK)) 791 if (path && access(path, R_OK))
792 { 792 {
793 ERR("couldn't access file \"%s\"", path); 793 ERR("couldn't access file \"%s\"", path);
794 return EINA_FALSE; 794 return EINA_FALSE;
795 } 795 }
796 796
797 path = _ethumb_build_absolute_path(path, buf); 797 path = _ethumb_build_absolute_path(path, buf);
@@ -829,85 +829,85 @@ static const char ACCEPTABLE_URI_CHARS[96] = {
829static const char * 829static const char *
830_ethumb_generate_hash(const char *file) 830_ethumb_generate_hash(const char *file)
831{ 831{
832 int n; 832 int n;
833 MD5_CTX ctx; 833 MD5_CTX ctx;
834 char md5out[(2 * MD5_HASHBYTES) + 1]; 834 char md5out[(2 * MD5_HASHBYTES) + 1];
835 unsigned char hash[MD5_HASHBYTES]; 835 unsigned char hash[MD5_HASHBYTES];
836 static const char hex[] = "0123456789abcdef"; 836 static const char hex[] = "0123456789abcdef";
837 837
838 char *uri; 838 char *uri;
839 char *t; 839 char *t;
840 const unsigned char *c; 840 const unsigned char *c;
841 841
842#ifdef HAVE_XATTR 842#ifdef HAVE_XATTR
843 ssize_t length; 843 ssize_t length;
844 844
845 length = getxattr(file, "user.e.md5", NULL, 0); 845 length = getxattr(file, "user.e.md5", NULL, 0);
846 846
847 if (length > 0) 847 if (length > 0)
848 { 848 {
849 char *tmp; 849 char *tmp;
850 850
851 tmp = alloca(length); 851 tmp = alloca(length);
852 length = getxattr(file, "user.e.md5", tmp, length); 852 length = getxattr(file, "user.e.md5", tmp, length);
853 853
854 /* check if we have at least something that look like a md5 hash */ 854 /* check if we have at least something that look like a md5 hash */
855 if (length > 0 && (length == MD5_HASHBYTES * 2 + 1)) 855 if (length > 0 && (length == MD5_HASHBYTES * 2 + 1))
856 { 856 {
857 tmp[length] = '\0'; 857 tmp[length] = '\0';
858 return eina_stringshare_add(tmp); 858 return eina_stringshare_add(tmp);
859 } 859 }
860 } 860 }
861#endif 861#endif
862 862
863#define _check_uri_char(c) \ 863#define _check_uri_char(c) \
864 ((c) >= 32 && (c) < 128 && (ACCEPTABLE_URI_CHARS[(c) - 32] & 0x08)) 864 ((c) >= 32 && (c) < 128 && (ACCEPTABLE_URI_CHARS[(c) - 32] & 0x08))
865 865
866 EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL); 866 EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
867 867
868 uri = alloca(3 * strlen(file) + 9); 868 uri = alloca(3 * strlen(file) + 9);
869 memcpy(uri, "file://", sizeof("file://") - 1); 869 memcpy(uri, "file://", sizeof("file://") - 1);
870 t = uri + sizeof("file://") - 1; 870 t = uri + sizeof("file://") - 1;
871 871
872 for (c = (const unsigned char *)file; *c != '\0'; c++) 872 for (c = (const unsigned char *)file; *c != '\0'; c++)
873 { 873 {
874 if (!_check_uri_char(*c)) 874 if (!_check_uri_char(*c))
875 { 875 {
876 *t++ = '%'; 876 *t++ = '%';
877 *t++ = hex[*c >> 4]; 877 *t++ = hex[*c >> 4];
878 *t++ = hex[*c & 15]; 878 *t++ = hex[*c & 15];
879 } 879 }
880 else 880 else
881 *t++ = *c; 881 *t++ = *c;
882 } 882 }
883 *t = '\0'; 883 *t = '\0';
884 884
885#undef _check_uri_char 885#undef _check_uri_char
886 886
887 MD5Init (&ctx); 887 MD5Init (&ctx);
888 MD5Update (&ctx, (unsigned char const*)uri, (unsigned)strlen (uri)); 888 MD5Update (&ctx, (unsigned char const*)uri, (unsigned)strlen (uri));
889 MD5Final (hash, &ctx); 889 MD5Final (hash, &ctx);
890 890
891 for (n = 0; n < MD5_HASHBYTES; n++) 891 for (n = 0; n < MD5_HASHBYTES; n++)
892 { 892 {
893 md5out[2 * n] = hex[hash[n] >> 4]; 893 md5out[2 * n] = hex[hash[n] >> 4];
894 md5out[2 * n + 1] = hex[hash[n] & 0x0f]; 894 md5out[2 * n + 1] = hex[hash[n] & 0x0f];
895 } 895 }
896 md5out[2 * n] = '\0'; 896 md5out[2 * n] = '\0';
897 897
898#ifdef HAVE_XATTR 898#ifdef HAVE_XATTR
899 setxattr(file, "user.e.md5", md5out, 2 * n + 1, 0); 899 setxattr(file, "user.e.md5", md5out, 2 * n + 1, 0);
900#endif 900#endif
901 901
902 DBG("md5=%s, file=%s", md5out, file); 902 DBG("md5=%s, file=%s", md5out, file);
903 return eina_stringshare_add(md5out); 903 return eina_stringshare_add(md5out);
904} 904}
905 905
906static int 906static int
907_ethumb_file_check_fdo(Ethumb *e) 907_ethumb_file_check_fdo(Ethumb *e)
908{ 908{
909 if (!((e->tw == THUMB_SIZE_NORMAL && e->th == THUMB_SIZE_NORMAL) || 909 if (!((e->tw == THUMB_SIZE_NORMAL && e->th == THUMB_SIZE_NORMAL) ||
910 (e->tw == THUMB_SIZE_LARGE && e->th == THUMB_SIZE_LARGE))) 910 (e->tw == THUMB_SIZE_LARGE && e->th == THUMB_SIZE_LARGE)))
911 return 0; 911 return 0;
912 912
913 if (e->format != ETHUMB_THUMB_FDO) 913 if (e->format != ETHUMB_THUMB_FDO)
@@ -949,7 +949,7 @@ _ethumb_file_generate_custom_category(Ethumb *e)
949 frame = ""; 949 frame = "";
950 950
951 snprintf(buf, sizeof(buf), "%dx%d-%s%s-%s", 951 snprintf(buf, sizeof(buf), "%dx%d-%s%s-%s",
952 e->tw, e->th, aspect, frame, format); 952 e->tw, e->th, aspect, frame, format);
953 953
954 return eina_stringshare_add(buf); 954 return eina_stringshare_add(buf);
955} 955}
@@ -975,16 +975,16 @@ _ethumb_file_generate_path(Ethumb *e)
975 category = _ethumb_file_generate_custom_category(e); 975 category = _ethumb_file_generate_custom_category(e);
976 else 976 else
977 { 977 {
978 if (e->tw == THUMB_SIZE_NORMAL) 978 if (e->tw == THUMB_SIZE_NORMAL)
979 category = eina_stringshare_ref(_thumb_category_normal); 979 category = eina_stringshare_ref(_thumb_category_normal);
980 else if (e->tw == THUMB_SIZE_LARGE) 980 else if (e->tw == THUMB_SIZE_LARGE)
981 category = eina_stringshare_ref(_thumb_category_large); 981 category = eina_stringshare_ref(_thumb_category_large);
982 else 982 else
983 { 983 {
984 ERR("fdo_format but size %d is not NORMAL (%d) or LARGE (%d)?", 984 ERR("fdo_format but size %d is not NORMAL (%d) or LARGE (%d)?",
985 e->tw, THUMB_SIZE_NORMAL, THUMB_SIZE_LARGE); 985 e->tw, THUMB_SIZE_NORMAL, THUMB_SIZE_LARGE);
986 category = "unknown"; 986 category = "unknown";
987 } 987 }
988 } 988 }
989 989
990 if (e->format == ETHUMB_THUMB_FDO) 990 if (e->format == ETHUMB_THUMB_FDO)
@@ -996,11 +996,11 @@ _ethumb_file_generate_path(Ethumb *e)
996 996
997 if (!e->src_hash) 997 if (!e->src_hash)
998 { 998 {
999 char *fullname; 999 char *fullname;
1000 1000
1001 fullname = ecore_file_realpath(e->src_path); 1001 fullname = ecore_file_realpath(e->src_path);
1002 e->src_hash = _ethumb_generate_hash(fullname); 1002 e->src_hash = _ethumb_generate_hash(fullname);
1003 free(fullname); 1003 free(fullname);
1004 } 1004 }
1005 snprintf(buf, sizeof(buf), "%s/%s/%s.%s", thumb_dir, category, e->src_hash, ext); 1005 snprintf(buf, sizeof(buf), "%s/%s/%s.%s", thumb_dir, category, e->src_hash, ext);
1006 DBG("ethumb=%p, path=%s", e, buf); 1006 DBG("ethumb=%p, path=%s", e, buf);
@@ -1009,8 +1009,8 @@ _ethumb_file_generate_path(Ethumb *e)
1009 eina_stringshare_replace(&e->thumb_key, "thumbnail"); 1009 eina_stringshare_replace(&e->thumb_key, "thumbnail");
1010 else 1010 else
1011 { 1011 {
1012 eina_stringshare_del(e->thumb_key); 1012 eina_stringshare_del(e->thumb_key);
1013 e->thumb_key = NULL; 1013 e->thumb_key = NULL;
1014 } 1014 }
1015 1015
1016 eina_stringshare_del(thumb_dir); 1016 eina_stringshare_del(thumb_dir);
@@ -1040,14 +1040,14 @@ ethumb_thumb_path_set(Ethumb *e, const char *path, const char *key)
1040 1040
1041 if (!path) 1041 if (!path)
1042 { 1042 {
1043 eina_stringshare_replace(&e->thumb_path, NULL); 1043 eina_stringshare_replace(&e->thumb_path, NULL);
1044 eina_stringshare_replace(&e->thumb_key, NULL); 1044 eina_stringshare_replace(&e->thumb_key, NULL);
1045 } 1045 }
1046 else 1046 else
1047 { 1047 {
1048 path = _ethumb_build_absolute_path(path, buf); 1048 path = _ethumb_build_absolute_path(path, buf);
1049 eina_stringshare_replace(&e->thumb_path, path); 1049 eina_stringshare_replace(&e->thumb_path, path);
1050 eina_stringshare_replace(&e->thumb_key, key); 1050 eina_stringshare_replace(&e->thumb_key, key);
1051 } 1051 }
1052} 1052}
1053 1053
@@ -1103,10 +1103,10 @@ ethumb_calculate_aspect_from_ratio(Ethumb *e, float ia, int *w, int *h)
1103 1103
1104 if (e->aspect == ETHUMB_THUMB_KEEP_ASPECT) 1104 if (e->aspect == ETHUMB_THUMB_KEEP_ASPECT)
1105 { 1105 {
1106 if ((ia > a && e->tw > 0) || e->th <= 0) 1106 if ((ia > a && e->tw > 0) || e->th <= 0)
1107 *h = e->tw / ia; 1107 *h = e->tw / ia;
1108 else 1108 else
1109 *w = e->th * ia; 1109 *w = e->th * ia;
1110 } 1110 }
1111} 1111}
1112 1112
@@ -1137,20 +1137,20 @@ ethumb_calculate_fill_from_ratio(Ethumb *e, float ia, int *fx, int *fy, int *fw,
1137 1137
1138 if (e->aspect == ETHUMB_THUMB_CROP) 1138 if (e->aspect == ETHUMB_THUMB_CROP)
1139 { 1139 {
1140 if ((ia > a && e->tw > 0) || e->th <= 0) 1140 if ((ia > a && e->tw > 0) || e->th <= 0)
1141 *fw = e->th * ia; 1141 *fw = e->th * ia;
1142 else 1142 else
1143 *fh = e->tw / ia; 1143 *fh = e->tw / ia;
1144 1144
1145 *fx = - e->crop_x * (*fw - e->tw); 1145 *fx = - e->crop_x * (*fw - e->tw);
1146 *fy = - e->crop_y * (*fh - e->th); 1146 *fy = - e->crop_y * (*fh - e->th);
1147 } 1147 }
1148 else if (e->aspect == ETHUMB_THUMB_KEEP_ASPECT) 1148 else if (e->aspect == ETHUMB_THUMB_KEEP_ASPECT)
1149 { 1149 {
1150 if ((ia > a && e->tw > 0) || e->th <= 0) 1150 if ((ia > a && e->tw > 0) || e->th <= 0)
1151 *fh = e->tw / ia; 1151 *fh = e->tw / ia;
1152 else 1152 else
1153 *fw = e->th * ia; 1153 *fw = e->th * ia;
1154 } 1154 }
1155} 1155}
1156 1156
@@ -1174,18 +1174,18 @@ _ethumb_plugin_generate(Ethumb *e)
1174 extp = strrchr(e->src_path, '.'); 1174 extp = strrchr(e->src_path, '.');
1175 if (!extp) 1175 if (!extp)
1176 { 1176 {
1177 ERR("could not get extension for file \"%s\"", e->src_path); 1177 ERR("could not get extension for file \"%s\"", e->src_path);
1178 return EINA_FALSE; 1178 return EINA_FALSE;
1179 } 1179 }
1180 1180
1181 for (i = 0; extp[i] != '\0'; i++) 1181 for (i = 0; extp[i] != '\0'; i++)
1182 ext[i] = tolower(extp[i + 1]); 1182 ext[i] = tolower(extp[i + 1]);
1183 1183
1184 plugin = eina_hash_find(_plugins_ext, ext); 1184 plugin = eina_hash_find(_plugins_ext, ext);
1185 if (!plugin) 1185 if (!plugin)
1186 { 1186 {
1187 DBG("no plugin for extension: \"%s\"", ext); 1187 DBG("no plugin for extension: \"%s\"", ext);
1188 return EINA_FALSE; 1188 return EINA_FALSE;
1189 } 1189 }
1190 1190
1191 if (e->frame) 1191 if (e->frame)
@@ -1208,16 +1208,16 @@ ethumb_plugin_image_resize(Ethumb *e, int w, int h)
1208 1208
1209 if (e->frame) 1209 if (e->frame)
1210 { 1210 {
1211 edje_extern_object_min_size_set(img, w, h); 1211 edje_extern_object_min_size_set(img, w, h);
1212 edje_extern_object_max_size_set(img, w, h); 1212 edje_extern_object_max_size_set(img, w, h);
1213 edje_object_calc_force(e->frame->edje); 1213 edje_object_calc_force(e->frame->edje);
1214 evas_object_move(e->frame->edje, 0, 0); 1214 evas_object_move(e->frame->edje, 0, 0);
1215 evas_object_resize(e->frame->edje, w, h); 1215 evas_object_resize(e->frame->edje, w, h);
1216 } 1216 }
1217 else 1217 else
1218 { 1218 {
1219 evas_object_move(img, 0, 0); 1219 evas_object_move(img, 0, 0);
1220 evas_object_resize(img, w, h); 1220 evas_object_resize(img, w, h);
1221 } 1221 }
1222 1222
1223 evas_object_image_size_set(e->o, w, h); 1223 evas_object_image_size_set(e->o, w, h);
@@ -1244,8 +1244,8 @@ ethumb_image_save(Ethumb *e)
1244 1244
1245 if (!e->thumb_path) 1245 if (!e->thumb_path)
1246 { 1246 {
1247 ERR("could not create file path..."); 1247 ERR("could not create file path...");
1248 return EINA_FALSE; 1248 return EINA_FALSE;
1249 } 1249 }
1250 1250
1251 dname = ecore_file_dir_get(e->thumb_path); 1251 dname = ecore_file_dir_get(e->thumb_path);
@@ -1253,19 +1253,19 @@ ethumb_image_save(Ethumb *e)
1253 free(dname); 1253 free(dname);
1254 if (!r) 1254 if (!r)
1255 { 1255 {
1256 ERR("could not create directory '%s'", dname); 1256 ERR("could not create directory '%s'", dname);
1257 return EINA_FALSE; 1257 return EINA_FALSE;
1258 } 1258 }
1259 1259
1260 snprintf(flags, sizeof(flags), "quality=%d compress=%d", 1260 snprintf(flags, sizeof(flags), "quality=%d compress=%d",
1261 e->quality, e->compress); 1261 e->quality, e->compress);
1262 r = evas_object_image_save(e->o, e->thumb_path, e->thumb_key, flags); 1262 r = evas_object_image_save(e->o, e->thumb_path, e->thumb_key, flags);
1263 1263
1264 if (!r) 1264 if (!r)
1265 { 1265 {
1266 ERR("could not save image: path=%s, key=%s", e->thumb_path, 1266 ERR("could not save image: path=%s, key=%s", e->thumb_path,
1267 e->thumb_key); 1267 e->thumb_key);
1268 return EINA_FALSE; 1268 return EINA_FALSE;
1269 } 1269 }
1270 1270
1271 return EINA_TRUE; 1271 return EINA_TRUE;
@@ -1287,55 +1287,55 @@ _ethumb_image_orient(Ethumb *e, int orientation)
1287 switch (orientation) 1287 switch (orientation)
1288 { 1288 {
1289 case ETHUMB_THUMB_FLIP_HORIZONTAL: 1289 case ETHUMB_THUMB_FLIP_HORIZONTAL:
1290 for (y = 0; y < ih; y++) 1290 for (y = 0; y < ih; y++)
1291 { 1291 {
1292 p1 = data + (y * iw); 1292 p1 = data + (y * iw);
1293 p2 = data + ((y + 1) * iw) - 1; 1293 p2 = data + ((y + 1) * iw) - 1;
1294 for (x = 0; x < (iw >> 1); x++) 1294 for (x = 0; x < (iw >> 1); x++)
1295 { 1295 {
1296 pt = *p1; 1296 pt = *p1;
1297 *p1 = *p2; 1297 *p1 = *p2;
1298 *p2 = pt; 1298 *p2 = pt;
1299 p1++; 1299 p1++;
1300 p2--; 1300 p2--;
1301 } 1301 }
1302 } 1302 }
1303 evas_object_image_data_set(img, data); 1303 evas_object_image_data_set(img, data);
1304 evas_object_image_data_update_add(img, 0, 0, iw, ih); 1304 evas_object_image_data_update_add(img, 0, 0, iw, ih);
1305 return; 1305 return;
1306 case ETHUMB_THUMB_FLIP_VERTICAL: 1306 case ETHUMB_THUMB_FLIP_VERTICAL:
1307 for (y = 0; y < (ih >> 1); y++) 1307 for (y = 0; y < (ih >> 1); y++)
1308 { 1308 {
1309 p1 = data + (y * iw); 1309 p1 = data + (y * iw);
1310 p2 = data + ((ih - 1 - y) * iw); 1310 p2 = data + ((ih - 1 - y) * iw);
1311 for (x = 0; x < iw; x++) 1311 for (x = 0; x < iw; x++)
1312 { 1312 {
1313 pt = *p1; 1313 pt = *p1;
1314 *p1 = *p2; 1314 *p1 = *p2;
1315 *p2 = pt; 1315 *p2 = pt;
1316 p1++; 1316 p1++;
1317 p2++; 1317 p2++;
1318 } 1318 }
1319 } 1319 }
1320 evas_object_image_data_set(img, data); 1320 evas_object_image_data_set(img, data);
1321 evas_object_image_data_update_add(img, 0, 0, iw, ih); 1321 evas_object_image_data_update_add(img, 0, 0, iw, ih);
1322 return; 1322 return;
1323 case ETHUMB_THUMB_ROTATE_180: 1323 case ETHUMB_THUMB_ROTATE_180:
1324 hw = iw * ih; 1324 hw = iw * ih;
1325 x = (hw / 2); 1325 x = (hw / 2);
1326 p1 = data; 1326 p1 = data;
1327 p2 = data + hw - 1; 1327 p2 = data + hw - 1;
1328 for (; --x > 0;) 1328 for (; --x > 0;)
1329 { 1329 {
1330 pt = *p1; 1330 pt = *p1;
1331 *p1 = *p2; 1331 *p1 = *p2;
1332 *p2 = pt; 1332 *p2 = pt;
1333 p1++; 1333 p1++;
1334 p2--; 1334 p2--;
1335 } 1335 }
1336 evas_object_image_data_set(img, data); 1336 evas_object_image_data_set(img, data);
1337 evas_object_image_data_update_add(img, 0, 0, iw, ih); 1337 evas_object_image_data_update_add(img, 0, 0, iw, ih);
1338 return; 1338 return;
1339 } 1339 }
1340 1340
1341 tmp = evas_object_image_add(evas_object_evas_get(img)); 1341 tmp = evas_object_image_add(evas_object_evas_get(img));
@@ -1354,28 +1354,28 @@ _ethumb_image_orient(Ethumb *e, int orientation)
1354 switch (orientation) 1354 switch (orientation)
1355 { 1355 {
1356 case ETHUMB_THUMB_FLIP_TRANSPOSE: 1356 case ETHUMB_THUMB_FLIP_TRANSPOSE:
1357 to = data; 1357 to = data;
1358 hw = -hw + 1; 1358 hw = -hw + 1;
1359 break; 1359 break;
1360 case ETHUMB_THUMB_FLIP_TRANSVERSE: 1360 case ETHUMB_THUMB_FLIP_TRANSVERSE:
1361 to = data + hw - 1; 1361 to = data + hw - 1;
1362 w = -w; 1362 w = -w;
1363 hw = hw - 1; 1363 hw = hw - 1;
1364 break; 1364 break;
1365 case ETHUMB_THUMB_ROTATE_90_CW: 1365 case ETHUMB_THUMB_ROTATE_90_CW:
1366 to = data + w - 1; 1366 to = data + w - 1;
1367 hw = -hw - 1; 1367 hw = -hw - 1;
1368 break; 1368 break;
1369 case ETHUMB_THUMB_ROTATE_90_CCW: 1369 case ETHUMB_THUMB_ROTATE_90_CCW:
1370 to = data + hw - w; 1370 to = data + hw - w;
1371 w = -w; 1371 w = -w;
1372 hw = hw + 1; 1372 hw = hw + 1;
1373 break; 1373 break;
1374 default: 1374 default:
1375 ERR("unknown orient %d", orientation); 1375 ERR("unknown orient %d", orientation);
1376 evas_object_del(tmp); 1376 evas_object_del(tmp);
1377 evas_object_image_data_set(img, data); // give it back 1377 evas_object_image_data_set(img, data); // give it back
1378 return; 1378 return;
1379 } 1379 }
1380 from = data2; 1380 from = data2;
1381 for (x = iw; --x >= 0;) 1381 for (x = iw; --x >= 0;)
@@ -1419,54 +1419,54 @@ _ethumb_image_load(Ethumb *e)
1419 error = evas_object_image_load_error_get(img); 1419 error = evas_object_image_load_error_get(img);
1420 if (error != EVAS_LOAD_ERROR_NONE) 1420 if (error != EVAS_LOAD_ERROR_NONE)
1421 { 1421 {
1422 ERR("could not load image '%s': %d", e->src_path, error); 1422 ERR("could not load image '%s': %d", e->src_path, error);
1423 return 0; 1423 return 0;
1424 } 1424 }
1425 1425
1426 if (e->orientation == ETHUMB_THUMB_ORIENT_ORIGINAL) 1426 if (e->orientation == ETHUMB_THUMB_ORIENT_ORIGINAL)
1427 { 1427 {
1428#ifdef HAVE_LIBEXIF 1428#ifdef HAVE_LIBEXIF
1429 ExifData *exif = exif_data_new_from_file(e->src_path); 1429 ExifData *exif = exif_data_new_from_file(e->src_path);
1430 ExifEntry *entry = NULL; 1430 ExifEntry *entry = NULL;
1431 ExifByteOrder bo; 1431 ExifByteOrder bo;
1432 int o = 0; 1432 int o = 0;
1433 1433
1434 if (exif) 1434 if (exif)
1435 { 1435 {
1436 entry = exif_data_get_entry(exif, EXIF_TAG_ORIENTATION); 1436 entry = exif_data_get_entry(exif, EXIF_TAG_ORIENTATION);
1437 if (entry) 1437 if (entry)
1438 { 1438 {
1439 bo = exif_data_get_byte_order(exif); 1439 bo = exif_data_get_byte_order(exif);
1440 o = exif_get_short(entry->data, bo); 1440 o = exif_get_short(entry->data, bo);
1441 } 1441 }
1442 exif_data_free(exif); 1442 exif_data_free(exif);
1443 switch (o) 1443 switch (o)
1444 { 1444 {
1445 case 2: 1445 case 2:
1446 orientation = ETHUMB_THUMB_FLIP_HORIZONTAL; 1446 orientation = ETHUMB_THUMB_FLIP_HORIZONTAL;
1447 break; 1447 break;
1448 case 3: 1448 case 3:
1449 orientation = ETHUMB_THUMB_ROTATE_180; 1449 orientation = ETHUMB_THUMB_ROTATE_180;
1450 break; 1450 break;
1451 case 4: 1451 case 4:
1452 orientation = ETHUMB_THUMB_FLIP_VERTICAL; 1452 orientation = ETHUMB_THUMB_FLIP_VERTICAL;
1453 break; 1453 break;
1454 case 5: 1454 case 5:
1455 orientation = ETHUMB_THUMB_FLIP_TRANSPOSE; 1455 orientation = ETHUMB_THUMB_FLIP_TRANSPOSE;
1456 break; 1456 break;
1457 case 6: 1457 case 6:
1458 orientation = ETHUMB_THUMB_ROTATE_90_CW; 1458 orientation = ETHUMB_THUMB_ROTATE_90_CW;
1459 break; 1459 break;
1460 case 7: 1460 case 7:
1461 orientation = ETHUMB_THUMB_FLIP_TRANSVERSE; 1461 orientation = ETHUMB_THUMB_FLIP_TRANSVERSE;
1462 break; 1462 break;
1463 case 8: 1463 case 8:
1464 orientation = ETHUMB_THUMB_ROTATE_90_CCW; 1464 orientation = ETHUMB_THUMB_ROTATE_90_CCW;
1465 break; 1465 break;
1466 } 1466 }
1467 } 1467 }
1468#endif 1468#endif
1469 } 1469 }
1470 1470
1471 if (orientation != ETHUMB_THUMB_ORIENT_NONE) 1471 if (orientation != ETHUMB_THUMB_ORIENT_NONE)
1472 _ethumb_image_orient(e, orientation); 1472 _ethumb_image_orient(e, orientation);
@@ -1479,16 +1479,16 @@ _ethumb_image_load(Ethumb *e)
1479 1479
1480 if (e->frame) 1480 if (e->frame)
1481 { 1481 {
1482 edje_extern_object_min_size_set(img, ww, hh); 1482 edje_extern_object_min_size_set(img, ww, hh);
1483 edje_extern_object_max_size_set(img, ww, hh); 1483 edje_extern_object_max_size_set(img, ww, hh);
1484 edje_object_calc_force(e->frame->edje); 1484 edje_object_calc_force(e->frame->edje);
1485 evas_object_move(e->frame->edje, 0, 0); 1485 evas_object_move(e->frame->edje, 0, 0);
1486 evas_object_resize(e->frame->edje, ww, hh); 1486 evas_object_resize(e->frame->edje, ww, hh);
1487 } 1487 }
1488 else 1488 else
1489 { 1489 {
1490 evas_object_move(img, 0, 0); 1490 evas_object_move(img, 0, 0);
1491 evas_object_resize(img, ww, hh); 1491 evas_object_resize(img, ww, hh);
1492 } 1492 }
1493 1493
1494 ethumb_calculate_fill(e, w, h, &fx, &fy, &fw, &fh); 1494 ethumb_calculate_fill(e, w, h, &fx, &fy, &fw, &fh);
@@ -1545,8 +1545,8 @@ ethumb_generate(Ethumb *e, Ethumb_Generate_Cb finished_cb, const void *data, Ein
1545 1545
1546 if (e->finished_idler) 1546 if (e->finished_idler)
1547 { 1547 {
1548 ERR("thumbnail generation already in progress."); 1548 ERR("thumbnail generation already in progress.");
1549 return EINA_FALSE; 1549 return EINA_FALSE;
1550 } 1550 }
1551 if (e->pdata) 1551 if (e->pdata)
1552 { 1552 {
@@ -1561,9 +1561,9 @@ ethumb_generate(Ethumb *e, Ethumb_Generate_Cb finished_cb, const void *data, Ein
1561 1561
1562 if (!e->src_path) 1562 if (!e->src_path)
1563 { 1563 {
1564 ERR("no file set."); 1564 ERR("no file set.");
1565 ethumb_finished_callback_call(e, 0); 1565 ethumb_finished_callback_call(e, 0);
1566 return EINA_FALSE; 1566 return EINA_FALSE;
1567 } 1567 }
1568 1568
1569 r = _ethumb_plugin_generate(e); 1569 r = _ethumb_plugin_generate(e);
@@ -1575,9 +1575,9 @@ ethumb_generate(Ethumb *e, Ethumb_Generate_Cb finished_cb, const void *data, Ein
1575 1575
1576 if (!_ethumb_image_load(e)) 1576 if (!_ethumb_image_load(e))
1577 { 1577 {
1578 ERR("could not load input image."); 1578 ERR("could not load input image.");
1579 ethumb_finished_callback_call(e, 0); 1579 ethumb_finished_callback_call(e, 0);
1580 return EINA_FALSE; 1580 return EINA_FALSE;
1581 } 1581 }
1582 1582
1583 r = ethumb_image_save(e); 1583 r = ethumb_image_save(e);