summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-12 20:26:29 -1000
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-13 21:33:30 -1000
commit713a4fcff6a580aab4a5036a5c3603ebce7ee830 (patch)
treeb47b4bd29cc692b1dfaa6890d108b422d1066ffa /main.c
parentaba65736eb8cb85fa9bfa953095eab21f0668904 (diff)
downloadsubsurface-713a4fcff6a580aab4a5036a5c3603ebce7ee830.tar.gz
Add the ability to set a nickname for a dive computer
We maintain a list of dive computers that we know about (by deviceid) and their nicknames in our config. If the user downloads dive from a dive computer that we haven't seen before, we give them the option to set a nickname for that dive computer. That nickname is displayed in the profile (and stored in the XML file, assuming it is not the same as the model). This implementation attempts to make sure that it correctly deals with utf8 nicknames. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'main.c')
-rw-r--r--main.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/main.c b/main.c
index b8d5079cc..44373faf6 100644
--- a/main.c
+++ b/main.c
@@ -124,6 +124,16 @@ void report_dives(gboolean is_imported, gboolean prefer_imported)
int preexisting = dive_table.preexisting;
struct dive *last;
+ /* set the nickname for the divecomputer for newly downloaded dives */
+ for (i = dive_table.preexisting; i < dive_table.nr; i++)
+ if (dive_table.dives[i]->downloaded) {
+ set_dc_nickname(dive_table.dives[i]);
+ } else {
+ struct divecomputer *dc = &dive_table.dives[i]->dc;
+ if (dc->nickname && *dc->nickname)
+ remember_dc(dc->deviceid, dc->nickname, TRUE);
+ }
+
/* This does the right thing for -1: NULL */
last = get_dive(preexisting-1);