Commit graph

8693 commits

Author SHA1 Message Date
Dirk Hohndel
092abe9b39 Cloud storage: add test for simple save / load from our test account
This will fail if the proxy settings of the user running the test are
incorrect.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:43:57 -07:00
Dirk Hohndel
420afeef57 Save XML: sort the dive sites by uuid
This makes it much easier to compare XML files written by Subsurface.
The order of the dive_site_table depended on the order in which they were
encountered. This makes it easier to eye-ball changes in XML files. And
allows the GitStorage test to pass.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:43:52 -07:00
Dirk Hohndel
e03b553e80 Make created dive site uuid deterministic
Having random uuids seemed like a good idea, but there are several
situations where they really cause problems. One is merging dive file
imports from V2 logfiles. Another is testing such imports.

Instead of making the uuid random we now hash the name and add the
timestamp of the first dive associated with this dive site to the hash
(first in this context is "first encountered" with no guarantee that it is
the chronologically first). This way V2 imports create deterministic uuids
but uuid conflicts are still extremely unlikely, even if the user has
multiple dive sites with the same name.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:43:48 -07:00
Dirk Hohndel
6eed3155e6 Add simple test for git storage
This just makes sure that writing data to git storage and reading it back
gives you the same result. Without the fixed generation of initial dive
site UUIDs this fails.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:43:41 -07:00
Dirk Hohndel
eb205c1b09 Cloud storage: be more verbose if asked to be verbose
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:43:36 -07:00
Dirk Hohndel
f177b2ec53 Cloud storage: try to brute force your way around merge issues
This seems to do the right thing in several cases that I tested, but I'm
worried if it might end up causing us data loss in other cases. This needs
a TON of testing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:43:32 -07:00
Dirk Hohndel
70c38de3a1 Cloud storage: be very strict about renames
Because of the structure of some of our files git too easily assumed that
they were renames and that confused the merge algorithm.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:43:27 -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
f5eb0e2bbb Cloud storage: move git merge into its own function
Just to keep things more readable.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:43:11 -07:00
Dirk Hohndel
4c31c01139 Cloud storage: better error message for dirty state
Tell us WHAT is wrong with the state.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:43:01 -07:00
Dirk Hohndel
b8575221b1 Cloud storage: use merge options to avoid conflicts
In many cases Subsurface will do something "reasonable" if we have
conflicting edits and then try to merge. GIT_MERGE_FILE_FAVOR_UNION means
that both edits will be added to the final file and then Subsurface should
quietly take one or the other - this will need quite a bit of testing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-22 17:52:31 -07:00
Dirk Hohndel
fe0864be60 Cloud storage: merge local and remote changes if there is no conflict
We still punt if there are any conflicts (which are likely to occur if we
have touched dive sites in both changes). But in my testing at least for
fairly simple, non-conflicting changes this works and creates a correctly
merged tree.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-22 17:52:31 -07:00
Dirk Hohndel
ccd2cb2502 Continue to separate logic code from UI code
We don't want to call into the MainWindow from C code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-22 07:05:13 -07:00
Dirk Hohndel
e86fd45efd Cmake: fix cross compiling on Windows
Cmake has a bug that causes the moc process not being handed the necessary
defines for the architecture we are building for.

Also we were missing a library to make the BT implementation on Windows
work.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-21 10:16:06 -07:00
Robert C. Helling
3437666010 Display error messages in planner
After a replot, check if there is an error message to display.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-21 10:16:06 -07:00
Dirk Hohndel
c7d8e72607 Use our pressure type to avoid bar / mbar confusion
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-21 10:16:06 -07:00
Robert C. Helling
652f7e9864 Don't do computationally expensive Boyle compensation when not using VPM-B
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-21 09:28:04 -07:00
Robert C. Helling
d9b4f2b7e3 Don't do Boyle compensation when still on first stop
There is nothing to compensate but we would hit a 0/0 numerical
instability there.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-21 09:27:53 -07:00
Tomaz Canabrava
0f096d0e53 Save Properties for each State of the mainWindow
Each state can have the same widgets but with different
properties - currently I'm using "enabled" : true and false
for the DiveSiteEdit, it looks like a big amount of code
for such a small thing but it was the cleaner way that
I tougth of doing.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-21 07:37:15 -07:00
Dirk Hohndel
307df53bb4 Updates to the ReleaseNotes
Including a quick note about the two known issues on Macs.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 23:14:54 -07:00
Venkatesh Shukla
eb31b3b075 Open subsurface on attaching divecomputer
Added USB usage permissions in manifest.
Also added various FTDI based USB devices in xml/device_filter.xml. When any
device matching the VID and PID provided in the device_filter.xml is attached,
subsurface application is opened automatically. Also, the USB permissions are
granted to the application. This simplifies the USB file generation approach.

