-rw-r--r-- | noncore/applets/memoryapplet/swapfile.cpp | 82 |
1 files changed, 42 insertions, 40 deletions
diff --git a/noncore/applets/memoryapplet/swapfile.cpp b/noncore/applets/memoryapplet/swapfile.cpp index 7483592..04da8bb 100644 --- a/noncore/applets/memoryapplet/swapfile.cpp +++ b/noncore/applets/memoryapplet/swapfile.cpp | |||
@@ -11,62 +11,64 @@ | |||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "swapfile.h" | 21 | #include "swapfile.h" |
22 | 22 | ||
23 | #include <qfile.h> | ||
24 | #include <qtextstream.h> | ||
23 | #include <qlabel.h> | 25 | #include <qlabel.h> |
24 | #include <qtimer.h> | 26 | #include <qtimer.h> |
25 | #include <qlayout.h> | 27 | #include <qlayout.h> |
26 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
27 | #include <qhbuttongroup.h> | 29 | #include <qhbuttongroup.h> |
28 | #include <qradiobutton.h> | 30 | #include <qradiobutton.h> |
29 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
30 | #include <qprogressbar.h> | 32 | #include <qprogressbar.h> |
31 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
32 | #include <qvgroupbox.h> | 34 | #include <qvgroupbox.h> |
33 | #include <qhbox.h> | 35 | #include <qhbox.h> |
34 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
35 | #include <stdio.h> | 37 | #include <stdio.h> |
36 | #include <stdlib.h> | 38 | #include <stdlib.h> |
37 | #include <string.h> | 39 | #include <string.h> |
38 | 40 | ||
39 | #include <qcopchannel_qws.h> | 41 | #include <qcopchannel_qws.h> |
40 | #include <qpe/resource.h> | 42 | #include <qpe/resource.h> |
41 | 43 | ||
42 | #include <unistd.h> | 44 | #include <unistd.h> |
43 | #include <fcntl.h> | 45 | #include <fcntl.h> |
44 | #include <sys/vfs.h> | 46 | #include <sys/vfs.h> |
45 | #include <mntent.h> | 47 | #include <mntent.h> |
46 | #include <unistd.h> | 48 | #include <unistd.h> |
47 | #include <sys/types.h> | 49 | #include <sys/types.h> |
48 | 50 | ||
49 | Swapfile::Swapfile( QWidget *parent, const char *name, WFlags f ) | 51 | Swapfile::Swapfile( QWidget *parent, const char *name, WFlags f ) |
50 | : QWidget( parent, name, f ) | 52 | : QWidget( parent, name, f ) |
51 | { | 53 | { |
52 | // are we running as root? | 54 | // are we running as root? |
53 | isRoot = geteuid() == 0; | 55 | isRoot = geteuid() == 0; |
54 | 56 | ||
55 | QVBoxLayout* vb = new QVBoxLayout(this, 5); | 57 | QVBoxLayout* vb = new QVBoxLayout(this, 5); |
56 | 58 | ||
57 | QHButtonGroup* cfsdRBG = new QHButtonGroup(tr("Swapfile location"), this); | 59 | QHButtonGroup* cfsdRBG = new QHButtonGroup(tr("Swapfile location"), this); |
58 | cfsdRBG->setRadioButtonExclusive(true); | 60 | cfsdRBG->setRadioButtonExclusive(true); |
59 | vb->addWidget(cfsdRBG); | 61 | vb->addWidget(cfsdRBG); |
60 | 62 | ||
61 | ramRB = new QRadioButton(tr("RAM"), cfsdRBG); | 63 | ramRB = new QRadioButton(tr("RAM"), cfsdRBG); |
62 | cfRB = new QRadioButton(tr("CF Card"), cfsdRBG); | 64 | cfRB = new QRadioButton(tr("CF Card"), cfsdRBG); |
63 | sdRB = new QRadioButton(tr("SD Card"), cfsdRBG); | 65 | sdRB = new QRadioButton(tr("SD Card"), cfsdRBG); |
64 | 66 | ||
65 | QHBox *hb1 = new QHBox(this); | 67 | QHBox *hb1 = new QHBox(this); |
66 | hb1->setSpacing(5); | 68 | hb1->setSpacing(5); |
67 | 69 | ||
68 | swapPath1 = new QLineEdit(hb1); | 70 | swapPath1 = new QLineEdit(hb1); |
69 | swapPath1->setEnabled(false); | 71 | swapPath1->setEnabled(false); |
70 | 72 | ||
71 | QPushButton* swapOn = new QPushButton(tr(" On "), hb1); | 73 | QPushButton* swapOn = new QPushButton(tr(" On "), hb1); |
72 | QPushButton* swapOff = new QPushButton(tr(" Off "), hb1); | 74 | QPushButton* swapOff = new QPushButton(tr(" Off "), hb1); |
@@ -97,56 +99,56 @@ Swapfile::Swapfile( QWidget *parent, const char *name, WFlags f ) | |||
97 | vb->addWidget(hb4); | 99 | vb->addWidget(hb4); |
98 | 100 | ||
99 | connect(swapOn, SIGNAL(clicked()), this, SLOT(swapon())); | 101 | connect(swapOn, SIGNAL(clicked()), this, SLOT(swapon())); |
100 | connect(swapOff, SIGNAL(clicked()), this, SLOT(swapoff())); | 102 | connect(swapOff, SIGNAL(clicked()), this, SLOT(swapoff())); |
101 | connect(cfRB, SIGNAL(clicked()), this, SLOT(cfsdchecked())); | 103 | connect(cfRB, SIGNAL(clicked()), this, SLOT(cfsdchecked())); |
102 | connect(sdRB, SIGNAL(clicked()), this, SLOT(cfsdchecked())); | 104 | connect(sdRB, SIGNAL(clicked()), this, SLOT(cfsdchecked())); |
103 | connect(ramRB, SIGNAL(clicked()), this, SLOT(cfsdchecked())); | 105 | connect(ramRB, SIGNAL(clicked()), this, SLOT(cfsdchecked())); |
104 | connect(mkSwap, SIGNAL(clicked()), this, SLOT(makeswapfile())); | 106 | connect(mkSwap, SIGNAL(clicked()), this, SLOT(makeswapfile())); |
105 | connect(rmSwap, SIGNAL(clicked()), this, SLOT(removeswapfile())); | 107 | connect(rmSwap, SIGNAL(clicked()), this, SLOT(removeswapfile())); |
106 | 108 | ||
107 | cfRB->setEnabled(FALSE); | 109 | cfRB->setEnabled(FALSE); |
108 | sdRB->setEnabled(FALSE); | 110 | sdRB->setEnabled(FALSE); |
109 | 111 | ||
110 | QCopChannel *pcmciaChannel = new QCopChannel("QPE/Card", this); | 112 | QCopChannel *pcmciaChannel = new QCopChannel("QPE/Card", this); |
111 | connect(pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), this, SLOT(cardnotify(const QCString &, const QByteArray &))); | 113 | connect(pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), this, SLOT(cardnotify(const QCString &, const QByteArray &))); |
112 | QCopChannel *sdChannel = new QCopChannel("QPE/Card", this); | 114 | QCopChannel *sdChannel = new QCopChannel("QPE/Card", this); |
113 | connect(sdChannel, SIGNAL(received(const QCString &, const QByteArray &)), this, SLOT(cardnotify(const QCString &, const QByteArray &))); | 115 | connect(sdChannel, SIGNAL(received(const QCString &, const QByteArray &)), this, SLOT(cardnotify(const QCString &, const QByteArray &))); |
114 | 116 | ||
115 | cardInPcmcia0 = FALSE; | 117 | cardInPcmcia0 = FALSE; |
116 | cardInPcmcia1 = FALSE; | 118 | cardInPcmcia1 = FALSE; |
117 | cardInSd = FALSE; | 119 | cardInSd = FALSE; |
118 | 120 | ||
119 | Swapfile::status(); | 121 | Swapfile::status(); |
120 | Swapfile::getStatusPcmcia(); | 122 | Swapfile::getStatusPcmcia(); |
121 | Swapfile::getStatusSd(); | 123 | Swapfile::getStatusSd(); |
122 | } | 124 | } |
123 | 125 | ||
124 | int Swapfile::exec(const QString& arg) | 126 | int Swapfile::exec(const QString& arg) |
125 | { | 127 | { |
126 | return system((!isRoot ? "sudo " : "") + arg); | 128 | return system((!isRoot ? "sudo " : "") + arg); |
127 | } | 129 | } |
128 | 130 | ||
129 | 131 | ||
130 | Swapfile::~Swapfile() | 132 | Swapfile::~Swapfile() |
131 | { | 133 | { |
132 | } | 134 | } |
133 | 135 | ||
134 | void Swapfile::cardnotify(const QCString & msg, const QByteArray &) | 136 | void Swapfile::cardnotify(const QCString & msg, const QByteArray &) |
135 | { | 137 | { |
136 | if (msg == "stabChanged()") | 138 | if (msg == "stabChanged()") |
137 | { | 139 | { |
138 | getStatusPcmcia(); | 140 | getStatusPcmcia(); |
139 | } | 141 | } |
140 | else if (msg == "mtabChanged()") | 142 | else if (msg == "mtabChanged()") |
141 | { | 143 | { |
142 | getStatusSd(); | 144 | getStatusSd(); |
143 | } | 145 | } |
144 | } | 146 | } |
145 | 147 | ||
146 | void Swapfile::getStatusPcmcia() | 148 | void Swapfile::getStatusPcmcia() |
147 | { | 149 | { |
148 | 150 | ||
149 | bool cardWas0 = cardInPcmcia0;// remember last state | 151 | bool cardWas0 = cardInPcmcia0;// remember last state |
150 | bool cardWas1 = cardInPcmcia1; | 152 | bool cardWas1 = cardInPcmcia1; |
151 | 153 | ||
152 | QString fileName; | 154 | QString fileName; |
@@ -184,37 +186,37 @@ void Swapfile::getStatusPcmcia() | |||
184 | && !cardInPcmcia1) { | 186 | && !cardInPcmcia1) { |
185 | cardInPcmcia1 = TRUE; | 187 | cardInPcmcia1 = TRUE; |
186 | } | 188 | } |
187 | } | 189 | } |
188 | } | 190 | } |
189 | f.close(); | 191 | f.close(); |
190 | 192 | ||
191 | if (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1) { | 193 | if (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1) { |
192 | QString text = QString::null; | 194 | QString text = QString::null; |
193 | QString what = QString::null; | 195 | QString what = QString::null; |
194 | if (cardWas0 != cardInPcmcia0) { | 196 | if (cardWas0 != cardInPcmcia0) { |
195 | if (cardInPcmcia0) { | 197 | if (cardInPcmcia0) { |
196 | cfRB->setEnabled(TRUE); | 198 | cfRB->setEnabled(TRUE); |
197 | } else { | 199 | } else { |
198 | cfRB->setChecked(FALSE); | 200 | cfRB->setChecked(FALSE); |
199 | cfRB->setEnabled(FALSE); | 201 | cfRB->setEnabled(FALSE); |
200 | } | 202 | } |
201 | } | 203 | } |
202 | 204 | ||
203 | if (cardWas1 != cardInPcmcia1) { | 205 | if (cardWas1 != cardInPcmcia1) { |
204 | if (cardInPcmcia1) { | 206 | if (cardInPcmcia1) { |
205 | cfRB->setEnabled(TRUE); | 207 | cfRB->setEnabled(TRUE); |
206 | } else { | 208 | } else { |
207 | cfRB->setChecked(FALSE); | 209 | cfRB->setChecked(FALSE); |
208 | cfRB->setEnabled(FALSE); | 210 | cfRB->setEnabled(FALSE); |
209 | } | 211 | } |
210 | } | 212 | } |
211 | } | 213 | } |
212 | } else { | 214 | } else { |
213 | // no file found | 215 | // no file found |
214 | qDebug("no file found"); | 216 | qDebug("no file found"); |
215 | cardInPcmcia0 = FALSE; | 217 | cardInPcmcia0 = FALSE; |
216 | cardInPcmcia1 = FALSE; | 218 | cardInPcmcia1 = FALSE; |
217 | } | 219 | } |
218 | Swapfile::cfsdchecked(); | 220 | Swapfile::cfsdchecked(); |
219 | } | 221 | } |
220 | 222 | ||
@@ -236,28 +238,28 @@ void Swapfile::getStatusSd() | |||
236 | || fs.left(9) == "/dev/mmcd") { | 238 | || fs.left(9) == "/dev/mmcd") { |
237 | cardInSd = TRUE; | 239 | cardInSd = TRUE; |
238 | show(); | 240 | show(); |
239 | } | 241 | } |
240 | } | 242 | } |
241 | endmntent(mntfp); | 243 | endmntent(mntfp); |
242 | } | 244 | } |
243 | 245 | ||
244 | if (cardWas != cardInSd) { | 246 | if (cardWas != cardInSd) { |
245 | QString text = QString::null; | 247 | QString text = QString::null; |
246 | QString what = QString::null; | 248 | QString what = QString::null; |
247 | if (cardInSd) { | 249 | if (cardInSd) { |
248 | sdRB->setEnabled(TRUE); | 250 | sdRB->setEnabled(TRUE); |
249 | } else { | 251 | } else { |
250 | sdRB->setChecked(FALSE); | 252 | sdRB->setChecked(FALSE); |
251 | sdRB->setEnabled(FALSE); | 253 | sdRB->setEnabled(FALSE); |
252 | } | 254 | } |
253 | } | 255 | } |
254 | #else | 256 | #else |
255 | #error "Not on Linux" | 257 | #error "Not on Linux" |
256 | #endif | 258 | #endif |
257 | Swapfile::cfsdchecked(); | 259 | Swapfile::cfsdchecked(); |
258 | } | 260 | } |
259 | 261 | ||
260 | int rc=0; | 262 | int rc=0; |
261 | 263 | ||
262 | void Swapfile::swapon() | 264 | void Swapfile::swapon() |
263 | { | 265 | { |
@@ -278,155 +280,155 @@ void Swapfile::swapon() | |||
278 | 280 | ||
279 | 281 | ||
280 | void Swapfile::setStatusMessage(const QString& text, bool error /* = false */) | 282 | void Swapfile::setStatusMessage(const QString& text, bool error /* = false */) |
281 | { | 283 | { |
282 | swapStatus->setText("<b>" + text + "</b>"); | 284 | swapStatus->setText("<b>" + text + "</b>"); |
283 | swapStatusIcon->setPixmap(Resource::loadPixmap(error ? "close" : "done")); | 285 | swapStatusIcon->setPixmap(Resource::loadPixmap(error ? "close" : "done")); |
284 | } | 286 | } |
285 | 287 | ||
286 | 288 | ||
287 | void Swapfile::swapoff() | 289 | void Swapfile::swapoff() |
288 | { | 290 | { |
289 | char swapcmd[128] ="swapoff "; | 291 | char swapcmd[128] ="swapoff "; |
290 | if (Swapfile::cfRB->isChecked() == TRUE) | 292 | if (Swapfile::cfRB->isChecked() == TRUE) |
291 | Swapfile::cfsdchecked(); | 293 | Swapfile::cfsdchecked(); |
292 | strcat(swapcmd,swapPath1->text()); | 294 | strcat(swapcmd,swapPath1->text()); |
293 | char *runcmd = swapcmd; | 295 | char *runcmd = swapcmd; |
294 | rc = exec(QString("%1").arg(runcmd)); | 296 | rc = exec(QString("%1").arg(runcmd)); |
295 | if (rc != 0) { | 297 | if (rc != 0) { |
296 | setStatusMessage(tr("Failed to detach swapfile."), true); | 298 | setStatusMessage(tr("Failed to detach swapfile."), true); |
297 | } | 299 | } |
298 | else { | 300 | else { |
299 | /* QMessageBox::information(this, "Information", "Swapfile is inactive!"); */ | 301 | /* QMessageBox::information(this, "Information", "Swapfile is inactive!"); */ |
300 | setStatusMessage(tr("Swapfile deactivated.")); | 302 | setStatusMessage(tr("Swapfile deactivated.")); |
301 | /* Swapfile::swapPath->clear();*/ | 303 | /* Swapfile::swapPath->clear();*/ |
302 | } | 304 | } |
303 | Swapfile::status(); | 305 | Swapfile::status(); |
304 | } | 306 | } |
305 | 307 | ||
306 | void Swapfile::cfsdchecked() | 308 | void Swapfile::cfsdchecked() |
307 | { | 309 | { |
308 | /* Swapfile::swapPath->clear();*/ | 310 | /* Swapfile::swapPath->clear();*/ |
309 | Swapfile::swapPath1->clear(); | 311 | Swapfile::swapPath1->clear(); |
310 | if (Swapfile::ramRB->isChecked() == TRUE) | 312 | if (Swapfile::ramRB->isChecked() == TRUE) |
311 | { | 313 | { |
312 | Swapfile::swapPath1->insert("/home/swapfile"); | 314 | Swapfile::swapPath1->insert("/home/swapfile"); |
313 | } | 315 | } |
314 | if (Swapfile::sdRB->isChecked() == TRUE) | 316 | if (Swapfile::sdRB->isChecked() == TRUE) |
315 | { | 317 | { |
316 | Swapfile::swapPath1->insert("/mnt/card/swapfile"); | 318 | Swapfile::swapPath1->insert("/mnt/card/swapfile"); |
317 | } | 319 | } |
318 | if (Swapfile::cfRB->isChecked() == TRUE) | 320 | if (Swapfile::cfRB->isChecked() == TRUE) |
319 | { | 321 | { |
320 | Swapfile::swapPath1->insert("/mnt/cf/swapfile"); | 322 | Swapfile::swapPath1->insert("/mnt/cf/swapfile"); |
321 | } | 323 | } |
322 | /*Swapfile::swapPath->insert(Swapfile::swapPath1->text());*/ | 324 | /*Swapfile::swapPath->insert(Swapfile::swapPath1->text());*/ |
323 | } | 325 | } |
324 | 326 | ||
325 | void Swapfile::makeswapfile() | 327 | void Swapfile::makeswapfile() |
326 | { | 328 | { |
327 | int i = swapSize->currentItem(); | 329 | int i = swapSize->currentItem(); |
328 | 330 | ||
329 | mkswapProgress->setProgress(1); | 331 | mkswapProgress->setProgress(1); |
330 | switch ( i ) { | 332 | switch ( i ) { |
331 | case 0: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=2048").arg(swapPath1->text())); | 333 | case 0: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=2048").arg(swapPath1->text())); |
332 | break; | 334 | break; |
333 | case 1: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=4096").arg(swapPath1->text())); | 335 | case 1: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=4096").arg(swapPath1->text())); |
334 | break; | 336 | break; |
335 | case 2: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=6144").arg(swapPath1->text())); | 337 | case 2: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=6144").arg(swapPath1->text())); |
336 | break; | 338 | break; |
337 | case 3: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=8192").arg(swapPath1->text())); | 339 | case 3: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=8192").arg(swapPath1->text())); |
338 | break; | 340 | break; |
339 | } | 341 | } |
340 | if (rc != 0) { | 342 | if (rc != 0) { |
341 | setStatusMessage(tr("Failed to create swapfile."), true); | 343 | setStatusMessage(tr("Failed to create swapfile."), true); |
342 | } | 344 | } |
343 | 345 | ||
344 | mkswapProgress->setProgress(2); | 346 | mkswapProgress->setProgress(2); |
345 | rc=exec(QString("mkswap %1").arg(swapPath1->text())); | 347 | rc=exec(QString("mkswap %1").arg(swapPath1->text())); |
346 | if (rc != 0) { | 348 | if (rc != 0) { |
347 | setStatusMessage(tr("Failed to initialize swapfile."), true); | 349 | setStatusMessage(tr("Failed to initialize swapfile."), true); |
348 | } | 350 | } |
349 | mkswapProgress->setProgress(3); | 351 | mkswapProgress->setProgress(3); |
350 | mkswapProgress->reset(); | 352 | mkswapProgress->reset(); |
351 | setStatusMessage(tr("Swapfile created.")); | 353 | setStatusMessage(tr("Swapfile created.")); |
352 | } | 354 | } |
353 | 355 | ||
354 | void Swapfile::removeswapfile() | 356 | void Swapfile::removeswapfile() |
355 | { | 357 | { |
356 | exec(QString("swapoff %1").arg(swapPath1->text())); | 358 | exec(QString("swapoff %1").arg(swapPath1->text())); |
357 | rc=exec(QString("rm -rf %1").arg(swapPath1->text())); | 359 | rc=exec(QString("rm -rf %1").arg(swapPath1->text())); |
358 | if (rc != 0) { | 360 | if (rc != 0) { |
359 | setStatusMessage(tr("Failed to remove swapfile."), true); | 361 | setStatusMessage(tr("Failed to remove swapfile."), true); |
360 | } | 362 | } |
361 | Swapfile::status(); | 363 | Swapfile::status(); |
362 | Swapfile::cfsdchecked(); | 364 | Swapfile::cfsdchecked(); |
363 | setStatusMessage(tr("Swapfile removed.")); | 365 | setStatusMessage(tr("Swapfile removed.")); |
364 | } | 366 | } |
365 | 367 | ||
366 | void Swapfile::status() | 368 | void Swapfile::status() |
367 | { | 369 | { |
368 | FILE *fp; | 370 | FILE *fp; |
369 | char buffer[128], swapfile[128], temp[128]; | 371 | char buffer[128], swapfile[128], temp[128]; |
370 | int swapsize=2000, i=1; | 372 | int swapsize=2000, i=1; |
371 | 373 | ||
372 | fp=fopen("/proc/swaps", "r"); | 374 | fp=fopen("/proc/swaps", "r"); |
373 | while ( (fgets(buffer,128,fp)) != NULL ) { | 375 | while ( (fgets(buffer,128,fp)) != NULL ) { |
374 | sscanf(buffer, "%s %s %d %s %s\n", swapfile, temp, &swapsize, temp, temp); | 376 | sscanf(buffer, "%s %s %d %s %s\n", swapfile, temp, &swapsize, temp, temp); |
375 | } | 377 | } |
376 | fclose(fp); | 378 | fclose(fp); |
377 | 379 | ||
378 | ramRB->setChecked(FALSE); | 380 | ramRB->setChecked(FALSE); |
379 | cfRB->setChecked(FALSE); | 381 | cfRB->setChecked(FALSE); |
380 | sdRB->setChecked(FALSE); | 382 | sdRB->setChecked(FALSE); |
381 | 383 | ||
382 | i=strcmp(swapfile, "/home/swapfile"); | 384 | i=strcmp(swapfile, "/home/swapfile"); |
383 | if ( i == 0 ) { | 385 | if ( i == 0 ) { |
384 | ramRB->setChecked(TRUE); | 386 | ramRB->setChecked(TRUE); |
385 | /* QMessageBox::information(this, "Information", "Swapfile is active!"); */ | 387 | /* QMessageBox::information(this, "Information", "Swapfile is active!"); */ |
386 | setStatusMessage(tr("Swapfile activated.")); | 388 | setStatusMessage(tr("Swapfile activated.")); |
387 | } | 389 | } |
388 | i=strcmp(swapfile, "/usr/mnt.rom/cf/swapfile"); | 390 | i=strcmp(swapfile, "/usr/mnt.rom/cf/swapfile"); |
389 | if ( i == 0 ) { | 391 | if ( i == 0 ) { |
390 | cfRB->setChecked(TRUE); | 392 | cfRB->setChecked(TRUE); |
391 | /* QMessageBox::information(this, "Information", "Swapfile is active!"); */ | 393 | /* QMessageBox::information(this, "Information", "Swapfile is active!"); */ |
392 | setStatusMessage(tr("Swapfile activated.")); | 394 | setStatusMessage(tr("Swapfile activated.")); |
393 | } | 395 | } |
394 | i=strcmp(swapfile, "/mnt/cf/swapfile"); | 396 | i=strcmp(swapfile, "/mnt/cf/swapfile"); |
395 | if ( i == 0 ) { | 397 | if ( i == 0 ) { |
396 | cfRB->setChecked(TRUE); | 398 | cfRB->setChecked(TRUE); |
397 | /* QMessageBox::information(this, "Information", "Swapfile is active!"); */ | 399 | /* QMessageBox::information(this, "Information", "Swapfile is active!"); */ |
398 | setStatusMessage(tr("Swapfile activated.")); | 400 | setStatusMessage(tr("Swapfile activated.")); |
399 | } | 401 | } |
400 | i=strcmp(swapfile, "/usr/mnt.rom/card/swapfile"); | 402 | i=strcmp(swapfile, "/usr/mnt.rom/card/swapfile"); |
401 | if ( i == 0 ) { | 403 | if ( i == 0 ) { |
402 | sdRB->setChecked(TRUE); | 404 | sdRB->setChecked(TRUE); |
403 | /* QMessageBox::information(this, "Information", "Swapfile is active!"); */ | 405 | /* QMessageBox::information(this, "Information", "Swapfile is active!"); */ |
404 | setStatusMessage(tr("Swapfile activated.")); | 406 | setStatusMessage(tr("Swapfile activated.")); |
405 | } | 407 | } |
406 | i=strcmp(swapfile, "/mnt/card/swapfile"); | 408 | i=strcmp(swapfile, "/mnt/card/swapfile"); |
407 | if ( i == 0 ) { | 409 | if ( i == 0 ) { |
408 | sdRB->setChecked(TRUE); | 410 | sdRB->setChecked(TRUE); |
409 | /* QMessageBox::information(this, "Information", "Swapfile is active!"); */ | 411 | /* QMessageBox::information(this, "Information", "Swapfile is active!"); */ |
410 | setStatusMessage(tr("Swapfile activated.")); | 412 | setStatusMessage(tr("Swapfile activated.")); |
411 | } | 413 | } |
412 | 414 | ||
413 | Swapfile::cfsdchecked(); | 415 | Swapfile::cfsdchecked(); |
414 | 416 | ||
415 | 417 | ||
416 | swapsize /=1000; | 418 | swapsize /=1000; |
417 | 419 | ||
418 | switch ( swapsize ) { | 420 | switch ( swapsize ) { |
419 | case 2: swapSize->setCurrentItem(0); | 421 | case 2: swapSize->setCurrentItem(0); |
420 | break; | 422 | break; |
421 | case 4: swapSize->setCurrentItem(1); | 423 | case 4: swapSize->setCurrentItem(1); |
422 | break; | 424 | break; |
423 | case 6: swapSize->setCurrentItem(2); | 425 | case 6: swapSize->setCurrentItem(2); |
424 | break; | 426 | break; |
425 | case 8: swapSize->setCurrentItem(3); | 427 | case 8: swapSize->setCurrentItem(3); |
426 | break; | 428 | break; |
427 | } | 429 | } |
428 | 430 | ||
429 | 431 | ||
430 | } | 432 | } |
431 | 433 | ||
432 | 434 | ||