diff options
author | Gerald Combs <gerald@wireshark.org> | 2014-08-14 13:20:09 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2014-08-29 00:24:02 +0000 |
commit | a71f6807b82bb4a4149141af7eff79738304ee22 (patch) | |
tree | 8dbd4bfa0cb7774345f4b6e5d54e01626b692bf7 /ui/capture_ui_utils.c | |
parent | b65d0e07193fe15df08739f89d95c29edb6aafed (diff) |
Qt: Rework the "Manage Interfaces" dialog.
Convert QTableWidget to QTreeWidget.
It looks like the GTK+ version has a separate set of apply/save buttons
for each tab which *only* operates on that tab. This can result unexpected
behavior which throws away changes if the user updates more than one
tab. Use a single "OK" button that applies all of our changes instead.
Reorder the tabs. Put Local Interfaces first and select it by default.
Always show Remote Interfaces. Disable it on platforms that don't have
PCAP_REMOTE.
Automatically start editing when we add a new pipe. Don't immediately
update pipe interface settings. Wait until we hit "OK" instead.
Rename NewFileDelegate to PathChooserDelegate. Note that we might want
to move it use it elsewhere in the application.
Try switching the user-facing terminology from "Hide" to the more
positive "Show".
Tell the user that we don't save pipe or remote interface settings.
Add a help URL for the "Manage Interfaces" dialog box.
Use the GLib and Qt string functions and classes to split and join
comma-separated preferences. This makes sure capture_dev_user_descr_find
doesn't skip over the first interface. It also keeps the Qt code from
adding a leading comma to our capture preferences.
Add a note about strings to README.qt. Summary: Use QStrings.
For another day:
- If we *do* save remote settings we need to store credentials securely,
e.g. with CryptProtectData.
- Get rid of the remote settings dialogs. Their controls should fit in the
remote settings tab.
- Add an extcap tab.
- We need getter/setter functions for global_capture_opts.all_ifaces. We
iterate over it *way* too much.
Change-Id: Ib7b61972f3ece4325e0230f725e7f2678acbb24b
Reviewed-on: https://code.wireshark.org/review/3873
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/capture_ui_utils.c')
-rw-r--r-- | ui/capture_ui_utils.c | 70 |
1 files changed, 22 insertions, 48 deletions
diff --git a/ui/capture_ui_utils.c b/ui/capture_ui_utils.c index 23de71f716..6f1fae83fb 100644 --- a/ui/capture_ui_utils.c +++ b/ui/capture_ui_utils.c @@ -44,63 +44,37 @@ char * capture_dev_user_descr_find(const gchar *if_name) { - char *p, *str; - char *p2 = NULL; - char *descr = NULL; - int lp = 0; - int ct = 0; - - if ((prefs.capture_devices_descr == NULL) || - (*prefs.capture_devices_descr == '\0')) { - /* There are no descriptions. */ + gchar **if_tokens; + gchar *descr = NULL; + int i; + + if (if_name == NULL || strlen(if_name) < 1) { return NULL; } - /* There might be names like 'lo' and 'nflog' in Ubuntu which can lead to wrong results. - Therefore, the search must be more exact. */ - str = g_strdup_printf(",%s(", if_name); - if ((p = strstr(prefs.capture_devices_descr, str)) == NULL) { - /* There are, but there isn't one for this interface. */ + if (prefs.capture_devices_descr == NULL || + strlen(prefs.capture_devices_descr) < 1) { + /* There are no descriptions. */ return NULL; } - p++; - while (*p != '\0') { - /* error: ran into next interface description */ - if (*p == ',') - return NULL; - /* found left parenthesis, start of description */ - else if (*p == '(') { - ct = 0; - lp++; - /* skip over left parenthesis */ - p++; - /* save pointer to beginning of description */ - p2 = p; - continue; - } - else if (*p == ')') { - /* end of description */ - break; - } - else { - p++; - ct++; + + if_tokens = g_strsplit(prefs.capture_devices_descr, ",", -1); + for (i = 0; if_tokens[i] != NULL; i++) { + gchar **descr_tokens; + descr_tokens = g_strsplit_set(if_tokens[i], "()", -1); + if (g_strv_length(descr_tokens) == 3) { /* interface + description + empty */ + if (strcmp(descr_tokens[0], if_name) == 0 && strlen(descr_tokens[1]) > 0) { + descr = g_strdup(descr_tokens[1]); + g_strfreev(descr_tokens); + break; + } } + g_strfreev(descr_tokens); } + g_strfreev(if_tokens); - g_free(str); - if ((lp == 1) && (ct > 0) && (p2 != NULL)) { - /* Allocate enough space to return the string, - which runs from p2 to p, plus a terminating - '\0'. */ - descr = (char *)g_malloc(p - p2 + 1); - memcpy(descr, p2, p - p2); - descr[p - p2] = '\0'; - return descr; - } - else - return NULL; + return descr; } gint |