-rw-r--r-- | noncore/settings/sysinfo/modulesinfo.cpp | 88 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processinfo.cpp | 76 |
2 files changed, 84 insertions, 80 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 | |||
@@ -10,112 +10,114 @@ | |||
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" | ||
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 | |||
33 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) | 35 | ModulesInfo::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 ); |
38 | layout->setMargin( 4 ); | 40 | layout->setMargin( 4 ); |
39 | 41 | ||
40 | ModulesView = new QListView( this ); | 42 | ModulesView = new QListView( this ); |
41 | int colnum = ModulesView->addColumn( tr( "Module" ) ); | 43 | int colnum = ModulesView->addColumn( tr( "Module" ) ); |
42 | colnum = ModulesView->addColumn( tr( "Size" ) ); | 44 | colnum = ModulesView->addColumn( tr( "Size" ) ); |
43 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 45 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
44 | colnum = ModulesView->addColumn( tr( "Use#" ) ); | 46 | colnum = ModulesView->addColumn( tr( "Use#" ) ); |
45 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 47 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
46 | colnum = ModulesView->addColumn( tr( "Used by" ) ); | 48 | colnum = ModulesView->addColumn( tr( "Used by" ) ); |
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" ); |
61 | CommandCB->insertItem( "rmmod" ); | 63 | CommandCB->insertItem( "rmmod" ); |
62 | // I can't think of other useful commands yet. Anyone? | 64 | // I can't think of other useful commands yet. Anyone? |
63 | layout->addWidget( CommandCB, 1, 0 ); | 65 | layout->addWidget( CommandCB, 1, 0 ); |
64 | 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." ) ); |
65 | 67 | ||
66 | QPushButton *btn = new QPushButton( this ); | 68 | QPushButton *btn = new QPushButton( this ); |
67 | btn->setMinimumSize( QSize( 50, 24 ) ); | 69 | btn->setMinimumSize( QSize( 50, 24 ) ); |
68 | btn->setMaximumSize( QSize( 50, 24 ) ); | 70 | btn->setMaximumSize( QSize( 50, 24 ) ); |
69 | btn->setText( tr( "Send" ) ); | 71 | btn->setText( tr( "Send" ) ); |
70 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); | 72 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); |
71 | layout->addWidget( btn, 1, 1 ); | 73 | layout->addWidget( btn, 1, 1 ); |
72 | 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." ) ); |
73 | 75 | ||
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 | ||
84 | ModulesInfo::~ModulesInfo() | 86 | ModulesInfo::~ModulesInfo() |
85 | { | 87 | {} |
86 | } | ||
87 | 88 | ||
88 | void ModulesInfo::updateData() | 89 | void ModulesInfo::updateData() |
89 | { | 90 | { |
90 | char modname[64]; | 91 | char modname[64]; |
91 | char usage[200]; | 92 | char usage[200]; |
92 | int modsize, usecount; | 93 | int modsize, usecount; |
93 | 94 | ||
94 | QString selectedmod; | 95 | QString selectedmod; |
95 | QListViewItem *curritem = ModulesView->currentItem(); | 96 | QListViewItem *curritem = ModulesView->currentItem(); |
96 | if ( curritem ) | 97 | if ( curritem ) |
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"); |
104 | 105 | ||
105 | if ( procfile ) | 106 | if ( procfile ) |
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 ); |
113 | 115 | ||
114 | if ( success == EOF ) | 116 | if ( success == EOF ) |
115 | break; | 117 | break; |
116 | 118 | ||
117 | QString qmodname = QString( modname ); | 119 | QString qmodname = QString( modname ); |
118 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); | 120 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); |
119 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); | 121 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); |
120 | QString qusage = QString( usage ); | 122 | QString qusage = QString( usage ); |
121 | 123 | ||
@@ -124,65 +126,65 @@ void ModulesInfo::updateData() | |||
124 | { | 126 | { |
125 | selecteditem = newitem; | 127 | selecteditem = newitem; |
126 | } | 128 | } |
127 | } | 129 | } |
128 | ModulesView->setCurrentItem( selecteditem ); | 130 | ModulesView->setCurrentItem( selecteditem ); |
129 | 131 | ||
130 | fclose( procfile ); | 132 | fclose( procfile ); |
131 | } | 133 | } |
132 | } | 134 | } |
133 | 135 | ||
134 | void ModulesInfo::slotSendClicked() | 136 | void 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 ) |
155 | pclose( stream ); | 157 | pclose( stream ); |
156 | } | 158 | } |
157 | 159 | ||
158 | } | 160 | } |
159 | 161 | ||
160 | void ModulesInfo::viewModules( QListViewItem *modules ) | 162 | void 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 | ||
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp index af0fe26..2a90b0f 100644 --- a/noncore/settings/sysinfo/processinfo.cpp +++ b/noncore/settings/sysinfo/processinfo.cpp | |||
@@ -8,60 +8,63 @@ | |||
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" | ||
21 | #include "detail.h" | ||
22 | |||
23 | /* OPIE */ | ||
20 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
21 | 25 | ||
26 | /* QT */ | ||
22 | #include <qdir.h> | 27 | #include <qdir.h> |
23 | #include <qlayout.h> | 28 | #include <qlayout.h> |
24 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
25 | #include <qtimer.h> | 30 | #include <qtimer.h> |
26 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
27 | 32 | ||
33 | /* STD */ | ||
28 | #include <sys/types.h> | 34 | #include <sys/types.h> |
29 | #include <signal.h> | 35 | #include <signal.h> |
30 | 36 | ||
31 | #include "processinfo.h" | ||
32 | #include "detail.h" | ||
33 | |||
34 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) | 37 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) |
35 | : QWidget( parent, name, fl ) | 38 | : QWidget( parent, name, fl ) |
36 | { | 39 | { |
37 | QGridLayout *layout = new QGridLayout( this ); | 40 | QGridLayout *layout = new QGridLayout( this ); |
38 | layout->setSpacing( 4 ); | 41 | layout->setSpacing( 4 ); |
39 | layout->setMargin( 4 ); | 42 | layout->setMargin( 4 ); |
40 | 43 | ||
41 | 44 | ||
42 | ProcessView = new QListView( this, "ProcessView" ); | 45 | ProcessView = new QListView( this, "ProcessView" ); |
43 | int colnum = ProcessView->addColumn( tr( "PID" ) ); | 46 | int colnum = ProcessView->addColumn( tr( "PID" ) ); |
44 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | 47 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); |
45 | colnum = ProcessView->addColumn( tr( "Command" ),96 ); | 48 | colnum = ProcessView->addColumn( tr( "Command" ),96 ); |
46 | colnum = ProcessView->addColumn( tr( "Status" ) ); | 49 | colnum = ProcessView->addColumn( tr( "Status" ) ); |
47 | colnum = ProcessView->addColumn( tr( "Time" ) ); | 50 | colnum = ProcessView->addColumn( tr( "Time" ) ); |
48 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | 51 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); |
49 | ProcessView->setAllColumnsShowFocus( TRUE ); | 52 | ProcessView->setAllColumnsShowFocus( TRUE ); |
50 | QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); | 53 | QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); |
51 | connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 54 | connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
52 | this, SLOT( viewProcess( QListViewItem * ) ) ); | 55 | this, SLOT( viewProcess( QListViewItem * ) ) ); |
53 | layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); | 56 | layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); |
54 | 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." ) ); |
55 | 58 | ||
56 | SignalCB = new QComboBox( FALSE, this, "SignalCB" ); | 59 | SignalCB = new QComboBox( FALSE, this, "SignalCB" ); |
57 | SignalCB->insertItem( " 1: SIGHUP" ); | 60 | SignalCB->insertItem( " 1: SIGHUP" ); |
58 | SignalCB->insertItem( " 2: SIGINT" ); | 61 | SignalCB->insertItem( " 2: SIGINT" ); |
59 | SignalCB->insertItem( " 3: SIGQUIT" ); | 62 | SignalCB->insertItem( " 3: SIGQUIT" ); |
60 | SignalCB->insertItem( " 5: SIGTRAP" ); | 63 | SignalCB->insertItem( " 5: SIGTRAP" ); |
61 | SignalCB->insertItem( " 6: SIGABRT" ); | 64 | SignalCB->insertItem( " 6: SIGABRT" ); |
62 | SignalCB->insertItem( " 9: SIGKILL" ); | 65 | SignalCB->insertItem( " 9: SIGKILL" ); |
63 | SignalCB->insertItem( "14: SIGALRM" ); | 66 | SignalCB->insertItem( "14: SIGALRM" ); |
64 | SignalCB->insertItem( "15: SIGTERM" ); | 67 | SignalCB->insertItem( "15: SIGTERM" ); |
65 | SignalCB->insertItem( "18: SIGCONT" ); | 68 | SignalCB->insertItem( "18: SIGCONT" ); |
66 | SignalCB->insertItem( "19: SIGSTOP" ); | 69 | SignalCB->insertItem( "19: SIGSTOP" ); |
67 | layout->addWidget( SignalCB, 1, 0 ); | 70 | layout->addWidget( SignalCB, 1, 0 ); |
@@ -77,124 +80,123 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) | |||
77 | 80 | ||
78 | QTimer *t = new QTimer( this ); | 81 | QTimer *t = new QTimer( this ); |
79 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 82 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
80 | t->start( 5000 ); | 83 | t->start( 5000 ); |
81 | 84 | ||
82 | updateData(); | 85 | updateData(); |
83 | 86 | ||
84 | ProcessDtl = new Detail(); | 87 | ProcessDtl = new Detail(); |
85 | 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." ) ); |
86 | } | 89 | } |
87 | 90 | ||
88 | ProcessInfo::~ProcessInfo() | 91 | ProcessInfo::~ProcessInfo() |
89 | { | 92 | {} |
90 | } | ||
91 | 93 | ||
92 | void ProcessInfo::updateData() | 94 | void ProcessInfo::updateData() |
93 | { | 95 | { |
94 | 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, |
95 | signal, blocked, sigignore, sigcatch; | 97 | signal, blocked, sigignore, sigcatch; |
96 | 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, |
97 | endcode, startstack, kstkesp, kstkeip, wchan; | 99 | endcode, startstack, kstkesp, kstkeip, wchan; |
98 | char state; | 100 | char state; |
99 | char comm[64]; | 101 | char comm[64]; |
100 | 102 | ||
101 | QString selectedpid; | 103 | QString selectedpid; |
102 | QListViewItem *curritem = ProcessView->currentItem(); | 104 | QListViewItem *curritem = ProcessView->currentItem(); |
103 | if ( curritem ) | 105 | if ( curritem ) |
104 | { | 106 | { |
105 | selectedpid = curritem->text( 0 ); | 107 | selectedpid = curritem->text( 0 ); |
106 | } | 108 | } |
107 | 109 | ||
108 | ProcessView->clear(); | 110 | ProcessView->clear(); |
109 | 111 | ||
110 | QListViewItem *newitem; | 112 | QListViewItem *newitem; |
111 | QListViewItem *selecteditem = 0x0; | 113 | QListViewItem *selecteditem = 0x0; |
112 | QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); | 114 | QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); |
113 | QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); | 115 | QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); |
114 | if ( proclist ) | 116 | if ( proclist ) |
115 | { | 117 | { |
116 | QFileInfoListIterator it(*proclist); | 118 | QFileInfoListIterator it(*proclist); |
117 | QFileInfo *f; | 119 | QFileInfo *f; |
118 | while ( ( f = it.current() ) != 0 ) | 120 | while ( ( f = it.current() ) != 0 ) |
119 | { | 121 | { |
120 | ++it; | 122 | ++it; |
121 | QString processnum = f->fileName(); | 123 | QString processnum = f->fileName(); |
122 | if ( processnum >= "1" && processnum <= "99999" ) | 124 | if ( processnum >= "1" && processnum <= "99999" ) |
123 | { | 125 | { |
124 | FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); | 126 | FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); |
125 | 127 | ||
126 | if ( procfile ) | 128 | if ( procfile ) |
127 | { | 129 | { |
128 | fscanf( procfile, | 130 | fscanf( procfile, |
129 | "%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", |
130 | &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, | 132 | &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, |
131 | &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, | 133 | &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, |
132 | &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, | 134 | &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, |
133 | &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); | 135 | &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); |
134 | processnum = processnum.rightJustify( 5, ' ' ); | 136 | processnum = processnum.rightJustify( 5, ' ' ); |
135 | QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); | 137 | QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); |
136 | QString processstatus = QChar(state); | 138 | QString processstatus = QChar(state); |
137 | QString processtime = QString::number( ( utime + stime ) / 100 ); | 139 | QString processtime = QString::number( ( utime + stime ) / 100 ); |
138 | processtime = processtime.rightJustify( 9, ' ' ); | 140 | processtime = processtime.rightJustify( 9, ' ' ); |
139 | fclose( procfile ); | 141 | fclose( procfile ); |
140 | 142 | ||
141 | newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); | 143 | newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); |
142 | if ( processnum == selectedpid ) | 144 | if ( processnum == selectedpid ) |
143 | { | 145 | { |
144 | selecteditem = newitem; | 146 | selecteditem = newitem; |
145 | } | 147 | } |
146 | } | 148 | } |
147 | } | 149 | } |
148 | } | 150 | } |
149 | ProcessView->setCurrentItem( selecteditem ); | 151 | ProcessView->setCurrentItem( selecteditem ); |
150 | } | 152 | } |
151 | 153 | ||
152 | delete proclist; | 154 | delete proclist; |
153 | delete procdir; | 155 | delete procdir; |
154 | } | 156 | } |
155 | 157 | ||
156 | void ProcessInfo::slotSendClicked() | 158 | void ProcessInfo::slotSendClicked() |
157 | { | 159 | { |
158 | QListViewItem *currprocess = ProcessView->currentItem(); | 160 | QListViewItem *currprocess = ProcessView->currentItem(); |
159 | if ( !currprocess ) | 161 | if ( !currprocess ) |
160 | { | 162 | { |
161 | return; | 163 | return; |
162 | } | 164 | } |
163 | 165 | ||
164 | QString capstr = tr( "Really want to send %1\nto this process?" ).arg( SignalCB->currentText() ); | 166 | QString capstr = tr( "Really want to send %1\nto this process?" ).arg( SignalCB->currentText() ); |
165 | 167 | ||
166 | 168 | ||
167 | if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, | 169 | if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, |
168 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 170 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
169 | { | 171 | { |
170 | currprocess = ProcessView->currentItem(); | 172 | currprocess = ProcessView->currentItem(); |
171 | if ( currprocess ) | 173 | if ( currprocess ) |
172 | { | 174 | { |
173 | QString sigstr = SignalCB->currentText(); | 175 | QString sigstr = SignalCB->currentText(); |
174 | sigstr.truncate(2); | 176 | sigstr.truncate(2); |
175 | int sigid = sigstr.toUInt(); | 177 | int sigid = sigstr.toUInt(); |
176 | kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ); | 178 | kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ); |
177 | } | 179 | } |
178 | } | 180 | } |
179 | 181 | ||
180 | } | 182 | } |
181 | 183 | ||
182 | void ProcessInfo::viewProcess( QListViewItem *process ) | 184 | void ProcessInfo::viewProcess( QListViewItem *process ) |
183 | { | 185 | { |
184 | QString pid= process->text( 0 ).stripWhiteSpace(); | 186 | QString pid= process->text( 0 ).stripWhiteSpace(); |
185 | QString command = process->text( 1 ); | 187 | QString command = process->text( 1 ); |
186 | ProcessDtl->setCaption( pid + " - " + command ); | 188 | ProcessDtl->setCaption( pid + " - " + command ); |
187 | FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); | 189 | FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); |
188 | if ( statfile ) | 190 | if ( statfile ) |
189 | { | 191 | { |
190 | char line[81]; | 192 | char line[81]; |
191 | fgets( line, 81, statfile ); | 193 | fgets( line, 81, statfile ); |
192 | ProcessDtl->detailView->setText( line ); | 194 | ProcessDtl->detailView->setText( line ); |
193 | while ( fgets( line, 81, statfile ) ) | 195 | while ( fgets( line, 81, statfile ) ) |
194 | { | 196 | { |
195 | ProcessDtl->detailView->append( line ); | 197 | ProcessDtl->detailView->append( line ); |
196 | } | 198 | } |
197 | fclose( statfile ); | 199 | fclose( statfile ); |
198 | } | 200 | } |
199 | ProcessDtl->showMaximized(); | 201 | QPEApplication::showWidget( ProcessDtl ); |
200 | } | 202 | } |