-rw-r--r-- | noncore/settings/sysinfo/modulesinfo.cpp | 16 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processinfo.cpp | 16 |
2 files changed, 30 insertions, 2 deletions
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp index 7abad69..3d127a8 100644 --- a/noncore/settings/sysinfo/modulesinfo.cpp +++ b/noncore/settings/sysinfo/modulesinfo.cpp | |||
@@ -1,179 +1,193 @@ | |||
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 <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
23 | 23 | ||
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qfile.h> | 25 | #include <qfile.h> |
26 | #include <qheader.h> | 26 | #include <qheader.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qlistview.h> | 28 | #include <qlistview.h> |
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 | ||
38 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) | 38 | ModulesInfo::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 | ||
89 | ModulesInfo::~ModulesInfo() | 89 | ModulesInfo::~ModulesInfo() |
90 | { | 90 | { |
91 | } | 91 | } |
92 | 92 | ||
93 | void ModulesInfo::updateData() | 93 | void 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 | QString selectedmod; | ||
100 | QListViewItem *curritem = ModulesView->currentItem(); | ||
101 | if ( curritem ) | ||
102 | { | ||
103 | selectedmod = curritem->text( 0 ); | ||
104 | } | ||
105 | |||
99 | ModulesView->clear(); | 106 | ModulesView->clear(); |
100 | 107 | ||
101 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); | 108 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); |
102 | 109 | ||
103 | if ( procfile ) | 110 | if ( procfile ) |
104 | { | 111 | { |
112 | QListViewItem *newitem; | ||
113 | QListViewItem *selecteditem = 0x0; | ||
105 | while ( true ) { | 114 | while ( true ) { |
106 | int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); | 115 | int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); |
107 | 116 | ||
108 | if ( success == EOF ) | 117 | if ( success == EOF ) |
109 | break; | 118 | break; |
110 | 119 | ||
111 | QString qmodname = QString( modname ); | 120 | QString qmodname = QString( modname ); |
112 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); | 121 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); |
113 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); | 122 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); |
114 | QString qusage = QString( usage ); | 123 | QString qusage = QString( usage ); |
115 | 124 | ||
116 | ( void ) new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); | 125 | newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); |
126 | if ( qmodname == selectedmod ) | ||
127 | { | ||
128 | selecteditem = newitem; | ||
129 | } | ||
117 | } | 130 | } |
131 | ModulesView->setCurrentItem( selecteditem ); | ||
118 | 132 | ||
119 | fclose( procfile ); | 133 | fclose( procfile ); |
120 | } | 134 | } |
121 | } | 135 | } |
122 | 136 | ||
123 | void ModulesInfo::slotSendClicked() | 137 | void ModulesInfo::slotSendClicked() |
124 | { | 138 | { |
125 | if ( !ModulesView->currentItem() ) | 139 | if ( !ModulesView->currentItem() ) |
126 | { | 140 | { |
127 | return; | 141 | return; |
128 | } | 142 | } |
129 | 143 | ||
130 | QString capstr = tr( "You really want to execute\n" ); | 144 | QString capstr = tr( "You really want to execute\n" ); |
131 | capstr.append( CommandCB->currentText() ); | 145 | capstr.append( CommandCB->currentText() ); |
132 | capstr.append( "\nfor this module?" ); | 146 | capstr.append( "\nfor this module?" ); |
133 | 147 | ||
134 | QString modname = ModulesView->currentItem()->text( 0 ); | 148 | QString modname = ModulesView->currentItem()->text( 0 ); |
135 | 149 | ||
136 | if ( QMessageBox::warning( this, modname, capstr, | 150 | if ( QMessageBox::warning( this, modname, capstr, |
137 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 151 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
138 | { | 152 | { |
139 | QString command = "/sbin/"; | 153 | QString command = "/sbin/"; |
140 | command.append( CommandCB->currentText() ); | 154 | command.append( CommandCB->currentText() ); |
141 | command.append( " " ); | 155 | command.append( " " ); |
142 | command.append( modname ); | 156 | command.append( modname ); |
143 | 157 | ||
144 | FILE* stream = popen( command, "r" ); | 158 | FILE* stream = popen( command, "r" ); |
145 | if ( stream ) | 159 | if ( stream ) |
146 | pclose( stream ); | 160 | pclose( stream ); |
147 | } | 161 | } |
148 | 162 | ||
149 | } | 163 | } |
150 | 164 | ||
151 | void ModulesInfo::viewModules( QListViewItem *modules ) | 165 | void ModulesInfo::viewModules( QListViewItem *modules ) |
152 | { | 166 | { |
153 | QString modname = modules->text( 0 ); | 167 | QString modname = modules->text( 0 ); |
154 | QString capstr = "Module: "; | 168 | QString capstr = "Module: "; |
155 | capstr.append( modname ); | 169 | capstr.append( modname ); |
156 | ModulesDtl->setCaption( capstr ); | 170 | ModulesDtl->setCaption( capstr ); |
157 | QString command = "/sbin/modinfo "; | 171 | QString command = "/sbin/modinfo "; |
158 | command.append( modname ); | 172 | command.append( modname ); |
159 | FILE* modinfo = popen( command, "r" ); | 173 | FILE* modinfo = popen( command, "r" ); |
160 | 174 | ||
161 | if ( modinfo ) | 175 | if ( modinfo ) |
162 | { | 176 | { |
163 | char line[200]; | 177 | char line[200]; |
164 | ModulesDtl->detailView->setText( " Details:\n------------\n" ); | 178 | ModulesDtl->detailView->setText( " Details:\n------------\n" ); |
165 | 179 | ||
166 | while( true ) | 180 | while( true ) |
167 | { | 181 | { |
168 | int success = fscanf( modinfo, "%[^\n]\n", line ); | 182 | int success = fscanf( modinfo, "%[^\n]\n", line ); |
169 | if ( success == EOF ) | 183 | if ( success == EOF ) |
170 | break; | 184 | break; |
171 | ModulesDtl->detailView->append( line ); | 185 | ModulesDtl->detailView->append( line ); |
172 | } | 186 | } |
173 | 187 | ||
174 | pclose( modinfo ); | 188 | pclose( modinfo ); |
175 | } | 189 | } |
176 | 190 | ||
177 | ModulesDtl->showMaximized(); | 191 | ModulesDtl->showMaximized(); |
178 | } | 192 | } |
179 | 193 | ||
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp index 769410f..2232771 100644 --- a/noncore/settings/sysinfo/processinfo.cpp +++ b/noncore/settings/sysinfo/processinfo.cpp | |||
@@ -1,187 +1,201 @@ | |||
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 <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | 21 | ||
22 | #include <qdir.h> | 22 | #include <qdir.h> |
23 | #include <qfile.h> | 23 | #include <qfile.h> |
24 | #include <qheader.h> | 24 | #include <qheader.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qlistview.h> | 26 | #include <qlistview.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | 30 | ||
31 | #include <sys/types.h> | 31 | #include <sys/types.h> |
32 | #include <signal.h> | 32 | #include <signal.h> |
33 | 33 | ||
34 | #include "processinfo.h" | 34 | #include "processinfo.h" |
35 | #include "detail.h" | 35 | #include "detail.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 | 94 | ||
95 | void ProcessInfo::updateData() | 95 | void ProcessInfo::updateData() |
96 | { | 96 | { |
97 | int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, | 97 | int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, |
98 | signal, blocked, sigignore, sigcatch; | 98 | signal, blocked, sigignore, sigcatch; |
99 | uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, | 99 | uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, |
100 | endcode, startstack, kstkesp, kstkeip, wchan; | 100 | endcode, startstack, kstkesp, kstkeip, wchan; |
101 | char state; | 101 | char state; |
102 | char comm[64]; | 102 | char comm[64]; |
103 | 103 | ||
104 | QString selectedpid; | ||
105 | QListViewItem *curritem = ProcessView->currentItem(); | ||
106 | if ( curritem ) | ||
107 | { | ||
108 | selectedpid = curritem->text( 0 ); | ||
109 | } | ||
110 | |||
104 | ProcessView->clear(); | 111 | ProcessView->clear(); |
105 | 112 | ||
113 | QListViewItem *newitem; | ||
114 | QListViewItem *selecteditem = 0x0; | ||
106 | QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); | 115 | QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); |
107 | QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); | 116 | QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); |
108 | if ( proclist ) | 117 | if ( proclist ) |
109 | { | 118 | { |
110 | QFileInfoListIterator it(*proclist); | 119 | QFileInfoListIterator it(*proclist); |
111 | QFileInfo *f; | 120 | QFileInfo *f; |
112 | while ( ( f = it.current() ) != 0 ) | 121 | while ( ( f = it.current() ) != 0 ) |
113 | { | 122 | { |
114 | ++it; | 123 | ++it; |
115 | QString processnum = f->fileName(); | 124 | QString processnum = f->fileName(); |
116 | if ( processnum >= "1" && processnum <= "99999" ) | 125 | if ( processnum >= "1" && processnum <= "99999" ) |
117 | { | 126 | { |
118 | FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); | 127 | FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); |
119 | 128 | ||
120 | if ( procfile ) | 129 | if ( procfile ) |
121 | { | 130 | { |
122 | fscanf( procfile, | 131 | fscanf( procfile, |
123 | "%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 | "%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", |
124 | &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, | 133 | &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, |
125 | &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, | 134 | &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, |
126 | &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, | 135 | &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, |
127 | &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); | 136 | &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); |
128 | processnum = processnum.rightJustify( 5, ' ' ); | 137 | processnum = processnum.rightJustify( 5, ' ' ); |
129 | QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); | 138 | QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); |
130 | QString processstatus = QChar(state); | 139 | QString processstatus = QChar(state); |
131 | QString processtime = QString::number( ( utime + stime ) / 100 ); | 140 | QString processtime = QString::number( ( utime + stime ) / 100 ); |
132 | processtime = processtime.rightJustify( 9, ' ' ); | 141 | processtime = processtime.rightJustify( 9, ' ' ); |
133 | fclose( procfile ); | 142 | fclose( procfile ); |
134 | 143 | ||
135 | ( void ) new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); | 144 | newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); |
145 | if ( processnum == selectedpid ) | ||
146 | { | ||
147 | selecteditem = newitem; | ||
148 | } | ||
136 | } | 149 | } |
137 | } | 150 | } |
138 | } | 151 | } |
152 | ProcessView->setCurrentItem( selecteditem ); | ||
139 | } | 153 | } |
140 | 154 | ||
141 | delete proclist; | 155 | delete proclist; |
142 | delete procdir; | 156 | delete procdir; |
143 | } | 157 | } |
144 | 158 | ||
145 | void ProcessInfo::slotSendClicked() | 159 | void ProcessInfo::slotSendClicked() |
146 | { | 160 | { |
147 | QListViewItem *currprocess = ProcessView->currentItem(); | 161 | QListViewItem *currprocess = ProcessView->currentItem(); |
148 | if ( !currprocess ) | 162 | if ( !currprocess ) |
149 | { | 163 | { |
150 | return; | 164 | return; |
151 | } | 165 | } |
152 | 166 | ||
153 | QString capstr = tr( "You really want to send\n" ); | 167 | QString capstr = tr( "You really want to send\n" ); |
154 | capstr.append( SignalCB->currentText() ); | 168 | capstr.append( SignalCB->currentText() ); |
155 | capstr.append( "\nto this process?" ); | 169 | capstr.append( "\nto this process?" ); |
156 | 170 | ||
157 | 171 | ||
158 | if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, | 172 | if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, |
159 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 173 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
160 | { | 174 | { |
161 | QString sigstr = SignalCB->currentText(); | 175 | QString sigstr = SignalCB->currentText(); |
162 | sigstr.truncate(2); | 176 | sigstr.truncate(2); |
163 | int sigid = sigstr.toUInt(); | 177 | int sigid = sigstr.toUInt(); |
164 | kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ); | 178 | kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ); |
165 | } | 179 | } |
166 | 180 | ||
167 | } | 181 | } |
168 | 182 | ||
169 | void ProcessInfo::viewProcess( QListViewItem *process ) | 183 | void ProcessInfo::viewProcess( QListViewItem *process ) |
170 | { | 184 | { |
171 | QString pid= process->text( 0 ).stripWhiteSpace(); | 185 | QString pid= process->text( 0 ).stripWhiteSpace(); |
172 | QString command = process->text( 1 ); | 186 | QString command = process->text( 1 ); |
173 | ProcessDtl->setCaption( pid + " - " + command ); | 187 | ProcessDtl->setCaption( pid + " - " + command ); |
174 | FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); | 188 | FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); |
175 | if ( statfile ) | 189 | if ( statfile ) |
176 | { | 190 | { |
177 | char line[81]; | 191 | char line[81]; |
178 | fgets( line, 81, statfile ); | 192 | fgets( line, 81, statfile ); |
179 | ProcessDtl->detailView->setText( line ); | 193 | ProcessDtl->detailView->setText( line ); |
180 | while ( fgets( line, 81, statfile ) ) | 194 | while ( fgets( line, 81, statfile ) ) |
181 | { | 195 | { |
182 | ProcessDtl->detailView->append( line ); | 196 | ProcessDtl->detailView->append( line ); |
183 | } | 197 | } |
184 | fclose( statfile ); | 198 | fclose( statfile ); |
185 | } | 199 | } |
186 | ProcessDtl->showMaximized(); | 200 | ProcessDtl->showMaximized(); |
187 | } | 201 | } |