-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,4 +1,4 @@ /********************************************************************** -** ModulesDetail +** Detail ** ** Display module information @@ -20,30 +20,31 @@ **********************************************************************/ -#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 @@ -20,6 +20,6 @@ **********************************************************************/ -#ifndef MODULESDETAIL_H -#define MODULESDETAIL_H +#ifndef DETAIL_H +#define DETAIL_H #include <qwidget.h> @@ -29,21 +29,14 @@ #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 @@ -34,4 +34,5 @@ #include "modulesinfo.h" +#include "detail.h" ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) @@ -52,4 +53,12 @@ ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) 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 ); @@ -71,6 +80,9 @@ ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) 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." ) ); } @@ -115,5 +127,7 @@ void ModulesInfo::slotSendClicked() 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 ) { @@ -121,13 +135,40 @@ void ModulesInfo::slotSendClicked() 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 @@ -25,6 +25,8 @@ #include <qwidget.h> +class Detail; class QComboBox; class QListView; +class QListViewItem; class ModulesInfo : public QWidget @@ -36,10 +38,13 @@ public: private: - QListView* ModulesView; + QListView* ModulesView; QComboBox* CommandCB; + Detail* ModulesDtl; + private slots: void updateData(); void slotSendClicked(); + void viewModules( QListViewItem * ); }; 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 @@ -25,13 +25,21 @@ #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" ); @@ -46,6 +54,28 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) 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 ); @@ -55,6 +85,6 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) 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." ) ); } @@ -113,4 +143,26 @@ void ProcessInfo::updateData() } +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 ) { @@ -118,5 +170,4 @@ void ProcessInfo::viewProcess( QListViewItem *process ) QString command = process->text( 1 ); ProcessDtl->setCaption( pid + " - " + command ); - ProcessDtl->pid = pid.toUInt(); FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); if ( statfile ) @@ -124,8 +175,8 @@ void ProcessInfo::viewProcess( QListViewItem *process ) 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 ); 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 @@ -24,5 +24,8 @@ #include <qlistview.h> -#include "processdetail.h" +class Detail; +class QComboBox; +class QListView; +class QListViewItem; class ProcessInfo : public QWidget @@ -33,11 +36,15 @@ public: ~ProcessInfo(); +private: + QListView* ProcessView; + QComboBox* SignalCB; + QPushButton* SendButton; + + Detail *ProcessDtl; + private slots: void updateData(); + void slotSendClicked(); void viewProcess( QListViewItem * ); - -private: - QListView* ProcessView; - ProcessDetail *ProcessDtl; }; 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 @@ -7,6 +7,6 @@ HEADERS = memory.h \ storage.h \ processinfo.h \ - processdetail.h \ modulesinfo.h \ + detail.h \ versioninfo.h \ sysinfo.h @@ -18,5 +18,5 @@ SOURCES = main.cpp \ processinfo.cpp \ modulesinfo.cpp \ - processdetail.cpp \ + detail.cpp \ versioninfo.cpp \ sysinfo.cpp |