summaryrefslogtreecommitdiff
path: root/noncore
Unidiff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/processinfo.cpp119
-rw-r--r--noncore/settings/sysinfo/processinfo.h123
-rw-r--r--noncore/settings/sysinfo/sysinfo.cpp2
-rw-r--r--noncore/settings/sysinfo/sysinfo.pro40
4 files changed, 265 insertions, 19 deletions
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp
new file mode 100644
index 0000000..bd954c8
--- a/dev/null
+++ b/noncore/settings/sysinfo/processinfo.cpp
@@ -0,0 +1,119 @@
1/**********************************************************************
2** ProcessInfo
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 <qheader.h>
21#include <qlistview.h>
22#include <qlayout.h>
23#include <qtimer.h>
24#include <qfile.h>
25#include <qdir.h>
26
27#include "processinfo.h"
28
29ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl )
30 : QWidget( parent, name, fl )
31{
32 QVBoxLayout *vb = new QVBoxLayout( this, 5 );
33
34 ProcessView = new QListView( this, "ProcessView" );
35 int colnum = ProcessView->addColumn( tr( "PID" ) );
36 ProcessView->setColumnAlignment( colnum, Qt::AlignRight );
37 colnum = ProcessView->addColumn( tr( "Command" ),90 );
38 ProcessView->setColumnAlignment( colnum, Qt::AlignRight );
39 colnum = ProcessView->addColumn( tr( "Status" ) );
40 ProcessView->setColumnAlignment( colnum, Qt::AlignRight );
41 colnum = ProcessView->addColumn( tr( "Time" ) );
42 ProcessView->setColumnAlignment( colnum, Qt::AlignRight );
43 ProcessView->setAllColumnsShowFocus( TRUE );
44 connect( ProcessView, SIGNAL( doubleClicked(QListViewItem *) ), this, SLOT( viewProcess(QListViewItem *) ) );
45
46 vb->addWidget( ProcessView );
47
48 QTimer *t = new QTimer( this );
49 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) );
50 t->start( 5000 );
51
52 updateData();
53}
54
55ProcessInfo::~ProcessInfo()
56{
57}
58
59void ProcessInfo::updateData()
60{
61 QString processnum("");
62 QString processcmd("");
63 QString processstatus("");
64 QString processtime("");
65 int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime,
66 signal, blocked, sigignore, sigcatch;
67 uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode,
68 endcode, startstack, kstkesp, kstkeip, wchan;
69 char state;
70 char comm[255];
71
72 ProcessView->clear();
73
74 QDir *procdir = new QDir("/proc");
75 procdir->setFilter(QDir::Dirs);
76 procdir->setSorting(QDir::Name);
77 QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList()));
78 if ( proclist )
79 {
80 QFileInfoListIterator it(*proclist);
81 QFileInfo *f;
82 while ( ( f = it.current() ) != 0 )
83 {
84 ++it;
85 processnum = f->fileName();
86 if ( processnum >= "0" && processnum <= "99999" )
87 {
88 FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r");
89
90 if ( procfile )
91 {
92 fscanf( procfile,
93 "%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",
94 &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt,
95 &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout,
96 &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack,
97 &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan );
98 processnum = processnum.rightJustify( 5, ' ' );
99 processcmd = QString( comm ).replace( QRegExp( "(" ), "" );
100 processcmd = processcmd.replace( QRegExp( ")" ), "" );
101 processstatus = state;
102 processtime.setNum( ( utime + stime ) / 100 );
103 processtime = processtime.rightJustify( 9, ' ' );
104 fclose( procfile );
105
106 ( void ) new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime );
107 }
108 }
109 }
110 }
111
112 delete proclist;
113 delete procdir;
114}
115
116void ProcessInfo::viewProcess(QListViewItem *process)
117{
118//printf("Double click for PID: %s\n", process->text(0).stripWhiteSpace().latin1());
119}
diff --git a/noncore/settings/sysinfo/processinfo.h b/noncore/settings/sysinfo/processinfo.h
new file mode 100644
index 0000000..f2eedc9
--- a/dev/null
+++ b/noncore/settings/sysinfo/processinfo.h
@@ -0,0 +1,123 @@
1/**********************************************************************
2** ProcessInfo
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 PROCESSINFO_H
21#define PROCESSINFO_H
22
23#include <qwidget.h>
24#include <qlistview.h>
25
26class ProcessInfo : public QWidget
27{
28 Q_OBJECT
29public:
30 ProcessInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
31 ~ProcessInfo();
32
33private slots:
34 void updateData();
35 void viewProcess(QListViewItem *);
36
37private:
38 QListView* ProcessView;
39};
40
41#endif
42/**********************************************************************
43** ProcessInfo
44**
45** Display process information
46**
47** Copyright (C) 2002, Dan Williams
48** williamsdr@acm.org
49** http://draknor.net
50**
51** This file may be distributed and/or modified under the terms of the
52** GNU General Public License version 2 as published by the Free Software
53** Foundation and appearing in the file LICENSE.GPL included in the
54** packaging of this file.
55**
56** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
57** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
58**
59**********************************************************************/
60
61#ifndef PROCESSINFO_H
62#define PROCESSINFO_H
63
64#include <qwidget.h>
65#include <qlistview.h>
66
67class ProcessInfo : public QWidget
68{
69 Q_OBJECT
70public:
71 ProcessInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
72 ~ProcessInfo();
73
74private slots:
75 void updateData();
76 void viewProcess(QListViewItem *);
77
78private:
79 QListView* ProcessView;
80};
81
82#endif
83/**********************************************************************
84** ProcessInfo
85**
86** Display process information
87**
88** Copyright (C) 2002, Dan Williams
89** williamsdr@acm.org
90** http://draknor.net
91**
92** This file may be distributed and/or modified under the terms of the
93** GNU General Public License version 2 as published by the Free Software
94** Foundation and appearing in the file LICENSE.GPL included in the
95** packaging of this file.
96**
97** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
98** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
99**
100**********************************************************************/
101
102#ifndef PROCESSINFO_H
103#define PROCESSINFO_H
104
105#include <qwidget.h>
106#include <qlistview.h>
107
108class ProcessInfo : public QWidget
109{
110 Q_OBJECT
111public:
112 ProcessInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
113 ~ProcessInfo();
114
115private slots:
116 void updateData();
117 void viewProcess(QListViewItem *);
118
119private:
120 QListView* ProcessView;
121};
122
123#endif
diff --git a/noncore/settings/sysinfo/sysinfo.cpp b/noncore/settings/sysinfo/sysinfo.cpp
index bc483aa..5697f36 100644
--- a/noncore/settings/sysinfo/sysinfo.cpp
+++ b/noncore/settings/sysinfo/sysinfo.cpp
@@ -22,6 +22,7 @@
22#include "load.h" 22#include "load.h"
23#include "storage.h" 23#include "storage.h"
24//#include "graphics.h" 24//#include "graphics.h"
25#include "processinfo.h"
25#include "versioninfo.h" 26#include "versioninfo.h"
26#include "sysinfo.h" 27#include "sysinfo.h"
27 28
@@ -45,6 +46,7 @@ SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags f )
45#endif 46#endif
46 tab->addTab( new LoadInfo( tab ), tr("CPU") ); 47 tab->addTab( new LoadInfo( tab ), tr("CPU") );
47// tab->addTab( new Graphics( tab ), tr("Graphics") ); 48// tab->addTab( new Graphics( tab ), tr("Graphics") );
49 tab->addTab( new ProcessInfo( tab ), tr("Process") );
48 tab->addTab( new VersionInfo( tab ), tr("Version") ); 50 tab->addTab( new VersionInfo( tab ), tr("Version") );
49 51
50 resize( 220, 180 ); 52 resize( 220, 180 );
diff --git a/noncore/settings/sysinfo/sysinfo.pro b/noncore/settings/sysinfo/sysinfo.pro
index 3393a12..7f84dec 100644
--- a/noncore/settings/sysinfo/sysinfo.pro
+++ b/noncore/settings/sysinfo/sysinfo.pro
@@ -1,25 +1,27 @@
1 TEMPLATE= app 1TEMPLATE = app
2 CONFIG = qt warn_on release 2CONFIG = qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin 3DESTDIR = $(OPIEDIR)/bin
4 HEADERS = memory.h \ 4HEADERS = memory.h \
5 graph.h \ 5 graph.h \
6 load.h \ 6 load.h \
7 storage.h \ 7 storage.h \
8 versioninfo.h \ 8 processinfo.h \
9 sysinfo.h 9 versioninfo.h \
10 SOURCES = main.cpp \ 10 sysinfo.h
11 memory.cpp \ 11SOURCES = main.cpp \
12 graph.cpp \ 12 memory.cpp \
13 load.cpp \ 13 graph.cpp \
14 storage.cpp \ 14 load.cpp \
15 versioninfo.cpp \ 15 storage.cpp \
16 sysinfo.cpp 16 processinfo.cpp \
17 INTERFACES= 17 versioninfo.cpp \
18 sysinfo.cpp
19INTERFACES =
18 20
19INCLUDEPATH += $(OPIEDIR)/include 21INCLUDEPATH += $(OPIEDIR)/include
20 DEPENDPATH+= $(OPIEDIR)/include 22DEPENDPATH += $(OPIEDIR)/include
21LIBS += -lqpe 23LIBS += -lqpe
22 24
23 TARGET = sysinfo 25TARGET = sysinfo
24 26
25TRANSLATIONS = ../i18n/de/sysinfo.ts 27TRANSLATIONS = ../i18n/de/sysinfo.ts