aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Knall <roland.knall@br-automation.com>2016-02-01 09:53:31 +0100
committerRoland Knall <rknall@gmail.com>2016-02-01 12:14:44 +0000
commit71a21d79cfa6f40ddb4f761b40720e2bf5f75906 (patch)
tree7136106d5de03c0633313745f641aa42b3edbf8a
parent927ffaa794d5fb24e0b4f3fba08c4c31f4dd7d63 (diff)
extcap: Correct save for file arguments
Also add check to has_configuration Change-Id: Ia0ffbd3bf68ad51c26bc75b5ee179db179e22bd4 Reviewed-on: https://code.wireshark.org/review/13635 Reviewed-by: Roland Knall <rknall@gmail.com>
-rw-r--r--extcap.c5
-rw-r--r--ui/qt/extcap_argument_file.cpp20
2 files changed, 22 insertions, 3 deletions
diff --git a/extcap.c b/extcap.c
index c2f01d102a..a4e656f5bf 100644
--- a/extcap.c
+++ b/extcap.c
@@ -584,6 +584,11 @@ extcap_has_configuration(const char * ifname, gboolean is_required) {
else if ( ! defval && (!stored || strlen(g_strchomp(stored)) <= (size_t)0) )
found = TRUE;
}
+
+ if ( arg->arg_type == EXTCAP_ARG_FILESELECT ) {
+ if ( arg->fileexists && ! ( file_exists(defval) || file_exists(stored) ) )
+ found = TRUE;
+ }
}
}
diff --git a/ui/qt/extcap_argument_file.cpp b/ui/qt/extcap_argument_file.cpp
index 4d2e301aa1..3c99ae05cc 100644
--- a/ui/qt/extcap_argument_file.cpp
+++ b/ui/qt/extcap_argument_file.cpp
@@ -53,6 +53,9 @@ ExtcapArgumentFileSelection::~ExtcapArgumentFileSelection()
QWidget * ExtcapArgumentFileSelection::createEditor(QWidget * parent)
{
+ QString storeval;
+ QString text = defaultValue();
+
QWidget * fileWidget = new QWidget(parent);
QHBoxLayout * editLayout = new QHBoxLayout();
QMargins margins = editLayout->contentsMargins();
@@ -63,8 +66,14 @@ QWidget * ExtcapArgumentFileSelection::createEditor(QWidget * parent)
textBox = new QLineEdit(defaultValue(), parent);
textBox->setReadOnly(true);
- if ( _argument->default_complex != NULL && _argument->arg_type == EXTCAP_ARG_STRING )
- textBox->setText(QString().fromUtf8(extcap_complex_get_string(_argument->default_complex)));
+ if ( _argument->storeval )
+ {
+ QString storeValue = _argument->storeval;
+
+ if ( storeValue.length() > 0 && storeValue.compare(text) != 0 )
+ text = storeValue.trimmed();
+ }
+ textBox->setText(text);
if ( _argument->tooltip != NULL )
{
@@ -121,7 +130,12 @@ bool ExtcapArgumentFileSelection::isValid()
{
bool valid = false;
- if ( textBox->text().length() > 0 || ! isRequired() )
+ if ( textBox->text().length() > 0 )
+ {
+ if ( QFileInfo(textBox->text()).exists() && _argument->fileexists )
+ valid = true;
+ }
+ else if ( ! isRequired() )
valid = true;
QString lblInvalidColor = ColorUtils::fromColorT(prefs.gui_text_invalid).name();