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 /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 @@ -15,56 +15,86 @@ ** 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; @@ -103,32 +133,53 @@ void ProcessInfo::updateData() 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(); } |