Skip to content

Commit

Permalink
Bugfixes and new package management and log features
Browse files Browse the repository at this point in the history
Signed-off-by: Mustafa Özcelikörs <[email protected]>
  • Loading branch information
mozcelikors committed Mar 1, 2018
1 parent 1e7fc21 commit db65bd0
Show file tree
Hide file tree
Showing 22 changed files with 545 additions and 95 deletions.
333 changes: 258 additions & 75 deletions forms/mainwindow.ui

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions include/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class MainWindow : public QMainWindow
void yakalaUpdateProcessTable (void);
void yakalaUpdateSocketsTable (void);
void yakalaUpdatePackagesTable (void);
void yakalaUpdateAptCacheTable (void);

void loadingAnimStart (void);
void loadingAnimStop (void);
Expand Down Expand Up @@ -82,6 +83,8 @@ private slots:
void handlePackagesTableClicked (int row, int col);
void handlePackageUninstallButton(void);
void inputPackageChanged (void);
void handleAutoremovePackageButton (void);
void handlePackageAptCacheButton (void);

};

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions include/packages.h → include/systemmanager/packages.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class Packages
{
private:
QStringList names;
QStringList aptcachename;
QStringList aptcachedescription;
QString uninstallpackage;

public:
Expand All @@ -32,9 +34,14 @@ class Packages
QStringList getNames (void);
void setUninstallPackage (QString packagename);
void searchPackages (QString needle);
void removeUnusedPackages (void);

void uninstallPackage (void);
QString getUninstallPackage (void);

void searchAptcache (QString needle);
QStringList getAptcachenames (void);
QStringList getAptcachedescription (void);
};


Expand Down
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions include/systeminfo.h → include/systemmanager/systeminfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class SystemInfo

char mac_addr[MAX_BUFSIZE];

QString ifconfig_out;
QString lsusb_out;
QString syslog_out;
QString dmesg_out;

public:
SystemInfo();
void readMemoryTotal();
Expand Down Expand Up @@ -91,6 +96,12 @@ class SystemInfo

void readMACAddress(QString ip_addr);
QString getMACAddress (void);

void readSysLogs (void);
QString getSysLogOut (void);
QString getDmesgOut (void);
QString getIfconfigOut (void);
QString getLsusbOut (void);
};

#endif // SYSTEMINFO_H
8 changes: 8 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ if [ "" == "$PKG_OK" ]; then
sudo apt-get --force-yes --yes install gksu
fi

## Check for usbutils
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' 'usbutils' | grep "install ok installed")
echo "Checking for usbutils: $PKG_OK"
if [ "" == "$PKG_OK" ]; then
echo "No usbutils. Setting up usbutils."
sudo apt-get --force-yes --yes install usbutils
fi

## Check for xterm
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' 'xterm' | grep "install ok installed")
echo "Checking for xterm: $PKG_OK"
Expand Down
58 changes: 58 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,34 @@ void MainWindow::yakalaUpdateEnvironmentTable (void)
ui->tableWidget_env->repaint();
}

void MainWindow::yakalaUpdateAptCacheTable (void)
{
/* Load table widget for Aliases section */
ui->tableWidget_aptcache->setColumnCount(2);
ui->tableWidget_aptcache->setRowCount(pa.getAptcachenames().count());
QStringList TableHeader;
TableHeader<<"Package" << "Description";
ui->tableWidget_aptcache->setColumnWidth(0, 200);
ui->tableWidget_aptcache->setHorizontalHeaderLabels(TableHeader);
ui->tableWidget_aptcache->horizontalHeader()->setStretchLastSection(true);

if (pa.getAptcachedescription().count() == pa.getAptcachenames().count())
{
for (int i = 0; i < pa.getAptcachenames().count(); i++)
{
QTableWidgetItem *item = new QTableWidgetItem(pa.getAptcachenames().at(i));
item->setFlags(item->flags() ^ Qt::ItemIsEditable);
ui->tableWidget_aptcache->setItem(i, 0, item);

QTableWidgetItem *item2 = new QTableWidgetItem(pa.getAptcachedescription().at(i));
item2->setFlags(item2->flags() ^ Qt::ItemIsEditable);
ui->tableWidget_aptcache->setItem(i, 1, item2);
}
}

this->ui->tableWidget_aptcache->repaint();
}

