This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

How to modify the values of an enum preference after registering?

0

Hello

I would like to know whether it is possible to change the values of an enum preference after registering. I am integrating a tool to my custom dissector and this tool parses a specific file and extracts information. Based on the information extracted, the dissector should change/update the values of an enum preference so that the user will see an updated drop down box(with new options) in the preferences.

If it is not possible to change the enum values after registering a preference, is there some way to de-register/delete a previously registered preference and add a new preference?

asked 15 Dec '16, 06:58

sherlock_000's gravatar image

sherlock_000
11458
accept rate: 0%

edited 15 Dec '16, 06:59

I have managed to solve part of my question. I am now able to update the enum preference values after registering. The following is what I did:

  • Created a fixed length array of type enum_val_t and initialized all entries to End of List value (NULL for Name and Description and -1 for value)

  • Registered the enum preference using a reference to this array

  • Whenever the values of the enum preference drop-down list needs to be changed, I update the corresponding values to this array with an End of List entry at the last (I always make sure that the maximum entries within this array shall never go beyond its fixed length)

I am not sure whether it is the right solution but it works for me!

However, there is still one problem for which I would like to hear some suggestions. Once the preference is registered, if there occurs a scenario where no are entries needed to be displayed in the enum list, I want to hide the preference from the user. But with my current approach, the preference will be visible to the user with no options to choose from the drop-down list.

So my question is, is temporary hiding of a preference possible? If not, is it atleast possible to delete a preference (so that I can register it again if needed)?

(16 Dec '16, 03:43) sherlock_000