author | drw <drw> | 2002-12-16 01:55:56 (UTC) |
---|---|---|
committer | drw <drw> | 2002-12-16 01:55:56 (UTC) |
commit | 64bc40080abc56e6bd804dadb44d2510f25f2efa (patch) (unidiff) | |
tree | 20d1840b63dc76608aee6f80bf011811d392fbac /noncore/settings/sysinfo/modulesinfo.cpp | |
parent | e4057ee7fe74c83e2dc44f8b9870f65da60fc4fa (diff) | |
download | opie-64bc40080abc56e6bd804dadb44d2510f25f2efa.zip opie-64bc40080abc56e6bd804dadb44d2510f25f2efa.tar.gz opie-64bc40080abc56e6bd804dadb44d2510f25f2efa.tar.bz2 |
1. Added RAM disk to storage tab (could someone verify works on Z?) 2. QScrollView for storage tab 3. Removed module detail dialog since it did not provide any useful information 4. Fix compiler warnings 5. Removed unneeded qDebugs
Diffstat (limited to 'noncore/settings/sysinfo/modulesinfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/sysinfo/modulesinfo.cpp | 83 |
1 files changed, 47 insertions, 36 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 | |||
@@ -12,111 +12,122 @@ | |||
12 | ** This file may be distributed and/or modified under the terms of the | 12 | ** This file may be distributed and/or modified under the terms of the |
13 | ** GNU General Public License version 2 as published by the Free Software | 13 | ** GNU General Public License version 2 as published by the Free Software |
14 | ** Foundation and appearing in the file LICENSE.GPL included in the | 14 | ** Foundation and appearing in the file LICENSE.GPL included in the |
15 | ** packaging of this file. | 15 | ** packaging of this file. |
16 | ** | 16 | ** |
17 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 17 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
18 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 18 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
23 | 23 | ||
24 | #include <qcombobox.h> | ||
24 | #include <qfile.h> | 25 | #include <qfile.h> |
25 | #include <qheader.h> | 26 | #include <qheader.h> |
26 | #include <qlayout.h> | 27 | #include <qlayout.h> |
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> |
29 | #include <qwhatsthis.h> | 33 | #include <qwhatsthis.h> |
30 | 34 | ||
31 | #include "modulesinfo.h" | 35 | #include "modulesinfo.h" |
32 | 36 | ||
33 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) | 37 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) |
34 | : QWidget( parent, name, fl ) | 38 | : QWidget( parent, name, 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" ) ); |
40 | colnum = ModulesView->addColumn( tr( "Size" ) ); | 46 | colnum = ModulesView->addColumn( tr( "Size" ) ); |
41 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 47 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
42 | colnum = ModulesView->addColumn( tr( "Use#" ) ); | 48 | colnum = ModulesView->addColumn( tr( "Use#" ) ); |
43 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 49 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
44 | colnum = ModulesView->addColumn( tr( "Used By" ) ); | 50 | colnum = ModulesView->addColumn( tr( "Used By" ) ); |
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 ); |
53 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 71 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
54 | t->start( 5000 ); | 72 | t->start( 5000 ); |
55 | 73 | ||
56 | updateData(); | 74 | updateData(); |
57 | |||
58 | ModulesDtl = new ModulesDetail( 0, 0, 0 ); | ||
59 | ModulesDtl->ModulesView->setTextFormat( PlainText ); | ||
60 | } | 75 | } |
61 | 76 | ||
62 | ModulesInfo::~ModulesInfo() | 77 | ModulesInfo::~ModulesInfo() |
63 | { | 78 | { |
64 | } | 79 | } |
65 | 80 | ||
66 | void ModulesInfo::updateData() | 81 | void ModulesInfo::updateData() |
67 | { | 82 | { |
68 | char modname[64]; | 83 | char modname[64]; |
69 | char usage[200]; | 84 | char usage[200]; |
70 | int modsize, usecount; | 85 | int modsize, usecount; |
71 | 86 | ||
72 | ModulesView->clear(); | 87 | ModulesView->clear(); |
73 | 88 | ||
74 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); | 89 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); |
75 | 90 | ||
76 | if ( procfile ) | 91 | if ( procfile ) |
77 | { | 92 | { |
78 | while ( true ) { | 93 | while ( true ) { |
79 | int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); | 94 | int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); |
80 | 95 | ||
81 | if ( success == EOF ) | 96 | if ( success == EOF ) |
82 | break; | 97 | break; |
83 | 98 | ||
84 | QString qmodname = QString( modname ); | 99 | QString qmodname = QString( modname ); |
85 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); | 100 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); |
86 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); | 101 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); |
87 | QString qusage = QString( usage ); | 102 | QString qusage = QString( usage ); |
88 | 103 | ||
89 | ( void ) new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); | 104 | ( void ) new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); |
90 | } | 105 | } |
91 | 106 | ||
92 | fclose( procfile ); | 107 | fclose( procfile ); |
93 | } | 108 | } |
94 | } | 109 | } |
95 | 110 | ||
96 | void ModulesInfo::viewModules( QListViewItem *modules ) | 111 | void ModulesInfo::slotSendClicked() |
97 | { | 112 | { |
98 | QString modname = modules->text( 0 ); | 113 | QString capstr = tr( "You really want to execute\n" ); |
99 | ModulesDtl->setCaption( QString( "Module: " ) + modname ); | 114 | capstr.append( CommandCB->currentText() ); |
100 | ModulesDtl->modname = modname; | 115 | capstr.append( "\nfor this module?" ); |
101 | QString command = QString( "/sbin/modinfo " ) + modules->text( 0 ); | 116 | |
102 | 117 | if ( QMessageBox::warning( this, caption(), capstr, | |
103 | FILE* modinfo = popen( command, "r" ); | 118 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
104 | |||
105 | if ( modinfo ) | ||
106 | { | 119 | { |
107 | char line[200]; | 120 | QString command = "/sbin/"; |
108 | ModulesDtl->ModulesView->setText( " Details:\n------------\n" ); | 121 | command.append( CommandCB->currentText() ); |
109 | 122 | command.append( " " ); | |
110 | while( true ) | 123 | command.append( ModulesView->currentItem()->text( 0 ) ); |
111 | { | 124 | |
112 | int success = fscanf( modinfo, "%[^\n]\n", line ); | 125 | FILE* stream = popen( command, "r" ); |
113 | if ( success == EOF ) | 126 | if ( stream ) |
114 | break; | 127 | pclose( stream ); |
115 | ModulesDtl->ModulesView->append( line ); | 128 | //{ |
116 | } | 129 | // hide(); |
117 | 130 | //} | |
118 | pclose( modinfo ); | ||
119 | } | 131 | } |
120 | 132 | ||
121 | ModulesDtl->showMaximized(); | ||
122 | } | 133 | } |