2016-05-03 15:23:36 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "extra.h"
|
|
|
|
|
|
|
|
#include "extra_private.h"
|
|
|
|
|
|
|
|
static int _extra_init = 0;
|
|
|
|
int _extra_lib_log_dom = -1;
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
extra_init(void)
|
|
|
|
{
|
|
|
|
_extra_init++;
|
|
|
|
if (_extra_init > 1) return _extra_init;
|
|
|
|
|
|
|
|
eina_init();
|
|
|
|
|
|
|
|
_extra_lib_log_dom = eina_log_domain_register("extra", EINA_COLOR_CYAN);
|
|
|
|
if (_extra_lib_log_dom < 0)
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("extra can not create its log domain.");
|
|
|
|
goto shutdown_eina;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Put here your initialization logic of your library
|
|
|
|
|
|
|
|
eina_log_timing(_extra_lib_log_dom, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT);
|
|
|
|
|
|
|
|
return _extra_init;
|
|
|
|
|
|
|
|
shutdown_eina:
|
|
|
|
eina_shutdown();
|
|
|
|
_extra_init--;
|
|
|
|
|
|
|
|
return _extra_init;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
extra_shutdown(void)
|
|
|
|
{
|
|
|
|
_extra_init--;
|
|
|
|
if (_extra_init != 0) return _extra_init;
|
|
|
|
|
|
|
|
eina_log_timing(_extra_lib_log_dom,
|
|
|
|
EINA_LOG_STATE_START,
|
|
|
|
EINA_LOG_STATE_SHUTDOWN);
|
|
|
|
|
|
|
|
// Put here your shutdown logic
|
|
|
|
|
|
|
|
eina_log_domain_unregister(_extra_lib_log_dom);
|
|
|
|
_extra_lib_log_dom = -1;
|
|
|
|
|
|
|
|
eina_shutdown();
|
|
|
|
|
|
|
|
return _extra_init;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_url_data_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event_info)
|
|
|
|
{
|
|
|
|
Ecore_Con_Event_Url_Data *url_data = event_info;
|
2016-08-06 15:10:27 -07:00
|
|
|
char buf[1024];
|
|
|
|
int i, p = 0;
|
2016-05-03 15:23:36 -07:00
|
|
|
|
|
|
|
for (i = 0; i < url_data->size; i++)
|
2016-08-06 15:10:27 -07:00
|
|
|
{
|
|
|
|
if (url_data->data[i] == '\r' || url_data->data[i] == '\n')
|
|
|
|
{
|
|
|
|
if (p == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
buf[p] = '\0';
|
|
|
|
if (buf[0] == '"')
|
|
|
|
{
|
|
|
|
buf[p-1] = '\0';
|
|
|
|
printf("THEME %s\n", buf+1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf("THEME %s\n", buf);
|
|
|
|
|
|
|
|
p = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buf[p] = url_data->data[i];
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
2016-05-03 15:23:36 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_url_complete_cb(void *data, int type EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ecore_Con_Url *url = data;
|
|
|
|
|
|
|
|
ecore_con_url_free(url);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
extra_library_call(void)
|
|
|
|
{
|
|
|
|
Ecore_Con_Url *url;
|
|
|
|
|
|
|
|
url = ecore_con_url_custom_new("http://ajwilliams.pythonanywhere.com/v1/themes/", "GET");
|
2016-08-06 15:10:27 -07:00
|
|
|
ecore_con_url_additional_header_add(url, "Accept", "text/csv");
|
2016-05-03 15:23:36 -07:00
|
|
|
|
|
|
|
ecore_event_handler_add(ECORE_CON_EVENT_URL_DATA, _url_data_cb, NULL);
|
|
|
|
ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _url_complete_cb, url);
|
|
|
|
|
|
|
|
ecore_con_url_get(url);
|
|
|
|
}
|