2009-07-18
+ * add compilation switch --enable-xoap to be able to use
+ www.weather.com as a source of weather data (this avoids adding
+ libxml2 as a required dependency for users that wish to use noaa
+ and not weather.com)
+
+2009-07-18
* www.weather.com can now be used as well as a source of weather data
2009-07-11
AC_ARG_ENABLE([weather],
AC_HELP_STRING([--enable-weather], [enable if you want weather support @<:@default=no@:>@]),
[want_weather="$enableval"], [want_weather=no])
+
+AC_ARG_ENABLE([xoap],
+ AC_HELP_STRING([--enable-xoap], [enable if you want weather xoap support @<:@default=no@:>@]),
+ [want_xoap="$enableval"], [want_xoap=no])
#
AM_CONDITIONAL(BUILD_WEATHER, test x$want_weather = xyes)
if test x$want_weather = xyes; then
- PKG_CHECK_MODULES([libxml2], libxml-2.0)
+ AM_CONDITIONAL(BUILD_XOAP, test x$want_xoap = xyes)
+ if test x$want_xoap = xyes; then
+ PKG_CHECK_MODULES([libxml2], libxml-2.0)
+ conky_CFLAGS="$conky_CFLAGS $libxml2_CFLAGS"
+ conky_LIBS="$conky_LIBS $libxml2_LIBS"
+ AC_DEFINE(XOAP, 1, [Define if you want weather xoap support])
+ AC_DEFINE(XOAP_FILE, "$HOME/.xoaprc", [User xoap keys file])
+ fi
PKG_CHECK_MODULES([libcurl], libcurl)
- conky_CFLAGS="$conky_CFLAGS $libxml2_CFLAGS $libcurl_CFLAGS"
- conky_LIBS="$conky_LIBS $libxml2_LIBS $libcurl_LIBS"
+ conky_CFLAGS="$conky_CFLAGS $libcurl_CFLAGS"
+ conky_LIBS="$conky_LIBS $libcurl_LIBS"
AC_DEFINE(WEATHER, 1, [Define if you want weather support])
fi
AC_DEFINE(DEFAULTNETDEV, "eth0", [Default networkdevice])
AC_DEFINE(CONFIG_FILE, "$HOME/.conkyrc", [Configfile of the user])
-AC_DEFINE(XOAP_FILE, "$HOME/.xoaprc", [User xoap keys file])
AC_DEFINE(MAX_SPECIALS_DEFAULT, 512, [Default maximum number of special things, e.g. fonts, offsets, aligns, etc.])
AC_DEFINE(MAX_USER_TEXT_DEFAULT, 16384, [Default maximum size of config TEXT buffer, i.e. below TEXT line.])
AC_DEFINE(DEFAULT_TEXT_BUFFER_SIZE, 256, [Default size used for temporary, static text buffers])
if( obj->data.weather.uri != NULL ) {
process_weather_info(p, p_max_size, obj->data.weather.uri, obj->data.weather.data_type, obj->data.weather.interval);
} else {
- strncpy(p, "invalid xoap keys file", p_max_size);
+ strncpy(p, "either invalid xoap keys file or compiled without xoap support", p_max_size);
}
}
#endif
}
#endif /* X11 */
-#ifdef WEATHER
+#if defined(WEATHER) && defined(XOAP)
/*
* TODO: make the xoap keys file readable from the config file
* make the keys directly readable from the config file
free(par);
free(key);
}
-#endif /* WEATHER */
+#endif /* WEATHER && XOAP */
static void print_help(const char *prog_name) {
printf("Usage: %s [OPTION]...\n"
}
}
-#ifdef WEATHER
+#if defined(WEATHER) && defined(XOAP)
/* Load xoap keys, if existing */
load_xoap_keys();
-#endif /* WEATHER */
+#endif /* WEATHER && XOAP */
#ifdef HAVE_SYS_INOTIFY_H
inotify_fd = inotify_init();
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
+#ifdef XOAP
#include <libxml/parser.h>
+#endif /* XOAP */
/* Possible sky conditions */
#define NUM_CC_CODES 6
const char *WC_CODES[NUM_WC_CODES] = {
"DZ", "RA", "GR", "GS", "SN", "SG",
"FG", "HZ", "FU", "BR", "DU", "SA",
- "FC", "PO", "SQ", "SS", "DS",
+ "FC", "PO", "SQ", "SS", "DS"
};
typedef struct location_ {
#endif /* MATH */
}
+#ifdef XOAP
//TODO: Lets get rid of the recursion
static void parse_cc(PWEATHER *res, xmlNodePtr cc)
{
xmlFreeDoc(doc);
return ;
}
+#endif /* XOAP */
/*
* Horrible hack to avoid using regexes
//Reset results
memset(res, 0, sizeof(PWEATHER));
+#ifdef XOAP
//Check if it is an xml file
if ( strncmp(data, "<?xml ", 6) == 0 ) {
parse_weather_xml(res, data);
- } else {
- //We assume its a text file
- char s_tmp[256];
- const char delim[] = " ";
+ } else
+#endif /* XOAP */
+ {
+ //We assume its a text file
+ char s_tmp[256];
+ const char delim[] = " ";
- //Divide time stamp and metar data
- if (sscanf(data, "%[^'\n']\n%[^'\n']", res->lastupd, s_tmp) == 2) {
+ //Divide time stamp and metar data
+ if (sscanf(data, "%[^'\n']\n%[^'\n']", res->lastupd, s_tmp) == 2) {
//Process all tokens
char *p_tok = NULL;
} while (p_tok != NULL);
}
return;
+ }
+ else {
+ return;
+ }
}
- else {
- return;
- }
- }
}
void fetch_weather_info(location *curloc)
} else if (strcmp(data_type, "temperature") == EQUAL) {
temp_print(p, p_max_size, curloc->data.temp, TEMP_CELSIUS);
} else if (strcmp(data_type, "cloud_cover") == EQUAL) {
+#ifdef XOAP
if (curloc->data.xoap_t[0] != '\0') {
strncpy(p, curloc->data.xoap_t, p_max_size);
- } else if (curloc->data.cc == 0) {
+ } else
+#endif /* XOAP */
+ if (curloc->data.cc == 0) {
strncpy(p, "", p_max_size);
} else if (curloc->data.cc < 3) {
strncpy(p, "clear", p_max_size);
/* WEATHER data */
typedef struct PWEATHER_ {
char lastupd[32];
+#ifdef XOAP
char xoap_t[32];
- int temp;
- int dew;
- int cc;
- int bar;
- int wind_s;
- int wind_d;
- int hmid;
- int wc;
/*
* TODO:
* Is it worth investigating about using icons from weather.com?
char icon[3];
*/
+#endif /* XOAP */
+ int temp;
+ int dew;
+ int cc;
+ int bar;
+ int wind_s;
+ int wind_d;
+ int hmid;
+ int wc;
} PWEATHER;
/* Prototypes */