diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | parse-xml.c | 26 | ||||
-rw-r--r-- | qt-ui/globe.h | 4 | ||||
-rw-r--r-- | qt-ui/maintab.cpp | 2 | ||||
-rw-r--r-- | qt-ui/subsurfacewebservices.cpp | 8 | ||||
-rwxr-xr-x | scripts/build.sh | 2 |
6 files changed, 38 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ada22a35..c5e039185 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_LIBGIT23_API") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LIBGIT23_API") find_package(libssh2 QUIET) - if(!LIBSSH2_FOUND) + if(!LIBSSH2_FOUND OR "${LIBSSH2_FOUND}" STREQUAL "") pkg_config_library(LIBSSH2 libssh2 REQUIRED) endif() set(LIBGIT2_LIBRARIES ${LIBGIT2_LIBRARIES} ${LIBSSH2_LIBRARIES}) diff --git a/parse-xml.c b/parse-xml.c index 1fbde0bf0..f9e5296ff 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -170,6 +170,7 @@ static enum import_source { LIBDIVECOMPUTER, DIVINGLOG, UDDF, + SSRF_WS, } import_source; static void divedate(const char *buffer, timestamp_t *when) @@ -1209,8 +1210,10 @@ static void gps_in_dive(char *buffer, struct dive *dive) add_geo_information_for_lookup(latitude, longitude, dive->dive_site_uuid); } -static void add_dive_site(char *buffer, struct dive *dive) +static void add_dive_site(char *ds_name, struct dive *dive) { + static long suffix = 1; + char *buffer = ds_name; fprintf(stderr, "add_dive_site with name %s\n", buffer); int size = trimspace(buffer); if(size) { @@ -1221,9 +1224,22 @@ static void add_dive_site(char *buffer, struct dive *dive) fprintf(stderr, "dive contains a non-existing dive site uuid %x\n", dive->dive_site_uuid); uuid = 0; } - if (!uuid) + if (!uuid) { // if the dive doesn't have a uuid, check if there's already a dive site by this name uuid = get_dive_site_uuid_by_name(buffer, &ds); + if (uuid && import_source == SSRF_WS) { + // when downloading GPS fixes from the Subsurface webservice we will often + // get a lot of dives with identical names (the autogenerated fixes). + // So in this case modify the name to make it unique + int name_size = strlen(buffer) + 10; // 8 digits - enough for 100 million sites + buffer = malloc(name_size); + do { + suffix++; + snprintf(buffer, name_size, "%s %8d", ds_name, suffix); + } while (get_dive_site_uuid_by_name(buffer, NULL) != 0); + ds = NULL; + } + } if (ds) { // we have a uuid, let's hope there isn't a different name fprintf(stderr, "have existing site with name {%s} gps %f/%f ", ds->name, ds->latitude.udeg / 1000000.0, ds->longitude.udeg / 1000000.0); @@ -1824,6 +1840,11 @@ static void uddf_importer(void) xml_parsing_units.temperature = KELVIN; } +static void subsurface_webservice(void) +{ + import_source = SSRF_WS; +} + /* * I'm sure this could be done as some fancy DTD rules. * It's just not worth the headache. @@ -1856,6 +1877,7 @@ static struct nesting { /* Import type recognition */ { "Divinglog", DivingLog_importer }, { "uddf", uddf_importer }, + { "output", subsurface_webservice }, { NULL, } }; diff --git a/qt-ui/globe.h b/qt-ui/globe.h index 31683dc35..903b9f89c 100644 --- a/qt-ui/globe.h +++ b/qt-ui/globe.h @@ -1,8 +1,9 @@ #ifndef GLOBE_H #define GLOBE_H -#ifndef NO_MARBLE #include <stdint.h> + +#ifndef NO_MARBLE #include <marble/MarbleWidget.h> #include <marble/GeoDataCoordinates.h> @@ -64,6 +65,7 @@ public: void reload(); void repopulateLabels(); void centerOnDiveSite(uint32_t uuid); + void centerOnCurrentDive(); bool eventFilter(QObject *, QEvent *); public slots: diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 55b01a29f..8b141a16f 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -999,8 +999,10 @@ void MainTab::rejectChanges() DivePictureModel::instance()->updateDivePictures(); // the user could have edited the location and then canceled the edit // let's get the correct location back in view +#ifndef NO_MARBLE MainWindow::instance()->globe()->centerOnDiveSite(displayed_dive.dive_site_uuid); MainWindow::instance()->globe()->reload(); +#endif // show the profile and dive info MainWindow::instance()->graphics()->replot(); MainWindow::instance()->setEnabledToolbar(true); diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index 6aadc2de7..6050782b2 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -85,6 +85,7 @@ static bool merge_locations_into_dives(void) */ if ((dive->when + dive->duration.seconds - gpsfix->when) < (nextgpsfix->when - gpsfix->when)) { copy_gps_location(gpsfix, dive); + changed++; tracer = j; break; } @@ -346,8 +347,11 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton *button) /* now merge the data in the gps_location table into the dive_table */ if (merge_locations_into_dives()) { mark_divelist_changed(true); +#ifndef NO_MARBLE + MainWindow::instance()->globe()->repopulateLabels(); MainWindow::instance()->globe()->centerOnDiveSite(current_dive->dive_site_uuid); +#endif MainWindow::instance()->information()->updateDiveInfo(); } @@ -378,8 +382,10 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton *button) usedUuids.insert(d->dive_site_uuid); } for_each_dive_site(i, ds) { - if (!usedUuids.contains(ds->uuid) && same_string(ds->notes, "SubsurfaceWebservice")) + if (!usedUuids.contains(ds->uuid) && same_string(ds->notes, "SubsurfaceWebservice")) { delete_dive_site(ds->uuid); + i--; // otherwise we skip one site + } } } break; case QDialogButtonBox::RejectRole: diff --git a/scripts/build.sh b/scripts/build.sh index f51314a5f..89c682b6d 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -159,7 +159,7 @@ if [ ! -d grantlee ] ; then if [[ $1 = local ]] ; then git clone $SRC/../grantlee grantlee else - git clone git://gitorious.org/grantlee/grantlee + git clone https://gitorious.org/grantlee/grantlee.git fi fi cd grantlee |