summaryrefslogtreecommitdiffstats
path: root/core
AgeCommit message (Collapse)Author
2020-03-24cleanup: fix unitialized valueGravatar Dirk Hohndel
Fixes CID 355179 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-22translations: use German translation for non-Swiss German localesGravatar Dirk Hohndel
Unless a German speaker explicitly asks for the Swiss localization, give them the German localization. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-22cleanup: don't allocate translators on heapGravatar Berthold Stoeger
This is pointless bike-shedding: instead of allocating the QTranslators on the heap an assigning them to a variable at translation-unit scope, we can simply generate them as static objects. That makes 1) two fewer lines of code 2) the translator-resources are properly released when the application closes. Not that either of these points would make *any* difference. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-22cleanup: remove memory leak in initUiLocale()Gravatar Berthold Stoeger
The prefs.locale.lang_locale field was overwritten without free()ing the old value. Not that the function would be called numerous times, but as a matter of principle... Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-22cleanup: split uiLanguage() in two functionsGravatar Berthold Stoeger
The uiLanguage() function was used for two purposes: to initialize the language related preferences and to read the current language. To make things more easy to follow, split this function in two: one for initializing, one for getting the current language. Moreover, don't return the current locale in an out-parameter as there is already a function to do that [getLocale()]. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-22locale: store locate to preferences after fixing up mac-weirdnessGravatar Berthold Stoeger
In uiLanguage() the preferences fields are initialized and there is fixup for a MacOS indiosyncrasy. For some reason the uncorrected value is written to the preferences. Let's store the corrected value instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-22cleanup: don't call uiLanguage() in qPref::loadSync()Gravatar Berthold Stoeger
uiLanguage() initializes the language fields from the preferences values. It is unclear why this function is called in qPref::loadSync() *before* the fields are loaded from disk. It can only initialize to the default values anyway. After qPref::loadSync() uiLanguage() is called again so that everything can be initialized with the correct perferences values. Remove the first call. If things break, let's fix them in a sensible way. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-21Revert "core: use set_lang_locale to modify prefs.locale.lang_locale"Gravatar Berthold Stoeger
This reverts commit 573a4a5e2da9531fbaa9e82da57131edc691a851. The commit broke setting the language in the desktop preferences: Instead of setting the locale in the prefs struct, the locale is set via qPrefLanguage. However, that saves the default language (extracted from the system) to disk. Now when the language is read from the preferences, we get that default value. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-20Ignore invalid dives in statisticsGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-20Core: consider invalid flag when adding divesGravatar Berthold Stoeger
Adding dives uses the number of the last dive to create a new dive number. Ignore invalid dives. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-20Filter: hide invalid divesGravatar Berthold Stoeger
Hide invalid dives if prefs.display_invalid_dives is false. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-20Undo: implement invalidate-dive commandGravatar Berthold Stoeger
Connect command to context menu. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-20Core: introduce invalid flag for divesGravatar Berthold Stoeger
Implement reading/writing the flag from/to XML/git. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-19cleanup: fix mis-spelling of UCT in comments as wellGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-19cleanup: remove unnecessary includeGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-17cleanup: remove record_dive() functionGravatar Berthold Stoeger
No user left. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-17git: load into arbitrary dive tablesGravatar Berthold Stoeger
The git parser loads into the global dive table, even if it is called indirectly via parse_file(). However, parse_file() may be given a different table. Fix this by extending the git parser state. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-17mobile/edit: don't add dive site twice to tableGravatar Berthold Stoeger
When editing a dive on mobile we might have to create a new dive site. That site is added to the global dive site table in the undo command. However, the code in QMLManager created the dive site with create_dive_site*() functions, which already adds it to the table. The undo command then added the dive site again leading to a hang of the application. To solve this problem, create new alloc_dive_site*() functions that do the same as create_dive_site*() but do not add it to the table. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-16git: return strdup()ed empty string on error in pop_cstringGravatar Berthold Stoeger
The pop_cstring() function is used by the git parser to duplicate a quoted string. On error, it returns an empty string literal. Since the caller expects a copied string and takes ownership of that string, it will ultimately be freed. Concrete example: a log with erroneous cylinder data was opened getting such an empty string literal as description. On closing or syncing with the cloud, the dive is freed, leading to a free of the string literal -> crash. Return a copy of the empty string instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-16android/usb: better memory managementGravatar Dirk Hohndel
Instead of relying on the std::vector staying unchanged and not freeing its members, instead keep a copy of the object in our DCDeviceData class. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16android/usb: simply restart the download after receiving permissionGravatar Dirk Hohndel
If the user tries to download from a device that he hasn't given the app permission to read from, Android will pop up a dialogue asking for that permission. With this after giving the permission we continue (well, technically, restart) the download which is likely the expected behavior. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16android/usb: remove "autoselect driver" option for unknown VID/PIDsGravatar Christof Arnosti
Signed-off-by: Christof Arnosti <charno@charno.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16android/usb: pass in the UsbDevice when downloadingGravatar Dirk Hohndel
This finally allows us to download from not just the first device, but specifically the device that the user picks. Passing the object through a void pointer is not nice - but since this traverses C code other solutions (like passing an index into the list) seemed even worse. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16android/usb: pass the usbDevice for intent handlingGravatar Dirk Hohndel
Instead of creating a string with all the object information, simply pass the actual object to the C++ code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16android/usb: remove alternative way of scanning for devicesGravatar Dirk Hohndel
We now always create a list of usb devices that doesn't list a driver for known devices, and adds multiple entries with each of the drivers for devices that are unknown to us. This removes some debugging output in the ..._open() function as well. This could be combined with Christof's earlier commit. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16android/usb: add helper to recognize chipsets known to usGravatar Dirk Hohndel
This will allow us to know when we can guess the driver. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16android/usb: guess the actual manufacturer and productGravatar Dirk Hohndel
For a small number of dive computers we can actually figure out the real information which we can then later show to the user. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16usb-serial-for-android: More fields in device descriptorGravatar Christof Arnosti
As discussed in issue #2657, there are now more fields about the usb device information in android_usb_serial_device_descriptor. Additionally, the user-facing string now makes more sense: "vendor [<bus# as integer>:<dev# as integer>]" Where vendor is as reported by android, but shortened to 16 characters. Examples: FTDI [1:2] Silicon Labs [1:4] Signed-off-by: Christof Arnosti <charno@charno.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-16usb-serial-for-android: Use correct format spezifier for size_tGravatar Christof Arnosti
Signed-off-by: Christof Arnosti <charno@charno.ch>
2020-03-16android usb serial: Prepare device / driver selectGravatar Christof Arnosti
This commit contains the serial_android_usb part of the changes proposed in issue #2657. What's implemented: - A data structure that contains all the data that can be used to describe an usb device (including user-facing string). - A function to get a list of all attached usb devices (optionally with selectable driver class). - Changes in the serial_android_usb_open-function and in the Java part to use the information about the usb device and optionally selected driver when connecting. This commit keeps compatibility with the current UI-Code in the case that only one USB-Device is connected. If two devices are connected, only the first one is tried. There are still some small things to do: - Change the user-facing string to something more descriptive. - Parts which aren't uesd anymore when the UI-Part is implemented are simply marked as obsolete (to keep compatibility for now). But generally it seems to work. [Dirk Hohndel: some white space / coding style adjustments] Signed-off-by: Christof Arnosti <charno@charno.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-14iostream: fix incorrect rfcomm error case when writingGravatar Linus Torvalds
This is the exact same case as the previous commit, just for the writing side. Once again, it's the subsurface rfcomm iostream code that can return DC_STATUS_SUCCESS with a byte count of zero when something goes wrong with the write. And once again, our libdivecomputer iostream code didn't try to be robust and protect itself from that case. The fix is equivalent, although slightly simpler, since the write side doesn't have the whole timeout issue. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-03-14iostream: fix incorrect rfcomm error case when readingGravatar Linus Torvalds
We had two independent bugs here, both of which needed to fire for this to cause a problem. This fixes both of them. The first bug was that our rfcomm code would return DC_STATUS_SUCCESS with a zero-sized read when a timeout happened, or when the rfcomm socket had disconnected. That makes absolutely no sense. We should return DC_STATUS_TIMEOUT on timeout, and DC_STATUS_IO if the socket has disconnected without any data. The fix to this is to make the whole rfcomm iostream read logic much simpler: there's no need to loop at all for partial results, because the libdivecomputer iostream side will do the loop for us (and handle partial results much better: it knows if the target backend can handle those partial results or not). The second bug was in our libdivecomputer iostream read() function, which reacted very badly to this bad return value. This updates our libdivecomputer branch to one that is more careful about things. Reported-by: linuxcrash <albin@mrty.ch> Debugged-by: Jef Driesen <jef@libdivecomputer.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-03-12cleanup: remove current_dive parameter from divesSelected signalGravatar Berthold Stoeger
The diveListNotifier.divesSelected() signal is used to inform the models of a selection change. It sent the current dive as a second parameter. This is redundant, because the only sender of the signal sets current_dive just before sending the signal. Remove the parameter, which appears to be an artifact. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-11Grammar: replaces 'indexes' by 'indices'Gravatar Robert C. Helling
Grammar-nazi ran git grep -l 'indexes' | xargs sed -i '' -e 's/indexes/indices/g' to prevent future wincing when reading the source code. Unfortunatly, Qt itself is infected as in QModelIndexList QItemSelection::indexes() const Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-03-10Add timestamps to libdivecomputer.logGravatar Christof Arnosti
Since I learned while trying to implement this that getting sub-second resolution time in portable C99 is hard (especially for someone who is used to the comfort of std::chrono and Howard Hinnants date library) the timer-implemetation from libdivecomputer is now copied to the subsurface source. Signed-off-by: Christof Arnosti <charno@charno.ch>
2020-03-10Android: stop trying to list only FTDI based serial DCsGravatar Dirk Hohndel
Thanks to the new USB serial implementation also that complex special-casing is no longer needed. This should do the right thing now. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10cloud storage: add list of changes made to commit messagesGravatar Dirk Hohndel
This should make it easier to figure out what operations lead to the commit that is written to git. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10core: make command texts available for C codeGravatar Dirk Hohndel
Create a C string (which the caller needs to free) with the executed commands in this session. The detour via the callback allows us to not make the corelib depend on the commands, which is nice for tests, export-html, and smtk2ssrf. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10core/trip handling: add helper function to get trip from idGravatar Dirk Hohndel
In the QML code we pass ids around. I had assumed that there already was a reverse lookup function, but I wasn't able to find it. So I added it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10mobile/filter: use signal to reload filterGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10mobile: remove dive::collapsedGravatar Berthold Stoeger
This was used by the old dive-list to mark collapsed entries. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10mobile: unify download code on mobile and desktopGravatar Berthold Stoeger
Use the undo-command for importing dives also on mobile. This should make the whole disconnect-model shenigans unnecessary. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09mobile: use undo-command to apply gps fixesGravatar Berthold Stoeger
The goal is to send the signal for the correct dives / divesites and thus not having to reload the whole model. Right now the mobile UI does not yet catch the diveSiteChanged signals. [Dirk Hohndel: small fix to ensure that we trigger a save to storage] Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09GPS fixes: split collecting GPS fixes into own functionGravatar Berthold Stoeger
This finishes the spliting of the GPS fix application: One function for collecting the fixes, one for application. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09cleanup: use QStringLiterals in core/gpslocation.cppGravatar Berthold Stoeger
Not that this would make any noticeable difference, but out of principle, let's use Qt's string-literal macro for string-literals. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09GPS fixes: collect fixes first, apply laterGravatar Berthold Stoeger
Make the application of the GPS fixes in two runs: first collect dives and fixes, then apply the fixes. This will simplify turning the application of GPS fixes into an undo-command. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09Android: don't list devices with unsupported transportGravatar Dirk Hohndel
We know that we cannot support native USB, USB HID, IRDA, and USB storage on Android. On the flip side, don't try to force the long broken FTDI download. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-08usb-serial-for-android: Implement timeout-handlingGravatar Christof Arnosti
Since the Android USB stack and subsequently the usb-serial-for-android driver have problems with read-timeouts, the read-timeout is now implemented in AndroidSerial.java. Also, DC_STATUS_TIMEOUT is returned if there are less bytes returned than expected. Different chipsets seem to behave differently with usb-serial-for-android. On CP210x the read blocks until there is some data here, but on FTDI the chip seems to return whatever is currently in the buffer (so 0 bytes if the buffer is empty). This different behaviour should be mitigated by the changes by this commit. Signed-off-by: Christof Arnosti <charno@charno.ch>
2020-03-07usb-serial-for-android: ImplementationGravatar Christof Arnosti
Implement the libdivecomputer API in Java and create C/JNI translation layer. [Dirk Hohndel: whitespace harmonization - yes, some of this is Java, this still makes it much easier to read for me; also changed the FTDI conditional compilation to make sure we can still use that for mobile-on-desktop if necessary] Signed-off-by: Christof Arnosti <charno@charno.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-07serial-usb-for-android: Display all Serial computersGravatar Christof Arnosti
Signed-off-by: Christof Arnosti <charno@charno.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>