weather: add icon data_type for xoap
authorCesare Tirabassi <norsetto@ubuntu.com>
Wed, 29 Jul 2009 20:22:24 +0000 (22:22 +0200)
committerCesare Tirabassi <norsetto@ubuntu.com>
Wed, 29 Jul 2009 20:22:24 +0000 (22:22 +0200)
doc/variables.xml
src/weather.c
src/weather.h

index 1d8be43..cd35e97 100644 (file)
                     weather.com site since this data is aggregated
                     into the cloud_cover one</option>
                 </member>
+                <member>
+                    <command>icon</command>
+                    <option>Weather icon (only for www.weather.com).
+                   Can be used together with the icon kit provided
+                   upon registering to their service.</option>
+                </member>
             </simplelist>
             <para>'delay_in_minutes' (optional, default 30) cannot
             be lower than 30 min.</para>
index 432e4b8..6a144cd 100644 (file)
 #include <libxml/xpath.h>
 
 /* Xpath expressions for XOAP xml parsing */
-#define NUM_XPATH_EXPRESSIONS 7
+#define NUM_XPATH_EXPRESSIONS 8
 const char *xpath_expression[NUM_XPATH_EXPRESSIONS] = {
        "/weather/cc/lsup", "/weather/cc/tmp", "/weather/cc/t",
        "/weather/cc/bar/r", "/weather/cc/wind/s", "/weather/cc/wind/d",
-       "/weather/cc/hmid"
+       "/weather/cc/hmid", "/weather/cc/icon"
 };
 #endif /* XOAP */
 
@@ -128,6 +128,9 @@ static void parse_cc(PWEATHER *res, xmlXPathContextPtr xpathCtx)
                            break;
                       case 6:
                            res->hmid = atoi(content);
+                               break;
+                      case 7:
+                           strncpy(res->icon, content, 2);
                  }
                  xmlFree(content);
                }
@@ -542,6 +545,10 @@ void weather_process_info(char *p, int p_max_size, char *uri, char *data_type, i
                        } else  {
                                strncpy(p, "cumulonimbus", p_max_size);
                        }
+#ifdef XOAP
+       } else if (strcmp(data_type, "icon") == EQUAL) {
+               strncpy(p, data->icon, p_max_size);
+#endif /* XOAP */
        } else if (strcmp(data_type, "pressure") == EQUAL) {
                snprintf(p, p_max_size, "%d", data->bar);
        } else if (strcmp(data_type, "wind_speed") == EQUAL) {
index c8aceab..fa418d0 100644 (file)
@@ -37,16 +37,7 @@ typedef struct PWEATHER_ {
        char lastupd[32];
 #ifdef XOAP
        char xoap_t[32];
-       /*
-        * TODO:
-        * Is it worth investigating about using icons from weather.com?
-        * We could use them for data from noaa as well.
-        * They can display nicely with cimlib_add_image (with appropriate
-        * #ifdefs on imlib2 and x11), and an additional input argoment for position.
-
-        char icon[3];
-
-        */
+       char icon[3];
 #endif /* XOAP */
        int temp;
        int dew;