summaryrefslogtreecommitdiff
path: root/noncore/settings/sysinfo/modulesinfo.cpp
Unidiff
Diffstat (limited to 'noncore/settings/sysinfo/modulesinfo.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/sysinfo/modulesinfo.cpp71
1 files changed, 41 insertions, 30 deletions
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp
index a0d26c7..c558fad 100644
--- a/noncore/settings/sysinfo/modulesinfo.cpp
+++ b/noncore/settings/sysinfo/modulesinfo.cpp
@@ -23,2 +23,3 @@
23 23
24#include <qcombobox.h>
24#include <qfile.h> 25#include <qfile.h>
@@ -27,2 +28,5 @@
27#include <qlistview.h> 28#include <qlistview.h>
29#include <qmessagebox.h>
30#include <qpushbutton.h>
31#include <qstring.h>
28#include <qtimer.h> 32#include <qtimer.h>
@@ -35,5 +39,7 @@ ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl )
35{ 39{
36 QVBoxLayout *layout = new QVBoxLayout( this, 5 ); 40 QGridLayout *layout = new QGridLayout( this );
41 layout->setSpacing( 4 );
42 layout->setMargin( 4 );
37 43
38 ModulesView = new QListView( this, "ModulesView" ); 44 ModulesView = new QListView( this );
39 int colnum = ModulesView->addColumn( tr( "Module" ) ); 45 int colnum = ModulesView->addColumn( tr( "Module" ) );
@@ -45,8 +51,20 @@ ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl )
45 ModulesView->setAllColumnsShowFocus( TRUE ); 51 ModulesView->setAllColumnsShowFocus( TRUE );
46 QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); 52 layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 );
47 connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
48 this, SLOT( viewModules( QListViewItem * ) ) );
49 layout->addWidget( ModulesView );
50 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." ) ); 53 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." ) );
51 54
55 CommandCB = new QComboBox( FALSE, this );
56 CommandCB->insertItem( "modprobe -r" );
57 CommandCB->insertItem( "rmmod" );
58 // I can't think of other useful commands yet. Anyone?
59 layout->addWidget( CommandCB, 1, 0 );
60 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." ) );
61
62 QPushButton *btn = new QPushButton( this );
63 btn->setMinimumSize( QSize( 50, 24 ) );
64 btn->setMaximumSize( QSize( 50, 24 ) );
65 btn->setText( tr( "Send" ) );
66 connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) );
67 layout->addWidget( btn, 1, 1 );
68 QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) );
69
52 QTimer *t = new QTimer( this ); 70 QTimer *t = new QTimer( this );
@@ -56,5 +74,2 @@ ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl )
56 updateData(); 74 updateData();
57
58 ModulesDtl = new ModulesDetail( 0, 0, 0 );
59 ModulesDtl->ModulesView->setTextFormat( PlainText );
60} 75}
@@ -95,28 +110,24 @@ void ModulesInfo::updateData()
95 110
96void ModulesInfo::viewModules( QListViewItem *modules ) 111void ModulesInfo::slotSendClicked()
97{
98 QString modname = modules->text( 0 );
99 ModulesDtl->setCaption( QString( "Module: " ) + modname );
100 ModulesDtl->modname = modname;
101 QString command = QString( "/sbin/modinfo " ) + modules->text( 0 );
102
103 FILE* modinfo = popen( command, "r" );
104
105 if ( modinfo )
106 { 112 {
107 char line[200]; 113 QString capstr = tr( "You really want to execute\n" );
108 ModulesDtl->ModulesView->setText( " Details:\n------------\n" ); 114 capstr.append( CommandCB->currentText() );
115 capstr.append( "\nfor this module?" );
109 116
110 while( true ) 117 if ( QMessageBox::warning( this, caption(), capstr,
118 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes )
111 { 119 {
112 int success = fscanf( modinfo, "%[^\n]\n", line ); 120 QString command = "/sbin/";
113 if ( success == EOF ) 121 command.append( CommandCB->currentText() );
114 break; 122 command.append( " " );
115 ModulesDtl->ModulesView->append( line ); 123 command.append( ModulesView->currentItem()->text( 0 ) );
116 } 124
117 125 FILE* stream = popen( command, "r" );
118 pclose( modinfo ); 126 if ( stream )
127 pclose( stream );
128 //{
129 // hide();
130 //}
119 } 131 }
120 132
121 ModulesDtl->showMaximized();
122} 133}