summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2015-04-24 17:10:55 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-04-24 09:36:21 -0700
commit757c4aab20cee9cd3699276a9b4f7a7aee4719c2 (patch)
treecc4e06502e06183a8267e6708dbb9870ad183816 /dive.c
parent98ae7b1f8657d153dd3b431638ff0110429b9d5f (diff)
downloadsubsurface-757c4aab20cee9cd3699276a9b4f7a7aee4719c2.tar.gz
Allow images to be added via the web
This adds a new divelist context menu entry which asks for a URL. The file is retrieved and if it is an image it is added to the cache and the url is associated to dives as with local files. NB this currently only works with URLs pointing directly to images. But it should not be too hard to add the possibility to add a direction via an html file and its image tags. To test: open dives/test43.xml and delete the image and then add the URL http://euve10195.vserver.de/~robert/wreck.jpg Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/dive.c b/dive.c
index 037db594c..07b057be6 100644
--- a/dive.c
+++ b/dive.c
@@ -2885,7 +2885,7 @@ static bool new_picture_for_dive(struct dive *d, char *filename)
// only add pictures that have timestamps between 30 minutes before the dive and
// 30 minutes after the dive ends
#define D30MIN (30 * 60)
-bool dive_check_picture_time(struct dive *d, char *filename, int shift_time, timestamp_t timestamp)
+bool dive_check_picture_time(struct dive *d, int shift_time, timestamp_t timestamp)
{
offset_t offset;
if (timestamp) {
@@ -2905,7 +2905,7 @@ bool picture_check_valid(char *filename, int shift_time)
timestamp_t timestamp = picture_get_timestamp(filename);
for_each_dive (i, dive)
- if (dive->selected && dive_check_picture_time(dive, filename, shift_time, timestamp))
+ if (dive->selected && dive_check_picture_time(dive, shift_time, timestamp))
return true;
return false;
}
@@ -2915,11 +2915,11 @@ void dive_create_picture(struct dive *dive, char *filename, int shift_time)
timestamp_t timestamp = picture_get_timestamp(filename);
if (!new_picture_for_dive(dive, filename))
return;
- if (!dive_check_picture_time(dive, filename, shift_time, timestamp))
+ if (!dive_check_picture_time(dive, shift_time, timestamp))
return;
struct picture *picture = alloc_picture();
- picture->filename = filename;
+ picture->filename = strdup(filename);
picture->offset.seconds = timestamp - dive->when + shift_time;
picture_load_exif_data(picture);