-rw-r--r-- | libopie2/opiecore/linux/opcmciasystem.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libopie2/opiecore/linux/opcmciasystem.cpp b/libopie2/opiecore/linux/opcmciasystem.cpp index a924696..34e4477 100644 --- a/libopie2/opiecore/linux/opcmciasystem.cpp +++ b/libopie2/opiecore/linux/opcmciasystem.cpp | |||
@@ -1,142 +1,143 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | .=l. | 4 | .=l. |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; version 2 of the License. | 10 | - . .-<_> .<> Foundation; version 2 of the License. |
11 | ._= =} : | 11 | ._= =} : |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "opcmciasystem.h" | 30 | #include "opcmciasystem.h" |
31 | using namespace Opie::Core; | 31 | using namespace Opie::Core; |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
35 | 35 | ||
36 | /* QT */ | 36 | /* QT */ |
37 | #include <qfile.h> | 37 | #include <qfile.h> |
38 | #include <qtextstream.h> | 38 | #include <qtextstream.h> |
39 | 39 | ||
40 | /* STD */ | 40 | /* STD */ |
41 | #include <errno.h> | 41 | #include <errno.h> |
42 | #include <fcntl.h> | 42 | #include <fcntl.h> |
43 | #include <string.h> | 43 | #include <string.h> |
44 | #include <sys/ioctl.h> | 44 | #include <sys/ioctl.h> |
45 | #include <sys/types.h> | 45 | #include <sys/types.h> |
46 | #include <sys/stat.h> | 46 | #include <sys/stat.h> |
47 | 47 | ||
48 | /*====================================================================================== | 48 | /*====================================================================================== |
49 | * OPcmciaSystem | 49 | * OPcmciaSystem |
50 | *======================================================================================*/ | 50 | *======================================================================================*/ |
51 | 51 | ||
52 | OPcmciaSystem* OPcmciaSystem::_instance = 0; | 52 | OPcmciaSystem* OPcmciaSystem::_instance = 0; |
53 | 53 | ||
54 | OPcmciaSystem::OPcmciaSystem() | 54 | OPcmciaSystem::OPcmciaSystem() |
55 | { | 55 | { |
56 | qDebug( "OPcmciaSystem::OPcmciaSystem()" ); | 56 | qDebug( "OPcmciaSystem::OPcmciaSystem()" ); |
57 | synchronize(); | 57 | synchronize(); |
58 | } | 58 | } |
59 | 59 | ||
60 | void OPcmciaSystem::synchronize() | 60 | void OPcmciaSystem::synchronize() |
61 | { | 61 | { |
62 | qDebug( "OPcmciaSystem::synchronize()" ); | 62 | qDebug( "OPcmciaSystem::synchronize()" ); |
63 | _interfaces.clear(); | 63 | _interfaces.clear(); |
64 | 64 | ||
65 | //FIXME: Use cardmgr subsystem ioctls | 65 | //FIXME: Use cardmgr subsystem ioctls |
66 | 66 | ||
67 | QString fileName; | 67 | QString fileName; |
68 | if ( QFile::exists( "/var/run/stab" ) ) { fileName = "/var/run/stab"; } | 68 | if ( QFile::exists( "/var/run/stab" ) ) { fileName = "/var/run/stab"; } |
69 | else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) { fileName = "/var/state/pcmcia/stab"; } | 69 | else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) { fileName = "/var/state/pcmcia/stab"; } |
70 | else { fileName = "/var/lib/pcmcia/stab"; } | 70 | else { fileName = "/var/lib/pcmcia/stab"; } |
71 | QFile cardinfofile( fileName ); | 71 | QFile cardinfofile( fileName ); |
72 | if ( !cardinfofile.exists() || !cardinfofile.open( IO_ReadOnly ) ) | 72 | if ( !cardinfofile.exists() || !cardinfofile.open( IO_ReadOnly ) ) |
73 | { | 73 | { |
74 | qWarning( "pcmcia info file not found or unaccessible" ); | 74 | qWarning( "pcmcia info file not found or unaccessible" ); |
75 | return; | 75 | return; |
76 | } | 76 | } |
77 | QTextStream cardinfo( &cardinfofile ); | 77 | QTextStream cardinfo( &cardinfofile ); |
78 | while ( !cardinfo.atEnd() ) | 78 | while ( !cardinfo.atEnd() ) |
79 | { | 79 | { |
80 | QString line = cardinfo.readLine(); | 80 | QString line = cardinfo.readLine(); |
81 | if ( line.startsWith( "Socket" ) ) | 81 | // qDebug( "line = '%s'", (const char*) line ); |
82 | if ( line.startsWith( "Socket" ) && ! line.contains( "empty" ) ) | ||
82 | { | 83 | { |
83 | int mid = line.find( ':' ); | 84 | int mid = line.find( ':' ); |
84 | QString name = line.right( line.length() - mid - 1 ); | 85 | QString name = line.right( line.length() - mid - 1 ); |
85 | QString id = line.right( line.length() - mid + 1 ); | 86 | QString id = line.right( line.length() - mid + 1 ); |
86 | if ( mid ) _interfaces.insert( name, new OPcmciaCard( this, (const char*) id ) ); | 87 | if ( mid ) _interfaces.insert( name.stripWhiteSpace(), new OPcmciaCard( this, (const char*) id.stripWhiteSpace() ) ); |
87 | } | 88 | } |
88 | else | 89 | else |
89 | { | 90 | { |
90 | continue; | 91 | continue; |
91 | } | 92 | } |
92 | } | 93 | } |
93 | } | 94 | } |
94 | 95 | ||
95 | 96 | ||
96 | int OPcmciaSystem::count() const | 97 | int OPcmciaSystem::count() const |
97 | { | 98 | { |
98 | return _interfaces.count(); | 99 | return _interfaces.count(); |
99 | } | 100 | } |
100 | 101 | ||
101 | 102 | ||
102 | OPcmciaCard* OPcmciaSystem::card( const QString& iface ) const | 103 | OPcmciaCard* OPcmciaSystem::card( const QString& iface ) const |
103 | { | 104 | { |
104 | return _interfaces[iface]; | 105 | return _interfaces[iface]; |
105 | } | 106 | } |
106 | 107 | ||
107 | 108 | ||
108 | OPcmciaSystem* OPcmciaSystem::instance() | 109 | OPcmciaSystem* OPcmciaSystem::instance() |
109 | { | 110 | { |
110 | if ( !_instance ) _instance = new OPcmciaSystem(); | 111 | if ( !_instance ) _instance = new OPcmciaSystem(); |
111 | return _instance; | 112 | return _instance; |
112 | } | 113 | } |
113 | 114 | ||
114 | 115 | ||
115 | OPcmciaSystem::CardIterator OPcmciaSystem::iterator() const | 116 | OPcmciaSystem::CardIterator OPcmciaSystem::iterator() const |
116 | { | 117 | { |
117 | return OPcmciaSystem::CardIterator( _interfaces ); | 118 | return OPcmciaSystem::CardIterator( _interfaces ); |
118 | } | 119 | } |
119 | 120 | ||
120 | 121 | ||
121 | /*====================================================================================== | 122 | /*====================================================================================== |
122 | * OPcmciaCard | 123 | * OPcmciaCard |
123 | *======================================================================================*/ | 124 | *======================================================================================*/ |
124 | 125 | ||
125 | OPcmciaCard::OPcmciaCard( QObject* parent, const char* name ) | 126 | OPcmciaCard::OPcmciaCard( QObject* parent, const char* name ) |
126 | :QObject( parent, name ) | 127 | :QObject( parent, name ) |
127 | { | 128 | { |
128 | odebug << "OPcmciaCard::OPcmciaCard()" << oendl; | 129 | odebug << "OPcmciaCard::OPcmciaCard()" << oendl; |
129 | init(); | 130 | init(); |
130 | } | 131 | } |
131 | 132 | ||
132 | 133 | ||
133 | OPcmciaCard::~OPcmciaCard() | 134 | OPcmciaCard::~OPcmciaCard() |
134 | { | 135 | { |
135 | } | 136 | } |
136 | 137 | ||
137 | 138 | ||
138 | void OPcmciaCard::init() | 139 | void OPcmciaCard::init() |
139 | { | 140 | { |
140 | } | 141 | } |
141 | 142 | ||
142 | 143 | ||