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); } } }
void LocationInformationWidget::acceptChanges() { char *uiString; currentDs->latitude = displayed_dive_site.latitude; currentDs->longitude = displayed_dive_site.longitude; uiString = ui.diveSiteName->text().toUtf8().data(); if (!same_string(uiString, currentDs->name)) { free(currentDs->name); currentDs->name = copy_string(uiString); } uiString = ui.diveSiteDescription->text().toUtf8().data(); if (!same_string(uiString, currentDs->description)) { free(currentDs->description); currentDs->description = copy_string(uiString); } uiString = ui.diveSiteNotes->document()->toPlainText().toUtf8().data(); if (!same_string(uiString, currentDs->notes)) { free(currentDs->notes); currentDs->notes = copy_string(uiString); } if (dive_site_is_empty(currentDs)) { delete_dive_site(currentDs->uuid); displayed_dive.dive_site_uuid = 0; setLocationId(0); } else { setLocationId(currentDs->uuid); } mark_divelist_changed(true); resetState(); emit informationManagementEnded(); emit coordinatesChanged(); }
void LocationInformationWidget::rejectChanges() { Q_ASSERT(currentDs != NULL); if (dive_site_is_empty(currentDs)) { delete_dive_site(currentDs->uuid); displayed_dive.dive_site_uuid = 0; setLocationId(0); } else { setLocationId(currentDs->uuid); } resetState(); emit informationManagementEnded(); emit coordinatesChanged(); }
void save_dives_buffer(struct membuffer *b, const bool select_only) { int i; struct dive *dive; dive_trip_t *trip; put_format(b, "<divelog program='subsurface' version='%d'>\n<settings>\n", VERSION); if (prefs.save_userid_local) put_format(b, " <userid>%30s</userid>\n", prefs.userid); /* save the dive computer nicknames, if any */ call_for_each_dc(b, save_one_device); if (autogroup) put_format(b, " <autogroup state='1' />\n"); put_format(b, "</settings>\n"); /* save the dive sites */ put_format(b, "<divesites>\n"); for (i = 0; i < dive_site_table.nr; i++) { struct dive_site *ds = get_dive_site(i); if (dive_site_is_empty(ds)) { int j; struct dive *d; for_each_dive(j, d) { if (d->dive_site_uuid == ds->uuid) d->dive_site_uuid = 0; } delete_dive_site(get_dive_site(i)->uuid); i--; // since we just deleted that one continue; } put_format(b, "<site uuid='%8x'", ds->uuid); show_utf8(b, ds->name, " name='", "'", 1); if (ds->latitude.udeg || ds->longitude.udeg) { put_degrees(b, ds->latitude, " gps='", " "); put_degrees(b, ds->longitude, "", "'"); } show_utf8(b, ds->description, " description='", "'", 1); show_utf8(b, ds->notes, " notes='", "'", 1); put_format(b, "/>\n"); } put_format(b, "</divesites>\n<dives>\n"); for (trip = dive_trip_list; trip != NULL; trip = trip->next) trip->index = 0; /* save the dives */ for_each_dive(i, dive) { if (select_only) { if (!dive->selected) continue; save_one_dive_to_mb(b, dive); } else { trip = dive->divetrip; /* Bare dive without a trip? */ if (!trip) { save_one_dive_to_mb(b, dive); continue; } /* Have we already seen this trip (and thus saved this dive?) */ if (trip->index) continue; /* We haven't seen this trip before - save it and all dives */ trip->index = 1; save_trip(b, trip); } } put_format(b, "</dives>\n</divelog>\n"); }
void save_dives_buffer(struct membuffer *b, const bool select_only) { int i; struct dive *dive; dive_trip_t *trip; put_format(b, "<divelog program='subsurface' version='%d'>\n<settings>\n", DATAFORMAT_VERSION); if (prefs.save_userid_local) put_format(b, " <userid>%30s</userid>\n", prefs.userid); /* save the dive computer nicknames, if any */ call_for_each_dc(b, save_one_device, select_only); if (autogroup) put_format(b, " <autogroup state='1' />\n"); put_format(b, "</settings>\n"); /* save the dive sites - to make the output consistent let's sort the table, first */ dive_site_table_sort(); put_format(b, "<divesites>\n"); for (i = 0; i < dive_site_table.nr; i++) { int j; struct dive *d; struct dive_site *ds = get_dive_site(i); if (dive_site_is_empty(ds)) { for_each_dive(j, d) { if (d->dive_site_uuid == ds->uuid) d->dive_site_uuid = 0; } delete_dive_site(get_dive_site(i)->uuid); i--; // since we just deleted that one continue; } if (select_only && !is_dive_site_used(ds->uuid, true)) continue; put_format(b, "<site uuid='%8x'", ds->uuid); show_utf8(b, ds->name, " name='", "'", 1); if (ds->latitude.udeg || ds->longitude.udeg) { put_degrees(b, ds->latitude, " gps='", " "); put_degrees(b, ds->longitude, "", "'"); } show_utf8(b, ds->description, " description='", "'", 1); show_utf8(b, ds->notes, " notes='", "'", 1); if (ds->taxonomy.nr) { put_format(b, ">\n"); for (int j = 0; j < ds->taxonomy.nr; j++) { struct taxonomy *t = &ds->taxonomy.category[j]; if (t->category != TC_NONE) { put_format(b, "<geo cat='%d'", t->category); put_format(b, " origin='%d'", t->origin); show_utf8(b, t->value, " value='", "'/>\n", 1); } } put_format(b, "</site>\n"); } else { put_format(b, "/>\n"); } } put_format(b, "</divesites>\n<dives>\n"); for (trip = dive_trip_list; trip != NULL; trip = trip->next) trip->index = 0; /* save the dives */ for_each_dive(i, dive) { if (select_only) { if (!dive->selected) continue; save_one_dive_to_mb(b, dive); } else { trip = dive->divetrip; /* Bare dive without a trip? */ if (!trip) { save_one_dive_to_mb(b, dive); continue; } /* Have we already seen this trip (and thus saved this dive?) */ if (trip->index) continue; /* We haven't seen this trip before - save it and all dives */ trip->index = 1; save_trip(b, trip); } } put_format(b, "</dives>\n</divelog>\n"); }
void save_dives_buffer(struct membuffer *b, const bool select_only) { int i; struct dive *dive; dive_trip_t *trip; put_format(b, "<divelog program='subsurface' version='%d'>\n<settings>\n", DATAFORMAT_VERSION); if (prefs.save_userid_local) put_format(b, " <userid>%30s</userid>\n", prefs.userid); /* save the dive computer nicknames, if any */ call_for_each_dc(b, save_one_device, select_only); if (autogroup) put_format(b, " <autogroup state='1' />\n"); put_format(b, "</settings>\n"); /* save the dive sites - to make the output consistent let's sort the table, first */ dive_site_table_sort(); put_format(b, "<divesites>\n"); for (i = 0; i < dive_site_table.nr; i++) { int j; struct dive *d; struct dive_site *ds = get_dive_site(i); if (dive_site_is_empty(ds)) { for_each_dive(j, d) { if (d->dive_site_uuid == ds->uuid) d->dive_site_uuid = 0; } delete_dive_site(ds->uuid); i--; // since we just deleted that one continue; } else if (ds->name && (strncmp(ds->name, "Auto-created dive", 17) == 0 || strncmp(ds->name, "New Dive", 8) == 0)) { // these are the two default names for sites from // the web service; if the site isn't used in any // dive (really? you didn't rename it?), delete it if (!is_dive_site_used(ds->uuid, false)) { if (verbose) fprintf(stderr, "Deleted unused auto-created dive site %s\n", ds->name); delete_dive_site(ds->uuid); i--; // since we just deleted that one continue; } } if (select_only && !is_dive_site_used(ds->uuid, true)) continue; put_format(b, "<site uuid='%8x'", ds->uuid); show_utf8(b, ds->name, " name='", "'", 1); if (ds->latitude.udeg || ds->longitude.udeg) { put_degrees(b, ds->latitude, " gps='", " "); put_degrees(b, ds->longitude, "", "'"); } show_utf8(b, ds->description, " description='", "'", 1); put_format(b, ">\n"); show_utf8(b, ds->notes, " <notes>", " </notes>\n", 0); if (ds->taxonomy.nr) { for (int j = 0; j < ds->taxonomy.nr; j++) { struct taxonomy *t = &ds->taxonomy.category[j]; if (t->category != TC_NONE && t->value) { put_format(b, " <geo cat='%d'", t->category); put_format(b, " origin='%d'", t->origin); show_utf8(b, t->value, " value='", "'/>\n", 1); } } } put_format(b, "</site>\n"); }