From: Kaj-Michael Lang Date: Fri, 1 Aug 2008 11:20:10 +0000 (+0300) Subject: MapDownload: Small adjustments X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0bc38ab1b7aa3c1602fd7657a6caf26e0841ad91;p=mapper MapDownload: Small adjustments --- diff --git a/src/map-download.c b/src/map-download.c index 5785912..c890135 100644 --- a/src/map-download.c +++ b/src/map-download.c @@ -447,34 +447,36 @@ return FALSE; * downloading the map, then this method does nothing. */ void -map_initiate_download(guint tilex, guint tiley, guint zoom, gint retries) +map_download(RepoData *repo, guint tilex, guint tiley, guint zoom, gint retries) { ProgressUpdateInfo *pui; iap_connect(); -pui = g_slice_new(ProgressUpdateInfo); -pui->tilex = tilex; -pui->tiley = tiley; -pui->zoom = zoom; -pui->priority = 1; +g_return_if_fail(repo); + +pui=g_slice_new(ProgressUpdateInfo); +pui->tilex=tilex; +pui->tiley=tiley; +pui->zoom=zoom; +pui->priority=1; if (!retries) - pui->priority = -pui->priority; /* "Negative" makes them lowest pri. */ -pui->retries = retries; -pui->repo = _curr_repo; + pui->priority=-pui->priority; /* "Negative" makes them lowest pri. */ +pui->retries=retries; +pui->repo=repo; if (g_tree_lookup(pui_tree, pui) || g_tree_lookup(downloading_tree, pui)) { /* Already downloading. */ g_slice_free(ProgressUpdateInfo, pui); return; } -pui->src_str = NULL; -pui->dest_str = NULL; -pui->file = NULL; +pui->src_str=NULL; +pui->dest_str=NULL; +pui->file=NULL; g_tree_insert(pui_tree, pui, pui); if (iap_is_connected() && !_curl_sid) - _curl_sid = g_timeout_add(100, (GSourceFunc) map_download_timeout, NULL); + _curl_sid=g_timeout_add(100, (GSourceFunc)map_download_timeout, NULL); if (!_num_downloads++) gtk_progress_bar_set_text(_progress_item, _("Downloading maps...")); diff --git a/src/map-download.h b/src/map-download.h index d94c0cb..97cf816 100644 --- a/src/map-download.h +++ b/src/map-download.h @@ -10,11 +10,15 @@ #define INITIAL_DOWNLOAD_RETRIES (3) -/** The Source ID of the CURL Multi Download timeout. */ +/** + * The Source ID of the CURL Multi Download timeout. + */ guint _curl_sid; CURLM *_curl_multi; -/** Data used during the asynchronous progress update phase of automatic map downloading. */ +/** + * Data used during the asynchronous progress update phase of automatic map downloading. + */ typedef struct _ProgressUpdateInfo ProgressUpdateInfo; struct _ProgressUpdateInfo { gchar *src_str; @@ -27,7 +31,7 @@ struct _ProgressUpdateInfo { }; void map_download_init(void); -void map_initiate_download(guint tilex, guint tiley, guint zoom, gint retries); +void map_download(RepoData *repo, guint tilex, guint tiley, guint zoom, gint retries); gboolean map_download_stop(void); gboolean map_download_timeout(); gboolean map_download_idle_refresh(ProgressUpdateInfo * pui); diff --git a/src/map-repo-manager.c b/src/map-repo-manager.c index f307718..fac28e0 100644 --- a/src/map-repo-manager.c +++ b/src/map-repo-manager.c @@ -557,6 +557,7 @@ if (start_unity > end_unity) { for (i = 0; i < _curr_repo->max_zoom; i++) { if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info->chk_zoom_levels[i]))) { guint start_tilex, start_tiley, end_tilex, end_tiley; + start_tilex = gtk_map_unit2ztile(start_unitx, i); start_tiley = gtk_map_unit2ztile(start_unity, i); end_tilex = gtk_map_unit2ztile(end_unitx, i); @@ -582,6 +583,7 @@ for (i = 0; i < _curr_repo->max_zoom; i++) { if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info->chk_zoom_levels[i]))) { guint start_tilex, start_tiley, end_tilex, end_tiley; guint tilex, tiley; + start_tilex = gtk_map_unit2ztile(start_unitx, i); start_tiley = gtk_map_unit2ztile(start_unity, i); end_tilex = gtk_map_unit2ztile(end_unitx, i); @@ -589,8 +591,7 @@ for (i = 0; i < _curr_repo->max_zoom; i++) { for (tiley = start_tiley; tiley <= end_tiley; tiley++) for (tilex = start_tilex; tilex <= end_tilex; tilex++) - map_initiate_download(tilex, tiley, i, is_deleting ? 0 : (is_overwriting ? - -INITIAL_DOWNLOAD_RETRIES : INITIAL_DOWNLOAD_RETRIES)); + map_download(_curr_repo, tilex, tiley, i, is_deleting ? 0 : (is_overwriting ? -INITIAL_DOWNLOAD_RETRIES : INITIAL_DOWNLOAD_RETRIES)); } } gtk_widget_destroy(confirm); @@ -669,7 +670,7 @@ for (i = 0; i < _curr_repo->max_zoom; i++) { } for (x = minx; x <= maxx; x++) for (y = miny; y <= maxy; y++) - map_initiate_download(x, y, i, is_deleting ? 0 + map_download(_curr_repo, x, y, i, is_deleting ? 0 : (is_overwriting ? -INITIAL_DOWNLOAD_RETRIES : INITIAL_DOWNLOAD_RETRIES)); prev_tilex = tilex; prev_tiley = tiley;