summaryrefslogtreecommitdiff
path: root/library/storage.cpp
Unidiff
Diffstat (limited to 'library/storage.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/storage.cpp2
1 files changed, 0 insertions, 2 deletions
diff --git a/library/storage.cpp b/library/storage.cpp
index 1ce43bc..dc5cc22 100644
--- a/library/storage.cpp
+++ b/library/storage.cpp
@@ -1,122 +1,120 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org> 2** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org>
3** Copyright (C) Lorn Potter <llornkcor@handhelds.org> 3** Copyright (C) Lorn Potter <llornkcor@handhelds.org>
4** Copyright (C) 2000 Trolltech AS. All rights reserved. 4** Copyright (C) 2000 Trolltech AS. All rights reserved.
5** 5**
6** This file is part of Opie Environment. 6** This file is part of Opie Environment.
7** 7**
8** This file may be distributed and/or modified under the terms of the 8** This file may be distributed and/or modified under the terms of the
9** GNU General Public License version 2 as published by the Free Software 9** GNU General Public License version 2 as published by the Free Software
10** Foundation and appearing in the file LICENSE.GPL included in the 10** Foundation and appearing in the file LICENSE.GPL included in the
11** packaging of this file. 11** packaging of this file.
12** 12**
13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15** 15**
16** See http://www.trolltech.com/gpl/ for GPL licensing information. 16** See http://www.trolltech.com/gpl/ for GPL licensing information.
17** 17**
18** Contact info@trolltech.com if any conditions of this licensing are 18** Contact info@trolltech.com if any conditions of this licensing are
19** not clear to you. 19** not clear to you.
20** 20**
21**********************************************************************/ 21**********************************************************************/
22 22
23#include <qpe/storage.h> 23#include <qpe/storage.h>
24#if defined(QT_QWS_SL5XXX)
25#include <qpe/custom.h> 24#include <qpe/custom.h>
26#endif
27 25
28#include <qfile.h> 26#include <qfile.h>
29#include <qtimer.h> 27#include <qtimer.h>
30#include <qcopchannel_qws.h> 28#include <qcopchannel_qws.h>
31 29
32#include <stdio.h> 30#include <stdio.h>
33 31
34#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 32#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
35#include <sys/vfs.h> 33#include <sys/vfs.h>
36#include <mntent.h> 34#include <mntent.h>
37#endif 35#endif
38 36
39#include <qstringlist.h> 37#include <qstringlist.h>
40 38
41#include <sys/vfs.h> 39#include <sys/vfs.h>
42#include <mntent.h> 40#include <mntent.h>
43 41
44 42
45static bool isCF(const QString& m) 43static bool isCF(const QString& m)
46{ 44{
47 FILE* f = fopen("/var/run/stab", "r"); 45 FILE* f = fopen("/var/run/stab", "r");
48 if (!f) f = fopen("/var/state/pcmcia/stab", "r"); 46 if (!f) f = fopen("/var/state/pcmcia/stab", "r");
49 if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); 47 if (!f) f = fopen("/var/lib/pcmcia/stab", "r");
50 if ( f ) { 48 if ( f ) {
51 char line[1024]; 49 char line[1024];
52 char devtype[80]; 50 char devtype[80];
53 char devname[80]; 51 char devname[80];
54 while ( fgets( line, 1024, f ) ) { 52 while ( fgets( line, 1024, f ) ) {
55 // 0 ide ide-cs 0 hda 3 0 53 // 0 ide ide-cs 0 hda 3 0
56 if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) 54 if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 )
57 { 55 {
58 if ( QString(devtype) == "ide" && m.find(devname)>0 ) { 56 if ( QString(devtype) == "ide" && m.find(devname)>0 ) {
59 fclose(f); 57 fclose(f);
60 return TRUE; 58 return TRUE;
61 } 59 }
62 } 60 }
63 } 61 }
64 fclose(f); 62 fclose(f);
65 } 63 }
66 return FALSE; 64 return FALSE;
67} 65}
68 66
69/*! \class StorageInfo storage.h 67/*! \class StorageInfo storage.h
70 \brief The StorageInfo class describes the disks mounted on the file system. 68 \brief The StorageInfo class describes the disks mounted on the file system.
71 69
72 This class provides access to the mount information for the Linux 70 This class provides access to the mount information for the Linux
73 filesystem. Each mount point is represented by the FileSystem class. 71 filesystem. Each mount point is represented by the FileSystem class.
74 To ensure this class has the most up to date size information, call 72 To ensure this class has the most up to date size information, call
75 the update() method. Note that this will automatically be signaled 73 the update() method. Note that this will automatically be signaled
76 by the operating system when a disk has been mounted or unmounted. 74 by the operating system when a disk has been mounted or unmounted.
77 75
78 \ingroup qtopiaemb 76 \ingroup qtopiaemb
79*/ 77*/
80 78
81/*! Constructor that determines the current mount points of the filesystem. 79/*! Constructor that determines the current mount points of the filesystem.
82 The standard \a parent parameters is passed on to QObject. 80 The standard \a parent parameters is passed on to QObject.
83 */ 81 */
84StorageInfo::StorageInfo( QObject *parent ) 82StorageInfo::StorageInfo( QObject *parent )
85 : QObject( parent ) 83 : QObject( parent )
86{ 84{
87 mFileSystems.setAutoDelete( TRUE ); 85 mFileSystems.setAutoDelete( TRUE );
88 channel = new QCopChannel( "QPE/Card", this ); 86 channel = new QCopChannel( "QPE/Card", this );
89 connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), 87 connect( channel, SIGNAL(received(const QCString &, const QByteArray &)),
90 this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); 88 this, SLOT(cardMessage( const QCString &, const QByteArray &)) );
91 update(); 89 update();
92} 90}
93 91
94/*! Returns the longest matching FileSystem that starts with the 92/*! Returns the longest matching FileSystem that starts with the
95 same prefix as \a filename as its mount point. 93 same prefix as \a filename as its mount point.
96*/ 94*/
97const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) 95const FileSystem *StorageInfo::fileSystemOf( const QString &filename )
98{ 96{
99 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { 97 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) {
100 if ( filename.startsWith( (*i)->path() ) ) 98 if ( filename.startsWith( (*i)->path() ) )
101 return (*i); 99 return (*i);
102 } 100 }
103 return 0; 101 return 0;
104} 102}
105 103
106 104
107void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) 105void StorageInfo::cardMessage( const QCString& msg, const QByteArray& )
108{ 106{
109 if ( msg == "mtabChanged()" ) 107 if ( msg == "mtabChanged()" )
110 update(); 108 update();
111} 109}
112 110
113 111
114/*! Updates the mount and free space available information for each mount 112/*! Updates the mount and free space available information for each mount
115 point. This method is automatically called when a disk is mounted or 113 point. This method is automatically called when a disk is mounted or
116 unmounted. 114 unmounted.
117*/ 115*/
118// cause of the lack of a d pointer we need 116// cause of the lack of a d pointer we need
119// to store informations in a config file :( 117// to store informations in a config file :(
120void StorageInfo::update() 118void StorageInfo::update()
121{ 119{
122 //qDebug("StorageInfo::updating"); 120 //qDebug("StorageInfo::updating");