Commit graph

8714 commits

Author SHA1 Message Date
Dirk Hohndel
6359a98397 system_default_directory() is broken with Qt 5.4
So for now just keep using the same function as we use with earlier
versions of Qt5 as that seems to work.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 21:12:54 -07:00
Anton Lundin
7a594e3ec5 Simplify distance calculations
This simplifies the distance calculations and removes a dependency.

This version uses propper math instead of my to simple previous version.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 21:08:11 -07:00
Dirk Hohndel
9ec155fad0 Cloud storage: clean up error propagation
We were falling of the end of a number of functions that were supposed to
return 0 on success or an error.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 20:03:20 -07:00
Dirk Hohndel
0c5ea57f1c Cloud storage: initialize local cache and remote on first use
There's no point in telling the user that the remote is empty. We need to
instead fix that and create the local cache and set things up for the
remote.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 18:36:08 -07:00
Dirk Hohndel
e6dce94088 Cloud storage: if there is no remote tracking branch, create it
When we first store things to the remote there won't be a matching branch
for it. And even if for some silly reason the remote branch got lost -
what's the point of telling the user that there is no remote branch? What
are they supposed to do about it. Let's just fix the problem and move on.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 18:36:08 -07:00
Dirk Hohndel
ef85875cd0 Cloud storage: make do_git_save available to other modules
And add a parameter that tells it whether to try to save any Subsurface
data or whether to just create a branch and push it out.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 18:36:04 -07:00
Dirk Hohndel
f6981f0210 Add helper function to create a directory
Yes, this could easily done from the C code. But this seems just so much
easier and I don't have to worry about the oddities of Windows and all
that.

I'm lazy. So sue me.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 18:26:34 -07:00
Dirk Hohndel
b413fabce7 Cloud storage: don't print confusing warning
This is no longer correct and is actively misleading. We now correctly
sync with the remote.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 18:24:27 -07:00
Dirk Hohndel
3d62f89bce Cloud storage: Remove another git related message
Once we failed to load data from cloud storage (for example the first time
we try to use it when the remote repository is empty), don't show git
related errors to the user. It's enough to tell them that the cloud
storage is empty.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 13:16:08 -07:00
Dirk Hohndel
7b7568b1ba Cloud storage: setup proxy before cloning new repository
If we don't have a repository yet, we can't setup the proxy option before
calling into libgit2. Instead we use a callback.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 09:14:48 -07:00
Dirk Hohndel
df255e2573 Don't show an error if you fail to open the cloud storage
The lower level functions will already report that things didn't connect
successfully, no reason to repeat it here (which then exposes the git
URL).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 09:14:48 -07:00
Dirk Hohndel
abde615c1c Cloud storage: give user friendly error messages
Instead of showing the git URL and talking about failures to clone
repositories, simply tell the user what's happening with the cloud
storage.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 09:14:48 -07:00
Dirk Hohndel
3ad517d87a Cloud storage: check connectivity before trying to connect
With a new repository we take a different path.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 09:14:48 -07:00
Dirk Hohndel
9a22efb97b Move git related declarations into their own header file
Also change the name of the enum and make sure all the inner functions get
passed the remote transport information.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 09:14:48 -07:00
Dirk Hohndel
e21cae2d46 Cloud storage: sync the remote after save
This change once again tests if the remote can be reached. Even with a
fairly big data file and a medium speed internet connection the remote
sync is fast enough to call it nearly instantaneous. Maybe a couple of
seconds.

