Commit graph

315 commits

Author SHA1 Message Date
jan Iversen
d48a748a25 mobile-widgets: limit use of QSettings in qmlmanager
Replace QSettings for userName/Password/credentials with proper qPrefCloudStorage calls

Signed-off-by: Jan Iversen <jani@apache.org>
2019-12-24 08:25:51 +09:00
jan Iversen
bf7954ebe7 core: remove LOG_STP from mobile
LOG_STP is on longer providing the data needed, since a lot of the startup
is indirectly in QML, furthermore using the xcode project and running profiler
gives much more detailed information

Signed-off-by: Jan Iversen <jani@apache.org>
2019-12-13 07:04:00 -05:00
jan Iversen
53069fe777 mobile-widgets: activate uploadDiveShare in qmlmanager
Remove "TO BE IMPLEMENTED" and add call doUpload

Connect signal to signal in QMLManager to avoid registring the
upload class.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-12 21:35:55 -05:00
jan Iversen
4b2cae3f7c mobile-widgets: make upload signals available to QML
Connect signal to signal in QMLManager to avoid registring the
upload class.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
jan Iversen
03c9cdfbed mobile-widgets: activate uploadDiveLogsDE in qmlmanager
Remove "TO BE IMPLEMENTED" and add call doUpload

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11 12:36:43 -05:00
Berthold Stoeger
4b1a3a1a6e Selection: move selection functions from divelist.c to selection.c
Since we now have a selection.c translation unit, put the selection-
related functions there.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-04 13:00:23 +01:00
jan Iversen
27ce89a6e5 mobile-widgets: add export functionality to qmlmanager
Add enum with different export types (used to signal which type
of export QML desires).

Add QML export functions (one for file and one for upload to web)

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-03 21:30:39 -08:00
Dirk Hohndel
4f0d437f1e Mobile: add ability to directly open support email
This is even easier and more obvious than copying the logs on the About page
and then manually creating an email and pasting those logs.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-10 21:59:32 +01:00
Berthold Stoeger
794066b236 Cylinders: access cylinders with get_cylinder()
Instead of accessing the cylinder table directly, use the get_cylinder()
function. This gives less unwieldy expressions. But more importantly,
the function does bound checking. This is crucial for now as the code
hasn't be properly audited since the change to arbitrarily sized
cylinder tables. Accesses of invalid cylinder indexes may lead to
silent data-corruption that is sometimes not even noticed by
valgrind. Returning NULL instead of an invalid pointer will make
debugging much easier.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
7c9f46acd2 Core: remove MAX_CYLINDERS restriction
Instead of using fixed size arrays, use a new cylinder_table structure.
The code copies the weightsystem code, but is significantly more complex
because cylinders are such an integral part of the core.

Two functions to access the cylinders were added:
get_cylinder() and get_or_create_cylinder()
The former does a simple array access and supposes that the cylinder
exists. The latter is used by the parser(s) and if a cylinder with
the given id does not exist, cylinders up to that id are generated.

One point will make C programmers cringe: the cylinder structure is
passed by value. This is due to the way the table-macros work. A
refactoring of the table macros is planned. It has to be noted that
the size of a cylinder_t is 64 bytes, i.e. 8 long words on a 64-bit
architecture, so passing on the stack is probably not even significantly
slower than passing as reference.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Dirk Hohndel
15674f1a71 Mobile: modify filter so that all models get notified
When we change the filter string, we need to make sure that the collapsed model is
also aware of the change.

Similarly, instead of just calling resetFilter and directly changing the core
data structures, we need to set the filter to the empty string which ensures
that all three models get notified and the view updates correctly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
c759157331 Mobile: setup CollapsedDiveListSortModel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
3a7b8d73d8 Mobile: let the user know if we can't save changes
While the error that caused this to happen should be fixed, we should at least
let the user know if things failed catastrophically and we can't figure out how
to save their data.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
ccace53b83 Mobile: remember if we were able to open the local cache
If there is a local cache, we at least once successfully accessed the cloud, so
this is a valid cloud based git tree.

