]> err.no Git - mapper/commitdiff
MapDownload: Small adjustments
authorKaj-Michael Lang <milang@tal.org>
Fri, 1 Aug 2008 11:20:10 +0000 (14:20 +0300)
committerKaj-Michael Lang <milang@tal.org>
Fri, 1 Aug 2008 11:20:10 +0000 (14:20 +0300)
src/map-download.c
src/map-download.h
src/map-repo-manager.c

index 57859122689b721a099f91fcc586030af3fd8167..c890135becac44d02d9a30ee2823e2b5d06beb51 100644 (file)
@@ -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..."));    
index d94c0cb8f1b70e2c37c3b12894d1c391df9b2788..97cf8166547e85b66604e6f183113b518300457f 100644 (file)
 
 #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);
index f307718885c375840057e67e35e43f185b5964f4..fac28e00a13798750ea6a4d0c61ea3257ed679a8 100644 (file)
@@ -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;