use ecore_on url - nuke warnings and use mouse up for popup
This commit is contained in:
parent
d91f0a6c0f
commit
d1486a92a0
|
@ -77,7 +77,7 @@ _create_data(E_Config_Dialog *cfd)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
_free_data(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata)
|
||||||
{
|
{
|
||||||
if (!forecasts_config)
|
if (!forecasts_config)
|
||||||
return;
|
return;
|
||||||
|
@ -102,7 +102,7 @@ _poll_time_slider_changed_cb(void *data, Evas_Object *obj,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_radio_changed_cb(void *data, Evas_Object *obj,
|
_radio_changed_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||||
void *event_info EINA_UNUSED)
|
void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
E_Config_Dialog *cfd = data;
|
E_Config_Dialog *cfd = data;
|
||||||
|
@ -123,7 +123,7 @@ _text_location_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_item_location_del(void *data, Evas_Object *obj)
|
_item_location_del(void *data, Evas_Object *obj EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Places_Location *location = data;
|
Places_Location *location = data;
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ _item_location_del(void *data, Evas_Object *obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_locations_selected_cb(void *data, Evas_Object *obj,
|
_locations_selected_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||||
void *event_info EINA_UNUSED)
|
void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
E_Config_Dialog_Data *cfdata;
|
E_Config_Dialog_Data *cfdata;
|
||||||
|
@ -186,8 +186,8 @@ _locations_fill(E_Config_Dialog_Data *cfdata)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_categories_selected_cb(void *data, Evas_Object *obj,
|
_categories_selected_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||||
void *event_info EINA_UNUSED)
|
void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
E_Config_Dialog_Data *cfdata;
|
E_Config_Dialog_Data *cfdata;
|
||||||
Elm_Object_Item *it;
|
Elm_Object_Item *it;
|
||||||
|
@ -206,7 +206,7 @@ _categories_selected_cb(void *data, Evas_Object *obj,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_item_location_id_del(void *data, Evas_Object *obj)
|
_item_location_id_del(void *data, Evas_Object *obj EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Places_Category *category = data;
|
Places_Category *category = data;
|
||||||
free(category);
|
free(category);
|
||||||
|
|
279
src/e_mod_main.c
279
src/e_mod_main.c
|
@ -2,8 +2,7 @@
|
||||||
#include "e_mod_main.h"
|
#include "e_mod_main.h"
|
||||||
#include <json-c/json.h>
|
#include <json-c/json.h>
|
||||||
|
|
||||||
#define _XOPEN_SOURCE
|
char *strptime(const char *s, const char *format, struct tm *tm);
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#define FORECASTS 2
|
#define FORECASTS 2
|
||||||
#define KM_TO_MI 1.609344
|
#define KM_TO_MI 1.609344
|
||||||
|
@ -42,10 +41,9 @@ struct _Instance
|
||||||
Evas_Object *forecasts_obj;
|
Evas_Object *forecasts_obj;
|
||||||
Forecasts *forecasts;
|
Forecasts *forecasts;
|
||||||
Ecore_Timer *check_timer;
|
Ecore_Timer *check_timer;
|
||||||
Ecore_Con_Server *server;
|
Ecore_Con_Url *url;
|
||||||
Ecore_Event_Handler *add_handler;
|
Ecore_Event_Handler *url_data_handler;
|
||||||
Ecore_Event_Handler *del_handler;
|
Ecore_Event_Handler *url_complete_handler;
|
||||||
Ecore_Event_Handler *data_handler;
|
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
@ -99,17 +97,9 @@ struct _Forecasts
|
||||||
Evas_Object *icon_obj;
|
Evas_Object *icon_obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
const char *host;
|
|
||||||
int port;
|
|
||||||
} proxy = {
|
|
||||||
NULL, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Module Function Protos */
|
/* Module Function Protos */
|
||||||
static void _forecasts_cb_mouse_down(void *data, Evas *e, Evas_Object *obj,
|
static void _forecasts_cb_mouse_up(void *data, Evas *e, Evas_Object *obj,
|
||||||
void *event_info);
|
void *event_info);
|
||||||
static void _forecasts_menu_cb_configure(void *data, E_Menu *m,
|
static void _forecasts_menu_cb_configure(void *data, E_Menu *m,
|
||||||
E_Menu_Item *mi);
|
E_Menu_Item *mi);
|
||||||
static void _forecasts_menu_cb_post(void *data, E_Menu *m);
|
static void _forecasts_menu_cb_post(void *data, E_Menu *m);
|
||||||
|
@ -117,10 +107,8 @@ static Eina_Bool _forecasts_cb_check(void *data);
|
||||||
static Config_Item *_forecasts_config_item_get(const char *id);
|
static Config_Item *_forecasts_config_item_get(const char *id);
|
||||||
static Forecasts *_forecasts_new(Evas *evas);
|
static Forecasts *_forecasts_new(Evas *evas);
|
||||||
static void _forecasts_free(Forecasts *w);
|
static void _forecasts_free(Forecasts *w);
|
||||||
static void _forecasts_get_proxy(void);
|
static Eina_Bool _forecasts_url_data(void *data, int type, void *event);
|
||||||
static Eina_Bool _forecasts_server_add(void *data, int type, void *event);
|
static Eina_Bool _forecasts_url_complete(void *data, int type, void *event);
|
||||||
static Eina_Bool _forecasts_server_del(void *data, int type, void *event);
|
|
||||||
static Eina_Bool _forecasts_server_data(void *data, int type, void *event);
|
|
||||||
static int _forecasts_parse(void *data);
|
static int _forecasts_parse(void *data);
|
||||||
static void _forecasts_converter(Instance *inst);
|
static void _forecasts_converter(Instance *inst);
|
||||||
static void _forecasts_convert_degrees(int *value, int dir);
|
static void _forecasts_convert_degrees(int *value, int dir);
|
||||||
|
@ -128,7 +116,7 @@ static void _forecasts_convert_distances(int *value, int dir);
|
||||||
static void _forecasts_convert_pressures(float *value, int dir);
|
static void _forecasts_convert_pressures(float *value, int dir);
|
||||||
static void _forecasts_display_set(Instance *inst, int ok);
|
static void _forecasts_display_set(Instance *inst, int ok);
|
||||||
static void _forecasts_popup_content_create(Instance *inst);
|
static void _forecasts_popup_content_create(Instance *inst);
|
||||||
static void _cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
static void _cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||||
static void _cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
static void _cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||||
static void _cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
static void _cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||||
static Evas_Object *_forecasts_popup_icon_create(Evas *evas, const char *code);
|
static Evas_Object *_forecasts_popup_icon_create(Evas *evas, const char *code);
|
||||||
|
@ -159,28 +147,24 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
||||||
inst->gcc = gcc;
|
inst->gcc = gcc;
|
||||||
inst->popup = NULL;
|
inst->popup = NULL;
|
||||||
inst->forecasts_obj = o;
|
inst->forecasts_obj = o;
|
||||||
evas_object_event_callback_add(inst->forecasts_obj, EVAS_CALLBACK_MOUSE_DOWN,
|
evas_object_event_callback_add(inst->forecasts_obj, EVAS_CALLBACK_MOUSE_UP,
|
||||||
_cb_mouse_down, inst);
|
_cb_mouse_up, inst);
|
||||||
evas_object_event_callback_add(inst->forecasts_obj, EVAS_CALLBACK_MOUSE_IN,
|
evas_object_event_callback_add(inst->forecasts_obj, EVAS_CALLBACK_MOUSE_IN,
|
||||||
_cb_mouse_in, inst);
|
_cb_mouse_in, inst);
|
||||||
evas_object_event_callback_add(inst->forecasts_obj, EVAS_CALLBACK_MOUSE_OUT,
|
evas_object_event_callback_add(inst->forecasts_obj, EVAS_CALLBACK_MOUSE_OUT,
|
||||||
_cb_mouse_out, inst);
|
_cb_mouse_out, inst);
|
||||||
|
|
||||||
if (!inst->add_handler)
|
if (!inst->url_data_handler)
|
||||||
inst->add_handler =
|
inst->url_data_handler =
|
||||||
ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD,
|
ecore_event_handler_add(ECORE_CON_EVENT_URL_DATA,
|
||||||
_forecasts_server_add, inst);
|
_forecasts_url_data, inst);
|
||||||
if (!inst->del_handler)
|
if (!inst->url_complete_handler)
|
||||||
inst->del_handler =
|
inst->url_complete_handler =
|
||||||
ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL,
|
ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE,
|
||||||
_forecasts_server_del, inst);
|
_forecasts_url_complete, inst);
|
||||||
if (!inst->data_handler)
|
|
||||||
inst->data_handler =
|
|
||||||
ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA,
|
|
||||||
_forecasts_server_data, inst);
|
|
||||||
|
|
||||||
evas_object_event_callback_add(w->forecasts_obj, EVAS_CALLBACK_MOUSE_DOWN,
|
evas_object_event_callback_add(w->forecasts_obj, EVAS_CALLBACK_MOUSE_UP,
|
||||||
_forecasts_cb_mouse_down, inst);
|
_forecasts_cb_mouse_up, inst);
|
||||||
forecasts_config->instances =
|
forecasts_config->instances =
|
||||||
eina_list_append(forecasts_config->instances, inst);
|
eina_list_append(forecasts_config->instances, inst);
|
||||||
|
|
||||||
|
@ -202,24 +186,22 @@ _gc_shutdown(E_Gadcon_Client *gcc)
|
||||||
if (inst->popup) _forecasts_popup_destroy(inst);
|
if (inst->popup) _forecasts_popup_destroy(inst);
|
||||||
if (inst->check_timer)
|
if (inst->check_timer)
|
||||||
ecore_timer_del(inst->check_timer);
|
ecore_timer_del(inst->check_timer);
|
||||||
if (inst->add_handler)
|
if (inst->url_data_handler)
|
||||||
ecore_event_handler_del(inst->add_handler);
|
ecore_event_handler_del(inst->url_data_handler);
|
||||||
if (inst->data_handler)
|
if (inst->url_complete_handler)
|
||||||
ecore_event_handler_del(inst->data_handler);
|
ecore_event_handler_del(inst->url_complete_handler);
|
||||||
if (inst->del_handler)
|
if (inst->url)
|
||||||
ecore_event_handler_del(inst->del_handler);
|
ecore_con_url_free(inst->url);
|
||||||
if (inst->server)
|
|
||||||
ecore_con_server_del(inst->server);
|
|
||||||
if (inst->area)
|
if (inst->area)
|
||||||
eina_stringshare_del(inst->area);
|
eina_stringshare_del(inst->area);
|
||||||
eina_strbuf_free(inst->buffer);
|
eina_strbuf_free(inst->buffer);
|
||||||
|
|
||||||
inst->server = NULL;
|
inst->url = NULL;
|
||||||
forecasts_config->instances =
|
forecasts_config->instances =
|
||||||
eina_list_remove(forecasts_config->instances, inst);
|
eina_list_remove(forecasts_config->instances, inst);
|
||||||
|
|
||||||
evas_object_event_callback_del(w->forecasts_obj, EVAS_CALLBACK_MOUSE_DOWN,
|
evas_object_event_callback_del(w->forecasts_obj, EVAS_CALLBACK_MOUSE_UP,
|
||||||
_forecasts_cb_mouse_down);
|
_forecasts_cb_mouse_up);
|
||||||
|
|
||||||
_forecasts_free(w);
|
_forecasts_free(w);
|
||||||
E_FREE(inst);
|
E_FREE(inst);
|
||||||
|
@ -249,13 +231,13 @@ _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
_gc_label(const E_Gadcon_Client_Class *client_class)
|
_gc_label(const E_Gadcon_Client_Class *client_class EINA_UNUSED)
|
||||||
{
|
{
|
||||||
return D_("Forecasts");
|
return D_("Forecasts");
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas)
|
_gc_icon(const E_Gadcon_Client_Class *client_class EINA_UNUSED, Evas *evas)
|
||||||
{
|
{
|
||||||
Evas_Object *o;
|
Evas_Object *o;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
|
@ -268,7 +250,7 @@ _gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
_gc_id_new(const E_Gadcon_Client_Class *client_class)
|
_gc_id_new(const E_Gadcon_Client_Class *client_class EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Config_Item *ci;
|
Config_Item *ci;
|
||||||
|
|
||||||
|
@ -277,14 +259,14 @@ _gc_id_new(const E_Gadcon_Client_Class *client_class)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_forecasts_cb_mouse_down(void *data, Evas *e, Evas_Object *obj,
|
_forecasts_cb_mouse_up(void *data, Evas *e EINA_UNUSED,
|
||||||
void *event_info)
|
Evas_Object *obj EINA_UNUSED,
|
||||||
|
void *event_info)
|
||||||
{
|
{
|
||||||
Instance *inst;
|
Instance *inst = data;
|
||||||
Evas_Event_Mouse_Down *ev;
|
Evas_Event_Mouse_Up *ev = event_info;
|
||||||
|
|
||||||
inst = data;
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
||||||
ev = event_info;
|
|
||||||
if ((ev->button == 3) && (!forecasts_config->menu))
|
if ((ev->button == 3) && (!forecasts_config->menu))
|
||||||
{
|
{
|
||||||
E_Menu *m;
|
E_Menu *m;
|
||||||
|
@ -312,7 +294,7 @@ _forecasts_cb_mouse_down(void *data, Evas *e, Evas_Object *obj,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_forecasts_menu_cb_post(void *data, E_Menu *m)
|
_forecasts_menu_cb_post(void *data EINA_UNUSED, E_Menu *m EINA_UNUSED)
|
||||||
{
|
{
|
||||||
if (!forecasts_config->menu)
|
if (!forecasts_config->menu)
|
||||||
return;
|
return;
|
||||||
|
@ -321,7 +303,7 @@ _forecasts_menu_cb_post(void *data, E_Menu *m)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_forecasts_menu_cb_configure(void *data, E_Menu *m, E_Menu_Item *mi)
|
_forecasts_menu_cb_configure(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Instance *inst;
|
Instance *inst;
|
||||||
|
|
||||||
|
@ -367,7 +349,6 @@ _forecasts_config_item_get(const char *id)
|
||||||
ci->id = eina_stringshare_add(id);
|
ci->id = eina_stringshare_add(id);
|
||||||
ci->poll_time = 60.0;
|
ci->poll_time = 60.0;
|
||||||
ci->degrees = DEGREES_C;
|
ci->degrees = DEGREES_C;
|
||||||
ci->host = eina_stringshare_add("www.enlightenment.org");
|
|
||||||
ci->lat = ci->lon = 0;
|
ci->lat = ci->lon = 0;
|
||||||
ci->show_text = 1;
|
ci->show_text = 1;
|
||||||
ci->popup_on_hover = 1;
|
ci->popup_on_hover = 1;
|
||||||
|
@ -385,6 +366,7 @@ E_API E_Module_Api e_modapi = {
|
||||||
E_API void *
|
E_API void *
|
||||||
e_modapi_init(E_Module *m)
|
e_modapi_init(E_Module *m)
|
||||||
{
|
{
|
||||||
|
ecore_con_url_init();
|
||||||
bindtextdomain(PACKAGE, LOCALE_DIR);
|
bindtextdomain(PACKAGE, LOCALE_DIR);
|
||||||
bind_textdomain_codeset(PACKAGE, "UTF-8");
|
bind_textdomain_codeset(PACKAGE, "UTF-8");
|
||||||
|
|
||||||
|
@ -396,7 +378,6 @@ e_modapi_init(E_Module *m)
|
||||||
E_CONFIG_VAL(D, T, id, STR);
|
E_CONFIG_VAL(D, T, id, STR);
|
||||||
E_CONFIG_VAL(D, T, poll_time, DOUBLE);
|
E_CONFIG_VAL(D, T, poll_time, DOUBLE);
|
||||||
E_CONFIG_VAL(D, T, degrees, INT);
|
E_CONFIG_VAL(D, T, degrees, INT);
|
||||||
E_CONFIG_VAL(D, T, host, STR);
|
|
||||||
E_CONFIG_VAL(D, T, show_text, INT);
|
E_CONFIG_VAL(D, T, show_text, INT);
|
||||||
E_CONFIG_VAL(D, T, popup_on_hover, INT);
|
E_CONFIG_VAL(D, T, popup_on_hover, INT);
|
||||||
E_CONFIG_VAL(D, T, location_id, INT);
|
E_CONFIG_VAL(D, T, location_id, INT);
|
||||||
|
@ -421,7 +402,6 @@ e_modapi_init(E_Module *m)
|
||||||
ci = E_NEW(Config_Item, 1);
|
ci = E_NEW(Config_Item, 1);
|
||||||
ci->poll_time = 60.0;
|
ci->poll_time = 60.0;
|
||||||
ci->degrees = DEGREES_C;
|
ci->degrees = DEGREES_C;
|
||||||
ci->host = eina_stringshare_add("www.enlightenment.org");
|
|
||||||
ci->lat = ci->lon = 0;
|
ci->lat = ci->lon = 0;
|
||||||
ci->id = eina_stringshare_add("0");
|
ci->id = eina_stringshare_add("0");
|
||||||
ci->show_text = 1;
|
ci->show_text = 1;
|
||||||
|
@ -429,7 +409,6 @@ e_modapi_init(E_Module *m)
|
||||||
|
|
||||||
forecasts_config->items = eina_list_append(forecasts_config->items, ci);
|
forecasts_config->items = eina_list_append(forecasts_config->items, ci);
|
||||||
}
|
}
|
||||||
_forecasts_get_proxy();
|
|
||||||
|
|
||||||
forecasts_config->module = m;
|
forecasts_config->module = m;
|
||||||
e_gadcon_provider_register(&_gadcon_class);
|
e_gadcon_provider_register(&_gadcon_class);
|
||||||
|
@ -437,7 +416,7 @@ e_modapi_init(E_Module *m)
|
||||||
}
|
}
|
||||||
|
|
||||||
E_API int
|
E_API int
|
||||||
e_modapi_shutdown(E_Module *m)
|
e_modapi_shutdown(E_Module *m EINA_UNUSED)
|
||||||
{
|
{
|
||||||
forecasts_config->module = NULL;
|
forecasts_config->module = NULL;
|
||||||
e_gadcon_provider_unregister(&_gadcon_class);
|
e_gadcon_provider_unregister(&_gadcon_class);
|
||||||
|
@ -458,8 +437,6 @@ e_modapi_shutdown(E_Module *m)
|
||||||
ci = forecasts_config->items->data;
|
ci = forecasts_config->items->data;
|
||||||
if (ci->id)
|
if (ci->id)
|
||||||
eina_stringshare_del(ci->id);
|
eina_stringshare_del(ci->id);
|
||||||
if (ci->host)
|
|
||||||
eina_stringshare_del(ci->host);
|
|
||||||
if (ci->location)
|
if (ci->location)
|
||||||
eina_stringshare_del(ci->location);
|
eina_stringshare_del(ci->location);
|
||||||
|
|
||||||
|
@ -472,11 +449,12 @@ e_modapi_shutdown(E_Module *m)
|
||||||
E_FREE(forecasts_config);
|
E_FREE(forecasts_config);
|
||||||
E_CONFIG_DD_FREE(conf_item_edd);
|
E_CONFIG_DD_FREE(conf_item_edd);
|
||||||
E_CONFIG_DD_FREE(conf_edd);
|
E_CONFIG_DD_FREE(conf_edd);
|
||||||
|
ecore_con_url_shutdown();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
E_API int
|
E_API int
|
||||||
e_modapi_save(E_Module *m)
|
e_modapi_save(E_Module *m EINA_UNUSED)
|
||||||
{
|
{
|
||||||
e_config_domain_save("module.forecasts", conf_edd, forecasts_config);
|
e_config_domain_save("module.forecasts", conf_edd, forecasts_config);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -529,101 +507,47 @@ _forecasts_free(Forecasts *w)
|
||||||
w = NULL;
|
w = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_forecasts_get_proxy(void)
|
|
||||||
{
|
|
||||||
const char *env;
|
|
||||||
const char *host = NULL;
|
|
||||||
const char *p;
|
|
||||||
int port = 0;
|
|
||||||
|
|
||||||
env = getenv("http_proxy");
|
|
||||||
if ((!env) || (!*env)) env = getenv("HTTP_PROXY");
|
|
||||||
if ((!env) || (!*env)) return;
|
|
||||||
if (strncmp(env, "http://", 7)) return;
|
|
||||||
|
|
||||||
host = strchr(env, ':');
|
|
||||||
host += 3;
|
|
||||||
p = strchr(host, ':');
|
|
||||||
if (p)
|
|
||||||
{
|
|
||||||
if (sscanf(p + 1, "%d", &port) != 1)
|
|
||||||
port = 0;
|
|
||||||
}
|
|
||||||
if ((host) && (port))
|
|
||||||
{
|
|
||||||
if (proxy.host) eina_stringshare_del(proxy.host);
|
|
||||||
proxy.host = eina_stringshare_add_length(host, p - host);
|
|
||||||
proxy.port = port;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_forecasts_cb_check(void *data)
|
_forecasts_cb_check(void *data)
|
||||||
{
|
{
|
||||||
Instance *inst;
|
Instance *inst = data;
|
||||||
|
char buf[256];
|
||||||
/* check that data is valid */
|
|
||||||
if (!(inst = data)) return EINA_FALSE;
|
|
||||||
|
|
||||||
/* if we have a previous server, delete it */
|
/* if we have a previous server, delete it */
|
||||||
if (inst->server) ecore_con_server_del(inst->server);
|
if (inst->url) ecore_con_url_free(inst->url);
|
||||||
|
snprintf(buf, sizeof(buf),
|
||||||
/* server deleted, set variable to NULL */
|
"https://www.enlightenment.org/weather.php?lat=%s&lon=%s",
|
||||||
inst->server = NULL;
|
inst->ci->lat, inst->ci->lon);
|
||||||
|
DEBUG("FC: URL: %s", buf);
|
||||||
if (proxy.port != 0)
|
inst->url = ecore_con_url_new(buf);
|
||||||
inst->server =
|
if (!inst->url) return EINA_FALSE;
|
||||||
ecore_con_server_connect(ECORE_CON_REMOTE_NODELAY,
|
ecore_con_url_http_version_set(inst->url, ECORE_CON_URL_HTTP_VERSION_1_0);
|
||||||
proxy.host, proxy.port, inst);
|
ecore_con_url_get(inst->url);
|
||||||
else
|
|
||||||
inst->server =
|
|
||||||
ecore_con_server_connect(ECORE_CON_REMOTE_NODELAY | ECORE_CON_USE_MIXED, inst->ci->host, 443, inst);
|
|
||||||
|
|
||||||
if (!inst->server) return EINA_FALSE;
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_forecasts_server_add(void *data, int type, void *event)
|
_forecasts_url_data(void *data, int type EINA_UNUSED, void *event)
|
||||||
{
|
{
|
||||||
Instance *inst;
|
Instance *inst = data;
|
||||||
Ecore_Con_Event_Server_Add *ev;
|
Ecore_Con_Event_Url_Data *ev = event;
|
||||||
char buf[1024];
|
|
||||||
char forecast[1024];
|
|
||||||
|
|
||||||
inst = data;
|
if ((!inst->url) || (inst->url != ev->url_con)) return EINA_TRUE;
|
||||||
if (!inst)
|
eina_strbuf_append_length(inst->buffer, (const char *)ev->data, ev->size);
|
||||||
return EINA_TRUE;
|
|
||||||
|
|
||||||
ev = event;
|
|
||||||
if ((!inst->server) || (inst->server != ev->server))
|
|
||||||
return EINA_TRUE;
|
|
||||||
|
|
||||||
snprintf(forecast, sizeof(forecast), "/weather.php?lat=%s&lon=%s", inst->ci->lat, inst->ci->lon);
|
|
||||||
snprintf(buf, sizeof(buf)-strlen(forecast)-(strlen(inst->ci->host)*2), "GET https://%s%s HTTP/1.1\r\n"
|
|
||||||
"Host: %s\r\n"
|
|
||||||
"Connection: close\r\n\r\n",
|
|
||||||
inst->ci->host, forecast, inst->ci->host);
|
|
||||||
DEBUG("Server: %s", buf);
|
|
||||||
ecore_con_server_send(inst->server, buf, strlen(buf));
|
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_forecasts_server_del(void *data, int type, void *event)
|
_forecasts_url_complete(void *data, int type EINA_UNUSED, void *event)
|
||||||
{
|
{
|
||||||
Instance *inst;
|
Instance *inst = data;
|
||||||
Ecore_Con_Event_Server_Del *ev;
|
Ecore_Con_Event_Url_Complete *ev = event;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
inst = data;
|
if ((!inst->url) || (inst->url != ev->url_con)) return EINA_TRUE;
|
||||||
ev = event;
|
DEBUG("FC: status: %i %s", ev->status, eina_strbuf_string_get(inst->buffer));
|
||||||
if ((!inst->server) || (inst->server != ev->server))
|
ecore_con_url_free(inst->url);
|
||||||
return EINA_TRUE;
|
inst->url = NULL;
|
||||||
|
|
||||||
ecore_con_server_del(inst->server);
|
|
||||||
inst->server = NULL;
|
|
||||||
|
|
||||||
eina_stringshare_replace(&inst->location, inst->ci->location);
|
eina_stringshare_replace(&inst->location, inst->ci->location);
|
||||||
ret = _forecasts_parse(inst);
|
ret = _forecasts_parse(inst);
|
||||||
|
@ -631,22 +555,6 @@ _forecasts_server_del(void *data, int type, void *event)
|
||||||
_forecasts_display_set(inst, ret);
|
_forecasts_display_set(inst, ret);
|
||||||
|
|
||||||
eina_strbuf_string_free(inst->buffer);
|
eina_strbuf_string_free(inst->buffer);
|
||||||
|
|
||||||
return EINA_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Eina_Bool
|
|
||||||
_forecasts_server_data(void *data, int type, void *event)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
Ecore_Con_Event_Server_Data *ev;
|
|
||||||
|
|
||||||
inst = data;
|
|
||||||
ev = event;
|
|
||||||
|
|
||||||
if ((!inst->server) || (inst->server != ev->server))
|
|
||||||
return EINA_TRUE;
|
|
||||||
eina_strbuf_append_length(inst->buffer, ev->data, ev->size);
|
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,8 +586,8 @@ _epoch_days(struct tm *tm_in)
|
||||||
static int
|
static int
|
||||||
_forecasts_parse(void *data)
|
_forecasts_parse(void *data)
|
||||||
{
|
{
|
||||||
Instance *inst;
|
Instance *inst = data;
|
||||||
char *needle;
|
const char *result;
|
||||||
const char *timestamp, *code;
|
const char *timestamp, *code;
|
||||||
time_t now;
|
time_t now;
|
||||||
struct tm *tm_local, *tm_data;
|
struct tm *tm_local, *tm_data;
|
||||||
|
@ -695,11 +603,7 @@ _forecasts_parse(void *data)
|
||||||
"Sat",
|
"Sat",
|
||||||
};
|
};
|
||||||
|
|
||||||
inst = data;
|
if (!inst->buffer) return 0;
|
||||||
if (!inst)
|
|
||||||
return 0;
|
|
||||||
if (!inst->buffer)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < FORECASTS; i++)
|
for (int i = 0; i < FORECASTS; i++)
|
||||||
{
|
{
|
||||||
|
@ -710,11 +614,10 @@ _forecasts_parse(void *data)
|
||||||
tm_local = localtime(&now);
|
tm_local = localtime(&now);
|
||||||
days_prev = _epoch_days(tm_local);
|
days_prev = _epoch_days(tm_local);
|
||||||
|
|
||||||
needle = strstr(eina_strbuf_string_get(inst->buffer), "\r\n\r\n");
|
result = eina_strbuf_string_get(inst->buffer);
|
||||||
if (!needle) goto error;
|
if (!result) goto error;
|
||||||
needle += 4;
|
|
||||||
|
|
||||||
json_object *o_root = json_tokener_parse(needle);
|
json_object *o_root = json_tokener_parse(result);
|
||||||
if (!o_root) goto error;
|
if (!o_root) goto error;
|
||||||
json_object *o_properties = json_object_object_get(o_root, "properties");
|
json_object *o_properties = json_object_object_get(o_root, "properties");
|
||||||
if (!o_properties) goto error;
|
if (!o_properties) goto error;
|
||||||
|
@ -805,7 +708,7 @@ _forecasts_parse(void *data)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
fprintf(stderr, "ERROR: Couldn't parse info from %s\n", inst->ci->host);
|
printf("FC: ERROR: Couldn't parse info\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -871,13 +774,12 @@ _forecasts_convert_pressures(float *value, int dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_forecasts_display_set(Instance *inst, int ok)
|
_forecasts_display_set(Instance *inst, int ok EINA_UNUSED)
|
||||||
{
|
{
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
char m[4096];
|
char m[4096];
|
||||||
|
|
||||||
if (!inst)
|
if (!inst) return;
|
||||||
return;
|
|
||||||
|
|
||||||
snprintf(m, sizeof(m), "%s/forecasts.edj",
|
snprintf(m, sizeof(m), "%s/forecasts.edj",
|
||||||
e_module_dir_get(forecasts_config->module));
|
e_module_dir_get(forecasts_config->module));
|
||||||
|
@ -1175,13 +1077,12 @@ _forecasts_popup_destroy(Instance *inst)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
_cb_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||||
{
|
{
|
||||||
Instance *inst;
|
Instance *inst = data;
|
||||||
Evas_Event_Mouse_Down *ev;
|
Evas_Event_Mouse_Up *ev = event_info;
|
||||||
|
|
||||||
if (!(inst = data)) return;
|
|
||||||
|
|
||||||
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
||||||
if (!inst->ci->popup_on_hover)
|
if (!inst->ci->popup_on_hover)
|
||||||
{
|
{
|
||||||
if (!inst->popup) _forecasts_popup_content_create(inst);
|
if (!inst->popup) _forecasts_popup_content_create(inst);
|
||||||
|
@ -1189,33 +1090,25 @@ _cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ev = event_info;
|
if (ev->button == 1) e_gadcon_popup_toggle_pinned(inst->popup);
|
||||||
if (ev->button == 1)
|
|
||||||
{
|
|
||||||
e_gadcon_popup_toggle_pinned(inst->popup);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
_cb_mouse_in(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Instance *inst;
|
Instance *inst = data;
|
||||||
|
|
||||||
if (!(inst = data)) return;
|
|
||||||
if (!inst->ci->popup_on_hover) return;
|
if (!inst->ci->popup_on_hover) return;
|
||||||
|
|
||||||
if (!inst->popup) _forecasts_popup_content_create(inst);
|
if (!inst->popup) _forecasts_popup_content_create(inst);
|
||||||
e_gadcon_popup_show(inst->popup);
|
e_gadcon_popup_show(inst->popup);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
_cb_mouse_out(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Instance *inst;
|
Instance *inst = data;
|
||||||
|
|
||||||
if (!(inst = data)) return;
|
|
||||||
if (!(inst->popup)) return;
|
if (!(inst->popup)) return;
|
||||||
|
|
||||||
if (inst->popup->pinned) return;
|
if (inst->popup->pinned) return;
|
||||||
e_gadcon_popup_hide(inst->popup);
|
e_gadcon_popup_hide(inst->popup);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ struct _Config_Item
|
||||||
|
|
||||||
double poll_time;
|
double poll_time;
|
||||||
int degrees;
|
int degrees;
|
||||||
const char *host;
|
|
||||||
int show_text;
|
int show_text;
|
||||||
int popup_on_hover;
|
int popup_on_hover;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue