[PATCH 5/5] Only remember a DC nickname if the user has pressed OK

Dirk Hohndel dirk at hohndel.org
Fri Dec 21 09:36:59 PST 2012


Linus Torvalds <torvalds at linux-foundation.org> writes:

> On Thu, Dec 20, 2012 at 5:14 PM, Dirk Hohndel <dirk at hohndel.org> wrote:
>>
>> I still don't like this, as set_dc_nickname() gets called for every new
>> dive. So if I say "ask me next time" then I'll get asked again, right
>> away. Also, the text in the dialogbox is now of course wrong.
>
> I think the whole nickname thing is wrong, and totally mis-designed.
>
> It also (and for the same reason) makes the XML look like crap.
>
> The nick-name shouldn't be some per-dive thing in the first place.
> Which very much implies that it should *NOT* be saved in the
> dive.divecomputer xml node.

That's a good point. It seemed to make sense to have it there with the
model in case people want to post dives. I could similarly argue that
all we need in the dives is the deviceid and even the model doesn't need
to be there, correct?

> So it shouldn't exist as a member of "struct divecomputer", and ti
> shouldn't exist in the XML under the divecomputer thing. The
> divecomputer node we have in the XML is a per-dive "this is the dive
> computer data for this dive" thing. Not a "oh, and this is what I call
> this dive computer, and let's repeat that information every single
> time!"

True, but again, this would apply to the model, too. It's also
redundantly repeated in every entry.

> I think a nickname for a dive computer may be a useful thing, but it
> should either be in the config file, or if it's saved in the XML it
> should be saved *separately* from the dives, and independently from
> them. Not in the middle of the dive data, multiple times.

Thinking some more about this I think we need to save it BOTH in the
config and in the XML file.

On the one hand the XML file should be self contained and if I send you
my XML file you should see the same names for the divecomputers when
displaying it.

On the other hand, if I have multiple data files then I shouldn't have
to manually enter the nickname every time.

I already store them in the config. What about adding a settings block
before the <dives></dives>? Something like

<settings>
<divecomputer deviceid='abc' nickname='my computer' />
<divecomputer deviceid='def' nickname='my backup computer' />
<autogroup value='TRUE' />  <--- remember, we wanted to make this per file
<other settings ... />
</settings>
<dives>
<program name='subsurface' version='1'></program>
<trip date='...

> Then, in prodile.c, when you want to show the nickname of the dive
> computer, you should *not* look at "dc->nickname". You should have a
> lookup function that takes the dc model and deviceid, and looks it up
> in that *separate* nickname table, and if it finds it there, show it
> (otherwise show the model).

Of course

> And giving nick-names to your dive computer should have ABSOLUTELY
> NOTHING to do with downloading new dives. That whole confusion - again
> - comes from thinking that nicknames are somehow associated with the
> per-dive dive computer info. That whole model makes no sense. It's a
> crazy model, and it results in these kinds of crazy confusions.

I'm not sure I agree with that last part. I think we should ask if the
user wants to name a dive computer the first time we see it - and that
is either when loading an XML file that has a deviceid and we don't have
a matching nickname, or when downloading from a new computer for the
first time...

This seems much more user friendly than expecting the user to somehow
detect the yet to be written divecomputer management menu entry...

/D


More information about the subsurface mailing list