Removing remaining GVFS dependencies.
authorAndy Spencer <andy753421@gmail.com>
Thu, 16 Jul 2009 06:36:26 +0000 (06:36 +0000)
committerAndy Spencer <andy753421@gmail.com>
Thu, 16 Jul 2009 06:36:26 +0000 (06:36 +0000)
Makefile.am
configure.ac
gen.sh [changed mode: 0755->0644]
src/data.c
src/plugin-radar.c

index 5938e17..f1c76f8 100644 (file)
@@ -14,3 +14,18 @@ release: all dist
        scp LATEST $(PACKAGE)-$(VERSION).tar.* \
                "lug@lug.rose-hulman.edu:/home/lug/htdocs/proj/$(PACKAGE)"; \
        rm -f LATEST
+
+depscan:
+       gtkdoc-depscan             \
+               --book=atk         \
+               --book=gdk         \
+               --book=gdk-pixbuf  \
+               --book=glib        \
+               --book=gio         \
+               --book=gobject     \
+               --book=gtk         \
+               --book=pango       \
+               --book=libsoup-2.4 \
+               --list-unknown     \
+               "$@"               \
+               src/*.c
index bd6a539..184a12e 100644 (file)
@@ -1,5 +1,5 @@
 # Init and options
-AC_INIT([aweather], [0.1], [spenceal@rose-hulman.edu])
+AC_INIT([aweather], [0.1.1], [spenceal@rose-hulman.edu])
 AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability foreign])
 AC_CONFIG_HEADERS([config.h])
 
@@ -9,9 +9,9 @@ PKG_PROG_PKG_CONFIG
 GTK_DOC_CHECK(1.9)
 
 # Check for required packages
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.14 gobject-2.0 gthread-2.0 gmodule-export-2.0)
+PKG_CHECK_MODULES(GTK,  gtk+-2.0 >= 2.16 gtkglext-1.0)
 PKG_CHECK_MODULES(SOUP, libsoup-2.4 >= 2.26)
-PKG_CHECK_MODULES(GLIB, gio-2.0 gmodule-export-2.0 gobject-2.0 gthread-2.0)
-PKG_CHECK_MODULES(GTK,  gtk+-2.0 gtkglext-1.0)
 
 # Define odd RSL install location
 #AC_SUBST(RSL_CFLAGS, "-I/usr/local/trmm/GVBOX/include/")
diff --git a/gen.sh b/gen.sh
old mode 100755 (executable)
new mode 100644 (file)
index 9def903..6186883 100644 (file)
@@ -96,6 +96,7 @@ static SoupSession *do_cache(cache_file_end_t *info, gboolean truncate, gchar *r
        long bytes = ftell(info->fp);
 
        SoupSession *session = soup_session_async_new();
+       g_object_set(session, "user-agent", PACKAGE_STRING, NULL);
        SoupMessage *message = soup_message_new("GET", info->uri);
        if (message == NULL)
                g_error("message is null, cannot parse uri");
index 8d5fb4e..18e9279 100644 (file)
@@ -27,6 +27,8 @@
 #include "plugin-radar.h"
 #include "data.h"
 
+static char *nexrad_base = "http://mesonet.agron.iastate.edu/data/";
+
 /****************
  * GObject code *
  ****************/
@@ -251,46 +253,10 @@ static void load_radar(AWeatherRadar *self, gchar *radar_file)
        load_radar_gui(self, radar);
 }
 
-static void update_times(AWeatherRadar *self, AWeatherView *view, char *site, char **last_time)
+/* TODO: These update times functions are getting ugly... */
+static void update_times_gtk(AWeatherRadar *self, GList *times)
 {
-       GList *times = NULL;
-       if (aweather_view_get_offline(view)) {
-               gchar *path = g_build_filename(g_get_user_cache_dir(), PACKAGE, "nexrd2", "raw", site, NULL);
-               GDir *dir = g_dir_open(path, 0, NULL);
-               if (dir) {
-                       const gchar *name;
-                       while ((name = g_dir_read_name(dir))) {
-                               times = g_list_prepend(times, g_strdup(name));
-                       }
-                       g_dir_close(dir);
-               }
-               g_free(path);
-       } else {
-               gchar *data;
-               gsize length;
-               GError *error = NULL;
-
-               char *list_uri = g_strdup_printf("http://mesonet.agron.iastate.edu/data/nexrd2/raw/%s/dir.list", site);
-               GFile *list = g_file_new_for_uri(list_uri);
-               g_file_load_contents(list, NULL, &data, &length, NULL, &error);
-               if (error) {
-                       g_warning("Error loading list for %s: %s", site, error->message);
-                       g_error_free(error);
-               } else {
-                       gchar **lines = g_strsplit(data, "\n", -1);
-                       for (int i = 0; lines[i] && lines[i][0]; i++) {
-                               char **parts = g_strsplit(lines[i], " ", 2);
-                               times = g_list_prepend(times, g_strdup(parts[1]));
-                               g_strfreev(parts);
-                       }
-                       g_strfreev(lines);
-                       g_free(data);
-               }
-
-               g_free(list_uri);
-               g_object_unref(list);
-       }
-
+       gchar *last_time = NULL;
        GRegex *regex = g_regex_new("^[A-Z]{4}_([0-9]{8}_[0-9]{4})$", 0, 0, NULL); // KLSX_20090622_2113
        GMatchInfo *info;
 
@@ -306,15 +272,55 @@ static void update_times(AWeatherRadar *self, AWeatherView *view, char *site, ch
                        g_message("adding time %s", (gchar*)cur->data);
                        gtk_list_store_insert(lstore, &iter, 0);
                        gtk_list_store_set(lstore, &iter, 0, time, -1);
-                       if (last_time)
-                               *last_time = time;
+                       last_time = time;
                }
        }
 
