summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--INSTALL2
-rw-r--r--backend-shared/exportfuncs.cpp1
-rw-r--r--commands/command_edit.cpp31
-rw-r--r--core/CMakeLists.txt2
-rw-r--r--core/android.cpp3
-rw-r--r--core/btdiscovery.cpp98
-rw-r--r--core/connectionlistmodel.cpp7
-rw-r--r--core/dive.c36
-rw-r--r--core/dive.h18
-rw-r--r--core/git-access.c17
-rw-r--r--core/git-access.h1
-rw-r--r--core/ios.cpp5
-rw-r--r--core/load-git.c1
-rw-r--r--core/macos.c6
-rw-r--r--core/parse-xml.c1
-rw-r--r--core/parse.c1
-rw-r--r--core/picture.c21
-rw-r--r--core/picture.h18
-rw-r--r--core/qthelper.cpp1
-rw-r--r--core/save-git.c24
-rw-r--r--core/save-html.c1
-rw-r--r--core/save-xml.c1
-rw-r--r--core/unix.c30
-rw-r--r--core/windows.c3
-rw-r--r--desktop-widgets/findmovedimagesdialog.cpp1
-rw-r--r--packaging/OBS/subsurfacedaily.spec1
-rw-r--r--packaging/ios/Subsurface-mobile.pro2
-rwxr-xr-xpackaging/ubuntu/debian/rules1
-rw-r--r--profile-widget/profilewidget2.cpp1
-rw-r--r--qt-models/divepicturemodel.cpp32
-rw-r--r--qt-models/divetripmodel.cpp1
-rwxr-xr-xscripts/build.sh22
-rw-r--r--tests/testpicture.cpp1
34 files changed, 176 insertions, 216 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8888b1ab1..861db1680 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,4 @@
+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
Mobile: remove locking of data storage access
diff --git a/INSTALL b/INSTALL
index 52b05cf2b..321c6cef0 100644
--- a/INSTALL
+++ b/INSTALL
@@ -97,7 +97,7 @@ Other third party library dependencies
--------------------------------------
In order for our cloud storage to be fully functional you need
-libgit2 0.23 or newer.
+libgit2 0.26 or newer.
cmake build system
diff --git a/backend-shared/exportfuncs.cpp b/backend-shared/exportfuncs.cpp
index 2a23e3b97..7ae91f2d4 100644
--- a/backend-shared/exportfuncs.cpp
+++ b/backend-shared/exportfuncs.cpp
@@ -10,6 +10,7 @@
#include "core/errorhelper.h"
#include "core/divefilter.h"
#include "core/divesite.h"
+#include "core/picture.h"
#include "exportfuncs.h"
#if !defined(SUBSURFACE_MOBILE)
diff --git a/commands/command_edit.cpp b/commands/command_edit.cpp
index 46c206c98..a5eb46bc1 100644
--- a/commands/command_edit.cpp
+++ b/commands/command_edit.cpp
@@ -660,8 +660,37 @@ PasteState::PasteState(dive *dIn, const dive *data, dive_components what) : d(dI
divesite = data->dive_site;
if (what.tags)
tags = taglist_copy(data->tag_list);
- if (what.cylinders)
+ if (what.cylinders) {
copy_cylinders(&data->cylinders, &cylinders);
+ // Paste cylinders is "special":
+ // 1) For cylinders that exist in the destination dive we keep the gas-mix and pressures.
+ // 2) For cylinders that do not yet exist in the destination dive, we set the pressures to 0, i.e. unset.
+ // Moreover, for these we set the manually_added flag, because they weren't downloaded from a DC.
+ for (int i = 0; i < d->cylinders.nr && i < cylinders.nr; ++i) {
+ const cylinder_t &src = d->cylinders.cylinders[i];
+ cylinder_t &dst = cylinders.cylinders[i];
+ dst.gasmix = src.gasmix;
+ dst.start = src.start;
+ dst.end = src.end;
+ dst.sample_start = src.sample_start;
+ dst.sample_end = src.sample_end;
+ dst.depth = src.depth;
+ dst.manually_added = src.manually_added;
+ dst.gas_used = src.gas_used;
+ dst.deco_gas_used = src.deco_gas_used;
+ dst.cylinder_use = src.cylinder_use;
+ dst.bestmix_o2 = src.bestmix_o2;
+ dst.bestmix_he = src.bestmix_he;
+ }
+ for (int i = d->cylinders.nr; i < cylinders.nr; ++i) {
+ cylinder_t &cyl = cylinders.cylinders[i];
+ cyl.start.mbar = 0;
+ cyl.end.mbar = 0;
+ cyl.sample_start.mbar = 0;
+ cyl.sample_end.mbar = 0;
+ cyl.manually_added = true;
+ }
+ }
if (what.weights)
copy_weights(&data->weightsystems, &weightsystems);
}
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index d325f9280..7699877bc 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -125,6 +125,8 @@ set(SUBSURFACE_CORE_LIB_SRCS
parse-xml.c
parse.c
parse.h
+ picture.c
+ picture.h
planner.c
planner.h
plannernotes.c
diff --git a/core/android.cpp b/core/android.cpp
index b86f2e557..d1a1570fb 100644
--- a/core/android.cpp
+++ b/core/android.cpp
@@ -53,9 +53,6 @@ bool subsurface_ignore_font(const char *font)
return false;
}
-void subsurface_user_info(struct user_info *user)
-{ /* Encourage use of at least libgit2-0.20 */ }
-
static const char *system_default_path_append(const char *append)
{
// Qt appears to find a working path for us - let's just go with that
diff --git a/core/btdiscovery.cpp b/core/btdiscovery.cpp
index ce12f40d6..b70330410 100644
--- a/core/btdiscovery.cpp
+++ b/core/btdiscovery.cpp
@@ -34,45 +34,36 @@ static dc_descriptor_t *getDeviceType(QString btName)
// just use a default product that allows the codoe to download from the
// user's dive computer
else product = "OSTC 2";
- }
-
- if (btName.startsWith("Predator") ||
- btName.startsWith("Petrel") ||
- btName.startsWith("Perdix") ||
- btName.startsWith("Teric") ||
- btName.startsWith("NERD")) {
+ } else if (btName.startsWith("Predator") ||
+ btName.startsWith("Petrel") ||
+ btName.startsWith("Perdix") ||
+ btName.startsWith("Teric") ||
+ btName.startsWith("NERD")) {
vendor = "Shearwater";
- if (btName.startsWith("Petrel")) product = "Petrel"; // or petrel 2?
+ // both the Petrel and Petrel 2 identify as "Petrel" as BT/BLE device
+ // but only the Petrel 2 is listed as available dive computer on iOS (which requires BLE support)
+ // so always pick the "Petrel 2" as product when seeing a Petrel
+ if (btName.startsWith("Petrel")) product = "Petrel 2";
if (btName.startsWith("Perdix")) product = "Perdix";
if (btName.startsWith("Predator")) product = "Predator";
if (btName.startsWith("Teric")) product = "Teric";
if (btName.startsWith("NERD")) product = "Nerd"; // next line might override this
if (btName.startsWith("NERD 2")) product = "Nerd 2";
- }
-
- if (btName.startsWith("EON Steel")) {
+ } else if (btName.startsWith("EON Steel")) {
vendor = "Suunto";
product = "EON Steel";
- }
-
- if (btName.startsWith("EON Core")) {
+ } else if (btName.startsWith("EON Core")) {
vendor = "Suunto";
product = "EON Core";
- }
-
- if (btName.startsWith("Suunto D5")) {
+ } else if (btName.startsWith("Suunto D5")) {
vendor = "Suunto";
product = "D5";
- }
-
- if (btName.startsWith("G2") || btName.startsWith("Aladin") || btName.startsWith("HUD")) {
+ } else if (btName.startsWith("G2") || btName.startsWith("Aladin") || btName.startsWith("HUD")) {
vendor = "Scubapro";
if (btName.startsWith("G2")) product = "G2";
if (btName.startsWith("HUD")) product = "G2 HUD";
if (btName.startsWith("Aladin")) product = "Aladin Sport Matrix";
- }
-
- if (btName.startsWith("Mares")) {
+ } else if (btName.startsWith("Mares")) {
vendor = "Mares";
// we don't know which of the dive computers it is,
// so let's just randomly pick one
@@ -80,66 +71,51 @@ static dc_descriptor_t *getDeviceType(QString btName)
// Some we can pick out directly
if (btName.startsWith("Mares Genius"))
product = "Genius";
- }
-
- if (btName.startsWith("CARTESIO_")) {
+ } else if (btName.startsWith("CARTESIO_")) {
vendor = "Cressi";
product = "Cartesio";
- }
-
- if (btName.startsWith("GOA_")) {
+ } else if (btName.startsWith("GOA_")) {
vendor = "Cressi";
product = "Goa";
- }
-
- // The Pelagic dive computers (generally branded as Oceanic or Aqualung)
- // show up with a two-byte model code followed by six bytes of serial
- // number. The model code matches the hex model (so "FQ" is 0x4651,
- // where 'F' is 46h and 'Q' is 51h in ASCII).
- if (btName.contains(QRegularExpression("^FI\\d{6}$"))) {
+ } else if (btName.contains(QRegularExpression("^FI\\d{6}$"))) {
+ // The Pelagic dive computers (generally branded as Oceanic or Aqualung)
+ // show up with a two-byte model code followed by six bytes of serial
+ // number. The model code matches the hex model (so "FQ" is 0x4651,
+ // where 'F' is 46h and 'Q' is 51h in ASCII).
vendor = "Aqualung";
product = "i200c";
- }
-
- if (btName.contains(QRegularExpression("^FH\\d{6}$"))) {
+ } else if (btName.contains(QRegularExpression("^FH\\d{6}$"))) {
vendor = "Aqualung";
product = "i300c";
- }
-
- if (btName.contains(QRegularExpression("^FQ\\d{6}$"))) {
+ } else if (btName.contains(QRegularExpression("^FQ\\d{6}$"))) {
vendor = "Aqualung";
product = "i770R";
- }
-
- if (btName.contains(QRegularExpression("^FR\\d{6}$"))) {
+ } else if (btName.contains(QRegularExpression("^FR\\d{6}$"))) {
vendor = "Aqualung";
product = "i550c";
- }
-
- if (btName.contains(QRegularExpression("^ER\\d{6}$"))) {
+ } else if (btName.contains(QRegularExpression("^ER\\d{6}$"))) {
vendor = "Oceanic";
product = "Pro Plus X";
- }
-
- if (btName.contains(QRegularExpression("^FS\\d{6}$"))) {
+ } else if (btName.contains(QRegularExpression("^FS\\d{6}$"))) {
vendor = "Oceanic";
product = "Geo 4.0";
- }
-
- // The Ratio bluetooth name looks like the Pelagic ones,
- // but that seems to be just happenstance.
- if (btName.contains(QRegularExpression("^DS\\d{6}"))) {
+ } else if (btName.contains(QRegularExpression("^DS\\d{6}"))) {
+ // The Ratio bluetooth name looks like the Pelagic ones,
+ // but that seems to be just happenstance.
vendor = "Ratio";
product = "iX3M GPS Easy"; // we don't know which of the GPS models, so set one
- }
-
- if (btName == "COSMIQ") {
+ } else if (btName == "COSMIQ") {
vendor = "Deepblu";
product = "Cosmiq+";
}
- if (!vendor.isEmpty() && !product.isEmpty())
- return descriptorLookup.value(vendor + product);
+ // check if we found a known dive computer
+ if (!vendor.isEmpty() && !product.isEmpty()) {
+ dc_descriptor_t *lookup = descriptorLookup.value(vendor + product);
+ if (!lookup)
+ qWarning("known dive computer %s not found in descriptorLookup", qPrintable(QString(vendor + product)));
+ return lookup;
+ }
return nullptr;
}
diff --git a/core/connectionlistmodel.cpp b/core/connectionlistmodel.cpp
index e4ac8bfeb..d97d4722c 100644
--- a/core/connectionlistmodel.cpp
+++ b/core/connectionlistmodel.cpp
@@ -39,9 +39,12 @@ void ConnectionListModel::addAddress(const QString &address)
void ConnectionListModel::removeAllAddresses()
{
- beginRemoveRows(QModelIndex(), 0, rowCount());
+ if (rowCount() == 0)
+ return;
+
+ beginResetModel();
m_addresses.clear();
- endRemoveRows();
+ endResetModel();
}
int ConnectionListModel::indexOf(const QString &address) const
diff --git a/core/dive.c b/core/dive.c
index ffdf91ae3..c97c229f6 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -14,6 +14,7 @@
#include "qthelper.h"
#include "metadata.h"
#include "membuffer.h"
+#include "picture.h"
#include "tag.h"
#include "trip.h"
#include "structured_list.h"
@@ -2697,14 +2698,6 @@ static void free_dc(struct divecomputer *dc)
free(dc);
}
-void free_picture(struct picture *picture)
-{
- if (picture) {
- free(picture->filename);
- free(picture);
- }
-}
-
static int same_sample(struct sample *a, struct sample *b)
{
if (a->time.seconds != b->time.seconds)
@@ -3410,15 +3403,6 @@ void set_git_prefs(const char *prefs)
git_prefs.pp_graphs.po2 = 1;
}
-struct picture *alloc_picture()
-{
- struct picture *pic = malloc(sizeof(struct picture));
- if (!pic)
- exit(1);
- memset(pic, 0, sizeof(struct picture));
- return pic;
-}
-
static bool new_picture_for_dive(struct dive *d, const char *filename)
{
FOR_EACH_PICTURE (d) {
@@ -3538,22 +3522,6 @@ void dive_add_picture(struct dive *dive, struct picture *newpic)
return;
}
-unsigned int dive_get_picture_count(struct dive *dive)
-{
- unsigned int i = 0;
- FOR_EACH_PICTURE (dive)
- i++;
- return i;
-}
-
-void picture_free(struct picture *picture)
-{
- if (!picture)
- return;
- free(picture->filename);
- free(picture);
-}
-
// Return true if picture was found and deleted
bool dive_remove_picture(struct dive *d, const char *filename)
{
@@ -3562,7 +3530,7 @@ bool dive_remove_picture(struct dive *d, const char *filename)
picture = &(*picture)->next;
if (*picture) {
struct picture *temp = (*picture)->next;
- picture_free(*picture);
+ free_picture(*picture);
*picture = temp;
invalidate_dive_cache(current_dive);
return true;
diff --git a/core/dive.h b/core/dive.h
index 1e5ca873d..13de360ed 100644
--- a/core/dive.h
+++ b/core/dive.h
@@ -211,25 +211,13 @@ extern struct event *get_next_divemodechange(const struct event **evd, bool upda
extern enum divemode_t get_divemode_at_time(const struct divecomputer *dc, int dtime, const struct event **ev_dmc);
/* picture list and methods related to dive picture handling */
-struct picture {
- char *filename;
- offset_t offset;
- location_t location;
- struct picture *next;
-};
-
#define FOR_EACH_PICTURE(_dive) \
if (_dive) \
for (struct picture *picture = (_dive)->picture_list; picture; picture = picture->next)
-
-extern struct picture *alloc_picture();
-extern void free_picture(struct picture *picture);
extern void create_picture(const char *filename, int shift_time, bool match_all);
extern void dive_add_picture(struct dive *d, struct picture *newpic);
extern bool dive_remove_picture(struct dive *d, const char *filename);
-extern unsigned int dive_get_picture_count(struct dive *d);
extern bool picture_check_valid_time(timestamp_t timestamp, int shift_time);
-extern void picture_free(struct picture *picture);
extern bool has_gaschange_event(const struct dive *dive, const struct divecomputer *dc, int idx);
extern int explicit_first_cylinder(const struct dive *dive, const struct divecomputer *dc);
@@ -322,12 +310,6 @@ extern int save_dive_sites_logic(const char *filename, const struct dive_site *s
struct membuffer;
extern void save_one_dive_to_mb(struct membuffer *b, struct dive *dive, bool anonymize);
-struct user_info {
- char *name;
- char *email;
-};
-
-extern void subsurface_user_info(struct user_info *);
extern void subsurface_console_init(void);
extern void subsurface_console_exit(void);
extern bool subsurface_user_is_root(void);
diff --git a/core/git-access.c b/core/git-access.c
index 28f00bb90..0db4faf8e 100644
--- a/core/git-access.c
+++ b/core/git-access.c
@@ -326,6 +326,7 @@ static int try_to_git_merge(git_repository *repo, git_reference **local_p, git_r
git_commit *local_commit, *remote_commit, *base_commit;
git_index *merged_index;
git_merge_options merge_options;
+ struct membuffer msg = { 0, 0, NULL};
if (verbose) {
char outlocal[41], outremote[41];
@@ -336,11 +337,7 @@ static int try_to_git_merge(git_repository *repo, git_reference **local_p, git_r
}
git_merge_init_options(&merge_options, GIT_MERGE_OPTIONS_VERSION);
-#if !LIBGIT2_VER_MAJOR && LIBGIT2_VER_MINOR > 23
merge_options.flags = GIT_MERGE_FIND_RENAMES;
-#else
- merge_options.tree_flags = GIT_MERGE_TREE_FIND_RENAMES;
-#endif
merge_options.file_favor = GIT_MERGE_FILE_FAVOR_UNION;
merge_options.rename_threshold = 100;
if (git_commit_lookup(&local_commit, repo, local_id)) {
@@ -411,10 +408,12 @@ static int try_to_git_merge(git_repository *repo, git_reference **local_p, git_r
goto write_error;
if (git_tree_lookup(&merged_tree, repo, &merge_oid))
goto write_error;
- if (git_signature_default(&author, repo) < 0)
- if (git_signature_now(&author, "Subsurface", "noemail@given") < 0)
- goto write_error;
- if (git_commit_create_v(&commit_oid, repo, NULL, author, author, NULL, "automatic merge", merged_tree, 2, local_commit, remote_commit))
+ if (get_authorship(repo, &author) < 0)
+ goto write_error;
+ const char *user_agent = subsurface_user_agent();
+ put_format(&msg, "Automatic merge\n\nCreated by %s\n", user_agent);
+ free((void *)user_agent);
+ if (git_commit_create_v(&commit_oid, repo, NULL, author, author, NULL, mb_cstring(&msg), merged_tree, 2, local_commit, remote_commit))
goto write_error;
if (git_commit_lookup(&commit, repo, &commit_oid))
goto write_error;
@@ -431,12 +430,14 @@ static int try_to_git_merge(git_repository *repo, git_reference **local_p, git_r
git_signature_free(author);
if (verbose)
fprintf(stderr, "Successfully merged repositories");
+ free_buffer(&msg);
return 0;
diverged_error:
return report_error(translate("gettextFromC", "Remote storage and local data diverged"));
write_error:
+ free_buffer(&msg);
return report_error(translate("gettextFromC", "Remote storage and local data diverged. Error: writing the data failed (%s)"), giterr_last()->message);
}
diff --git a/core/git-access.h b/core/git-access.h
index 19cdde46a..8e20395a4 100644
--- a/core/git-access.h
+++ b/core/git-access.h
@@ -31,6 +31,7 @@ void set_git_update_cb(int(*)(const char *));
int git_storage_update_progress(const char *text);
char *get_local_dir(const char *remote, const char *branch);
int git_create_local_repo(const char *filename);
+int get_authorship(git_repository *repo, git_signature **authorp);
#ifdef __cplusplus
}
diff --git a/core/ios.cpp b/core/ios.cpp
index d54f2b4b8..b8fe7227e 100644
--- a/core/ios.cpp
+++ b/core/ios.cpp
@@ -37,11 +37,6 @@ bool subsurface_ignore_font(const char*)
return false;
}
-void subsurface_user_info(struct user_info *)
-{
- // We use of at least libgit2-0.20
-}
-
static const char *system_default_path_append(const char *append)
{
// Qt appears to find a working path for us - let's just go with that
diff --git a/core/load-git.c b/core/load-git.c
index cc6f42ce3..a372d1186 100644
--- a/core/load-git.c
+++ b/core/load-git.c
@@ -22,6 +22,7 @@
#include "device.h"
#include "membuffer.h"
#include "git-access.h"
+#include "picture.h"
#include "qthelper.h"
#include "tag.h"
diff --git a/core/macos.c b/core/macos.c
index dc07dc7b6..0ee7c1952 100644
--- a/core/macos.c
+++ b/core/macos.c
@@ -20,12 +20,6 @@
#include <zip.h>
#include <sys/stat.h>
-void subsurface_user_info(struct user_info *info)
-{
- UNUSED(info);
- /* Nothing, let's use libgit2-20 on MacOS */
-}
-
/* macos defines CFSTR to create a CFString object from a constant,
* but no similar macros if a C string variable is supposed to be
* the argument. We add this here (hardcoding the default allocator
diff --git a/core/parse-xml.c b/core/parse-xml.c
index 6218fc74d..490e56275 100644
--- a/core/parse-xml.c
+++ b/core/parse-xml.c
@@ -29,6 +29,7 @@
#include "trip.h"
#include "device.h"
#include "membuffer.h"
+#include "picture.h"
#include "qthelper.h"
#include "tag.h"
diff --git a/core/parse.c b/core/parse.c
index ceefa23bb..be10d65e3 100644
--- a/core/parse.c
+++ b/core/parse.c
@@ -11,6 +11,7 @@
#include "errorhelper.h"
#include "subsurface-string.h"
#include "parse.h"
+#include "picture.h"
#include "trip.h"
#include "device.h"
#include "gettext.h"
diff --git a/core/picture.c b/core/picture.c
new file mode 100644
index 000000000..3f887efe8
--- /dev/null
+++ b/core/picture.c
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "picture.h"
+#include <stdlib.h>
+#include <string.h>
+
+struct picture *alloc_picture()
+{
+ struct picture *pic = malloc(sizeof(struct picture));
+ if (!pic)
+ exit(1);
+ memset(pic, 0, sizeof(struct picture));
+ return pic;
+}
+
+void free_picture(struct picture *picture)
+{
+ if (picture) {
+ free(picture->filename);
+ free(picture);
+ }
+}
diff --git a/core/picture.h b/core/picture.h
new file mode 100644
index 000000000..93b644d71
--- /dev/null
+++ b/core/picture.h
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef PICTURE_H
+#define PICTURE_H
+
+// picture (more precisely media) related strutures and functions
+#include "units.h"
+
+struct picture {
+ char *filename;
+ offset_t offset;
+ location_t location;
+ struct picture *next;
+};
+
+extern struct picture *alloc_picture();
+extern void free_picture(struct picture *picture);
+
+#endif // PICTURE_H
diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index 7b879e7d6..eb755bf20 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -19,6 +19,7 @@
#include <sys/time.h>
#include "exif.h"
#include "file.h"
+#include "picture.h"
#include "tag.h"
#include "trip.h"
#include "imagedownloader.h"
diff --git a/core/save-git.c b/core/save-git.c
index a304e0d94..2d58f931a 100644
--- a/core/save-git.c
+++ b/core/save-git.c
@@ -25,6 +25,7 @@
#include "membuffer.h"
#include "git-access.h"
#include "version.h"
+#include "picture.h"
#include "qthelper.h"
#include "gettext.h"
#include "tag.h"
@@ -1020,25 +1021,18 @@ int update_git_checkout(git_repository *repo, git_object *parent, git_tree *tree
return git_checkout_tree(repo, (git_object *) tree, &opts);
}
-static int get_authorship(git_repository *repo, git_signature **authorp)
+int get_authorship(git_repository *repo, git_signature **authorp)
{
-#if LIBGIT2_VER_MAJOR || LIBGIT2_VER_MINOR >= 20
if (git_signature_default(authorp, repo) == 0)
return 0;
+
+#ifdef SUBSURFACE_MOBILE
+#define APPNAME "Subsurface-mobile"
+#else
+#define APPNAME "Subsurface"
#endif
- /* try to fetch the user info from the OS, otherwise use default values. */
- struct user_info user = { .name = NULL, .email = NULL };
- subsurface_user_info(&user);
- if (!user.name || !*user.name)
- user.name = strdup("Subsurface");
- if (!user.email)
- user.email = strdup("subsurface-app-account@subsurface-divelog.org");
-
- /* git_signature_default() is too recent */
- int ret = git_signature_now(authorp, user.name, user.email);
- free((void *)user.name);
- free((void *)user.email);
- return ret;
+ return git_signature_now(authorp, APPNAME, "subsurface-app-account@subsurface-divelog.org");
+#undef APPNAME
}
static void create_commit_message(struct membuffer *msg, bool create_empty)
diff --git a/core/save-html.c b/core/save-html.c
index d5f472058..82defeed3 100644
--- a/core/save-html.c
+++ b/core/save-html.c
@@ -10,6 +10,7 @@
#include "divesite.h"
#include "errorhelper.h"
#include "file.h"
+#include "picture.h"
#include "tag.h"
#include "trip.h"
#include <stdio.h>
diff --git a/core/save-xml.c b/core/save-xml.c
index 6662069d8..c7ef3a7c2 100644
--- a/core/save-xml.c
+++ b/core/save-xml.c
@@ -20,6 +20,7 @@
#include "device.h"
#include "file.h"
#include "membuffer.h"
+#include "picture.h"
#include "strndup.h"
#include "git-access.h"
#include "qthelper.h"
diff --git a/core/unix.c b/core/unix.c
index 5106278a2..bcac33ff3 100644
--- a/core/unix.c
+++ b/core/unix.c
@@ -34,36 +34,6 @@ bool subsurface_ignore_font(const char *font)
return false;
}
-void subsurface_user_info(struct user_info *user)
-{
- struct passwd *pwd = getpwuid(getuid());
- const char *username = getenv("USER");
-
- if (pwd) {
- if (!empty_string(pwd->pw_gecos)) {
- user->name = strdup(pwd->pw_gecos);
- // We only want the name, not the office or phone number
- char *c = user->name;
- while (*c) {
- if (*c == ',') {
- *c = '\0';
- break;
- }
- ++c;
- }
- }
- if (!username)
- username = pwd->pw_name;
- }
- if (!empty_string(username)) {
- char hostname[64];
- struct membuffer mb = {};
- gethostname(hostname, sizeof(hostname));
- put_format(&mb, "%s@%s", username, hostname);
- user->email = detach_cstring(&mb);
- }
-}
-
static const char *system_default_path_append(const char *append)
{
const char *home = getenv("HOME");
diff --git a/core/windows.c b/core/windows.c
index 4ca0c621a..37f4d3a63 100644
--- a/core/windows.c
+++ b/core/windows.c
@@ -23,9 +23,6 @@ const char current_system_divelist_default_font[] = "Segoe UI";
const char *system_divelist_default_font = non_standard_system_divelist_default_font;
double system_divelist_default_font_size = -1;
-void subsurface_user_info(struct user_info *user)
-{ /* Encourage use of at least libgit2-0.20 */ }
-
extern bool isWin7Or8();
void subsurface_OS_pref_setup(void)
diff --git a/desktop-widgets/findmovedimagesdialog.cpp b/desktop-widgets/findmovedimagesdialog.cpp
index a0ef0d9b4..088f195f6 100644
--- a/desktop-widgets/findmovedimagesdialog.cpp
+++ b/desktop-widgets/findmovedimagesdialog.cpp
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include "findmovedimagesdialog.h"
+#include "core/picture.h"
#include "core/qthelper.h"
#include "desktop-widgets/divelistview.h" // TODO: used for lastUsedImageDir()
#include "qt-models/divepicturemodel.h"
diff --git a/packaging/OBS/subsurfacedaily.spec b/packaging/OBS/subsurfacedaily.spec
index 86c6e150e..f814b26a7 100644
--- a/packaging/OBS/subsurfacedaily.spec
+++ b/packaging/OBS/subsurfacedaily.spec
@@ -120,7 +120,6 @@ mkdir -p install-root
-DLIBGIT2_INCLUDE_DIR=$RPM_BUILD_DIR/install-root/include \
-DLIBDIVECOMPUTER_LIBRARIES=$RPM_BUILD_DIR/install-root/lib/libdivecomputer.a \
-DLIBGIT2_LIBRARIES=$RPM_BUILD_DIR/install-root/lib/libgit2.a \
- -DUSE_LIBGIT23_API=ON \
-DCMAKE_C_FLAGS:STRING="%optflags" \
-DCMAKE_CXX_FLAGS:STRING="%optflags" \
-DNO_PRINTING=OFF \
diff --git a/packaging/ios/Subsurface-mobile.pro b/packaging/ios/Subsurface-mobile.pro
index eabeb72f7..2e70662c5 100644
--- a/packaging/ios/Subsurface-mobile.pro
+++ b/packaging/ios/Subsurface-mobile.pro
@@ -62,6 +62,7 @@ SOURCES += ../../subsurface-mobile-main.cpp \
../../core/load-git.c \
../../core/parse-xml.c \
../../core/parse.c \
+ ../../core/picture.c \
../../core/import-suunto.c \
../../core/import-shearwater.c \
../../core/import-cobalt.c \
@@ -201,6 +202,7 @@ HEADERS += \
../../core/statistics.h \
../../core/units.h \
../../core/version.h \
+ ../../core/picture.h \
../../core/planner.h \
../../core/divesite.h \
../../core/checkcloudconnection.h \
diff --git a/packaging/ubuntu/debian/rules b/packaging/ubuntu/debian/rules
index 7c7c63362..97fa17b6d 100755
--- a/packaging/ubuntu/debian/rules
+++ b/packaging/ubuntu/debian/rules
@@ -64,7 +64,6 @@ override_dh_auto_configure:
-DLIBGIT2_LIBRARIES=$(MY_INSTALL_ROOT)/lib/libgit2.a \
-DLIBDIVECOMPUTER_INCLUDE_DIR=$(MY_INSTALL_ROOT)/include \
-DLIBDIVECOMPUTER_LIBRARIES=$(MY_INSTALL_ROOT)/lib/libdivecomputer.a \
- -DUSE_LIBGIT23_API=1 \
-DFORCE_LIBSSH=1 \
-DNO_PRINTING=OFF \
-DMAKE_TESTS=OFF \
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index a162f8782..fb5680eb5 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -3,6 +3,7 @@
#include "qt-models/diveplotdatamodel.h"
#include "core/subsurface-string.h"
#include "core/qthelper.h"
+#include "core/picture.h"
#include "core/profile.h"
#include "core/settings/qPrefDisplay.h"
#include "core/settings/qPrefTechnicalDetails.h"
diff --git a/qt-models/divepicturemodel.cpp b/qt-models/divepicturemodel.cpp
index 8156693ef..ab54c2dc1 100644
--- a/qt-models/divepicturemodel.cpp
+++ b/qt-models/divepicturemodel.cpp
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
#include "qt-models/divepicturemodel.h"
-#include "core/dive.h"
#include "core/metrics.h"
-#include "core/divelist.h"
+#include "core/divelist.h" // for mark_divelist_changed()
#include "core/imagedownloader.h"
+#include "core/picture.h"
#include "core/qthelper.h"
#include <QFileInfo>
@@ -79,42 +79,34 @@ int DivePictureModel::columnCount(const QModelIndex&) const
QVariant DivePictureModel::data(const QModelIndex &index, int role) const
{
- QVariant ret;
if (!index.isValid())
- return ret;
+ return QVariant();
const PictureEntry &entry = pictures.at(index.row());
if (index.column() == 0) {
switch (role) {
case Qt::ToolTipRole:
- ret = entry.filename;
- break;
+ return entry.filename;
case Qt::DecorationRole:
- ret = entry.image.scaled(size, size, Qt::KeepAspectRatio);
- break;
+ return entry.image.scaled(size, size, Qt::KeepAspectRatio);
case Qt::DisplayRole:
- ret = QFileInfo(entry.filename).fileName();
- break;
+ return QFileInfo(entry.filename).fileName();
case Qt::DisplayPropertyRole:
- ret = QFileInfo(entry.filename).filePath();
- break;
+ return QFileInfo(entry.filename).filePath();
case Qt::UserRole:
- ret = entry.diveId;
- break;
+ return entry.diveId;
case Qt::UserRole + 1:
- ret = entry.offsetSeconds;
- break;
+ return entry.offsetSeconds;
case Qt::UserRole + 2:
- ret = entry.length.seconds;
+ return entry.length.seconds;
}
} else if (index.column() == 1) {
switch (role) {
case Qt::DisplayRole:
- ret = entry.filename;
- break;
+ return entry.filename;
}
}
- return ret;
+ return QVariant();
}
// Return true if we actually removed a picture
diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp
index 2e5359b89..0f381410a 100644
--- a/qt-models/divetripmodel.cpp
+++ b/qt-models/divetripmodel.cpp
@@ -10,6 +10,7 @@
#include "core/trip.h"
#include "core/qthelper.h"
#include "core/divesite.h"
+#include "core/picture.h"
#include "core/subsurface-string.h"
#include "core/tag.h"
#include "qt-models/divelocationmodel.h" // For the dive-site field ids
diff --git a/scripts/build.sh b/scripts/build.sh
index aeb3ecbed..83923744e 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -245,8 +245,8 @@ fi
if [ "$PLATFORM" = Darwin ] ; then
SH_LIB_EXT=dylib
if [ ! "$BUILD_DEPS" == "1" ] ; then
- pkg-config --exists libgit2 && LIBGIT=$(pkg-config --modversion libgit2 | cut -d. -f2)
- if [[ "$LIBGIT" -gt "23" ]] ; then
+ pkg-config --exists libgit2 && LIBGIT=$(pkg-config --modversion libgit2) && LIBGITMAJ=$(echo $LIBGIT | cut -d. -f1) && LIBGIT=$(echo $LIBGIT | cut -d. -f2)
+ if [[ "$LIBGITMAJ" -gt "0" || "$LIBGIT" -gt "25" ]] ; then
LIBGIT2_FROM_PKGCONFIG="-DLIBGIT2_FROM_PKGCONFIG=ON"
fi
fi
@@ -258,12 +258,20 @@ else
# first check pkgconfig (that will capture our own local build if
# this script has been run before)
if pkg-config --exists libgit2 ; then
- LIBGIT=$(pkg-config --modversion libgit2 | cut -d. -f2)
- LIBGIT2_FROM_PKGCONFIG="-DLIBGIT2_FROM_PKGCONFIG=ON"
+ LIBGIT=$(pkg-config --modversion libgit2)
+ LIBGITMAJ=$(echo $LIBGIT | cut -d. -f1)
+ LIBGIT=$(echo $LIBGIT | cut -d. -f2)
+ if [[ "$LIBGITMAJ" -gt "0" || "$LIBGIT" -gt "25" ]] ; then
+ LIBGIT2_FROM_PKGCONFIG="-DLIBGIT2_FROM_PKGCONFIG=ON"
+ fi
fi
- if [[ "$LIBGIT" -lt "26" ]] ; then
+ if [[ "$LIBGITMAJ" -lt "1" && "$LIBGIT" -lt "26" ]] ; then
# maybe there's a system version that's new enough?
- LIBGIT=$(ldconfig -p | grep libgit2\\.so\\. | awk -F. '{ print $NF }')
+ # Ugh that's uggly - read the ultimate filename, split at the last 'o' which gets us ".0.26.3" or ".1.0.0"
+ # since that starts with a dot, the field numbers in the cut need to be one higher
+ LIBGIT=$(realpath $(ldconfig -p | grep libgit2\\.so\\. | cut -d\ -f4) | awk -Fo '{ print $NF }')
+ LIBGITMAJ=$(echo $LIBGIT | cut -d. -f2)
+ LIBGIT=$(echo $LIBGIT | cut -d. -f3)
fi
fi
@@ -312,7 +320,7 @@ if [[ $PLATFORM = Darwin && "$BUILD_DEPS" == "1" ]] ; then
fi
fi
-if [[ "$LIBGIT" -lt "26" ]] ; then
+if [[ "$LIBGITMAJ" -lt "1" && "$LIBGIT" -lt "26" ]] ; then
LIBGIT_ARGS=" -DLIBGIT2_INCLUDE_DIR=$INSTALL_ROOT/include -DLIBGIT2_LIBRARIES=$INSTALL_ROOT/lib/libgit2.$SH_LIB_EXT "
cd "$SRC"
diff --git a/tests/testpicture.cpp b/tests/testpicture.cpp
index 28a063f96..08922b1aa 100644
--- a/tests/testpicture.cpp
+++ b/tests/testpicture.cpp
@@ -2,6 +2,7 @@
#include "testpicture.h"
#include "core/divesite.h"
#include "core/errorhelper.h"
+#include "core/picture.h"
#include "core/trip.h"
#include "core/file.h"
#include <QString>