Commit graph

19844 commits

Author SHA1 Message Date
Berthold Stoeger
37994740ce core: remove alloc_filter_preset() and free_filter_preset()
All users of that are now C++ and don't need these helpers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 22:01:23 +01:00
Berthold Stoeger
c9a10733d3 core: turn a memblock in the parser to std::string
This avoid memory-management troubles. Had to convert a few
of the parsers (cochran, datatrak, liquivision) to C++.
Also had to convert libdivecomputer.c. This was less
painful than expected.

std::string is used because parts of the code assumes
that the data is null terminated after the last character
of the data. std::string does precisely that.

One disadvantage is that std::string clears its memory
when resizing / initializing. Thus we read the file onto
freshly cleared data, which some might thing is a
performance regression. Until someone shows me that this
matters, I don't care.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 22:01:23 +01:00
Berthold Stoeger
615dd376f3 core: make get_sha() return std::string
This was crazy: it returned a local static buffer, i.e. was
inherently non-reentrant.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 21:31:54 +01:00
Berthold Stoeger
3e60f6c390 core: port printGPSCoordsC to return std::string
Less memory management hassle.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 21:31:54 +01:00
Berthold Stoeger
68ddce5b11 core: port filterpreset.cpp to std::string
Less memory management hassle.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 21:31:54 +01:00
Berthold Stoeger
5d36ba4593 core: convert filter_constraint_data_to_string to C++
Return an std::string to avoid memory management headaches.

While doing that, convert time.c to C++ so that
format_datetime directly returns an std::string.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 21:31:54 +01:00
Berthold Stoeger
a49e84082c core: make fp_get_data return an std::string
No need for manual memory management.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 21:31:54 +01:00
Berthold Stoeger
e456c1b574 core: convert parser_state to C++
Add constructor, destructor and use std::string for memory
management of text data.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 21:31:54 +01:00
Berthold Stoeger
f5e3004ab5 core: convert core/import-*.c to C++
import-csv.c was crazy with implicit (const char *) to (char *)
conversions!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 21:31:54 +01:00
Berthold Stoeger
3a130fe242 core: convert parse-xml.c and parse.c to C++
This was very annoying, because the old code was not const-clean
at all and trampled all over buffers. This makes the new code
pretty messy for now.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 21:31:54 +01:00
Berthold Stoeger
5285243a40 mobile: turn testqml into a std::string
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 21:31:54 +01:00
Berthold Stoeger
af94f21ea1 divetripmodel: explicitly convert char * to QString
The automatic conversion from char * to QVariant failed to
compile for me. Let's hint that this should be interpreted
as a string. No idea, why this happens for me, but apparently
not on CI.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 21:31:54 +01:00
Berthold Stoeger
f9916652db core: use std::string in load-git.cpp
Make the memory management easier to follow. I feel that the old
code was leaking left and right, but not sure because it was so
intractable.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 21:31:54 +01:00
Berthold Stoeger
9e97bbfb18 core: use std::string in parser state of git loader
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 20:50:59 +01:00
Berthold Stoeger
bf05dec52b core: turn saved_git_id into a std::string
Simplifies memory management. Think about unglobalizing this,
once everything is in C++ so that we can put an std::string
into struct divelog.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 20:50:58 +01:00
Berthold Stoeger
45cb0c09fc core: convert load-git.c to C++
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 20:50:58 +01:00
Berthold Stoeger
9cd5c0e0e6 core: convert file.c to C++
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 20:50:58 +01:00
Berthold Stoeger
b060df91e7 core: convert save-xml.c to C++
This includes using the C++ version of membuffer. There appears
to not have been a leak, because the buffer is freed in
flush_buffer(), but usage was somewhat inconsistent and hard to
follow.

Also, convert some string handling to std::string to avoid free()
madness.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 20:50:58 +01:00
Berthold Stoeger
be3a497885 core: port subsurface-startup.c to C++
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 20:50:58 +01:00
Berthold Stoeger
6b0cdb028f core: turn a few string helpers into C++
get_changes_made(), subsurface_user_agent() and normalize_cloud_name()
are only called from C++.

Avoids having to manually free the returned value and is therefore
more robust against leaks.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 20:50:58 +01:00
Berthold Stoeger
b8b55eedaf core: convert git-access.c to C++
Had to make sha.h compatible with C++.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 20:50:58 +01:00
Berthold Stoeger
c2a5e3eb73 core: use C++-style memory management for struct dir
The code is now much easier to check for memory leaks,
since there are no explicit free()s. Yes, memory is not
released immediately, but that should be of no concern.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 20:11:43 +01:00
Berthold Stoeger
929e7ea23e core: convert core/save-git.c to C++
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 20:11:43 +01:00
Berthold Stoeger
c8c533e791 core: convert sample.c to C++ and add default constructor
This changes default behavior when creating a sample struct
in C++ code: it is now initialized to default values. If this
ever turns out to be a performance problem, we can either add
additional constructors or use special functions that do
not initialize memory, such as make_unique_for_overwrite.

This removes non-standard (respectively >C++20) constructs,
namely designated initializers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 20:11:43 +01:00
Berthold Stoeger
f47196087e core: replace dynamic arrays in dive.cpp by C++ constructs
Avoid error-prone malloc/free pairs. This uses somewhat
obscure constructs to stay as close as possible to the
original C code. Notably, it uses mostly unique_ptr<T[]>
which doesn't store the length of the array, because the
length is supposed to be known.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 20:11:43 +01:00
Berthold Stoeger
317a1c91d4 core: convert dive.c to C++
Long term project: convert core to C++ so that we can
use higer-level constructs, notably std::vector<>.

This does not change any code - only fixes compile issues.

