summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/modulesinfo.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp
index 29cce90..7abad69 100644
--- a/noncore/settings/sysinfo/modulesinfo.cpp
+++ b/noncore/settings/sysinfo/modulesinfo.cpp
@@ -29,151 +29,151 @@
29#include <qmessagebox.h> 29#include <qmessagebox.h>
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#include "detail.h"
37 37
38ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) 38ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl )
39 : QWidget( parent, name, fl ) 39 : QWidget( parent, name, fl )
40{ 40{
41 QGridLayout *layout = new QGridLayout( this ); 41 QGridLayout *layout = new QGridLayout( this );
42 layout->setSpacing( 4 ); 42 layout->setSpacing( 4 );
43 layout->setMargin( 4 ); 43 layout->setMargin( 4 );
44 44
45 ModulesView = new QListView( this ); 45 ModulesView = new QListView( this );
46 int colnum = ModulesView->addColumn( tr( "Module" ) ); 46 int colnum = ModulesView->addColumn( tr( "Module" ) );
47 colnum = ModulesView->addColumn( tr( "Size" ) ); 47 colnum = ModulesView->addColumn( tr( "Size" ) );
48 ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); 48 ModulesView->setColumnAlignment( colnum, Qt::AlignRight );
49 colnum = ModulesView->addColumn( tr( "Use#" ) ); 49 colnum = ModulesView->addColumn( tr( "Use#" ) );
50 ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); 50 ModulesView->setColumnAlignment( colnum, Qt::AlignRight );
51 colnum = ModulesView->addColumn( tr( "Used By" ) ); 51 colnum = ModulesView->addColumn( tr( "Used By" ) );
52 ModulesView->setAllColumnsShowFocus( TRUE ); 52 ModulesView->setAllColumnsShowFocus( TRUE );
53 layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); 53 layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 );
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." ) ); 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 55
56 // Test if we have /sbin/modinfo, and if so, allow module detail window 56 // Test if we have /sbin/modinfo, and if so, allow module detail window
57 if ( QFile::exists( "/sbin/modinfo" ) ) 57 if ( QFile::exists( "/sbin/modinfo" ) )
58 { 58 {
59 QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); 59 QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold );
60 connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), 60 connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
61 this, SLOT( viewModules( QListViewItem * ) ) ); 61 this, SLOT( viewModules( QListViewItem * ) ) );
62 } 62 }
63 63
64 CommandCB = new QComboBox( FALSE, this ); 64 CommandCB = new QComboBox( FALSE, this );
65 CommandCB->insertItem( "modprobe -r" ); 65 CommandCB->insertItem( "modprobe -r" );
66 CommandCB->insertItem( "rmmod" ); 66 CommandCB->insertItem( "rmmod" );
67 // I can't think of other useful commands yet. Anyone? 67 // I can't think of other useful commands yet. Anyone?
68 layout->addWidget( CommandCB, 1, 0 ); 68 layout->addWidget( CommandCB, 1, 0 );
69 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." ) ); 69 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." ) );
70 70
71 QPushButton *btn = new QPushButton( this ); 71 QPushButton *btn = new QPushButton( this );
72 btn->setMinimumSize( QSize( 50, 24 ) ); 72 btn->setMinimumSize( QSize( 50, 24 ) );
73 btn->setMaximumSize( QSize( 50, 24 ) ); 73 btn->setMaximumSize( QSize( 50, 24 ) );
74 btn->setText( tr( "Send" ) ); 74 btn->setText( tr( "Send" ) );
75 connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); 75 connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) );
76 layout->addWidget( btn, 1, 1 ); 76 layout->addWidget( btn, 1, 1 );
77 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." ) );
78 78
79 QTimer *t = new QTimer( this ); 79 QTimer *t = new QTimer( this );
80 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); 80 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) );
81 t->start( 5000 ); 81 t->start( 5000 );
82 82
83 updateData(); 83 updateData();
84 84
85 ModulesDtl = new Detail(); 85 ModulesDtl = new Detail();
86 QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); 86 QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) );
87} 87}
88 88
89ModulesInfo::~ModulesInfo() 89ModulesInfo::~ModulesInfo()
90{ 90{
91} 91}
92 92
93void ModulesInfo::updateData() 93void ModulesInfo::updateData()
94{ 94{
95 char modname[64]; 95 char modname[64];
96 char usage[200]; 96 char usage[200];
97 int modsize, usecount; 97 int modsize, usecount;
98 98
99 ModulesView->clear(); 99 ModulesView->clear();
100 100
101 FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); 101 FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r");
102 102
103 if ( procfile ) 103 if ( procfile )
104 { 104 {
105 while ( true ) { 105 while ( true ) {
106 int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); 106 int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage );
107 107
108 if ( success == EOF ) 108 if ( success == EOF )
109 break; 109 break;
110 110
111 QString qmodname = QString( modname ); 111 QString qmodname = QString( modname );
112 QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); 112 QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' );
113 QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); 113 QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' );
114 QString qusage = QString( usage ); 114 QString qusage = QString( usage );
115 115
116 ( void ) new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); 116 ( void ) new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage );
117 } 117 }
118 118
119 fclose( procfile ); 119 fclose( procfile );
120 } 120 }
121} 121}
122 122
123void ModulesInfo::slotSendClicked() 123void ModulesInfo::slotSendClicked()
124{ 124{
125 if ( !ModulesView->currentItem() ) 125 if ( !ModulesView->currentItem() )
126 { 126 {
127 return; 127 return;
128 } 128 }
129 129
130 QString capstr = tr( "You really want to execute\n" ); 130 QString capstr = tr( "You really want to execute\n" );
131 capstr.append( CommandCB->currentText() ); 131 capstr.append( CommandCB->currentText() );
132 capstr.append( "\nfor this module?" ); 132 capstr.append( "\nfor this module?" );
133 133
134 QString modname = ModulesView->currentItem()->text( 0 ); 134 QString modname = ModulesView->currentItem()->text( 0 );
135 135
136 if ( QMessageBox::warning( this, modname, capstr, 136 if ( QMessageBox::warning( this, modname, capstr,
137 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) 137 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes )
138 { 138 {
139 QString command = "/sbin/"; 139 QString command = "/sbin/";
140 command.append( CommandCB->currentText() ); 140 command.append( CommandCB->currentText() );
141 command.append( " " ); 141 command.append( " " );
142 command.append( modname ); 142 command.append( modname );
143 143
144 FILE* stream = popen( command, "r" ); 144 FILE* stream = popen( command, "r" );
145 if ( stream ) 145 if ( stream )
146 pclose( stream ); 146 pclose( stream );
147 } 147 }
148 148
149} 149}
150 150
151void ModulesInfo::viewModules( QListViewItem *modules ) 151void ModulesInfo::viewModules( QListViewItem *modules )
152{ 152{
153 QString modname = modules->text( 0 ); 153 QString modname = modules->text( 0 );
154 QString capstr = "Module: "; 154 QString capstr = "Module: ";
155 capstr.append( modname ); 155 capstr.append( modname );
156 ModulesDtl->setCaption( capstr ); 156 ModulesDtl->setCaption( capstr );
157 QString command = "/sbin/modinfo -nad "; 157 QString command = "/sbin/modinfo ";
158 command.append( modname ); 158 command.append( modname );
159 FILE* modinfo = popen( command, "r" ); 159 FILE* modinfo = popen( command, "r" );
160 160
161 if ( modinfo ) 161 if ( modinfo )
162 { 162 {
163 char line[200]; 163 char line[200];
164 ModulesDtl->detailView->setText( " Details:\n------------\n" ); 164 ModulesDtl->detailView->setText( " Details:\n------------\n" );
165 165
166 while( true ) 166 while( true )
167 { 167 {
168 int success = fscanf( modinfo, "%[^\n]\n", line ); 168 int success = fscanf( modinfo, "%[^\n]\n", line );
169 if ( success == EOF ) 169 if ( success == EOF )
170 break; 170 break;
171 ModulesDtl->detailView->append( line ); 171 ModulesDtl->detailView->append( line );
172 } 172 }
173 173
174 pclose( modinfo ); 174 pclose( modinfo );
175 } 175 }
176 176
177 ModulesDtl->showMaximized(); 177 ModulesDtl->showMaximized();
178} 178}
179 179