Commit graph

74 commits

Author SHA1 Message Date
Dirk Hohndel
d0fba482b7 Cloud storage: in verbose mode give lots of progress information
If a user gets stuck accessing cloud storage it's often hard to figure out
which step is hanging which makes it much harder to narrow down the
problem. With this patch calling Subsurface with '-v' will give somewhat
finely grained progress information on stderr.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-20 10:15:34 -07:00
Dirk Hohndel
a29f897125 Only store dive site uuid in dive if the dive site exists
Don't store stale uuids.
As a side effect this makes it easy to remove dive sites from the XML file
(or the git repository) when duplicates have been added for some reason
and the user wants to restart from scratch.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-08 09:45:09 -07:00
Dirk Hohndel
a45c5f1acf When building against libgit2 v0.23 or newer we can assume API23
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:43:22 -07:00
Dirk Hohndel
471af6c2fd Cloud storage: clean up after the merge
Make sure the branch is pointing at the merge commit, etc.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:43:16 -07:00
Dirk Hohndel
a081ffe48e Always save taxonomy data, even if disabled in the prefs
Otherwise, if one of the systems used with cloud storage doesn't have the
preference for geo encoding enabled, the taxonomy data will be lost.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 11:05:07 -07:00
Salvador Cuñat
a09cfb8e98 RBT - Add load/save in git storage support
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-30 07:43:16 -07:00
Dirk Hohndel
a0f88e4c9f Git storage: only show geo cat if there is a value
Otherwise we could get mangled data since the newline isn't printed.
Now a good question would be "why do we have empty values in our data",
but either way, we should write invalid data to the git repository.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-10 09:49:32 -07:00
Dirk Hohndel
bc8c54f1ee Rename enum values for taxonomy
This avoids confusion and namespace collisions.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-02 10:22:31 -07:00
Dirk Hohndel
6e81677d89 Geo taxonomy: save and load the geo taxonomy data with git
This also supports the cloud storage, of course.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-01 12:29:32 -07:00
Dirk Hohndel
298f023e1f Use our membuffer infrastructure to assemble string
We should use this consistently throughout the code instead of manually
assembling strings and messing with memory all over the place.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-25 07:46:37 -07:00
Dirk Hohndel
c9d48c9a72 Add helper function to return local filename of picture as C string
This way we can actually find the picture that we are showing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 12:49:05 -07:00
Dirk Hohndel
97386a6f3d Git storage: store pictures in the repository
In order to be able to see pictures when using cloud storage from
different machines, we really need to store the pictures with the dive
data.

This could be made optional with a preference, but for now I'll just
enable it by default.

Loading the pictures from git still needs to be implemented.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 10:47:00 -07:00
Dirk Hohndel
9d8b05f47e Git storage: replaces colons with equal in picture offset
I found another place where we had colons in file names...

This fixes a small cut and paste error in an error message as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 06:23:49 -07:00
Dirk Hohndel
de35c88683 Track minimum datafile version
Add infrastructure and helper functions to track minimum datafile version.
To make this information useful we need to keep the XML and git data
format versions in track moving forward.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-20 06:45:12 -07:00
Dirk Hohndel
56b82e0ecf Git storage: change time encoding in directory names
We used to use [[yyyy-]mm-]nn-ddd-hh:mm:ss[~hex] in our git storage format
for directory that contained dives. Problem with the is that on Windows
the colon ':' is an illegal character in a filename. So libgit2 refuses to
clone such a repository on Windows.

So instead we now always write dive directories in git repositories as
[[yyyy-]mm-]nn-ddd-hh=mm=ss[~hex] which replaces the ':' with an '='.

