]> git.street.me.uk Git - andy/viking.git/commitdiff
Add new process stage for acquire methods.
authorRob Norris <rw_norris@hotmail.com>
Thu, 6 Oct 2011 18:09:36 +0000 (19:09 +0100)
committerRob Norris <rw_norris@hotmail.com>
Sun, 11 Dec 2011 20:03:12 +0000 (20:03 +0000)
This is designed to handle the main event of conversion / whatever processing is to be done.
ATM only invoked for the new VIK_DATASOURCE_INTERNAL type.

src/acquire.c
src/acquire.h
src/datasource_bfilter.c
src/datasource_file.c
src/datasource_gc.c
src/datasource_google.c
src/datasource_gps.c
src/datasource_osm.c

index 1a65e91f9f42be58406a0248f910325fef91d3eb..a71df6221c6243b72a83cdcfbfa891a923a0bd4c 100644 (file)
@@ -119,6 +119,7 @@ static void get_from_anything ( w_and_interface_t *wi )
   }
   gdk_threads_leave();
 
+  // TODO consider removing 'type' and make everything run via the specficied process function
   switch ( source_interface->type ) {
   case VIK_DATASOURCE_GPSBABEL_DIRECT:
     result = a_babel_convert_from (vtl, cmd, (BabelStatusFunc) progress_func, extra, w);
@@ -129,6 +130,10 @@ static void get_from_anything ( w_and_interface_t *wi )
   case VIK_DATASOURCE_SHELL_CMD:
     result = a_babel_convert_from_shellcommand ( vtl, cmd, extra, (BabelStatusFunc) progress_func, w);
     break;
+  case VIK_DATASOURCE_INTERNAL:
+    if ( source_interface->process_func )
+      result = source_interface->process_func ( vtl, cmd, extra, (BabelStatusFunc) progress_func, w );
+    break;
   default:
     g_critical("Houston, we've had a problem.");
   }