Signed-off-by: Venkatesh Shukla <venkatesh.shukla.eee11@iitbhu.ac.in>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 23:01:15 -07:00
Anton Lundin
8d73e4f81c Connect up serial_ftdi custom serial
This connects the serial_ftdi implementation to subsurface, and builds
libftdi1 for the android builds.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:59:54 -07:00
Anton Lundin
e2c98def26 Turn serial_ftdi.c into a custom_serial
This cleans up serial_ftdi.c from being a libdivecomputer source and
making it into a subsurface custom_serial.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:59:49 -07:00
Anton Lundin
3104508247 Re-indent and style up serial ftdi
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:59:42 -07:00
Venkatesh Shukla
f33843ed35 serial_ftdi.c for communication with ftdi devices
This script is based on serial_posix.c and is primarily meant to work on
android, but could be used elsewhere as well. This script communicates with
libftdi devices connected to the system using libftdi library.

ftdi_read_data returns 0 if no data is received from the device. Allowing to
continue on recieving 0 might end up in an infinite loop. But it works in
OSTC3. This needs to be checked further.

libftdi returns -3 when it could not find any device corresponding to the pid
and vid given. (Different from -3 of libusb which means you do not have
permissions to access the device) Use this to return value to check for other
accepted chipsets including the custom pids used by divecomputer manufacturers
such as Cressi (Leonardo), Suunto and Oceanic.

ftdi_read_data returns the number of bytes read (+ve), 0 when there is no data
to read, and negative when there is an error.
Instead of infinitely waiting for the data to appear, it is better to implement
an exponential backoff which times out after MAX_BACKOFF.

[Anton Lundin: This code was originally intended to be included in
	       libdivecomputer, but because we now got the custom-serial
	       patches, its included in subsurface instead, and wired in
	       from there - renamed the resulting file to serial_ftdi.c]

Signed-off-by: Venkatesh Shukla <venkatesh.shukla.eee11@iitbhu.ac.in>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>

Rename serial_ftdi.c for subsurface source

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:58:45 -07:00
Anton Lundin
9ddc21a476 Wire up get_usb_fd to libusb_set_android_open_callback
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:56:27 -07:00
Venkatesh Shukla
b629088dfa Extract usb file descriptor of ftdi on Android
Using JNI implementation of QtAndroid, usb file descriptor
of attached ftdi usb device is extracted. This would then
be used for opening usb device on android.
This implementation assumes that permission for usage of
device is already present. This is because of the device_filter
due to which on attaching a recognised usb device (Only ftdi
for now) to android, a dialog pops up asking for permission to
use it with subsurface.
Not an ideal assumption but works sufficiently well.

Signed-off-by: Venkatesh Shukla <venkatesh.shukla.eee11@iitbhu.ac.in>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:53:14 -07:00
Anton Lundin
72872bd7fd Enable android logging from libusb
This makes libusb to log straight to the android logging system. This
makes sure we can reach the logs and debug things.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:53:01 -07:00
Anton Lundin
676c1b319f Patch libusb for android custom open function
This idea was inspired by:
https://github.com/PointCloudLibrary/mobile/blob/master/3rdparty/android/patches/libusb.patch

The whole thing is re-written from scratch but the idea came from there,
and its a way simpler way of getting a system-opened fd to the right
place than patching every call in the stack to pass a fd down.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:52:21 -07:00
Claudiu Olteanu
55353bda40 Add implementation for device discovery agent initialization (Windows)
Register the metatypes needed for Windows platforms and initialize
our custom device discovery agent.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:45:58 -07:00
Claudiu Olteanu
7a7d492525 Get a pretty print message when a device discovery error occured
Try to get a pretty print message when a device discovery error
is raised and it is unknown.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:45:55 -07:00
Claudiu Olteanu
baa45472a2 Add implementation for BTH device item selection on Windows platforms
When a Bluetooth device is selected from the discovered list
display information about its address and enable the save button.
On Windows we don't need to check if the devices are paired because
the pairing process is done automatically on the connection step.
If the devices are not paired Windows will ask for user's permission
to continue the process.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:45:51 -07:00
Claudiu Olteanu
5f60a688c6 Use the address of the BTH device if its name is empty
There are moments when the name of the device is not collected
properly and it is unavailable. Instead of showing an empty string
then print the address of the device.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:45:45 -07:00
Claudiu Olteanu
13083fb524 Add implementation for add remote Bluetooth device handler
On Windows we cannot determine the pairing status of the
device. Therefore we print only information about its name
and about its BTH address.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:45:42 -07:00
Claudiu Olteanu
c0b169e0a3 Wait for BTH device discovery thread to finish on stop call
We should wait for the WinBluetoothDeviceDiscoveryAgent completion
when the stop method was called.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:45:39 -07:00
Claudiu Olteanu
74187657e5 Initialize WinSock and hide the information about the local device
On Windows we cannot select a device or show information about the
local device. Therefore we disable the UI section related to local
device details.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:45:37 -07:00
Claudiu Olteanu
2af14ba445 Add implementation for our custom BTH device discovery service
Implement a custom lookup service for remote Bluetooth devices
discovery. This will be used on Windows platforms to collect
information about the name and the address of a remote Bluetooth
device.

