summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/modulesdetail.cpp85
-rw-r--r--noncore/settings/sysinfo/modulesdetail.h49
-rw-r--r--noncore/settings/sysinfo/modulesinfo.cpp120
-rw-r--r--noncore/settings/sysinfo/modulesinfo.h46
-rw-r--r--noncore/settings/sysinfo/sysinfo.cpp2
-rw-r--r--noncore/settings/sysinfo/sysinfo.pro4
6 files changed, 306 insertions, 0 deletions
diff --git a/noncore/settings/sysinfo/modulesdetail.cpp b/noncore/settings/sysinfo/modulesdetail.cpp
new file mode 100644
index 0000000..48d47f6
--- a/dev/null
+++ b/noncore/settings/sysinfo/modulesdetail.cpp
@@ -0,0 +1,85 @@
+/**********************************************************************
+** ModulesDetail
+**
+** Display module information
+**
+** Copyright (C) 2002, Michael Lauer
+** mickey@tm.informatik.uni-frankfurt.de
+** http://www.Vanille.de
+**
+** Based on ProcessDetail by Dan Williams <williamsdr@acm.org>
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+**********************************************************************/
+
+#include "modulesdetail.h"
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <qcombobox.h>
+#include <qpushbutton.h>
+#include <qtextview.h>
+#include <qlayout.h>
+#include <qlistview.h>
+#include <qmessagebox.h>
+
+ModulesDetail::ModulesDetail( QWidget* parent, const char* name, WFlags fl )
+ : QWidget( parent, name, fl )
+{
+ modname = "";
+
+ QGridLayout *layout = new QGridLayout( this );
+ layout->setSpacing( 4 );
+ layout->setMargin( 4 );
+
+ CommandCB = new QComboBox( FALSE, this, "CommandCB" );
+ CommandCB->insertItem( "modprobe -r" );
+ CommandCB->insertItem( "rmmod" );
+ // I can't think of other useful commands yet. Anyone?
+
+ layout->addWidget( CommandCB, 1, 0 );
+
+ ModulesView = new QTextView( this, "ModulesView" );
+ layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 );
+
+ SendButton = new QPushButton( this, "SendButton" );
+ SendButton->setMinimumSize( QSize( 50, 24 ) );
+ SendButton->setMaximumSize( QSize( 50, 24 ) );
+ SendButton->setText( tr( "Send" ) );
+ connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) );
+ layout->addWidget( SendButton, 1, 1 );
+}
+
+ModulesDetail::~ModulesDetail()
+{
+}
+
+void ModulesDetail::slotSendClicked()
+{
+ QString command = QString( "/sbin/" )
+ + CommandCB->currentText()
+ + QString( " " ) + modname;
+
+ if ( QMessageBox::warning( this, caption(),
+ tr( "You really want to \n" + CommandCB->currentText() + "\nthis Module?"),
+ QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape )
+ == QMessageBox::Yes )
+ {
+ FILE* stream = popen( command, "r" );
+ if ( stream )
+ pclose( stream );
+ {
+ hide();
+ }
+ }
+
+}
+
+
diff --git a/noncore/settings/sysinfo/modulesdetail.h b/noncore/settings/sysinfo/modulesdetail.h
new file mode 100644
index 0000000..5515c4b
--- a/dev/null
+++ b/noncore/settings/sysinfo/modulesdetail.h
@@ -0,0 +1,49 @@
+/**********************************************************************
+** ModulesDetail
+**
+** Display module information
+**
+** Copyright (C) 2002, Michael Lauer
+** mickey@tm.informatik.uni-frankfurt.de
+** http://www.Vanille.de
+**
+** Based on ProcessDetail by Dan Williams <williamsdr@acm.org>
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+**********************************************************************/
+
+#ifndef MODULESDETAIL_H
+#define MODULESDETAIL_H
+
+#include <qwidget.h>
+#include <qcombo.h>
+#include <qtextview.h>
+#include <qpushbutton.h>
+#include <qlistview.h>
+
+class ModulesDetail : public QWidget
+{
+ Q_OBJECT
+
+public:
+ ModulesDetail( QWidget* parent, const char* name, WFlags fl );
+ ~ModulesDetail();
+
+ QComboBox* CommandCB;
+ QTextView* ModulesView;
+ QPushButton* SendButton;
+
+ QString modname;
+
+private slots:
+ void slotSendClicked();
+};
+
+#endif // MODULESDETAIL_H
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp
new file mode 100644
index 0000000..7a32c20
--- a/dev/null
+++ b/noncore/settings/sysinfo/modulesinfo.cpp
@@ -0,0 +1,120 @@
+/**********************************************************************
+** ModulesInfo
+**
+** Display Modules information
+**
+** Copyright (C) 2002, Michael Lauer
+** mickey@tm.informatik.uni-frankfurt.de
+** http://www.Vanille.de
+**
+** Based on ProcessInfo by Dan Williams <williamsdr@acm.org>
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+**********************************************************************/
+
+#include <qpe/qpeapplication.h>
+
+#include <qheader.h>
+#include <qlistview.h>
+#include <qlayout.h>
+#include <qtimer.h>
+#include <qfile.h>
+
+#include "modulesinfo.h"
+
+ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl )
+ : QWidget( parent, name, fl )
+{
+ QVBoxLayout *layout = new QVBoxLayout( this, 5 );
+
+ ModulesView = new QListView( this, "ModulesView" );
+ int colnum = ModulesView->addColumn( tr( "Module" ) );
+ colnum = ModulesView->addColumn( tr( "Size" ) );
+ ModulesView->setColumnAlignment( colnum, Qt::AlignRight );
+ colnum = ModulesView->addColumn( tr( "Use#" ) );
+ ModulesView->setColumnAlignment( colnum, Qt::AlignRight );
+ colnum = ModulesView->addColumn( tr( "Used By" ) );
+ ModulesView->setAllColumnsShowFocus( TRUE );
+ QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold );
+ connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
+ this, SLOT( viewModules( QListViewItem * ) ) );
+
+ layout->addWidget( ModulesView );
+ QTimer *t = new QTimer( this );
+ connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) );
+ t->start( 5000 );
+
+ updateData();
+
+ ModulesDtl = new ModulesDetail( 0, 0, 0 );
+ ModulesDtl->ModulesView->setTextFormat( PlainText );
+}
+
+ModulesInfo::~ModulesInfo()
+{
+}
+
+void ModulesInfo::updateData()
+{
+ char modname[64];
+ char usage[200];
+ int modsize, usecount;
+
+ ModulesView->clear();
+
+ FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r");
+
+ if ( procfile )
+ {
+ while ( true ) {
+ int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage );
+
+ if ( success == EOF )
+ break;
+
+ QString qmodname = QString( modname );
+ QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' );
+ QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' );
+ QString qusage = QString( usage );
+
+ ( void ) new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage );
+ }
+
+ fclose( procfile );
+ }
+}
+
+void ModulesInfo::viewModules( QListViewItem *modules )
+{
+ QString modname = modules->text( 0 );
+ ModulesDtl->setCaption( QString( "Module: " ) + modname );
+ ModulesDtl->modname = modname;
+ QString command = QString( "/sbin/modinfo " ) + modules->text( 0 );
+
+ FILE* modinfo = popen( command, "r" );
+
+ if ( modinfo )
+ {
+ char line[200];
+ ModulesDtl->ModulesView->setText( " Details:\n------------\n" );
+
+ while( true )
+ {
+ int success = fscanf( modinfo, "%[^\n]\n", line );
+ if ( success == EOF )
+ break;
+ ModulesDtl->ModulesView->append( line );
+ }
+
+ pclose( modinfo );
+ }
+
+ ModulesDtl->showMaximized();
+}
diff --git a/noncore/settings/sysinfo/modulesinfo.h b/noncore/settings/sysinfo/modulesinfo.h
new file mode 100644
index 0000000..c702f24
--- a/dev/null
+++ b/noncore/settings/sysinfo/modulesinfo.h
@@ -0,0 +1,46 @@
+/**********************************************************************
+** ModulesInfo
+**
+** Display modules information
+**
+** Copyright (C) 2002, Michael Lauer
+** mickey@tm.informatik.uni-frankfurt.de
+** http://www.Vanille.de
+**
+** Based on ProcessInfo by Dan Williams <williamsdr@acm.org>
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+**********************************************************************/
+
+#ifndef MODULESINFO_H
+#define MODULESINFO_H
+
+#include <qwidget.h>
+#include <qlistview.h>
+
+#include "modulesdetail.h"
+
+class ModulesInfo : public QWidget
+{
+ Q_OBJECT
+public:
+ ModulesInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
+ ~ModulesInfo();
+
+private slots:
+ void updateData();
+ void viewModules( QListViewItem * );
+
+private:
+ QListView* ModulesView;
+ ModulesDetail *ModulesDtl;
+};
+
+#endif
diff --git a/noncore/settings/sysinfo/sysinfo.cpp b/noncore/settings/sysinfo/sysinfo.cpp
index 5697f36..13f810a 100644
--- a/noncore/settings/sysinfo/sysinfo.cpp
+++ b/noncore/settings/sysinfo/sysinfo.cpp
@@ -24,4 +24,5 @@
//#include "graphics.h"
#include "processinfo.h"
+#include "modulesinfo.h"
#include "versioninfo.h"
#include "sysinfo.h"
@@ -48,4 +49,5 @@ SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags f )
// tab->addTab( new Graphics( tab ), tr("Graphics") );
tab->addTab( new ProcessInfo( tab ), tr("Process") );
+ tab->addTab( new ModulesInfo( tab ), tr("Modules") );
tab->addTab( new VersionInfo( tab ), tr("Version") );
diff --git a/noncore/settings/sysinfo/sysinfo.pro b/noncore/settings/sysinfo/sysinfo.pro
index c317677..c0cef8f 100644
--- a/noncore/settings/sysinfo/sysinfo.pro
+++ b/noncore/settings/sysinfo/sysinfo.pro
@@ -8,4 +8,6 @@ HEADERS = memory.h \
processinfo.h \
processdetail.h \
+ modulesinfo.h \
+ modulesdetail.h \
versioninfo.h \
sysinfo.h
@@ -16,5 +18,7 @@ SOURCES = main.cpp \
storage.cpp \
processinfo.cpp \
+ modulesinfo.cpp \
processdetail.cpp \
+ modulesdetail.cpp \
versioninfo.cpp \
sysinfo.cpp