Without this change we run into a subtle bug: after a fresh install, or when
switching users, when the cloud data is accessed the very first time, we don't
remember that this was indeed loaded from the cloud. So if we then download
from a dive computer or make any other changes to the dive log, we cannot save
those dives to cloud storage - but we fail silently doing so. Which to the user
would look that inexplicable data loss.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
08e2013d1e Mobile: remove useless attempt to prevent access to the cloud
This code really made no sense, adding a comment to try to explain that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
4111de70e8 Mobile: drop extra argument to QString
Clearly a cut and paste error. Only creates a harmless warning, still...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
84920fd657 Mobile: change show/hide busy functions
The old code was ill named - this way the busy spinner itself
becomes reusable with a reasonable set of function names.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
bf6a644fc6 Mobile: provide better tracking of applied GPS fixes
Also reset the page stack to make sure we don't end up with stale data.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
e6298f9352 Mobile: allow editing dive number
No checks regarding duplicate numbers - we trust the user knows what
they are doing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-21 15:50:41 -04:00
Dirk Hohndel
5f11c94f02 Mobile: improve helper function to track selected dives
While on mobile there should always be only one selected dive, it's very
cheap to make sure that amount_selected is tracked correctly.  The
incrementing of amount_selected is done in case an invalid id is passed
in.

Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
9a73be9207 Mobile: add helper function to keep selection in sync
Without this the core data structure never gets updated to reflect which
dive is currently selected.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Berthold Stoeger
3db50aedea Cleanup: Turn DiveListSortModel into classical singleton
To make this class available from QMLManager, the run_ui()
function would create the object and then set a pointer in
QMLManager. It works, but is inconsistent with the rest of
the code. Therefore, make it a classical singleton class,
which is generated on demand.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-10-04 09:19:10 -07:00
Dirk Hohndel
cd98cb8921 Mobile: add more debugging output for screen width issue
Somehow we need to be able to figure out which width information is
correct.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-02 08:04:49 -07:00
Berthold Stoeger
649ac1f83a Mobile: clear dive data via model
Clearing the dive data directly in the core leaves us with an
inconsistent model. Therefore, clear via the model.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-27 16:33:37 -07:00
Dirk Hohndel
9ae7040a91 Revert the singleton PR
It turns out that this isn't working the way it was intended to.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-27 16:26:58 -07:00
Berthold Stoeger
4d3686edec Cleanup: Pass gpsTrackers directly to GpsListModel::update()
Instead of using the GpsLocation singleton in GpsListModel::update()
to extract the gpsTrackers, pass the gpsTrackers as function argument.

The caller has direct access to the GpsLocation object anyway and this
make things less entangled.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-25 13:35:30 -07:00
Berthold Stoeger
05200f9266 Cleanup: unify idiosyncratic singletons
The way we handle singletons in QML, QML insists on allocating the
objects. This leads to a very idiosyncratic way of handling
singletons: The global instance pointer is set in the constructor.

Unify all these by implementing a "SillySingleton" template. All
of the weird singleton-classes can derive from this template and
don't have to bother with reimplementing the instance() function
with all the safety-checks, etc.

This serves firstly as documentation but also improves debugging
as we will now see wanted and unwanted creation and destruction
of these weird singletons.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-25 13:35:30 -07:00
Dirk Hohndel
b2230855e6 Mobile: make sure QML gets notified when value changes
This addresses the following warning when running the mobile app:
INFO: QQmlExpression: Expression qrc:/qml/DownloadFromDiveComputer.qml:339:5 depends on non-NOTIFYable properties:
INFO:     QMLManager::DC_forceDownload

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 16:31:27 -07:00
Dirk Hohndel
cf4dbbe5f2 Android: print Android HW information
This uses Android methods through JNI.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 15:13:10 -07:00
Dirk Hohndel
e68d287c91 Mobile: print out Qt information on the system we are running on
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 15:13:10 -07:00
Berthold Stoeger
6a9df3bba3 Mobile: transform DiveObjectHelper into value-type
Instead of handing a reference-to-dive to QML, prerender all the needed
properties and store them as values in DiveObjectHelper. Exception:
 - date(): generated from timestamp
 - time(): generated from timestamp
 - cylinderList(): does not depend on dive anyway and should be made
   static.

This hopefully avoids the random mobile crashes that we are seeing.
Clearly, this code needs to be optimized, but it is a start.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
a4f3580e10 Mobile: remove dive argument from DiveListModel::insertDive()
Since DiveListModel does not keep its own list of dives anymore,
insertDive() doesn't use the DiveObjectHelper argument. Remove it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
feb11f6f5f Mobile: use value semantics for DiveObjectHelper in qmlmanager.cpp
Instead of creating a pointer-to-DiveObjectHelper in commitChanges,
use a normal object. Thus, we don't have to think about ownership
issues with respect to this object.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
0026aa3955 Mobile: replace clear()/addAllDives() pairs by reload()
The clear()/addAllDives() pair was bogus as the former didn't
clear the model (this is not possible anymore - the model
represents the core dive list) and the latter readded all
dives again.

