return TRUE;
}
-RepoData *
-config_parse_repo(gchar * str)
-{
- /* Parse each part of a repo, delimited by newline characters:
- * 1. name
- * 2. url
- * 3. cache_dir
- * 4. dl_zoom_steps
- * 5. view_zoom_steps
- */
-gchar *token, *error_check;
-RepoData *rd;
-
-rd=map_tile_repo_new();
-
-/* Parse name. */
-token = strsep(&str, "\n\t");
-if (token)
- rd->name = g_strdup(token);
-
-/* Parse URL format. */
-token = strsep(&str, "\n\t");
-if (token)
- rd->url = g_strdup(token);
-
-/* Parse cache dir. */
-token = strsep(&str, "\n\t");
-if (token)
- rd->cache_dir = gnome_vfs_expand_initial_tilde(token);
-
-/* Parse download zoom steps. */
-token = strsep(&str, "\n\t");
-if (!token || !*token || !(rd->dl_zoom_steps = atoi(token)))
- rd->dl_zoom_steps = 1;
-
-/* Parse view zoom steps. */
-token = strsep(&str, "\n\t");
-if (!token || !*token || !(rd->view_zoom_steps = atoi(token)))
- rd->view_zoom_steps = 1;
-
-/* Parse double-size. */
-token = strsep(&str, "\n\t");
-if (token)
- rd->double_size = atoi(token); /* Default is zero (FALSE) */
-
-/* Parse next-able. */
-token = strsep(&str, "\n\t");
-if (!token || !*token
- || (rd->nextable = strtol(token, &error_check, 10), token == str))
- rd->nextable = TRUE;
-
-map_tile_repo_set_type(rd);
-return rd;
-}
-
static void
config_default_repo(void)
{
list = gconf_client_get_list(gconf_client, GCONF_KEY_REPOSITORIES, GCONF_VALUE_STRING, NULL);
for (curr = list; curr != NULL; curr = curr->next) {
- RepoData *rd = config_parse_repo(curr->data);
+ RepoData *rd = map_tile_repo_new_from_string(curr->data);
_repo_list = g_list_append(_repo_list, rd);
if (!curr_repo_index--)
repo_set_curr(rd);
/* Get repo config file from www.gnuite.com. */
if (GNOME_VFS_OK != (vfs_result = gnome_vfs_read_entire_file(MAP_REPO_LIST_URL, &size, &bytes))) {
- popup_error(rmi->dialog,
- _("An error occurred while retrieving the repositories. "
- "The web service may be temporarily down."));
+ popup_error(rmi->dialog, _("An error occurred while retrieving the repositories. The web service may be temporarily down."));
g_printerr("Error while download repositories: %s\n", gnome_vfs_result_to_string(vfs_result));
} else {
- /* Parse each line as a reposotory. */
+ /* Parse each line as a repository. */
for (head = bytes; head && *head; head = tail) {
RepoData *rd;
RepoEditInfo *rei;
tail = strchr(head, '\n');
*tail++ = '\0';
- rd = config_parse_repo(head);
+ rd = map_tile_repo_new_from_string(head);
rei = repoman_dialog_add_repo(rmi, g_strdup(rd->name));
/* Initialize fields with data from the RepoData object. */
gtk_entry_set_text(GTK_ENTRY(rei->txt_url), rd->url);
return g_new0(RepoData, 1);
}
+RepoData *
+map_tile_repo_new_from_string(gchar *str)
+{
+gchar *token, *error_check;
+RepoData *rd;
+
+/* Parse each part of a repo, delimited by newline characters:
+ * 1. name
+ * 2. url
+ * 3. cache_dir
+ * 4. dl_zoom_steps
+ * 5. view_zoom_steps
+ */
+
+rd=map_tile_repo_new();
+
+/* Parse name. */
+token = strsep(&str, "\n\t");
+if (token)
+ rd->name = g_strdup(token);
+
+/* Parse URL format. */
+token = strsep(&str, "\n\t");
+if (token)
+ rd->url = g_strdup(token);
+
+/* Parse cache dir. */
+token = strsep(&str, "\n\t");
+if (token)
+ rd->cache_dir = gnome_vfs_expand_initial_tilde(token);
+
+/* Parse download zoom steps. */
+token = strsep(&str, "\n\t");
+if (!token || !*token || !(rd->dl_zoom_steps = atoi(token)))
+ rd->dl_zoom_steps = 1;
+
+/* Parse view zoom steps. */
+token = strsep(&str, "\n\t");
+if (!token || !*token || !(rd->view_zoom_steps = atoi(token)))
+ rd->view_zoom_steps = 1;
+
+/* Parse double-size. */
+token = strsep(&str, "\n\t");
+if (token)
+ rd->double_size = atoi(token); /* Default is zero (FALSE) */
+
+/* Parse next-able. */
+token = strsep(&str, "\n\t");
+if (!token || !*token || (rd->nextable = strtol(token, &error_check, 10), token == str))
+ rd->nextable = TRUE;
+
+map_tile_repo_set_type(rd);
+return rd;
+}
+
+
void
map_tile_repo_free(RepoData *rd)
{
+if (rd->name)
+ g_free(rd->name);
+if (rd->url)
+ g_free(rd->url);
+if (rd->cache_dir)
+ g_free(rd->cache_dir);
+
g_free(rd);
}
};
RepoData *map_tile_repo_new(void);
+RepoData *map_tile_repo_new_from_string(gchar *str);
void map_tile_repo_free(RepoData *rd);
void map_tile_repo_set_type(RepoData *rd);