author | mickeyl <mickeyl> | 2005-06-24 12:10:13 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-06-24 12:10:13 (UTC) |
commit | 886b3a77a64d5808d2fe68d0e7e6b712cf642753 (patch) (unidiff) | |
tree | 60121b38e6100ff10a6e01293b7e478489f09bba /noncore/applets/pcmcia/configdialog.cpp | |
parent | 4775588885d60ea208c667a5863244a847a69f94 (diff) | |
download | opie-886b3a77a64d5808d2fe68d0e7e6b712cf642753.zip opie-886b3a77a64d5808d2fe68d0e7e6b712cf642753.tar.gz opie-886b3a77a64d5808d2fe68d0e7e6b712cf642753.tar.bz2 |
- fix configdialog checking for productIdentity, not for cardmgr's idea of that
- perform insert action and perform suspend action
Except for "prompt for" and some polishing, this applet should now be fairly complete
Diffstat (limited to 'noncore/applets/pcmcia/configdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/pcmcia/configdialog.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp index f5812ba..f94edde 100644 --- a/noncore/applets/pcmcia/configdialog.cpp +++ b/noncore/applets/pcmcia/configdialog.cpp | |||
@@ -1,177 +1,179 @@ | |||
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; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
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 "configdialog.h" | 30 | #include "configdialog.h" |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <opie2/oconfig.h> | 33 | #include <opie2/oconfig.h> |
34 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
35 | #include <opie2/opcmciasystem.h> | 35 | #include <opie2/opcmciasystem.h> |
36 | using namespace Opie::Core; | 36 | using namespace Opie::Core; |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
40 | #include <qdir.h> | 40 | #include <qdir.h> |
41 | #include <qfile.h> | 41 | #include <qfile.h> |
42 | #include <qgroupbox.h> | 42 | #include <qgroupbox.h> |
43 | #include <qlabel.h> | 43 | #include <qlabel.h> |
44 | #include <qtextstream.h> | 44 | #include <qtextstream.h> |
45 | 45 | ||
46 | ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) | 46 | ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) |
47 | :ConfigDialogBase( parent, "pcmcia config dialog", true ) | 47 | :ConfigDialogBase( parent, "pcmcia config dialog", true ) |
48 | { | 48 | { |
49 | gbDetails->setTitle( QString( "Details for card in socket #%1" ).arg( card->number() ) ); | 49 | gbDetails->setTitle( QString( "Details for card in socket #%1" ).arg( card->number() ) ); |
50 | txtCardName->setText( card->productIdentity().join( " " ) ); | 50 | txtCardName->setText( card->productIdentity().join( " " ) ); |
51 | txtManfid->setText( card->manufacturerIdentity() ); | 51 | txtManfid->setText( card->manufacturerIdentity() ); |
52 | txtFunction->setText( card->function() ); | 52 | txtFunction->setText( card->function() ); |
53 | 53 | ||
54 | QString insertAction = preferredAction( card, "insert" ); | 54 | QString insertAction = preferredAction( card, "insert" ); |
55 | QString resumeAction = preferredAction( card, "resume" ); | 55 | QString resumeAction = preferredAction( card, "resume" ); |
56 | 56 | ||
57 | odebug << "pcmcia: preferred insertion action for card '" << card->name() << "' seems to be '" << insertAction << "'" << oendl; | 57 | odebug << "pcmcia: preferred insertion action for card '" << card->name() << "' seems to be '" << insertAction << "'" << oendl; |
58 | odebug << "pcmcia: preferred resume action for card '" << card->name() << "' seems to be '" << resumeAction << "'" << oendl; | 58 | odebug << "pcmcia: preferred resume action for card '" << card->name() << "' seems to be '" << resumeAction << "'" << oendl; |
59 | 59 | ||
60 | if ( !insertAction.isEmpty() ) | 60 | if ( !insertAction.isEmpty() ) |
61 | { | 61 | { |
62 | for ( int i; i < cbInsertAction->count(); ++i ) | 62 | for ( int i; i < cbInsertAction->count(); ++i ) |
63 | if ( cbInsertAction->text( i ) == insertAction ) cbInsertAction->setCurrentItem( i ); | 63 | if ( cbInsertAction->text( i ) == insertAction ) cbInsertAction->setCurrentItem( i ); |
64 | } | 64 | } |
65 | 65 | ||
66 | if ( !resumeAction.isEmpty() ) | 66 | if ( !resumeAction.isEmpty() ) |
67 | { | 67 | { |
68 | for ( int i; i < cbResumeAction->count(); ++i ) | 68 | for ( int i; i < cbResumeAction->count(); ++i ) |
69 | if ( cbResumeAction->text( i ) == resumeAction ) cbResumeAction->setCurrentItem( i ); | 69 | if ( cbResumeAction->text( i ) == resumeAction ) cbResumeAction->setCurrentItem( i ); |
70 | } | 70 | } |
71 | 71 | ||
72 | if ( !card->isUnsupported() ) | 72 | if ( !card->isUnsupported() ) |
73 | { | 73 | { |
74 | odebug << "pcmcia: card is recognized - hiding bindings" << oendl; | 74 | odebug << "pcmcia: card is recognized - hiding bindings" << oendl; |
75 | textInfo->hide(); | 75 | textInfo->hide(); |
76 | textBindTo->hide(); | 76 | textBindTo->hide(); |
77 | cbBindTo->hide(); | 77 | cbBindTo->hide(); |
78 | return; | 78 | return; |
79 | } | 79 | } |
80 | else | 80 | else |
81 | { | 81 | { |
82 | odebug << "card is unsupported yet - showing possible bindings" << oendl; | 82 | odebug << "card is unsupported yet - showing possible bindings" << oendl; |
83 | textInfo->show(); | 83 | textInfo->show(); |
84 | textBindTo->show(); | 84 | textBindTo->show(); |
85 | cbBindTo->show(); | 85 | cbBindTo->show(); |
86 | } | 86 | } |
87 | 87 | ||
88 | // parse possible bind entries out of /etc/pcmcia/*.conf | 88 | // parse possible bind entries out of /etc/pcmcia/*.conf |
89 | QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); | 89 | QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); |
90 | 90 | ||
91 | for ( unsigned int i = 0; i < pcmciaconfdir.count(); ++i ) | 91 | for ( unsigned int i = 0; i < pcmciaconfdir.count(); ++i ) |
92 | { | 92 | { |
93 | odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; | 93 | odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; |
94 | QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); | 94 | QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); |
95 | QFile conffile( conffilename ); | 95 | QFile conffile( conffilename ); |
96 | if ( conffile.open( IO_ReadOnly ) ) | 96 | if ( conffile.open( IO_ReadOnly ) ) |
97 | { | 97 | { |
98 | QTextStream ts( &conffile ); | 98 | QTextStream ts( &conffile ); |
99 | while ( !ts.atEnd() ) | 99 | while ( !ts.atEnd() ) |
100 | { | 100 | { |
101 | QString word; | 101 | QString word; |
102 | ts >> word; | 102 | ts >> word; |
103 | if ( word == "bind" ) | 103 | if ( word == "bind" ) |
104 | { | 104 | { |
105 | word = ts.readLine(); | 105 | word = ts.readLine(); |
106 | bindEntries[ word.stripWhiteSpace() ] = conffilename; | 106 | bindEntries[ word.stripWhiteSpace() ] = conffilename; |
107 | continue; | 107 | continue; |
108 | } | 108 | } |
109 | ts.readLine(); | 109 | ts.readLine(); |
110 | } | 110 | } |
111 | } | 111 | } |
112 | else | 112 | else |
113 | { | 113 | { |
114 | owarn << "couldn't open '" << conffile.name() << "' for reading" << oendl; | 114 | owarn << "couldn't open '" << conffile.name() << "' for reading" << oendl; |
115 | continue; | 115 | continue; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it ) | 119 | for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it ) |
120 | { | 120 | { |
121 | odebug << "found binding '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl; | 121 | odebug << "found binding '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl; |
122 | cbBindTo->insertItem( it.key() ); | 122 | cbBindTo->insertItem( it.key() ); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | ConfigDialog::~ConfigDialog() | 126 | ConfigDialog::~ConfigDialog() |
127 | { | 127 | { |
128 | } | 128 | } |
129 | 129 | ||
130 | void ConfigDialog::writeConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& value ) | 130 | void ConfigDialog::writeConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& value ) |
131 | { | 131 | { |
132 | OConfig cfg( "PCMCIA" ); | 132 | OConfig cfg( "PCMCIA" ); |
133 | cfg.setGroup( "Global" ); | 133 | cfg.setGroup( "Global" ); |
134 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 134 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
135 | QString cardName = card->productIdentity().join( " " ).stripWhiteSpace(); | ||
135 | QString action; | 136 | QString action; |
136 | 137 | ||
137 | for ( int i = 0; i < nCards; ++i ) | 138 | for ( int i = 0; i < nCards; ++i ) |
138 | { | 139 | { |
139 | QString cardSection = QString( "Card_%1" ).arg( i ); | 140 | QString cardSection = QString( "Card_%1" ).arg( i ); |
140 | cfg.setGroup( cardSection ); | 141 | cfg.setGroup( cardSection ); |
141 | QString name = cfg.readEntry( "name" ); | 142 | QString name = cfg.readEntry( "name" ); |
142 | odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; | 143 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; |
143 | if ( card->name() == name ) | 144 | if ( cardName == name ) |
144 | { | 145 | { |
145 | cfg.writeEntry( key, value ); | 146 | cfg.writeEntry( key, value ); |
146 | break; | 147 | break; |
147 | } | 148 | } |
148 | } | 149 | } |
149 | } | 150 | } |
150 | 151 | ||
151 | QString ConfigDialog::readConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& defaultValue ) | 152 | QString ConfigDialog::readConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& defaultValue ) |
152 | { | 153 | { |
153 | OConfig cfg( "PCMCIA" ); | 154 | OConfig cfg( "PCMCIA" ); |
154 | cfg.setGroup( "Global" ); | 155 | cfg.setGroup( "Global" ); |
155 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 156 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
157 | QString cardName = card->productIdentity().join( " " ).stripWhiteSpace(); | ||
156 | QString value; | 158 | QString value; |
157 | 159 | ||
158 | for ( int i = 0; i < nCards; ++i ) | 160 | for ( int i = 0; i < nCards; ++i ) |
159 | { | 161 | { |
160 | QString cardSection = QString( "Card_%1" ).arg( i ); | 162 | QString cardSection = QString( "Card_%1" ).arg( i ); |
161 | cfg.setGroup( cardSection ); | 163 | cfg.setGroup( cardSection ); |
162 | QString name = cfg.readEntry( "name" ); | 164 | QString name = cfg.readEntry( "name" ); |
163 | odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; | 165 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; |
164 | if ( card->name() == name ) | 166 | if ( cardName == name ) |
165 | { | 167 | { |
166 | value = cfg.readEntry( key, defaultValue ); | 168 | value = cfg.readEntry( key, defaultValue ); |
167 | break; | 169 | break; |
168 | } | 170 | } |
169 | } | 171 | } |
170 | return value; | 172 | return value; |
171 | } | 173 | } |
172 | 174 | ||
173 | 175 | ||
174 | QString ConfigDialog::preferredAction( const OPcmciaSocket* card, const QString& type ) | 176 | QString ConfigDialog::preferredAction( const OPcmciaSocket* card, const QString& type ) |
175 | { | 177 | { |
176 | return ConfigDialog::readConfigEntry( card, QString( "%1Action" ).arg( type ), "suspend" ); | 178 | return ConfigDialog::readConfigEntry( card, QString( "%1Action" ).arg( type ), "suspend" ); |
177 | } | 179 | } |