summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Bouchaud (yoz) <yoz@efl.so>2019-01-14 00:55:47 +0100
committerMichael Bouchaud (yoz) <yoz@efl.so>2019-01-14 00:55:47 +0100
commit3a3a30b8181fb3820458ecc134dc9f0d89f56cd9 (patch)
tree9b697a314159cfe61312179f817ac4b2b12e151f
parent743db365790ad96cb9489c604a9ca8ef80636e25 (diff)
Add eina_log_domain to openweathermap plugin
-rw-r--r--src/plugin.c1
-rw-r--r--src/plugin.h2
-rw-r--r--src/plugin_openweathermap.c16
3 files changed, 18 insertions, 1 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 2b442ae..5926e5b 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -483,6 +483,7 @@ weather_plugin_shutdown(void)
483 483
484 EINA_LIST_FREE(plugins, wp) 484 EINA_LIST_FREE(plugins, wp)
485 { 485 {
486 if (wp->func.del) wp->func.del();
486 eina_stringshare_del(wp->name); 487 eina_stringshare_del(wp->name);
487 free(wp); 488 free(wp);
488 } 489 }
diff --git a/src/plugin.h b/src/plugin.h
index bb6c5de..94c60b3 100644
--- a/src/plugin.h
+++ b/src/plugin.h
@@ -4,6 +4,7 @@
4 4
5 5
6 6
7typedef void (*Weather_Plugin_Del) (void);
7typedef const char *(*Weather_Plugin_Uri) (Weather *wd); 8typedef const char *(*Weather_Plugin_Uri) (Weather *wd);
8typedef Eina_Bool (*Weather_Plugin_Parse) (Weather *wd, const unsigned char *parse, size_t size); 9typedef Eina_Bool (*Weather_Plugin_Parse) (Weather *wd, const unsigned char *parse, size_t size);
9typedef void (*Weather_Plugin_Search_Cb) (Eina_List *wds, void *data); 10typedef void (*Weather_Plugin_Search_Cb) (Eina_List *wds, void *data);
@@ -29,6 +30,7 @@ typedef struct _Weather_Plugin
29 unsigned int map_zoom; 30 unsigned int map_zoom;
30 Eina_Binbuf *buf; 31 Eina_Binbuf *buf;
31 struct { 32 struct {
33 Weather_Plugin_Del del;
32 Weather_Plugin_Uri uri_get; 34 Weather_Plugin_Uri uri_get;
33 Weather_Plugin_Parse parse; 35 Weather_Plugin_Parse parse;
34 Weather_Plugin_Search search_uri_get; 36 Weather_Plugin_Search search_uri_get;
diff --git a/src/plugin_openweathermap.c b/src/plugin_openweathermap.c
index 9536f8a..7ed459b 100644
--- a/src/plugin_openweathermap.c
+++ b/src/plugin_openweathermap.c
@@ -1,5 +1,5 @@
1#define _GNU_SOURCE 1 1#define _GNU_SOURCE 1
2#define LOG_DOMAIN _plugin_openweather_map_log_domain 2#define LOG_DOMAIN _openweathermap_log_domain
3#include <time.h> 3#include <time.h>
4#include "weather.h" 4#include "weather.h"
5#include "plugin.h" 5#include "plugin.h"
@@ -28,6 +28,7 @@ typedef enum Weather_Tag_
28 WEATHER_TAG_LOCATION = (1 << 2) 28 WEATHER_TAG_LOCATION = (1 << 2)
29} Weather_Tag; 29} Weather_Tag;
30 30
31static int _openweathermap_log_domain = 0;
31static Weather_Tag _xml_tag = 0; 32static Weather_Tag _xml_tag = 0;
32static Weather_Data *_current_wd = NULL; 33static Weather_Data *_current_wd = NULL;
33 34
@@ -89,6 +90,7 @@ _time_attr(void *data, const char *key, const char *value)
89 } 90 }
90 if (!wd) 91 if (!wd)
91 { 92 {
93 DBG("Add new weather data");
92 wd = E_NEW(Weather_Data, 1); 94 wd = E_NEW(Weather_Data, 1);
93 memcpy(&wd->time_start, &time_start, sizeof(struct tm)); 95 memcpy(&wd->time_start, &time_start, sizeof(struct tm));
94 weather->datas = eina_list_append(weather->datas, wd); 96 weather->datas = eina_list_append(weather->datas, wd);
@@ -680,6 +682,7 @@ _search_tag_cb(void *data, Eina_Simple_XML_Type type, const char *content, unsig
680 { 682 {
681 if (!strncmp(content, "item", sizeof("item") - 1)) 683 if (!strncmp(content, "item", sizeof("item") - 1))
682 { 684 {
685 DBG("Add new search weather results");
683 weather = E_NEW(Weather, 1); 686 weather = E_NEW(Weather, 1);
684 eina_simple_xml_parse(content, length, EINA_TRUE, _tag_cb, weather); 687 eina_simple_xml_parse(content, length, EINA_TRUE, _tag_cb, weather);
685 *pws = eina_list_append(*pws, weather); 688 *pws = eina_list_append(*pws, weather);
@@ -860,15 +863,24 @@ _plugin_openweathermap_map_uris_get(Weather_Map_Type type)
860 return uris; 863 return uris;
861} 864}
862 865
866static void
867_plugin_openweathermap_del(void)
868{
869 eina_log_domain_unregister(_openweathermap_log_domain);
870}
871
863EINTERN Weather_Plugin * 872EINTERN Weather_Plugin *
864plugin_openweathermap_create(void) 873plugin_openweathermap_create(void)
865{ 874{
866 Weather_Plugin *wp; 875 Weather_Plugin *wp;
867 876
877 _openweathermap_log_domain = eina_log_domain_register("openweathermap", EINA_COLOR_YELLOW);
878 DBG("Create openweathermap plugin");
868 wp = E_NEW(Weather_Plugin, 1); 879 wp = E_NEW(Weather_Plugin, 1);
869 wp->name = eina_stringshare_add("Openweathermap"); 880 wp->name = eina_stringshare_add("Openweathermap");
870 wp->map_zoom = OPENWEATHER_MAP_ZOOM; 881 wp->map_zoom = OPENWEATHER_MAP_ZOOM;
871 wp->type = WEATHER_PLUGIN_WEATHER_HOUR; 882 wp->type = WEATHER_PLUGIN_WEATHER_HOUR;
883 wp->func.del = _plugin_openweathermap_del;
872 wp->func.uri_get = _plugin_openweathermap_uri_get; 884 wp->func.uri_get = _plugin_openweathermap_uri_get;
873 wp->func.parse = _plugin_openweathermap_parse; 885 wp->func.parse = _plugin_openweathermap_parse;
874 wp->func.search_uri_get = _plugin_openweathermap_search_uri_get; 886 wp->func.search_uri_get = _plugin_openweathermap_search_uri_get;
@@ -877,3 +889,5 @@ plugin_openweathermap_create(void)
877 889
878 return wp; 890 return wp;
879} 891}
892
893