summaryrefslogtreecommitdiffstats
path: root/dive.h
diff options
context:
space:
mode:
Diffstat (limited to 'dive.h')
-rw-r--r--dive.h82
1 files changed, 49 insertions, 33 deletions
diff --git a/dive.h b/dive.h
index 9e86b74f9..9a26892e6 100644
--- a/dive.h
+++ b/dive.h
@@ -8,6 +8,7 @@
#include <zip.h>
#include <sqlite3.h>
#include <string.h>
+#include "divesite.h"
/* Windows has no MIN/MAX macros - so let's just roll our own */
#define MIN(x, y) ({ \
@@ -47,6 +48,11 @@ extern "C" {
#include <stdbool.h>
#endif
+extern int last_xml_version;
+extern bool abort_read_of_old_file;
+extern bool v2_question_shown;
+extern bool imported_via_xslt;
+
enum dive_comp_type {OC, CCR, PSCR, FREEDIVE, NUM_DC_TYPE}; // Flags (Open-circuit and Closed-circuit-rebreather) for setting dive computer type
enum cylinderuse {OC_GAS, DILUENT, OXYGEN, NUM_GAS_USE}; // The different uses for cylinders
@@ -320,11 +326,10 @@ struct dive {
bool hidden_by_filter;
bool downloaded;
timestamp_t when;
- char *location;
+ uint32_t dive_site_uuid;
char *notes;
char *divemaster, *buddy;
int rating;
- degrees_t latitude, longitude;
int visibility; /* 0 - 5 star rating */
cylinder_t cylinder[MAX_CYLINDERS];
weightsystem_t weightsystem[MAX_WEIGHTSYSTEMS];
@@ -346,17 +351,17 @@ struct dive {
};
extern int get_cylinder_idx_by_use(struct dive *dive, enum cylinderuse cylinder_use_type);
+extern void dc_cylinder_renumber(struct dive *dive, struct divecomputer *dc, int mapping[]);
/* when selectively copying dive information, which parts should be copied? */
struct dive_components {
- unsigned int location : 1;
+ unsigned int divesite : 1;
unsigned int notes : 1;
unsigned int divemaster : 1;
unsigned int buddy : 1;
unsigned int suit : 1;
unsigned int rating : 1;
unsigned int visibility : 1;
- unsigned int gps : 1;
unsigned int tags : 1;
unsigned int cylinders : 1;
unsigned int weights : 1;
@@ -365,6 +370,7 @@ struct dive_components {
/* picture list and methods related to dive picture handling */
struct picture {
char *filename;
+ char *hash;
offset_t offset;
degrees_t latitude;
degrees_t longitude;
@@ -379,31 +385,18 @@ struct picture {
for (struct picture *picture = (_divestruct).picture_list; picture; picture = picture->next)
extern struct picture *alloc_picture();
+extern bool dive_check_picture_time(struct dive *d, int shift_time, timestamp_t timestamp);
extern void dive_create_picture(struct dive *d, char *filename, int shift_time);
extern void dive_add_picture(struct dive *d, struct picture *newpic);
extern void dive_remove_picture(char *filename);
extern unsigned int dive_get_picture_count(struct dive *d);
-extern void picture_load_exif_data(struct picture *p, timestamp_t *timestamp);
+extern bool picture_check_valid(char *filename, int shift_time);
+extern void picture_load_exif_data(struct picture *p);
+extern timestamp_t picture_get_timestamp(char *filename);
extern void dive_set_geodata_from_picture(struct dive *d, struct picture *pic);
extern int explicit_first_cylinder(struct dive *dive, struct divecomputer *dc);
-static inline int dive_has_gps_location(struct dive *dive)
-{
- return dive->latitude.udeg || dive->longitude.udeg;
-}
-
-static inline void copy_gps_location(struct dive *from, struct dive *to)
-{
- if (from && to) {
- to->latitude.udeg = from->latitude.udeg;
- to->longitude.udeg = from->longitude.udeg;
- if (!to->location) {
- to->location = strdup(from->location);
- }
- }
-}
-
static inline int get_surface_pressure_in_mbar(const struct dive *dive, bool non_null)
{
int mbar = dive->surface_pressure.mbar;
@@ -491,18 +484,12 @@ struct dive_table {
extern struct dive_table dive_table;
extern struct dive displayed_dive;
+extern struct dive_site displayed_dive_site;
extern int selected_dive;
extern unsigned int dc_number;
#define current_dive (get_dive(selected_dive))
#define current_dc (get_dive_dc(current_dive, dc_number))
-static inline struct dive *get_gps_location(int nr, struct dive_table *table)
-{
- if (nr >= table->nr || nr < 0)
- return NULL;
- return table->dives[nr];
-}
-
static inline struct dive *get_dive(int nr)
{
if (nr >= dive_table.nr || nr < 0)
@@ -517,6 +504,21 @@ static inline struct dive *get_dive_from_table(int nr, struct dive_table *dt)
return dt->dives[nr];
}
+static inline struct dive_site *get_dive_site_for_dive(struct dive *dive)
+{
+ if (dive)
+ return get_dive_site_by_uuid(dive->dive_site_uuid);
+ return NULL;
+}
+
+static inline char *get_dive_location(struct dive *dive)
+{
+ struct dive_site *ds = get_dive_site_by_uuid(dive->dive_site_uuid);
+ if (ds && ds->name)
+ return ds->name;
+ return NULL;
+}
+
static inline unsigned int number_of_computers(struct dive *dive)
{
unsigned int total_number = 0;
@@ -615,6 +617,16 @@ static inline int get_idx_by_uniq_id(int id)
return i;
}
+static inline bool dive_site_has_gps_location(struct dive_site *ds)
+{
+ return ds && (ds->latitude.udeg || ds->longitude.udeg);
+}
+
+static inline int dive_has_gps_location(struct dive *dive)
+{
+ return dive_site_has_gps_location(get_dive_site_by_uuid(dive->dive_site_uuid));
+}
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -642,15 +654,18 @@ extern int parse_dlf_buffer(unsigned char *buffer, size_t size);
extern int parse_file(const char *filename);
extern int parse_csv_file(const char *filename, int time, int depth, int temp, int po2f, int cnsf, int ndlf, int ttsf, int stopdepthf, int pressuref, int sepidx, const char *csvtemplate, int units);
-extern int parse_seabear_csv_file(const char *filename, int time, int depth, int temp, int po2f, int cnsf, int ndlf, int ttsf, int stopdepthf, int pressuref, int sepidx, const char *csvtemplate, int units);
+extern int parse_seabear_csv_file(const char *filename, int time, int depth, int temp, int po2f, int cnsf, int ndlf, int ttsf, int stopdepthf, int pressuref, int sepidx, const char *csvtemplate, int units, const char *delta);
extern int parse_txt_file(const char *filename, const char *csv);
-extern int parse_manual_file(const char *filename, int separator_index, int units, int dateformat, int durationformat, int number, int date, int time, int duration, int location, int gps, int maxdepth, int meandepth, int divemaster, int buddy, int notes, int weight, int tags, int cylsizef, int startpresf, int endpresf, int o2f, int hef, int airtempf, int watertempf);
+extern int parse_manual_file(const char *filename, int separator_index, int units, int dateformat, int durationformat, int number, int date, int time, int duration, int location, int gps, int maxdepth, int meandepth, int divemaster, int buddy, int suit, int notes, int weight, int tags, int cylsizef, int startpresf, int endpresf, int o2f, int hef, int airtempf, int watertempf);
extern int save_dives(const char *filename);
extern int save_dives_logic(const char *filename, bool select_only);
extern int save_dive(FILE *f, struct dive *dive);
extern int export_dives_xslt(const char *filename, const bool selected, const int units, const char *export_xslt);
+struct membuffer;
+extern void save_one_dive_to_mb(struct membuffer *b, struct dive *dive);
+
struct git_oid;
struct git_repository;
#define dummy_git_repository ((git_repository *)3ul) /* Random bogus pointer, not NULL */
@@ -712,6 +727,7 @@ extern struct dive *merge_dives(struct dive *a, struct dive *b, int offset, bool
extern struct dive *try_to_merge(struct dive *a, struct dive *b, bool prefer_downloaded);
extern void renumber_dives(int start_nr, bool selected_only);
extern void copy_events(struct divecomputer *s, struct divecomputer *d);
+extern void free_events(struct event *ev);
extern void copy_cylinders(struct dive *s, struct dive *d, bool used_only);
extern void copy_samples(struct divecomputer *s, struct divecomputer *d);
extern bool is_cylinder_used(struct dive *dive, int idx);
@@ -803,10 +819,10 @@ struct divedatapoint *create_dp(int time_incr, int depth, struct gasmix gasmix,
#if DEBUG_PLAN
void dump_plan(struct diveplan *diveplan);
#endif
-int plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool show_disclaimer);
+bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool show_disclaimer);
void delete_single_dive(int idx);
-struct event *get_next_event(struct event *event, char *name);
+struct event *get_next_event(struct event *event, const char *name);
/* these structs holds the information that
@@ -864,7 +880,7 @@ extern depth_t string_to_depth(const char *str);
extern pressure_t string_to_pressure(const char *str);
extern volume_t string_to_volume(const char *str, pressure_t workp);
extern fraction_t string_to_fraction(const char *str);
-extern int average_depth(struct diveplan *dive);
+extern void average_max_depth(struct diveplan *dive, int *avg_depth, int *max_depth);
#include "pref.h"