1
/* $Id: weather-parsers.c 2366 2007-01-15 19:10:23Z nick $
3
* Copyright (c) 2003-2007 Xfce Development Team
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Library General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
#include "weather-parsers.h"
25
#include <libxfce4panel/xfce-panel-macros.h>
30
parse_weather (xmlNode *cur_node)
36
if (!NODE_IS_TYPE (cur_node, "weather"))
41
if ((ret = panel_slice_new0 (xml_weather)) == NULL)
44
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
46
if (cur_node->type != XML_ELEMENT_NODE)
49
if (NODE_IS_TYPE (cur_node, "cc"))
50
ret->cc = parse_cc (cur_node);
51
else if (NODE_IS_TYPE (cur_node, "loc"))
52
ret->loc = parse_loc (cur_node);
53
else if (NODE_IS_TYPE (cur_node, "dayf"))
55
for (child_node = cur_node->children; child_node;
56
child_node = child_node->next)
58
if (NODE_IS_TYPE (child_node, "day"))
60
if (i >= XML_WEATHER_DAYF_N)
63
ret->dayf[i] = parse_dayf (child_node);
77
parse_loc (xmlNode *cur_node)
81
if ((ret = panel_slice_new0 (xml_loc)) == NULL)
85
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
87
if (cur_node->type != XML_ELEMENT_NODE)
90
if (NODE_IS_TYPE (cur_node, "dnam"))
91
ret->dnam = DATA (cur_node);
92
else if (NODE_IS_TYPE (cur_node, "sunr"))
93
ret->sunr = DATA (cur_node);
94
else if (NODE_IS_TYPE (cur_node, "suns"))
95
ret->suns = DATA (cur_node);
104
parse_uv (xmlNode *cur_node)
108
if ((ret = panel_slice_new0 (xml_uv)) == NULL)
111
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
113
if (cur_node->type != XML_ELEMENT_NODE)
116
if (NODE_IS_TYPE (cur_node, "i"))
117
ret->i = DATA (cur_node);
118
else if (NODE_IS_TYPE (cur_node, "t"))
119
ret->t = DATA (cur_node);
128
parse_bar (xmlNode *cur_node)
132
if ((ret = panel_slice_new0 (xml_bar)) == NULL)
135
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
137
if (cur_node->type != XML_ELEMENT_NODE)
140
if (NODE_IS_TYPE (cur_node, "r"))
141
ret->r = DATA (cur_node);
142
else if (NODE_IS_TYPE (cur_node, "d"))
143
ret->d = DATA (cur_node);
152
parse_wind (xmlNode *cur_node)
156
if ((ret = panel_slice_new0 (xml_wind)) == NULL)
159
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
161
if (cur_node->type != XML_ELEMENT_NODE)
164
if (NODE_IS_TYPE (cur_node, "s"))
165
ret->s = DATA (cur_node);
166
else if (NODE_IS_TYPE (cur_node, "gust"))
167
ret->gust = DATA (cur_node);
168
else if (NODE_IS_TYPE (cur_node, "d"))
169
ret->d = DATA (cur_node);
170
else if (NODE_IS_TYPE (cur_node, "t"))
171
ret->t = DATA (cur_node);
180
parse_cc (xmlNode *cur_node)
184
if ((ret = panel_slice_new0 (xml_cc)) == NULL)
187
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
189
if (cur_node->type != XML_ELEMENT_NODE)
192
if (NODE_IS_TYPE (cur_node, "tmp"))
193
ret->tmp = DATA (cur_node);
194
else if (NODE_IS_TYPE (cur_node, "icon"))
195
ret->icon = DATA (cur_node);
196
else if (NODE_IS_TYPE (cur_node, "t"))
197
ret->t = DATA (cur_node);
198
else if (NODE_IS_TYPE (cur_node, "flik"))
199
ret->flik = DATA (cur_node);
200
else if (NODE_IS_TYPE (cur_node, "bar"))
201
ret->bar = parse_bar (cur_node);
202
else if (NODE_IS_TYPE (cur_node, "wind"))
203
ret->wind = parse_wind (cur_node);
204
else if (NODE_IS_TYPE (cur_node, "hmid"))
205
ret->hmid = DATA (cur_node);
206
else if (NODE_IS_TYPE (cur_node, "vis"))
207
ret->vis = DATA (cur_node);
208
else if (NODE_IS_TYPE (cur_node, "uv"))
209
ret->uv = parse_uv (cur_node);
210
else if (NODE_IS_TYPE (cur_node, "dewp"))
211
ret->dewp = DATA (cur_node);
212
else if (NODE_IS_TYPE (cur_node, "lsup"))
213
ret->lsup = DATA (cur_node);
214
else if (NODE_IS_TYPE (cur_node, "obst"))
215
ret->obst = DATA (cur_node);
224
parse_part (xmlNode *cur_node)
228
if ((ret = panel_slice_new0 (xml_part)) == NULL)
231
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
233
if (cur_node->type != XML_ELEMENT_NODE)
236
if (NODE_IS_TYPE (cur_node, "icon"))
237
ret->icon = DATA (cur_node);
238
else if (NODE_IS_TYPE (cur_node, "t"))
239
ret->t = DATA (cur_node);
240
else if (NODE_IS_TYPE (cur_node, "wind"))
241
ret->wind = parse_wind (cur_node);
242
else if (NODE_IS_TYPE (cur_node, "ppcp"))
243
ret->ppcp = DATA (cur_node);
244
else if (NODE_IS_TYPE (cur_node, "hmid"))
245
ret->hmid = DATA (cur_node);
254
parse_dayf (xmlNode *cur_node)
259
if ((ret = panel_slice_new0 (xml_dayf)) == NULL)
262
ret->day = (gchar *) xmlGetProp (cur_node, (const xmlChar *) "t");
263
ret->date = (gchar *) xmlGetProp (cur_node, (const xmlChar *) "dt");
265
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
267
if (cur_node->type != XML_ELEMENT_NODE)
270
if (NODE_IS_TYPE (cur_node, "hi"))
272
ret->hi = DATA (cur_node);
273
g_assert (ret->hi != NULL);
275
else if (NODE_IS_TYPE (cur_node, "low"))
277
ret->low = DATA (cur_node);
279
else if (NODE_IS_TYPE (cur_node, "part"))
281
value = (gchar *) xmlGetProp (cur_node, (const xmlChar *) "p");
283
if (xmlStrEqual ((const xmlChar *) value, (const xmlChar *) "d"))
284
ret->part[0] = parse_part (cur_node);
286
if (xmlStrEqual ((const xmlChar *) value, (const xmlChar *) "n"))
287
ret->part[1] = parse_part (cur_node);
299
xml_uv_free (xml_uv * data)
304
panel_slice_free (xml_uv, data);
310
xml_wind_free (xml_wind * data)
317
panel_slice_free (xml_wind, data);
323
xml_bar_free (xml_bar * data)
328
panel_slice_free (xml_bar, data);
334
xml_cc_free (xml_cc * data)
347
xml_uv_free (data->uv);
350
xml_wind_free (data->wind);
353
xml_bar_free (data->bar);
355
panel_slice_free (xml_cc, data);
361
xml_loc_free (xml_loc *data)
367
panel_slice_free (xml_loc, data);
373
xml_part_free (xml_part *data)
384
xml_wind_free (data->wind);
386
panel_slice_free (xml_part, data);
392
xml_dayf_free (xml_dayf *data)
403
xml_part_free (data->part[0]);
406
xml_part_free (data->part[1]);
408
panel_slice_free (xml_dayf, data);
414
xml_weather_free (xml_weather *data)
419
xml_cc_free (data->cc);
422
xml_loc_free (data->loc);
426
for (i = 0; i < XML_WEATHER_DAYF_N; i++)
431
xml_dayf_free (data->dayf[i]);
435
panel_slice_free (xml_weather, data);