/*
   
        (c) 2006 by Thomas Michel <tom.michel@arcor.de>

        Kwlan is free software; you can redistribute it and/or modify
        it under the terms of the GNU Library General Public License as
        published by the Free Software Foundation; either version 2 of
        the License, or (at your option) any later version.

        Kwlan is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU Library General Public License for more details.

        You should have received a copy of the GNU Library General Public License
        along with this library; see the file COPYING.LIB.  If not, write to
        the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
        Boston, MA 02110-1301, USA.
*/

#include "kstartsupplicantdlg.h"
#include "wlanlib.h"
#include "wpa_ctrl.h"
#include "kwlansuclient.h"

#include <qstringlist.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qstring.h>
#include <kmessagebox.h>
#include <qwidget.h>
#include <klocale.h>

KStartSupplicantDlg::KStartSupplicantDlg(QWidget* parent, const char* name, bool modal, Qt::WFlags fl)
: QDialog(parent)//),name,modal,fl) //KStartSupplicant(parent,name, modal,fl)
{
    setupUi(this);
    cbDriver->clear();
    cbDriver->addItem("atmel");
    cbDriver->addItem("broadcom");
    cbDriver->addItem("bsd");
    cbDriver->addItem("hostap");
    cbDriver->addItem("ipw");
    cbDriver->addItem("madwifi");
    cbDriver->addItem("ndiswrapper");
    cbDriver->addItem("prism54");
    cbDriver->addItem("wext");
    cbDriver->addItem("wired");
}

KStartSupplicantDlg::~KStartSupplicantDlg()
{
}

/*$SPECIALIZATION$*/
void KStartSupplicantDlg::setData(QString *interface, QString *driver)
{
    if (interface) txtInterface->setText(*interface);
    if (driver) cbDriver->setCurrentIndex(cbDriver->findText(*driver));
}

void KStartSupplicantDlg::Cancel()
{
    m_start = FALSE;
    QDialog::close();
}

QString KStartSupplicantDlg::getInterface()
{
    return txtInterface->text();
}

QString KStartSupplicantDlg::getDriver()
{
    return cbDriver->currentText();
}

void KStartSupplicantDlg::startSupplicant()
{
    struct wpa_ctrl;
    // First get parameters
    QString interface, driver;
    interface = txtInterface->text();
    driver = cbDriver->currentText();

    if ((!interface.isEmpty()) && (!driver.isEmpty())) {
        m_start=TRUE;
        QWidget::close();
    }
    else {
        KMessageBox::sorry(this,i18n("You must select a driver and an interface."));
    }
}



#include "kstartsupplicantdlg.moc"


