-rw-r--r-- | noncore/settings/sysinfo/benchmarkinfo.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/sysinfo/modulesinfo.cpp | 4 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processinfo.cpp | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp index 0aeb251..d6ecec5 100644 --- a/noncore/settings/sysinfo/benchmarkinfo.cpp +++ b/noncore/settings/sysinfo/benchmarkinfo.cpp | |||
@@ -52,193 +52,193 @@ extern "C" | |||
52 | double dhry_main( int ); | 52 | double dhry_main( int ); |
53 | } | 53 | } |
54 | 54 | ||
55 | #define DHRYSTONE_RUNS 20000000 | 55 | #define DHRYSTONE_RUNS 20000000 |
56 | #define TEST_DURATION 3 | 56 | #define TEST_DURATION 3 |
57 | 57 | ||
58 | #define BUFF_SIZE 8192 | 58 | #define BUFF_SIZE 8192 |
59 | #define FILE_SIZE 1024 * 1024 // 1Mb | 59 | #define FILE_SIZE 1024 * 1024 // 1Mb |
60 | 60 | ||
61 | //=========================================================================== | 61 | //=========================================================================== |
62 | 62 | ||
63 | class BenchmarkPaintWidget : public QWidget | 63 | class BenchmarkPaintWidget : public QWidget |
64 | { | 64 | { |
65 | public: | 65 | public: |
66 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) | 66 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) |
67 | { | 67 | { |
68 | resize( QApplication::desktop()->size() ); | 68 | resize( QApplication::desktop()->size() ); |
69 | show(); | 69 | show(); |
70 | p.begin( this ); | 70 | p.begin( this ); |
71 | }; | 71 | }; |
72 | 72 | ||
73 | ~BenchmarkPaintWidget() | 73 | ~BenchmarkPaintWidget() |
74 | { | 74 | { |
75 | p.end(); | 75 | p.end(); |
76 | hide(); | 76 | hide(); |
77 | }; | 77 | }; |
78 | 78 | ||
79 | QPainter p; | 79 | QPainter p; |
80 | }; | 80 | }; |
81 | 81 | ||
82 | //=========================================================================== | 82 | //=========================================================================== |
83 | 83 | ||
84 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) | 84 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) |
85 | : QWidget( parent, name, wFlags ) | 85 | : QWidget( parent, name, wFlags ) |
86 | { | 86 | { |
87 | 87 | ||
88 | setMinimumSize( 200, 150 ); | 88 | setMinimumSize( 200, 150 ); |
89 | 89 | ||
90 | QVBoxLayout* vb = new QVBoxLayout( this ); | 90 | QVBoxLayout* vb = new QVBoxLayout( this ); |
91 | vb->setSpacing( 4 ); | 91 | vb->setSpacing( 4 ); |
92 | vb->setMargin( 4 ); | 92 | vb->setMargin( 4 ); |
93 | 93 | ||
94 | tests = new QListView( this ); | 94 | tests = new QListView( this ); |
95 | tests->setMargin( 0 ); | 95 | tests->setMargin( 0 ); |
96 | tests->addColumn( tr( "Tests" ) ); | 96 | tests->addColumn( tr( "Tests" ) ); |
97 | tests->addColumn( tr( "Results" ) ); | 97 | tests->addColumn( tr( "Results" ) ); |
98 | tests->addColumn( tr( "Comparison" ) ); | 98 | tests->addColumn( tr( "Comparison" ) ); |
99 | tests->setShowSortIndicator( true ); | 99 | tests->setShowSortIndicator( true ); |
100 | 100 | ||
101 | test_alu = new QCheckListItem( tests, tr( "1. Integer Arithmetic " ), QCheckListItem::CheckBox ); | 101 | test_alu = new QCheckListItem( tests, tr( "1. Integer Arithmetic " ), QCheckListItem::CheckBox ); |
102 | test_fpu = new QCheckListItem( tests, tr( "2. Floating Point Unit " ), QCheckListItem::CheckBox ); | 102 | test_fpu = new QCheckListItem( tests, tr( "2. Floating Point Unit " ), QCheckListItem::CheckBox ); |
103 | test_txt = new QCheckListItem( tests, tr( "3. Text Rendering " ), QCheckListItem::CheckBox ); | 103 | test_txt = new QCheckListItem( tests, tr( "3. Text Rendering " ), QCheckListItem::CheckBox ); |
104 | test_gfx = new QCheckListItem( tests, tr( "4. Gfx Rendering " ), QCheckListItem::CheckBox ); | 104 | test_gfx = new QCheckListItem( tests, tr( "4. Gfx Rendering " ), QCheckListItem::CheckBox ); |
105 | test_ram = new QCheckListItem( tests, tr( "5. RAM Performance " ), QCheckListItem::CheckBox ); | 105 | test_ram = new QCheckListItem( tests, tr( "5. RAM Performance " ), QCheckListItem::CheckBox ); |
106 | test_sd = new QCheckListItem( tests, tr( "6. SD Card Performance " ), QCheckListItem::CheckBox ); | 106 | test_sd = new QCheckListItem( tests, tr( "6. SD Card Performance " ), QCheckListItem::CheckBox ); |
107 | test_cf = new QCheckListItem( tests, tr( "7. CF Card Performance " ), QCheckListItem::CheckBox ); | 107 | test_cf = new QCheckListItem( tests, tr( "7. CF Card Performance " ), QCheckListItem::CheckBox ); |
108 | 108 | ||
109 | test_alu->setText( 1, "n/a" ); | 109 | test_alu->setText( 1, "n/a" ); |
110 | test_fpu->setText( 1, "n/a" ); | 110 | test_fpu->setText( 1, "n/a" ); |
111 | test_txt->setText( 1, "n/a" ); | 111 | test_txt->setText( 1, "n/a" ); |
112 | test_gfx->setText( 1, "n/a" ); | 112 | test_gfx->setText( 1, "n/a" ); |
113 | test_ram->setText( 1, "n/a" ); | 113 | test_ram->setText( 1, "n/a" ); |
114 | test_sd->setText( 1, "n/a" ); | 114 | test_sd->setText( 1, "n/a" ); |
115 | test_cf->setText( 1, "n/a" ); | 115 | test_cf->setText( 1, "n/a" ); |
116 | 116 | ||
117 | test_alu->setText( 2, "n/a" ); | 117 | test_alu->setText( 2, "n/a" ); |
118 | test_fpu->setText( 2, "n/a" ); | 118 | test_fpu->setText( 2, "n/a" ); |
119 | test_txt->setText( 2, "n/a" ); | 119 | test_txt->setText( 2, "n/a" ); |
120 | test_gfx->setText( 2, "n/a" ); | 120 | test_gfx->setText( 2, "n/a" ); |
121 | test_ram->setText( 2, "n/a" ); | 121 | test_ram->setText( 2, "n/a" ); |
122 | test_sd->setText( 2, "n/a" ); | 122 | test_sd->setText( 2, "n/a" ); |
123 | test_cf->setText( 2, "n/a" ); | 123 | test_cf->setText( 2, "n/a" ); |
124 | 124 | ||
125 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); | 125 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); |
126 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); | 126 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); |
127 | 127 | ||
128 | vb->addWidget( tests, 2 ); | 128 | vb->addWidget( tests, 2 ); |
129 | 129 | ||
130 | QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); | 130 | QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); |
131 | if ( f.open( IO_ReadOnly ) ) | 131 | if ( f.open( IO_ReadOnly ) ) |
132 | { | 132 | { |
133 | machineCombo = new QComboBox( this ); | 133 | machineCombo = new QComboBox( this ); |
134 | 134 | ||
135 | QTextStream ts( &f ); | 135 | QTextStream ts( &f ); |
136 | while( !ts.eof() ) | 136 | while( !ts.eof() ) |
137 | { | 137 | { |
138 | QString machline = ts.readLine(); | 138 | QString machline = ts.readLine(); |
139 | qDebug( "sysinfo: parsing benchmark results for '%s'", (const char*) machline ); | 139 | qDebug( "sysinfo: parsing benchmark results for '%s'", (const char*) machline ); |
140 | QString resline = ts.readLine(); | 140 | QString resline = ts.readLine(); |
141 | machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); | 141 | machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); |
142 | machineCombo->insertItem( machline ); | 142 | machineCombo->insertItem( machline ); |
143 | } | 143 | } |
144 | 144 | ||
145 | QHBoxLayout* hb = new QHBoxLayout( vb ); | 145 | QHBoxLayout* hb = new QHBoxLayout( vb ); |
146 | hb->addWidget( new QLabel( tr( "Compare To:" ), this ) ); | 146 | hb->addWidget( new QLabel( tr( "Compare To:" ), this ) ); |
147 | hb->addWidget( machineCombo, 2 ); | 147 | hb->addWidget( machineCombo, 2 ); |
148 | connect( machineCombo, SIGNAL( activated( int ) ), this, SLOT( machineActivated( int ) ) ); | 148 | connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) ); |
149 | } | 149 | } |
150 | 150 | ||
151 | vb->addWidget( startButton, 2 ); | 151 | vb->addWidget( startButton, 2 ); |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | BenchmarkInfo::~BenchmarkInfo() | 155 | BenchmarkInfo::~BenchmarkInfo() |
156 | {} | 156 | {} |
157 | 157 | ||
158 | 158 | ||
159 | void BenchmarkInfo::machineActivated( int index ) | 159 | void BenchmarkInfo::machineActivated( int index ) |
160 | { | 160 | { |
161 | QStringList* results = machines[ machineCombo->text( index ) ]; | 161 | QStringList* results = machines[ machineCombo->text( index ) ]; |
162 | if ( !results ) | 162 | if ( !results ) |
163 | { | 163 | { |
164 | qDebug( "sysinfo: no results available." ); | 164 | qDebug( "sysinfo: no results available." ); |
165 | return; | 165 | return; |
166 | } | 166 | } |
167 | QStringList::Iterator it = results->begin(); | 167 | QStringList::Iterator it = results->begin(); |
168 | test_alu->setText( 2, *(it++) ); | 168 | test_alu->setText( 2, *(it++) ); |
169 | test_fpu->setText( 2, *(it++) ); | 169 | test_fpu->setText( 2, *(it++) ); |
170 | test_txt->setText( 2, *(it++) ); | 170 | test_txt->setText( 2, *(it++) ); |
171 | test_gfx->setText( 2, *(it++) ); | 171 | test_gfx->setText( 2, *(it++) ); |
172 | test_ram->setText( 2, *(it++) ); | 172 | test_ram->setText( 2, *(it++) ); |
173 | test_sd->setText( 2, *(it++) ); | 173 | test_sd->setText( 2, *(it++) ); |
174 | test_cf->setText( 2, *(it++) ); | 174 | test_cf->setText( 2, *(it++) ); |
175 | } | 175 | } |
176 | 176 | ||
177 | 177 | ||
178 | void BenchmarkInfo::run() | 178 | void BenchmarkInfo::run() |
179 | { | 179 | { |
180 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); | 180 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); |
181 | qApp->processEvents(); | 181 | qApp->processEvents(); |
182 | QTime t; | 182 | QTime t; |
183 | 183 | ||
184 | if ( test_alu->isOn() ) | 184 | if ( test_alu->isOn() ) |
185 | { | 185 | { |
186 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); | 186 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); |
187 | test_alu->setText( 1, QString( "%1 dhrys" ).arg( QString::number( d ) ) ); | 187 | test_alu->setText( 1, QString( "%1 dhrys" ).arg( QString::number( d ) ) ); |
188 | test_alu->setOn( false ); | 188 | test_alu->setOn( false ); |
189 | } | 189 | } |
190 | 190 | ||
191 | if ( test_fpu->isOn() ) | 191 | if ( test_fpu->isOn() ) |
192 | { | 192 | { |
193 | t.start(); | 193 | t.start(); |
194 | BenchFFT(); | 194 | BenchFFT(); |
195 | test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); | 195 | test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); |
196 | test_fpu->setOn( false ); | 196 | test_fpu->setOn( false ); |
197 | } | 197 | } |
198 | 198 | ||
199 | if ( test_txt->isOn() ) | 199 | if ( test_txt->isOn() ) |
200 | { | 200 | { |
201 | int value = textRendering( TEST_DURATION ); | 201 | int value = textRendering( TEST_DURATION ); |
202 | test_txt->setText( 1, QString( "%1 chars/sec" ).arg( QString::number( value / TEST_DURATION ) ) ); | 202 | test_txt->setText( 1, QString( "%1 chars/sec" ).arg( QString::number( value / TEST_DURATION ) ) ); |
203 | test_txt->setOn( false ); | 203 | test_txt->setOn( false ); |
204 | } | 204 | } |
205 | 205 | ||
206 | if ( test_gfx->isOn() ) | 206 | if ( test_gfx->isOn() ) |
207 | { | 207 | { |
208 | int value = gfxRendering( TEST_DURATION ); | 208 | int value = gfxRendering( TEST_DURATION ); |
209 | test_gfx->setText( 1, QString( "%1 gops/sec" ).arg( QString::number( value / 4 / TEST_DURATION ) ) ); // 4 tests | 209 | test_gfx->setText( 1, QString( "%1 gops/sec" ).arg( QString::number( value / 4 / TEST_DURATION ) ) ); // 4 tests |
210 | test_gfx->setOn( false ); | 210 | test_gfx->setOn( false ); |
211 | } | 211 | } |
212 | 212 | ||
213 | if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA | 213 | if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA |
214 | { | 214 | { |
215 | performFileTest( "/tmp/benchmarkFile.dat", test_ram ); | 215 | performFileTest( "/tmp/benchmarkFile.dat", test_ram ); |
216 | } | 216 | } |
217 | 217 | ||
218 | if ( test_cf->isOn() ) | 218 | if ( test_cf->isOn() ) |
219 | { | 219 | { |
220 | OStorageInfo storage; | 220 | OStorageInfo storage; |
221 | performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); | 221 | performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); |
222 | } | 222 | } |
223 | 223 | ||
224 | if ( test_sd->isOn() ) | 224 | if ( test_sd->isOn() ) |
225 | { | 225 | { |
226 | OStorageInfo storage; | 226 | OStorageInfo storage; |
227 | performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); | 227 | performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); |
228 | } | 228 | } |
229 | 229 | ||
230 | startButton->setText( tr( "&Start Tests!" ) ); | 230 | startButton->setText( tr( "&Start Tests!" ) ); |
231 | } | 231 | } |
232 | 232 | ||
233 | 233 | ||
234 | int BenchmarkInfo::textRendering( int seconds ) | 234 | int BenchmarkInfo::textRendering( int seconds ) |
235 | { | 235 | { |
236 | QTime t; | 236 | QTime t; |
237 | t.start(); | 237 | t.start(); |
238 | int stop = t.elapsed() + seconds * 1000; | 238 | int stop = t.elapsed() + seconds * 1000; |
239 | 239 | ||
240 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 240 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
241 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 241 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
242 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 242 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
243 | const QString text( "Opie Benchmark Test" ); | 243 | const QString text( "Opie Benchmark Test" ); |
244 | 244 | ||
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp index 9cb8ad2..e688a29 100644 --- a/noncore/settings/sysinfo/modulesinfo.cpp +++ b/noncore/settings/sysinfo/modulesinfo.cpp | |||
@@ -1,154 +1,154 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** ModulesInfo | 2 | ** ModulesInfo |
3 | ** | 3 | ** |
4 | ** Display Modules information | 4 | ** Display Modules information |
5 | ** | 5 | ** |
6 | ** Copyright (C) 2002, Michael Lauer | 6 | ** Copyright (C) 2002, Michael Lauer |
7 | ** mickey@tm.informatik.uni-frankfurt.de | 7 | ** mickey@tm.informatik.uni-frankfurt.de |
8 | ** http://www.Vanille.de | 8 | ** http://www.Vanille.de |
9 | ** | 9 | ** |
10 | ** Based on ProcessInfo by Dan Williams <williamsdr@acm.org> | 10 | ** Based on ProcessInfo by Dan Williams <williamsdr@acm.org> |
11 | ** | 11 | ** |
12 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 14 | ** Foundation and appearing in the file LICENSE.GPL included in the |
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 <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | 27 | ||
28 | /* QT */ | 28 | /* QT */ |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qwhatsthis.h> | 33 | #include <qwhatsthis.h> |
34 | 34 | ||
35 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) | 35 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) |
36 | : QWidget( parent, name, fl ) | 36 | : QWidget( parent, name, fl ) |
37 | { | 37 | { |
38 | QGridLayout *layout = new QGridLayout( this ); | 38 | QGridLayout *layout = new QGridLayout( this ); |
39 | layout->setSpacing( 4 ); | 39 | layout->setSpacing( 4 ); |
40 | layout->setMargin( 4 ); | 40 | layout->setMargin( 4 ); |
41 | 41 | ||
42 | ModulesView = new QListView( this ); | 42 | ModulesView = new QListView( this ); |
43 | int colnum = ModulesView->addColumn( tr( "Module" ) ); | 43 | int colnum = ModulesView->addColumn( tr( "Module" ) ); |
44 | colnum = ModulesView->addColumn( tr( "Size" ) ); | 44 | colnum = ModulesView->addColumn( tr( "Size" ) ); |
45 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 45 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
46 | colnum = ModulesView->addColumn( tr( "Use#" ) ); | 46 | colnum = ModulesView->addColumn( tr( "Use#" ) ); |
47 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 47 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
48 | colnum = ModulesView->addColumn( tr( "Used by" ) ); | 48 | colnum = ModulesView->addColumn( tr( "Used by" ) ); |
49 | ModulesView->setAllColumnsShowFocus( TRUE ); | 49 | ModulesView->setAllColumnsShowFocus( TRUE ); |
50 | layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); | 50 | layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); |
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." ) ); | 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." ) ); |
52 | 52 | ||
53 | // 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 |
54 | if ( QFile::exists( "/sbin/modinfo" ) ) | 54 | if ( QFile::exists( "/sbin/modinfo" ) ) |
55 | { | 55 | { |
56 | QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); | 56 | QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); |
57 | connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 57 | connect( ModulesView, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), |
58 | this, SLOT( viewModules( QListViewItem * ) ) ); | 58 | this, SLOT( viewModules(QListViewItem*) ) ); |
59 | } | 59 | } |
60 | 60 | ||
61 | CommandCB = new QComboBox( FALSE, this ); | 61 | CommandCB = new QComboBox( FALSE, this ); |
62 | CommandCB->insertItem( "modprobe -r" ); | 62 | CommandCB->insertItem( "modprobe -r" ); |
63 | CommandCB->insertItem( "rmmod" ); | 63 | CommandCB->insertItem( "rmmod" ); |
64 | // I can't think of other useful commands yet. Anyone? | 64 | // I can't think of other useful commands yet. Anyone? |
65 | layout->addWidget( CommandCB, 1, 0 ); | 65 | layout->addWidget( CommandCB, 1, 0 ); |
66 | 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." ) ); | 66 | 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." ) ); |
67 | 67 | ||
68 | QPushButton *btn = new QPushButton( this ); | 68 | QPushButton *btn = new QPushButton( this ); |
69 | btn->setMinimumSize( QSize( 50, 24 ) ); | 69 | btn->setMinimumSize( QSize( 50, 24 ) ); |
70 | btn->setMaximumSize( QSize( 50, 24 ) ); | 70 | btn->setMaximumSize( QSize( 50, 24 ) ); |
71 | btn->setText( tr( "Send" ) ); | 71 | btn->setText( tr( "Send" ) ); |
72 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); | 72 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); |
73 | layout->addWidget( btn, 1, 1 ); | 73 | layout->addWidget( btn, 1, 1 ); |
74 | QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); | 74 | QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); |
75 | 75 | ||
76 | QTimer *t = new QTimer( this ); | 76 | QTimer *t = new QTimer( this ); |
77 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 77 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
78 | t->start( 5000 ); | 78 | t->start( 5000 ); |
79 | 79 | ||
80 | updateData(); | 80 | updateData(); |
81 | 81 | ||
82 | ModulesDtl = new Detail(); | 82 | ModulesDtl = new Detail(); |
83 | 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." ) ); |
84 | } | 84 | } |
85 | 85 | ||
86 | ModulesInfo::~ModulesInfo() | 86 | ModulesInfo::~ModulesInfo() |
87 | {} | 87 | {} |
88 | 88 | ||
89 | void ModulesInfo::updateData() | 89 | void ModulesInfo::updateData() |
90 | { | 90 | { |
91 | char modname[64]; | 91 | char modname[64]; |
92 | char usage[200]; | 92 | char usage[200]; |
93 | int modsize, usecount; | 93 | int modsize, usecount; |
94 | 94 | ||
95 | QString selectedmod; | 95 | QString selectedmod; |
96 | QListViewItem *curritem = ModulesView->currentItem(); | 96 | QListViewItem *curritem = ModulesView->currentItem(); |
97 | if ( curritem ) | 97 | if ( curritem ) |
98 | { | 98 | { |
99 | selectedmod = curritem->text( 0 ); | 99 | selectedmod = curritem->text( 0 ); |
100 | } | 100 | } |
101 | 101 | ||
102 | ModulesView->clear(); | 102 | ModulesView->clear(); |
103 | 103 | ||
104 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); | 104 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); |
105 | 105 | ||
106 | if ( procfile ) | 106 | if ( procfile ) |
107 | { | 107 | { |
108 | QListViewItem *newitem; | 108 | QListViewItem *newitem; |
109 | QListViewItem *selecteditem = 0x0; | 109 | QListViewItem *selecteditem = 0x0; |
110 | while ( true ) | 110 | while ( true ) |
111 | { | 111 | { |
112 | modname[0] = '\0'; | 112 | modname[0] = '\0'; |
113 | usage[0] = '\0'; | 113 | usage[0] = '\0'; |
114 | 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 ); |
115 | 115 | ||
116 | if ( success == EOF ) | 116 | if ( success == EOF ) |
117 | break; | 117 | break; |
118 | 118 | ||
119 | QString qmodname = QString( modname ); | 119 | QString qmodname = QString( modname ); |
120 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); | 120 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); |
121 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); | 121 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); |
122 | QString qusage = QString( usage ); | 122 | QString qusage = QString( usage ); |
123 | 123 | ||
124 | newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); | 124 | newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); |
125 | if ( qmodname == selectedmod ) | 125 | if ( qmodname == selectedmod ) |
126 | { | 126 | { |
127 | selecteditem = newitem; | 127 | selecteditem = newitem; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | ModulesView->setCurrentItem( selecteditem ); | 130 | ModulesView->setCurrentItem( selecteditem ); |
131 | 131 | ||
132 | fclose( procfile ); | 132 | fclose( procfile ); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | void ModulesInfo::slotSendClicked() | 136 | void ModulesInfo::slotSendClicked() |
137 | { | 137 | { |
138 | if ( !ModulesView->currentItem() ) | 138 | if ( !ModulesView->currentItem() ) |
139 | { | 139 | { |
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | 142 | ||
143 | 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() ); |
144 | 144 | ||
145 | QString modname = ModulesView->currentItem()->text( 0 ); | 145 | QString modname = ModulesView->currentItem()->text( 0 ); |
146 | 146 | ||
147 | if ( QMessageBox::warning( this, modname, capstr, | 147 | if ( QMessageBox::warning( this, modname, capstr, |
148 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 148 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
149 | { | 149 | { |
150 | QString command = "/sbin/"; | 150 | QString command = "/sbin/"; |
151 | command.append( CommandCB->currentText() ); | 151 | command.append( CommandCB->currentText() ); |
152 | command.append( " " ); | 152 | command.append( " " ); |
153 | command.append( modname ); | 153 | command.append( modname ); |
154 | 154 | ||
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp index 2a90b0f..69b4ab5 100644 --- a/noncore/settings/sysinfo/processinfo.cpp +++ b/noncore/settings/sysinfo/processinfo.cpp | |||
@@ -1,151 +1,151 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** ProcessInfo | 2 | ** ProcessInfo |
3 | ** | 3 | ** |
4 | ** Display process information | 4 | ** Display process information |
5 | ** | 5 | ** |
6 | ** Copyright (C) 2002, Dan Williams | 6 | ** Copyright (C) 2002, Dan Williams |
7 | ** williamsdr@acm.org | 7 | ** williamsdr@acm.org |
8 | ** http://draknor.net | 8 | ** http://draknor.net |
9 | ** | 9 | ** |
10 | ** This file may be distributed and/or modified under the terms of the | 10 | ** This file may be distributed and/or modified under the terms of the |
11 | ** GNU General Public License version 2 as published by the Free Software | 11 | ** GNU General Public License version 2 as published by the Free Software |
12 | ** Foundation and appearing in the file LICENSE.GPL included in the | 12 | ** Foundation and appearing in the file LICENSE.GPL included in the |
13 | ** packaging of this file. | 13 | ** packaging of this file. |
14 | ** | 14 | ** |
15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
17 | ** | 17 | ** |
18 | **********************************************************************/ | 18 | **********************************************************************/ |
19 | 19 | ||
20 | #include "processinfo.h" | 20 | #include "processinfo.h" |
21 | #include "detail.h" | 21 | #include "detail.h" |
22 | 22 | ||
23 | /* OPIE */ | 23 | /* OPIE */ |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | 25 | ||
26 | /* QT */ | 26 | /* QT */ |
27 | #include <qdir.h> | 27 | #include <qdir.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
32 | 32 | ||
33 | /* STD */ | 33 | /* STD */ |
34 | #include <sys/types.h> | 34 | #include <sys/types.h> |
35 | #include <signal.h> | 35 | #include <signal.h> |
36 | 36 | ||
37 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) | 37 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) |
38 | : QWidget( parent, name, fl ) | 38 | : QWidget( parent, name, fl ) |
39 | { | 39 | { |
40 | QGridLayout *layout = new QGridLayout( this ); | 40 | QGridLayout *layout = new QGridLayout( this ); |
41 | layout->setSpacing( 4 ); | 41 | layout->setSpacing( 4 ); |
42 | layout->setMargin( 4 ); | 42 | layout->setMargin( 4 ); |
43 | 43 | ||
44 | 44 | ||
45 | ProcessView = new QListView( this, "ProcessView" ); | 45 | ProcessView = new QListView( this, "ProcessView" ); |
46 | int colnum = ProcessView->addColumn( tr( "PID" ) ); | 46 | int colnum = ProcessView->addColumn( tr( "PID" ) ); |
47 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | 47 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); |
48 | colnum = ProcessView->addColumn( tr( "Command" ),96 ); | 48 | colnum = ProcessView->addColumn( tr( "Command" ),96 ); |
49 | colnum = ProcessView->addColumn( tr( "Status" ) ); | 49 | colnum = ProcessView->addColumn( tr( "Status" ) ); |
50 | colnum = ProcessView->addColumn( tr( "Time" ) ); | 50 | colnum = ProcessView->addColumn( tr( "Time" ) ); |
51 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | 51 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); |
52 | ProcessView->setAllColumnsShowFocus( TRUE ); | 52 | ProcessView->setAllColumnsShowFocus( TRUE ); |
53 | QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); | 53 | QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); |
54 | connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 54 | connect( ProcessView, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), |
55 | this, SLOT( viewProcess( QListViewItem * ) ) ); | 55 | this, SLOT( viewProcess(QListViewItem*) ) ); |
56 | layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); | 56 | layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); |
57 | QWhatsThis::add( ProcessView, tr( "This is a list of all the processes on this handheld device.\n\nClick and hold on a process to see additional information about the process, or to send a signal to it." ) ); | 57 | QWhatsThis::add( ProcessView, tr( "This is a list of all the processes on this handheld device.\n\nClick and hold on a process to see additional information about the process, or to send a signal to it." ) ); |
58 | 58 | ||
59 | SignalCB = new QComboBox( FALSE, this, "SignalCB" ); | 59 | SignalCB = new QComboBox( FALSE, this, "SignalCB" ); |
60 | SignalCB->insertItem( " 1: SIGHUP" ); | 60 | SignalCB->insertItem( " 1: SIGHUP" ); |
61 | SignalCB->insertItem( " 2: SIGINT" ); | 61 | SignalCB->insertItem( " 2: SIGINT" ); |
62 | SignalCB->insertItem( " 3: SIGQUIT" ); | 62 | SignalCB->insertItem( " 3: SIGQUIT" ); |
63 | SignalCB->insertItem( " 5: SIGTRAP" ); | 63 | SignalCB->insertItem( " 5: SIGTRAP" ); |
64 | SignalCB->insertItem( " 6: SIGABRT" ); | 64 | SignalCB->insertItem( " 6: SIGABRT" ); |
65 | SignalCB->insertItem( " 9: SIGKILL" ); | 65 | SignalCB->insertItem( " 9: SIGKILL" ); |
66 | SignalCB->insertItem( "14: SIGALRM" ); | 66 | SignalCB->insertItem( "14: SIGALRM" ); |
67 | SignalCB->insertItem( "15: SIGTERM" ); | 67 | SignalCB->insertItem( "15: SIGTERM" ); |
68 | SignalCB->insertItem( "18: SIGCONT" ); | 68 | SignalCB->insertItem( "18: SIGCONT" ); |
69 | SignalCB->insertItem( "19: SIGSTOP" ); | 69 | SignalCB->insertItem( "19: SIGSTOP" ); |
70 | layout->addWidget( SignalCB, 1, 0 ); | 70 | layout->addWidget( SignalCB, 1, 0 ); |
71 | QWhatsThis::add( SignalCB, tr( "Select a signal here and then click the Send button to the right to send to this process." ) ); | 71 | QWhatsThis::add( SignalCB, tr( "Select a signal here and then click the Send button to the right to send to this process." ) ); |
72 | 72 | ||
73 | SendButton = new QPushButton( this, "SendButton" ); | 73 | SendButton = new QPushButton( this, "SendButton" ); |
74 | SendButton->setMinimumSize( QSize( 50, 24 ) ); | 74 | SendButton->setMinimumSize( QSize( 50, 24 ) ); |
75 | SendButton->setMaximumSize( QSize( 50, 24 ) ); | 75 | SendButton->setMaximumSize( QSize( 50, 24 ) ); |
76 | SendButton->setText( tr( "Send" ) ); | 76 | SendButton->setText( tr( "Send" ) ); |
77 | connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); | 77 | connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); |
78 | layout->addWidget( SendButton, 1, 1 ); | 78 | layout->addWidget( SendButton, 1, 1 ); |
79 | QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) ); | 79 | QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) ); |
80 | 80 | ||
81 | QTimer *t = new QTimer( this ); | 81 | QTimer *t = new QTimer( this ); |
82 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 82 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
83 | t->start( 5000 ); | 83 | t->start( 5000 ); |
84 | 84 | ||
85 | updateData(); | 85 | updateData(); |
86 | 86 | ||
87 | ProcessDtl = new Detail(); | 87 | ProcessDtl = new Detail(); |
88 | QWhatsThis::add( ProcessDtl->detailView, tr( "This area shows detailed information about this process." ) ); | 88 | QWhatsThis::add( ProcessDtl->detailView, tr( "This area shows detailed information about this process." ) ); |
89 | } | 89 | } |
90 | 90 | ||
91 | ProcessInfo::~ProcessInfo() | 91 | ProcessInfo::~ProcessInfo() |
92 | {} | 92 | {} |
93 | 93 | ||
94 | void ProcessInfo::updateData() | 94 | void ProcessInfo::updateData() |
95 | { | 95 | { |
96 | int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, | 96 | int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, |
97 | signal, blocked, sigignore, sigcatch; | 97 | signal, blocked, sigignore, sigcatch; |
98 | uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, | 98 | uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, |
99 | endcode, startstack, kstkesp, kstkeip, wchan; | 99 | endcode, startstack, kstkesp, kstkeip, wchan; |
100 | char state; | 100 | char state; |
101 | char comm[64]; | 101 | char comm[64]; |
102 | 102 | ||
103 | QString selectedpid; | 103 | QString selectedpid; |
104 | QListViewItem *curritem = ProcessView->currentItem(); | 104 | QListViewItem *curritem = ProcessView->currentItem(); |
105 | if ( curritem ) | 105 | if ( curritem ) |
106 | { | 106 | { |
107 | selectedpid = curritem->text( 0 ); | 107 | selectedpid = curritem->text( 0 ); |
108 | } | 108 | } |
109 | 109 | ||
110 | ProcessView->clear(); | 110 | ProcessView->clear(); |
111 | 111 | ||
112 | QListViewItem *newitem; | 112 | QListViewItem *newitem; |
113 | QListViewItem *selecteditem = 0x0; | 113 | QListViewItem *selecteditem = 0x0; |
114 | QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); | 114 | QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); |
115 | QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); | 115 | QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); |
116 | if ( proclist ) | 116 | if ( proclist ) |
117 | { | 117 | { |
118 | QFileInfoListIterator it(*proclist); | 118 | QFileInfoListIterator it(*proclist); |
119 | QFileInfo *f; | 119 | QFileInfo *f; |
120 | while ( ( f = it.current() ) != 0 ) | 120 | while ( ( f = it.current() ) != 0 ) |
121 | { | 121 | { |
122 | ++it; | 122 | ++it; |
123 | QString processnum = f->fileName(); | 123 | QString processnum = f->fileName(); |
124 | if ( processnum >= "1" && processnum <= "99999" ) | 124 | if ( processnum >= "1" && processnum <= "99999" ) |
125 | { | 125 | { |
126 | FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); | 126 | FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); |
127 | 127 | ||
128 | if ( procfile ) | 128 | if ( procfile ) |
129 | { | 129 | { |
130 | fscanf( procfile, | 130 | fscanf( procfile, |
131 | "%d %s %c %d %d %d %d %d %u %u %u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %u %u %u %u %u %d %d %d %d %u", | 131 | "%d %s %c %d %d %d %d %d %u %u %u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %u %u %u %u %u %d %d %d %d %u", |
132 | &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, | 132 | &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, |
133 | &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, | 133 | &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, |
134 | &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, | 134 | &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, |
135 | &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); | 135 | &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); |
136 | processnum = processnum.rightJustify( 5, ' ' ); | 136 | processnum = processnum.rightJustify( 5, ' ' ); |
137 | QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); | 137 | QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); |
138 | QString processstatus = QChar(state); | 138 | QString processstatus = QChar(state); |
139 | QString processtime = QString::number( ( utime + stime ) / 100 ); | 139 | QString processtime = QString::number( ( utime + stime ) / 100 ); |
140 | processtime = processtime.rightJustify( 9, ' ' ); | 140 | processtime = processtime.rightJustify( 9, ' ' ); |
141 | fclose( procfile ); | 141 | fclose( procfile ); |
142 | 142 | ||
143 | newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); | 143 | newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); |
144 | if ( processnum == selectedpid ) | 144 | if ( processnum == selectedpid ) |
145 | { | 145 | { |
146 | selecteditem = newitem; | 146 | selecteditem = newitem; |
147 | } | 147 | } |
148 | } | 148 | } |
149 | } | 149 | } |
150 | } | 150 | } |
151 | ProcessView->setCurrentItem( selecteditem ); | 151 | ProcessView->setCurrentItem( selecteditem ); |