author | drw <drw> | 2002-12-20 01:36:55 (UTC) |
---|---|---|
committer | drw <drw> | 2002-12-20 01:36:55 (UTC) |
commit | 3e556ed5f8c8b1236b9c6155b609930103d17b21 (patch) (unidiff) | |
tree | 859cc1e4f3097276ab77cac4cff5b24fde26ba11 /noncore/settings/sysinfo/processinfo.cpp | |
parent | 876e1a4724a7bd75dc642e295de354241096e028 (diff) | |
download | opie-3e556ed5f8c8b1236b9c6155b609930103d17b21.zip opie-3e556ed5f8c8b1236b9c6155b609930103d17b21.tar.gz opie-3e556ed5f8c8b1236b9c6155b609930103d17b21.tar.bz2 |
1. Added check for /sbin/modinfo, and if exists will display module details again. 2. Combined process and module detail viewers into one common class. 3. Move process signal sending to main process tab.
Diffstat (limited to 'noncore/settings/sysinfo/processinfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/sysinfo/processinfo.cpp | 65 |
1 files changed, 58 insertions, 7 deletions
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp index 86133a9..35d7ba1 100644 --- a/noncore/settings/sysinfo/processinfo.cpp +++ b/noncore/settings/sysinfo/processinfo.cpp | |||
@@ -23,17 +23,25 @@ | |||
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 <qtimer.h> | 28 | #include <qtimer.h> |
28 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
29 | 30 | ||
31 | #include <sys/types.h> | ||
32 | #include <signal.h> | ||
33 | |||
30 | #include "processinfo.h" | 34 | #include "processinfo.h" |
35 | #include "detail.h" | ||
31 | 36 | ||
32 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) | 37 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) |
33 | : QWidget( parent, name, fl ) | 38 | : QWidget( parent, name, fl ) |
34 | { | 39 | { |
35 | QVBoxLayout *layout = new QVBoxLayout( this, 5 ); | 40 | QGridLayout *layout = new QGridLayout( this ); |
41 | layout->setSpacing( 4 ); | ||
42 | layout->setMargin( 4 ); | ||
43 | |||
36 | 44 | ||
37 | ProcessView = new QListView( this, "ProcessView" ); | 45 | ProcessView = new QListView( this, "ProcessView" ); |
38 | int colnum = ProcessView->addColumn( tr( "PID" ) ); | 46 | int colnum = ProcessView->addColumn( tr( "PID" ) ); |
39 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | 47 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); |
@@ -44,19 +52,41 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) | |||
44 | ProcessView->setAllColumnsShowFocus( TRUE ); | 52 | ProcessView->setAllColumnsShowFocus( TRUE ); |
45 | QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); | 53 | QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); |
46 | connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 54 | connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
47 | this, SLOT( viewProcess( QListViewItem * ) ) ); | 55 | this, SLOT( viewProcess( QListViewItem * ) ) ); |
48 | layout->addWidget( ProcessView ); | 56 | layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); |
49 | 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 | |||
59 | SignalCB = new QComboBox( FALSE, this, "SignalCB" ); | ||
60 | SignalCB->insertItem( " 1: SIGHUP" ); | ||
61 | SignalCB->insertItem( " 2: SIGINT" ); | ||
62 | SignalCB->insertItem( " 3: SIGQUIT" ); | ||
63 | SignalCB->insertItem( " 5: SIGTRAP" ); | ||
64 | SignalCB->insertItem( " 6: SIGABRT" ); | ||
65 | SignalCB->insertItem( " 9: SIGKILL" ); | ||
66 | SignalCB->insertItem( "14: SIGALRM" ); | ||
67 | SignalCB->insertItem( "15: SIGTERM" ); | ||
68 | SignalCB->insertItem( "18: SIGCONT" ); | ||
69 | SignalCB->insertItem( "19: SIGSTOP" ); | ||
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." ) ); | ||
72 | |||
73 | SendButton = new QPushButton( this, "SendButton" ); | ||
74 | SendButton->setMinimumSize( QSize( 50, 24 ) ); | ||
75 | SendButton->setMaximumSize( QSize( 50, 24 ) ); | ||
76 | SendButton->setText( tr( "Send" ) ); | ||
77 | connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); | ||
78 | layout->addWidget( SendButton, 1, 1 ); | ||
79 | QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) ); | ||
50 | 80 | ||
51 | QTimer *t = new QTimer( this ); | 81 | QTimer *t = new QTimer( this ); |
52 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 82 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
53 | t->start( 5000 ); | 83 | t->start( 5000 ); |
54 | 84 | ||
55 | updateData(); | 85 | updateData(); |
56 | 86 | ||
57 | ProcessDtl = new ProcessDetail( 0, 0, 0 ); | 87 | ProcessDtl = new Detail(); |
58 | ProcessDtl->ProcessView->setTextFormat( RichText ); | 88 | QWhatsThis::add( ProcessDtl->detailView, tr( "This area shows detailed information about this process." ) ); |
59 | } | 89 | } |
60 | 90 | ||
61 | ProcessInfo::~ProcessInfo() | 91 | ProcessInfo::~ProcessInfo() |
62 | { | 92 | { |
@@ -111,23 +141,44 @@ void ProcessInfo::updateData() | |||
111 | delete proclist; | 141 | delete proclist; |
112 | delete procdir; | 142 | delete procdir; |
113 | } | 143 | } |
114 | 144 | ||
145 | void ProcessInfo::slotSendClicked() | ||
146 | { | ||
147 | QString capstr = tr( "You really want to send\n" ); | ||
148 | capstr.append( SignalCB->currentText() ); | ||
149 | capstr.append( "\nto this process?" ); | ||
150 | |||
151 | QListViewItem *currprocess = ProcessView->currentItem(); | ||
152 | |||
153 | if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, | ||
154 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | ||
155 | { | ||
156 | QString sigstr = SignalCB->currentText(); | ||
157 | sigstr.truncate(2); | ||
158 | int sigid = sigstr.toUInt(); | ||
159 | if ( kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ) == 0 ) | ||
160 | { | ||
161 | hide(); | ||
162 | } | ||
163 | } | ||
164 | |||
165 | } | ||
166 | |||
115 | void ProcessInfo::viewProcess( QListViewItem *process ) | 167 | void ProcessInfo::viewProcess( QListViewItem *process ) |
116 | { | 168 | { |
117 | QString pid= process->text( 0 ).stripWhiteSpace(); | 169 | QString pid= process->text( 0 ).stripWhiteSpace(); |
118 | QString command = process->text( 1 ); | 170 | QString command = process->text( 1 ); |
119 | ProcessDtl->setCaption( pid + " - " + command ); | 171 | ProcessDtl->setCaption( pid + " - " + command ); |
120 | ProcessDtl->pid = pid.toUInt(); | ||
121 | FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); | 172 | FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); |
122 | if ( statfile ) | 173 | if ( statfile ) |
123 | { | 174 | { |
124 | char line[81]; | 175 | char line[81]; |
125 | fgets( line, 81, statfile ); | 176 | fgets( line, 81, statfile ); |
126 | ProcessDtl->ProcessView->setText( line ); | 177 | ProcessDtl->detailView->setText( line ); |
127 | while ( fgets( line, 81, statfile ) ) | 178 | while ( fgets( line, 81, statfile ) ) |
128 | { | 179 | { |
129 | ProcessDtl->ProcessView->append( line ); | 180 | ProcessDtl->detailView->append( line ); |
130 | } | 181 | } |
131 | fclose( statfile ); | 182 | fclose( statfile ); |
132 | } | 183 | } |
133 | ProcessDtl->showMaximized(); | 184 | ProcessDtl->showMaximized(); |