summaryrefslogtreecommitdiff
path: root/core/launcher/stabmon.cpp
authorzecke <zecke>2003-08-28 14:46:42 (UTC)
committer zecke <zecke>2003-08-28 14:46:42 (UTC)
commit285e7737f47c508ee816c5a96ebfc4207dc78438 (patch) (unidiff)
tree195ec4cee2dc4330dab6abb935edeecfd52ec8ad /core/launcher/stabmon.cpp
parentb2929c823a2ec7d64b879266bebf2c648753c995 (diff)
downloadopie-285e7737f47c508ee816c5a96ebfc4207dc78438.zip
opie-285e7737f47c508ee816c5a96ebfc4207dc78438.tar.gz
opie-285e7737f47c508ee816c5a96ebfc4207dc78438.tar.bz2
Use /proc/fstab
Diffstat (limited to 'core/launcher/stabmon.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/stabmon.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/core/launcher/stabmon.cpp b/core/launcher/stabmon.cpp
index 3d0d534..4e5f290 100644
--- a/core/launcher/stabmon.cpp
+++ b/core/launcher/stabmon.cpp
@@ -1,10 +1,10 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
@@ -18,19 +18,23 @@
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21 21
22#include "stabmon.h" 22#include "stabmon.h"
23 23
24#include <qpe/qcopenvelope_qws.h> 24#ifdef QWS
25#include <qtopia/qcopenvelope_qws.h>
26#endif
25 27
26#include <qfile.h> 28#include <qfile.h>
27#include <qcstring.h> 29#include <qcstring.h>
28 30
29#include <sys/stat.h> 31#include <sys/stat.h>
32#if defined(Q_OS_LINUX) || defined(_OS_LINUX_)
30#include <unistd.h> 33#include <unistd.h>
34#endif
31#include <stdlib.h> 35#include <stdlib.h>
32 36
33SysFileMonitor::SysFileMonitor(QObject* parent) : 37SysFileMonitor::SysFileMonitor(QObject* parent) :
34 QObject(parent) 38 QObject(parent)
35{ 39{
36 startTimer(2000); 40 startTimer(2000);
@@ -56,37 +60,43 @@ void SysFileMonitor::timerEvent(QTimerEvent*)
56 for ( int i=0; i<nstab; i++ ) { 60 for ( int i=0; i<nstab; i++ ) {
57 if ( ::stat(tab[i], &s)==0 && (long)s.st_mtime != last[i] ) { 61 if ( ::stat(tab[i], &s)==0 && (long)s.st_mtime != last[i] ) {
58 last[i] = (long)s.st_mtime; 62 last[i] = (long)s.st_mtime;
59 ch=TRUE; 63 ch=TRUE;
60 } 64 }
61 if ( ch ) { 65 if ( ch ) {
66#ifndef QT_NO_COP
62 QCopEnvelope("QPE/Card", "stabChanged()" ); 67 QCopEnvelope("QPE/Card", "stabChanged()" );
68#endif
63 break; 69 break;
64 } 70 }
65 } 71 }
66 72
67 // st_size is no use, it's 0 for /proc/mounts too. Read it all. 73 // st_size is no use, it's 0 for /proc/mounts too. Read it all.
68 static int mtabSize = 0; 74 static int mtabSize = 0;
69 QFile f( "/proc/mounts" ); 75 QFile f( "/proc/mounts" );
70 if ( f.open(IO_ReadOnly) ) { 76 if ( f.open(IO_ReadOnly) ) {
71#if 0 77#if 0
72 // readAll does not work correctly on sequential devices (as eg. /proc files) 78 // readAll does not work correctly on sequential devices (as eg. /proc files)
73 QByteArray ba = f.readAll(); 79 QByteArray ba = f.readAll();
74 if ( (int)ba.size() != mtabSize ) { 80 if ( (int)ba.size() != mtabSize ) {
75 mtabSize = (int)ba.size(); 81 mtabSize = (int)ba.size();
82#ifndef QT_NO_COP
76 QCopEnvelope("QPE/Card", "mtabChanged()" ); 83 QCopEnvelope("QPE/Card", "mtabChanged()" );
84#endif
77 } 85 }
78#else 86#else
79 QString s; 87 QString s;
80 while( !f.atEnd() ) { 88 while( !f.atEnd() ) {
81 QString tmp; 89 QString tmp;
82 f.readLine( tmp, 1024 ); 90 f.readLine( tmp, 1024 );
83 s += tmp; 91 s += tmp;
84 } 92 }
85 if ( (int)s.length() != mtabSize ) { 93 if ( (int)s.length() != mtabSize ) {
86 mtabSize = (int)s.length(); 94 mtabSize = (int)s.length();
95#ifndef QT_NO_COP
87 QCopEnvelope("QPE/Card", "mtabChanged()" ); 96 QCopEnvelope("QPE/Card", "mtabChanged()" );
97#endif
88 } 98 }
89 #endif 99#endif
90 } 100 }
91} 101}
92 102