author | drw <drw> | 2002-12-20 01:36:55 (UTC) |
---|---|---|
committer | drw <drw> | 2002-12-20 01:36:55 (UTC) |
commit | 3e556ed5f8c8b1236b9c6155b609930103d17b21 (patch) (side-by-side diff) | |
tree | 859cc1e4f3097276ab77cac4cff5b24fde26ba11 | |
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.
-rw-r--r-- | noncore/settings/sysinfo/detail.cpp (copied from noncore/settings/sysinfo/modulesdetail.h) | 41 | ||||
-rw-r--r-- | noncore/settings/sysinfo/detail.h (renamed from noncore/settings/sysinfo/modulesdetail.h) | 21 | ||||
-rw-r--r-- | noncore/settings/sysinfo/modulesdetail.cpp | 89 | ||||
-rw-r--r-- | noncore/settings/sysinfo/modulesinfo.cpp | 53 | ||||
-rw-r--r-- | noncore/settings/sysinfo/modulesinfo.h | 7 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processdetail.cpp | 92 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processdetail.h | 47 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processinfo.cpp | 65 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processinfo.h | 17 | ||||
-rw-r--r-- | noncore/settings/sysinfo/sysinfo.pro | 4 |
10 files changed, 153 insertions, 283 deletions
diff --git a/noncore/settings/sysinfo/modulesdetail.h b/noncore/settings/sysinfo/detail.cpp index 5515c4b..2c5fdc4 100644 --- a/noncore/settings/sysinfo/modulesdetail.h +++ b/noncore/settings/sysinfo/detail.cpp @@ -1,49 +1,50 @@ /********************************************************************** -** ModulesDetail +** Detail ** ** Display module information ** ** Copyright (C) 2002, Michael Lauer ** mickey@tm.informatik.uni-frankfurt.de ** http://www.Vanille.de ** ** Based on ProcessDetail by Dan Williams <williamsdr@acm.org> ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ -#ifndef MODULESDETAIL_H -#define MODULESDETAIL_H +#include "detail.h" -#include <qwidget.h> -#include <qcombo.h> -#include <qtextview.h> -#include <qpushbutton.h> +#include <sys/types.h> +#include <stdio.h> + +#include <qcombobox.h> +#include <qlayout.h> #include <qlistview.h> +#include <qmessagebox.h> +#include <qpushbutton.h> +#include <qtextview.h> +#include <qwhatsthis.h> -class ModulesDetail : public QWidget +Detail::Detail( QWidget* parent, const char* name, WFlags ) + : QWidget( parent, name, WStyle_ContextHelp ) { - Q_OBJECT + QVBoxLayout *layout = new QVBoxLayout( this ); -public: - ModulesDetail( QWidget* parent, const char* name, WFlags fl ); - ~ModulesDetail(); + detailView = new QTextView( this ); + detailView->setTextFormat( PlainText ); - QComboBox* CommandCB; - QTextView* ModulesView; - QPushButton* SendButton; + layout->addWidget( detailView ); +} - QString modname; +Detail::~Detail() +{ +} -private slots: - void slotSendClicked(); -}; -#endif // MODULESDETAIL_H diff --git a/noncore/settings/sysinfo/modulesdetail.h b/noncore/settings/sysinfo/detail.h index 5515c4b..7ca9d45 100644 --- a/noncore/settings/sysinfo/modulesdetail.h +++ b/noncore/settings/sysinfo/detail.h @@ -1,49 +1,42 @@ /********************************************************************** ** ModulesDetail ** ** Display module information ** ** Copyright (C) 2002, Michael Lauer ** mickey@tm.informatik.uni-frankfurt.de ** http://www.Vanille.de ** ** Based on ProcessDetail by Dan Williams <williamsdr@acm.org> ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ -#ifndef MODULESDETAIL_H -#define MODULESDETAIL_H +#ifndef DETAIL_H +#define DETAIL_H #include <qwidget.h> #include <qcombo.h> #include <qtextview.h> #include <qpushbutton.h> #include <qlistview.h> -class ModulesDetail : public QWidget +class Detail : public QWidget { Q_OBJECT public: - ModulesDetail( QWidget* parent, const char* name, WFlags fl ); - ~ModulesDetail(); + Detail( QWidget * = 0x0, const char * = 0x0, WFlags = 0 ); + ~Detail(); - QComboBox* CommandCB; - QTextView* ModulesView; - QPushButton* SendButton; - - QString modname; - -private slots: - void slotSendClicked(); + QTextView* detailView; }; -#endif // MODULESDETAIL_H +#endif // DETAIL_H diff --git a/noncore/settings/sysinfo/modulesdetail.cpp b/noncore/settings/sysinfo/modulesdetail.cpp deleted file mode 100644 index ea9cdfa..0000000 --- a/noncore/settings/sysinfo/modulesdetail.cpp +++ b/dev/null @@ -1,89 +0,0 @@ -/********************************************************************** -** ModulesDetail -** -** Display module information -** -** Copyright (C) 2002, Michael Lauer -** mickey@tm.informatik.uni-frankfurt.de -** http://www.Vanille.de -** -** Based on ProcessDetail by Dan Williams <williamsdr@acm.org> -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -**********************************************************************/ - -#include "modulesdetail.h" - -#include <sys/types.h> -#include <stdio.h> - -#include <qcombobox.h> -#include <qlayout.h> -#include <qlistview.h> -#include <qmessagebox.h> -#include <qpushbutton.h> -#include <qtextview.h> -#include <qwhatsthis.h> - -ModulesDetail::ModulesDetail( QWidget* parent, const char* name, WFlags ) - : QWidget( parent, name, WStyle_ContextHelp ) -{ - modname = ""; - - QGridLayout *layout = new QGridLayout( this ); - layout->setSpacing( 4 ); - layout->setMargin( 4 ); - - CommandCB = new QComboBox( FALSE, this, "CommandCB" ); - CommandCB->insertItem( "modprobe -r" ); - CommandCB->insertItem( "rmmod" ); - // I can't think of other useful commands yet. Anyone? - layout->addWidget( CommandCB, 1, 0 ); - QWhatsThis::add( CommandCB, tr( "Select a command here and then click the Send button to the right to send the command." ) ); - - ModulesView = new QTextView( this, "ModulesView" ); - layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); - QWhatsThis::add( ModulesView, tr( "This area shows detailed information about this module." ) ); - - SendButton = new QPushButton( this, "SendButton" ); - SendButton->setMinimumSize( QSize( 50, 24 ) ); - SendButton->setMaximumSize( QSize( 50, 24 ) ); - SendButton->setText( tr( "Send" ) ); - connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); - layout->addWidget( SendButton, 1, 1 ); - QWhatsThis::add( SendButton, tr( "Click here to send the selected command to this module." ) ); -} - -ModulesDetail::~ModulesDetail() -{ -} - -void ModulesDetail::slotSendClicked() -{ - QString command = QString( "/sbin/" ) - + CommandCB->currentText() - + QString( " " ) + modname; - - if ( QMessageBox::warning( this, caption(), - tr( "You really want to \n" + CommandCB->currentText() + "\nthis Module?"), - QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) - == QMessageBox::Yes ) - { - FILE* stream = popen( command, "r" ); - if ( stream ) - pclose( stream ); - { - hide(); - } - } - -} - - diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp index c558fad..8b58fe9 100644 --- a/noncore/settings/sysinfo/modulesinfo.cpp +++ b/noncore/settings/sysinfo/modulesinfo.cpp @@ -12,122 +12,163 @@ ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include <qpe/qpeapplication.h> #include <qcombobox.h> #include <qfile.h> #include <qheader.h> #include <qlayout.h> #include <qlistview.h> #include <qmessagebox.h> #include <qpushbutton.h> #include <qstring.h> #include <qtimer.h> #include <qwhatsthis.h> #include "modulesinfo.h" +#include "detail.h" ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { QGridLayout *layout = new QGridLayout( this ); layout->setSpacing( 4 ); layout->setMargin( 4 ); ModulesView = new QListView( this ); int colnum = ModulesView->addColumn( tr( "Module" ) ); colnum = ModulesView->addColumn( tr( "Size" ) ); ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); colnum = ModulesView->addColumn( tr( "Use#" ) ); ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); colnum = ModulesView->addColumn( tr( "Used By" ) ); ModulesView->setAllColumnsShowFocus( TRUE ); layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); 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." ) ); + + // Test if we have /sbin/modinfo, and if so, allow module detail window + if ( QFile::exists( "/sbin/modinfo" ) ) + { + QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); + connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), + this, SLOT( viewModules( QListViewItem * ) ) ); + } CommandCB = new QComboBox( FALSE, this ); CommandCB->insertItem( "modprobe -r" ); CommandCB->insertItem( "rmmod" ); // I can't think of other useful commands yet. Anyone? layout->addWidget( CommandCB, 1, 0 ); 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." ) ); QPushButton *btn = new QPushButton( this ); btn->setMinimumSize( QSize( 50, 24 ) ); btn->setMaximumSize( QSize( 50, 24 ) ); btn->setText( tr( "Send" ) ); connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); layout->addWidget( btn, 1, 1 ); QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); QTimer *t = new QTimer( this ); connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); t->start( 5000 ); - + updateData(); + + ModulesDtl = new Detail(); + QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); } ModulesInfo::~ModulesInfo() { } void ModulesInfo::updateData() { char modname[64]; char usage[200]; int modsize, usecount; ModulesView->clear(); FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); if ( procfile ) { while ( true ) { int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); if ( success == EOF ) break; QString qmodname = QString( modname ); QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); QString qusage = QString( usage ); ( void ) new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); } fclose( procfile ); } } void ModulesInfo::slotSendClicked() { QString capstr = tr( "You really want to execute\n" ); capstr.append( CommandCB->currentText() ); capstr.append( "\nfor this module?" ); - if ( QMessageBox::warning( this, caption(), capstr, + QString modname = ModulesView->currentItem()->text( 0 ); + + if ( QMessageBox::warning( this, modname, capstr, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) { QString command = "/sbin/"; command.append( CommandCB->currentText() ); command.append( " " ); - command.append( ModulesView->currentItem()->text( 0 ) ); + command.append( modname ); FILE* stream = popen( command, "r" ); if ( stream ) pclose( stream ); - //{ - // hide(); - //} } } + +void ModulesInfo::viewModules( QListViewItem *modules ) +{ + QString modname = modules->text( 0 ); + QString capstr = "Module: "; + capstr.append( modname ); + ModulesDtl->setCaption( capstr ); + QString command = "/sbin/modinfo -nad "; + command.append( modname ); + FILE* modinfo = popen( command, "r" ); + + if ( modinfo ) + { + char line[200]; + ModulesDtl->detailView->setText( " Details:\n------------\n" ); + + while( true ) + { + int success = fscanf( modinfo, "%[^\n]\n", line ); + if ( success == EOF ) + break; + ModulesDtl->detailView->append( line ); + } + + pclose( modinfo ); + } + + ModulesDtl->showMaximized(); +} + diff --git a/noncore/settings/sysinfo/modulesinfo.h b/noncore/settings/sysinfo/modulesinfo.h index ef1f805..e974610 100644 --- a/noncore/settings/sysinfo/modulesinfo.h +++ b/noncore/settings/sysinfo/modulesinfo.h @@ -3,44 +3,49 @@ ** ** Display modules information ** ** Copyright (C) 2002, Michael Lauer ** mickey@tm.informatik.uni-frankfurt.de ** http://www.Vanille.de ** ** Based on ProcessInfo by Dan Williams <williamsdr@acm.org> ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #ifndef MODULESINFO_H #define MODULESINFO_H #include <qwidget.h> +class Detail; class QComboBox; class QListView; +class QListViewItem; class ModulesInfo : public QWidget { Q_OBJECT public: ModulesInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~ModulesInfo(); private: - QListView* ModulesView; + QListView* ModulesView; QComboBox* CommandCB; + Detail* ModulesDtl; + private slots: void updateData(); void slotSendClicked(); + void viewModules( QListViewItem * ); }; #endif diff --git a/noncore/settings/sysinfo/processdetail.cpp b/noncore/settings/sysinfo/processdetail.cpp deleted file mode 100644 index fcb871f..0000000 --- a/noncore/settings/sysinfo/processdetail.cpp +++ b/dev/null @@ -1,92 +0,0 @@ -/********************************************************************** -** ProcessDetail -** -** Display process information -** -** Copyright (C) 2002, Dan Williams -** williamsdr@acm.org -** http://draknor.net -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -**********************************************************************/ - -#include "processdetail.h" - -#include <sys/types.h> -#include <signal.h> - -#include <qcombobox.h> -#include <qlayout.h> -#include <qlistview.h> -#include <qmessagebox.h> -#include <qpushbutton.h> -#include <qtextview.h> -#include <qwhatsthis.h> - -ProcessDetail::ProcessDetail( QWidget* parent, const char* name, WFlags ) - : QWidget( parent, name, WStyle_ContextHelp ) -{ - pid = 0; - - QGridLayout *layout = new QGridLayout( this ); - layout->setSpacing( 4 ); - layout->setMargin( 4 ); - - SignalCB = new QComboBox( FALSE, this, "SignalCB" ); - SignalCB->insertItem( " 1: SIGHUP" ); - SignalCB->insertItem( " 2: SIGINT" ); - SignalCB->insertItem( " 3: SIGQUIT" ); - SignalCB->insertItem( " 5: SIGTRAP" ); - SignalCB->insertItem( " 6: SIGABRT" ); - SignalCB->insertItem( " 9: SIGKILL" ); - SignalCB->insertItem( "14: SIGALRM" ); - SignalCB->insertItem( "15: SIGTERM" ); - SignalCB->insertItem( "18: SIGCONT" ); - SignalCB->insertItem( "19: SIGSTOP" ); - layout->addWidget( SignalCB, 1, 0 ); - QWhatsThis::add( SignalCB, tr( "Select a signal here and then click the Send button to the right to send to this process." ) ); - - ProcessView = new QTextView( this, "ProcessView" ); - layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); - QWhatsThis::add( ProcessView, tr( "This area shows detailed information about this process." ) ); - - SendButton = new QPushButton( this, "SendButton" ); - SendButton->setMinimumSize( QSize( 50, 24 ) ); - SendButton->setMaximumSize( QSize( 50, 24 ) ); - SendButton->setText( tr( "Send" ) ); - connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); - layout->addWidget( SendButton, 1, 1 ); - QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) ); -} - -ProcessDetail::~ProcessDetail() -{ -} - -void ProcessDetail::slotSendClicked() -{ - QString sigstr = SignalCB->currentText(); - sigstr.truncate(2); - int sigid = sigstr.toUInt(); - - if ( QMessageBox::warning( this, caption(), - tr( "You really want to send\n" + SignalCB->currentText() + "\nto this process?"), - QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) - == QMessageBox::Yes ) - { - if ( kill( pid, sigid ) == 0 ) - { - hide(); - } - } - -} - - diff --git a/noncore/settings/sysinfo/processdetail.h b/noncore/settings/sysinfo/processdetail.h deleted file mode 100644 index 22e196f..0000000 --- a/noncore/settings/sysinfo/processdetail.h +++ b/dev/null @@ -1,47 +0,0 @@ -/********************************************************************** -** ProcessDetail -** -** Display process information -** -** Copyright (C) 2002, Dan Williams -** williamsdr@acm.org -** http://draknor.net -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -**********************************************************************/ - -#ifndef PROCESSDETAIL_H -#define PROCESSDETAIL_H - -#include <qwidget.h> -#include <qcombo.h> -#include <qtextview.h> -#include <qpushbutton.h> -#include <qlistview.h> - -class ProcessDetail : public QWidget -{ - Q_OBJECT - -public: - ProcessDetail( QWidget* parent, const char* name, WFlags fl ); - ~ProcessDetail(); - - QComboBox* SignalCB; - QTextView* ProcessView; - QPushButton* SendButton; - - int pid; - -private slots: - void slotSendClicked(); -}; - -#endif // PROCESSDETAIL_H 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 @@ -3,80 +3,110 @@ ** ** Display process information ** ** Copyright (C) 2002, Dan Williams ** williamsdr@acm.org ** http://draknor.net ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include <qpe/qpeapplication.h> #include <qdir.h> #include <qfile.h> #include <qheader.h> #include <qlayout.h> #include <qlistview.h> +#include <qmessagebox.h> #include <qtimer.h> #include <qwhatsthis.h> +#include <sys/types.h> +#include <signal.h> + #include "processinfo.h" +#include "detail.h" ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { - QVBoxLayout *layout = new QVBoxLayout( this, 5 ); + QGridLayout *layout = new QGridLayout( this ); + layout->setSpacing( 4 ); + layout->setMargin( 4 ); + ProcessView = new QListView( this, "ProcessView" ); int colnum = ProcessView->addColumn( tr( "PID" ) ); ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); colnum = ProcessView->addColumn( tr( "Command" ),96 ); colnum = ProcessView->addColumn( tr( "Status" ) ); colnum = ProcessView->addColumn( tr( "Time" ) ); ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); ProcessView->setAllColumnsShowFocus( TRUE ); QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), this, SLOT( viewProcess( QListViewItem * ) ) ); - layout->addWidget( ProcessView ); + layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); 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." ) ); + + SignalCB = new QComboBox( FALSE, this, "SignalCB" ); + SignalCB->insertItem( " 1: SIGHUP" ); + SignalCB->insertItem( " 2: SIGINT" ); + SignalCB->insertItem( " 3: SIGQUIT" ); + SignalCB->insertItem( " 5: SIGTRAP" ); + SignalCB->insertItem( " 6: SIGABRT" ); + SignalCB->insertItem( " 9: SIGKILL" ); + SignalCB->insertItem( "14: SIGALRM" ); + SignalCB->insertItem( "15: SIGTERM" ); + SignalCB->insertItem( "18: SIGCONT" ); + SignalCB->insertItem( "19: SIGSTOP" ); + layout->addWidget( SignalCB, 1, 0 ); + QWhatsThis::add( SignalCB, tr( "Select a signal here and then click the Send button to the right to send to this process." ) ); + + SendButton = new QPushButton( this, "SendButton" ); + SendButton->setMinimumSize( QSize( 50, 24 ) ); + SendButton->setMaximumSize( QSize( 50, 24 ) ); + SendButton->setText( tr( "Send" ) ); + connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); + layout->addWidget( SendButton, 1, 1 ); + QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) ); QTimer *t = new QTimer( this ); connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); t->start( 5000 ); updateData(); - ProcessDtl = new ProcessDetail( 0, 0, 0 ); - ProcessDtl->ProcessView->setTextFormat( RichText ); + ProcessDtl = new Detail(); + QWhatsThis::add( ProcessDtl->detailView, tr( "This area shows detailed information about this process." ) ); } ProcessInfo::~ProcessInfo() { } void ProcessInfo::updateData() { int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, signal, blocked, sigignore, sigcatch; uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, endcode, startstack, kstkesp, kstkeip, wchan; char state; char comm[64]; ProcessView->clear(); QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); if ( proclist ) { QFileInfoListIterator it(*proclist); QFileInfo *f; while ( ( f = it.current() ) != 0 ) @@ -91,44 +121,65 @@ void ProcessInfo::updateData() { fscanf( procfile, "%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", &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); processnum = processnum.rightJustify( 5, ' ' ); QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); QString processstatus = QChar(state); QString processtime = QString::number( ( utime + stime ) / 100 ); processtime = processtime.rightJustify( 9, ' ' ); fclose( procfile ); ( void ) new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); } } } } delete proclist; delete procdir; } +void ProcessInfo::slotSendClicked() +{ + QString capstr = tr( "You really want to send\n" ); + capstr.append( SignalCB->currentText() ); + capstr.append( "\nto this process?" ); + + QListViewItem *currprocess = ProcessView->currentItem(); + + if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, + QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) + { + QString sigstr = SignalCB->currentText(); + sigstr.truncate(2); + int sigid = sigstr.toUInt(); + if ( kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ) == 0 ) + { + hide(); + } + } + +} + void ProcessInfo::viewProcess( QListViewItem *process ) { QString pid= process->text( 0 ).stripWhiteSpace(); QString command = process->text( 1 ); ProcessDtl->setCaption( pid + " - " + command ); - ProcessDtl->pid = pid.toUInt(); FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); if ( statfile ) { char line[81]; fgets( line, 81, statfile ); - ProcessDtl->ProcessView->setText( line ); + ProcessDtl->detailView->setText( line ); while ( fgets( line, 81, statfile ) ) { - ProcessDtl->ProcessView->append( line ); + ProcessDtl->detailView->append( line ); } fclose( statfile ); } ProcessDtl->showMaximized(); } diff --git a/noncore/settings/sysinfo/processinfo.h b/noncore/settings/sysinfo/processinfo.h index 24b190e..687e080 100644 --- a/noncore/settings/sysinfo/processinfo.h +++ b/noncore/settings/sysinfo/processinfo.h @@ -2,43 +2,50 @@ ** ProcessInfo ** ** Display process information ** ** Copyright (C) 2002, Dan Williams ** williamsdr@acm.org ** http://draknor.net ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #ifndef PROCESSINFO_H #define PROCESSINFO_H #include <qwidget.h> #include <qlistview.h> -#include "processdetail.h" +class Detail; +class QComboBox; +class QListView; +class QListViewItem; class ProcessInfo : public QWidget { Q_OBJECT public: ProcessInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~ProcessInfo(); +private: + QListView* ProcessView; + QComboBox* SignalCB; + QPushButton* SendButton; + + Detail *ProcessDtl; + private slots: void updateData(); + void slotSendClicked(); void viewProcess( QListViewItem * ); - -private: - QListView* ProcessView; - ProcessDetail *ProcessDtl; }; #endif diff --git a/noncore/settings/sysinfo/sysinfo.pro b/noncore/settings/sysinfo/sysinfo.pro index 7e66451..b6217c3 100644 --- a/noncore/settings/sysinfo/sysinfo.pro +++ b/noncore/settings/sysinfo/sysinfo.pro @@ -1,44 +1,44 @@ TEMPLATE = app CONFIG = qt warn_on release DESTDIR = $(OPIEDIR)/bin HEADERS = memory.h \ graph.h \ load.h \ storage.h \ processinfo.h \ - processdetail.h \ modulesinfo.h \ + detail.h \ versioninfo.h \ sysinfo.h SOURCES = main.cpp \ memory.cpp \ graph.cpp \ load.cpp \ storage.cpp \ processinfo.cpp \ modulesinfo.cpp \ - processdetail.cpp \ + detail.cpp \ versioninfo.cpp \ sysinfo.cpp INTERFACES = INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie TARGET = sysinfo TRANSLATIONS = ../../../i18n/de/sysinfo.ts \ ../../../i18n/xx/sysinfo.ts \ ../../../i18n/en/sysinfo.ts \ ../../../i18n/es/sysinfo.ts \ ../../../i18n/fr/sysinfo.ts \ ../../../i18n/hu/sysinfo.ts \ ../../../i18n/ja/sysinfo.ts \ ../../../i18n/ko/sysinfo.ts \ ../../../i18n/no/sysinfo.ts \ ../../../i18n/pl/sysinfo.ts \ ../../../i18n/pt/sysinfo.ts \ ../../../i18n/pt_BR/sysinfo.ts \ ../../../i18n/sl/sysinfo.ts \ ../../../i18n/zh_CN/sysinfo.ts \ ../../../i18n/zh_TW/sysinfo.ts \ ../../../i18n/da/sysinfo.ts |