#include "gpx.h"
#include "map-download.h"
-guint _num_downloads=0;
-guint _curr_download=0;
+static guint _num_downloads=0;
+static guint _curr_download=0;
static gchar *map_construct_url(guint tilex, guint tiley, guint zoom);
if (msg->easy_handle == _autoroute_data.curl_easy) {
/* This is the autoroute download. */
/* Now, parse the autoroute and update the display. */
- if (_autoroute_data.enabled
- && parse_gpx(&_route,
+ if (_autoroute_data.enabled && parse_gpx(&_route,
_autoroute_data.rdl_data.bytes,
_autoroute_data.rdl_data.bytes_read, 0)) {
/* Find the nearest route point, if we're connected. */
if (msg->data.result != CURLE_OK)
g_unlink(pui->dest_str); /* Delete so we try again. */
curl_multi_remove_handle(_curl_multi, msg->easy_handle);
- g_idle_add_full(G_PRIORITY_HIGH_IDLE,
- (GSourceFunc)map_download_idle_refresh, pui, NULL);
+ g_idle_add_full(G_PRIORITY_HIGH_IDLE, (GSourceFunc)map_download_idle_refresh, pui, NULL);
}
}
}
if (pui->retries > 0) {
/* We're not updating - check if file already exists. */
if (g_file_test(pui->dest_str, G_FILE_TEST_EXISTS)) {
- g_idle_add_full(G_PRIORITY_HIGH_IDLE,
- (GSourceFunc)map_download_idle_refresh, pui, NULL);
+ g_idle_add_full(G_PRIORITY_HIGH_IDLE, (GSourceFunc)map_download_idle_refresh, pui, NULL);
continue;
}
}
/* Attempt to open the file for writing. */
- if (!(f = g_fopen(pui->dest_str, "w"))
- && errno == ENOENT) {
+ if (!(f = g_fopen(pui->dest_str, "w")) && errno == ENOENT) {
/* Directory doesn't exist yet - create it, then we'll retry */
gchar buffer[BUFFER_SIZE];
snprintf(buffer, sizeof(buffer), "%s/%u/%u",
curl_multi_add_handle(_curl_multi, curl_easy);
num_transfers++;
} else {
- /* Unable to download file. */
+ /* Unable to open tile file for writing. */
gchar buffer[BUFFER_SIZE];
snprintf(buffer, sizeof(buffer), "%s:\n%s",
_("Failed to open file for writing"),
pui->dest_str);
MACRO_BANNER_SHOW_INFO(_window, buffer);
- g_idle_add_full(G_PRIORITY_HIGH_IDLE,
- (GSourceFunc)map_download_idle_refresh, pui,
- NULL);
+ g_idle_add_full(G_PRIORITY_HIGH_IDLE, (GSourceFunc)map_download_idle_refresh, pui, NULL);
continue;
}
} else if (--deletes_left) {
g_tree_insert(_downloading_tree, pui, pui);
snprintf(buffer, sizeof(buffer), "%s/%u/%u/%u.jpg",
- pui->repo->cache_dir, pui->zoom, pui->tilex,
- pui->tiley);
+ pui->repo->cache_dir, pui->zoom,
+ pui->tilex, pui->tiley);
g_unlink(buffer);
- g_idle_add_full(G_PRIORITY_HIGH_IDLE,
- (GSourceFunc)map_download_idle_refresh,
- pui, NULL);
+ g_idle_add_full(G_PRIORITY_HIGH_IDLE,(GSourceFunc)map_download_idle_refresh, pui, NULL);
} else
break;
}
system_retcode = system(cmd);
if (system_retcode)
- g_printerr("cs2cs returned error code %d\n",
- WEXITSTATUS(system_retcode));
+ g_printerr("cs2cs returned error code %d\n", WEXITSTATUS(system_retcode));
else if (!(in = g_fopen("/tmp/tmpcs2cs", "r")))
g_printerr("Cannot open results of conversion\n");
-else if (5 !=
- fscanf(in, "%lf %lf %s %lf %lf", &lon1, &lat1, cmd, &lon2, &lat2)) {
+else if (5 != fscanf(in, "%lf %lf %s %lf %lf", &lon1, &lat1, cmd, &lon2, &lat2)) {
g_printerr("Wrong conversion\n");
fclose(in);
} else {
/* If zoom has changed since we first put in the request for
* this tile, then we may have to update more than one tile. */
guint tilex, tiley, tilex_end, tiley_end;
- for (tilex = pui->tilex << zoom_diff,
- tilex_end = tilex + (1 << zoom_diff);
- tilex < tilex_end; tilex++) {
- for (tiley = pui->tiley << zoom_diff,
- tiley_end = tiley + (1 << zoom_diff);
- tiley < tiley_end; tiley++) {
+ for (tilex = pui->tilex << zoom_diff, tilex_end = tilex + (1 << zoom_diff); tilex < tilex_end; tilex++) {
+ for (tiley = pui->tiley << zoom_diff, tiley_end = tiley + (1 << zoom_diff); tiley < tiley_end; tiley++) {
if ((tilex - _base_tilex) < BUF_WIDTH_TILES && (tiley - _base_tiley) < BUF_HEIGHT_TILES) {
map_render_tile(tilex, tiley,
((tilex - _base_tilex) << TILE_SIZE_P2),
return FALSE;
} else {
/* No more retries left - something must be wrong. */
- MACRO_BANNER_SHOW_INFO(_window, _("Error in download. Check internet connection"
- " and/or Map Repository URL Format."));
+ MACRO_BANNER_SHOW_INFO(_window, _("Error in download. Check internet connection and/or Map Repository URL Format."));
}
}
#ifdef WITH_HILDON
gtk_widget_destroy(_download_banner);
_download_banner = NULL;
-#else
- gtk_widget_hide(GTK_WIDGET(_progress_item));
#endif
_num_downloads = _curr_download = 0;
-} else
+} else {
hildon_banner_set_fraction(HILDON_BANNER(_download_banner), _curr_download / (double)_num_downloads);
-
+}
return FALSE;
}
_curl_sid = g_timeout_add(100, (GSourceFunc) map_download_timeout, NULL);
if (!_num_downloads++ && !_download_banner) {
- gchar buffer[100];
- g_snprintf(buffer, 100, _("Downloading maps (%d)"), g_tree_nnodes(_pui_tree));
- _download_banner = hildon_banner_show_progress(_window, NULL, buffer);
+ _download_banner = hildon_banner_show_progress(_window, NULL, _("Downloading maps..."));
}
}