@@ -224,7 +229,8 @@ static void acquire ( VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikD
   /* for manual dialogs */
   GtkWidget *dialog = NULL;
   GtkWidget *status;
-  gchar *cmd, *extra;
+  gchar *cmd = NULL;
+  gchar *extra = NULL;
   gchar *cmd_off = NULL;
   gchar *extra_off = NULL;
   acq_dialog_widgets_t *w;
@@ -315,8 +321,8 @@ static void acquire ( VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikD
        ( pass_along_data, &cmd, &extra, name_src_track );
 
     g_free ( name_src_track );
-  } else
-    source_interface->get_cmd_string_func ( pass_along_data, &cmd, &extra );
+  } else if ( source_interface->get_cmd_string_func )
+      source_interface->get_cmd_string_func ( pass_along_data, &cmd, &extra );
 
   /* Get data for Off command */
   if ( source_interface->off_func ) {
index d6cd224635295bb9b6e3e4dd1f88ad7c583fe71d..8b8eb929a0bd01e609adcd4b916922025b13655a 100644 (file)
@@ -27,6 +27,7 @@
 #include "vikwindow.h"
 #include "viklayerspanel.h"
 #include "vikviewport.h"
+#include "babel.h"
 
 typedef struct _VikDataSourceInterface VikDataSourceInterface;
 
@@ -42,10 +43,12 @@ typedef struct {
   gpointer user_data;
 } acq_dialog_widgets_t;
 
+/* Direct, URL & Shell types process the results with GPSBabel to create tracks/waypoint */
 typedef enum {
   VIK_DATASOURCE_GPSBABEL_DIRECT,
   VIK_DATASOURCE_URL,
-  VIK_DATASOURCE_SHELL_CMD
+  VIK_DATASOURCE_SHELL_CMD,
+  VIK_DATASOURCE_INTERNAL
 } vik_datasource_type_t;
 
 typedef enum {
@@ -79,6 +82,9 @@ typedef void (*VikDataSourceGetCmdStringFunc) ( gpointer user_data, gchar **babe
 typedef void (*VikDataSourceGetCmdStringFuncWithInput) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype, const gchar *input_file_name );
 typedef void (*VikDataSourceGetCmdStringFuncWithInputInput) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype, const gchar *input_file_name, const gchar *input_track_file_name );
 
+/* The actual function to do stuff - must report success/failure */
+typedef gboolean (*VikDataSourceProcessFunc)  ( gpointer vtl, const gchar *cmd, const gchar *extra, BabelStatusFunc status_cb, acq_dialog_widgets_t *adw );
+
 /* */
 typedef void  (*VikDataSourceProgressFunc)  (gpointer c, gpointer data, acq_dialog_widgets_t *w);
 
@@ -109,6 +115,8 @@ struct _VikDataSourceInterface {
   /* or VikDataSourceGetCmdStringFuncWithInput, if inputtype is not NONE */
   VikDataSourceGetCmdStringFunc get_cmd_string_func; 
 
+  VikDataSourceProcessFunc process_func;
+
   VikDataSourceProgressFunc progress_func;
   VikDataSourceAddProgressWidgetsFunc add_progress_widgets_func;
   VikDataSourceCleanupFunc cleanup_func;
index fb237496296b067ffd3055b229fb3afc6a3c581c..78dbe9c713e41c00dd7a5ef89bf3d040b94459b6 100644 (file)
@@ -66,6 +66,7 @@ VikDataSourceInterface vik_datasource_bfilter_simplify_interface = {
   FALSE, /* keep dialog open after success */
   NULL, NULL, NULL,
   (VikDataSourceGetCmdStringFunc)      datasource_bfilter_simplify_get_cmd_string,
+  (VikDataSourceProcessFunc) NULL,
   NULL, NULL, NULL,
   (VikDataSourceOffFunc) NULL,
 
@@ -101,6 +102,7 @@ VikDataSourceInterface vik_datasource_bfilter_dup_interface = {
   FALSE, /* keep dialog open after success */
   NULL, NULL, NULL,
   (VikDataSourceGetCmdStringFunc)      datasource_bfilter_dup_get_cmd_string,
+  (VikDataSourceProcessFunc) NULL,
   NULL, NULL, NULL,
   (VikDataSourceOffFunc) NULL,
 
@@ -133,6 +135,7 @@ VikDataSourceInterface vik_datasource_bfilter_polygon_interface = {
   FALSE, /* keep dialog open after success */
   NULL, NULL, NULL,
   (VikDataSourceGetCmdStringFunc)      datasource_bfilter_polygon_get_cmd_string,
+  (VikDataSourceProcessFunc) NULL,
   NULL, NULL, NULL,
   (VikDataSourceOffFunc) NULL,
 
@@ -168,6 +171,7 @@ VikDataSourceInterface vik_datasource_bfilter_exclude_polygon_interface = {
   FALSE, /* keep dialog open after success */
   NULL, NULL, NULL,
   (VikDataSourceGetCmdStringFunc)      datasource_bfilter_exclude_polygon_get_cmd_string,
+  (VikDataSourceProcessFunc) NULL,
   NULL, NULL, NULL,
   (VikDataSourceOffFunc) NULL,
 
index 43896bc0cd829a2991de937baadfc553d8c56ea8..1b4daeaeaa0e9b444c26edf8f36081ae857fd8c6 100644 (file)
@@ -67,6 +67,7 @@ VikDataSourceInterface vik_datasource_file_interface = {
   (VikDataSourceCheckExistenceFunc)    NULL,
   (VikDataSourceAddSetupWidgetsFunc)   datasource_file_add_setup_widgets,
   (VikDataSourceGetCmdStringFunc)      datasource_file_get_cmd_string,
+  (VikDataSourceProcessFunc)           NULL,
   (VikDataSourceProgressFunc)          NULL,
   (VikDataSourceAddProgressWidgetsFunc)        NULL,
   (VikDataSourceCleanupFunc)           datasource_file_cleanup,
index 1f68e82f444ec15c79cb5e211e8d677e81e35924..b3b6b2c545aca22ad3121f350f2ca7ad54e65fb6 100644 (file)
@@ -74,6 +74,7 @@ VikDataSourceInterface vik_datasource_gc_interface = {
   (VikDataSourceCheckExistenceFunc)    datasource_gc_check_existence,
   (VikDataSourceAddSetupWidgetsFunc)   datasource_gc_add_setup_widgets,
   (VikDataSourceGetCmdStringFunc)      datasource_gc_get_cmd_string,
+  (VikDataSourceProcessFunc)           NULL,
   (VikDataSourceProgressFunc)          NULL,
   (VikDataSourceAddProgressWidgetsFunc)        NULL,
   (VikDataSourceCleanupFunc)           datasource_gc_cleanup,
index 95d4516a1e577bbf58d3c699804064c219fe21a9..10d4991a73ce7fa7831866a7ab8dd95ef8371713 100644 (file)
@@ -57,6 +57,7 @@ VikDataSourceInterface vik_datasource_google_interface = {
   (VikDataSourceCheckExistenceFunc)    NULL,
   (VikDataSourceAddSetupWidgetsFunc)   datasource_google_add_setup_widgets,
   (VikDataSourceGetCmdStringFunc)      datasource_google_get_cmd_string,
+  (VikDataSourceProcessFunc)           NULL,
   (VikDataSourceProgressFunc)          NULL,
   (VikDataSourceAddProgressWidgetsFunc)        NULL,
   (VikDataSourceCleanupFunc)           datasource_google_cleanup,
index 005902210e6e7d5a423a2326d921dbe7f02b1263..41023e927e686d61f80c7132549831e16da390f1 100644 (file)
@@ -63,6 +63,7 @@ VikDataSourceInterface vik_datasource_gps_interface = {
   (VikDataSourceCheckExistenceFunc)    NULL,
   (VikDataSourceAddSetupWidgetsFunc)   datasource_gps_add_setup_widgets,
   (VikDataSourceGetCmdStringFunc)      datasource_gps_get_cmd_string,
+  (VikDataSourceProcessFunc)           NULL,
   (VikDataSourceProgressFunc)          datasource_gps_progress,
   (VikDataSourceAddProgressWidgetsFunc)        datasource_gps_add_progress_widgets,
   (VikDataSourceCleanupFunc)           datasource_gps_cleanup,
index c7f91fe58334d289390bcb1145fec26f9fffe94e..9315f5c8b84ef31f915035ce826cb76811413d39 100644 (file)
@@ -60,6 +60,7 @@ VikDataSourceInterface vik_datasource_osm_interface = {
   (VikDataSourceCheckExistenceFunc)    NULL,
   (VikDataSourceAddSetupWidgetsFunc)   datasource_osm_add_setup_widgets,
   (VikDataSourceGetCmdStringFunc)      datasource_osm_get_cmd_string,
+  (VikDataSourceProcessFunc)           NULL,
   (VikDataSourceProgressFunc)          NULL,
   (VikDataSourceAddProgressWidgetsFunc)        NULL,
   (VikDataSourceCleanupFunc)           datasource_osm_cleanup,