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.cpp88
1 files changed, 45 insertions, 43 deletions
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp
index 566b179..9cb8ad2 100644
--- a/noncore/settings/sysinfo/modulesinfo.cpp
+++ b/noncore/settings/sysinfo/modulesinfo.cpp
@@ -19,19 +19,21 @@
19** 19**
20**********************************************************************/ 20**********************************************************************/
21 21
22#include "modulesinfo.h"
23#include "detail.h"
24
25/* OPIE */
22#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
23 27
28/* QT */
24#include <qfile.h> 29#include <qfile.h>
25#include <qlayout.h> 30#include <qlayout.h>
26#include <qmessagebox.h> 31#include <qmessagebox.h>
27#include <qtimer.h> 32#include <qtimer.h>
28#include <qwhatsthis.h> 33#include <qwhatsthis.h>
29 34
30#include "modulesinfo.h"
31#include "detail.h"
32
33ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) 35ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl )
34 : QWidget( parent, name, fl ) 36 : QWidget( parent, name, fl )
35{ 37{
36 QGridLayout *layout = new QGridLayout( this ); 38 QGridLayout *layout = new QGridLayout( this );
37 layout->setSpacing( 4 ); 39 layout->setSpacing( 4 );
@@ -47,14 +49,14 @@ ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl )
47 ModulesView->setAllColumnsShowFocus( TRUE ); 49 ModulesView->setAllColumnsShowFocus( TRUE );
48 layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); 50 layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 );
49 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." ) ); 51 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." ) );
50 52
51 // Test if we have /sbin/modinfo, and if so, allow module detail window 53 // Test if we have /sbin/modinfo, and if so, allow module detail window
52 if ( QFile::exists( "/sbin/modinfo" ) ) 54 if ( QFile::exists( "/sbin/modinfo" ) )
53 { 55 {
54 QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); 56 QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold );
55 connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), 57 connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
56 this, SLOT( viewModules( QListViewItem * ) ) ); 58 this, SLOT( viewModules( QListViewItem * ) ) );
57 } 59 }
58 60
59 CommandCB = new QComboBox( FALSE, this ); 61 CommandCB = new QComboBox( FALSE, this );
60 CommandCB->insertItem( "modprobe -r" ); 62 CommandCB->insertItem( "modprobe -r" );
@@ -74,16 +76,15 @@ ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl )
74 QTimer *t = new QTimer( this ); 76 QTimer *t = new QTimer( this );
75 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); 77 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) );
76 t->start( 5000 ); 78 t->start( 5000 );
77 79
78 updateData(); 80 updateData();
79 81
80 ModulesDtl = new Detail(); 82 ModulesDtl = new Detail();
81 QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); 83 QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) );
82} 84}
83 85
84ModulesInfo::~ModulesInfo() 86ModulesInfo::~ModulesInfo()
85{ 87{}
86}
87 88
88void ModulesInfo::updateData() 89void ModulesInfo::updateData()
89{ 90{
@@ -97,7 +98,7 @@ void ModulesInfo::updateData()
97 { 98 {
98 selectedmod = curritem->text( 0 ); 99 selectedmod = curritem->text( 0 );
99 } 100 }
100 101
101 ModulesView->clear(); 102 ModulesView->clear();
102 103
103 FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); 104 FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r");
@@ -106,7 +107,8 @@ void ModulesInfo::updateData()
106 { 107 {
107 QListViewItem *newitem; 108 QListViewItem *newitem;
108 QListViewItem *selecteditem = 0x0; 109 QListViewItem *selecteditem = 0x0;
109 while ( true ) { 110 while ( true )
111 {
110 modname[0] = '\0'; 112 modname[0] = '\0';
111 usage[0] = '\0'; 113 usage[0] = '\0';
112 int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); 114 int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage );
@@ -133,22 +135,22 @@ void ModulesInfo::updateData()
133 135
134void ModulesInfo::slotSendClicked() 136void ModulesInfo::slotSendClicked()
135{ 137{
136 if ( !ModulesView->currentItem() ) 138 if ( !ModulesView->currentItem() )
137 { 139 {
138 return; 140 return;
139 } 141 }
140 142
141 QString capstr = tr( "You really want to execute %1 for this module?" ).arg( CommandCB->currentText() ); 143 QString capstr = tr( "You really want to execute %1 for this module?" ).arg( CommandCB->currentText() );
142 144
143 QString modname = ModulesView->currentItem()->text( 0 ); 145 QString modname = ModulesView->currentItem()->text( 0 );
144 146
145 if ( QMessageBox::warning( this, modname, capstr, 147 if ( QMessageBox::warning( this, modname, capstr,
146 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) 148 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes )
147 { 149 {
148 QString command = "/sbin/"; 150 QString command = "/sbin/";
149 command.append( CommandCB->currentText() ); 151 command.append( CommandCB->currentText() );
150 command.append( " " ); 152 command.append( " " );
151 command.append( modname ); 153 command.append( modname );
152 154
153 FILE* stream = popen( command, "r" ); 155 FILE* stream = popen( command, "r" );
154 if ( stream ) 156 if ( stream )
@@ -159,30 +161,30 @@ void ModulesInfo::slotSendClicked()
159 161
160void ModulesInfo::viewModules( QListViewItem *modules ) 162void ModulesInfo::viewModules( QListViewItem *modules )
161{ 163{
162 QString modname = modules->text( 0 ); 164 QString modname = modules->text( 0 );
163 QString capstr = "Module: "; 165 QString capstr = "Module: ";
164 capstr.append( modname ); 166 capstr.append( modname );
165 ModulesDtl->setCaption( capstr ); 167 ModulesDtl->setCaption( capstr );
166 QString command = "/sbin/modinfo "; 168 QString command = "/sbin/modinfo ";
167 command.append( modname ); 169 command.append( modname );
168 FILE* modinfo = popen( command, "r" ); 170 FILE* modinfo = popen( command, "r" );
169 171
170 if ( modinfo ) 172 if ( modinfo )
171 { 173 {
172 char line[200]; 174 char line[200];
173 ModulesDtl->detailView->setText( " Details:\n------------\n" ); 175 ModulesDtl->detailView->setText( " Details:\n------------\n" );
174 176
175 while( true ) 177 while( true )
176 { 178 {
177 int success = fscanf( modinfo, "%[^\n]\n", line ); 179 int success = fscanf( modinfo, "%[^\n]\n", line );
178 if ( success == EOF ) 180 if ( success == EOF )
179 break; 181 break;
180 ModulesDtl->detailView->append( line ); 182 ModulesDtl->detailView->append( line );
181 } 183 }
182 184
183 pclose( modinfo ); 185 pclose( modinfo );
184 } 186 }
185 187
186 ModulesDtl->showMaximized(); 188 QPEApplication::showWidget( ModulesDtl );
187} 189}
188 190