aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/extcap_options_dialog.cpp
diff options
context:
space:
mode:
authorRoland Knall <roland.knall@br-automation.com>2018-03-02 15:41:00 +0100
committerRoland Knall <rknall@gmail.com>2018-04-05 09:31:23 +0000
commit6124ee2a1c06ccc96c3e9aa62c136f34085bfa61 (patch)
treea54fe1c4247e3f4519f71940d74c6a3f665d8a07 /ui/qt/extcap_options_dialog.cpp
parentc2422d78281e10beb6ce4ebda1d61c9d0ca63a09 (diff)
extcap: Reload values on request
Allow certaing elements to be reloaded upon request. The way this works is, certain elements can be configured to be reloadable. By doing so, the extcap is asked once more just for the values list of this item, together with all already set options, and reloads the available options depending on the response. Only supported for selector. Radio and Multiselect will need additional patches, also moving those parts outside of extcap_argument.cpp might make sense before hand. Change-Id: I2e9e3d109b334bf878835a7cc9354f468bc22dee Reviewed-on: https://code.wireshark.org/review/26223 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui/qt/extcap_options_dialog.cpp')
-rw-r--r--ui/qt/extcap_options_dialog.cpp71
1 files changed, 68 insertions, 3 deletions
diff --git a/ui/qt/extcap_options_dialog.cpp b/ui/qt/extcap_options_dialog.cpp
index cd7e386e48..88b809317b 100644
--- a/ui/qt/extcap_options_dialog.cpp
+++ b/ui/qt/extcap_options_dialog.cpp
@@ -205,7 +205,7 @@ void ExtcapOptionsDialog::loadArguments()
item = g_list_first((GList *)(walker->data));
while ( item != NULL )
{
- argument = ExtcapArgument::create((extcap_arg *)(item->data));
+ argument = ExtcapArgument::create((extcap_arg *)(item->data), this);
if ( argument != NULL )
{
if ( argument->isRequired() )
@@ -253,7 +253,6 @@ void ExtcapOptionsDialog::updateWidgets()
/* Load all extcap arguments */
loadArguments();
-
ExtcapArgumentList::iterator iter = extcapArguments.begin();
while ( iter != extcapArguments.end() )
{
@@ -424,7 +423,7 @@ void ExtcapOptionsDialog::resetValues()
}
}
-void ExtcapOptionsDialog::storeValues()
+GHashTable *ExtcapOptionsDialog::getArgumentSettings(bool useCallsAsKey)
{
GHashTable * entries = g_hash_table_new(g_str_hash, g_str_equal);
ExtcapArgumentList::const_iterator iter;
@@ -476,6 +475,9 @@ void ExtcapOptionsDialog::storeValues()
value = (*iter)->prefValue();
QString key = argument->prefKey(device_name);
+ if ( useCallsAsKey )
+ key = argument->call();
+
if (key.length() > 0)
{
gchar * val = g_strdup(value.length() == 0 ? " " : value.toStdString().c_str());
@@ -484,6 +486,13 @@ void ExtcapOptionsDialog::storeValues()
}
}
+ return entries;
+}
+
+void ExtcapOptionsDialog::storeValues()
+{
+ GHashTable * entries = getArgumentSettings();
+
if ( g_hash_table_size(entries) > 0 )
{
if ( prefs_store_ext_multiple("extcap", entries) )
@@ -492,6 +501,62 @@ void ExtcapOptionsDialog::storeValues()
}
}
+ExtcapValueList ExtcapOptionsDialog::loadValuesFor(int argNum, QString argumentName, QString parent)
+{
+ ExtcapValueList elements;
+ GList * walker = 0, * values = 0;
+ extcap_value * v;
+
+ QList<QWidget *> children = findChildren<QWidget *>();
+ foreach ( QWidget * child, children )
+ child->setEnabled(false);
+
+ QString argcall = argumentName;
+ if ( argcall.startsWith("--") )
+ argcall = argcall.right(argcall.size()-2);
+
+ GHashTable * entries = getArgumentSettings(true);
+
+ values = extcap_get_if_configuration_values(this->device_name.toStdString().c_str(), argcall.toStdString().c_str(), entries);
+
+ for (walker = g_list_first((GList *)(values)); walker != NULL ; walker = walker->next)
+ {
+ v = (extcap_value *) walker->data;
+ if (v == NULL || v->display == NULL || v->call == NULL )
+ break;
+
+ /* Only accept values for this argument */
+ if ( v->arg_num != argNum )
+ break;
+
+ QString valParent = QString().fromUtf8(v->parent);
+
+ if ( parent.compare(valParent) == 0 )
+ {
+
+ QString display = QString().fromUtf8(v->display);
+ QString call = QString().fromUtf8(v->call);
+
+ ExtcapValue element = ExtcapValue(display, call,
+ v->enabled == (gboolean)TRUE, v->is_default == (gboolean)TRUE);
+
+#if 0
+ /* TODO: Disabled due to wrong parent handling. It leads to an infinite loop for now. To implement this properly, other things
+ will be needed, like new arguments for setting the parent in the call to the extcap utility*/
+ if (!call.isEmpty())
+ element.setChildren(this->loadValuesFor(argumentName, call));
+#endif
+
+ elements.append(element);
+ }
+ }
+
+ foreach ( QWidget * child, children )
+ child->setEnabled(true);
+
+ return elements;
+}
+
/*
* Editor modelines
*