[Xfce4-commits] <xfce4-weather-plugin:master> Update astrodata callback function for libsoup.
Harald Judt
noreply at xfce.org
Tue Nov 20 20:18:04 CET 2012
Updating branch refs/heads/master
to 6db4747c68fb013ce53e780f839a7e2b45921277 (commit)
from 1445bcd83c4eaf795447f30c16379d439d31796e (commit)
commit 6db4747c68fb013ce53e780f839a7e2b45921277
Author: Harald Judt <h.judt at gmx.at>
Date: Tue Nov 20 20:01:49 2012 +0100
Update astrodata callback function for libsoup.
panel-plugin/weather.c | 38 +++++++++-----------------------------
1 files changed, 9 insertions(+), 29 deletions(-)
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 25dcc7d..13b0941 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -309,39 +309,21 @@ update_current_conditions(xfceweather_data *data)
static void
-cb_astro_update(const gboolean succeed,
- gchar *result,
- const size_t len,
+cb_astro_update(SoupSession *session,
+ SoupMessage *msg,
gpointer user_data)
{
+ SoupMessageBody *body;
xfceweather_data *data = user_data;
- xmlDoc *doc;
- xmlNode *cur_node;
- xml_astro *astro = NULL;
-
- if (G_LIKELY(succeed && result)) {
- if (g_utf8_validate(result, -1, NULL)) {
- /* force parsing as UTF-8, the XML encoding header may lie */
- doc = xmlReadMemory(result, strlen(result), NULL, "UTF-8", 0);
- } else
- doc = xmlParseMemory(result, strlen(result));
- g_free(result);
+ xml_astro *astro;
- if (G_LIKELY(doc)) {
- cur_node = xmlDocGetRootElement(doc);
- if (G_LIKELY(cur_node))
- astro = parse_astro(cur_node);
- xmlFreeDoc(doc);
- }
- }
-
- if (astro) {
+ if ((astro =
+ (xml_astro *) parse_xml_document(msg, (XmlParseFunc) parse_astro))) {
if (data->astrodata)
xml_astro_free(data->astrodata);
data->astrodata = astro;
data->last_astro_update = time(NULL);
}
-
weather_dump(weather_dump_astrodata, data->astrodata);
}
@@ -470,7 +452,7 @@ update_weatherdata(xfceweather_data *data)
now_tm = *localtime(&now_t);
/* build url */
- url = g_strdup_printf("/weatherapi/sunrise/1.0/?"
+ url = g_strdup_printf("http://api.yr.no/weatherapi/sunrise/1.0/?"
"lat=%s;lon=%s;date=%04d-%02d-%02d",
data->lat, data->lon,
now_tm.tm_year + 1900,
@@ -478,10 +460,8 @@ update_weatherdata(xfceweather_data *data)
now_tm.tm_mday);
/* start receive thread */
- g_message("getting http://api.yr.no%s", url);
- weather_http_receive_data("api.yr.no", url, data->proxy_host,
- data->proxy_port, cb_astro_update, data);
-
+ g_message("getting %s", url);
+ weather_http_queue_request(url, cb_astro_update, data);
g_free(url);
}
More information about the Xfce4-commits
mailing list