[Xfce4-commits] <xfce4-weather-plugin:master> weather-parsers: Prepare to move openstreetmap parsing code.

Harald Judt noreply at xfce.org
Fri Aug 3 01:06:04 CEST 2012


Updating branch refs/heads/master
         to 182e417afb7f522732e9038918f6e58c7a8ede0a (commit)
       from a868e406294974d21c525172f871e7c04c30d965 (commit)

commit 182e417afb7f522732e9038918f6e58c7a8ede0a
Author: Harald Judt <h.judt at gmx.at>
Date:   Fri Aug 3 00:35:38 2012 +0200

    weather-parsers: Prepare to move openstreetmap parsing code.
    
    All XML parsing should be done in weather-parsers.

 panel-plugin/weather-parsers.c |   34 ++++++++++++++++++++++++++++++++++
 panel-plugin/weather-parsers.h |   11 +++++++++++
 2 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/panel-plugin/weather-parsers.c b/panel-plugin/weather-parsers.c
index 1359b09..d5c9df6 100644
--- a/panel-plugin/weather-parsers.c
+++ b/panel-plugin/weather-parsers.c
@@ -404,6 +404,28 @@ parse_geolocation(xmlNode *cur_node)
 }
 
 
+xml_place *
+parse_place(xmlNode *cur_node)
+{
+    xml_place *place;
+
+    g_assert(cur_node != NULL);
+    if (G_UNLIKELY(cur_node == NULL))
+        return NULL;
+
+    if (!NODE_IS_TYPE(cur_node, "place"))
+        return NULL;
+
+    place = g_slice_new0(xml_place);
+    if (G_UNLIKELY(place == NULL))
+        return NULL;
+    place->lat = PROP(cur_node, "lat");
+    place->lon = PROP(cur_node, "lon");
+    place->display_name = PROP(cur_node, "display_name");
+    return place;
+}
+
+
 static void
 xml_location_free(xml_location *loc)
 {
@@ -490,3 +512,15 @@ xml_geolocation_free(xml_geolocation *geo)
     g_free(geo->latitude);
     g_free(geo->longitude);
 }
+
+
+void
+xml_place_free(xml_place *place)
+{
+    g_assert(place != NULL);
+    if (G_UNLIKELY(place == NULL))
+        return;
+    g_free(place->lat);
+    g_free(place->lon);
+    g_free(place->display_name);
+}
diff --git a/panel-plugin/weather-parsers.h b/panel-plugin/weather-parsers.h
index fe26e48..dc746f2 100644
--- a/panel-plugin/weather-parsers.h
+++ b/panel-plugin/weather-parsers.h
@@ -108,12 +108,21 @@ typedef struct {
 } xml_geolocation;
 
 
+typedef struct {
+    gchar *display_name;
+    gchar *lat;
+    gchar *lon;
+} xml_place;
+
+
 xml_weather *parse_weather(xmlNode *cur_node);
 
 xml_astro *parse_astro(xmlNode *cur_node);
 
 xml_geolocation *parse_geolocation(xmlNode *cur_node);
 
+xml_place *parse_place(xmlNode *cur_node);
+
 xml_time *get_timeslice(xml_weather *data,
                         const time_t start_t,
                         const time_t end_t);
@@ -126,6 +135,8 @@ void xml_astro_free(xml_astro *astro);
 
 void xml_geolocation_free(xml_geolocation *geo);
 
+void xml_place_free(xml_place *place);
+
 G_END_DECLS
 
 #endif


More information about the Xfce4-commits mailing list