-rw-r--r-- | noncore/settings/sysinfo/modulesinfo.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp index 8def0d6..0bf51e8 100644 --- a/noncore/settings/sysinfo/modulesinfo.cpp +++ b/noncore/settings/sysinfo/modulesinfo.cpp | |||
@@ -67,96 +67,98 @@ ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) | |||
67 | // I can't think of other useful commands yet. Anyone? | 67 | // I can't think of other useful commands yet. Anyone? |
68 | layout->addWidget( CommandCB, 1, 0 ); | 68 | layout->addWidget( CommandCB, 1, 0 ); |
69 | 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." ) ); | 69 | 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." ) ); |
70 | 70 | ||
71 | QPushButton *btn = new QPushButton( this ); | 71 | QPushButton *btn = new QPushButton( this ); |
72 | btn->setMinimumSize( QSize( 50, 24 ) ); | 72 | btn->setMinimumSize( QSize( 50, 24 ) ); |
73 | btn->setMaximumSize( QSize( 50, 24 ) ); | 73 | btn->setMaximumSize( QSize( 50, 24 ) ); |
74 | btn->setText( tr( "Send" ) ); | 74 | btn->setText( tr( "Send" ) ); |
75 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); | 75 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); |
76 | layout->addWidget( btn, 1, 1 ); | 76 | layout->addWidget( btn, 1, 1 ); |
77 | QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); | 77 | QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); |
78 | 78 | ||
79 | QTimer *t = new QTimer( this ); | 79 | QTimer *t = new QTimer( this ); |
80 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 80 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
81 | t->start( 5000 ); | 81 | t->start( 5000 ); |
82 | 82 | ||
83 | updateData(); | 83 | updateData(); |
84 | 84 | ||
85 | ModulesDtl = new Detail(); | 85 | ModulesDtl = new Detail(); |
86 | QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); | 86 | QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); |
87 | } | 87 | } |
88 | 88 | ||
89 | ModulesInfo::~ModulesInfo() | 89 | ModulesInfo::~ModulesInfo() |
90 | { | 90 | { |
91 | } | 91 | } |
92 | 92 | ||
93 | void ModulesInfo::updateData() | 93 | void ModulesInfo::updateData() |
94 | { | 94 | { |
95 | char modname[64]; | 95 | char modname[64]; |
96 | char usage[200]; | 96 | char usage[200]; |
97 | int modsize, usecount; | 97 | int modsize, usecount; |
98 | 98 | ||
99 | QString selectedmod; | 99 | QString selectedmod; |
100 | QListViewItem *curritem = ModulesView->currentItem(); | 100 | QListViewItem *curritem = ModulesView->currentItem(); |
101 | if ( curritem ) | 101 | if ( curritem ) |
102 | { | 102 | { |
103 | selectedmod = curritem->text( 0 ); | 103 | selectedmod = curritem->text( 0 ); |
104 | } | 104 | } |
105 | 105 | ||
106 | ModulesView->clear(); | 106 | ModulesView->clear(); |
107 | 107 | ||
108 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); | 108 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); |
109 | 109 | ||
110 | if ( procfile ) | 110 | if ( procfile ) |
111 | { | 111 | { |
112 | QListViewItem *newitem; | 112 | QListViewItem *newitem; |
113 | QListViewItem *selecteditem = 0x0; | 113 | QListViewItem *selecteditem = 0x0; |
114 | while ( true ) { | 114 | while ( true ) { |
115 | modname[0] = '\0'; | ||
116 | usage[0] = '\0'; | ||
115 | int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); | 117 | int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); |
116 | 118 | ||
117 | if ( success == EOF ) | 119 | if ( success == EOF ) |
118 | break; | 120 | break; |
119 | 121 | ||
120 | QString qmodname = QString( modname ); | 122 | QString qmodname = QString( modname ); |
121 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); | 123 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); |
122 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); | 124 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); |
123 | QString qusage = QString( usage ); | 125 | QString qusage = QString( usage ); |
124 | 126 | ||
125 | newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); | 127 | newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); |
126 | if ( qmodname == selectedmod ) | 128 | if ( qmodname == selectedmod ) |
127 | { | 129 | { |
128 | selecteditem = newitem; | 130 | selecteditem = newitem; |
129 | } | 131 | } |
130 | } | 132 | } |
131 | ModulesView->setCurrentItem( selecteditem ); | 133 | ModulesView->setCurrentItem( selecteditem ); |
132 | 134 | ||
133 | fclose( procfile ); | 135 | fclose( procfile ); |
134 | } | 136 | } |
135 | } | 137 | } |
136 | 138 | ||
137 | void ModulesInfo::slotSendClicked() | 139 | void ModulesInfo::slotSendClicked() |
138 | { | 140 | { |
139 | if ( !ModulesView->currentItem() ) | 141 | if ( !ModulesView->currentItem() ) |
140 | { | 142 | { |
141 | return; | 143 | return; |
142 | } | 144 | } |
143 | 145 | ||
144 | QString capstr = tr( "You really want to execute %1 for this module?" ).arg( CommandCB->currentText() ); | 146 | QString capstr = tr( "You really want to execute %1 for this module?" ).arg( CommandCB->currentText() ); |
145 | 147 | ||
146 | QString modname = ModulesView->currentItem()->text( 0 ); | 148 | QString modname = ModulesView->currentItem()->text( 0 ); |
147 | 149 | ||
148 | if ( QMessageBox::warning( this, modname, capstr, | 150 | if ( QMessageBox::warning( this, modname, capstr, |
149 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 151 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
150 | { | 152 | { |
151 | QString command = "/sbin/"; | 153 | QString command = "/sbin/"; |
152 | command.append( CommandCB->currentText() ); | 154 | command.append( CommandCB->currentText() ); |
153 | command.append( " " ); | 155 | command.append( " " ); |
154 | command.append( modname ); | 156 | command.append( modname ); |
155 | 157 | ||
156 | FILE* stream = popen( command, "r" ); | 158 | FILE* stream = popen( command, "r" ); |
157 | if ( stream ) | 159 | if ( stream ) |
158 | pclose( stream ); | 160 | pclose( stream ); |
159 | } | 161 | } |
160 | 162 | ||
161 | } | 163 | } |
162 | 164 | ||