Compare commits

...

5 Commits

Author SHA1 Message Date
Dirk Hohndel
4be64b97e6 update CHANGELOG
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-17 15:56:16 -07:00
Dirk Hohndel
102374b45e core: debug cert calls
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-17 15:18:12 -07:00
Dirk Hohndel
c344857953 core: bring back libgit2 certificate callback
Turns out that at least on Android libgit2 sometimes rejects valid
certificates. And I cannot quite figure out when and why. But since we
actually already checked the validity of the certificate when we called
canReachCloudServer() (and the Qt code handles certificates correctly),
we'll simply ignore this here and override the check to always return
true for our cloud server.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-17 15:18:12 -07:00
Dirk Hohndel
e5cd213a97 debug output: ensure our debug output is captured on Android
I would have bet money that Android used to send stderr to the logcat
log, but apparently it doesn't (anymore?). So in order to be able to
have a chance to debug weird cloud storage issues on Android, let's do
some wholesale replacement of fprintf(stderr,...) with our own version
of the INFO macro that we long ago borrowed from libdivecomputer (and
rename it to ensure we don't have a conflict there).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-17 15:18:12 -07:00
Dirk Hohndel
6b3cbb24f5 mobile UI: indicate status of verbose flag
This way the user can verify that they have set the log to verbose
mode in the developer menu.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-17 12:24:59 -07:00
10 changed files with 86 additions and 62 deletions

View File

@ -1,3 +1,4 @@
Mobile: fix false rejection of Subsurface cloud SSL certificate
Mobile: fix misdetection of Shearwater Petrel 2 on iOS
Desktop: fix creation of new cylinder types (names couldn't be the start of already existing names)
Mobile: fix no-cloud to cloud transition

View File

@ -177,7 +177,7 @@ static int reset_to_remote(git_repository *repo, git_reference *local, const git
git_object *target;
if (verbose)
fprintf(stderr, "git storage: reset to remote\n");
SSRF_INFO("git storage: reset to remote\n");
// If it's not checked out (bare or not HEAD), just update the reference */
if (git_repository_is_bare(repo) || git_branch_is_head(local) != 1) {
@ -286,6 +286,22 @@ int credential_https_cb(git_cred **out,
return git_cred_userpass_plaintext_new(out, username, password);
}
int certificate_check_cb(git_cert *cert, int valid, const char *host, void *payload)
{
UNUSED(payload);
if (verbose)
SSRF_INFO("certificate callback for host %s with validity %d\n", host, valid);
if (same_string(host, "cloud.subsurface-divelog.org") && cert->cert_type == GIT_CERT_X509) {
// for some reason the LetsEncrypt certificate makes libgit2 throw up on some
// platforms but not on others
// if we are connecting to the cloud server we alrady called 'canReachCloudServer()'
// which will fail if the SSL certificate isn't valid, so let's simply always
// tell the caller that this certificate is valid
return 1;
}
return valid;
}
static int update_remote(git_repository *repo, git_remote *origin, git_reference *local, git_reference *remote, enum remote_transport rt)
{
UNUSED(repo);
@ -296,7 +312,7 @@ static int update_remote(git_repository *repo, git_remote *origin, git_reference
const char *name = git_reference_name(local);
if (verbose)
fprintf(stderr, "git storage: update remote\n");
SSRF_INFO("git storage: update remote\n");
refspec.count = 1;
refspec.strings = (char **)&name;
@ -307,6 +323,7 @@ static int update_remote(git_repository *repo, git_remote *origin, git_reference
opts.callbacks.credentials = credential_ssh_cb;
else if (rt == RT_HTTPS)
opts.callbacks.credentials = credential_https_cb;
opts.callbacks.certificate_check = certificate_check_cb;
if (git_remote_push(origin, &refspec, &opts)) {
if (is_subsurface_cloud)
@ -333,7 +350,7 @@ static int try_to_git_merge(git_repository *repo, git_reference **local_p, git_r
outlocal[40] = outremote[40] = 0;
git_oid_fmt(outlocal, local_id);
git_oid_fmt(outremote, remote_id);
fprintf(stderr, "trying to merge local SHA %s remote SHA %s\n", outlocal, outremote);
SSRF_INFO("trying to merge local SHA %s remote SHA %s\n", outlocal, outremote);
}
git_merge_init_options(&merge_options, GIT_MERGE_OPTIONS_VERSION);
@ -341,31 +358,31 @@ static int try_to_git_merge(git_repository *repo, git_reference **local_p, git_r
merge_options.file_favor = GIT_MERGE_FILE_FAVOR_UNION;
merge_options.rename_threshold = 100;
if (git_commit_lookup(&local_commit, repo, local_id)) {
fprintf(stderr, "Remote storage and local data diverged. Error: can't get commit (%s)", giterr_last()->message);
SSRF_INFO("Remote storage and local data diverged. Error: can't get commit (%s)", giterr_last()->message);
goto diverged_error;
}
if (git_commit_tree(&local_tree, local_commit)) {
fprintf(stderr, "Remote storage and local data diverged. Error: failed local tree lookup (%s)", giterr_last()->message);
SSRF_INFO("Remote storage and local data diverged. Error: failed local tree lookup (%s)", giterr_last()->message);
goto diverged_error;
}
if (git_commit_lookup(&remote_commit, repo, remote_id)) {
fprintf(stderr, "Remote storage and local data diverged. Error: can't get commit (%s)", giterr_last()->message);
SSRF_INFO("Remote storage and local data diverged. Error: can't get commit (%s)", giterr_last()->message);
goto diverged_error;
}
if (git_commit_tree(&remote_tree, remote_commit)) {
fprintf(stderr, "Remote storage and local data diverged. Error: failed local tree lookup (%s)", giterr_last()->message);
SSRF_INFO("Remote storage and local data diverged. Error: failed local tree lookup (%s)", giterr_last()->message);
goto diverged_error;
}
if (git_commit_lookup(&base_commit, repo, base)) {
fprintf(stderr, "Remote storage and local data diverged. Error: can't get commit (%s)", giterr_last()->message);
SSRF_INFO("Remote storage and local data diverged. Error: can't get commit (%s)", giterr_last()->message);
goto diverged_error;
}
if (git_commit_tree(&base_tree, base_commit)) {
fprintf(stderr, "Remote storage and local data diverged. Error: failed base tree lookup (%s)", giterr_last()->message);
SSRF_INFO("Remote storage and local data diverged. Error: failed base tree lookup (%s)", giterr_last()->message);
goto diverged_error;
}
if (git_merge_trees(&merged_index, repo, base_tree, local_tree, remote_tree, &merge_options)) {
fprintf(stderr, "Remote storage and local data diverged. Error: merge failed (%s)", giterr_last()->message);
SSRF_INFO("Remote storage and local data diverged. Error: merge failed (%s)", giterr_last()->message);
// this is the one where I want to report more detail to the user - can't quite explain why
return report_error(translate("gettextFromC", "Remote storage and local data diverged. Error: merge failed (%s)"), giterr_last()->message);
}
@ -379,20 +396,20 @@ static int try_to_git_merge(git_repository *repo, git_reference **local_p, git_r
while (git_index_conflict_next(&ancestor, &ours, &theirs, iter)
!= GIT_ITEROVER) {
/* Mark this conflict as resolved */
fprintf(stderr, "conflict in %s / %s / %s -- ",
SSRF_INFO("conflict in %s / %s / %s -- ",
ours ? ours->path : "-",
theirs ? theirs->path : "-",
ancestor ? ancestor->path : "-");
if ((!ours && theirs && ancestor) ||
(ours && !theirs && ancestor)) {
// the file was removed on one side or the other - just remove it
fprintf(stderr, "looks like a delete on one side; removing the file from the index\n");
SSRF_INFO("looks like a delete on one side; removing the file from the index\n");
error = git_index_remove(merged_index, ours ? ours->path : theirs->path, GIT_INDEX_STAGE_ANY);
} else if (ancestor) {
error = git_index_conflict_remove(merged_index, ours ? ours->path : theirs ? theirs->path : ancestor->path);
}
if (error) {
fprintf(stderr, "error at conflict resplution (%s)", giterr_last()->message);
SSRF_INFO("error at conflict resplution (%s)", giterr_last()->message);
}
}
git_index_conflict_cleanup(merged_index);
@ -429,7 +446,7 @@ static int try_to_git_merge(git_repository *repo, git_reference **local_p, git_r
set_git_id(&commit_oid);
git_signature_free(author);
if (verbose)
fprintf(stderr, "Successfully merged repositories");
SSRF_INFO("Successfully merged repositories");
free_buffer(&msg);
return 0;
@ -460,7 +477,7 @@ static int try_to_update(git_repository *repo, git_remote *origin, git_reference
int ret = 0;
if (verbose)
fprintf(stderr, "git storage: try to update\n");
SSRF_INFO("git storage: try to update\n");
if (!git_reference_cmp(local, remote))
return 0;
@ -502,7 +519,7 @@ static int try_to_update(git_repository *repo, git_remote *origin, git_reference
/* Is the local repo the more recent one? See if we can update upstream */
if (git_oid_equal(&base, remote_id)) {
if (verbose)
fprintf(stderr, "local is newer than remote, update remote\n");
SSRF_INFO("local is newer than remote, update remote\n");
git_storage_update_progress(translate("gettextFromC", "Push local changes to cloud storage"));
return update_remote(repo, origin, local, remote, rt);
}
@ -542,7 +559,7 @@ static int check_remote_status(git_repository *repo, git_remote *origin, const c
git_reference *local_ref, *remote_ref;
if (verbose)
fprintf(stderr, "git storage: check remote status\n");
SSRF_INFO("git storage: check remote status\n");
if (git_branch_lookup(&local_ref, repo, branch, GIT_BRANCH_LOCAL)) {
if (is_subsurface_cloud)
@ -562,6 +579,7 @@ static int check_remote_status(git_repository *repo, git_remote *origin, const c
opts.callbacks.credentials = credential_ssh_cb;
else if (rt == RT_HTTPS)
opts.callbacks.credentials = credential_https_cb;
opts.callbacks.certificate_check = certificate_check_cb;
git_storage_update_progress(translate("gettextFromC", "Store data into cloud storage"));
error = git_remote_push(origin, &refspec, &opts);
} else {
@ -593,7 +611,7 @@ void delete_remote_branch(git_repository *repo, const char *remote, const char *
git_config_delete_entry(conf, "http.proxy");
}
if (git_remote_lookup(&origin, repo, "origin")) {
fprintf(stderr, "Repository '%s' origin lookup failed (%s)", remote, giterr_last() ? giterr_last()->message : "(unspecified)");
SSRF_INFO("Repository '%s' origin lookup failed (%s)", remote, giterr_last() ? giterr_last()->message : "(unspecified)");
return;
}
/* fetch the remote state */
@ -602,7 +620,7 @@ void delete_remote_branch(git_repository *repo, const char *remote, const char *
f_opts.callbacks.credentials = credential_https_cb;
error = git_remote_fetch(origin, NULL, &f_opts, NULL);
if (error) {
fprintf(stderr, "remote fetch failed (%s)\n", giterr_last() ? giterr_last()->message : "authentication failed");
SSRF_INFO("remote fetch failed (%s)\n", giterr_last() ? giterr_last()->message : "authentication failed");
return;
}
/* delete the remote branch by pushing to ":refs/heads/<branch>" */
@ -616,8 +634,8 @@ void delete_remote_branch(git_repository *repo, const char *remote, const char *
error = git_remote_push(origin, &refspec, &p_opts);
free(branch_ref);
if (error) {
fprintf(stderr, "Unable to delete branch '%s'", branch);
fprintf(stderr, "error was (%s)\n", giterr_last() ? giterr_last()->message : "(unspecified)");
SSRF_INFO("Unable to delete branch '%s'", branch);
SSRF_INFO("error was (%s)\n", giterr_last() ? giterr_last()->message : "(unspecified)");
}
git_remote_free(origin);
return;
@ -632,21 +650,21 @@ int sync_with_remote(git_repository *repo, const char *remote, const char *branc
if (git_local_only) {
if (verbose)
fprintf(stderr, "don't sync with remote - read from cache only\n");
SSRF_INFO("don't sync with remote - read from cache only\n");
return 0;
}
if (verbose)
fprintf(stderr, "sync with remote %s[%s]\n", remote, branch);
SSRF_INFO("sync with remote %s[%s]\n", remote, branch);
git_storage_update_progress(translate("gettextFromC", "Sync with cloud storage"));
git_repository_config(&conf, repo);
if (rt == RT_HTTPS && getProxyString(&proxy_string)) {
if (verbose)
fprintf(stderr, "set proxy to \"%s\"\n", proxy_string);
SSRF_INFO("set proxy to \"%s\"\n", proxy_string);
git_config_set_string(conf, "http.proxy", proxy_string);
free(proxy_string);
} else {
if (verbose)
fprintf(stderr, "delete proxy setting\n");
SSRF_INFO("delete proxy setting\n");
git_config_delete_entry(conf, "http.proxy");
}
@ -668,7 +686,7 @@ int sync_with_remote(git_repository *repo, const char *remote, const char *branc
return 0;
}
if (verbose)
fprintf(stderr, "git storage: fetch remote\n");
SSRF_INFO("git storage: fetch remote\n");
git_fetch_options opts = GIT_FETCH_OPTIONS_INIT;
opts.callbacks.transfer_progress = &transfer_progress_cb;
auth_attempt = 0;
@ -676,6 +694,7 @@ int sync_with_remote(git_repository *repo, const char *remote, const char *branc
opts.callbacks.credentials = credential_ssh_cb;
else if (rt == RT_HTTPS)
opts.callbacks.credentials = credential_https_cb;
opts.callbacks.certificate_check = certificate_check_cb;
git_storage_update_progress(translate("gettextFromC", "Successful cloud connection, fetch remote"));
error = git_remote_fetch(origin, NULL, &opts, NULL);
// NOTE! A fetch error is not fatal, we just report it
@ -686,7 +705,7 @@ int sync_with_remote(git_repository *repo, const char *remote, const char *branc
report_error("Unable to fetch remote '%s'", remote);
if (verbose)
// If we returned GIT_EUSER during authentication, giterr_last() returns NULL
fprintf(stderr, "remote fetch failed (%s)\n",
SSRF_INFO("remote fetch failed (%s)\n",
giterr_last() ? giterr_last()->message : "authentication failed");
// Since we failed to sync with online repository, enter offline mode
git_local_only = true;
@ -706,7 +725,7 @@ static git_repository *update_local_repo(const char *localdir, const char *remot
git_reference *head;
if (verbose)
fprintf(stderr, "git storage: update local repo\n");
SSRF_INFO("git storage: update local repo\n");
error = git_repository_open(&repo, localdir);
if (error) {
@ -723,7 +742,7 @@ static git_repository *update_local_repo(const char *localdir, const char *remot
if (!git_branch_name(&name, head)) {
if (strcmp(name, branch)) {
char *branchref = format_string("refs/heads/%s", branch);
fprintf(stderr, "Setting cache branch from '%s' to '%s'", name, branch);
SSRF_INFO("Setting cache branch from '%s' to '%s'", name, branch);
git_repository_set_head(repo, branchref);
free(branchref);
}
@ -746,19 +765,19 @@ static int repository_create_cb(git_repository **out, const char *path, int bare
int ret = git_repository_init(out, path, bare);
if (ret != 0) {
if (verbose)
fprintf(stderr, "Initializing git repository failed\n");
SSRF_INFO("Initializing git repository failed\n");
return ret;
}
git_repository_config(&conf, *out);
if (getProxyString(&proxy_string)) {
if (verbose)
fprintf(stderr, "set proxy to \"%s\"\n", proxy_string);
SSRF_INFO("set proxy to \"%s\"\n", proxy_string);
git_config_set_string(conf, "http.proxy", proxy_string);
free(proxy_string);
} else {
if (verbose)
fprintf(stderr, "delete proxy setting\n");
SSRF_INFO("delete proxy setting\n");
git_config_delete_entry(conf, "http.proxy");
}
return ret;
@ -773,7 +792,7 @@ static git_repository *create_and_push_remote(const char *localdir, const char *
char *variable_name, *head;
if (verbose)
fprintf(stderr, "git storage: create and push remote\n");
SSRF_INFO("git storage: create and push remote\n");
/* first make sure the directory for the local cache exists */
subsurface_mkdir(localdir);
@ -812,7 +831,7 @@ static git_repository *create_local_repo(const char *localdir, const char *remot
git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
if (verbose)
fprintf(stderr, "git storage: create_local_repo\n");
SSRF_INFO("git storage: create_local_repo\n");
auth_attempt = 0;
opts.fetch_opts.callbacks.transfer_progress = &transfer_progress_cb;
@ -821,20 +840,21 @@ static git_repository *create_local_repo(const char *localdir, const char *remot
else if (rt == RT_HTTPS)
opts.fetch_opts.callbacks.credentials = credential_https_cb;
opts.repository_cb = repository_create_cb;
opts.fetch_opts.callbacks.certificate_check = certificate_check_cb;
opts.checkout_branch = branch;
if (is_subsurface_cloud && !canReachCloudServer())
return 0;
if (verbose > 1)
fprintf(stderr, "git storage: calling git_clone()\n");
SSRF_INFO("git storage: calling git_clone()\n");
error = git_clone(&cloned_repo, remote, localdir, &opts);
if (verbose > 1)
fprintf(stderr, "git storage: returned from git_clone() with error %d\n", error);
SSRF_INFO("git storage: returned from git_clone() with error %d\n", error);
if (error) {
char *msg = "";
if (giterr_last()) {
msg = giterr_last()->message;
fprintf(stderr, "error message was %s\n", msg);
SSRF_INFO("error message was %s\n", msg);
}
char *pattern = format_string("reference 'refs/remotes/origin/%s' not found", branch);
// it seems that we sometimes get 'Reference' and sometimes 'reference'
@ -843,7 +863,7 @@ static git_repository *create_local_repo(const char *localdir, const char *remot
* to our cloud storage and the branch doesn't exist.
* So we need to create the branch and push it to the remote */
if (verbose)
fprintf(stderr, "remote repo didn't include our branch\n");
SSRF_INFO("remote repo didn't include our branch\n");
cloned_repo = create_and_push_remote(localdir, remote, branch);
#if !defined(DEBUG) && !defined(SUBSURFACE_MOBILE)
} else if (is_subsurface_cloud) {
@ -874,7 +894,7 @@ static struct git_repository *get_remote_repo(const char *localdir, const char *
enum remote_transport rt = url_to_remote_transport(remote);
if (verbose > 1) {
fprintf(stderr, "git_remote_repo: accessing %s\n", remote);
SSRF_INFO("git_remote_repo: accessing %s\n", remote);
}
git_storage_update_progress(translate("gettextFromC", "Synchronising data file"));
/* Do we already have a local cache? */
@ -1057,7 +1077,7 @@ struct git_repository *is_git_repository(const char *filename, const char **bran
if (subsurface_stat(loc, &st) < 0 || !S_ISDIR(st.st_mode)) {
if (verbose)
fprintf(stderr, "loc %s wasn't found or is not a directory\n", loc);
SSRF_INFO("loc %s wasn't found or is not a directory\n", loc);
free(loc);
free(branch);
return dummy_git_repository;

View File

@ -1630,7 +1630,7 @@ static int walk_tree_file(const char *root, const git_tree_entry *entry, struct
dive_trip_t *trip = state->active_trip;
const char *name = git_tree_entry_name(entry);
if (verbose > 1)
fprintf(stderr, "git load handling file %s\n", name);
SSRF_INFO("git load handling file %s\n", name);
switch (*name) {
case '-': case '+':
if (dive)

View File

@ -318,7 +318,7 @@ int get_cylinder_index(const struct dive *dive, const struct event *ev)
* We now match up gas change events with their cylinders at dive
* event fixup time.
*/
fprintf(stderr, "Still looking up cylinder based on gas mix in get_cylinder_index()!\n");
SSRF_INFO("Still looking up cylinder based on gas mix in get_cylinder_index()!\n");
mix = get_gasmix_from_event(dive, ev);
best = find_best_gasmix_match(mix, &dive->cylinders);
@ -1055,7 +1055,7 @@ void calculate_deco_information(struct deco_state *ds, const struct deco_state *
entry->ambpressure = depth_to_bar(entry->depth, dive);
entry->gfline = get_gf(ds, entry->ambpressure, dive) * (100.0 - AMB_PERCENTAGE) + AMB_PERCENTAGE;
if (t0 > t1) {
fprintf(stderr, "non-monotonous dive stamps %d %d\n", t0, t1);
SSRF_INFO("non-monotonous dive stamps %d %d\n", t0, t1);
int xchg = t1;
t1 = t0;
t0 = xchg;

View File

@ -161,4 +161,13 @@ char *get_changes_made();
}
#endif
// 4) SSRF_INFO macro to replace fprintf calls in our code
// (originally based on logging bits from libdivecomputer)
#if !defined(Q_OS_ANDROID) && !defined(__ANDROID__)
#define SSRF_INFO(fmt, ...) fprintf(stderr, "INFO: " fmt "\n", ##__VA_ARGS__)
#else
#include <android/log.h>
#define SSRF_INFO(fmt, ...) __android_log_print(ANDROID_LOG_INFO, "Subsurface", "INFO: " fmt "\n", ##__VA_ARGS__);
#endif
#endif // QTHELPER_H

View File

@ -448,7 +448,7 @@ static void create_dive_buffer(struct dive *dive, struct membuffer *b)
if (dive->dive_site)
put_format(b, "divesiteid %08x\n", dive->dive_site->uuid);
if (verbose && dive->dive_site)
fprintf(stderr, "removed reference to non-existant dive site with uuid %08x\n", dive->dive_site->uuid);
SSRF_INFO("removed reference to non-existant dive site with uuid %08x\n", dive->dive_site->uuid);
save_overview(b, dive);
save_cylinder_info(b, dive);
save_weightsystem_info(b, dive);
@ -491,7 +491,7 @@ static int tree_insert(git_treebuilder *dir, const char *name, int mkunique, git
if (ret) {
const git_error *gerr = giterr_last();
if (gerr) {
fprintf(stderr, "tree_insert failed with return %d error %s\n", ret, gerr->message);
SSRF_INFO("tree_insert failed with return %d error %s\n", ret, gerr->message);
}
}
return ret;
@ -1071,7 +1071,7 @@ static void create_commit_message(struct membuffer *msg, bool create_empty)
free((void *)user_agent);
free(changes_made);
if (verbose)
fprintf(stderr, "Commit message:\n\n%s\n", mb_cstring(msg));
SSRF_INFO("Commit message:\n\n%s\n", mb_cstring(msg));
}
static int create_new_commit(git_repository *repo, const char *remote, const char *branch, git_oid *tree_id, bool create_empty)
@ -1100,7 +1100,7 @@ static int create_new_commit(git_repository *repo, const char *remote, const cha
if (saved_git_id) {
if (existing_filename && verbose)
fprintf(stderr, "existing filename %s\n", existing_filename);
SSRF_INFO("existing filename %s\n", existing_filename);
const git_oid *id = git_commit_id((const git_commit *) parent);
/* if we are saving to the same git tree we got this from, let's make
* sure there is no confusion */
@ -1199,7 +1199,7 @@ static int write_git_tree(git_repository *repo, struct dir *tree, git_oid *resul
if (ret && verbose) {
const git_error *gerr = giterr_last();
if (gerr)
fprintf(stderr, "tree_insert failed with return %d error %s\n", ret, gerr->message);
SSRF_INFO("tree_insert failed with return %d error %s\n", ret, gerr->message);
}
/* .. and free the now useless treebuilder */
@ -1215,7 +1215,7 @@ int do_git_save(git_repository *repo, const char *branch, const char *remote, bo
bool cached_ok;
if (verbose)
fprintf(stderr, "git storage: do git save\n");
SSRF_INFO("git storage: do git save\n");
if (!create_empty) // so we are actually saving the dives
git_storage_update_progress(translate("gettextFromC", "Preparing to save data"));
@ -1238,7 +1238,7 @@ int do_git_save(git_repository *repo, const char *branch, const char *remote, bo
return -1;
if (verbose)
fprintf(stderr, "git storage, write git tree\n");
SSRF_INFO("git storage, write git tree\n");
if (write_git_tree(repo, &tree, &id))
return report_error("git tree write failed");

View File

@ -4,6 +4,7 @@
#include "subsurface-string.h"
#include "selection.h"
#include "table.h"
#include "core/qthelper.h"
struct trip_table trip_table;
@ -87,7 +88,7 @@ void add_dive_to_trip(struct dive *dive, dive_trip_t *trip)
if (dive->divetrip == trip)
return;
if (dive->divetrip)
fprintf(stderr, "Warning: adding dive to trip that has trip set\n");
SSRF_INFO("Warning: adding dive to trip that has trip set\n");
insert_dive(&trip->dives, dive);
dive->divetrip = trip;
}

View File

@ -526,7 +526,7 @@ if you have network connectivity and want to sync your data to cloud storage."),
}
Kirigami.Action {
text: qsTr("Enable verbose logging")
text: qsTr("Enable verbose logging (currently: %1)").arg(manager.verboseEnabled)
onTriggered: {
showPassiveNotification(qsTr("Not persistent"), 3000)
globalDrawer.close()

View File

@ -229,7 +229,7 @@ QStringList DiveSiteSortedModel::allSiteNames() const
// (more precisely: the core has more sites than the model is aware of),
// we might get an invalid index.
if (idx < 0 || idx > dive_site_table.nr) {
fprintf(stderr, "DiveSiteSortedModel::allSiteNames(): invalid index");
SSRF_INFO("DiveSiteSortedModel::allSiteNames(): invalid index");
continue;
}
locationNames << QString(dive_site_table.dive_sites[idx]->name);

View File

@ -1,13 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include "messagehandlermodel.h"
/* based on logging bits from libdivecomputer */
#if !defined(Q_OS_ANDROID)
#define INFO(fmt, ...) fprintf(stderr, "INFO: " fmt "\n", ##__VA_ARGS__)
#else
#include <android/log.h>
#define INFO(fmt, ...) __android_log_print(ANDROID_LOG_DEBUG, "Subsurface", "INFO: " fmt "\n", ##__VA_ARGS__);
#endif
#include "core/qthelper.h"
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
extern void writeToAppLogFile(QString logText);
@ -49,7 +42,7 @@ void MessageHandlerModel::addLog(QtMsgType type, const QString& message)
beginInsertRows(QModelIndex(), rowCount(), rowCount());
m_data.append({message, type});
endInsertRows();
INFO("%s", qPrintable(message));
SSRF_INFO("%s", qPrintable(message));
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
writeToAppLogFile(message);
#endif