summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/processdetail.cpp22
-rw-r--r--noncore/settings/sysinfo/processdetail.h6
-rw-r--r--noncore/settings/sysinfo/processinfo.cpp41
-rw-r--r--noncore/settings/sysinfo/processinfo.h3
4 files changed, 32 insertions, 40 deletions
diff --git a/noncore/settings/sysinfo/processdetail.cpp b/noncore/settings/sysinfo/processdetail.cpp
index 06e5c0d..ef612e6 100644
--- a/noncore/settings/sysinfo/processdetail.cpp
+++ b/noncore/settings/sysinfo/processdetail.cpp
@@ -26,39 +26,34 @@
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qtextview.h> 27#include <qtextview.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qlistview.h> 29#include <qlistview.h>
30#include <qmessagebox.h> 30#include <qmessagebox.h>
31 31
32ProcessDetail::ProcessDetail( QWidget* parent, const char* name, bool modal, WFlags fl ) 32ProcessDetail::ProcessDetail( QWidget* parent, const char* name, WFlags fl )
33 : QDialog( parent, name, modal, fl ) 33 : QWidget( parent, name, fl )
34{ 34{
35 pid = 0; 35 pid = 0;
36 36
37 QGridLayout *layout = new QGridLayout( this ); 37 QGridLayout *layout = new QGridLayout( this );
38 layout->setSpacing( 6 ); 38 layout->setSpacing( 4 );
39 layout->setMargin( 11 ); 39 layout->setMargin( 4 );
40 40
41 SignalCB = new QComboBox( FALSE, this, "SignalCB" ); 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" ); 42 SignalCB->insertItem( " 1: SIGHUP" );
46 SignalCB->insertItem( " 2: SIGINT" ); 43 SignalCB->insertItem( " 2: SIGINT" );
47 SignalCB->insertItem( " 9: SIGKILL" ); 44 SignalCB->insertItem( " 9: SIGKILL" );
48 SignalCB->insertItem( "15: SIGTERM" ); 45 SignalCB->insertItem( "15: SIGTERM" );
49 SignalCB->insertItem( "18: SIGCONT" ); 46 SignalCB->insertItem( "18: SIGCONT" );
50 SignalCB->insertItem( "19: SIGSTOP" ); 47 SignalCB->insertItem( "19: SIGSTOP" );
51 layout->addWidget( SignalCB, 1, 0 ); 48 layout->addWidget( SignalCB, 1, 0 );
52 49
53 ProcessView = new QTextView( this, "ProcessView" ); 50 ProcessView = new QTextView( this, "ProcessView" );
54 ProcessView->setFrameShadow( QTextView::Plain );
55 layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); 51 layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 );
56 52
57 SendButton = new QPushButton( this, "SendButton" ); 53 SendButton = new QPushButton( this, "SendButton" );
58 SendButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, SendButton->sizePolicy().hasHeightForWidth() ) );
59 SendButton->setMinimumSize( QSize( 50, 24 ) ); 54 SendButton->setMinimumSize( QSize( 50, 24 ) );
60 SendButton->setMaximumSize( QSize( 50, 24 ) ); 55 SendButton->setMaximumSize( QSize( 50, 24 ) );
61 SendButton->setText( tr( "Send" ) ); 56 SendButton->setText( tr( "Send" ) );
62 connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); 57 connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) );
63 layout->addWidget( SendButton, 1, 1 ); 58 layout->addWidget( SendButton, 1, 1 );
64} 59}
@@ -70,19 +65,20 @@ ProcessDetail::~ProcessDetail()
70void ProcessDetail::slotSendClicked() 65void ProcessDetail::slotSendClicked()
71{ 66{
72 QString sigstr = SignalCB->currentText(); 67 QString sigstr = SignalCB->currentText();
73 sigstr.truncate(2); 68 sigstr.truncate(2);
74 int sigid = sigstr.toUInt(); 69 int sigid = sigstr.toUInt();
75 70
76 if ( !QMessageBox::information( this, caption(), 71 if ( QMessageBox::warning( this, caption(),
77 ( tr( "You really want to send\n" + SignalCB->currentText() + "\nto this process?") ), 72 tr( "You really want to send\n" + SignalCB->currentText() + "\nto this process?"),
78 ( tr( "Yes" ) ), ( tr( "No" ) ), 0 ) ) 73 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape )
74 == QMessageBox::Yes )
79 { 75 {
80 if ( kill( pid, sigid ) == 0 ) 76 if ( kill( pid, sigid ) == 0 )
81 { 77 {
82 accept(); 78 hide();
83 } 79 }
84 } 80 }
85 81
86} 82}
87 83
88 84
diff --git a/noncore/settings/sysinfo/processdetail.h b/noncore/settings/sysinfo/processdetail.h
index 5d418ac..22e196f 100644
--- a/noncore/settings/sysinfo/processdetail.h
+++ b/noncore/settings/sysinfo/processdetail.h
@@ -17,24 +17,24 @@
17** 17**
18**********************************************************************/ 18**********************************************************************/
19 19
20#ifndef PROCESSDETAIL_H 20#ifndef PROCESSDETAIL_H
21#define PROCESSDETAIL_H 21#define PROCESSDETAIL_H
22 22
23#include <qdialog.h> 23#include <qwidget.h>
24#include <qcombo.h> 24#include <qcombo.h>
25#include <qtextview.h> 25#include <qtextview.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qlistview.h> 27#include <qlistview.h>
28 28
29class ProcessDetail : public QDialog 29class ProcessDetail : public QWidget
30{ 30{
31 Q_OBJECT 31 Q_OBJECT
32 32
33public: 33public:
34 ProcessDetail( QWidget* parent, const char* name, bool modal, WFlags fl ); 34 ProcessDetail( QWidget* parent, const char* name, WFlags fl );
35 ~ProcessDetail(); 35 ~ProcessDetail();
36 36
37 QComboBox* SignalCB; 37 QComboBox* SignalCB;
38 QTextView* ProcessView; 38 QTextView* ProcessView;
39 QPushButton* SendButton; 39 QPushButton* SendButton;
40 40
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp
index 225da63..ad81d7b 100644
--- a/noncore/settings/sysinfo/processinfo.cpp
+++ b/noncore/settings/sysinfo/processinfo.cpp
@@ -22,13 +22,12 @@
22#include <qlayout.h> 22#include <qlayout.h>
23#include <qtimer.h> 23#include <qtimer.h>
24#include <qfile.h> 24#include <qfile.h>
25#include <qdir.h> 25#include <qdir.h>
26 26
27#include "processinfo.h" 27#include "processinfo.h"
28#include "processdetail.h"
29 28
30ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) 29ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl )
31 : QWidget( parent, name, fl ) 30 : QWidget( parent, name, fl )
32{ 31{
33 QVBoxLayout *layout = new QVBoxLayout( this, 5 ); 32 QVBoxLayout *layout = new QVBoxLayout( this, 5 );
34 33
@@ -46,62 +45,58 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl )
46 45
47 QTimer *t = new QTimer( this ); 46 QTimer *t = new QTimer( this );
48 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); 47 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) );
49 t->start( 5000 ); 48 t->start( 5000 );
50 49
51 updateData(); 50 updateData();
51
52 ProcessDtl = new ProcessDetail( 0, 0, 0 );
53 ProcessDtl->ProcessView->setTextFormat( RichText );
52} 54}
53 55
54ProcessInfo::~ProcessInfo() 56ProcessInfo::~ProcessInfo()
55{ 57{
56} 58}
57 59
58void ProcessInfo::updateData() 60void ProcessInfo::updateData()
59{ 61{
60 QString processnum("");
61 QString processcmd("");
62 QString processstatus("");
63 QString processtime("");
64 int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, 62 int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime,
65 signal, blocked, sigignore, sigcatch; 63 signal, blocked, sigignore, sigcatch;
66 uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, 64 uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode,
67 endcode, startstack, kstkesp, kstkeip, wchan; 65 endcode, startstack, kstkesp, kstkeip, wchan;
68 char state; 66 char state;
69 char comm[255]; 67 char comm[64];
70 68
71 ProcessView->clear(); 69 ProcessView->clear();
72 70
73 QDir *procdir = new QDir("/proc"); 71 QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs);
74 procdir->setFilter(QDir::Dirs);
75 procdir->setSorting(QDir::Name);
76 QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); 72 QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList()));
77 if ( proclist ) 73 if ( proclist )
78 { 74 {
79 QFileInfoListIterator it(*proclist); 75 QFileInfoListIterator it(*proclist);
80 QFileInfo *f; 76 QFileInfo *f;
81 while ( ( f = it.current() ) != 0 ) 77 while ( ( f = it.current() ) != 0 )
82 { 78 {
83 ++it; 79 ++it;
84 processnum = f->fileName(); 80 QString processnum = f->fileName();
85 if ( processnum >= "0" && processnum <= "99999" ) 81 if ( processnum >= "1" && processnum <= "99999" )
86 { 82 {
87 FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); 83 FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r");
88 84
89 if ( procfile ) 85 if ( procfile )
90 { 86 {
91 fscanf( procfile, 87 fscanf( procfile,
92 "%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", 88 "%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",
93 &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, 89 &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt,
94 &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, 90 &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout,
95 &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, 91 &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack,
96 &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); 92 &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan );
97 processnum = processnum.rightJustify( 5, ' ' ); 93 processnum = processnum.rightJustify( 5, ' ' );
98 processcmd = QString( comm ).replace( QRegExp( "(" ), "" ); 94 QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" );
99 processcmd = processcmd.replace( QRegExp( ")" ), "" ); 95 QString processstatus = QChar(state);
100 processstatus = state; 96 QString processtime = QString::number( ( utime + stime ) / 100 );
101 processtime.setNum( ( utime + stime ) / 100 );
102 processtime = processtime.rightJustify( 9, ' ' ); 97 processtime = processtime.rightJustify( 9, ' ' );
103 fclose( procfile ); 98 fclose( procfile );
104 99
105 ( void ) new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); 100 ( void ) new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime );
106 } 101 }
107 } 102 }
@@ -111,27 +106,25 @@ void ProcessInfo::updateData()
111 delete proclist; 106 delete proclist;
112 delete procdir; 107 delete procdir;
113} 108}
114 109
115void ProcessInfo::viewProcess(QListViewItem *process) 110void ProcessInfo::viewProcess(QListViewItem *process)
116{ 111{
117 QString pid= process->text(0).stripWhiteSpace(); 112 QString pid= process->text( 0 ).stripWhiteSpace();
118 QString command = process->text(1); 113 QString command = process->text( 1 );
119 ProcessDetail *processdtl = new ProcessDetail( this, 0, TRUE, 0); 114 ProcessDtl->setCaption( pid + " - " + command );
120 processdtl->setCaption( pid + " - " + command ); 115 ProcessDtl->pid = pid.toUInt();
121 processdtl->pid = pid.toUInt();
122 processdtl->ProcessView->setTextFormat( RichText );
123 FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); 116 FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r");
124 if ( statfile ) 117 if ( statfile )
125 { 118 {
126 char line[81]; 119 char line[81];
127 fgets( line, 81, statfile ); 120 fgets( line, 81, statfile );
128 processdtl->ProcessView->setText( line ); 121 ProcessDtl->ProcessView->setText( line );
129 while ( fgets( line, 81, statfile ) ) 122 while ( fgets( line, 81, statfile ) )
130 { 123 {
131 processdtl->ProcessView->append( line ); 124 ProcessDtl->ProcessView->append( line );
132 } 125 }
133 fclose( statfile ); 126 fclose( statfile );
134 } 127 }
135 128
136 processdtl->showMaximized(); 129 ProcessDtl->showMaximized();
137} 130}
diff --git a/noncore/settings/sysinfo/processinfo.h b/noncore/settings/sysinfo/processinfo.h
index e5bacca..89d1a93 100644
--- a/noncore/settings/sysinfo/processinfo.h
+++ b/noncore/settings/sysinfo/processinfo.h
@@ -20,12 +20,14 @@
20#ifndef PROCESSINFO_H 20#ifndef PROCESSINFO_H
21#define PROCESSINFO_H 21#define PROCESSINFO_H
22 22
23#include <qwidget.h> 23#include <qwidget.h>
24#include <qlistview.h> 24#include <qlistview.h>
25 25
26#include "processdetail.h"
27
26class ProcessInfo : public QWidget 28class ProcessInfo : public QWidget
27{ 29{
28 Q_OBJECT 30 Q_OBJECT
29public: 31public:
30 ProcessInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 32 ProcessInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
31 ~ProcessInfo(); 33 ~ProcessInfo();
@@ -33,9 +35,10 @@ public:
33private slots: 35private slots:
34 void updateData(); 36 void updateData();
35 void viewProcess(QListViewItem *); 37 void viewProcess(QListViewItem *);
36 38
37private: 39private:
38 QListView* ProcessView; 40 QListView* ProcessView;
41 ProcessDetail *ProcessDtl;
39}; 42};
40 43
41#endif 44#endif