In the beginning we initialize the queryset with the necessary
flags and we start the lookup service. When a device is discovered
we collect information about its name and its address and we
raise a signal with it using the same signature as the one emitted
by QtBluetoothDeviceDiscoveryAgent implementation.

Finally we end the lookup service and we reset the internal flags.

This code was written with the help of the sample code documenting the
relevant APIs provided by Microsoft Corporation at
https://code.msdn.microsoft.com/windowsdesktop/Bluetooth-Connection-e3263296
which is under the MS-LPL. No code from the samples was copied and the
code in this commit is covered by the GPL and not the MS-LPL.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:45:34 -07:00
Claudiu Olteanu
3b811552aa Add implementation for BTH custom serial write method used on Windows
Implement the write method used for our custom serial implementation
on Windows platforms.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:45:31 -07:00
Claudiu Olteanu
994087c0b9 Add implementation for BTH custom serial read method used on Windows
Implement the read method used for our custom serial implementation
on Windows platforms.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:45:28 -07:00
Claudiu Olteanu
23c5dee2f1 Add implementation for BTH custom serial close method on Windows
Implement the close method used on Windows platforms for our custom
serial implementation.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:45:26 -07:00
Claudiu Olteanu
e2cac92d23 Add implementation for BTH custom serial open method on Windows platforms
Implement the custom serial open method using the WinSocket2 API.
First the device address is converted from text representation into
a sockaddr structure. Then a connection is initiated to the device
using device's Serial Port service.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:45:23 -07:00
Claudiu Olteanu
7488f5500e Add skeleton for Bluetooth custom serial implementation on Windows platforms
Add a skeleton which will be used to develop the Bluetooth custom
serial implementation for Windows platforms.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:45:20 -07:00
Claudiu Olteanu
2aa6ffe0c8 Add set_timeout callback for Bluetooth custom serial implementation
The new callback will be usefull when we will implement the support
for Windows. The implementation of native serial set_timeout method
uses a HANDLER on Windows and we will use the WinSock2 API which has
a socket descriptor.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:45:16 -07:00
Claudiu Olteanu
69c81ed8e4 Reimplement pairingFinished method
The old implementation didn't use the correct deviceLabel pattern.
When the pairing status of a device was changed the name of the device
was missing from the new label. With the new implementation when the
pairing status is changed we replace the old state with the new one and
maintain the device information from the old label.
Also we set the same pairing background colors used in the
addRemoteDevice callback. In this way the label's state is consistent
and the UX is improved.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:45:13 -07:00
Claudiu Olteanu
a83f59ff09 Clear the BTH discovered devices list on each search
Clear the Bluetooth discovered devices list on each search.
In this way we will show only the devices that are in range
and active during the last scannning. Also if we clear the
list before each call we don't need to check anymore if the
discovered device is already in the list.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:45:11 -07:00
Claudiu Olteanu
14ca6a4e77 Check the last error when the BTH device scanning is finished
If there is no error reported when the device scanning is finished
then report to the dialog status that the scanning finished
successfully. Otherwise report the last error.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:45:07 -07:00
Claudiu Olteanu
9f043f4a93 Cleanup Bluetooth local device and the discovery agent on exit
Do some extra cleanup when the BtDeviceSelectionDialog is
destroyed.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:45:04 -07:00
Tomaz Canabrava
118e978b5a Display dives from the same location on the list
Some dive sites are separated in more than one real dive site
(for instance, a 'blue hole' dive site that has different
entry points on the gps), so instead of checking only the
dive_site id, also check it's name.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 22:23:25 -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