summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-04-10 09:42:14 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-04-10 10:53:03 -0700
commit3f3869ff650229e99262ee07b14e1d14ca973d10 (patch)
tree7508ff4e13d831855551d6737d0373e67e126470
parent34657f62ae5209b2f1c44efde053aba43e783e5e (diff)
downloadsubsurface-3f3869ff650229e99262ee07b14e1d14ca973d10.tar.gz
media: move picture function from dive.c to picture.c
Currently, move only those functions that do not access dive structures. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--backend-shared/exportfuncs.cpp1
-rw-r--r--core/CMakeLists.txt2
-rw-r--r--core/dive.c18
-rw-r--r--core/dive.h10
-rw-r--r--core/load-git.c1
-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.c1
-rw-r--r--core/save-html.c1
-rw-r--r--core/save-xml.c1
-rw-r--r--desktop-widgets/findmovedimagesdialog.cpp1
-rw-r--r--packaging/ios/Subsurface-mobile.pro2
-rw-r--r--profile-widget/profilewidget2.cpp1
-rw-r--r--qt-models/divepicturemodel.cpp4
-rw-r--r--qt-models/divetripmodel.cpp1
-rw-r--r--tests/testpicture.cpp1
19 files changed, 58 insertions, 29 deletions
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/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/dive.c b/core/dive.c
index 732e9d5a5..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) {
diff --git a/core/dive.h b/core/dive.h
index 1a1022e53..04d90a997 100644
--- a/core/dive.h
+++ b/core/dive.h
@@ -211,19 +211,9 @@ 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);
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/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..2b6b7c29a 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"
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/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/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/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..1eb0767f6 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>
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/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>