diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | libdivecomputer.h | 3 | ||||
-rw-r--r-- | qt-ui/downloadfromdivecomputer.cpp | 5 | ||||
-rw-r--r-- | uemis-downloader.c | 19 |
4 files changed, 19 insertions, 10 deletions
@@ -70,6 +70,8 @@ SOURCES = \ sha1.c \ statistics.c \ time.c \ + uemis.c \ + uemis-downloader.c \ libdivecomputer.c \ qt-gui.cpp \ qthelper.cpp \ diff --git a/libdivecomputer.h b/libdivecomputer.h index 3cc8bd4b3..4bb0239e9 100644 --- a/libdivecomputer.h +++ b/libdivecomputer.h @@ -28,6 +28,7 @@ typedef struct device_data_t { } device_data_t; const char *do_libdivecomputer_import(device_data_t *data); +char *do_uemis_import(const char *mountpath, short force_download); extern int import_thread_cancelled; extern const char *progress_bar_text; @@ -37,4 +38,4 @@ extern double progress_bar_fraction; } #endif -#endif
\ No newline at end of file +#endif diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index 37ca2775b..f3cd45c71 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -183,7 +183,10 @@ DownloadThread::DownloadThread(device_data_t* data): data(data) void DownloadThread::run() { DownloadFromDCWidget *dfdcw = DownloadFromDCWidget::instance(); - do_libdivecomputer_import(data); + if (!strcmp(data->vendor, "Uemis")) + do_uemis_import(data->devname, data->force_download); + else + do_libdivecomputer_import(data); process_dives(TRUE, dfdcw->preferDownloaded()); dfdcw->stoppedDownloading(); } diff --git a/uemis-downloader.c b/uemis-downloader.c index 53d4f6876..ace806f68 100644 --- a/uemis-downloader.c +++ b/uemis-downloader.c @@ -19,12 +19,14 @@ #include <string.h> #include <glib/gi18n.h> +#include "libdivecomputer.h" #include "uemis.h" #include "dive.h" #include "divelist.h" #include "display.h" +#if USE_GTK_UI #include "display-gtk.h" - +#endif #define ERR_FS_ALMOST_FULL N_("Uemis Zurich: File System is almost full\nDisconnect/reconnect the dive computer\nand click \'Retry\'") #define ERR_FS_FULL N_("Uemis Zurich: File System is full\nDisconnect/reconnect the dive computer\nand try again") #define ERR_FS_SHORT_WRITE N_("Short write to req.txt file\nIs the Uemis Zurich plugged in correctly?") @@ -49,14 +51,17 @@ static int number_of_files; static char *mbuf = NULL; static int mbuf_size = 0; +#if USE_GTK_UI struct argument_block { const char *mountpath; progressbar_t *progress; gboolean force_download; }; +#endif static int nr_divespots = 0; +#if USE_GTK_UI static int import_thread_done = 0, import_thread_cancelled; static const char *progress_bar_text = ""; static double progress_bar_fraction = 0.0; @@ -73,6 +78,7 @@ static GError *error(const char *fmt, ...) va_end(args); return error; } +#endif /* helper function to parse the Uemis data structures */ static void uemis_ts(char *buffer, void *_when) @@ -752,9 +758,8 @@ static char *uemis_get_divenr(char *deviceidstr) return strdup(divenr); } -static char *do_uemis_download(struct argument_block *args) +char *do_uemis_import(const char *mountpath, short force_download) { - const char *mountpath = args->mountpath; char *newmax = NULL; int start, end, i, offset; uint32_t deviceidnr; @@ -788,7 +793,7 @@ static char *do_uemis_download(struct argument_block *args) param_buff[1] = "notempty"; /* if we have an empty divelist or force it, then we start downloading from the * first dive on the Uemis; otherwise check which was the last dive downloaded */ - if (!args->force_download && dive_table.nr > 0) + if (force_download && dive_table.nr > 0) newmax = uemis_get_divenr(deviceid); else newmax = strdup("0"); @@ -881,6 +886,7 @@ bail: return result; } +#if USE_GTK_UI static void *pthread_wrapper(void *_data) { struct argument_block *args = _data; @@ -922,18 +928,14 @@ GError *uemis_download(const char *mountpath, progressbar_t *progress, if (!import_thread_cancelled) { int result; g_timeout_add(100, timeout_func, dialog); -#if USE_GTK_UI update_progressbar(args.progress, progress_bar_fraction); update_progressbar_text(args.progress, progress_bar_text); -#endif result = gtk_dialog_run(dialog); if (result == GTK_RESPONSE_CANCEL) import_thread_cancelled = TRUE; } else { -#if USE_GTK_UI update_progressbar(args.progress, progress_bar_fraction); update_progressbar_text(args.progress, _("Cancelled, exiting cleanly...")); -#endif usleep(100000); } } @@ -943,3 +945,4 @@ GError *uemis_download(const char *mountpath, progressbar_t *progress, return error(retval); return NULL; } +#endif |