Commit a9847021 authored by librewish's avatar librewish
Browse files

rm windows tab its unnecessary

parent 0ddb0be1
......@@ -2,14 +2,13 @@
# Maintainer: librewish <librewish@garudalinux.org>
pkgname=garuda-network-assistant
pkgver=1.1.1
pkgver=1.1.2
pkgrel=1
pkgdesc="A Boot options utility for Garuda Linux"
arch=('any')
url="https://gitlab.com/garuda-linux/applications/garuda-network-assistant"
license=('GPL3')
depends=('qt5-base' 'xdg-utils' 'polkit' 'wget' 'net-tools' 'linux-wifi-hotspot' 'traceroute' 'ethtool' 'wireless_tools')
optdepends=('ndiswrapper' 'ndiswrapper-dkms')
depends=('qt5-base' 'xdg-utils' 'polkit' 'wget' 'net-tools' 'linux-wifi-hotspot' 'traceroute' 'wireless_tools')
makedepends=('git')
groups=('garuda')
source=("$pkgname.tar.gz::$url/-/archive/$pkgver/$pkgname-$pkgver.tar.gz")
......
......@@ -55,8 +55,6 @@ MainWindow::MainWindow(QWidget* parent)
SLOT(showContextMenuForHw(const QPoint &)));
connect(linuxDrvList, SIGNAL(customContextMenuRequested(const QPoint &)),
SLOT(showContextMenuForLinuxDrv(const QPoint &)));
connect(windowsDrvList, SIGNAL(customContextMenuRequested(const QPoint &)),
SLOT(showContextMenuForWindowsDrv(const QPoint &)));
}
MainWindow::~MainWindow() {
......@@ -86,9 +84,6 @@ void MainWindow::refresh() {
checkAirplaneEnabled();
checkGpsEnabled();
checkWolEnabled();
checkWpEnabled();
checkMacDisabled();
// checkWifiAvailable();
checkNetwokManagerStatus();
checkConnmanStatus();
......@@ -103,10 +98,7 @@ void MainWindow::refresh() {
on_linuxDrvDiagnosePushButton_clicked();
break;
case 2: // Windows drivers
on_windowsDrvDiagnosePushButton_clicked();
break;
case 3: // Diagnostic
case 2: // Diagnostic
break;
default:
......@@ -190,31 +182,6 @@ void MainWindow::linuxDrvListFullToClipboard()
}
}
void MainWindow::windowsDrvListToClipboard()
{
if (linuxDrvList->currentRow() != -1)
{
QClipboard *clipboard = QApplication::clipboard();
QListWidgetItem* currentElement = windowsDrvList->currentItem();
clipboard->setText(currentElement->text());
}
}
void MainWindow::windowsDrvListFullToClipboard()
{
if (hwList->count() > -1)
{
QClipboard *clipboard = QApplication::clipboard();
QString elementList = "";
for (int i = 0; i < windowsDrvList->count(); i++)
{
QListWidgetItem* currentElement = windowsDrvList->item(i);
elementList += currentElement->text() + "\n";
}
clipboard->setText(elementList);
}
}
void MainWindow::showContextMenuForHw(const QPoint &pos)
{
QMenu contextMenu(this);
......@@ -243,20 +210,6 @@ void MainWindow::showContextMenuForLinuxDrv(const QPoint &pos)
contextMenu.exec(linuxDrvList->mapToGlobal(pos));
}
void MainWindow::showContextMenuForWindowsDrv(const QPoint &pos)
{
QMenu contextMenu(this);
QAction * copyAction = new QAction(tr("&Copy"), this);
connect(copyAction, SIGNAL(activated()) , this, SLOT(windowsDrvListToClipboard()));
copyAction->setShortcut(tr("Ctrl+C"));
QAction * copyAllAction = new QAction(tr("Copy &All"), this);
connect(copyAllAction, SIGNAL(activated()) , this, SLOT(windowsDrvListFullToClipboard()));
copyAllAction->setShortcut(tr("Ctrl+A"));
contextMenu.addAction(copyAction);
contextMenu.addAction(copyAllAction);
contextMenu.exec(windowsDrvList->mapToGlobal(pos));
}
void MainWindow::on_clearTraceOutput_clicked()
{
tracerouteOutputEdit->clear();
......@@ -590,59 +543,6 @@ void MainWindow::on_linuxDrvDiagnosePushButton_clicked()
inputr8168Blacklist.close();
}
void MainWindow::on_windowsDrvDiagnosePushButton_clicked()
{
windowsDrvList->clear();
if (system("[ -f /usr/sbin/ndiswrapper ]") != 0) {
uninstallNdiswrapper->setVisible(false);
QMessageBox::warning(0, windowTitle(), QApplication::tr("Ndiswrapper is not installed"));
return;
}
QStringList queryResult = cmd.getCmdOut("ndiswrapper -l 2>/dev/null").split("\n");
if (queryResult.size() == 1 && queryResult.at(0) == "") return;
int i = 0;
while (i < queryResult.size())
{
QString currentElement = queryResult.at(i);
QString label = currentElement.left(currentElement.indexOf(":"));
label.append(QApplication::tr("driver installed"));
//label = currentElement.remove(": ");
if ((i + 1) < queryResult.size())
{
if (!queryResult.at(i + 1).contains(": driver installed"))
{
QString installInfo = queryResult.at(i + 1);
int infoPos = installInfo.indexOf(QRegExp("[\\d|A|B|C|D|E|F][\\d|A|B|C|D|E|F][\\d|A|B|C|D|E|F][\\d|A|B|C|D|E|F]:[\\d|A|B|C|D|E|F][\\d|A|B|C|D|E|F][\\d|A|B|C|D|E|F][\\d|A|B|C|D|E|F]"));
//device (14E4:4320) present (alternate driver: bcm43xx)
if (infoPos != -1)
{
label.append(QApplication::tr(" and in use by "));
label.append(installInfo.midRef(infoPos, 9));
}
if (installInfo.contains("alternate driver"))
{
infoPos = installInfo.lastIndexOf(": ");
if (infoPos != -1)
{
int strLen = installInfo.length();
label.append(QApplication::tr(". Alternate driver: "));
QString s =installInfo.right(strLen - infoPos);
s.remove(")");
s.remove(" ");
s.remove(":");
label.append(s);
}
}
i++;
}
}
new QListWidgetItem(QIcon("/usr/share/icons/breeze/apps/16/krfb.png"), label, windowsDrvList);
i++;
}
}
bool MainWindow::blacklistModule(QString module)
{
QFile outputBlacklist;
......@@ -842,112 +742,6 @@ bool MainWindow::installModule(QString module)
return true;
}
// run apt-get update and at the end start installNDIS
void MainWindow::on_installNdiswrapper_clicked()
{
setCursor(QCursor(Qt::BusyCursor));
if (installProc->state() != QProcess::NotRunning)
{
installProc->kill();
}
installProc->start("pacman -Sy");
installOutputEdit->clear();
installOutputEdit->show();
installOutputEdit->resize(800, 600);
// center output window
QRect screenGeometry = QApplication::desktop()->screenGeometry();
int x = (screenGeometry.width()-installOutputEdit->width()) / 2;
int y = (screenGeometry.height()-installOutputEdit->height()) / 2;
installOutputEdit->move(x, y);
// hide main window
this->hide();
installOutputEdit->raise();
disconnect(installProc, SIGNAL(readyReadStandardOutput()), 0, 0);
connect(installProc, SIGNAL(readyReadStandardOutput()), this, SLOT(writeInstallOutput()));
disconnect(installProc, SIGNAL(finished(int)), 0, 0);
connect(installProc, SIGNAL(finished(int)), this, SLOT(aptUpdateFinished()));
}
// Uninstall ndiswrapper
void MainWindow::on_uninstallNdiswrapper_clicked()
{
setCursor(QCursor(Qt::BusyCursor));
if (installProc->state() != QProcess::NotRunning)
{
installProc->kill();
}
removeModule("ndiswrapper");
installProc->start("pacman -Rns ndiswrapper ndiswrapper-dkms --noconfirm");
installOutputEdit->clear();
installOutputEdit->show();
installOutputEdit->resize(800, 600);
// center output window
QRect screenGeometry = QApplication::desktop()->screenGeometry();
int x = (screenGeometry.width()-installOutputEdit->width()) / 2;
int y = (screenGeometry.height()-installOutputEdit->height()) / 2;
installOutputEdit->move(x, y);
// hide main window
this->hide();
installOutputEdit->raise();
disconnect(installProc, SIGNAL(readyReadStandardOutput()), 0, 0);
connect(installProc, SIGNAL(readyReadStandardOutput()), this, SLOT(writeInstallOutput()));
disconnect(installProc, SIGNAL(finished(int)), 0, 0);
connect(installProc, SIGNAL(finished(int)), this, SLOT(uninstallNdisFinished(int)));
}
// install NDISwrapper
void MainWindow::aptUpdateFinished()
{
if (installProc->state() != QProcess::NotRunning)
{
installProc->kill();
}
installProc->start("pacman -S ndiswrapper ndiswrapper-dkms --noconfirm");
disconnect(installProc, SIGNAL(readyReadStandardOutput()), 0, 0);
connect(installProc, SIGNAL(readyReadStandardOutput()), this, SLOT(writeInstallOutput()));
disconnect(installProc, SIGNAL(finished(int)), 0, 0);
connect(installProc, SIGNAL(finished(int)), this, SLOT(installFinished(int)));
}
// finished ndiswrapper install
void MainWindow::installFinished(int errorCode)
{
installOutputEdit->close();
this->show();
setCursor(QCursor(Qt::ArrowCursor));
if (errorCode == 0)
{
if (installModule("ndiswrapper"))
{
uninstallNdiswrapper->setVisible(true);
QMessageBox::information(0, windowTitle(), QApplication::tr("Installation successful"));
}
else
{
QMessageBox::information(0, windowTitle(), QApplication::tr("Error detected, could not compile ndiswrapper driver."));
}
}
else
{
QMessageBox::warning(0, windowTitle(), QApplication::tr("Error detected, could not install ndiswrapper."));
}
}
void MainWindow::uninstallNdisFinished(int errorCode)
{
installOutputEdit->close();
this->show();
setCursor(QCursor(Qt::ArrowCursor));
if (errorCode == 0) {
removeStart("ndiswrapper");
} else {
QMessageBox::warning(0, windowTitle(), QApplication::tr("Error encountered while removing Ndiswrapper"));
}
}
void MainWindow::writeInstallOutput()
{
QByteArray bytes = installProc->readAllStandardOutput();
......@@ -1347,93 +1141,11 @@ void MainWindow::on_bluetooth_clicked()
{
system("systemctl enable bluetooth --now");
}
void MainWindow::on_restartwifi_clicked()
{
QProcess proc;
proc.start("/bin/sh", QStringList()<< "/usr/share/garuda/scripts/restart-wifi.sh");
proc.waitForFinished();
}
void MainWindow::on_restartbt_clicked()
{
QProcess proc;
proc.start("/bin/sh", QStringList()<< "/usr/share/garuda/scripts/restart-bt.sh");
proc.waitForFinished();
}
void MainWindow::on_wifihotspot_clicked()
{
system("sh -c 'env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /usr/bin/wihotspot'");
}
void MainWindow::on_windowsDrvAddPushButton_clicked()
{
QString infFileName = QFileDialog::getOpenFileName(this,
tr("Locate the Windows driver you want to add"), "/home", tr("Windows installation information file (*.inf)"));
if (!infFileName.isEmpty())
{
// Search in the inf file the name of the .sys file
QFile infFile(infFileName);
infFile.open(QFile::ReadOnly|QFile::Text);
QString s;
bool found = false;
bool exist = false;
QStringList foundSysFiles;
QDir sysDir(infFileName);
sysDir.cdUp();
while ((!infFile.atEnd())) {
s = infFile.readLine();
if (s.contains("ServiceBinary",Qt::CaseInsensitive)) {
s = s.right(s.length() - s.lastIndexOf('\\'));
s = s.remove('\\');
s = s.remove('\n');
found = true;
if (this->checkSysFileExists(sysDir, s, Qt::CaseInsensitive)) {
exist = true;
}
else {
foundSysFiles << s;
}
}
}
infFile.close();
if (found) {
if (!exist) {
QMessageBox::warning(0, QString(tr("*.sys file not found")), tr("The *.sys files must be in the same location as the *.inf file. %1 cannot be found").arg(foundSysFiles.join(", ")));
}
else {
QString cmd_str = QString("ndiswrapper -i %1").arg(infFileName);
cmd.run(cmd_str);
cmd_str = QString("ndiswrapper -ma");
cmd.run(cmd_str);
on_windowsDrvDiagnosePushButton_clicked();
}
}
else {
QMessageBox::critical(0, QString(tr("sys file reference not found")).arg(infFile.fileName()), tr("The sys file for the given driver cannot be determined after parsing the inf file"));
}
}
}
void MainWindow::on_windowsDrvList_currentRowChanged(int row)
{
windowsDrvRemovePushButton->setEnabled(row != -1);
}
void MainWindow::on_windowsDrvRemovePushButton_clicked()
{
if (windowsDrvList->currentRow() != -1)
{
QListWidgetItem* currentDriver = windowsDrvList->currentItem();
QString driver = currentDriver->text();
QString cmd_str = QString("ndiswrapper -r %1").arg(driver.left(driver.indexOf(" ")));
cmd.run(cmd_str);
QMessageBox::information(0, windowTitle(), tr("Ndiswrapper driver removed."));
on_windowsDrvDiagnosePushButton_clicked();
}
}
void MainWindow::on_generalHelpPushButton_clicked()
{
......@@ -1523,126 +1235,3 @@ void MainWindow::on_linuxDrvUnload_clicked()
}
}
}
bool MainWindow::checkWolEnabled()
{
QProcess procwol;
//wakeonlan status
procwol.start("/bin/sh", QStringList()<< "/usr/share/garuda/scripts/check-wol.sh");
procwol.waitForFinished();
QString wol=procwol.readAllStandardOutput();
wol = wol.trimmed();
if( wol == "enabled")
{
checkBox_wol->setChecked(true);
return true;
}
else
{
checkBox_wol->setChecked(false);
return false;
}
}
void MainWindow::on_checkBox_wol_clicked(bool checked)
{
if(checked) //on
{
QProcess proc;
proc.startDetached("/bin/sh", QStringList()<< "/usr/share/garuda/scripts/wol-on.sh");
proc.waitForFinished();
}
else //off
{
QProcess proc;
proc.startDetached("/bin/sh", QStringList()<< "/usr/share/garuda/scripts/wol-off.sh");
proc.waitForFinished();
}
checkWolEnabled();
checkWolEnabled();
}
bool MainWindow::checkWpEnabled()
{
QProcess procwp;
//wifi powersave status
procwp.start("/bin/sh", QStringList()<< "/usr/share/garuda/scripts/check-wifi-powersave.sh");
procwp.waitForFinished();
QString wp=procwp.readAllStandardOutput();
wp = wp.trimmed();
if( wp == "enabled")
{
checkBox_wifipowersave->setChecked(true);
return true;
}
else
{
checkBox_wifipowersave->setChecked(false);
return false;
}
}
void MainWindow::on_checkBox_wifipowersave_clicked(bool checked)
{
if(checked) //on
{
QProcess proc;
proc.startDetached("/bin/sh", QStringList()<< "/usr/share/garuda/scripts/wifi-powersave-on.sh");
proc.waitForFinished();
}
else //off
{
QProcess proc;
proc.startDetached("/bin/sh", QStringList()<< "/usr/share/garuda/scripts/wifi-powersave-off.sh");
proc.waitForFinished();
}
checkWpEnabled();
checkWpEnabled();
}
bool MainWindow::checkMacDisabled()
{
QProcess procmac;
//wifi powersave status
procmac.start("/bin/sh", QStringList()<< "/usr/share/garuda/scripts/check-nm-mac-random.sh");
procmac.waitForFinished();
QString mac=procmac.readAllStandardOutput();
mac = mac.trimmed();
if( mac == "enabled")
{
checkBox_nmmaccrandom->setChecked(true);
return true;
}
else
{
checkBox_nmmaccrandom->setChecked(false);
return false;
}
}
void MainWindow::on_checkBox_nmmaccrandom_clicked(bool checked)
{
if(checked) //on
{
QProcess proc;
proc.startDetached("/bin/sh", QStringList()<< "/usr/share/garuda/scripts/disable-nm-mac-random.sh");
proc.waitForFinished();
}
else //off
{
QProcess proc;
proc.startDetached("/bin/sh", QStringList()<< "/usr/share/garuda/scripts/enable-nm-mac-random.sh");
proc.waitForFinished();
}
checkMacDisabled();
checkMacDisabled();
}
......@@ -43,9 +43,6 @@ public:
bool checkSysFileExists(QDir searchPath, QString fileName, Qt::CaseSensitivity cs);
bool checkAirplaneEnabled();
bool checkWolEnabled();
bool checkWpEnabled();
bool checkMacDisabled();
bool checkGpsEnabled();
bool checkBtAvailable();
bool checkBtEnabled();
......@@ -66,11 +63,8 @@ public slots:
virtual void on_generalHelpPushButton_clicked();
virtual void on_hwDiagnosePushButton_clicked();
virtual void on_linuxDrvDiagnosePushButton_clicked();
virtual void on_windowsDrvDiagnosePushButton_clicked();
virtual void on_linuxDrvList_currentRowChanged(int currentRow );
virtual void on_linuxDrvBlacklistPushButton_clicked();
virtual void on_windowsDrvAddPushButton_clicked() ;
virtual void on_windowsDrvRemovePushButton_clicked();
virtual void on_clearPingOutput_clicked();
virtual void on_clearTraceOutput_clicked();
virtual void on_tracerouteButton_clicked();
......@@ -82,20 +76,13 @@ public slots:
virtual void writeInstallOutput();
virtual void pingFinished();
virtual void tracerouteFinished();
virtual void aptUpdateFinished();
virtual void installFinished(int);
virtual void uninstallNdisFinished(int);
virtual void on_windowsDrvList_currentRowChanged(int row);
virtual void hwListToClipboard();
virtual void hwListFullToClipboard();
virtual void linuxDrvListToClipboard();
virtual void linuxDrvListFullToClipboard();
virtual void windowsDrvListToClipboard();
virtual void windowsDrvListFullToClipboard();
virtual void showContextMenuForHw(const QPoint &pos);
virtual void showContextMenuForLinuxDrv(const QPoint &pos);
virtual void showContextMenuForWindowsDrv(const QPoint &pos);
protected:
/*$PROTECTED_FUNCTIONS$*/
......@@ -127,8 +114,6 @@ protected slots:
/*$PROTECTED_SLOTS$*/
private slots:
void on_installNdiswrapper_clicked();
void on_uninstallNdiswrapper_clicked();
void on_linuxDrvLoad_clicked();
void on_linuxDrvUnload_clicked();
......@@ -138,10 +123,6 @@ private slots:
void on_bluetooth_clicked();
void on_restartwifi_clicked();
void on_restartbt_clicked();
void on_wifihotspot_clicked();
void on_toolButton_wifi_clicked(bool checked);
......@@ -152,11 +133,6 @@ private slots:
void on_toolButton_gps_clicked(bool checked);
void on_checkBox_wol_clicked(bool checked);
void on_checkBox_wifipowersave_clicked(bool checked);
void on_checkBox_nmmaccrandom_clicked(bool checked);
private:
Cmd cmd;
......
......@@ -206,8 +206,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>861</width>
<height>718</height>
<width>886</width>
<height>656</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
......@@ -337,30 +337,17 @@
<string>Bluetooth status</string>
</property>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="4" alignment="Qt::AlignHCenter">
<widget class="QToolButton" name="toolButton_bluetooth">
<item row="1" column="4" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="labelBt">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/icons/bluetooth-active.png</normaloff>:/icons/bluetooth-active.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
<string>bt</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QPushButton" name="restartbt">
<widget class="QPushButton" name="bluetooth">
<property name="text">
<string>Restart Bluetooth module</string>
<string>Start Bluetooth</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
......@@ -368,22 +355,24 @@
</property>
</widget>
</item>