summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/memoryapplet/swapfile.cpp82
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
@@ -21,15 +21,17 @@
#include "swapfile.h"
+#include <qfile.h>
+#include <qtextstream.h>
#include <qlabel.h>
#include <qtimer.h>
#include <qlayout.h>
#include <qpushbutton.h>
-#include <qhbuttongroup.h>
-#include <qradiobutton.h>
-#include <qlineedit.h>
-#include <qprogressbar.h>
-#include <qcombobox.h>
-#include <qvgroupbox.h>
-#include <qhbox.h>
+#include <qhbuttongroup.h>
+#include <qradiobutton.h>
+#include <qlineedit.h>
+#include <qprogressbar.h>
+#include <qcombobox.h>
+#include <qvgroupbox.h>
+#include <qhbox.h>
#include <qmessagebox.h>
#include <stdio.h>
@@ -44,6 +46,6 @@
#include <sys/vfs.h>
#include <mntent.h>
-#include <unistd.h>
-#include <sys/types.h>
+#include <unistd.h>
+#include <sys/types.h>
Swapfile::Swapfile( QWidget *parent, const char *name, WFlags f )
@@ -58,5 +60,5 @@ Swapfile::Swapfile( QWidget *parent, const char *name, WFlags f )
cfsdRBG->setRadioButtonExclusive(true);
vb->addWidget(cfsdRBG);
-
+
ramRB = new QRadioButton(tr("RAM"), cfsdRBG);
cfRB = new QRadioButton(tr("CF Card"), cfsdRBG);
@@ -107,10 +109,10 @@ Swapfile::Swapfile( QWidget *parent, const char *name, WFlags f )
cfRB->setEnabled(FALSE);
sdRB->setEnabled(FALSE);
-
+
QCopChannel *pcmciaChannel = new QCopChannel("QPE/Card", this);
connect(pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), this, SLOT(cardnotify(const QCString &, const QByteArray &)));
QCopChannel *sdChannel = new QCopChannel("QPE/Card", this);
connect(sdChannel, SIGNAL(received(const QCString &, const QByteArray &)), this, SLOT(cardnotify(const QCString &, const QByteArray &)));
-
+
cardInPcmcia0 = FALSE;
cardInPcmcia1 = FALSE;
@@ -134,9 +136,9 @@ Swapfile::~Swapfile()
void Swapfile::cardnotify(const QCString & msg, const QByteArray &)
{
- if (msg == "stabChanged()")
+ if (msg == "stabChanged()")
{
getStatusPcmcia();
- }
- else if (msg == "mtabChanged()")
+ }
+ else if (msg == "mtabChanged()")
{
getStatusSd();
@@ -194,8 +196,8 @@ void Swapfile::getStatusPcmcia()
if (cardWas0 != cardInPcmcia0) {
if (cardInPcmcia0) {
- cfRB->setEnabled(TRUE);
+ cfRB->setEnabled(TRUE);
} else {
cfRB->setChecked(FALSE);
- cfRB->setEnabled(FALSE);
+ cfRB->setEnabled(FALSE);
}
}
@@ -203,8 +205,8 @@ void Swapfile::getStatusPcmcia()
if (cardWas1 != cardInPcmcia1) {
if (cardInPcmcia1) {
- cfRB->setEnabled(TRUE);
+ cfRB->setEnabled(TRUE);
} else {
cfRB->setChecked(FALSE);
- cfRB->setEnabled(FALSE);
+ cfRB->setEnabled(FALSE);
}
}
@@ -246,8 +248,8 @@ void Swapfile::getStatusSd()
QString what = QString::null;
if (cardInSd) {
- sdRB->setEnabled(TRUE);
+ sdRB->setEnabled(TRUE);
} else {
sdRB->setChecked(FALSE);
- sdRB->setEnabled(FALSE);
+ sdRB->setEnabled(FALSE);
}
}
@@ -288,5 +290,5 @@ void Swapfile::swapoff()
{
char swapcmd[128] ="swapoff ";
- if (Swapfile::cfRB->isChecked() == TRUE)
+ if (Swapfile::cfRB->isChecked() == TRUE)
Swapfile::cfsdchecked();
strcat(swapcmd,swapPath1->text());
@@ -308,5 +310,5 @@ void Swapfile::cfsdchecked()
/* Swapfile::swapPath->clear();*/
Swapfile::swapPath1->clear();
- if (Swapfile::ramRB->isChecked() == TRUE)
+ if (Swapfile::ramRB->isChecked() == TRUE)
{
Swapfile::swapPath1->insert("/home/swapfile");
@@ -324,8 +326,8 @@ void Swapfile::cfsdchecked()
void Swapfile::makeswapfile()
-{
+{
int i = swapSize->currentItem();
- mkswapProgress->setProgress(1);
+ mkswapProgress->setProgress(1);
switch ( i ) {
case 0: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=2048").arg(swapPath1->text()));
@@ -337,18 +339,18 @@ void Swapfile::makeswapfile()
case 3: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=8192").arg(swapPath1->text()));
break;
- }
+ }
if (rc != 0) {
setStatusMessage(tr("Failed to create swapfile."), true);
}
- mkswapProgress->setProgress(2);
+ mkswapProgress->setProgress(2);
rc=exec(QString("mkswap %1").arg(swapPath1->text()));
if (rc != 0) {
setStatusMessage(tr("Failed to initialize swapfile."), true);
}
- mkswapProgress->setProgress(3);
- mkswapProgress->reset();
+ mkswapProgress->setProgress(3);
+ mkswapProgress->reset();
setStatusMessage(tr("Swapfile created."));
-}
+}
void Swapfile::removeswapfile()
@@ -375,5 +377,5 @@ void Swapfile::status()
}
fclose(fp);
-
+
ramRB->setChecked(FALSE);
cfRB->setChecked(FALSE);
@@ -382,5 +384,5 @@ void Swapfile::status()
i=strcmp(swapfile, "/home/swapfile");
if ( i == 0 ) {
- ramRB->setChecked(TRUE);
+ ramRB->setChecked(TRUE);
/* QMessageBox::information(this, "Information", "Swapfile is active!"); */
setStatusMessage(tr("Swapfile activated."));
@@ -388,5 +390,5 @@ void Swapfile::status()
i=strcmp(swapfile, "/usr/mnt.rom/cf/swapfile");
if ( i == 0 ) {
- cfRB->setChecked(TRUE);
+ cfRB->setChecked(TRUE);
/* QMessageBox::information(this, "Information", "Swapfile is active!"); */
setStatusMessage(tr("Swapfile activated."));
@@ -394,5 +396,5 @@ void Swapfile::status()
i=strcmp(swapfile, "/mnt/cf/swapfile");
if ( i == 0 ) {
- cfRB->setChecked(TRUE);
+ cfRB->setChecked(TRUE);
/* QMessageBox::information(this, "Information", "Swapfile is active!"); */
setStatusMessage(tr("Swapfile activated."));
@@ -400,5 +402,5 @@ void Swapfile::status()
i=strcmp(swapfile, "/usr/mnt.rom/card/swapfile");
if ( i == 0 ) {
- sdRB->setChecked(TRUE);
+ sdRB->setChecked(TRUE);
/* QMessageBox::information(this, "Information", "Swapfile is active!"); */
setStatusMessage(tr("Swapfile activated."));
@@ -406,5 +408,5 @@ void Swapfile::status()
i=strcmp(swapfile, "/mnt/card/swapfile");
if ( i == 0 ) {
- sdRB->setChecked(TRUE);
+ sdRB->setChecked(TRUE);
/* QMessageBox::information(this, "Information", "Swapfile is active!"); */
setStatusMessage(tr("Swapfile activated."));
@@ -412,6 +414,6 @@ void Swapfile::status()
Swapfile::cfsdchecked();
-
-
+
+
swapsize /=1000;
@@ -425,6 +427,6 @@ void Swapfile::status()
case 8: swapSize->setCurrentItem(3);
break;
- }
-
+ }
+
}