Beispiel #1
0
/**
 * @fn connectToEssid
 */
InterfaceAnswer NetctlInterface::connectToEssid(const QString essid,
                                                QMap<QString, QString> settings) const
{
    if (debug) qDebug() << PDEBUG;
    if (netctlCommand == nullptr) {
        if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
        return InterfaceAnswer::Error;
    }
    if (wpaCommand == nullptr) {
        if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
        return InterfaceAnswer::Error;
    }

    QString profile = wpaCommand->existentProfile(essid);
    if (profile.isEmpty())
        return connectToUnknownEssid(essid, settings);
    else
        return startProfile(profile);
}
Beispiel #2
0
void MainWindow::wifiTabStart()
{
    if (debug) qDebug() << PDEBUG;
    if (!checkExternalApps(QString("wpasup"))) {
        ErrorWindow::showWindow(1, QString(PDEBUG), debug);
        emit(needToBeConfigured());
        return;
    }
    if (ui->tableWidget_wifi->currentItem() == nullptr) return;

    ui->tabWidget->setDisabled(true);
    // name is hidden
    if (ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text() == QString("<hidden>")) {
        hiddenNetwork = true;
        passwdWid = new PasswdWidget(this);
        passwdWid->setPassword(false);
        int widgetWidth = 2 * width() / 3;
        int widgetHeight = 110;
        int x = (width() - widgetWidth) / 2;
        int y = (height() - widgetHeight) / 2;
        passwdWid->setGeometry(x, y, widgetWidth, widgetHeight);
        passwdWid->show();
        passwdWid->setFocusToLineEdit();
        return;
    }

    // name isn't hidden
    hiddenNetwork = false;
    QString profile = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text();
    QString profileName = QString("");
    if (!ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 4)->text().isEmpty()) {
        if (useHelper) {
            QList<QVariant> args;
            args.append(profile);
            QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
                                                       DBUS_HELPER_INTERFACE, QString("ProfileByEssid"),
                                                       args, true, debug);
            if (responce.isEmpty()) {
                if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
                useHelper = false;
                return wifiTabStart();
            }
            profileName = responce[0].toString();
        } else
            profileName = wpaCommand->existentProfile(profile);
        if (startProfileSlot(profileName))
            ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
        else
            ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
    } else {
        QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text();
        if (security == QString("none")) return connectToUnknownEssid(QString(""));
        else {
            passwdWid = new PasswdWidget(this);
            passwdWid->setPassword(true);
            int widgetWidth = 2 * width() / 3;
            int widgetHeight = 110;
            int x = (width() - widgetWidth) / 2;
            int y = (height() - widgetHeight) / 2;
            passwdWid->setGeometry(x, y, widgetWidth, widgetHeight);
            passwdWid->show();
            passwdWid->setFocusToLineEdit();
            return;
        }
    }

    updateWifiTab();
}