summaryrefslogtreecommitdiff
path: root/noncore/settings/sysinfo/modulesinfo.cpp
Unidiff
Diffstat (limited to 'noncore/settings/sysinfo/modulesinfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/modulesinfo.cpp53
1 files changed, 47 insertions, 6 deletions
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp
index c558fad..8b58fe9 100644
--- a/noncore/settings/sysinfo/modulesinfo.cpp
+++ b/noncore/settings/sysinfo/modulesinfo.cpp
@@ -30,12 +30,13 @@
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qwhatsthis.h> 33#include <qwhatsthis.h>
34 34
35#include "modulesinfo.h" 35#include "modulesinfo.h"
36#include "detail.h"
36 37
37ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) 38ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl )
38 : QWidget( parent, name, fl ) 39 : QWidget( parent, name, fl )
39{ 40{
40 QGridLayout *layout = new QGridLayout( this ); 41 QGridLayout *layout = new QGridLayout( this );
41 layout->setSpacing( 4 ); 42 layout->setSpacing( 4 );
@@ -48,12 +49,20 @@ ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl )
48 colnum = ModulesView->addColumn( tr( "Use#" ) ); 49 colnum = ModulesView->addColumn( tr( "Use#" ) );
49 ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); 50 ModulesView->setColumnAlignment( colnum, Qt::AlignRight );
50 colnum = ModulesView->addColumn( tr( "Used By" ) ); 51 colnum = ModulesView->addColumn( tr( "Used By" ) );
51 ModulesView->setAllColumnsShowFocus( TRUE ); 52 ModulesView->setAllColumnsShowFocus( TRUE );
52 layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); 53 layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 );
53 QWhatsThis::add( ModulesView, tr( "This is a list of all the kernel modules currently loaded on this handheld device.\n\nClick and hold on a module to see additional information about the module, or to unload it." ) ); 54 QWhatsThis::add( ModulesView, tr( "This is a list of all the kernel modules currently loaded on this handheld device.\n\nClick and hold on a module to see additional information about the module, or to unload it." ) );
55
56 // Test if we have /sbin/modinfo, and if so, allow module detail window
57 if ( QFile::exists( "/sbin/modinfo" ) )
58 {
59 QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold );
60 connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
61 this, SLOT( viewModules( QListViewItem * ) ) );
62 }
54 63
55 CommandCB = new QComboBox( FALSE, this ); 64 CommandCB = new QComboBox( FALSE, this );
56 CommandCB->insertItem( "modprobe -r" ); 65 CommandCB->insertItem( "modprobe -r" );
57 CommandCB->insertItem( "rmmod" ); 66 CommandCB->insertItem( "rmmod" );
58 // I can't think of other useful commands yet. Anyone? 67 // I can't think of other useful commands yet. Anyone?
59 layout->addWidget( CommandCB, 1, 0 ); 68 layout->addWidget( CommandCB, 1, 0 );
@@ -67,14 +76,17 @@ ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl )
67 layout->addWidget( btn, 1, 1 ); 76 layout->addWidget( btn, 1, 1 );
68 QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); 77 QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) );
69 78
70 QTimer *t = new QTimer( this ); 79 QTimer *t = new QTimer( this );
71 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); 80 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) );
72 t->start( 5000 ); 81 t->start( 5000 );
73 82
74 updateData(); 83 updateData();
84
85 ModulesDtl = new Detail();
86 QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) );
75} 87}
76 88
77ModulesInfo::~ModulesInfo() 89ModulesInfo::~ModulesInfo()
78{ 90{
79} 91}
80 92
@@ -111,23 +123,52 @@ void ModulesInfo::updateData()
111void ModulesInfo::slotSendClicked() 123void ModulesInfo::slotSendClicked()
112{ 124{
113 QString capstr = tr( "You really want to execute\n" ); 125 QString capstr = tr( "You really want to execute\n" );
114 capstr.append( CommandCB->currentText() ); 126 capstr.append( CommandCB->currentText() );
115 capstr.append( "\nfor this module?" ); 127 capstr.append( "\nfor this module?" );
116 128
117 if ( QMessageBox::warning( this, caption(), capstr, 129 QString modname = ModulesView->currentItem()->text( 0 );
130
131 if ( QMessageBox::warning( this, modname, capstr,
118 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) 132 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes )
119 { 133 {
120 QString command = "/sbin/"; 134 QString command = "/sbin/";
121 command.append( CommandCB->currentText() ); 135 command.append( CommandCB->currentText() );
122 command.append( " " ); 136 command.append( " " );
123 command.append( ModulesView->currentItem()->text( 0 ) ); 137 command.append( modname );
124 138
125 FILE* stream = popen( command, "r" ); 139 FILE* stream = popen( command, "r" );
126 if ( stream ) 140 if ( stream )
127 pclose( stream ); 141 pclose( stream );
128 //{
129 // hide();
130 //}
131 } 142 }
132 143
133} 144}
145
146void ModulesInfo::viewModules( QListViewItem *modules )
147{
148 QString modname = modules->text( 0 );
149 QString capstr = "Module: ";
150 capstr.append( modname );
151 ModulesDtl->setCaption( capstr );
152 QString command = "/sbin/modinfo -nad ";
153 command.append( modname );
154 FILE* modinfo = popen( command, "r" );
155
156 if ( modinfo )
157 {
158 char line[200];
159 ModulesDtl->detailView->setText( " Details:\n------------\n" );
160
161 while( true )
162 {
163 int success = fscanf( modinfo, "%[^\n]\n", line );
164 if ( success == EOF )
165 break;
166 ModulesDtl->detailView->append( line );
167 }
168
169 pclose( modinfo );
170 }
171
172 ModulesDtl->showMaximized();
173}
174