The longer I stared at the existing code the less it made sense.
So instead I rewrote it in a way that seems logical to me. And added a
boatload of debugging output (which needs to be removed, of course).
I tested this against more than a hundred dives and it seemed to always
pick the right fix.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Most of these will likely have no big impact, but it's better not to just
ignore them as they could lead to crashes.
Uemis downloader: if lseek fails, return 0
Uemis downloader: consistently check for failure to open req.txt
Zip file handling: dup could fail
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This creates the basis to allow other backends to be used with the cloud
storage infrastructure.
So far this should all just transparently continue to work. A user would
have to manually add the cloud_base_url entry to the CloudStorage section
in their config file in order to use a different backend server.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Correctly tracking the status of our authentication with the cloud service
is non-trivial, especially since the user may quit Subsurface between
registering and verifying an account, they might even register on one
machine and verify on another.
This tries to make sure that when in doubt we check with the cloud service
backend. And we show errors in the UI.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
libgit2 takes forever (a minute or so) to figure out that it can't connect
to a remote server.
So if we are using https as connection protocol, quickly check utilizing
RFCs 2324/7168 to make sure we can reach the cloud server (and not some
captive portal or something).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When downloading GPS data from the Subsurface webservice we repopulated
the globe before purging all the unused GPS fixes from the list of dive
sites which caused massive clutter (until the next time the user changed
the displayed dive or did anything else that caused the globe to redraw
itself).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
After we import all the GPS fixes from the Subsurfae webservice we delete
the ones that didn't match any dives. The algorithm skipped every other
one by mistake.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We can't build with -DNO_MARBLE after some previous commit broke
globe.cpp
- centerOnCurrentDive() is still existing in the code while removed from
header in 6b81fb49d0.
- Some referenced to MainWindow::instance()->globe() even if we are
building with no marble.
- include stdint.h
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This triggers when the email address / password is changed in the
preferences. It opens an https connection with the backend server (the URL
is hardcoded) which should create an account with these credentials.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We were relying in the current_dive to display the
globe coordinates correctly - but this is not always
the case: you can be inserting a new dive site and it
isn't yet inside of the dive until the user presses
accept. So always pass the uuid of the dive site that
we want to display.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of writing each dive out to a file and reading that file back in,
let's just use the internal helper function that places the dive as XML
into a membuffer.
So much simpler, so much faster.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Previously we simply failed silently without showing the user any
indication that something went wrong. That seems wrong.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Non-static class member multipart is not initialized in the constructor
Signed-off-by: Marcos CARDINOT <mcardinot@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Showing an Error message is better called from the Notification Object,
So for consistency old references to showError is replaced by calling
the notification object.
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We had a ton of helper functions in qt-gui.cpp which really didn't make
much sense. So I moved them all into qthelper.cpp.
Also moved the UserAgent helper that didn't belong in the UpdateHandler to
begin with - that's a generic helper used in many places...
With this we can successfully build using cmake again.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is a bit awkward now. We are downloading what looks like fake dives
in the v2 format. So we create a dive site for every single fix.
After we merge those new dive sites into the existing dives we need to
throw away all the dive sites that weren't used.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Now it's created in the mainwindow.cpp as part of the new
way to configure the interface.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Now it's started from mainwindo.cpp and it's part of the
new states
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It's now set up from the mainwindow.cpp file.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Lots and lots and lots of header files were being included without being
needed. This attempts to clean some of that crud up.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This will allow us to download the dives from the dive computer into a
separate table just for that purpose and not into the main dive_table.
I really dislike the code that's in place that dates back to the very
earliest code written for Subsurface. Dumping the dives straight into the
main dive_table seems really stupid to me.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This fixes two typos found by lintian.
I guess a bunch of translations will need to be updated or something, I am not
sure how they work so I didn't touch them. I presume in the worst case they
will need to be re-translated at the next iteration
--
Salvo Tomaselli
"Io non mi sento obbligato a credere che lo stesso Dio che ci ha dotato di
senso, ragione ed intelletto intendesse che noi ne facessimo a meno."
-- Galileo Galilei
http://ltworf.github.io/ltworf/
From a0e5f48349557fcccd82ba8c7555043de140835c Mon Sep 17 00:00:00 2001
From: Salvo 'LtWorf' Tomaselli <tiposchi@tiscali.it>
Signed-off-by: Salvo 'LtWorf' Tomaselli <tiposchi@tiscali.it>
Date: Fri, 12 Sep 2014 18:25:20 +0200
Subject: [PATCH] Fix typos reported by lintian
Fixes two typos reported by lintian.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This one is less verbose and very easy to parse. It's guaranteed to have
five components, separated by ':' with no other ':' in the string:
Subsurface:<version>:<PrettyOSName>:<appCpuArch[/osCpuArch]>:<UILang>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It appears that at least on Win7-64 Windows tries to create the temporary
file in C:\ and fails because of insufficient permissions. How stupid is
that.
Instead we roll our own tempfiles, based on the already existing tempfile
name that is passed in.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
zip_open needs correct directory separators. QFile::encodeName does not
do this conversion, so we must call it explicitly.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The access manager is only one, while we can make requests from
different parts of the application, so relying on the manager
finished() signal to see if something was done or not was a
not very good move.
The QNetworkReply is created when a get() is invocked on the
AccessManager and that's unique. connect it's finished()
signal instead.
bonus: code cleanup.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We were actually searching dives which match the dowloaded position
fixes. So we're also trying to take into account if the fix is automatic
or no based on a limited amount of predefined strings (bad idea, as the
user can change in companion app settings the predefined string).
This way, in actual implementation, if program concludes that a fix has
been manually got or, simply, the user is unlucky enough to have all the
position fixes out of the dive time, find_dive_n_near() function will
pair fix and dive in an ordered way (1st fix -> 1st dive; 2nd fix -> 2nd
dive ...) which is probably erroneous, except for manual position fixes.
BTW actual implementation can't pair the same gps position with more
than one dive, which would be the case, e.g. in repetitive dives while at
anchor in the same point.
The patch changes the logic:
- Search positions for defined dives (instead of dives for defined
positions) without care if position has manually or automatically been
set.
- Only take care of those dives that don't have a position yet.
- It makes two assumptions:
a.- If the position fix has been taken during the dive time, is
correct. If there are more than one inside the dive time, takes the
first one (closest to the DC's reported time).
b.- If not during diving time, the correct one is the nearest fix
before the dive begins (also the usual case if manually fixed from the
smartphone just before jump into the water). But will work too if there
is only one fix *in SAME_GROUP range* after the dive (another usual
case).
- Finally, as copy_gps_location() in dive.h is used only here, let it
take care of naming the dive if user hasn't named it yet.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This will make more easy to move code around in the future.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This switches the QTextEdit fields to QPlainTextEdit (I don't see a reason
why we should allow HTML here), no longer tries to have a default text but
instead adds labels for the two fields, connects the UI so th data is
collected and uses a bastardized WebServices subclass to send the data to
our backend.
Fixes#546
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>