void MainWindow::yakalaUpdateNetworkTable (void)
{
/* Load table widget for Network section */
Expand Down Expand Up @@ -582,6 +610,11 @@ void MainWindow::yakalaUiManipulations(void)
ui->tabWidget_system->tabBar()->setCursor(Qt::PointingHandCursor);
ui->tabWidget_system->tabBar()->setStyleSheet("QTabBar::tab {border-top-left-radius:5px; border-top-right-radius:5px; border-bottom-left-radius:0px; } QTabBar::tab:selected, QTabBar::tab:selected::hover { background: #93C83E; border-bottom-right-radius:0px; color:#333; }");

/* tabWidget system log and messages */
ui->tabWidget_systemlogs->tabBar()->setCursor(Qt::PointingHandCursor);
ui->tabWidget_systemlogs->tabBar()->setStyleSheet("QTabBar::tab {border-top-left-radius:5px; border-top-right-radius:5px; border-bottom-left-radius:0px; } QTabBar::tab:selected, QTabBar::tab:selected::hover { background: #ffe100; border-bottom-right-radius:0px; color:#333; }");


/* Process part UI manipulations */
this->ui->pushButton_killproc->setStyleSheet("QPushButton { color:white; background-color:red;} QPushButton::hover{color:black; background-color:white;}");

Expand All @@ -594,6 +627,17 @@ void MainWindow::yakalaUiManipulations(void)
/* Configure graphs */
this->configureGraphs ();

/* System logs */
s.readSysLogs();
this->ui->textEdit_driver->setStyleSheet("font-family:'Courier New'; font-size:14px;");
this->ui->textEdit_interfaces->setStyleSheet("font-family:'Courier New'; font-size:14px;");
this->ui->textEdit_systemlogs->setStyleSheet("font-family:'Courier New'; font-size:14px;");
this->ui->textEdit_usb->setStyleSheet("font-family:'Courier New'; font-size:14px;");
this->ui->textEdit_driver->setText(s.getDmesgOut());
this->ui->textEdit_interfaces->setText(s.getIfconfigOut());
this->ui->textEdit_systemlogs->setText(s.getSysLogOut());
this->ui->textEdit_usb->setText(s.getLsusbOut());

/*********** CONNECT and TIMERs ***************/

/* Tab bar signal-slot */
Expand Down Expand Up @@ -646,9 +690,12 @@ void MainWindow::yakalaUiManipulations(void)
connect(ui->tableWidget_packages, SIGNAL(cellClicked(int,int)), this, SLOT(handlePackagesTableClicked(int,int)));
connect(ui->pushButton_uninstallpackage, SIGNAL(released()), this, SLOT (handlePackageUninstallButton()));
connect(ui->lineEdit_searchpackage, SIGNAL(textChanged(const QString &)), this, SLOT(inputPackageChanged()));
connect(ui->pushButton_aptcache, SIGNAL(released()), this, SLOT (handlePackageAptCacheButton()));

/* File search button signal-slot */
connect(ui->pushButton_browsefolder, SIGNAL(released()), this, SLOT (handleBrowseFolderButton()));

connect(ui->pushButton_autoremove, SIGNAL(released()), this, SLOT (handleAutoremovePackageButton()));
}

MainWindow::~MainWindow()
Expand All @@ -658,6 +705,17 @@ MainWindow::~MainWindow()

/**************** SLOTS *******************/

void MainWindow::handlePackageAptCacheButton (void)
{
pa.searchAptcache(this->ui->lineEdit_searchaptcache->text());
this->yakalaUpdateAptCacheTable();
}

void MainWindow::handleAutoremovePackageButton (void)
{
pa.removeUnusedPackages();
}

void MainWindow::handleBrowseFolderButton (void)
{
QFileDialog *file_dialog = new QFileDialog;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
77 changes: 77 additions & 0 deletions src/packages.cpp → src/systemmanager/packages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,52 @@ Packages::Packages ()
this->uninstallpackage = QString("0");
}

void Packages::searchAptcache (QString needle)
{
this->aptcachename.clear();

FILE *fp;

/* Process retrieval */
fp = popen ((QString("timeout 30 apt-cache search ") +needle+ QString(" 2>/dev/null | sed 's/\ -.*//' > /tmp/yakala.aptcache && apt-cache search ")+needle+QString(" 2>/dev/null | sed 's/.*- //' > /tmp/yakala.aptcache2")).toLocal8Bit(),"w");

if (fp != NULL)
{

}
else
{

}
fclose(fp);

QFile MyFile3("/tmp/yakala.aptcache");
if (MyFile3.open(QIODevice::ReadWrite))
{
QTextStream in3 (&MyFile3);
QString line3;
while (!in3.atEnd())
{
line3 = in3.readLine();
this->aptcachename.append(line3);
}
MyFile3.close();
}

QFile MyFile4("/tmp/yakala.aptcache2");
if (MyFile4.open(QIODevice::ReadWrite))
{
QTextStream in4 (&MyFile4);
QString line4;
while (!in4.atEnd())
{
line4 = in4.readLine();
this->aptcachedescription.append(line4);
}
MyFile4.close();
}
}

