]> git.street.me.uk Git - andy/viking.git/blobdiff - src/vikdemlayer.c
Split background threads into two pools.
[andy/viking.git] / src / vikdemlayer.c
index cae46a4e87cf33b177e734dd661d726d6a15c792..305caafe2c770358db59f21b7f7e01135545960e 100644 (file)
@@ -424,7 +424,8 @@ gboolean dem_layer_set_param ( VikDEMLayer *vdl, guint16 id, VikLayerParamData d
         dltd->vdl = vdl;
         dltd->vdl->files = data.sl;
 
-        a_background_thread ( VIK_GTK_WINDOW_FROM_WIDGET(vp),
+        a_background_thread ( BACKGROUND_POOL_LOCAL,
+                              VIK_GTK_WINDOW_FROM_WIDGET(vp),
                               _("DEM Loading"),
                               (vik_thr_func) dem_layer_load_list_thread,
                               dltd,
@@ -953,7 +954,26 @@ static void srtm_dem_download_thread ( DEMDownloadParams *p, gpointer threaddata
                ABS(intlon) );
 
   static DownloadMapOptions options = { FALSE, FALSE, NULL, 0, a_check_map_file, NULL, NULL };
-  a_http_download_get_url ( SRTM_HTTP_SITE, src_fn, p->dest, &options, NULL );
+  DownloadResult_t result = a_http_download_get_url ( SRTM_HTTP_SITE, src_fn, p->dest, &options, NULL );
+  switch ( result ) {
+    case DOWNLOAD_CONTENT_ERROR:
+    case DOWNLOAD_HTTP_ERROR: {
+      gchar *msg = g_strdup_printf ( _("DEM download failure for %f, %f"), p->lat, p->lon );
+      vik_window_statusbar_update ( (VikWindow*)VIK_GTK_WINDOW_FROM_LAYER(p->vdl), msg, VIK_STATUSBAR_INFO );
+      g_free ( msg );
+      break;
+    }
+    case DOWNLOAD_FILE_WRITE_ERROR: {
+      gchar *msg = g_strdup_printf ( _("DEM write failure for %s"), p->dest );
+      vik_window_statusbar_update ( (VikWindow*)VIK_GTK_WINDOW_FROM_LAYER(p->vdl), msg, VIK_STATUSBAR_INFO );
+      g_free ( msg );
+      break;
+    }
+    case DOWNLOAD_SUCCESS:
+    case DOWNLOAD_NOT_REQUIRED:
+    default:
+      break;
+  }
   g_free ( src_fn );
 }
 
@@ -1160,7 +1180,7 @@ static void dem_download_thread ( DEMDownloadParams *p, gpointer threaddata )
 
 static void free_dem_download_params ( DEMDownloadParams *p )
 {
-  g_mutex_free ( p->mutex );
+  vik_mutex_free ( p->mutex );
   g_free ( p->dest );
   g_free ( p );
 }
@@ -1263,11 +1283,12 @@ static gboolean dem_layer_download_release ( VikDEMLayer *vdl, GdkEventButton *e
       p->lat = ll.lat;
       p->lon = ll.lon;
       p->vdl = vdl;
-      p->mutex = g_mutex_new();
+      p->mutex = vik_mutex_new();
       p->source = vdl->source;
       g_object_weak_ref(G_OBJECT(p->vdl), weak_ref_cb, p );
 
-      a_background_thread ( VIK_GTK_WINDOW_FROM_LAYER(vdl), tmp,
+      a_background_thread ( BACKGROUND_POOL_REMOTE,
+                            VIK_GTK_WINDOW_FROM_LAYER(vdl), tmp,
                             (vik_thr_func) dem_download_thread, p,
                             (vik_thr_free_func) free_dem_download_params, NULL, 1 );