summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2016-08-06 23:10:27 +0100
committerAndy Williams <andy@andywilliams.me>2016-08-06 23:10:27 +0100
commit6e58ecff42ecbd010f1ec34e84fa4cf91e628016 (patch)
tree497d80b804bf7d74bf6f02d78265d7b282a1ae5f
parentd713a8c51bc718f85f6330e42fe07a0d4af433e6 (diff)
Request and parse CSV format for theme list
-rw-r--r--src/lib/extra.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/lib/extra.c b/src/lib/extra.c
index f6afd2c..504f75d 100644
--- a/src/lib/extra.c
+++ b/src/lib/extra.c
@@ -61,10 +61,33 @@ static Eina_Bool
61_url_data_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event_info) 61_url_data_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event_info)
62{ 62{
63 Ecore_Con_Event_Url_Data *url_data = event_info; 63 Ecore_Con_Event_Url_Data *url_data = event_info;
64 int i; 64 char buf[1024];
65 int i, p = 0;
65 66
66 for (i = 0; i < url_data->size; i++) 67 for (i = 0; i < url_data->size; i++)
67 printf("%c", url_data->data[i]); 68 {
69 if (url_data->data[i] == '\r' || url_data->data[i] == '\n')
70 {
71 if (p == 0)
72 continue;
73
74 buf[p] = '\0';
75 if (buf[0] == '"')
76 {
77 buf[p-1] = '\0';
78 printf("THEME %s\n", buf+1);
79 }
80 else
81 printf("THEME %s\n", buf);
82
83 p = 0;
84 }
85 else
86 {
87 buf[p] = url_data->data[i];
88 p++;
89 }
90 }
68 91
69 return EINA_TRUE; 92 return EINA_TRUE;
70} 93}
@@ -84,6 +107,7 @@ extra_library_call(void)
84 Ecore_Con_Url *url; 107 Ecore_Con_Url *url;
85 108
86 url = ecore_con_url_custom_new("http://ajwilliams.pythonanywhere.com/v1/themes/", "GET"); 109 url = ecore_con_url_custom_new("http://ajwilliams.pythonanywhere.com/v1/themes/", "GET");
110 ecore_con_url_additional_header_add(url, "Accept", "text/csv");
87 111
88 ecore_event_handler_add(ECORE_CON_EVENT_URL_DATA, _url_data_cb, NULL); 112 ecore_event_handler_add(ECORE_CON_EVENT_URL_DATA, _url_data_cb, NULL);
89 ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _url_complete_cb, url); 113 ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _url_complete_cb, url);