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.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp
index dfe48e1..71cefcb 100644
--- a/noncore/settings/sysinfo/modulesinfo.cpp
+++ b/noncore/settings/sysinfo/modulesinfo.cpp
@@ -15,72 +15,73 @@
15** packaging of this file. 15** packaging of this file.
16** 16**
17** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 18** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19** 19**
20**********************************************************************/ 20**********************************************************************/
21 21
22#include "modulesinfo.h" 22#include "modulesinfo.h"
23#include "detail.h" 23#include "detail.h"
24 24
25/* OPIE */ 25/* OPIE */
26#include <opie2/olistview.h> 26#include <opie2/olistview.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28 28
29/* QT */ 29/* QT */
30#include <qcombobox.h> 30#include <qcombobox.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qlayout.h> 32#include <qlayout.h>
33#include <qmessagebox.h> 33#include <qmessagebox.h>
34#include <qpushbutton.h> 34#include <qpushbutton.h>
35#include <qtextview.h> 35#include <qtextview.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qwhatsthis.h> 37#include <qwhatsthis.h>
38 38
39using namespace Opie::Ui;
39ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) 40ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl )
40 : QWidget( parent, name, fl ) 41 : QWidget( parent, name, fl )
41{ 42{
42 QGridLayout *layout = new QGridLayout( this ); 43 QGridLayout *layout = new QGridLayout( this );
43 layout->setSpacing( 4 ); 44 layout->setSpacing( 4 );
44 layout->setMargin( 4 ); 45 layout->setMargin( 4 );
45 46
46 ModulesView = new OListView( this ); 47 ModulesView = new OListView( this );
47 int colnum = ModulesView->addColumn( tr( "Module" ) ); 48 int colnum = ModulesView->addColumn( tr( "Module" ) );
48 colnum = ModulesView->addColumn( tr( "Size" ) ); 49 colnum = ModulesView->addColumn( tr( "Size" ) );
49 ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); 50 ModulesView->setColumnAlignment( colnum, Qt::AlignRight );
50 colnum = ModulesView->addColumn( tr( "Use#" ) ); 51 colnum = ModulesView->addColumn( tr( "Use#" ) );
51 ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); 52 ModulesView->setColumnAlignment( colnum, Qt::AlignRight );
52 colnum = ModulesView->addColumn( tr( "Used by" ) ); 53 colnum = ModulesView->addColumn( tr( "Used by" ) );
53 ModulesView->setAllColumnsShowFocus( TRUE ); 54 ModulesView->setAllColumnsShowFocus( TRUE );
54 layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); 55 layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 );
55 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." ) ); 56 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." ) );
56 57
57 // Test if we have /sbin/modinfo, and if so, allow module detail window 58 // Test if we have /sbin/modinfo, and if so, allow module detail window
58 if ( QFile::exists( "/sbin/modinfo" ) ) 59 if ( QFile::exists( "/sbin/modinfo" ) )
59 { 60 {
60 QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); 61 QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold );
61 connect( ModulesView, SIGNAL( rightButtonPressed(OListViewItem*,const QPoint&,int) ), 62 connect( ModulesView, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ),
62 this, SLOT( viewModules(OListViewItem*) ) ); 63 this, SLOT( viewModules(QListViewItem*) ) );
63 } 64 }
64 65
65 CommandCB = new QComboBox( FALSE, this ); 66 CommandCB = new QComboBox( FALSE, this );
66 CommandCB->insertItem( "modprobe -r" ); 67 CommandCB->insertItem( "modprobe -r" );
67 CommandCB->insertItem( "rmmod" ); 68 CommandCB->insertItem( "rmmod" );
68 // I can't think of other useful commands yet. Anyone? 69 // I can't think of other useful commands yet. Anyone?
69 layout->addWidget( CommandCB, 1, 0 ); 70 layout->addWidget( CommandCB, 1, 0 );
70 QWhatsThis::add( CommandCB, tr( "Select a command here and then click the Send button to the right to send the command to module selected above." ) ); 71 QWhatsThis::add( CommandCB, tr( "Select a command here and then click the Send button to the right to send the command to module selected above." ) );
71 72
72 QPushButton *btn = new QPushButton( this ); 73 QPushButton *btn = new QPushButton( this );
73 btn->setMinimumSize( QSize( 50, 24 ) ); 74 btn->setMinimumSize( QSize( 50, 24 ) );
74 btn->setMaximumSize( QSize( 50, 24 ) ); 75 btn->setMaximumSize( QSize( 50, 24 ) );
75 btn->setText( tr( "Send" ) ); 76 btn->setText( tr( "Send" ) );
76 connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); 77 connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) );
77 layout->addWidget( btn, 1, 1 ); 78 layout->addWidget( btn, 1, 1 );
78 QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); 79 QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) );
79 80
80 QTimer *t = new QTimer( this ); 81 QTimer *t = new QTimer( this );
81 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); 82 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) );
82 t->start( 5000 ); 83 t->start( 5000 );
83 84
84 updateData(); 85 updateData();
85 86
86 ModulesDtl = new Detail(); 87 ModulesDtl = new Detail();
@@ -142,48 +143,53 @@ void ModulesInfo::slotSendClicked()
142 if ( !ModulesView->currentItem() ) 143 if ( !ModulesView->currentItem() )
143 { 144 {
144 return; 145 return;
145 } 146 }
146 147
147 QString capstr = tr( "You really want to execute\n%1 for this module?" ).arg( CommandCB->currentText() ); 148 QString capstr = tr( "You really want to execute\n%1 for this module?" ).arg( CommandCB->currentText() );
148 149
149 QString modname = ModulesView->currentItem()->text( 0 ); 150 QString modname = ModulesView->currentItem()->text( 0 );
150 151
151 if ( QMessageBox::warning( this, modname, capstr, 152 if ( QMessageBox::warning( this, modname, capstr,
152 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) 153 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes )
153 { 154 {
154 QString command = "/sbin/"; 155 QString command = "/sbin/";
155 command.append( CommandCB->currentText() ); 156 command.append( CommandCB->currentText() );
156 command.append( " " ); 157 command.append( " " );
157 command.append( modname ); 158 command.append( modname );
158 159
159 FILE* stream = popen( command, "r" ); 160 FILE* stream = popen( command, "r" );
160 if ( stream ) 161 if ( stream )
161 pclose( stream ); 162 pclose( stream );
162 } 163 }
163 164
164} 165}
165 166
167void ModulesInfo::viewModules( QListViewItem *module ) {
168 if ( !module )
169 return;
170 viewModules( static_cast<OListViewItem*>( module ) );
171}
166void ModulesInfo::viewModules( OListViewItem *modules ) 172void ModulesInfo::viewModules( OListViewItem *modules )
167{ 173{
168 QString modname = modules->text( 0 ); 174 QString modname = modules->text( 0 );
169 QString capstr = "Module: "; 175 QString capstr = "Module: ";
170 capstr.append( modname ); 176 capstr.append( modname );
171 ModulesDtl->setCaption( capstr ); 177 ModulesDtl->setCaption( capstr );
172 QString command = "/sbin/modinfo "; 178 QString command = "/sbin/modinfo ";
173 command.append( modname ); 179 command.append( modname );
174 FILE* modinfo = popen( command, "r" ); 180 FILE* modinfo = popen( command, "r" );
175 181
176 if ( modinfo ) 182 if ( modinfo )
177 { 183 {
178 char line[200]; 184 char line[200];
179 ModulesDtl->detailView->setText( " Details:\n------------\n" ); 185 ModulesDtl->detailView->setText( " Details:\n------------\n" );
180 186
181 while( true ) 187 while( true )
182 { 188 {
183 int success = fscanf( modinfo, "%[^\n]\n", line ); 189 int success = fscanf( modinfo, "%[^\n]\n", line );
184 if ( success == EOF ) 190 if ( success == EOF )
185 break; 191 break;
186 ModulesDtl->detailView->append( line ); 192 ModulesDtl->detailView->append( line );
187 } 193 }
188 194
189 pclose( modinfo ); 195 pclose( modinfo );