summaryrefslogtreecommitdiff
path: root/noncore/applets/memoryapplet/swapfile.cpp
Unidiff
Diffstat (limited to 'noncore/applets/memoryapplet/swapfile.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/memoryapplet/swapfile.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/noncore/applets/memoryapplet/swapfile.cpp b/noncore/applets/memoryapplet/swapfile.cpp
index 9416db3..a71078f 100644
--- a/noncore/applets/memoryapplet/swapfile.cpp
+++ b/noncore/applets/memoryapplet/swapfile.cpp
@@ -11,80 +11,85 @@
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/* OPIE */
24#include <opie2/odebug.h>
25#include <qpe/resource.h>
26using namespace Opie::Core;
27
28/* QT */
23#include <qfile.h> 29#include <qfile.h>
24#include <qtextstream.h> 30#include <qtextstream.h>
25#include <qlabel.h> 31#include <qlabel.h>
26#include <qtimer.h> 32#include <qtimer.h>
27#include <qlayout.h> 33#include <qlayout.h>
28#include <qpushbutton.h> 34#include <qpushbutton.h>
29#include <qhbuttongroup.h> 35#include <qhbuttongroup.h>
30#include <qradiobutton.h> 36#include <qradiobutton.h>
31#include <qlineedit.h> 37#include <qlineedit.h>
32#include <qprogressbar.h> 38#include <qprogressbar.h>
33#include <qcombobox.h> 39#include <qcombobox.h>
34#include <qvgroupbox.h> 40#include <qvgroupbox.h>
35#include <qhbox.h> 41#include <qhbox.h>
36#include <qmessagebox.h> 42#include <qmessagebox.h>
43#include <qcopchannel_qws.h>
44
45/* STD */
37#include <stdio.h> 46#include <stdio.h>
38#include <stdlib.h> 47#include <stdlib.h>
39#include <string.h> 48#include <string.h>
40
41#include <qcopchannel_qws.h>
42#include <qpe/resource.h>
43
44#include <unistd.h> 49#include <unistd.h>
45#include <fcntl.h> 50#include <fcntl.h>
46#include <sys/vfs.h> 51#include <sys/vfs.h>
47#include <mntent.h> 52#include <mntent.h>
48#include <unistd.h> 53#include <unistd.h>
49#include <sys/types.h> 54#include <sys/types.h>
50 55
51Swapfile::Swapfile( QWidget *parent, const char *name, WFlags f ) 56Swapfile::Swapfile( QWidget *parent, const char *name, WFlags f )
52 : QWidget( parent, name, f ) 57 : QWidget( parent, name, f )
53{ 58{
54 // are we running as root? 59 // are we running as root?
55 isRoot = geteuid() == 0; 60 isRoot = geteuid() == 0;
56 61
57 QVBoxLayout* vb = new QVBoxLayout(this, 5); 62 QVBoxLayout* vb = new QVBoxLayout(this, 5);
58 63
59 QHButtonGroup* cfsdRBG = new QHButtonGroup(tr("Swapfile location"), this); 64 QHButtonGroup* cfsdRBG = new QHButtonGroup(tr("Swapfile location"), this);
60 cfsdRBG->setRadioButtonExclusive(true); 65 cfsdRBG->setRadioButtonExclusive(true);
61 vb->addWidget(cfsdRBG); 66 vb->addWidget(cfsdRBG);
62 67
63 ramRB = new QRadioButton(tr("RAM"), cfsdRBG); 68 ramRB = new QRadioButton(tr("RAM"), cfsdRBG);
64 cfRB = new QRadioButton(tr("CF Card"), cfsdRBG); 69 cfRB = new QRadioButton(tr("CF Card"), cfsdRBG);
65 sdRB = new QRadioButton(tr("SD Card"), cfsdRBG); 70 sdRB = new QRadioButton(tr("SD Card"), cfsdRBG);
66 71
67 QHBox *hb1 = new QHBox(this); 72 QHBox *hb1 = new QHBox(this);
68 hb1->setSpacing(5); 73 hb1->setSpacing(5);
69 74
70 swapPath1 = new QLineEdit(hb1); 75 swapPath1 = new QLineEdit(hb1);
71 swapPath1->setEnabled(false); 76 swapPath1->setEnabled(false);
72 77
73 QPushButton* swapOn = new QPushButton(tr(" On "), hb1); 78 QPushButton* swapOn = new QPushButton(tr(" On "), hb1);
74 QPushButton* swapOff = new QPushButton(tr(" Off "), hb1); 79 QPushButton* swapOff = new QPushButton(tr(" Off "), hb1);
75 vb->addWidget(hb1); 80 vb->addWidget(hb1);
76 81
77 QVGroupBox* box1 = new QVGroupBox(tr("Manage Swapfile"), this); 82 QVGroupBox* box1 = new QVGroupBox(tr("Manage Swapfile"), this);
78 vb->addWidget(box1); 83 vb->addWidget(box1);
79 84
80 QHBox *hb2 = new QHBox(box1); 85 QHBox *hb2 = new QHBox(box1);
81 hb2->setSpacing(5); 86 hb2->setSpacing(5);
82 QPushButton* mkSwap = new QPushButton(tr("Generate"), hb2); 87 QPushButton* mkSwap = new QPushButton(tr("Generate"), hb2);
83 QPushButton* rmSwap = new QPushButton(tr("Remove"), hb2); 88 QPushButton* rmSwap = new QPushButton(tr("Remove"), hb2);
84 89
85 QHBox *hb3 = new QHBox(box1); 90 QHBox *hb3 = new QHBox(box1);
86 hb3->setSpacing(5); 91 hb3->setSpacing(5);
87 swapSize = new QComboBox(hb3); 92 swapSize = new QComboBox(hb3);
88 swapSize->insertStringList(QStringList::split(",", tr("2 Mb,4 Mb,6 Mb,8 Mb"))); 93 swapSize->insertStringList(QStringList::split(",", tr("2 Mb,4 Mb,6 Mb,8 Mb")));
89 94
90 mkswapProgress = new QProgressBar(3, hb3); 95 mkswapProgress = new QProgressBar(3, hb3);
@@ -204,25 +209,25 @@ void Swapfile::getStatusPcmcia()
204 209
205 if (cardWas1 != cardInPcmcia1) { 210 if (cardWas1 != cardInPcmcia1) {
206 if (cardInPcmcia1) { 211 if (cardInPcmcia1) {
207 cfRB->setEnabled(TRUE); 212 cfRB->setEnabled(TRUE);
208 } else { 213 } else {
209 cfRB->setChecked(FALSE); 214 cfRB->setChecked(FALSE);
210 cfRB->setEnabled(FALSE); 215 cfRB->setEnabled(FALSE);
211 } 216 }
212 } 217 }
213 } 218 }
214 } else { 219 } else {
215 // no file found 220 // no file found
216 qDebug("no file found"); 221 odebug << "no file found" << oendl;
217 cardInPcmcia0 = FALSE; 222 cardInPcmcia0 = FALSE;
218 cardInPcmcia1 = FALSE; 223 cardInPcmcia1 = FALSE;
219 } 224 }
220 Swapfile::cfsdchecked(); 225 Swapfile::cfsdchecked();
221} 226}
222 227
223 228
224void Swapfile::getStatusSd() 229void Swapfile::getStatusSd()
225{ 230{
226 231
227 bool cardWas = cardInSd;// remember last state 232 bool cardWas = cardInSd;// remember last state
228 cardInSd = FALSE; 233 cardInSd = FALSE;