Of course we load / parse both formats so that older formats still work.
The next time they are written all the names change which causes rather
huge commits, but that's the only way I see for cloud storage to work on
Windows.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-19 11:45:24 -07:00
Dirk Hohndel
89ca3c69c1 Git storage: don't abort if there is no default user/email set
I never ran into this because all of my computers have a global default
set for my name and email address. But if the user never uses git and has
no global settings there will be no such info. Instead of failing we need
to just set up a default ID and then try to get a best guess from the OS
(just as we used to do before libgit2 supported getting the git settings
for authorship).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-18 14:12:01 -07:00
Dirk Hohndel
c96ee6159b Fix potential crash if the existing filename is NULL
Should have used same_string() anyway...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-18 08:09:27 -07:00
Dirk Hohndel
ff4b5478b5 Store the user's unit preferences in git storage
Save and load a usually unused copy of the preferences with the units that
were active the last time the dive list was saved to git storage (this
isn't used in XML files); storing the unit preferences in the data file is
usually pointless (that's a setting of the software, not a property of the
data), but it's a great hint of what the user might expect to see when
creating a backend service that visualizes the dive list without
Subsurface running - so this is basically a functionality for the core
library that Subsurface itself doesn't use but that another consumer of
the library (like an HTML exporter) will need.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-17 09:48:10 -07:00
Dirk Hohndel
7cf3ebc2f7 Git storage: only check git_id if saving to the same remote
If we switch to a different remote (let's say we opened a local git repo
and want to save its content to the cloud storage) then don't check to
make sure that the branch stayed unchanged (because, duh, it's a different
remote, it will have changed).

This fixes the problem where you could open an XML file and store it to
cloud storage just fine, but opening a local git repository and then
storing that to cloud storage failed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-17 09:45:39 -07:00
Linus Torvalds
eff3fd3261 git save: fix crash with no remote
Commit e21cae2d46 ("Cloud storage: sync the remote after save") broke
regular git saving without any remotes: it would never initialize the
"remote" pointer, and then use that uninitialized remote pointer to see
if it was a cloud storage remote that it should try to sync.

Fix it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-16 21:40:31 -07:00
Dirk Hohndel
c593dea119 Cloud storage: use preference member instead of hard coded strings
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>
2015-06-15 10:22:00 -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
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
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
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
95664af53b Add USE_LIBGIT23_API as cmake option
Just as we would expect, the libgit2 developers of course once again broke
their API. In order to compile against current master we need to remap
those APIs once again.

Simply call cmake with -DUSE_LIBGIT23_API

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-28 09:13:51 -07:00
Robert C. Helling
b02bf002a6 Add hashes to images
Upon successfull reading an image file, this computes a SHA1 hash of the
image and saves it with the picture tag in the log file. When a file is
not successfully loaded (for example because the log was created on a
different computer) we look up the hash in a dictionary that maps hashes
to local file names.

That dictionary (actually two for both directions), is loaded on startup
and saved upon destruction of the main window.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-27 06:29:44 +01:00
Lubomir I. Ivanov
c45768a09f add and use a version.c / version.h pair
version.c is now object code which is recompiled each time
ssrf-version.h changes, while the interface file version.h
remains that same at all times and files which include it
will not need to be recompiled.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-15 13:26:51 -08:00
Linus Torvalds
e287590e4b Start splitting out git repo helper routines
This doesn't actually change any code, but it moves the 'is_git_repo()'
function that is used by both loading and saving into a new git-access.c
file.

This is where I'll start doing remote repo syncing too. Knock wood.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-15 06:03:19 -08:00
Dirk Hohndel
6820b13bd5 Don't store empty dive sites
And remove references to them from the dives.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 23:22:40 -08:00
Dirk Hohndel
da60867ae3 Always print dive site uuids as 8 digits / leading 0s in git format
Otherwise there are ugly spaces in the file names. This didn't break
anything, per se, it's mostly cosmetic.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 22:06:57 -08:00
Dirk Hohndel
ae49a8a4f7 Get location from dive site for git commit message
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 22:54:39 -08:00
Dirk Hohndel
05948530e9 Save and load dive sites in git format
Update the version to 3.

Continue to read version 2 files and create dive sites on the fly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 11:19:27 -08:00
Martin Gysel
6607425b03 api change in libgit2-0.22
Yet another api change in libgit2...
let's quote the website "libgit2 is ... linkable library with a solid
API ..."

Signed-off-by: Martin Gysel <me@bearsh.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-24 07:47:51 +12:00
Robert C. Helling
e219bc70f8 Refactor dctype -> divemode
... and repair a failed rebase (sorry).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10 17:27:25 -08:00
willem ferguson
b493a9967e CCR dive logs: git I/O
This patch privides for writing CCR dive log parameters to a git
repository and for reading the data back from a git repository.
This involves writing and reading the following members of the
structures of sample:
  o2sensor[3]
  o2cylinderpressure
and dc->no_o2sensors.

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-24 12:14:03 -08:00
Dirk Hohndel
2f7a7f3e6a Prevent garbage from being saved in the userid field
It seems that in some scenarios we end up with a string that isn't NUL
terminated and that results in garbage being stored as userid. This patch
is a little brute force but it fixes the problem even if a previous
version os Subsurface ended up adding other text to the end of the userid.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-20 14:30:44 -08:00
Dirk Hohndel
23304f69c0 Load and save the dc type for CCR dives
Oddly we already had code to load this from XML, but nothing else.
This makes the load from XML work like the rest of our code and adds the
save to XML plus the load and save for the git format.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-16 23:20:39 +00:00
Dirk Hohndel
202c5cbfeb Save CCR cylinder use in XML and git
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-16 22:13:12 +00:00
Dirk Hohndel
4ccddf95d7 Load and save extra data in git format
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-07 13:00:14 -08:00
Robert C. Helling
5f44fdd9cf Make planner work again for CCR dives
The latest CCR patches had rendered the planner not usable for CCR dives.
This patch corrects this (and reenables the CCR set point column for
segments). The problem was that a new member setpoint of struct divepoint
had been introduced, but there was already po2 which had the same meaning.
This patch merges the two and renames them setpoint to prevent future
confusion.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-19 07:07:07 -07:00
Linus Torvalds
df4e26c875 Start sanitizing gaschange event information
Decode the gasmix data into a sane format when creating the event, and
add the (currently unused) ability to specify a gas change to a
particular cylinder rather than (or in addition to) the gasmix.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-12 07:45:37 -04:00
Anton Lundin
f58bc011a7 Fix potential leak of branch in is_git_repository
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10 13:25:25 -07:00
Anton Lundin
848a5352c7 Add support divecomputer based TTS
Since earlier have we had support for our own calculated TTS. This adds
support for holding TTS values reported by a dive computer.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-09 13:22:00 -07:00
Linus Torvalds
5b311abfb5 git-format: save dive picture data
This doesn't actually parse the data at load time yet, but I need a save
file to do that..

The diff looks larger than it is because this moves the "mktree()"
function up earlier to be used by the picture saving code.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-29 17:17:57 -07:00
Willem Ferguson
eaf6d56487 CCR code: Change to sample structure
1) All the variables in the sample structures are strongly typed
2) Two additional types were declared in units.h:
     o2pressure_t
     bearing_t
3) The following variables were added:
     diluentpressure
     o2setpoint
     o2sensor[3]
4) Changes to a number of files were made to chanf
     sample->po2 to sample->po2.mbar
     bearing to bearring.degrees

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 17:05:25 -07:00
Linus Torvalds
531a5db2f1 git save: add list of dive computers to the commit message
This makes it much more obvious what is going on when you save in
between importing multiple dive computers, since the last dive
description otherwise stays the same.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-14 16:05:05 +09:00
Linus Torvalds
3159a90b0a git save: don't crash if the last dive isn't in a trip
The git save tries to generate a nice commit message based on the most
recent dive, but stupidly didn't check whether that dive was in a trip
or not, and unconditionally used the trip pointer to see if there was a
trip location.

Which works well enough if you always generate trips, but is an
unmitigated disaster otherwise.  Oops.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-14 06:16:41 +09:00
Linus Torvalds
05e0086631 Don't use locale for git save format
I stupidly used "weekday()" without realizing we localize it. And we
really don't want to make save formats be localized (we don't localize
decimal numbers etc either).

This fixes the git save format to just use a hardcoded weekday list.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-12 17:05:20 +09:00