Diffstat (limited to 'noncore/settings/sysinfo/modulesinfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/sysinfo/modulesinfo.cpp | 53 |
1 files changed, 47 insertions, 6 deletions
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 | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <qwhatsthis.h> | 33 | #include <qwhatsthis.h> |
34 | 34 | ||
35 | #include "modulesinfo.h" | 35 | #include "modulesinfo.h" |
36 | #include "detail.h" | ||
36 | 37 | ||
37 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) | 38 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) |
38 | : QWidget( parent, name, fl ) | 39 | : QWidget( parent, name, fl ) |
@@ -51,6 +52,14 @@ ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) | |||
51 | ModulesView->setAllColumnsShowFocus( TRUE ); | 52 | ModulesView->setAllColumnsShowFocus( TRUE ); |
52 | layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); | 53 | layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); |
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." ) ); | 54 | 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." ) ); |
55 | |||
56 | // Test if we have /sbin/modinfo, and if so, allow module detail window | ||
57 | if ( QFile::exists( "/sbin/modinfo" ) ) | ||
58 | { | ||
59 | QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); | ||
60 | connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | ||
61 | this, SLOT( viewModules( QListViewItem * ) ) ); | ||
62 | } | ||
54 | 63 | ||
55 | CommandCB = new QComboBox( FALSE, this ); | 64 | CommandCB = new QComboBox( FALSE, this ); |
56 | CommandCB->insertItem( "modprobe -r" ); | 65 | CommandCB->insertItem( "modprobe -r" ); |
@@ -70,8 +79,11 @@ ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) | |||
70 | QTimer *t = new QTimer( this ); | 79 | QTimer *t = new QTimer( this ); |
71 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 80 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
72 | t->start( 5000 ); | 81 | t->start( 5000 ); |
73 | 82 | ||
74 | updateData(); | 83 | updateData(); |
84 | |||
85 | ModulesDtl = new Detail(); | ||
86 | QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); | ||
75 | } | 87 | } |
76 | 88 | ||
77 | ModulesInfo::~ModulesInfo() | 89 | ModulesInfo::~ModulesInfo() |
@@ -114,20 +126,49 @@ void ModulesInfo::slotSendClicked() | |||
114 | capstr.append( CommandCB->currentText() ); | 126 | capstr.append( CommandCB->currentText() ); |
115 | capstr.append( "\nfor this module?" ); | 127 | capstr.append( "\nfor this module?" ); |
116 | 128 | ||
117 | if ( QMessageBox::warning( this, caption(), capstr, | 129 | QString modname = ModulesView->currentItem()->text( 0 ); |
130 | |||
131 | if ( QMessageBox::warning( this, modname, capstr, | ||
118 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 132 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
119 | { | 133 | { |
120 | QString command = "/sbin/"; | 134 | QString command = "/sbin/"; |
121 | command.append( CommandCB->currentText() ); | 135 | command.append( CommandCB->currentText() ); |
122 | command.append( " " ); | 136 | command.append( " " ); |
123 | command.append( ModulesView->currentItem()->text( 0 ) ); | 137 | command.append( modname ); |
124 | 138 | ||
125 | FILE* stream = popen( command, "r" ); | 139 | FILE* stream = popen( command, "r" ); |
126 | if ( stream ) | 140 | if ( stream ) |
127 | pclose( stream ); | 141 | pclose( stream ); |
128 | //{ | ||
129 | // hide(); | ||
130 | //} | ||
131 | } | 142 | } |
132 | 143 | ||
133 | } | 144 | } |
145 | |||
146 | void ModulesInfo::viewModules( QListViewItem *modules ) | ||
147 | { | ||
148 | QString modname = modules->text( 0 ); | ||
149 | QString capstr = "Module: "; | ||
150 | capstr.append( modname ); | ||
151 | ModulesDtl->setCaption( capstr ); | ||
152 | QString command = "/sbin/modinfo -nad "; | ||
153 | command.append( modname ); | ||
154 | FILE* modinfo = popen( command, "r" ); | ||
155 | |||
156 | if ( modinfo ) | ||
157 | { | ||
158 | char line[200]; | ||
159 | ModulesDtl->detailView->setText( " Details:\n------------\n" ); | ||
160 | |||
161 | while( true ) | ||
162 | { | ||
163 | int success = fscanf( modinfo, "%[^\n]\n", line ); | ||
164 | if ( success == EOF ) | ||
165 | break; | ||
166 | ModulesDtl->detailView->append( line ); | ||
167 | } | ||
168 | |||
169 | pclose( modinfo ); | ||
170 | } | ||
171 | |||
172 | ModulesDtl->showMaximized(); | ||
173 | } | ||
174 | |||