X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/28c82d8b28ffaae83acf74f348ddb7f864d0ce58..de2fc9aa9e8db8e0258c8328161c6b5eda176a0a:/src/datasource_gc.c diff --git a/src/datasource_gc.c b/src/datasource_gc.c index 551e19f5..21d653bf 100644 --- a/src/datasource_gc.c +++ b/src/datasource_gc.c @@ -18,15 +18,25 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #ifdef VIK_CONFIG_GEOCACHES #include +#include #include "viking.h" #include "babel.h" #include "gpx.h" #include "acquire.h" +#include "preferences.h" + +/* params will be geocaching.username, geocaching.password */ +/* we have to make sure these don't collide. */ +#define VIKING_GC_PARAMS_GROUP_KEY "geocaching" +#define VIKING_GC_PARAMS_NAMESPACE "geocaching." + typedef struct { GtkWidget *num_spin; @@ -49,8 +59,8 @@ static gchar *datasource_gc_check_existence (); #define METERSPERMILE 1609.344 VikDataSourceInterface vik_datasource_gc_interface = { - "Download Geocaches", - "Geocaching.com Caches", + N_("Download Geocaches"), + N_("Geocaching.com Caches"), VIK_DATASOURCE_SHELL_CMD, VIK_DATASOURCE_ADDTOLAYER, VIK_DATASOURCE_INPUTTYPE_NONE, @@ -64,6 +74,23 @@ VikDataSourceInterface vik_datasource_gc_interface = { (VikDataSourceCleanupFunc) datasource_gc_cleanup }; +static VikLayerParam prefs[] = { + { VIKING_GC_PARAMS_NAMESPACE "username", VIK_LAYER_PARAM_STRING, VIK_LAYER_GROUP_NONE, N_("geocaching.com username:"), VIK_LAYER_WIDGET_ENTRY }, + { VIKING_GC_PARAMS_NAMESPACE "password", VIK_LAYER_PARAM_STRING, VIK_LAYER_GROUP_NONE, N_("geocaching.com password:"), VIK_LAYER_WIDGET_ENTRY }, +}; + +void a_datasource_gc_init() +{ + a_preferences_register_group ( VIKING_GC_PARAMS_GROUP_KEY, "Geocaching" ); + + VikLayerParamData tmp; + tmp.s = "username"; + a_preferences_register(prefs, tmp, VIKING_GC_PARAMS_GROUP_KEY); + tmp.s = "password"; + a_preferences_register(prefs+1, tmp, VIKING_GC_PARAMS_GROUP_KEY); +} + + static gpointer datasource_gc_init ( ) { datasource_gc_widgets_t *widgets = g_malloc(sizeof(*widgets)); @@ -77,7 +104,7 @@ static gchar *datasource_gc_check_existence () g_free(gcget_location); return NULL; } - return g_strdup("Can't find gcget in path! Check that you have installed gcget correctly."); + return g_strdup(_("Can't find gcget in path! Check that you have installed gcget correctly.")); } static void datasource_gc_draw_circle ( datasource_gc_widgets_t *widgets ) @@ -139,9 +166,9 @@ static void datasource_gc_add_setup_widgets ( GtkWidget *dialog, VikViewport *vv struct LatLon ll; gchar *s_ll; - num_label = gtk_label_new ("Max number geocaches:"); + num_label = gtk_label_new (_("Number geocaches:")); widgets->num_spin = gtk_spin_button_new ( GTK_ADJUSTMENT(gtk_adjustment_new( 100, 1, 1000, 10, 20, 50 )), 25, 0 ); - center_label = gtk_label_new ("Centered around:"); + center_label = gtk_label_new (_("Centered around:")); widgets->center_entry = gtk_entry_new(); miles_radius_label = gtk_label_new ("Miles Radius:"); widgets->miles_radius_spin = gtk_spin_button_new ( GTK_ADJUSTMENT(gtk_adjustment_new( 100, 1, 1000, 5, 20, 50 )), 25, 2 ); @@ -173,11 +200,15 @@ static void datasource_gc_add_setup_widgets ( GtkWidget *dialog, VikViewport *vv static void datasource_gc_get_cmd_string ( datasource_gc_widgets_t *widgets, gchar **cmd, gchar **input_file_type ) { gchar *safe_string = g_shell_quote ( gtk_entry_get_text ( GTK_ENTRY(widgets->center_entry) ) ); - *cmd = g_strdup_printf( "gcget %s %d %.2lf", safe_string, + gchar *safe_user = g_shell_quote ( a_preferences_get ( VIKING_GC_PARAMS_NAMESPACE "username")->s ); + gchar *safe_pass = g_shell_quote ( a_preferences_get ( VIKING_GC_PARAMS_NAMESPACE "password")->s ); + *cmd = g_strdup_printf( "gcget -u %s -p -- %s %s %d %.2lf", safe_user, safe_pass, safe_string, gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(widgets->num_spin) ), gtk_spin_button_get_value_as_float ( GTK_SPIN_BUTTON(widgets->miles_radius_spin) ) ); *input_file_type = NULL; g_free ( safe_string ); + g_free ( safe_user ); + g_free ( safe_pass ); } static void datasource_gc_cleanup ( datasource_gc_widgets_t *widgets )