Replace this by a reload() function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14 13:20:59 +02:00
Dirk Hohndel
b1ba687a1d Mobile: deal better with incorrect credentials
This could happen if the password was changed from a different Subsurface instance.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-11 21:50:41 +01:00
Dirk Hohndel
f6f6a20555 Mobile: check if credentials are valid before accepting them
It seems crazy to simply assume that the later code can successfully
untangle the various states that the credentials can be in - let's just
stay on the credentials enrty page until we have verified credentials.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-11 21:50:41 +01:00
Dirk Hohndel
d717b9d2a7 Mobile: add helper function to check cloud credentials
This should do the right thing in the various situations of correct &
verified credentials, credentials needing PIN verification, invalid
email/password combination, incorrect PIN, correct PIN.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-11 21:50:41 +01:00
Dirk Hohndel
0eb14828b5 Mobile: use a default weight name when adding weight system
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-11 12:23:33 -07:00
Berthold Stoeger
6b92edc9ab Mobile: support editing of dives with no weightsystem
If a dive has no weightsystems, editing the weight system has to add
a new entry in the table. Implement that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-11 12:23:33 -07:00
Berthold Stoeger
0cce3ef2a8 Mobile: update dive site model if dive sites are created
Always keep the dive site model up to date when adding dive sites.
This hopefully avoids creation of invalid indexes followed by crashes.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-10 09:55:11 -07:00
Berthold Stoeger
5da09a21bb Cleanup: move error reporting function declarations to errorhelper.h
Move the declarations of the "report_error()" and "set_error_cb()"
functions and the "verbose" variable to errorhelper.h.
Thus, error-reporting translation units don't have to import the
big dive.h header file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08 16:26:30 -07:00
Berthold Stoeger
a5e7f4253a Core: dynamically resize weight table
Replace the fixed-size weightsystem table by a dynamically
relocated table. Reuse the table-macros used in other parts
of the code.

The table stores weightsystem entries, not pointers to
weightsystems. Thus, ownership of the description string is
taken when adding a weightsystem. An extra function adds
a cloned weightsystem at the end of the table.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 06:01:07 -07:00
Berthold Stoeger
7f4d9db962 Cleanup: move trip-related functions into own translation unit
These functions were spread out over dive.c and divelist.c.
Move them into their own file to make all this a bit less monolithic.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Linus Torvalds
263c87b1cc Update (and fix) device mobile ID's for Scubapro dive computers
I'm not sure this is actually relevant for anything any more, but this
adds the USB device ID's for the Scubapro G2 Console and HUD versions.
It also fixes things to use the proper vendor name (a bit too much
cut-and-paste, where the code said "Suunto" instead of "Scubapro").

The real device ID changes are in libdivecomputer, this is just the
Android xml list for recognized USB devices that likely nobody really
uses.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-04-25 13:22:21 +02:00
Berthold Stoeger
e99c4c9059 Dive site: introduce proxy model DiveSiteSortedModel
The LocationInformationModel used to sort its entries and was completely
rebuilt after every change. This makes it rather complex to support
incremental changes.

Instead, keep LocationInformationModel sorted by UUID so that indexes
are consistent with indices in the core dive site table.

Implement sorting by other columns than name and enable sorting in the
dive site view.

Finally, don't cache the list of dive site names for the mobile app,
since that would also need some rather convoluted methods of keeping
the list up to date. Calculate it on the fly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
e2df38d868 Dive site: add dive site ref-counting
Instead of setting dive->dive_site directly, call the
add_dive_to_dive_site() and unregister_dive_from_dive_site()
functions. In the parser this turned out to be a bit tricky.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
f3e1187e65 Cleanup: move parse-function declarations out of "dive.h"
Move the declaration of these functions to "file.h" and "parse.h"
according to the translation unit they are defined in. Thus, not
all users of "dive.h" have to suck in "sqlite3.h".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
31291b1c56 Dive site: set UUID only on save or load
Since the UUID will be overwritten on save and is only used on save
and load, set it only on save or load. For other created dive sites,
leave the UUID field uninitialized.

This means that the UUID will change between saves. Let's see how
the git saver handles that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
82af1b2377 Undo: make undo-system dive site-aware
As opposed to dive trips, dive sites were always directly added
to the global table, even on import. Instead, parse the divesites
into a distinct table and merge them on import.

Currently, this does not do any merging of dive sites, i.e. dive
sites are considered as either equal or different. Nevertheless,
merging of data should be rather easy to implement and simply
follow the code of the dive merging.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
37146c5742 Parser: parse into custom dive site table
To extend the undo system to dive sites, the importers and downloaders
must not parse directly into the global dive site table. Instead,
pass a dive_site_table argument to parse into.

For now, always pass the global dive_site_table so that this commit
should not cause any functional change.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00