summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/memoryapplet/config.in6
-rw-r--r--noncore/applets/memoryapplet/opie-memoryapplet.control2
-rw-r--r--noncore/applets/memoryapplet/swapfile.cpp4
3 files changed, 6 insertions, 6 deletions
diff --git a/noncore/applets/memoryapplet/config.in b/noncore/applets/memoryapplet/config.in
index a35e35d..a06f888 100644
--- a/noncore/applets/memoryapplet/config.in
+++ b/noncore/applets/memoryapplet/config.in
@@ -1,6 +1,6 @@
1 config MEMORYAPPLET 1 config MEMORYAPPLET
2 boolean "opie-memoryapplet (view memory status and manage a swap file)" 2 boolean "opie-memoryapplet (view memory status and manage a swap file)"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI && SYSINFO 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && SYSINFO
5 comment "opie-memoryapplet needs a libqpe, libopie2ui and sysinfo" 5 comment "opie-memoryapplet needs a libqpe, libopie2core, libopie2ui and sysinfo"
6 depends ! ( LIBOPIE && SYSINFO ) 6 depends ! (( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && SYSINFO)
diff --git a/noncore/applets/memoryapplet/opie-memoryapplet.control b/noncore/applets/memoryapplet/opie-memoryapplet.control
index c01a93f..40f1ec1 100644
--- a/noncore/applets/memoryapplet/opie-memoryapplet.control
+++ b/noncore/applets/memoryapplet/opie-memoryapplet.control
@@ -1,10 +1,10 @@
1Package: opie-memoryapplet 1Package: opie-memoryapplet
2Files: plugins/applets/libmemoryapplet.so* pics/memory 2Files: plugins/applets/libmemoryapplet.so* pics/memory
3Priority: optional 3Priority: optional
4Section: opie/applets 4Section: opie/applets
5Maintainer: Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 5Maintainer: Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal, libopieui2 7Depends: task-opie-minimal, libopiecore2, libopieui2
8Description: Memory Applet 8Description: Memory Applet
9 This applet displays the amount of free memory and manages the swap partition 9 This applet displays the amount of free memory and manages the swap partition
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/applets/memoryapplet/swapfile.cpp b/noncore/applets/memoryapplet/swapfile.cpp
index 50c173b..cd16d6d 100644
--- a/noncore/applets/memoryapplet/swapfile.cpp
+++ b/noncore/applets/memoryapplet/swapfile.cpp
@@ -1,74 +1,74 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** Copyright (C) 2002-2005 the Opie Team <opie-devel@handhelds.org> 3** Copyright (C) 2002-2005 the Opie Team <opie-devel@handhelds.org>
4** 4**
5** This file is part of Opie Environment. 5** This file is part of Opie Environment.
6** 6**
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14** 14**
15** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
16** 16**
17** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you. 18** not clear to you.
19** 19**
20**********************************************************************/ 20**********************************************************************/
21 21
22#include "swapfile.h" 22#include "swapfile.h"
23 23
24/* OPIE */ 24/* OPIE */
25#include <opie2/odebug.h> 25#include <opie2/odebug.h>
26#include <qpe/resource.h> 26#include <opie2/oresource.h>
27using namespace Opie::Core; 27using namespace Opie::Core;
28 28
29/* QT */ 29/* QT */
30#include <qfile.h> 30#include <qfile.h>
31#include <qtextstream.h> 31#include <qtextstream.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qtimer.h> 33#include <qtimer.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qhbuttongroup.h> 36#include <qhbuttongroup.h>
37#include <qradiobutton.h> 37#include <qradiobutton.h>
38#include <qlineedit.h> 38#include <qlineedit.h>
39#include <qprogressbar.h> 39#include <qprogressbar.h>
40#include <qcombobox.h> 40#include <qcombobox.h>
41#include <qvgroupbox.h> 41#include <qvgroupbox.h>
42#include <qhbox.h> 42#include <qhbox.h>
43#include <qmessagebox.h> 43#include <qmessagebox.h>
44#include <qcopchannel_qws.h> 44#include <qcopchannel_qws.h>
45 45
46/* STD */ 46/* STD */
47#include <stdio.h> 47#include <stdio.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <string.h> 49#include <string.h>
50#include <unistd.h> 50#include <unistd.h>
51#include <fcntl.h> 51#include <fcntl.h>
52#include <sys/vfs.h> 52#include <sys/vfs.h>
53#include <mntent.h> 53#include <mntent.h>
54#include <unistd.h> 54#include <unistd.h>
55#include <sys/types.h> 55#include <sys/types.h>
56 56
57Swapfile::Swapfile( QWidget *parent, const char *name, WFlags f ) 57Swapfile::Swapfile( QWidget *parent, const char *name, WFlags f )
58 : QWidget( parent, name, f ) 58 : QWidget( parent, name, f )
59{ 59{
60 if ( !QFile::exists( "/proc/swaps" ) ) 60 if ( !QFile::exists( "/proc/swaps" ) )
61 { 61 {
62 QLabel *text = new QLabel( tr( "Swap disabled in kernel" ), this ); 62 QLabel *text = new QLabel( tr( "Swap disabled in kernel" ), this );
63 return; 63 return;
64 } 64 }
65 // are we running as root? 65 // are we running as root?
66 isRoot = geteuid() == 0; 66 isRoot = geteuid() == 0;
67 67
68 QVBoxLayout* vb = new QVBoxLayout(this, 5); 68 QVBoxLayout* vb = new QVBoxLayout(this, 5);
69 69
70 QHButtonGroup* cfsdRBG = new QHButtonGroup(tr("Swapfile location"), this); 70 QHButtonGroup* cfsdRBG = new QHButtonGroup(tr("Swapfile location"), this);
71 cfsdRBG->setRadioButtonExclusive(true); 71 cfsdRBG->setRadioButtonExclusive(true);
72 vb->addWidget(cfsdRBG); 72 vb->addWidget(cfsdRBG);
73 73
74 ramRB = new QRadioButton(tr("RAM"), cfsdRBG); 74 ramRB = new QRadioButton(tr("RAM"), cfsdRBG);
@@ -248,97 +248,97 @@ void Swapfile::getStatusSd()
248 if (fs.left(14) == "/dev/mmc/part1" || fs.left(7) == "/dev/sd" 248 if (fs.left(14) == "/dev/mmc/part1" || fs.left(7) == "/dev/sd"
249 || fs.left(9) == "/dev/mmcd") { 249 || fs.left(9) == "/dev/mmcd") {
250 cardInSd = TRUE; 250 cardInSd = TRUE;
251 show(); 251 show();
252 } 252 }
253 } 253 }
254 endmntent(mntfp); 254 endmntent(mntfp);
255 } 255 }
256 256
257 if (cardWas != cardInSd) { 257 if (cardWas != cardInSd) {
258 QString text = QString::null; 258 QString text = QString::null;
259 QString what = QString::null; 259 QString what = QString::null;
260 if (cardInSd) { 260 if (cardInSd) {
261 sdRB->setEnabled(TRUE); 261 sdRB->setEnabled(TRUE);
262 } else { 262 } else {
263 sdRB->setChecked(FALSE); 263 sdRB->setChecked(FALSE);
264 sdRB->setEnabled(FALSE); 264 sdRB->setEnabled(FALSE);
265 } 265 }
266 } 266 }
267#else 267#else
268#error "Not on Linux" 268#error "Not on Linux"
269#endif 269#endif
270 Swapfile::cfsdchecked(); 270 Swapfile::cfsdchecked();
271} 271}
272 272
273int rc=0; 273int rc=0;
274 274
275void Swapfile::swapon() 275void Swapfile::swapon()
276{ 276{
277 char swapcmd[128] ="swapon "; 277 char swapcmd[128] ="swapon ";
278 Swapfile::cfsdchecked(); 278 Swapfile::cfsdchecked();
279 strcat(swapcmd,swapPath1->text()); 279 strcat(swapcmd,swapPath1->text());
280 char *runcmd = swapcmd; 280 char *runcmd = swapcmd;
281 rc = exec(QString("%1").arg(runcmd)); 281 rc = exec(QString("%1").arg(runcmd));
282 if (rc != 0) { 282 if (rc != 0) {
283 setStatusMessage("Failed to attach swapfile.", true); 283 setStatusMessage("Failed to attach swapfile.", true);
284 } 284 }
285 else { 285 else {
286 /* QMessageBox::information(this, "Information", "Swapfile is active!"); */ 286 /* QMessageBox::information(this, "Information", "Swapfile is active!"); */
287 setStatusMessage("Swapfile activated."); 287 setStatusMessage("Swapfile activated.");
288 } 288 }
289 Swapfile::status(); 289 Swapfile::status();
290} 290}
291 291
292 292
293void Swapfile::setStatusMessage(const QString& text, bool error /* = false */) 293void Swapfile::setStatusMessage(const QString& text, bool error /* = false */)
294{ 294{
295 swapStatus->setText("<b>" + text + "</b>"); 295 swapStatus->setText("<b>" + text + "</b>");
296 swapStatusIcon->setPixmap(Resource::loadPixmap(error ? "close" : "done")); 296 swapStatusIcon->setPixmap(Opie::Core::OResource::loadPixmap(error ? "close" : "done", Opie::Core::OResource::SmallIcon));
297} 297}
298 298
299 299
300void Swapfile::swapoff() 300void Swapfile::swapoff()
301{ 301{
302 char swapcmd[128] ="swapoff "; 302 char swapcmd[128] ="swapoff ";
303 if (Swapfile::cfRB->isChecked() == TRUE) 303 if (Swapfile::cfRB->isChecked() == TRUE)
304 Swapfile::cfsdchecked(); 304 Swapfile::cfsdchecked();
305 strcat(swapcmd,swapPath1->text()); 305 strcat(swapcmd,swapPath1->text());
306 char *runcmd = swapcmd; 306 char *runcmd = swapcmd;
307 rc = exec(QString("%1").arg(runcmd)); 307 rc = exec(QString("%1").arg(runcmd));
308 if (rc != 0) { 308 if (rc != 0) {
309 setStatusMessage(tr("Failed to detach swapfile."), true); 309 setStatusMessage(tr("Failed to detach swapfile."), true);
310 } 310 }
311 else { 311 else {
312 /* QMessageBox::information(this, "Information", "Swapfile is inactive!"); */ 312 /* QMessageBox::information(this, "Information", "Swapfile is inactive!"); */
313 setStatusMessage(tr("Swapfile deactivated.")); 313 setStatusMessage(tr("Swapfile deactivated."));
314 /* Swapfile::swapPath->clear();*/ 314 /* Swapfile::swapPath->clear();*/
315 } 315 }
316 Swapfile::status(); 316 Swapfile::status();
317} 317}
318 318
319void Swapfile::cfsdchecked() 319void Swapfile::cfsdchecked()
320{ 320{
321 /* Swapfile::swapPath->clear();*/ 321 /* Swapfile::swapPath->clear();*/
322 Swapfile::swapPath1->clear(); 322 Swapfile::swapPath1->clear();
323 if (Swapfile::ramRB->isChecked() == TRUE) 323 if (Swapfile::ramRB->isChecked() == TRUE)
324 { 324 {
325 Swapfile::swapPath1->insert("/home/swapfile"); 325 Swapfile::swapPath1->insert("/home/swapfile");
326 } 326 }
327 if (Swapfile::sdRB->isChecked() == TRUE) 327 if (Swapfile::sdRB->isChecked() == TRUE)
328 { 328 {
329 Swapfile::swapPath1->insert("/mnt/card/swapfile"); 329 Swapfile::swapPath1->insert("/mnt/card/swapfile");
330 } 330 }
331 if (Swapfile::cfRB->isChecked() == TRUE) 331 if (Swapfile::cfRB->isChecked() == TRUE)
332 { 332 {
333 Swapfile::swapPath1->insert("/mnt/cf/swapfile"); 333 Swapfile::swapPath1->insert("/mnt/cf/swapfile");
334 } 334 }
335 /*Swapfile::swapPath->insert(Swapfile::swapPath1->text());*/ 335 /*Swapfile::swapPath->insert(Swapfile::swapPath1->text());*/
336} 336}
337 337
338void Swapfile::makeswapfile() 338void Swapfile::makeswapfile()
339{ 339{
340 int i = swapSize->currentItem(); 340 int i = swapSize->currentItem();
341 341
342 mkswapProgress->setProgress(1); 342 mkswapProgress->setProgress(1);
343 switch ( i ) { 343 switch ( i ) {
344 case 0: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=2048").arg(swapPath1->text())); 344 case 0: rc=exec(QString("dd if=/dev/zero of=%1 bs=1k count=2048").arg(swapPath1->text()));