X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/ff33b1630f7d02cd797b60f8171135a5dfb53f9f..e8bab170981ff0e1cd572107ca4de122d4aafe8c:/src/babel.h diff --git a/src/babel.h b/src/babel.h index 967eb537..9138afa8 100644 --- a/src/babel.h +++ b/src/babel.h @@ -26,48 +26,92 @@ #include #include "viktrwlayer.h" +#include "download.h" +G_BEGIN_DECLS + +/** + * BabelProgressCode: + * @BABEL_DIAG_OUTPUT: a line of diagnostic output is available. The pointer is to a + * NULL-terminated line of diagnostic output from gpsbabel. + * @BABEL_DONE: gpsbabel finished, or %NULL if no callback is needed. + * + * Used when calling #BabelStatusFunc. + */ typedef enum { BABEL_DIAG_OUTPUT, BABEL_DONE, } BabelProgressCode; +/** + * BabelStatusFunc: + * + * Callback function. + */ typedef void (*BabelStatusFunc)(BabelProgressCode, gpointer, gpointer); -/* - * a_babel_convert modifies data in a trw layer using gpsbabel filters. This routine is synchronous; - * that is, it will block the calling program until the conversion is done. To avoid blocking, call - * this routine from a worker thread. The arguments are as follows: - * - * vt The TRW layer to modify. All data will be deleted, and replaced by what gpsbabel outputs. +/** + * BabelMode: * - * babelargs A string containing gpsbabel command line filter options. No file types or names should - * be specified. - * - * cb A callback function, called with the following status codes: - * BABEL_DIAG_OUTPUT: a line of diagnostic output is available. The pointer is to a - * NUL-terminated line of diagnostic output from gpsbabel. - * BABEL_DIAG_DONE: gpsbabel finished, - * or NULL if no callback is needed. + * Store the Read/Write support offered by gpsbabel for a given format. */ -gboolean a_babel_convert( VikTrwLayer *vt, const char *babelargs, BabelStatusFunc cb, gpointer user_data ); +typedef struct { + unsigned waypointsRead : 1; + unsigned waypointsWrite : 1; + unsigned tracksRead : 1; + unsigned tracksWrite : 1; + unsigned routesRead : 1; + unsigned routesWrite : 1; +} BabelMode; -/* - * a_babel_convert_from loads data into a trw layer from a file, using gpsbabel. This routine is synchronous; - * that is, it will block the calling program until the conversion is done. To avoid blocking, call - * this routine from a worker thread. The arguments are as follows: +/** + * BabelDevice: + * @name: gpsbabel's identifier of the device + * @label: human readable label * - * vt The TRW layer to place data into. Duplicate items will be overwritten. - * - * babelargs A string containing gpsbabel command line options. In addition to any filters, this string - * must include the input file type (-i) option. + * Representation of a supported device. + */ +typedef struct { + BabelMode mode; + gchar *name; + gchar *label; +} BabelDevice; + +/** + * BabelFile: + * @name: gpsbabel's identifier of the format + * @ext: file's extension for this format + * @label: human readable label * - * cb Optional callback function. Same usage as in a_babel_convert. + * Representation of a supported file format. */ -gboolean a_babel_convert_from( VikTrwLayer *vt, const char *babelargs, BabelStatusFunc cb, const char *file, gpointer user_data ); -gboolean a_babel_convert_from_shellcommand ( VikTrwLayer *vt, const char *input_cmd, const char *input_file_type, BabelStatusFunc cb, gpointer user_data ); -gboolean a_babel_convert_from_url ( VikTrwLayer *vt, const char *url, const char *input_type, BabelStatusFunc cb, gpointer user_data ); -gboolean a_babel_convert_to( VikTrwLayer *vt, const char *babelargs, BabelStatusFunc cb, const char *file, gpointer user_data ); +typedef struct { + BabelMode mode; + gchar *name; + gchar *ext; + gchar *label; +} BabelFile; + +GList *a_babel_file_list; +GList *a_babel_device_list; + +void a_babel_foreach_file_with_mode (BabelMode mode, GFunc func, gpointer user_data); +void a_babel_foreach_file_read_any (GFunc func, gpointer user_data); + +gboolean a_babel_convert( VikTrwLayer *vt, const char *babelargs, BabelStatusFunc cb, gpointer user_data, gpointer options ); +gboolean a_babel_convert_from_filter( VikTrwLayer *vt, const char *babelargs, const char *file, const char *babelfilters, BabelStatusFunc cb, gpointer user_data, gpointer options ); +gboolean a_babel_convert_from( VikTrwLayer *vt, const char *babelargs, const char *file, BabelStatusFunc cb, gpointer user_data, gpointer options ); +gboolean a_babel_convert_from_shellcommand ( VikTrwLayer *vt, const char *input_cmd, const char *input_file_type, BabelStatusFunc cb, gpointer user_data, gpointer options ); +gboolean a_babel_convert_from_url_filter ( VikTrwLayer *vt, const char *url, const char *input_type, const char *filter, BabelStatusFunc cb, gpointer user_data, DownloadMapOptions *options ); +gboolean a_babel_convert_from_url ( VikTrwLayer *vt, const char *url, const char *input_type, BabelStatusFunc cb, gpointer user_data, DownloadMapOptions *options ); +gboolean a_babel_convert_from_url_or_shell ( VikTrwLayer *vt, const char *input, const char *input_type, BabelStatusFunc cb, gpointer user_data, DownloadMapOptions *options ); +gboolean a_babel_convert_to( VikTrwLayer *vt, VikTrack *track, const char *babelargs, const char *file, BabelStatusFunc cb, gpointer user_data ); + +void a_babel_init (); +void a_babel_uninit (); + +gboolean a_babel_available (); +G_END_DECLS #endif