summaryrefslogtreecommitdiff
Unidiff
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 @@
1/**********************************************************************
2** ModulesDetail
3**
4** Display module information
5**
6** Copyright (C) 2002, Michael Lauer
7** mickey@tm.informatik.uni-frankfurt.de
8** http://www.Vanille.de
9**
10** Based on ProcessDetail by Dan Williams <williamsdr@acm.org>
11**
12** This file may be distributed and/or modified under the terms of the
13** GNU General Public License version 2 as published by the Free Software
14** Foundation and appearing in the file LICENSE.GPL included in the
15** packaging of this file.
16**
17** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19**
20**********************************************************************/
21
22#include "modulesdetail.h"
23
24#include <sys/types.h>
25#include <stdio.h>
26#include <qcombobox.h>
27#include <qpushbutton.h>
28#include <qtextview.h>
29#include <qlayout.h>
30#include <qlistview.h>
31#include <qmessagebox.h>
32
33ModulesDetail::ModulesDetail( QWidget* parent, const char* name, WFlags fl )
34 : QWidget( parent, name, fl )
35{
36 modname = "";
37
38 QGridLayout *layout = new QGridLayout( this );
39 layout->setSpacing( 4 );
40 layout->setMargin( 4 );
41
42 CommandCB = new QComboBox( FALSE, this, "CommandCB" );
43 CommandCB->insertItem( "modprobe -r" );
44 CommandCB->insertItem( "rmmod" );
45 // I can't think of other useful commands yet. Anyone?
46
47 layout->addWidget( CommandCB, 1, 0 );
48
49 ModulesView = new QTextView( this, "ModulesView" );
50 layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 );
51
52 SendButton = new QPushButton( this, "SendButton" );
53 SendButton->setMinimumSize( QSize( 50, 24 ) );
54 SendButton->setMaximumSize( QSize( 50, 24 ) );
55 SendButton->setText( tr( "Send" ) );
56 connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) );
57 layout->addWidget( SendButton, 1, 1 );
58}
59
60ModulesDetail::~ModulesDetail()
61{
62}
63
64void ModulesDetail::slotSendClicked()
65{
66 QString command = QString( "/sbin/" )
67 + CommandCB->currentText()
68 + QString( " " ) + modname;
69
70 if ( QMessageBox::warning( this, caption(),
71 tr( "You really want to \n" + CommandCB->currentText() + "\nthis Module?"),
72 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape )
73 == QMessageBox::Yes )
74 {
75 FILE* stream = popen( command, "r" );
76 if ( stream )
77 pclose( stream );
78 {
79 hide();
80 }
81 }
82
83}
84
85
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 @@
1/**********************************************************************
2** ModulesDetail
3**
4** Display module information
5**
6** Copyright (C) 2002, Michael Lauer
7** mickey@tm.informatik.uni-frankfurt.de
8** http://www.Vanille.de
9**
10** Based on ProcessDetail by Dan Williams <williamsdr@acm.org>
11**
12** This file may be distributed and/or modified under the terms of the
13** GNU General Public License version 2 as published by the Free Software
14** Foundation and appearing in the file LICENSE.GPL included in the
15** packaging of this file.
16**
17** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19**
20**********************************************************************/
21
22#ifndef MODULESDETAIL_H
23#define MODULESDETAIL_H
24
25#include <qwidget.h>
26#include <qcombo.h>
27#include <qtextview.h>
28#include <qpushbutton.h>
29#include <qlistview.h>
30
31class ModulesDetail : public QWidget
32{
33 Q_OBJECT
34
35public:
36 ModulesDetail( QWidget* parent, const char* name, WFlags fl );
37 ~ModulesDetail();
38
39 QComboBox* CommandCB;
40 QTextView* ModulesView;
41 QPushButton* SendButton;
42
43 QString modname;
44
45private slots:
46 void slotSendClicked();
47};
48
49#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 @@
1/**********************************************************************
2** ModulesInfo
3**
4** Display Modules information
5**
6** Copyright (C) 2002, Michael Lauer
7** mickey@tm.informatik.uni-frankfurt.de
8** http://www.Vanille.de
9**
10** Based on ProcessInfo by Dan Williams <williamsdr@acm.org>
11**
12** This file may be distributed and/or modified under the terms of the
13** GNU General Public License version 2 as published by the Free Software
14** Foundation and appearing in the file LICENSE.GPL included in the
15** packaging of this file.
16**
17** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19**
20**********************************************************************/
21
22#include <qpe/qpeapplication.h>
23
24#include <qheader.h>
25#include <qlistview.h>
26#include <qlayout.h>
27#include <qtimer.h>
28#include <qfile.h>
29
30#include "modulesinfo.h"
31
32ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl )
33 : QWidget( parent, name, fl )
34{
35 QVBoxLayout *layout = new QVBoxLayout( this, 5 );
36
37 ModulesView = new QListView( this, "ModulesView" );
38 int colnum = ModulesView->addColumn( tr( "Module" ) );
39 colnum = ModulesView->addColumn( tr( "Size" ) );
40 ModulesView->setColumnAlignment( colnum, Qt::AlignRight );
41 colnum = ModulesView->addColumn( tr( "Use#" ) );
42 ModulesView->setColumnAlignment( colnum, Qt::AlignRight );
43 colnum = ModulesView->addColumn( tr( "Used By" ) );
44 ModulesView->setAllColumnsShowFocus( TRUE );
45 QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold );
46 connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
47 this, SLOT( viewModules( QListViewItem * ) ) );
48
49 layout->addWidget( ModulesView );
50 QTimer *t = new QTimer( this );
51 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) );
52 t->start( 5000 );
53
54 updateData();
55
56 ModulesDtl = new ModulesDetail( 0, 0, 0 );
57 ModulesDtl->ModulesView->setTextFormat( PlainText );
58}
59
60ModulesInfo::~ModulesInfo()
61{
62}
63
64void ModulesInfo::updateData()
65{
66 char modname[64];
67 char usage[200];
68 int modsize, usecount;
69
70 ModulesView->clear();
71
72 FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r");
73
74 if ( procfile )
75 {
76 while ( true ) {
77 int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage );
78
79 if ( success == EOF )
80 break;
81
82 QString qmodname = QString( modname );
83 QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' );
84 QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' );
85 QString qusage = QString( usage );
86
87 ( void ) new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage );
88 }
89
90 fclose( procfile );
91 }
92}
93
94void ModulesInfo::viewModules( QListViewItem *modules )
95{
96 QString modname = modules->text( 0 );
97 ModulesDtl->setCaption( QString( "Module: " ) + modname );
98 ModulesDtl->modname = modname;
99 QString command = QString( "/sbin/modinfo " ) + modules->text( 0 );
100
101 FILE* modinfo = popen( command, "r" );
102
103 if ( modinfo )
104 {
105 char line[200];
106 ModulesDtl->ModulesView->setText( " Details:\n------------\n" );
107
108 while( true )
109 {
110 int success = fscanf( modinfo, "%[^\n]\n", line );
111 if ( success == EOF )
112 break;
113 ModulesDtl->ModulesView->append( line );
114 }
115
116 pclose( modinfo );
117 }
118
119 ModulesDtl->showMaximized();
120}
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 @@
1/**********************************************************************
2** ModulesInfo
3**
4** Display modules information
5**
6** Copyright (C) 2002, Michael Lauer
7** mickey@tm.informatik.uni-frankfurt.de
8** http://www.Vanille.de
9**
10** Based on ProcessInfo by Dan Williams <williamsdr@acm.org>
11**
12** This file may be distributed and/or modified under the terms of the
13** GNU General Public License version 2 as published by the Free Software
14** Foundation and appearing in the file LICENSE.GPL included in the
15** packaging of this file.
16**
17** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19**
20**********************************************************************/
21
22#ifndef MODULESINFO_H
23#define MODULESINFO_H
24
25#include <qwidget.h>
26#include <qlistview.h>
27
28#include "modulesdetail.h"
29
30class ModulesInfo : public QWidget
31{
32 Q_OBJECT
33public:
34 ModulesInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
35 ~ModulesInfo();
36
37private slots:
38 void updateData();
39 void viewModules( QListViewItem * );
40
41private:
42 QListView* ModulesView;
43 ModulesDetail *ModulesDtl;
44};
45
46#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
@@ -23,6 +23,7 @@
23#include "storage.h" 23#include "storage.h"
24//#include "graphics.h" 24//#include "graphics.h"
25#include "processinfo.h" 25#include "processinfo.h"
26#include "modulesinfo.h"
26#include "versioninfo.h" 27#include "versioninfo.h"
27#include "sysinfo.h" 28#include "sysinfo.h"
28 29
@@ -47,6 +48,7 @@ SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags f )
47 tab->addTab( new LoadInfo( tab ), tr("CPU") ); 48 tab->addTab( new LoadInfo( tab ), tr("CPU") );
48// tab->addTab( new Graphics( tab ), tr("Graphics") ); 49// tab->addTab( new Graphics( tab ), tr("Graphics") );
49 tab->addTab( new ProcessInfo( tab ), tr("Process") ); 50 tab->addTab( new ProcessInfo( tab ), tr("Process") );
51 tab->addTab( new ModulesInfo( tab ), tr("Modules") );
50 tab->addTab( new VersionInfo( tab ), tr("Version") ); 52 tab->addTab( new VersionInfo( tab ), tr("Version") );
51 53
52 resize( 220, 180 ); 54 resize( 220, 180 );
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
@@ -7,6 +7,8 @@ HEADERS = memory.h \
7 storage.h \ 7 storage.h \
8 processinfo.h \ 8 processinfo.h \
9 processdetail.h \ 9 processdetail.h \
10 modulesinfo.h \
11 modulesdetail.h \
10 versioninfo.h \ 12 versioninfo.h \
11 sysinfo.h 13 sysinfo.h
12SOURCES = main.cpp \ 14SOURCES = main.cpp \
@@ -15,7 +17,9 @@ SOURCES = main.cpp \
15 load.cpp \ 17 load.cpp \
16 storage.cpp \ 18 storage.cpp \
17 processinfo.cpp \ 19 processinfo.cpp \
20 modulesinfo.cpp \
18 processdetail.cpp \ 21 processdetail.cpp \
22 modulesdetail.cpp \
19 versioninfo.cpp \ 23 versioninfo.cpp \
20 sysinfo.cpp 24 sysinfo.cpp
21INTERFACES = 25INTERFACES =