We may need more checks / different heuristics / warnings if the sync
didn't happen, etc. But for now this should allow more reasonable testing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12 13:56:23 -07:00
Dirk Hohndel
492369b312 Cloud storage: Add preference option whether to sync in the background
This defaults to on as that's the most useful setting for the average
user.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12 11:48:56 -07:00
Dirk Hohndel
3a0ffb70a0 Cloud storage: don't clear out password by mistake
If the user didn't enable saving the password to the preferences, then the
password was cleared out as the preferences got synced.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12 11:28:20 -07:00
Dirk Hohndel
a9c2a3f009 Use friendlier file name when asking about saving changes
It's silly to show our full URL with branch name in that case.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12 10:42:14 -07:00
Dirk Hohndel
f442358915 Cloud storage: better window title
This makes it clear that we are working with the cloud storage and removes
the (in that case, redundant) branch name from the title.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12 10:38:01 -07:00
Dirk Hohndel
ef95bd9a27 Indicate that there are unsaved changes with a '*' in the window title
This seems to be a fairly common way to indicate this property.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12 10:21:16 -07:00
Dirk Hohndel
57f2c81125 Add header for Qt helpers used from C functions
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12 10:20:57 -07:00
Dirk Hohndel
4d06e8f7b5 Cloud storage: check connection before connecting
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>
2015-06-12 09:22:36 -07:00
Dirk Hohndel
5e0c546beb Cloud storage: Unset the proxy if none is configured
The settings are stored in the local cache repository - so without
resetting it a proxy would stay configured even if it was disabled in the
Subsurface preferences.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12 09:22:35 -07:00
Dirk Hohndel
490d21806e Cloud storage: Setup http proxy for git connection
At the time of this commit support for this feature has not landed in
upstream libgit2, yet (but there is a pull request). Yet supporting this
here doesn't appear to cause any issue with older versions of libgit2,
either, so the http proxy support will simply not work when enabled and a
version of libgit2 that's too old is used.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12 09:22:27 -07:00
Dirk Hohndel
3ff3577eda Cloud storage: Require libcurl in order to support http proxies
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12 06:10:19 -07:00
Miika Turkia
f3b93eb57a Add two new libraries to requirement list (deb)
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-11 11:52:15 -07:00
Dirk Hohndel
82b15b02b3 Dive site management: show pictures instead of profile
This seems to work better than moving the Globe up there.
It's not ideal (I really want to be able to show one big picture for the
site - and on all the sites without pictures we show nothing), but for now
I think this is better than having the profile there.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-11 11:10:14 -07:00
Dirk Hohndel
1dee5e1723 Revert "Dive site management: remove the profile view"
This reverts commit ec8ba5f830.

Turns out that moving the globeGps widget to a different quadrant breaks
the parent relationship and that causes things not to work. I know that I
tested this and didn't notice any issues, but I now can reproduce a broken
default screen. So let's revert.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-11 10:58:01 -07:00
Dirk Hohndel
3e35a0067b Add a more complex sample dive
This includes trips, dives outside trips, deco, gas changes, dives with
multiple dive computers, a really short dive, a rather long dive, a dive
with pictures, dive computers with very coarse sample rate, rather fine
sample rate, with gas integration, without...

Should touch a lot of different scenarios.

The file is in V2 format to also allow testing the importing / conversion
to dive sites.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-11 10:31:11 -07:00
Paul-Erik Törrönen
be6a9ac1ea Minor fixes to the INSTALL-file
* Add needed qt5-qtlocation-devel package for Fedora install
* Correct the call to subsurface binary after compilation]

Signed-off-by: Paul-Erik Törrönen <poltsi@777-team.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-11 07:55:23 -07:00
Dirk Hohndel
8ad000846d Cloud storage: use our credentials when updating the remote
If we are pushing to an ssh or https based remote we need to use our
credentials.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10 21:55:19 -07:00
Dirk Hohndel
26cbc32495 Cloud storage
Use the credential helpers earlier in the source. This way we can use them
for the push as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10 21:54:42 -07:00
Dirk Hohndel
e81a67f9d3 Cloud storage: track the repository type and pass the information around
This is easier than having various parts of the code to the string
comparison on the URL.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10 21:54:25 -07:00
Linus Torvalds
39a0ac965b git storage: actually update the remote repository if the local cache is more recent
Again, note that this currently only happens when you initially open the repository.

So if you do

    subsurface https://.../repo[myubranch]

it will start up by fetching the remote information, and updating the
local cache.  If you then download new dives, and do a save-and-exit, it
will save to the local cache, but it doesn't do the fetch at this point,
so the remote is now begind.

The *next* time you start subsurface, and load that git branch again, it
will fetch the remote, and now notice that the local cache is ahead of
it (because you downloaded new dives and saved them locally), and *then*
it will try to update the remote with the new information.

