]> git.street.me.uk Git - andy/viking.git/blobdiff - src/bingmapsource.c
Minimum GTK+2.14 required for the build.
[andy/viking.git] / src / bingmapsource.c
index c1f1da14accfa9763a7b759d4f3169cd9c1103e6..81ba1fd472838791dd112aa9e737473b8f79bcff 100644 (file)
@@ -46,8 +46,8 @@
 #include <glib/gi18n.h>
 #include <gdk-pixbuf/gdk-pixdata.h>
 #include "globals.h"
 #include <glib/gi18n.h>
 #include <gdk-pixbuf/gdk-pixdata.h>
 #include "globals.h"
-#include "curl_download.h"
 #include "bingmapsource.h"
 #include "bingmapsource.h"
+#include "maputils.h"
 #include "bbox.h"
 #include "background.h"
 #include "icons/icons.h"
 #include "bbox.h"
 #include "background.h"
 #include "icons/icons.h"
@@ -56,7 +56,7 @@
 #define URL_ATTR_FMT "http://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial/0,0?zl=1&mapVersion=v1&key=%s&include=ImageryProviders&output=xml"
 
 static gchar *_get_uri ( VikMapSourceDefault *self, MapCoord *src );
 #define URL_ATTR_FMT "http://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial/0,0?zl=1&mapVersion=v1&key=%s&include=ImageryProviders&output=xml"
 
 static gchar *_get_uri ( VikMapSourceDefault *self, MapCoord *src );
-static void _get_copyright (VikMapSource * self, LatLonBBox bbox, gdouble zoom, void (*fct)(void*,const gchar*), void *data);
+static void _get_copyright (VikMapSource * self, LatLonBBox bbox, gdouble zoom, void (*fct)(VikViewport*,const gchar*), void *data);
 static const GdkPixbuf *_get_logo ( VikMapSource *self );
 static int _load_attributions ( BingMapSource *self );
 static void _async_load_attributions ( BingMapSource *self );
 static const GdkPixbuf *_get_logo ( VikMapSource *self );
 static int _load_attributions ( BingMapSource *self );
 static void _async_load_attributions ( BingMapSource *self );
@@ -232,14 +232,14 @@ _get_logo( VikMapSource *self )
 }
 
 static void
 }
 
 static void
-_get_copyright(VikMapSource * self, LatLonBBox bbox, gdouble zoom, void (*fct)(void*,const gchar*), void *data)
+_get_copyright(VikMapSource * self, LatLonBBox bbox, gdouble zoom, void (*fct)(VikViewport*,const gchar*), void *data)
 {
        g_return_if_fail (BING_IS_MAP_SOURCE(self));
        g_debug("%s: looking for %g %g %g %g at %g", __FUNCTION__, bbox.south, bbox.north, bbox.east, bbox.west, zoom);
 
        BingMapSourcePrivate *priv = BING_MAP_SOURCE_GET_PRIVATE(self);
 
 {
        g_return_if_fail (BING_IS_MAP_SOURCE(self));
        g_debug("%s: looking for %g %g %g %g at %g", __FUNCTION__, bbox.south, bbox.north, bbox.east, bbox.west, zoom);
 
        BingMapSourcePrivate *priv = BING_MAP_SOURCE_GET_PRIVATE(self);
 
-       int level = vik_slippy_map_source_zoom_to_scale (zoom);
+       int level = map_utils_mpp_to_scale (zoom);
 
        /* Loop over all known attributions */
        GList *attribution = priv->attributions;
 
        /* Loop over all known attributions */
        GList *attribution = priv->attributions;
@@ -391,32 +391,12 @@ _parse_file_for_attributions(BingMapSource *self, gchar *filename)
 static int
 _load_attributions ( BingMapSource *self )
 {
 static int
 _load_attributions ( BingMapSource *self )
 {
-       FILE *tmp_file;
-       int tmp_fd;
-       gchar *tmpname;
-       gchar *uri;
        int ret = 0;  /* OK */
 
        BingMapSourcePrivate *priv = BING_MAP_SOURCE_GET_PRIVATE (self);
        int ret = 0;  /* OK */
 
        BingMapSourcePrivate *priv = BING_MAP_SOURCE_GET_PRIVATE (self);
+       gchar *uri = g_strdup_printf(URL_ATTR_FMT, priv->api_key);
 
 
-       if ((tmp_fd = g_file_open_tmp ("vik-bing.XXXXXX", &tmpname, NULL)) == -1) {
-               g_critical(_("couldn't open temp file"));
-               return -1;
-       }
-
-       tmp_file = fdopen(tmp_fd, "r+");
-       uri = g_strdup_printf(URL_ATTR_FMT, priv->api_key);
-
-       /* TODO: curl may not be available */
-       if (curl_download_uri(uri, tmp_file, vik_map_source_default_get_download_options(VIK_MAP_SOURCE_DEFAULT(self)), 0, NULL)) {  /* error */
-               fclose(tmp_file);
-               tmp_file = NULL;
-               ret = -1;
-               goto done;
-       }
-
-       fclose(tmp_file);
-       tmp_file = NULL;
+       gchar *tmpname = a_download_uri_to_tmp_file ( uri, vik_map_source_default_get_download_options(VIK_MAP_SOURCE_DEFAULT(self)) );
 
        g_debug("%s: %s", __FUNCTION__, tmpname);
        if (!_parse_file_for_attributions(self, tmpname)) {
 
        g_debug("%s: %s", __FUNCTION__, tmpname);
        if (!_parse_file_for_attributions(self, tmpname)) {
@@ -439,6 +419,7 @@ _emit_update ( gpointer data )
        vik_layers_panel_emit_update ( VIK_LAYERS_PANEL (data) );
        */
        gdk_threads_leave();
        vik_layers_panel_emit_update ( VIK_LAYERS_PANEL (data) );
        */
        gdk_threads_leave();
+       return 0;
 }
 
 static int
 }
 
 static int