Changeset e4086dc in subsurface


Ignore:
Timestamp:
Apr 4, 2017, 10:54:55 AM (3 weeks ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
e700ea9
Parents:
4864ea5
git-author:
Salvador Cuñat <salvador.cunat@…> (04/02/17 14:42:36)
git-committer:
Dirk Hohndel <dirk@…> (04/04/17 10:54:55)
Message:

smtk-import Avoid duplicities in bookmarks

SmartTrak?'s bookmarks work in the same fashion Subsurface's do. The user
may set a bookmark while underwater or set it just on the divelog
software.
At this time we are parsing those set in the DC twice, as we get one
from libdivecomputer and another from smarttrak's database.

This patch just checks if we have a bookmark event downloaded by
libdivecomputer which has the same time that the one parsed from the
.slg file. If so, merge the names taking the one from smarttrak.

Text from smarttrak is preferred because the user may have entered some
interesting note there and libdivecomputer's name is just "bookmark".

Signed-off-by: Salvador Cuñat <salvador.cunat@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • smtk-import/smartrak.c

    r4864ea5 re4086dc  
    646646
    647647/*
     648 * Returns a pointer to a bookmark event in an event list if it exists for
     649 * a given time. Return NULL otherwise.
     650 */
     651static struct event *find_bookmark(struct event *orig, unsigned int t)
     652{
     653        struct event *ev = orig;
     654
     655        while (ev) {
     656                if ((ev->time.seconds == t) && (ev->type == SAMPLE_EVENT_BOOKMARK))
     657                        return ev;
     658                ev = ev->next;
     659        }
     660        return NULL;
     661}
     662
     663/*
    648664 * Marker table is a mix between Type tables and Relations tables. Its format is
    649665 * | Dive Idx | Idx | Text | Type | XPos | YPos | XConnect | YConnect
     
    660676        char *bound_values[MDB_MAX_COLS], *tmp = NULL;
    661677        unsigned int time;
     678        struct event *ev;
    662679
    663680        table = smtk_open_table(mdb, "Marker", col, bound_values);
     
    668685                        time = lrint(strtod(col[4]->bind_ptr, NULL) * 60);
    669686                        tmp = strdup(col[2]->bind_ptr);
    670                         if (!add_event(&d->dc, time, SAMPLE_EVENT_BOOKMARK, 0, 0, tmp))
    671                         report_error("[smtk-import] Error - Couldn't add bookmark, dive %d, Name = %s",
    672                                      d->number, tmp);
     687                        ev = find_bookmark(d->dc.events, time);
     688                        if (ev != NULL) {
     689                                memset(&ev->name, 0, strlen(tmp) + 1);
     690                                memcpy(ev->name, tmp, strlen(tmp));
     691                        } else
     692                                if (!add_event(&d->dc, time, SAMPLE_EVENT_BOOKMARK, 0, 0, tmp))
     693                                        report_error("[smtk-import] Error - Couldn't add bookmark, dive %d, Name = %s",
     694                                                     d->number, tmp);
    673695                }
    674696        }
Note: See TracChangeset for help on using the changeset viewer.