summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extcap_parser.c11
-rw-r--r--extcap_parser.h3
-rw-r--r--ui/qt/extcap_argument.cpp8
-rw-r--r--ui/qt/extcap_argument.h2
-rw-r--r--ui/qt/extcap_argument_file.cpp16
5 files changed, 37 insertions, 3 deletions
diff --git a/extcap_parser.c b/extcap_parser.c
index 154e4aa068..ef683f1a40 100644
--- a/extcap_parser.c
+++ b/extcap_parser.c
@@ -339,6 +339,8 @@ extcap_token_sentence *extcap_tokenize_sentence(const gchar *s) {
tv->param_type = EXTCAP_PARAM_TOOLTIP;
} else if (g_ascii_strcasecmp(tv->arg, "mustexist") == 0) {
tv->param_type = EXTCAP_PARAM_FILE_MUSTEXIST;
+ } else if (g_ascii_strcasecmp(tv->arg, "fileext") == 0) {
+ tv->param_type = EXTCAP_PARAM_FILE_EXTENSION;
} else if (g_ascii_strcasecmp(tv->arg, "name") == 0) {
tv->param_type = EXTCAP_PARAM_NAME;
} else if (g_ascii_strcasecmp(tv->arg, "enabled") == 0) {
@@ -477,6 +479,7 @@ extcap_arg *extcap_new_arg(void) {
r->range_end = NULL;
r->default_complex = NULL;
r->fileexists = FALSE;
+ r->fileextension = NULL;
r->is_required = FALSE;
r->values = NULL;
@@ -503,6 +506,9 @@ void extcap_free_arg(extcap_arg *a) {
if (a->tooltip != NULL)
g_free(a->tooltip);
+ if (a->fileextension != NULL)
+ g_free(a->fileextension);
+
if (a->range_start != NULL)
extcap_free_complex(a->range_start);
@@ -594,6 +600,11 @@ extcap_arg *extcap_parse_arg_sentence(GList * args, extcap_token_sentence *s) {
target_arg->fileexists = (v->value[0] == 't' || v->value[0] == 'T');
}
+ if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_FILE_EXTENSION))
+ != NULL) {
+ target_arg->fileextension = g_strdup(v->value);
+ }
+
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_REQUIRED))
!= NULL) {
target_arg->is_required = (v->value[0] == 't' || v->value[0] == 'T');
diff --git a/extcap_parser.h b/extcap_parser.h
index de7be00498..a730d200bc 100644
--- a/extcap_parser.h
+++ b/extcap_parser.h
@@ -67,6 +67,7 @@ typedef enum {
EXTCAP_PARAM_NAME,
EXTCAP_PARAM_ENABLED,
EXTCAP_PARAM_FILE_MUSTEXIST,
+ EXTCAP_PARAM_FILE_EXTENSION,
EXTCAP_PARAM_PARENT,
EXTCAP_PARAM_REQUIRED
} extcap_param_type;
@@ -105,6 +106,8 @@ typedef struct _extcap_arg {
gchar *call;
gchar *display;
gchar *tooltip;
+
+ gchar * fileextension;
gboolean fileexists;
gboolean is_required;
diff --git a/ui/qt/extcap_argument.cpp b/ui/qt/extcap_argument.cpp
index b2ff0d04a7..0150446ae5 100644
--- a/ui/qt/extcap_argument.cpp
+++ b/ui/qt/extcap_argument.cpp
@@ -506,6 +506,14 @@ bool ExtcapArgument::isRequired()
return FALSE;
}
+bool ExtcapArgument::fileExists()
+{
+ if ( _argument != NULL )
+ return _argument->fileexists;
+
+ return FALSE;
+}
+
bool ExtcapArgument::isDefault()
{
if ( value().compare(defaultValue()) == 0 )
diff --git a/ui/qt/extcap_argument.h b/ui/qt/extcap_argument.h
index 0fdc59f31b..9287628a7c 100644
--- a/ui/qt/extcap_argument.h
+++ b/ui/qt/extcap_argument.h
@@ -98,6 +98,8 @@ Q_SIGNALS:
protected:
+ bool fileExists();
+
void setDefault(GHashTable * defaultsList);
ExtcapValueList loadValues(QString parent);
diff --git a/ui/qt/extcap_argument_file.cpp b/ui/qt/extcap_argument_file.cpp
index 557e3693b4..f0115ceda4 100644
--- a/ui/qt/extcap_argument_file.cpp
+++ b/ui/qt/extcap_argument_file.cpp
@@ -71,7 +71,6 @@ QWidget * ExtcapArgumentFileSelection::createEditor(QWidget * parent)
button->setToolTip(QString().fromUtf8(_argument->tooltip));
}
-
connect(button, SIGNAL(clicked()), (QObject *)this, SLOT(openFileDialog()));
editLayout->addWidget(textBox);
@@ -98,12 +97,23 @@ void ExtcapArgumentFileSelection::openFileDialog()
if (QFileInfo(filename).exists())
workingDir = QFileInfo(filename).dir();
+ QString fileExt(tr("Any File (*.*)"));
+ if ( _argument->fileextension != NULL )
+ {
+ QString givenExt = QString().fromUtf8(_argument->fileextension);
+ if ( givenExt.length() != 0 )
+ fileExt.prepend(";;").prepend(givenExt);
+ }
+
filename = QFileDialog::getOpenFileName((QWidget *)(textBox->parent()),
QString().fromUtf8(_argument->display) + " " + tr("Open File"),
- workingDir.absolutePath(), tr("All Files (*.*)"));
+ workingDir.absolutePath(), fileExt);
- if ( QFileInfo(filename).exists() )
+ if ( ! fileExists() || QFileInfo(filename).exists() )
+ {
textBox->setText(filename);
+ emit valueChanged();
+ }
}
bool ExtcapArgumentFileSelection::isValid()