+       AWeatherView *view = aweather_gui_get_view(self->gui);
+       aweather_view_set_time(view, last_time);
+
        g_regex_unref(regex);
        g_list_foreach(times, (GFunc)g_free, NULL);
        g_list_free(times);
 }
+static void update_times_online_cb(char *path, gboolean updated, gpointer _self)
+{
+       GList *times = NULL;
+       gchar *data;
+       gsize length;
+       g_file_get_contents(path, &data, &length, NULL);
+       gchar **lines = g_strsplit(data, "\n", -1);
+       for (int i = 0; lines[i] && lines[i][0]; i++) {
+               char **parts = g_strsplit(lines[i], " ", 2);
+               times = g_list_prepend(times, g_strdup(parts[1]));
+               g_strfreev(parts);
+       }
+       g_strfreev(lines);
+       g_free(data);
+
+       update_times_gtk(_self, times);
+}
+static void update_times(AWeatherRadar *self, AWeatherView *view, char *site)
+{
+       if (aweather_view_get_offline(view)) {
+               GList *times = NULL;
+               gchar *path = g_build_filename(g_get_user_cache_dir(), PACKAGE, "nexrd2", "raw", site, NULL);
+               GDir *dir = g_dir_open(path, 0, NULL);
+               if (dir) {
+                       const gchar *name;
+                       while ((name = g_dir_read_name(dir))) {
+                               times = g_list_prepend(times, g_strdup(name));
+                       }
+                       g_dir_close(dir);
+               }
+               g_free(path);
+               update_times_gtk(self, times);
+       } else {
+               gchar *path = g_strdup_printf("nexrd2/raw/%s/dir.list", site);
+               cache_file(nexrad_base, path, AWEATHER_REFRESH, NULL, update_times_online_cb, self);
+               /* update_times_gtk from update_times_online_cb */
+       }
+}
 
 /*****************
  * ASync helpers *
@@ -405,7 +411,6 @@ static void on_time_changed(AWeatherView *view, const char *time, gpointer _self
        g_debug("AWeatherRadar: on_time_changed - setting time=%s", time);
        // format: http://mesonet.agron.iastate.edu/data/nexrd2/raw/KABR/KABR_20090510_0323
        char *site = aweather_view_get_site(view);
-       char *base = "http://mesonet.agron.iastate.edu/data/";
        char *path = g_strdup_printf("nexrd2/raw/%s/%s_%s", site, site, time);
 
        /* Set up progress bar */
@@ -434,10 +439,10 @@ static void on_time_changed(AWeatherView *view, const char *time, gpointer _self
                self->soup = NULL;
        }
        if (aweather_view_get_offline(view)) 
-               self->soup = cache_file(base, path, AWEATHER_ONCE,
+               self->soup = cache_file(nexrad_base, path, AWEATHER_ONCE,
                                cache_chunk_cb, cache_done_cb, self);
        else 
-               self->soup = cache_file(base, path, AWEATHER_UPDATE,
+               self->soup = cache_file(nexrad_base, path, AWEATHER_UPDATE,
                                cache_chunk_cb, cache_done_cb, self);
        g_free(path);
 }
@@ -446,21 +451,14 @@ static void on_site_changed(AWeatherView *view, char *site, gpointer _self)
 {
        AWeatherRadar *self = AWEATHER_RADAR(_self);
        g_debug("AWeatherRadar: on_site_changed - Loading wsr88d list for %s", site);
-       char *time = NULL;
-       update_times(self, view, site, &time);
-       aweather_view_set_time(view, time);
-
-       g_free(time);
+       update_times(self, view, site), &time;
 }
 
 static void on_refresh(AWeatherView *view, gpointer _self)
 {
        AWeatherRadar *self = AWEATHER_RADAR(_self);
        char *site = aweather_view_get_site(view);
-       char *time = NULL;
-       update_times(self, view, site, &time);
-       aweather_view_set_time(view, time);
-       g_free(time);
+       update_times(self, view, site);
 }
 
 /***********