]> git.street.me.uk Git - andy/viking.git/blobdiff - src/vikslippymapsource.c
Add and use preference for speed units.
[andy/viking.git] / src / vikslippymapsource.c
index 44bf8b3174c8e50997f399d42917174ae7a02dc9..2c87804733bf42f408a1cc0f5b99dc02e532577e 100644 (file)
@@ -29,7 +29,9 @@
 
 static gboolean _coord_to_mapcoord ( VikMapSource *self, const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest );
 static void _mapcoord_to_center_coord ( VikMapSource *self, MapCoord *src, VikCoord *dest );
 
 static gboolean _coord_to_mapcoord ( VikMapSource *self, const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest );
 static void _mapcoord_to_center_coord ( VikMapSource *self, MapCoord *src, VikCoord *dest );
-static int _download ( VikMapSource *self, MapCoord *src, const gchar *dest_fn );
+static int _download ( VikMapSource *self, MapCoord *src, const gchar *dest_fn, void *handle );
+static void * _download_handle_init ( VikMapSource *self);
+static void _download_handle_cleanup ( VikMapSource *self, void *handle);
 static gboolean _supports_if_modified_since (VikMapSource *self );
 
 static gchar *_get_uri( VikSlippyMapSource *self, MapCoord *src );
 static gboolean _supports_if_modified_since (VikMapSource *self );
 
 static gchar *_get_uri( VikSlippyMapSource *self, MapCoord *src );
@@ -71,7 +73,7 @@ vik_slippy_map_source_init (VikSlippyMapSource *self)
   priv->options.referer = NULL;
   priv->options.follow_location = 0;
   priv->options.check_file = a_check_map_file;
   priv->options.referer = NULL;
   priv->options.follow_location = 0;
   priv->options.check_file = a_check_map_file;
