summaryrefslogtreecommitdiff
path: root/library/storage.cpp
Unidiff
Diffstat (limited to 'library/storage.cpp') (more/less context) (show whitespace changes)
-rw-r--r--library/storage.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/library/storage.cpp b/library/storage.cpp
index bd34a5f..a4c96be 100644
--- a/library/storage.cpp
+++ b/library/storage.cpp
@@ -1,49 +1,51 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org>
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 3** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 4**
4** This file is part of Qtopia Environment. 5** This file is part of Qtopia Environment.
5** 6**
6** 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
7** 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
8** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 10** packaging of this file.
10** 11**
11** 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
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 14**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 16**
16** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 18** not clear to you.
18** 19**
19**********************************************************************/ 20**********************************************************************/
20 21
21#include <qpe/storage.h> 22#include <qpe/storage.h>
22#ifdef QT_QWS_CUSTOM 23#ifdef QT_QWS_CUSTOM
23#include <qpe/custom.h> 24#include <qpe/custom.h>
24#endif 25#endif
25 26
27#include <qfile.h>
26#include <qtimer.h> 28#include <qtimer.h>
27#include <qcopchannel_qws.h> 29#include <qcopchannel_qws.h>
28 30
29#include <stdio.h> 31#include <stdio.h>
30 32
31#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 33#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
32#include <sys/vfs.h> 34#include <sys/vfs.h>
33#include <mntent.h> 35#include <mntent.h>
34#endif 36#endif
35 37
36#include <qstringlist.h> 38#include <qstringlist.h>
37 39
38static bool isCF(const QString& m) 40static bool isCF(const QString& m)
39{ 41{
40 FILE* f = fopen("/var/run/stab", "r"); 42 FILE* f = fopen("/var/run/stab", "r");
41 if (!f) f = fopen("/var/state/pcmcia/stab", "r"); 43 if (!f) f = fopen("/var/state/pcmcia/stab", "r");
42 if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); 44 if (!f) f = fopen("/var/lib/pcmcia/stab", "r");
43 if ( f ) { 45 if ( f ) {
44 char line[1024]; 46 char line[1024];
45 char devtype[80]; 47 char devtype[80];
46 char devname[80]; 48 char devname[80];
47 while ( fgets( line, 1024, f ) ) { 49 while ( fgets( line, 1024, f ) ) {
48 // 0 ide ide-cs 0 hda 3 0 50 // 0 ide ide-cs 0 hda 3 0
49 if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) 51 if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 )
@@ -63,49 +65,50 @@ StorageInfo::StorageInfo( QObject *parent )
63 : QObject( parent ) 65 : QObject( parent )
64{ 66{
65 mFileSystems.setAutoDelete( TRUE ); 67 mFileSystems.setAutoDelete( TRUE );
66 channel = new QCopChannel( "QPE/Card", this ); 68 channel = new QCopChannel( "QPE/Card", this );
67 connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), 69 connect( channel, SIGNAL(received(const QCString &, const QByteArray &)),
68 this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); 70 this, SLOT(cardMessage( const QCString &, const QByteArray &)) );
69 update(); 71 update();
70} 72}
71 73
72const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) 74const FileSystem *StorageInfo::fileSystemOf( const QString &filename )
73{ 75{
74 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { 76 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) {
75 if ( filename.startsWith( (*i)->path() ) ) 77 if ( filename.startsWith( (*i)->path() ) )
76 return (*i); 78 return (*i);
77 } 79 }
78 return 0; 80 return 0;
79} 81}
80 82
81 83
82void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) 84void StorageInfo::cardMessage( const QCString& msg, const QByteArray& )
83{ 85{
84 if ( msg == "mtabChanged()" ) 86 if ( msg == "mtabChanged()" )
85 update(); 87 update();
86} 88}
87 89// cause of the lack of a d pointer we need
90// to store informations in a config file :(
88void StorageInfo::update() 91void StorageInfo::update()
89{ 92{
90 //qDebug("StorageInfo::updating"); 93 //qDebug("StorageInfo::updating");
91#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 94#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
92 struct mntent *me; 95 struct mntent *me;
93 FILE *mntfp = setmntent( "/etc/mtab", "r" ); 96 FILE *mntfp = setmntent( "/etc/mtab", "r" );
94 97
95 QStringList curdisks; 98 QStringList curdisks;
96 QStringList curopts; 99 QStringList curopts;
97 QStringList curfs; 100 QStringList curfs;
98 bool rebuild = FALSE; 101 bool rebuild = FALSE;
99 int n=0; 102 int n=0;
100 if ( mntfp ) { 103 if ( mntfp ) {
101 while ( (me = getmntent( mntfp )) != 0 ) { 104 while ( (me = getmntent( mntfp )) != 0 ) {
102 QString fs = me->mnt_fsname; 105 QString fs = me->mnt_fsname;
103 if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd" 106 if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd"
104 || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd" ) 107 || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd" )
105 { 108 {
106 n++; 109 n++;
107 curdisks.append(fs); 110 curdisks.append(fs);
108 curopts.append( me->mnt_opts ); 111 curopts.append( me->mnt_opts );
109 //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts ); 112 //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts );
110 curfs.append( me->mnt_dir ); 113 curfs.append( me->mnt_dir );
111 bool found = FALSE; 114 bool found = FALSE;