1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-17 18:45:10 +00:00

Fix parsing of XOAP xml.

Also made the XOAP cloud condition match that of the NOAA stuff
(lowercase).
This commit is contained in:
Brenden Matthews 2009-08-04 21:15:08 -06:00
parent c99e092246
commit e41f3e4f7b
2 changed files with 59 additions and 43 deletions

View File

@ -3364,64 +3364,63 @@
<simplelist> <simplelist>
<member> <member>
<command>last_update</command> <command>last_update</command>
<option>The date and time stamp of the data. <para>The date and time stamp of the data.
The result depends on the URI used. For the The result depends on the URI used. For the
NOAA site it is date (yyyy/mm/dd) and UTC time. NOAA site it is date (yyyy/mm/dd) and UTC time.
For the weather.com one it is date For the weather.com one it is date
([m]m/[d]d/yy) and Local Time of the ([m]m/[d]d/yy) and Local Time of the
station.</option> station.</para>
</member> </member>
<member> <member>
<command>temperature</command> <command>temperature</command>
<option>Air temperature (you can use the <para>Air temperature (you can use the
'temperature_unit' config setting to change 'temperature_unit' config setting to change
units)</option> units)</para>
</member> </member>
<member> <member>
<command>cloud_cover</command> <command>cloud_cover</command>
<option>The highest cloud cover status</option> <para>The highest cloud cover status</para>
</member> </member>
<member> <member>
<command>pressure</command> <command>pressure</command>
<option>Air pressure in millibar</option> <para>Air pressure in millibar</para>
</member> </member>
<member> <member>
<command>wind_speed</command> <command>wind_speed</command>
<option>Wind speed in km/h</option> <para>Wind speed in km/h</para>
</member> </member>
<member> <member>
<command>wind_dir</command> <command>wind_dir</command>
<option>Wind direction</option> <para>Wind direction</para>
</member> </member>
<member> <member>
<command>wind_dir_DEG</command> <command>wind_dir_DEG</command>
<option>Compass wind direction</option> <para>Compass wind direction</para>
</member> </member>
<member> <member>
<command>humidity</command> <command>humidity</command>
<option>Relative humidity in %</option> <para>Relative humidity in %</para>
</member> </member>
<member> <member>
<command>weather</command> <command>weather</command>
<option>Any relevant weather event (rain, snow, <para>Any relevant weather event (rain, snow,
etc.). This is not used if you are querying the etc.). This is not used if you are querying the
weather.com site since this data is aggregated weather.com site since this data is aggregated
into the cloud_cover one</option> into the cloud_cover one</para>
</member> </member>
<member> <member>
<command>icon</command> <command>icon</command>
<option>Weather icon (only for <para>Weather icon (only for
www.weather.com). Can be used together with the www.weather.com). Can be used together with the
icon kit provided upon registering to their icon kit provided upon registering to their
service.</option> service.</para>
</member> </member>
</simplelist> </simplelist>
<para>'delay_in_minutes' (optional, default 30) cannot <para>'delay_in_minutes' (optional, default 30) cannot
be lower than 30 min.</para> be less than 30 minutes.</para>
<para>This object is threaded, and once a thread is <para>This object is threaded, and once a thread is
created it can't be explicitely destroyed. One thread created it can't be explicitely destroyed. One thread
will run for each URI specified. You can use any will run for each URI specified.</para>
protocol that Curl supports.</para>
<para>Note that these variables are still EXPERIMENTAL <para>Note that these variables are still EXPERIMENTAL
and can be subject to many future changes.</para> and can be subject to many future changes.</para>
</listitem> </listitem>

View File