-  priv->options.check_file_server_time = 0;
+  priv->options.check_file_server_time = FALSE;
 
   g_object_set (G_OBJECT (self),
                 "tilesize-x", 256,
 
   g_object_set (G_OBJECT (self),
                 "tilesize-x", 256,
@@ -127,7 +129,7 @@ vik_slippy_map_source_set_property (GObject      *object,
       break;
 
     case PROP_CHECK_FILE_SERVER_TIME:
       break;
 
     case PROP_CHECK_FILE_SERVER_TIME:
-      priv->options.check_file_server_time = g_value_get_uint (value);
+      priv->options.check_file_server_time = g_value_get_boolean (value);
       break;
 
     default:
       break;
 
     default:
@@ -165,7 +167,7 @@ vik_slippy_map_source_get_property (GObject    *object,
       break;
 
     case PROP_CHECK_FILE_SERVER_TIME:
       break;
 
     case PROP_CHECK_FILE_SERVER_TIME:
-      g_value_set_uint (value, priv->options.check_file_server_time);
+      g_value_set_boolean (value, priv->options.check_file_server_time);
       break;
          
     default:
       break;
          
     default:
@@ -189,6 +191,8 @@ vik_slippy_map_source_class_init (VikSlippyMapSourceClass *klass)
        parent_class->coord_to_mapcoord =        _coord_to_mapcoord;
        parent_class->mapcoord_to_center_coord = _mapcoord_to_center_coord;
        parent_class->download =                 _download;
        parent_class->coord_to_mapcoord =        _coord_to_mapcoord;
        parent_class->mapcoord_to_center_coord = _mapcoord_to_center_coord;
        parent_class->download =                 _download;
+       parent_class->download_handle_init =     _download_handle_init;
+       parent_class->download_handle_cleanup =  _download_handle_cleanup;
        parent_class->supports_if_modified_since = _supports_if_modified_since;
        
        /* Default implementation of methods */
        parent_class->supports_if_modified_since = _supports_if_modified_since;
        
        /* Default implementation of methods */
@@ -226,13 +230,11 @@ vik_slippy_map_source_class_init (VikSlippyMapSourceClass *klass)
                                G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
        g_object_class_install_property (object_class, PROP_FOLLOW_LOCATION, pspec);
        
                                G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
        g_object_class_install_property (object_class, PROP_FOLLOW_LOCATION, pspec);
        
-       pspec = g_param_spec_uint ("check-file-server-time",
-                                  "Check file server time",
-                               "Age of current cache before redownloading tile",
-                               0  /* minimum value */,
-                               G_MAXUINT16 /* maximum value */,
-                               0  /* default value */,
-                               G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
+       pspec = g_param_spec_boolean ("check-file-server-time",
+                                     "Check file server time",
+                                  "Age of current cache before redownloading tile",
+                                  FALSE  /* default value */,
+                                  G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
        g_object_class_install_property (object_class, PROP_CHECK_FILE_SERVER_TIME, pspec);
 
        g_type_class_add_private (klass, sizeof (VikSlippyMapSourcePrivate));
        g_object_class_install_property (object_class, PROP_CHECK_FILE_SERVER_TIME, pspec);
 
        g_type_class_add_private (klass, sizeof (VikSlippyMapSourcePrivate));
@@ -304,9 +306,7 @@ _supports_if_modified_since (VikMapSource *self)
        
     VikSlippyMapSourcePrivate *priv = VIK_SLIPPY_MAP_SOURCE_PRIVATE(self);
        
        
     VikSlippyMapSourcePrivate *priv = VIK_SLIPPY_MAP_SOURCE_PRIVATE(self);
        
-       g_debug ("%s: priv->options.check_file_server_time = %d", __FUNCTION__, priv->options.check_file_server_time);
-       
-       return priv->options.check_file_server_time != 0;
+       return priv->options.check_file_server_time;
 }
 static gboolean
 _coord_to_mapcoord ( VikMapSource *self, const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest )
 }
 static gboolean
 _coord_to_mapcoord ( VikMapSource *self, const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest )
@@ -337,18 +337,31 @@ _mapcoord_to_center_coord ( VikMapSource *self, MapCoord *src, VikCoord *dest )
 }
 
 static int
 }
 
 static int
-_download ( VikMapSource *self, MapCoord *src, const gchar *dest_fn )
+_download ( VikMapSource *self, MapCoord *src, const gchar *dest_fn, void *handle )
 {
    int res;
    gchar *uri = vik_slippy_map_source_get_uri(VIK_SLIPPY_MAP_SOURCE(self), src);
    gchar *host = vik_slippy_map_source_get_hostname(VIK_SLIPPY_MAP_SOURCE(self));
    DownloadOptions *options = vik_slippy_map_source_get_download_options(VIK_SLIPPY_MAP_SOURCE(self));
 {
    int res;
    gchar *uri = vik_slippy_map_source_get_uri(VIK_SLIPPY_MAP_SOURCE(self), src);
    gchar *host = vik_slippy_map_source_get_hostname(VIK_SLIPPY_MAP_SOURCE(self));
    DownloadOptions *options = vik_slippy_map_source_get_download_options(VIK_SLIPPY_MAP_SOURCE(self));
-   res = a_http_download_get_url ( host, uri, dest_fn, options );
+   res = a_http_download_get_url ( host, uri, dest_fn, options, handle );
    g_free ( uri );
    g_free ( host );
    return res;
 }
 
    g_free ( uri );
    g_free ( host );
    return res;
 }
 
+static void *
+_download_handle_init ( VikMapSource *self )
+{
+   return a_download_handle_init ();
+}
+
+
+static void
+_download_handle_cleanup ( VikMapSource *self, void *handle )
+{
+   return a_download_handle_cleanup ( handle );
+}
+
 static gchar *
 _get_uri( VikSlippyMapSource *self, MapCoord *src )
 {
 static gchar *
 _get_uri( VikSlippyMapSource *self, MapCoord *src )
 {