summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2016-05-28 13:04:10 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2016-05-28 13:04:10 -0400
commit5604b52a2d74263a308d09254b07ba705f24dc64 (patch)
tree91fc339cdfa00d61070bd0a41f585db5f609f8e7 /src
parentd2ce216f6d8b1d204750f506498a0144077d7ad8 (diff)
update google image fetcher to new google json code
Diffstat (limited to 'src')
-rw-r--r--src/modules/google_image.c71
1 files changed, 43 insertions, 28 deletions
diff --git a/src/modules/google_image.c b/src/modules/google_image.c
index 64b7b2a..092215c 100644
--- a/src/modules/google_image.c
+++ b/src/modules/google_image.c
@@ -43,41 +43,56 @@ gend(GImage_Data *gi, Ecore_Thread *eth EINA_UNUSED)
43static void 43static void
44gparse(GImage_Data *gi, Ecore_Thread *eth) 44gparse(GImage_Data *gi, Ecore_Thread *eth)
45{ 45{
46 const char *s, *e, *pct, *p = eina_strbuf_string_get(gi->data); 46 const char *s, *e, *p = eina_strbuf_string_get(gi->data);
47 unsigned int count = 0; 47 unsigned int count = 0;
48#define MARKER_ONE "\"ou\":\""
48 49
49 do { 50 do {
50 const char *use = NULL; 51 char *use, *enc;
51 s = strstr(p, "imgurl="); 52
53 s = strstr(p, MARKER_ONE);
52 if (!s) break; 54 if (!s) break;
53 s += sizeof("imgurl=") - 1; 55 s += sizeof(MARKER_ONE) - 1;
54 if (!memcmp(s, "&amp;", sizeof("&amp;") - 1)) 56 e = strchr(s, '"');
57 if (!e) break;
58 enc = memchr(s, '\\', e - s);
59 if (enc)
55 { 60 {
61 Eina_Strbuf *sbuf = eina_strbuf_new();
56 p = s; 62 p = s;
57 continue; 63
64 /* encoded ascii */
65 while (enc)
66 {
67 int c;
68 char buf[5] = {0};
69
70 eina_strbuf_append_length(sbuf, p, enc - p);
71 if ((!p[1]) || (!p[2]))
72 {
73 E_FREE_FUNC(sbuf, eina_strbuf_free);
74 break;
75 }
76 p = enc += 2;
77 strncpy(buf, enc, 4);
78 c = strtol(buf, NULL, 16);
79 if (c < 0)
80 {
81 E_FREE_FUNC(sbuf, eina_strbuf_free);
82 break;
83 }
84 p = enc += 4;
85 eina_strbuf_append_char(sbuf, c);
86 enc = memchr(enc, '\\', e - p);
87 }
88 eina_strbuf_append_length(sbuf, p, e - p);
89 use = eina_strbuf_string_steal(sbuf);
90 eina_strbuf_free(sbuf);
58 } 91 }
59 e = strstr(s, "&amp;"); 92 else
60 pct = s; 93 use = (char*)eina_memdup((void*)s, e - s, 1);
61 do 94
62 { 95 ecore_thread_feedback(eth, use);
63 const char *dot;
64
65 pct = memchr(pct + 1, '%', e - pct - 1);
66 if (!pct) break;
67 for (dot = pct; (dot != s) && (pct - dot < 6); dot--)
68 if (dot[0] == '.')
69 {
70 char buf[128] = {0};
71
72 memcpy(buf, dot, pct - dot);
73 if (evas_object_image_extension_can_load_get(buf))
74 use = pct;
75 break;
76 }
77 } while (!use);
78 if (!use)
79 use = e;
80 ecore_thread_feedback(eth, strndup(s, use - s));
81 count++; 96 count++;
82 if (count > 10) break; 97 if (count > 10) break;
83 p = e; 98 p = e;