@ -109,7 +109,7 @@ static void parse_df(PWEATHER_FORECAST *res, xmlXPathContextPtr xpathCtx)
xmlXPathObjectPtr xpathObj; xmlXPathObjectPtr xpathObj;
for (i = 0; i < NUM_XPATH_EXPRESSIONS_DF; i++) { for (i = 0; i < NUM_XPATH_EXPRESSIONS_DF; i++) {
xpathObj = xmlXPathEvalExpression((xmlChar *)xpath_expression_df[i], xpathCtx); xpathObj = xmlXPathEvalExpression((const xmlChar *)xpath_expression_df[i], xpathCtx);
if (xpathObj != NULL) { if (xpathObj != NULL) {
xmlNodeSetPtr nodes = xpathObj->nodesetval; xmlNodeSetPtr nodes = xpathObj->nodesetval;
k = 0; k = 0;
@ -179,34 +179,46 @@ static void parse_cc(PWEATHER *res, xmlXPathContextPtr xpathCtx)
char *content; char *content;
xmlXPathObjectPtr xpathObj; xmlXPathObjectPtr xpathObj;
xpathObj = xmlXPathEvalExpression((const xmlChar *)"/error/err", xpathCtx);
if (xpathObj && xpathObj->nodesetval && xpathObj->nodesetval->nodeNr > 0 &&
xpathObj->nodesetval->nodeTab[0]->type == XML_ELEMENT_NODE) {
content = (char *)xmlNodeGetContent(xpathObj->nodesetval->nodeTab[0]);
NORM_ERR("XOAP error: %s", content);
xmlFree(content);
xmlXPathFreeObject(xpathObj);
return;
}
for (i = 0; i < NUM_XPATH_EXPRESSIONS_CC; i++) { for (i = 0; i < NUM_XPATH_EXPRESSIONS_CC; i++) {
xpathObj = xmlXPathEvalExpression((xmlChar *)xpath_expression_cc[i], xpathCtx); xpathObj = xmlXPathEvalExpression((const xmlChar *)xpath_expression_cc[i], xpathCtx);
if ((xpathObj != NULL) && (xpathObj->nodesetval->nodeTab[0]->type == XML_ELEMENT_NODE)) { if (xpathObj && xpathObj->nodesetval && xpathObj->nodesetval->nodeNr >0 &&
xpathObj->nodesetval->nodeTab[0]->type ==
XML_ELEMENT_NODE) {
content = (char *)xmlNodeGetContent(xpathObj->nodesetval->nodeTab[0]); content = (char *)xmlNodeGetContent(xpathObj->nodesetval->nodeTab[0]);
switch(i) { switch(i) {
case 0: case 0:
strncpy(res->lastupd, content, 31); strncpy(res->lastupd, content, 31);
break; break;
case 1: case 1:
res->temp = atoi(content); res->temp = atoi(content);
break; break;
case 2: case 2:
strncpy(res->xoap_t, content, 31); strncpy(res->xoap_t, content, 31);
break; break;
case 3: case 3:
res->bar = atoi(content); res->bar = atoi(content);
break; break;
case 4: case 4:
res->wind_s = atoi(content); res->wind_s = atoi(content);
break; break;
case 5: case 5:
res->wind_d = atoi(content); res->wind_d = atoi(content);
break; break;
case 6: case 6:
res->hmid = atoi(content); res->hmid = atoi(content);
break; break;
case 7: case 7:
strncpy(res->icon, content, 2); strncpy(res->icon, content, 2);
} }
xmlFree(content); xmlFree(content);
} }
@ -695,7 +707,12 @@ void weather_process_info(char *p, int p_max_size, char *uri, char *data_type, i
} else if (strcmp(data_type, "cloud_cover") == EQUAL) { } else if (strcmp(data_type, "cloud_cover") == EQUAL) {
#ifdef XOAP #ifdef XOAP
if (data->xoap_t[0] != '\0') { if (data->xoap_t[0] != '\0') {
char *s = p;
strncpy(p, data->xoap_t, p_max_size); strncpy(p, data->xoap_t, p_max_size);
while (*s) {
*s = tolower(*s);
s++;
}
} else } else
#endif /* XOAP */ #endif /* XOAP */
if (data->cc == 0) { if (data->cc == 0) {