Diffstat (limited to 'noncore/settings/sysinfo/modulesinfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/sysinfo/modulesinfo.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp index 9cb8ad2..e688a29 100644 --- a/noncore/settings/sysinfo/modulesinfo.cpp +++ b/noncore/settings/sysinfo/modulesinfo.cpp | |||
@@ -1,154 +1,154 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** ModulesInfo | 2 | ** ModulesInfo |
3 | ** | 3 | ** |
4 | ** Display Modules information | 4 | ** Display Modules information |
5 | ** | 5 | ** |
6 | ** Copyright (C) 2002, Michael Lauer | 6 | ** Copyright (C) 2002, Michael Lauer |
7 | ** mickey@tm.informatik.uni-frankfurt.de | 7 | ** mickey@tm.informatik.uni-frankfurt.de |
8 | ** http://www.Vanille.de | 8 | ** http://www.Vanille.de |
9 | ** | 9 | ** |
10 | ** Based on ProcessInfo by Dan Williams <williamsdr@acm.org> | 10 | ** Based on ProcessInfo by Dan Williams <williamsdr@acm.org> |
11 | ** | 11 | ** |
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 "modulesinfo.h" | 22 | #include "modulesinfo.h" |
23 | #include "detail.h" | 23 | #include "detail.h" |
24 | 24 | ||
25 | /* OPIE */ | 25 | /* OPIE */ |
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | 27 | ||
28 | /* QT */ | 28 | /* QT */ |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qwhatsthis.h> | 33 | #include <qwhatsthis.h> |
34 | 34 | ||
35 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) | 35 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) |
36 | : QWidget( parent, name, fl ) | 36 | : QWidget( parent, name, fl ) |
37 | { | 37 | { |
38 | QGridLayout *layout = new QGridLayout( this ); | 38 | QGridLayout *layout = new QGridLayout( this ); |
39 | layout->setSpacing( 4 ); | 39 | layout->setSpacing( 4 ); |
40 | layout->setMargin( 4 ); | 40 | layout->setMargin( 4 ); |
41 | 41 | ||
42 | ModulesView = new QListView( this ); | 42 | ModulesView = new QListView( this ); |
43 | int colnum = ModulesView->addColumn( tr( "Module" ) ); | 43 | int colnum = ModulesView->addColumn( tr( "Module" ) ); |
44 | colnum = ModulesView->addColumn( tr( "Size" ) ); | 44 | colnum = ModulesView->addColumn( tr( "Size" ) ); |
45 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 45 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
46 | colnum = ModulesView->addColumn( tr( "Use#" ) ); | 46 | colnum = ModulesView->addColumn( tr( "Use#" ) ); |
47 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 47 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
48 | colnum = ModulesView->addColumn( tr( "Used by" ) ); | 48 | colnum = ModulesView->addColumn( tr( "Used by" ) ); |
49 | ModulesView->setAllColumnsShowFocus( TRUE ); | 49 | ModulesView->setAllColumnsShowFocus( TRUE ); |
50 | layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); | 50 | layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); |
51 | 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 | 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." ) ); |
52 | 52 | ||
53 | // Test if we have /sbin/modinfo, and if so, allow module detail window | 53 | // Test if we have /sbin/modinfo, and if so, allow module detail window |
54 | if ( QFile::exists( "/sbin/modinfo" ) ) | 54 | if ( QFile::exists( "/sbin/modinfo" ) ) |
55 | { | 55 | { |
56 | QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); | 56 | QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); |
57 | connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 57 | connect( ModulesView, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), |
58 | this, SLOT( viewModules( QListViewItem * ) ) ); | 58 | this, SLOT( viewModules(QListViewItem*) ) ); |
59 | } | 59 | } |
60 | 60 | ||
61 | CommandCB = new QComboBox( FALSE, this ); | 61 | CommandCB = new QComboBox( FALSE, this ); |
62 | CommandCB->insertItem( "modprobe -r" ); | 62 | CommandCB->insertItem( "modprobe -r" ); |
63 | CommandCB->insertItem( "rmmod" ); | 63 | CommandCB->insertItem( "rmmod" ); |
64 | // I can't think of other useful commands yet. Anyone? | 64 | // I can't think of other useful commands yet. Anyone? |
65 | layout->addWidget( CommandCB, 1, 0 ); | 65 | layout->addWidget( CommandCB, 1, 0 ); |
66 | 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." ) ); | 66 | 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." ) ); |
67 | 67 | ||
68 | QPushButton *btn = new QPushButton( this ); | 68 | QPushButton *btn = new QPushButton( this ); |
69 | btn->setMinimumSize( QSize( 50, 24 ) ); | 69 | btn->setMinimumSize( QSize( 50, 24 ) ); |
70 | btn->setMaximumSize( QSize( 50, 24 ) ); | 70 | btn->setMaximumSize( QSize( 50, 24 ) ); |
71 | btn->setText( tr( "Send" ) ); | 71 | btn->setText( tr( "Send" ) ); |
72 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); | 72 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); |
73 | layout->addWidget( btn, 1, 1 ); | 73 | layout->addWidget( btn, 1, 1 ); |
74 | QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); | 74 | QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); |
75 | 75 | ||
76 | QTimer *t = new QTimer( this ); | 76 | QTimer *t = new QTimer( this ); |
77 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 77 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
78 | t->start( 5000 ); | 78 | t->start( 5000 ); |
79 | 79 | ||
80 | updateData(); | 80 | updateData(); |
81 | 81 | ||
82 | ModulesDtl = new Detail(); | 82 | ModulesDtl = new Detail(); |
83 | QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); | 83 | QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); |
84 | } | 84 | } |
85 | 85 | ||
86 | ModulesInfo::~ModulesInfo() | 86 | ModulesInfo::~ModulesInfo() |
87 | {} | 87 | {} |
88 | 88 | ||
89 | void ModulesInfo::updateData() | 89 | void ModulesInfo::updateData() |
90 | { | 90 | { |
91 | char modname[64]; | 91 | char modname[64]; |
92 | char usage[200]; | 92 | char usage[200]; |
93 | int modsize, usecount; | 93 | int modsize, usecount; |
94 | 94 | ||
95 | QString selectedmod; | 95 | QString selectedmod; |
96 | QListViewItem *curritem = ModulesView->currentItem(); | 96 | QListViewItem *curritem = ModulesView->currentItem(); |
97 | if ( curritem ) | 97 | if ( curritem ) |
98 | { | 98 | { |
99 | selectedmod = curritem->text( 0 ); | 99 | selectedmod = curritem->text( 0 ); |
100 | } | 100 | } |
101 | 101 | ||
102 | ModulesView->clear(); | 102 | ModulesView->clear(); |
103 | 103 | ||
104 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); | 104 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); |
105 | 105 | ||
106 | if ( procfile ) | 106 | if ( procfile ) |
107 | { | 107 | { |
108 | QListViewItem *newitem; | 108 | QListViewItem *newitem; |
109 | QListViewItem *selecteditem = 0x0; | 109 | QListViewItem *selecteditem = 0x0; |
110 | while ( true ) | 110 | while ( true ) |
111 | { | 111 | { |
112 | modname[0] = '\0'; | 112 | modname[0] = '\0'; |
113 | usage[0] = '\0'; | 113 | usage[0] = '\0'; |
114 | int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); | 114 | int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); |
115 | 115 | ||
116 | if ( success == EOF ) | 116 | if ( success == EOF ) |
117 | break; | 117 | break; |
118 | 118 | ||
119 | QString qmodname = QString( modname ); | 119 | QString qmodname = QString( modname ); |
120 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); | 120 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); |
121 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); | 121 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); |
122 | QString qusage = QString( usage ); | 122 | QString qusage = QString( usage ); |
123 | 123 | ||
124 | newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); | 124 | newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); |
125 | if ( qmodname == selectedmod ) | 125 | if ( qmodname == selectedmod ) |
126 | { | 126 | { |
127 | selecteditem = newitem; | 127 | selecteditem = newitem; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | ModulesView->setCurrentItem( selecteditem ); | 130 | ModulesView->setCurrentItem( selecteditem ); |
131 | 131 | ||
132 | fclose( procfile ); | 132 | fclose( procfile ); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | void ModulesInfo::slotSendClicked() | 136 | void ModulesInfo::slotSendClicked() |
137 | { | 137 | { |
138 | if ( !ModulesView->currentItem() ) | 138 | if ( !ModulesView->currentItem() ) |
139 | { | 139 | { |
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | 142 | ||
143 | QString capstr = tr( "You really want to execute %1 for this module?" ).arg( CommandCB->currentText() ); | 143 | QString capstr = tr( "You really want to execute %1 for this module?" ).arg( CommandCB->currentText() ); |
144 | 144 | ||
145 | QString modname = ModulesView->currentItem()->text( 0 ); | 145 | QString modname = ModulesView->currentItem()->text( 0 ); |
146 | 146 | ||
147 | if ( QMessageBox::warning( this, modname, capstr, | 147 | if ( QMessageBox::warning( this, modname, capstr, |
148 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 148 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
149 | { | 149 | { |
150 | QString command = "/sbin/"; | 150 | QString command = "/sbin/"; |
151 | command.append( CommandCB->currentText() ); | 151 | command.append( CommandCB->currentText() ); |
152 | command.append( " " ); | 152 | command.append( " " ); |
153 | command.append( modname ); | 153 | command.append( modname ); |
154 | 154 | ||