map-download.h \
map-poi.c \
map-poi.h \
+ map-tile-repo.c \
+ map-tile-repo.h \
map-repo.c \
map-repo.h \
map.c \
#include "gpx.h"
#include "filter.h"
#include "dialogs.h"
+#include "map-tile-repo.h"
#define PROXY_PORT (8080)
* 5. view_zoom_steps
*/
gchar *token, *error_check;
+RepoData *rd;
-RepoData *rd = g_new0(RepoData, 1);
+rd=map_tile_repo_new();
/* Parse name. */
token = strsep(&str, "\n\t");
/* Parse download zoom steps. */
token = strsep(&str, "\n\t");
if (!token || !*token || !(rd->dl_zoom_steps = atoi(token)))
- rd->dl_zoom_steps = 2;
+ rd->dl_zoom_steps = 1;
/* Parse view zoom steps. */
token = strsep(&str, "\n\t");
|| (rd->nextable = strtol(token, &error_check, 10), token == str))
rd->nextable = TRUE;
-set_repo_type(rd);
+map_tile_repo_set_type(rd);
return rd;
}
static void
config_default_repo(void)
{
+RepoData *repo;
+
g_assert(gconf_client);
/* We have no repositories - create a default one. */
-RepoData *repo = g_new(RepoData, 1);
+repo=map_tile_repo_new();
/* Get Map Cache Dir. Default is REPO_DEFAULT_CACHE_DIR. */
repo->cache_dir = gconf_client_get_string(gconf_client, GCONF_KEY_MAP_DIR_NAME, NULL);
repo->view_zoom_steps = REPO_DEFAULT_VIEW_ZOOM_STEPS;
repo->double_size = FALSE;
repo->nextable = TRUE;
-set_repo_type(repo);
+map_tile_repo_set_type(repo);
-_repo_list = g_list_append(_repo_list, repo);
+_repo_list=g_list_append(_repo_list, repo);
repo_set_curr(repo);
}
}
g_slist_free(list);
-if (_repo_list == NULL)
+if (_repo_list==NULL)
config_default_repo();
return TRUE;
#include "dialogs.h"
#include "help.h"
#include "map-repo.h"
+#include "map-tile-repo.h"
#define MAP_REPO_LIST_URL "http://www.gnuite.com/nokia770/maemo-mapper/repos.txt"
GtkWidget *chk_zoom_levels[MAX_ZOOM];
};
-void set_repo_type(RepoData * repo)
-{
-if (repo->url && *repo->url) {
- gchar *url = g_utf8_strdown(repo->url, -1);
-
- /* Determine type of repository. */
- if (strstr(url, "service=wms"))
- repo->type = REPOTYPE_WMS;
- else if (strstr(url, "%s"))
- repo->type = REPOTYPE_QUAD_QRST;
- else if (strstr(url, "%0d"))
- repo->type = REPOTYPE_XYZ_INV;
- else if (strstr(url, "%0s"))
- repo->type = REPOTYPE_QUAD_ZERO;
- else
- repo->type = REPOTYPE_XYZ;
-
- g_free(url);
-} else
- repo->type = REPOTYPE_NONE;
-}
-
-gboolean
-repo_make_cache_dir(gchar * name, const gchar * cache_dir, GtkWidget * parent)
+gboolean
+repo_set_curr(RepoData *rd)
{
-if (g_mkdir_with_parents(cache_dir, 0755)) {
- /* Failed to create Map Cache directory. */
+_curr_repo=rd;
+if (map_tile_repo_make_cache_dir(rd)==FALSE) {
gchar buffer[BUFFER_SIZE];
- g_snprintf(buffer, sizeof(buffer), "%s: %s",
- _("Unable to create cache directory for repository"), name);
- popup_error(parent, buffer);
+ g_snprintf(buffer, sizeof(buffer), "%s: %s", _("Unable to create cache directory for repository"), rd->name);
+ popup_error(_window, buffer);
return FALSE;
}
-return g_file_test(cache_dir, G_FILE_TEST_EXISTS);
-}
-
-gboolean
-repo_set_curr(RepoData * rd)
-{
-_curr_repo = rd;
-return repo_make_cache_dir(rd->name, rd->cache_dir, _window);
+return TRUE;
}
static gboolean
{
GtkWidget *dialog;
-dialog = GTK_WIDGET(hildon_file_chooser_dialog_new
- (GTK_WINDOW(browse_info->dialog),
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER));
+dialog = GTK_WIDGET(hildon_file_chooser_dialog_new(GTK_WINDOW(browse_info->dialog), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER));
gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), TRUE);
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), gtk_entry_get_text(GTK_ENTRY(browse_info->txt)));
return TRUE;
}
-g_snprintf(buffer, sizeof(buffer), "%s:\n%s\n",
- _("Confirm delete of repository"),
- gtk_combo_box_get_active_text(GTK_COMBO_BOX(rmi->cmb_repos)));
+g_snprintf(buffer, sizeof(buffer), "%s:\n%s\n", _("Confirm delete of repository"), gtk_combo_box_get_active_text(GTK_COMBO_BOX(rmi->cmb_repos)));
confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), buffer);
if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
for (i = 0, curr = rmi.repo_edits; verified && curr; curr = curr->next, i++) {
RepoEditInfo *rei = curr->data;
gchar *expanded = gnome_vfs_expand_initial_tilde(gtk_entry_get_text(GTK_ENTRY(rei->txt_cache_dir)));
- verified = repo_make_cache_dir(rei->name, expanded, rmi.dialog);
+ verified = map_tile_repo_make_cache_dir(rei);
g_free(expanded);
}
if (!verified) {
rd->view_zoom_steps = hildon_controlbar_get_value(HILDON_CONTROLBAR(rei->num_view_zoom_steps));
rd->double_size = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(rei->chk_double_size));
rd->nextable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(rei->chk_nextable));
- set_repo_type(rd);
+ map_tile_repo_set_type(rd);
_repo_list = g_list_append(_repo_list, rd);
gtk_box_pack_start(GTK_BOX(vbox), hbox = gtk_hbox_new(FALSE, 4), FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), mapman_info.rad_download = gtk_radio_button_new_with_label(NULL, _("Download Maps")), FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), FALSE, FALSE, 0);
- gtk_container_add(GTK_CONTAINER(label), mapman_info.chk_overwrite =
- gtk_check_button_new_with_label(_("Overwrite"))),
- gtk_box_pack_start(GTK_BOX(vbox), mapman_info.rad_delete =
- gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(mapman_info.rad_download), _("Delete Maps")), FALSE, FALSE, 0);
+ mapman_info.chk_overwrite = gtk_check_button_new_with_label(_("Overwrite"));
+ gtk_toggle_button_set_active(mapman_info.chk_overwrite, TRUE);
+ mapman_info.rad_delete = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(mapman_info.rad_download), _("Delete Maps"));
+
+ gtk_container_add(GTK_CONTAINER(label), mapman_info.chk_overwrite);
+ gtk_box_pack_start(GTK_BOX(vbox), mapman_info.rad_delete, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
#ifndef _MAP_REPO_H
#define _MAP_REPO_H
-/** This enumerated type defines the supported types of repositories. */
-typedef enum {
- REPOTYPE_NONE, /* No URL set. */
- REPOTYPE_XYZ, /* x=%d, y=%d, and zoom=%d */
- REPOTYPE_XYZ_INV, /* zoom=%0d, x=%d, y=%d */
- REPOTYPE_QUAD_QRST, /* t=%s (%s = {qrst}*) */
- REPOTYPE_QUAD_ZERO, /* t=%0s (%0s = {0123}*) */
- REPOTYPE_WMS /* "service=wms" */
-} RepoType;
+#include "map-tile-repo.h"
-/** Data regarding a map repository. */
-typedef struct _RepoData RepoData;
-struct _RepoData {
- gchar *name;
- gchar *url;
- gchar *cache_dir;
- guint dl_zoom_steps;
- guint view_zoom_steps;
- gboolean double_size;
- gboolean nextable;
- RepoType type;
- GtkWidget *menu_item;
-};
-
-/** 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;
--- /dev/null
+/*
+ * This file is part of mapper
+ *
+ * Copyright (C) 2007 Kaj-Michael Lang
+ * Copyright (C) 2006-2007 John Costigan.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#include "map-tile-repo.h"
+
+RepoData *
+map_tile_repo_new(void)
+{
+return g_new0(RepoData, 1);
+}
+
+void
+map_tile_repo_free(RepoData *rd)
+{
+g_free(rd);
+}
+
+void
+map_tile_repo_set_type(RepoData *rd)
+{
+if (rd->url && *rd->url) {
+ gchar *url = g_utf8_strdown(rd->url, -1);
+
+ /* Determine type of repository. */
+ if (strstr(url, "service=wms"))
+ rd->type = REPOTYPE_WMS;
+ else if (strstr(url, "%s"))
+ rd->type = REPOTYPE_QUAD_QRST;
+ else if (strstr(url, "%0d"))
+ rd->type = REPOTYPE_XYZ_INV;
+ else if (strstr(url, "%0s"))
+ rd->type = REPOTYPE_QUAD_ZERO;
+ else
+ rd->type = REPOTYPE_XYZ;
+
+ g_free(url);
+} else
+ rd->type = REPOTYPE_NONE;
+}
+
+gboolean
+map_tile_repo_make_cache_dir(RepoData *rd)
+{
+if (g_mkdir_with_parents(rd->cache_dir, 0755))
+ return FALSE;
+return g_file_test(rd->cache_dir, G_FILE_TEST_EXISTS);
+}
+
--- /dev/null
+#ifndef _MAP_TILE_REPO_H
+#define _MAP_TILE_REPO_H
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+/** This enumerated type defines the supported types of repositories. */
+typedef enum {
+ REPOTYPE_NONE, /* No URL set. */
+ REPOTYPE_XYZ, /* x=%d, y=%d, and zoom=%d */
+ REPOTYPE_XYZ_INV, /* zoom=%0d, x=%d, y=%d */
+ REPOTYPE_QUAD_QRST, /* t=%s (%s = {qrst}*) */
+ REPOTYPE_QUAD_ZERO, /* t=%0s (%0s = {0123}*) */
+ REPOTYPE_WMS /* "service=wms" */
+} RepoType;
+
+/** Data regarding a map repository. */
+typedef struct _RepoData RepoData;
+struct _RepoData {
+ gchar *name;
+ gchar *url;
+ gchar *cache_dir;
+ guint dl_zoom_steps;
+ guint view_zoom_steps;
+ gboolean double_size;
+ gboolean nextable;
+ RepoType type;
+ GtkWidget *menu_item;
+};
+
+RepoData *map_tile_repo_new(void);
+void map_tile_repo_free(RepoData *rd);
+void map_tile_repo_set_type(RepoData *rd);
+
+#endif