/* control-atlas.c * * Copyright 2008 OpenMoko, Inc. * Authored by Chia-I Wu * * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include "diversity-control.h" static gboolean control_atlas_list_sources(DiversityAtlas *atlas, gchar ***OUT_sources, GError **error); static gboolean control_atlas_set_source(DiversityAtlas *atlas, const gchar *IN_source, GError **error); static gboolean control_atlas_get_source(DiversityAtlas *atlas, gchar **OUT_source, GError **error); static gboolean control_atlas_list_levels(DiversityAtlas *atlas, GArray **OUT_levels, GError **error); static gboolean control_atlas_set_level(DiversityAtlas *atlas, gint IN_level, GError **error); static gboolean control_atlas_get_level(DiversityAtlas *atlas, gint *OUT_level, GError **error); static gboolean control_atlas_get_tile_size(DiversityAtlas *atlas, gint *OUT_width, gint *OUT_height, GError **error); static gboolean control_atlas_get_atlas_coord(DiversityAtlas *atlas, gdouble IN_lon, gdouble IN_lat, gdouble *OUT_x, gdouble *OUT_y, GError **error); static gboolean control_atlas_get_world_coord(DiversityAtlas *atlas, gdouble IN_x, gdouble IN_y, gdouble *OUT_lon, gdouble *OUT_lat, GError **error); static gboolean control_atlas_get_uri(DiversityAtlas *atlas, gint IN_x, gint IN_y, gchar **OUT_uri, GError **error); static gboolean control_atlas_submit_tile(DiversityAtlas *atlas, gint IN_x, gint IN_y, gboolean IN_force, guint *OUT_tile, GError **error); static gboolean control_atlas_cancel_tile(DiversityAtlas *atlas, guint IN_tile, GError **error); static gboolean control_atlas_get_path(DiversityAtlas *atlas, gchar **OUT_path, GError **error); #include "control-atlas-glue.h" static gboolean control_atlas_list_sources(DiversityAtlas *atlas, gchar ***OUT_sources, GError **error) { gchar **strv; strv = (gchar **) diversity_atlas_list_sources(atlas); *OUT_sources = g_strdupv(strv); return TRUE; } static gboolean control_atlas_set_source(DiversityAtlas *atlas, const gchar *IN_source, GError **error) { diversity_atlas_set_source(atlas, IN_source); return TRUE; } static gboolean control_atlas_get_source(DiversityAtlas *atlas, gchar **OUT_source, GError **error) { const gchar *p; p = diversity_atlas_get_source(atlas); *OUT_source = g_strdup(p); return TRUE; } static gboolean control_atlas_list_levels(DiversityAtlas *atlas, GArray **OUT_levels, GError **error) { GArray *array; const guint *levels; gint size; levels = diversity_atlas_list_levels(atlas, &size); if (!levels) size = 0; array = g_array_sized_new(FALSE, FALSE, sizeof(guint), size); if (size) g_array_append_vals(array, levels, size); *OUT_levels = array; return TRUE; } static gboolean control_atlas_set_level(DiversityAtlas *atlas, gint IN_level, GError **error) { diversity_atlas_set_level(atlas, IN_level); return TRUE; } static gboolean control_atlas_get_level(DiversityAtlas *atlas, gint *OUT_level, GError **error) { *OUT_level = diversity_atlas_get_level(atlas); return TRUE; } static gboolean control_atlas_get_tile_size(DiversityAtlas *atlas, gint *OUT_width, gint *OUT_height, GError **error) { diversity_atlas_get_tile_size(atlas, OUT_width, OUT_height); return TRUE; } static gboolean control_atlas_get_atlas_coord(DiversityAtlas *atlas, gdouble IN_lon, gdouble IN_lat, gdouble *OUT_x, gdouble *OUT_y, GError **error) { diversity_atlas_get_atlas_coord(atlas, IN_lon, IN_lat, OUT_x, OUT_y); return TRUE; } static gboolean control_atlas_get_world_coord(DiversityAtlas *atlas, gdouble IN_x, gdouble IN_y, gdouble *OUT_lon, gdouble *OUT_lat, GError **error) { diversity_atlas_get_atlas_coord(atlas, IN_x, IN_y, OUT_lon, OUT_lat); return TRUE; } static gboolean control_atlas_get_uri(DiversityAtlas *atlas, gint IN_x, gint IN_y, gchar **OUT_uri, GError **error) { gchar *uri; uri = diversity_atlas_get_uri(atlas, IN_x, IN_y); *OUT_uri = uri; return TRUE; } static gboolean control_atlas_submit_tile(DiversityAtlas *atlas, gint IN_x, gint IN_y, gboolean IN_force, guint *OUT_tile, GError **error) { guint tile; tile = diversity_atlas_submit_tile(atlas, IN_x, IN_y, IN_force); if (!tile) { g_set_error(error, DIVERSITY_CONTROL_ERROR, 0, "failed to get tile(%d, %d)", IN_x, IN_y); return FALSE; } *OUT_tile = tile; return TRUE; } static gboolean control_atlas_cancel_tile(DiversityAtlas *atlas, guint IN_tile, GError **error) { diversity_atlas_cancel_tile(atlas, IN_tile); return TRUE; } static gboolean control_atlas_get_path(DiversityAtlas *atlas, gchar **OUT_path, GError **error) { const gchar *path; path = diversity_atlas_get_path(atlas); *OUT_path = g_strdup(path); return TRUE; }