Mostly casting of (void *) to the proper type. Also designated
initialization of the sample struct had to be rearranged.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 20:11:43 +01:00
Berthold Stoeger
812e9ab1d7 core: make translate() accessible from C++
In the core, we usually want C strings, not QStrings. Therefore,
make translated C strings directly available from C++.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 20:11:43 +01:00
Berthold Stoeger
a4091189b0 cleanup: use proper size when allocating string
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 19:21:59 +01:00
Berthold Stoeger
ef5859437a cleanup: remove ominous pointer calculation
Firstly, why calculate something when the next statement is a return
anyway.

Secondly, the calculation subtracts two completely unrelated pointers.

This must be some code reshuffling artifact.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-01 12:28:52 -08:00
Michał Sawicz
96470227d5 snap: fix grade determination
Determine grade based on whether we actually managed to check out the
buildnumber.

This assumes that the tree is clean for building a stable snap (one that
can be published to candidate and stable channels).

Signed-off-by: Michał Sawicz <michal@sawicz.net>
2024-03-01 09:03:28 -08:00
Berthold Stoeger
cb3e21c443 cleanup: remove unused data and bogus UNUSED in libdivecomputer.c
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-01 07:57:34 -08:00
Michael Keller
cedccbc340 Import: Update the libdivecomputer Submodule.
Update the libdivecomputer submodule.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-02-28 15:38:48 +13:00
Michael Keller
3ccd7e4bc7 Import: Add Support for New Dive Computer Models Supported by Libdivecomputer.
Add support for the new dive computer models that have been added in the
latest version of libdivecomputer.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-02-28 15:38:48 +13:00
Michael Keller
f495c4f002 Import: Update libdivecomputer to the Latest Version.
Update `libdivecomputer` to the latest upstream version.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-02-28 15:38:48 +13:00
Miika Turkia
4642f12e29 Divelogs.de integration update
Adding temp support for divelogs.de import/export.

Adding export of divecomputer model to divelogs.de export

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2024-02-27 15:44:32 -08:00
Michał Sawicz
c3aa505f2b snap: fix grade-setting
> variable 'grade' can be set only once.

Signed-off-by: Michał Sawicz <michal@sawicz.net>
2024-02-27 06:52:45 -08:00
Berthold Stoeger
bf5510e5a6 cleanup: remove bogus forward declaration of inexistent structure
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-02-27 13:14:34 +01:00
Dirk Hohndel
0cb5273766 Update translation source strings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2024-02-24 10:30:02 -08:00
transifex-integration[bot]
bca8eabcec Translate subsurface_source.ts in bg_BG
100% translated source file: 'subsurface_source.ts'
on 'bg_BG'.
2024-02-24 10:30:02 -08:00
transifex-integration[bot]
5ab5bc51cd Translate subsurface_source.ts in es_ES
100% translated source file: 'subsurface_source.ts'
on 'es_ES'.
2024-02-24 10:30:02 -08:00
transifex-integration[bot]
36a76e015f Translate subsurface_source.ts in es_ES
100% translated source file: 'subsurface_source.ts'
on 'es_ES'.
2024-02-24 10:30:02 -08:00
Dirk Hohndel
4b0fe3bc38 mobile: show incorrect cloud password state
While the startup flow should make it obvious when a user is not
correctly logged into the cloud, we still do see fairly frequent
situations where a user has an incorrect password on a mobile device and
is confused about why their data isn't syncing with their PC. Now this
is clearly shown in the main menu.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2024-02-23 20:12:12 -08:00
Berthold Stoeger
fac006148f profile: make event hiding persistent across change of dive
Currently, the "hide event" status is lost when switching dives.
Save it in the event struct instead to make it persistent.

In the future we might save this information to the log file.
Then this should be integrated in the undo-system.

This commit also makes the "unhide events" menu entry more
fine grained: It now differentiates between individual
events and event types.

Note this adds an additional field to the event structure.
There is a "deleted" field that is used internally for
book-keeping, but probably should be removed. Not touching
this at the moment as long as this is C-only code. When/if
switching to C++ we can make the event linked list a table,
which will make this much simpler.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-02-23 09:46:16 -08:00
Berthold Stoeger
4783e85b59 cleanup: fix typos in comments
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-02-23 09:46:16 -08:00
Berthold Stoeger
4422dbb52b events: make event severity explicit
Currently the event type code uses libdivecomputer's flags
to differentiate between events. Make this explicit and extract
the event severity.

The reason is that later we want to be more explicit about showing/
hiding events and thereto we must format the name of events.

Moreover, this encapsulates the complexities of extracting
the severity in the event code (that used to be in the profile
code).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-02-23 09:46:16 -08:00
Berthold Stoeger
6ad7e577f1 core: pass event to event_type functions
Instead of passing name / flag pairs to event_type functions,
pass a pointer to the event. This hides implementation details.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-02-23 09:46:16 -08:00
Berthold Stoeger
d3c9cb14bf core: rename eventname.* to eventtype.*
This structure is used to hide events of a certain type.
The type was inferred from its name, but now includes flags.
So event_type is more appropriate.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-02-23 09:46:16 -08:00
Dirk Hohndel
7a74a6c426 enable Korean translations for Subsurface and Subsurface-mobile
A great thank you to Wonchan Lee!

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2024-02-19 14:46:48 -08:00
transifex-integration[bot]
4877c5d99a Translate subsurface_source.ts in ko_KR
100% translated source file: 'subsurface_source.ts'
on 'ko_KR'.
2024-02-19 14:46:48 -08:00
transifex-integration[bot]
2ba04c71f1 Translate subsurface_source.ts in ko_KR
100% translated source file: 'subsurface_source.ts'
on 'ko_KR'.
2024-02-19 14:46:48 -08:00