summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzmike <michael.blumenkrantz@gmail.com>2014-02-05 22:51:50 -0500
committerzmike <michael.blumenkrantz@gmail.com>2014-02-05 22:51:50 -0500
commitc6c2527458980211cded80ef3fa18aabf7afead2 (patch)
tree09c9b4ba8f37e7cefffe82a3d94263b3b87d6a01
parent989033c9a55ca0735a492a9a15bdba3d284a40e7 (diff)
fix
-rw-r--r--excetra.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/excetra.c b/excetra.c
index 8842739..9f5eec8 100644
--- a/excetra.c
+++ b/excetra.c
@@ -76,46 +76,50 @@ lyricwiki_parse_lyric(Eina_Strbuf *buf)
76 lyric_start += sizeof("</div>") - 1; 76 lyric_start += sizeof("</div>") - 1;
77 lyric_end = strstr(lyric_start, "<!--"); 77 lyric_end = strstr(lyric_start, "<!--");
78 if (!lyric_end) goto error; 78 if (!lyric_end) goto error;
79 *lyric_end = 0; 79 lyric_end[0] = 0;
80 while (lyric_end[-1] == '\n')
81 {
82 lyric_end[-1] = 0;
83 lyric_end--;
84 }
80 return evas_textblock_text_markup_to_utf8(NULL, lyric_start); 85 return evas_textblock_text_markup_to_utf8(NULL, lyric_start);
81error: 86error:
82 ERR("Parsing error!"); 87 ERR("Parsing error!");
83 return NULL; 88 return NULL;
84} 89}
85 90
86#if 0
87static void 91static void
88lyricwiki_parse_stub(Eina_Strbuf *buf) 92lyricwiki_parse_stub(Excetra_Req *req)
89{ 93{
90 size_t size; 94 size_t size;
91 Azy_Net *net; 95 Azy_Net *net;
92 Azy_Content *content; 96 Azy_Content *content;
93 Lyricwiki_Lyric *lwl; 97 Lyricwiki_Lyric *lwl;
94 size = eina_strbuf_length_get(buf); 98
95 DBG("\n%s", eina_strbuf_string_get(buf)); 99 size = eina_strbuf_length_get(req->buf);
100 DBG("\n%s", eina_strbuf_string_get(req->buf));
96 if (!size) 101 if (!size)
97 { 102 {
98 ERR("size is 0!"); 103 ERR("size is 0!");
99 return; 104 return;
100 } 105 }
101 net = azy_net_buffer_new(eina_strbuf_string_steal(buf), size, AZY_NET_TRANSPORT_JSON, EINA_TRUE); 106 net = azy_net_buffer_new(eina_strbuf_string_steal(req->buf), size, AZY_NET_TRANSPORT_JSON, EINA_TRUE);
102 content = azy_content_new(NULL); 107 content = azy_content_new(NULL);
103 azy_content_deserialize(content, net); 108 azy_content_deserialize(content, net);
104 if (azy_value_to_Lyricwiki_Lyric(azy_content_retval_get(content), &lwl)) 109 if (azy_value_to_Lyricwiki_Lyric(azy_content_retval_get(content), &lwl))
105 { 110 {
106 Ecore_Con_Url *url;
107 INF("STUB:"); 111 INF("STUB:");
108 Lyricwiki_Lyric_print(NULL, 0, lwl); 112 Lyricwiki_Lyric_print(NULL, 0, lwl);
109 url = ecore_con_url_new(lwl->url); 113 ecore_con_url_free(req->url);
110 ecore_con_url_data_set(url, eina_strbuf_new()); 114 req->url = ecore_con_url_new(lwl->url);
111 ecore_con_url_get(url); 115 ecore_con_url_data_set(req->url, req);
116 ecore_con_url_get(req->url);
112 } 117 }
113 118
114 Lyricwiki_Lyric_free(lwl); 119 Lyricwiki_Lyric_free(lwl);
115 azy_net_free(net); 120 azy_net_free(net);
116 azy_content_free(content); 121 azy_content_free(content);
117} 122}
118#endif
119 123
120static Eina_Bool 124static Eina_Bool
121lyricwiki_complete(void *d EINA_UNUSED, int type EINA_UNUSED, Ecore_Con_Event_Url_Complete *ev) 125lyricwiki_complete(void *d EINA_UNUSED, int type EINA_UNUSED, Ecore_Con_Event_Url_Complete *ev)
@@ -153,13 +157,15 @@ lyricwiki_complete(void *d EINA_UNUSED, int type EINA_UNUSED, Ecore_Con_Event_Ur
153 excetra_req_free(req); 157 excetra_req_free(req);
154 return ECORE_CALLBACK_DONE; 158 return ECORE_CALLBACK_DONE;
155 } 159 }
156 if (!stub) 160 if (stub)
157 lyric = lyricwiki_parse_lyric(req->buf); 161 lyricwiki_parse_stub(req);
158 //else 162 else
159 //lyricwiki_parse_stub(req->buf); 163 {
160 req->cb(req->data, lyric); 164 lyric = lyricwiki_parse_lyric(req->buf);
161 free(lyric); 165 req->cb(req->data, lyric);
162 excetra_req_free(req); 166 free(lyric);
167 excetra_req_free(req);
168 }
163 return ECORE_CALLBACK_DONE; 169 return ECORE_CALLBACK_DONE;
164} 170}
165 171