This is obviously bogus, but we will need to decide exactly how we want
to sync with the remote repository.  But now the core functionality is
there, it's just that we need some interface to say "sync now".
Especially in the face of spotty (or non-working) internet, you want a
GUI etc for this whole remote sync, rather than doing it unconditionally
and silently whenever you load the local cache initially.

With that caveat:

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10 20:57:57 -07:00
Linus Torvalds
971f1c6674 git storage: re-organize code to make 'origin' remote more widely available
I'm going to try to update the remote if the local cache is more recent
when we fetch the data, which requires access to the remote over a wider
range of code.  This re-organizes the code so that we can free the
remote later without having to have nasty error handling.

We avoid the whole "if an error happened, free the remote and return" by
creating helper functions and freeing the remote in the caller, so that
all paths end up freeing it naturally.

NOTE! We want to try to update the remote when we save the local cache
too, so this whole "update remote when opening it" is incomplete. But
 (a) we do want to do it here as well
and
 (b) this is the easiest place to create the initial "push to remote"
     code without any new "sync with cloud" interfaces.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10 20:57:13 -07:00
Linus Torvalds
1379f34792 git storage: actually update cached copy from remote
We used to fetch the remote information but not actually do anything
about it, except report when it wasn't up-to-date.

Now we actually update the local cached copy if the remote has changed.

The code does not try to actually merge things, so only fast-forward
updates are done, but that should be the normal case.  We might
eventually do some simple merging on our own, but I suspect manual
merging may be the safer option.

We don't currently ever update the remote repository, and only inform
users that our local repository is ahead of the remote.  Fixing that is
the next step.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10 18:13:25 -07:00
Dirk Hohndel
ec8ba5f830 Dive site management: remove the profile view
While this isn't what I really want (I wanted pictures of the dive site
instead of the profile), at least this makes it clear that we aren't
editing a dive but instead are looking at a site.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10 15:03:12 -07:00
Dirk Hohndel
b0fc00694d Add "additional name" to the correct dive site
Adding the name to its own dive site was kind of silly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10 13:03:37 -07:00
Dirk Hohndel
3b018204f2 When done reverse geocoding, hide the notification
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10 12:30:02 -07:00
Dirk Hohndel
0da0a40bb8 Don't show the V2 warning anymore
This now happens in its own thread...

But leave the infrastructure so we can ask questions about the geo
encoding

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10 11:57:31 -07:00
Dirk Hohndel
2c22b24ef6 When parsing V2 XML files try to be smarter when creating dive sites
Two "locations" from a V2 file are the same site if they have the same
name AND if their GPS coordinates are within 20 meters of each other.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10 11:52:18 -07:00
Dirk Hohndel
d541c2b601 Add helper function to determine the distance between two points
And use this to find a dive site within a certain radius of a GPS fix.
This will be used to figure out if dive sites might be the same.

This uses a new Qt5 component (Positioning) which was added in Qt5.2.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10 11:51:15 -07:00
Dirk Hohndel
1ee447b5a9 When saving only selected dives, only include referenced dive computers
Since we should have far fewer dive computers than dives this straight
forward algorithm shouldn't cause any performance issues.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10 09:29:04 -07:00
Dirk Hohndel
2365531c68 When saving only selected dives, only include referenced dive sites
The algorithm seems rather brute force; basically quadratic in the number
of dives, assuming we have about the same number of dive sites as dives
which seems a reasonable assumotion.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-10 09:28:40 -07:00
Dirk Hohndel
d24de5b72b Don't show all the auto generated dive sites on the globe
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>
2015-06-10 07:09:23 -07:00
Dirk Hohndel
2a110811cf Cloud storage: be more careful when trying to determine a user name
Since we use the email address (including the '@' sign) as the repository
name we have to be more careful when trying to pick an account name from a
git URL.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-09 20:54:01 -07:00
Dirk Hohndel
0eb6dc4332 README should mention that this is not a release
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-09 17:42:30 -07:00
Dirk Hohndel
7ec406da82 ReleaseNotes: mention cloud storage
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-09 17:41:44 -07:00
Dirk Hohndel
8282ed2348 Merge branch 'cloudstorage' 2015-06-09 17:16:31 -07:00
Dirk Hohndel
57507cfb93 Cloud storage: implement confirmation of email address via PIN
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-09 17:04:30 -07:00