summaryrefslogtreecommitdiff
path: root/noncore/settings/sysinfo/modulesinfo.cpp
authorllornkcor <llornkcor>2002-07-02 23:32:30 (UTC)
committer llornkcor <llornkcor>2002-07-02 23:32:30 (UTC)
commit9579fde0f62704e77fc8a11575b85298f229de85 (patch) (side-by-side diff)
treef45d7f82a0dacae43693864ba824960bb70aa92d /noncore/settings/sysinfo/modulesinfo.cpp
parentd83f58a1a4a314a3ef8b25dd78432488922a9e31 (diff)
downloadopie-9579fde0f62704e77fc8a11575b85298f229de85.zip
opie-9579fde0f62704e77fc8a11575b85298f229de85.tar.gz
opie-9579fde0f62704e77fc8a11575b85298f229de85.tar.bz2
patch submitted by Dam WIlliams, who got it from Michael Lauer- adds a kernel modules tab
Diffstat (limited to 'noncore/settings/sysinfo/modulesinfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/modulesinfo.cpp120
1 files changed, 120 insertions, 0 deletions
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();
+}