void Packages::readPackageList (void)
{
this->names.clear();
Expand Down Expand Up @@ -89,6 +135,16 @@ QStringList Packages::getNames (void)
return this->names;
}

QStringList Packages::getAptcachenames (void)
{
return this->aptcachename;
}

QStringList Packages::getAptcachedescription (void)
{
return this->aptcachedescription;
}

void Packages::uninstallPackage (void)
{
FILE *fp;
Expand All @@ -110,6 +166,27 @@ void Packages::uninstallPackage (void)
this->readPackageList();
}

void Packages::removeUnusedPackages (void)
{
FILE *fp;

/* Process retrieval */
fp = popen ((QString("echo 'Y' | sudo apt-get autoremove ")+QString(" 1>/dev/null 2>/dev/null")).toLocal8Bit(), "w");

if (fp != NULL)
{

}
else
{

}
fclose(fp);

/* Package list update */
this->readPackageList();
}

void Packages::setUninstallPackage (QString packagename)
{
this->uninstallpackage = packagename;
Expand Down
File renamed without changes.
File renamed without changes.
101 changes: 101 additions & 0 deletions src/systeminfo.cpp → src/systemmanager/systeminfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <QString>
#include <QFile>
#include <QTextStream>

// To debug, uncomment below, and run 'valgrind -v ./yakala'
//#define DEBUG 1
Expand Down Expand Up @@ -488,4 +491,102 @@ int SystemInfo::getDiskPercentage (void)
return this->disk_percentage;
}

void SystemInfo::readSysLogs (void)
{
this->syslog_out.clear();
this->lsusb_out.clear();
this->dmesg_out.clear();
this->ifconfig_out.clear();

/* Syslog */
QFile MyFile3("/var/log/syslog");
if (MyFile3.open(QIODevice::ReadWrite))
{
QTextStream in3 (&MyFile3);
QString line3;
while (!in3.atEnd())
{
line3 = in3.readLine();
this->syslog_out.append(line3);
this->syslog_out.append("\n");
}
MyFile3.close();
}

/* Dmesg */
FILE *fp;
fp = popen ("timeout 5 dmesg > /tmp/yakala.dmesg ","w");
fclose(fp);

QFile MyFile4("/tmp/yakala.dmesg");
if (MyFile4.open(QIODevice::ReadWrite))
{
QTextStream in3 (&MyFile4);
QString line3;
while (!in3.atEnd())
{
line3 = in3.readLine();
this->dmesg_out.append(line3);
this->dmesg_out.append("\n");
}
MyFile4.close();
}

/* Ifconfig */
FILE *fp2;
fp2 = popen ("timeout 5 ifconfig > /tmp/yakala.ifconfig ","w");
fclose(fp2);

QFile MyFile5("/tmp/yakala.ifconfig");
if (MyFile5.open(QIODevice::ReadWrite))
{
QTextStream in3 (&MyFile5);
QString line3;
while (!in3.atEnd())
{
line3 = in3.readLine();
this->ifconfig_out.append(line3);
this->ifconfig_out.append("\n");
}
MyFile5.close();
}

/* Lsusb */
FILE *fp3;
fp3 = popen ("timeout 5 lsusb > /tmp/yakala.lsusb ","w");
fclose(fp3);

QFile MyFile6("/tmp/yakala.lsusb");
if (MyFile6.open(QIODevice::ReadWrite))
{
QTextStream in3 (&MyFile6);
QString line3;
while (!in3.atEnd())
{
line3 = in3.readLine();
this->lsusb_out.append(line3);
this->lsusb_out.append("\n");
}
MyFile6.close();
}
}

QString SystemInfo::getSysLogOut (void)
{
return this->syslog_out;
}

QString SystemInfo::getDmesgOut (void)
{
return this->dmesg_out;
}

QString SystemInfo::getIfconfigOut (void)
{
return this->ifconfig_out;
}

QString SystemInfo::getLsusbOut (void)
{
return this->lsusb_out;
}
1 change: 1 addition & 0 deletions src/thread_systeminfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void *Thread_SystemInfo (void *arg)
s.readDiskTotal();
pa.readPackageList();


while (1)
{
/* Get Periodic System Details*/
Expand Down
Loading

0 comments on commit db65bd0

Please sign in to comment.