mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Merge branch 'webservice-import'
Update maxdepth / duration that have moved into the divecomputer structure. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
						commit
						100c400809
					
				
					 4 changed files with 37 additions and 3 deletions
				
			
		
							
								
								
									
										9
									
								
								dive.c
									
										
									
									
									
								
							
							
						
						
									
										9
									
								
								dive.c
									
										
									
									
									
								
							|  | @ -1206,12 +1206,19 @@ static int max_time(duration_t a, duration_t b) | ||||||
|  */ |  */ | ||||||
| static int likely_same_dive(struct dive *a, struct dive *b) | static int likely_same_dive(struct dive *a, struct dive *b) | ||||||
| { | { | ||||||
| 	int fuzz, match; | 	int match, fuzz = 20 * 60; | ||||||
| 
 | 
 | ||||||
| 	/* Don't try to merge dives in different trips */ | 	/* Don't try to merge dives in different trips */ | ||||||
| 	if (a->divetrip && b->divetrip && a->divetrip != b->divetrip) | 	if (a->divetrip && b->divetrip && a->divetrip != b->divetrip) | ||||||
| 		return 0; | 		return 0; | ||||||
| 
 | 
 | ||||||
|  | 	/* if one of the dives has no depth and duration this could be
 | ||||||
|  | 	 * a location marker from the webservice (in this situation it | ||||||
|  | 	 * is valid to only check the first dc structure as we know that | ||||||
|  | 	 * a location marker will only ever have one of those structures) */ | ||||||
|  | 	if ((!a->dc.maxdepth.mm && !a->dc.duration.seconds) || | ||||||
|  | 	    (!b->dc.maxdepth.mm && !b->dc.duration.seconds)) | ||||||
|  | 		return ((a->when <= b->when + fuzz) && (a->when >= b->when - fuzz)); | ||||||
| 	/*
 | 	/*
 | ||||||
| 	 * Do some basic sanity testing of the values we | 	 * Do some basic sanity testing of the values we | ||||||
| 	 * have filled in during 'fixup_dive()' | 	 * have filled in during 'fixup_dive()' | ||||||
|  |  | ||||||
							
								
								
									
										5
									
								
								main.c
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								main.c
									
										
									
									
									
								
							|  | @ -165,7 +165,10 @@ void report_dives(gboolean is_imported, gboolean prefer_imported) | ||||||
| 		struct dive *dive = pp[1]; | 		struct dive *dive = pp[1]; | ||||||
| 		struct dive *merged; | 		struct dive *merged; | ||||||
| 
 | 
 | ||||||
| 		if (prev->when + prev->dc.duration.seconds < dive->when) | 		/* only try to merge overlapping dives - or if one of the dives has
 | ||||||
|  | 		 * zero duration (that might be a gps marker from the webservice) */ | ||||||
|  | 		if (prev->dc.duration.seconds && dive->dc.duration.seconds && | ||||||
|  | 		    prev->when + prev->dc.duration.seconds < dive->when) | ||||||
| 			continue; | 			continue; | ||||||
| 
 | 
 | ||||||
| 		merged = try_to_merge(prev, dive, prefer_imported); | 		merged = try_to_merge(prev, dive, prefer_imported); | ||||||
|  |  | ||||||
							
								
								
									
										22
									
								
								parse-xml.c
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								parse-xml.c
									
										
									
									
									
								
							|  | @ -932,6 +932,22 @@ static degrees_t parse_degrees(char *buf, char **end) | ||||||
| 	return ret; | 	return ret; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static void gps_lat(char *buffer, void *_dive) | ||||||
|  | { | ||||||
|  | 	char *end; | ||||||
|  | 	struct dive *dive = _dive; | ||||||
|  | 
 | ||||||
|  | 	dive->latitude = parse_degrees(buffer, &end); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static void gps_long(char *buffer, void *_dive) | ||||||
|  | { | ||||||
|  | 	char *end; | ||||||
|  | 	struct dive *dive = _dive; | ||||||
|  | 
 | ||||||
|  | 	dive->longitude = parse_degrees(buffer, &end); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| static void gps_location(char *buffer, void *_dive) | static void gps_location(char *buffer, void *_dive) | ||||||
| { | { | ||||||
| 	char *end; | 	char *end; | ||||||
|  | @ -986,8 +1002,14 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf) | ||||||
| 		return; | 		return; | ||||||
| 	if (MATCH(".gps", gps_location, dive)) | 	if (MATCH(".gps", gps_location, dive)) | ||||||
| 		return; | 		return; | ||||||
|  | 	if (MATCH(".latitude", gps_lat, dive)) | ||||||
|  | 		return; | ||||||
|  | 	if (MATCH(".longitude", gps_long, dive)) | ||||||
|  | 		return; | ||||||
| 	if (MATCH(".location", utf8_string, &dive->location)) | 	if (MATCH(".location", utf8_string, &dive->location)) | ||||||
| 		return; | 		return; | ||||||
|  | 	if (MATCH(".name", utf8_string, &dive->location)) | ||||||
|  | 		return; | ||||||
| 	if (MATCH(".suit", utf8_string, &dive->suit)) | 	if (MATCH(".suit", utf8_string, &dive->suit)) | ||||||
| 		return; | 		return; | ||||||
| 	if (MATCH(".divesuit", utf8_string, &dive->suit)) | 	if (MATCH(".divesuit", utf8_string, &dive->suit)) | ||||||
|  |  | ||||||
|  | @ -198,7 +198,9 @@ void webservice_download_dialog(void) | ||||||
| 	result = gtk_dialog_run(GTK_DIALOG(dialog)); | 	result = gtk_dialog_run(GTK_DIALOG(dialog)); | ||||||
| 	if (result == GTK_RESPONSE_ACCEPT) { | 	if (result == GTK_RESPONSE_ACCEPT) { | ||||||
| 		/* apply download */ | 		/* apply download */ | ||||||
| 		g_message("\napply download should happen here: \n\n %s", state.xmldata); | 		/* g_message("\napply download should happen here: \n\n %s", state.xmldata); */ | ||||||
|  | 		parse_xml_buffer(_("Webservice"), state.xmldata, strlen(state.xmldata), NULL); | ||||||
|  | 		report_dives(TRUE, FALSE); | ||||||
| 	} | 	} | ||||||
| 	download_dialog_release_xml(&state); | 	download_dialog_release_xml(&state); | ||||||
| 	gtk_widget_destroy(dialog); | 	gtk_widget_destroy(dialog); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue