extra/src/lib/extra.c

93 lines
1.8 KiB
C

#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;
int i;
for (i = 0; i < url_data->size; i++)
printf("%c", url_data->data[i]);
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");
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);
}