summaryrefslogtreecommitdiffstats
path: root/core
AgeCommit message (Collapse)Author
2018-02-17Coding-style: remove superfluous parenthesesGravatar Berthold Stoeger
Mostly replace "return (expression);" by "return expression;" and one case of "function((parameter))" by "function(parameter)". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-17Cleanup: Save hash from filename-to-hash map to git repositoryGravatar Berthold Stoeger
This unifies behavior of XML & git saving. Now, in both cases, the picture hash is extracted from the filename-to-hash map instead of using the picture structure. This seems more robust, because the picture structure is not necessarily updated by learnHash(). The latter may operate on a copy of the picture structure. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-17Cleanup: return copied string from hashstring()Gravatar Berthold Stoeger
The following statement in the hashstring() function: return hashOf[QString(filename)].toHex().data(); returns data of the temporary QByteArray generated by toHex(). Thus, the caller will access released memory, which could lead to data corruption. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-12Cleanup: remove outdated TODO itemGravatar Berthold Stoeger
report_error() automatically pushes error messages. No need for a separate signal. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-12Cleanup: remove declaration of get_error_string()Gravatar Berthold Stoeger
This function was removed in #8f81a22e7f26729cc2f4902ba7db8f696314539f. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-12dump_tissues: fix missing 'struct deco_state' argumentGravatar Lubomir I. Ivanov
With DECO_CALC_DEBUG != 0, divelist.c and profile.c have calls to dump_tissues() without passing a 'struct deco_state' argument. Fixes #1105 Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-02-10Add a preference to turn on ICD warningsGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-02-07Cleanup: unserialize loading of picturesGravatar Berthold Stoeger
The images to load are kept in a set to avoid multiple loading of the same picture. The set was protected with a mutex. Problem: the mutex was not released before loading the picture, effectively serializing the loading of pictures. Therefore unlock the mutex once the set is updated. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-07Cleanup: remove unused typedefGravatar Berthold Stoeger
The type SHashedFilename defined in core/imagedownloader.h was not used anywhere. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-07Cleanup: Make local helpers and variables of static linkageGravatar Berthold Stoeger
In core/imagedownloader.cpp the helpers cloudImageUrl() and loadPicture() are made of static linkage. The global variables queuedPictures and pictureQueueMutex were moved into the loadPicture() function, because they are used only there. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-04Do not remove seconds from duration input fieldGravatar Oliver Schwaneberg
This change deals with issue #554. If you enter a dive duration manually, the cell renderer cuts the seconds away when the changes are saved. I added the helper "render_seconds_to_string" as a counterpart to "parseDurationToSeconds". The helper keeps the seconds, if not null. The rendering of the cell is done at two places in the code, so I think it is cleaner to add a dedicated method for it. Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-02-02Free various struct membuffer in different functionsGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-02Print icd data only when it is really neededGravatar Willem Ferguson
Reduce the impact and visibility of icd calculations by writing the data to the planner output only in cases where gas switches involve: 1) ascent 2) helium is used as part of breathing gas 3) gas switch results in an increase in partial pressure of nitrogen. Coding change: 1) The code for writing the header of the icd table as well as the inclusion of the data in the planner output is made conditional on the above three requirements. This involves moving the code that writes the table header into the function that writes an icd data item to buffer. 2) Manipulation of a boolean variable that controls writing of the table header to buffer and that also determines whether any icd results should be inluded in the planner results. 3) Reorganise comments so that there are not multiple tabs between the code and the start of a comment. Correct type and insert braces where important Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-31mobile cleanup: restyle construction of locationlistGravatar Jan Mulder
See also e6e1473e6. The construction of the locationlist was not the same as the 3 previous lists, and it needs the inclusion of a new model file (divelocationmodel.cpp) in the mobile app. In addition, as the mobile app is mainly interested in a simple stringList (model) to populate a HintsText field (or maybe later a combobox), this stringlist is added to the model, to easy interfacing with QML. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31mobile cleanup: unduplicate code and do not loop over dives (3)Gravatar Jan Mulder
See e6e1473e6. Exact same commit but here for the list of divemaster. The careful reader will spot a small addition to the clearDetailsEdit() QML function. Two more field are cleared. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31mobile cleanup: unduplicate code and do not loop over dives (2)Gravatar Jan Mulder
See e6e1473e6. Exact same commit but here for the list of buddies. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31mobile cleanup: unduplicate code and do not loop over dives (1)Gravatar Jan Mulder
This is the first of a set of commits that are (very) similar. It appeared that a number of more or less static lists, which are constructed by a loop over all dives in the logbook, were executed when changing focus to a next dive. For example, the in this commit addressed list of used dive suits. What was wrong was that the suitList was linked to a dive. There is only a need to construct the list of used suits when data is changed (and obviously, once on startup of the app). Further, it appeared that a lot of code was duplicated and that we can use (in this case) the same code from the desktop completionmodels.cpp. Basically, this commit involves the following changes: - include completionmodels.cpp in mobile and desktop (so move it from the desktop only category to the generic category). - remove double code from DiveObjectHelper.cpp - Do not differentiate in the init phase and the normal refresh of the list - the per dive logic is now only the getting of a previously constructed list (in init or update of the divelist). There are no visible changes in the UI, other than a better performance when scrolling over dive details. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31uemis: code refactoringGravatar Oliver Schwaneberg
- Variable max_deleted_seen had no effect and is removed. - Results of read/write operations are evaluated to assert success and to prevent compiler warnings. Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-01-31Make report_error() reentrantGravatar Berthold Stoeger
Remove the global error buffer and pass the error string directly to the frontend. The frontend is then responsible for accumulating errors. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-31uemis: Fix mapping of object_ids to dive numbersGravatar Oliver Schwaneberg
When performing a factory reset to an uemis, the object_ids within the divelog will not be reset. Nevertheless, the dive numbers are reset to 1. So, the first log will have a positive offset n to the first dive number. The uemis-downloader used the object_id from the logs as a start point for getDive, if dives were already synced before. This causes the sync to stall. I prevent this by subtracting the lowest object_id from the requested before using it as dive number. Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-01-27uemis: speed up synchronisation of same divesitesGravatar Oliver Schwaneberg
uemis-downloader downloads the dive spot for each dive, even if the same location was already downloaded before within the ongoing synchronization run. I modified the function "get_uemis_divespot" to remember all requested divespot_ids and their mapping to uuids. New helper functions: - static void erase_divespot_mapping() - static void add_to_divespot_mapping(int divespot_id, uint32_t dive_site_uuid) - static bool is_divespot_mappable(int divespot_id) - static uint32_t get_dive_site_uuid_by_divespot_id(int divespot_id) The memory leak is removed through the call of erade_divespot_mapping(). Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-01-26Limit recreational dives to 6 hoursGravatar Robert C. Helling
Otherwise, with large gradient factors, one can have infinite NDL which result in an infinite loop when no gas is set. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-01-24Planner: print icd information at 0.1 resolutionGravatar Willem Ferguson
The gas fractions (in %) are now printed at a resolution of 0.1% and not at 0.01% as previously. The string in the info box that provides icd data is reformatted so that the info-box is as narrow as possible. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-24Do not add double ConnectionList itemsGravatar Jan Mulder
Refuse to add a ConnectionList row, when the row is already there. This, obviously, prevents double items. Fixes: #1069 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-21Only give ICD warning if pN2 increasesGravatar Robert C. Helling
as otherwise there are warning on the descent. The ICD line in the info box is generated for all gas switches with decreasing He content. Also change the presentation in the info box to align it with the notes. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-01-21Planner notes min gas: Remove incorrect line wrap inside printf stringGravatar Stefan Fuchs
With old code the tabs at the start of the second line were incorrectly added to the string. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-21Planner notes ICD: Format HTML with DIV, do table title differentlyGravatar Stefan Fuchs
In the planner notes format the HTML for different sections with div tags. Put the table title for the ICD table outside the table because then the alignment looks a little bit nicer. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-21Planner notes ICD: Coding style change onlyGravatar Stefan Fuchs
Avoid the need for a char array for the "old_gas_name" by passing two pointers to the gasmixes to the add_icd_entry function and calling helper function gasname() there twice. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-21Planner notes ICD: Print correct runtime for gaschangeGravatar Stefan Fuchs
If a gaschange happens at the beginning of a segment, currently the wrong runtime (end of segment time) is printed in the ICD table. This is corrected here. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-20Move function isobaric_counterdiffusion()Gravatar Willem Ferguson
Move the above function from plannernotes.c to dive.c so that it is available to be called from the dive log part of the software, and not only from the planner. The following was done: 1) Edit the comment above the code to make it more accurate 2) Move the structure icd_data to dive.h 3) Create an external reference in dive.h for the above function 4) Copy the body of isobaric_counterdiffusion() to dive.c Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-19Implement ICD calculations in planner outputGravatar Willem Ferguson
This patch implements the calculation and printing of icd parameters in the dive planner output. It does: 1) icd parameters are calculated following the rule-of-fifths for OC trimix dives. For each gas change on the ascent that involves helium, the change in gas composition as well as the change in partial pressures are shown. If rule-of-fifths is exceeded, a warning message is prinetd. 2) An independent function is provided that in principle enables calculation of icd paramaters outside of the context of the dive planner. Further updates to icd calculations These changes respond to #1047. Code style conventions have been improved. The ICD table is now also printed when the planner is set to verbatim mode. The code that created the html icd results has been moved to a function. This does not make the code more efficient (many parameters passed) but it makes the code more clean. Free a new dynamic variable (old_gas_name) Stylistic changes to new code in plannernotes.c Changes in comments to explain some of the changes I made. Preparation of comments and functioning of isobaric_counterdiffusion() and its dependent data structure for possible transfer to dive.c and dive.h after finalisation and merging of the present PR. Smaller stylistic changes to conform to our coding rules. The several comments and suggestions during github review (@atdotde, @leolit123, @sfuchs79) are incorporated. Fixed up mis-aligned comments and text descriptions by replacing tab characters with space characters, thereby hard-forcing alignment of indented lines of text. Remove parameter *dive from function isobaric_counterdiffusion(). Improve a few constructs to conform to our style rules. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-19Improve profile display in plannerGravatar Willem Ferguson
This patch allows the planner to save the last manually-entered dive planner point of a dive plan. When the plan has been saved and re-opened for edit, the time of the last-entered dive planner point is used to ensure that dive planning continues from the same point in the profile as was when the original dive plan was saved. Mechanism: 1) In dive.h, create a new dc attribute dc->last_manual_time with data type of duration_t. 2) In diveplanner.c, ensure that the last manually-entered dive planner point is saved in dc->last_manual_time. 3) In save-xml.c, create a new XML attribute for the <divecomputer> element, named last-manual-time. For dive plans, the element would now look like: <divecomputer model='planned dive' last-manual-time='31:17 min'> 4) In parse-xml.c, insert code that recognises the last-manual-time XML attribute, reads the time value and assigns this time to dc->last_manual_time. 5) In diveplannermodel.cpp, method DiveplannerPointModel::loadfromdive, insert code that sets the appropriate boolean value to dp->entered by comparing newtime (i.e. time of dp) with dc->last_manual_time. 6) Diveplannermodel.cpp also accepts profile data from normal dives in the dive log, whether hand-entered or loaded from dive computer. It looks like the reduction of dive points for dives with >100 points continues to work ok. The result is that when a dive plan is saved with manually entered points up to e.g. 10 minutes into the dive, it can be re-opened for edit in the dive planner and the planner re-creates the plan with manually entered points up to 10 minutes. The rest of the points are "soft" points, shaped by the deco calculations of the planner. Improvements: Improve code for profile display in dive planner This responds to #1052. Change load-git.c and save-git.c so that the last-manual-time is also saved in the git-format dive log. Several stylistic changes in text for consistent C source code. Improvement of dive planner profile display: Do some simplification of my alterations to diveplannermodel.cpp Two small style changes in planner.c and diveplannermodel.cpp as requested ny @neolit123 Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-19Unify username handling of remote git repositoriesGravatar Berthold Stoeger
The username was extracted from https:// urls but not from ssh:// urls. Unify this by extracting the username from any remote url. This is done with regard to unifying the file handling in the frontend. For this approach to work, the credential callback of the ssh:// transport had to be adapted. It now also supports username/password in addition to private-key authentication. Currently, the only way the user can use the username/password authentication is by deleting a potential public key. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-19Support non-https:// repositories for savingGravatar Berthold Stoeger
On saving to a remote git repository, the transport was set to https://, which broke saving to ssh:// repositories. Instead determine the transport from the remote url. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-19Create local cache and push to remote for any remote repositoryGravatar Berthold Stoeger
This used to be done only for cloud repositories. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-19Check cloudserver availability only for cloud repositoriesGravatar Berthold Stoeger
The check used to be done for any https:// repository. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-19Factor out counting of authentication attempts into functionGravatar Berthold Stoeger
Moreover, make the maximum number of authentication attempts a const variable. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-19Use different preference file for mobileGravatar Jan Mulder
This is a change mainly for developers working on both mobile and desktop application. As the current setup is that all preferences are stored in one file (Subsurface.conf), for both mobile and desktop, the unwary developer might get confused that the things tested on mobile-on-desktop are not working on mobile-on-device. As we share a lot of code between the desktop and the mobile code, also our fairly extensive set of preferences play a significant role in the inner workings of our applications. So, this commit introduces an own preferences file for mobile (on desktop) resulting in the preferences between the plain desktop apllication now invisible to the mobile-on-desktop application and vise versa. Making the mobile-on-desktop a much more realistic test plaform for mobile development. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-19Checking for ACK for getDive.Gravatar Oliver Schwaneberg
get_matching_dive does not check if the DC wrote an acknowledgement for the requested dive. As result, the sync stalls if dive number 0 is not available. Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-01-18code cleanup: translators are not globalGravatar Jan Mulder
Un-globalize unused global variables. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-17Use format_string() in core/git_access.cGravatar Berthold Stoeger
Since this helper-function exists, we might just use it. A subtle reuse of a buffer (string of second use was known to be shorter than string of first use) was replaced by a separate allocation. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-13Fix leak(s) in core/git-access.cGravatar Berthold Stoeger
The libgit2 functions git_cred_ssh_key_new() and git_cred_userpass_plaintext_new() copy their arguments. Therefore, free the string arguments or don't copy them in the first place. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-11Fix indentations for plannernotes.cGravatar Willem Ferguson
The last 2 commits have now been squashed. S Fuchs's comment on line 315 has been fixed Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-11Move always true ++lineptr out of while-conditionGravatar Berthold Stoeger
In core/file.c move ++lineptr out of the while condition !empty_string(lineptr) && (lineptr = strchr(lineptr, '\n') && ++lineptr since it always evaluates to true. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-11Use helper function empty_string() instead of manual checksGravatar Berthold Stoeger
For code consistency, substitute boolean expressions: s && *s -> !empty_string(s) s && s[0] -> !empty_string(s) !s || !*s -> empty_string(s) !s || !s[0] -> empty_string(s) Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-11Introduce helper function empty_string()Gravatar Berthold Stoeger
There are ca. 50 constructs of the kind same_string(s, "") to test for empty or null strings. Replace them by the new helper function empty_string(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-11Change return code of string comparison functions to boolGravatar Berthold Stoeger
These functions were returning 0 or 1 anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10Typo: indice -> indexGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10cleanup: fix possbile buffer overrunGravatar Jan Mulder
No reason to mess around with a 5 byte buffer when we have a proper buffer available to receive a possibly 8 byte output based on the format string. And silences compiler warning. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10cleanup: initilize local variableGravatar Jan Mulder
Silence compiler warning by correctly initializing local variable. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>