Пример #1
0
static void get_uemis_divespot(const char *mountpath, int divespot_id, struct dive *dive)
{
	struct dive_site *nds = get_dive_site_by_uuid(dive->dive_site_uuid);
	if (nds && nds->name && strstr(nds->name,"from Uemis")) {
		if (load_uemis_divespot(mountpath, divespot_id)) {
			/* get the divesite based on the diveid, this should give us
			* the newly created site
			*/
			struct dive_site *ods = NULL;
			/* with the divesite name we got from parse_dive, that is called on load_uemis_divespot
			 * we search all existing divesites if we have one with the same name already. The function
			 * returns the first found which is luckily not the newly created.
			 */
			(void)get_dive_site_uuid_by_name(nds->name, &ods);
			if (ods) {
				/* if the uuid's are the same, the new site is a duplicat and can be deleted */
				if (nds->uuid != ods->uuid) {
					delete_dive_site(nds->uuid);
					dive->dive_site_uuid = ods->uuid;
				}
			}
		} else {
			/* if we cant load the dive site details, delete the site we
			* created in process_raw_buffer
			*/
			delete_dive_site(dive->dive_site_uuid);
		}
	}
}
Пример #2
0
static void parse_dive_location(char *line, struct membuffer *str, void *_dive)
{
	uint32_t uuid;
	char *name = get_utf8(str);
	struct dive *dive = _dive;
	struct dive_site *ds = get_dive_site_for_dive(dive);
	if (!ds) {
		uuid = get_dive_site_uuid_by_name(name, NULL);
		if (!uuid)
			uuid = create_dive_site(name, dive->when);
		dive->dive_site_uuid = uuid;
	} else {
		// we already had a dive site linked to the dive
		if (same_string(ds->name, "")) {
			ds->name = strdup(name);
		} else {
			// and that dive site had a name. that's weird - if our name is different, add it to the notes
			if (!same_string(ds->name, name))
				ds->notes = add_to_string(ds->notes, translate("gettextFromC", "additional name for site: %s\n"), name);
		}
	}
	free(name);
}