summaryrefslogtreecommitdiff
authorbipolar <bipolar>2002-03-07 02:27:02 (UTC)
committer bipolar <bipolar>2002-03-07 02:27:02 (UTC)
commit09444065297662fca1396abf8c0c9dd00380699f (patch) (unidiff)
tree1e7fbec969b991e5f75406674679d450daa94889
parentfc2c85782429209229228602b6149248635597a5 (diff)
downloadopie-09444065297662fca1396abf8c0c9dd00380699f.zip
opie-09444065297662fca1396abf8c0c9dd00380699f.tar.gz
opie-09444065297662fca1396abf8c0c9dd00380699f.tar.bz2
ljp: added processinfo for drw
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/processdetail.cpp85
-rw-r--r--noncore/settings/sysinfo/processdetail.h47
-rw-r--r--noncore/settings/sysinfo/processinfo.cpp44
-rw-r--r--noncore/settings/sysinfo/sysinfo.pro4
4 files changed, 156 insertions, 24 deletions
diff --git a/noncore/settings/sysinfo/processdetail.cpp b/noncore/settings/sysinfo/processdetail.cpp
new file mode 100644
index 0000000..1ca1e72
--- a/dev/null
+++ b/noncore/settings/sysinfo/processdetail.cpp
@@ -0,0 +1,85 @@
1/**********************************************************************
2** ProcessDetail
3**
4** Display process information
5**
6** Copyright (C) 2002, Dan Williams
7** williamsdr@acm.org
8** http://draknor.net
9**
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
12** Foundation and appearing in the file LICENSE.GPL included in the
13** packaging of this file.
14**
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.
17**
18**********************************************************************/
19
20#include "processdetail.h"
21
22#include <sys/types.h>
23#include <signal.h>
24
25#include <qcombobox.h>
26#include <qpushbutton.h>
27#include <qtextview.h>
28#include <qlayout.h>
29#include <qlistview.h>
30#include <qmessagebox.h>
31
32ProcessDetail::ProcessDetail( QWidget* parent, const char* name, bool modal, WFlags fl )
33 : QDialog( parent, name, modal, fl )
34{
35 pid = 0;
36
37 QGridLayout *layout = new QGridLayout( this );
38 layout->setSpacing( 6 );
39 layout->setMargin( 11 );
40
41 SignalCB = new QComboBox( FALSE, this, "SignalCB" );
42 SignalCB->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)7, SignalCB->sizePolicy().hasHeightForWidth() ) );
43 SignalCB->setMinimumSize( QSize( 50, 24 ) );
44 SignalCB->setMaximumSize( QSize( 600, 24 ) );
45 SignalCB->insertItem( " 1: SIGHUP" );
46 SignalCB->insertItem( " 9: SIGKILL" );
47 SignalCB->insertItem( "15: SIGTERM" );
48 layout->addWidget( SignalCB, 1, 0 );
49
50 ProcessView = new QTextView( this, "ProcessView" );
51 ProcessView->setFrameShadow( QTextView::Plain );
52 layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 );
53
54 SendButton = new QPushButton( this, "SendButton" );
55 SendButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, SendButton->sizePolicy().hasHeightForWidth() ) );
56 SendButton->setMinimumSize( QSize( 50, 24 ) );
57 SendButton->setMaximumSize( QSize( 50, 24 ) );
58 SendButton->setText( tr( "Send" ) );
59 connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) );
60 layout->addWidget( SendButton, 1, 1 );
61}
62
63ProcessDetail::~ProcessDetail()
64{
65}
66
67void ProcessDetail::slotSendClicked()
68{
69 QString sigstr = SignalCB->currentText();
70 sigstr.truncate(2);
71 int sigid = sigstr.toUInt();
72
73 if ( !QMessageBox::information( this, caption(),
74 ( tr( "You really want to send\n" + SignalCB->currentText() + "\nto this process?") ),
75 ( tr( "Yes" ) ), ( tr( "No" ) ), 0 ) )
76 {
77 if ( kill( pid, sigid ) == 0 )
78 {
79 accept();
80 }
81 }
82
83}
84
85
diff --git a/noncore/settings/sysinfo/processdetail.h b/noncore/settings/sysinfo/processdetail.h
new file mode 100644
index 0000000..5d418ac
--- a/dev/null
+++ b/noncore/settings/sysinfo/processdetail.h
@@ -0,0 +1,47 @@
1/**********************************************************************
2** ProcessDetail
3**
4** Display process information
5**
6** Copyright (C) 2002, Dan Williams
7** williamsdr@acm.org
8** http://draknor.net
9**
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
12** Foundation and appearing in the file LICENSE.GPL included in the
13** packaging of this file.
14**
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.
17**
18**********************************************************************/
19
20#ifndef PROCESSDETAIL_H
21#define PROCESSDETAIL_H
22
23#include <qdialog.h>
24#include <qcombo.h>
25#include <qtextview.h>
26#include <qpushbutton.h>
27#include <qlistview.h>
28
29class ProcessDetail : public QDialog
30{
31 Q_OBJECT
32
33public:
34 ProcessDetail( QWidget* parent, const char* name, bool modal, WFlags fl );
35 ~ProcessDetail();
36
37 QComboBox* SignalCB;
38 QTextView* ProcessView;
39 QPushButton* SendButton;
40
41 int pid;
42
43private slots:
44 void slotSendClicked();
45};
46
47#endif // PROCESSDETAIL_H
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp
index 4ecb704..225da63 100644
--- a/noncore/settings/sysinfo/processinfo.cpp
+++ b/noncore/settings/sysinfo/processinfo.cpp
@@ -25,8 +25,5 @@
25#include <qdir.h> 25#include <qdir.h>
26#include <qmessagebox.h>
27
28#include <sys/types.h>
29#include <signal.h>
30 26
31#include "processinfo.h" 27#include "processinfo.h"
28#include "processdetail.h"
32 29
@@ -35,3 +32,3 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl )
35{ 32{
36 QVBoxLayout *vb = new QVBoxLayout( this, 5 ); 33 QVBoxLayout *layout = new QVBoxLayout( this, 5 );
37 34
@@ -41,5 +38,3 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl )
41 colnum = ProcessView->addColumn( tr( "Command" ),96 ); 38 colnum = ProcessView->addColumn( tr( "Command" ),96 );
42 ProcessView->setColumnAlignment( colnum, Qt::AlignRight );
43 colnum = ProcessView->addColumn( tr( "Status" ) ); 39 colnum = ProcessView->addColumn( tr( "Status" ) );
44 ProcessView->setColumnAlignment( colnum, Qt::AlignRight );
45 colnum = ProcessView->addColumn( tr( "Time" ) ); 40 colnum = ProcessView->addColumn( tr( "Time" ) );
@@ -49,3 +44,3 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl )
49 44
50 vb->addWidget( ProcessView ); 45 layout->addWidget( ProcessView );
51 46
@@ -121,19 +116,22 @@ void ProcessInfo::viewProcess(QListViewItem *process)
121{ 116{
122 QString pid= process->text(0); 117 QString pid= process->text(0).stripWhiteSpace();
123 QString command = process->text(1); 118 QString command = process->text(1);
124 switch( QMessageBox::information( this, (tr("Kill Process?")), 119 ProcessDetail *processdtl = new ProcessDetail( this, 0, TRUE, 0);
125 (tr("You really want to kill\n"+command+" PID: "+pid+"?")), 120 processdtl->setCaption( pid + " - " + command );
126 (tr("Yes")), (tr("No")), 0 )){ 121 processdtl->pid = pid.toUInt();
127 case 0: // Yes clicked, 122 processdtl->ProcessView->setTextFormat( RichText );
123 FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r");
124 if ( statfile )
125 {
126 char line[81];
127 fgets( line, 81, statfile );
128 processdtl->ProcessView->setText( line );
129 while ( fgets( line, 81, statfile ) )
128 { 130 {
129 bool ok; 131 processdtl->ProcessView->append( line );
130 pid_t child=pid.toInt(&ok,10); 132 }
131 if((kill(child,SIGKILL)) < 0) 133 fclose( statfile );
132 perror("kill:SIGKILL"); 134 }
133 } 135
134 break; 136 processdtl->showMaximized();
135 case 1: // Cancel
136 break;
137 };
138//printf("Double click for PID: %s\n", process->text(0).stripWhiteSpace().latin1());
139} 137}
diff --git a/noncore/settings/sysinfo/sysinfo.pro b/noncore/settings/sysinfo/sysinfo.pro
index 7f84dec..f14716e 100644
--- a/noncore/settings/sysinfo/sysinfo.pro
+++ b/noncore/settings/sysinfo/sysinfo.pro
@@ -8,2 +8,3 @@ HEADERS = memory.h \
8 processinfo.h \ 8 processinfo.h \
9 processdetail.h \
9 versioninfo.h \ 10 versioninfo.h \
@@ -15,3 +16,4 @@ SOURCES = main.cpp \
15 storage.cpp \ 16 storage.cpp \
16 processinfo.cpp \ 17 processinfo.cpp \
18 processdetail.cpp \
17 versioninfo.cpp \ 19 versioninfo.cpp \