* 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..."));
#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;
};
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);
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);
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);
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);
}
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;