-rw-r--r-- | noncore/applets/pcmcia/configdialog.cpp | 55 | ||||
-rw-r--r-- | noncore/applets/pcmcia/configdialog.h | 7 | ||||
-rw-r--r-- | noncore/applets/pcmcia/configdialogbase.ui | 171 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.cpp | 69 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.h | 2 |
5 files changed, 216 insertions, 88 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp index f961069..f5812ba 100644 --- a/noncore/applets/pcmcia/configdialog.cpp +++ b/noncore/applets/pcmcia/configdialog.cpp | |||
@@ -48,25 +48,33 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) | |||
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 action = preferredAction( card ); | 54 | QString insertAction = preferredAction( card, "insert" ); |
55 | QString resumeAction = preferredAction( card, "resume" ); | ||
55 | 56 | ||
56 | odebug << "preferred action for card '" << card->name() << "' seems to be '" << action << "'" << 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; | ||
57 | 59 | ||
58 | if ( !action.isEmpty() ) | 60 | if ( !insertAction.isEmpty() ) |
59 | { | 61 | { |
60 | for ( int i; i < cbAction->count(); ++i ) | 62 | for ( int i; i < cbInsertAction->count(); ++i ) |
61 | if ( cbAction->text( i ) == action ) cbAction->setCurrentItem( i ); | 63 | if ( cbInsertAction->text( i ) == insertAction ) cbInsertAction->setCurrentItem( i ); |
64 | } | ||
65 | |||
66 | if ( !resumeAction.isEmpty() ) | ||
67 | { | ||
68 | for ( int i; i < cbResumeAction->count(); ++i ) | ||
69 | if ( cbResumeAction->text( i ) == resumeAction ) cbResumeAction->setCurrentItem( i ); | ||
62 | } | 70 | } |
63 | 71 | ||
64 | if ( !card->isUnsupported() ) | 72 | if ( !card->isUnsupported() ) |
65 | { | 73 | { |
66 | odebug << "card is recognized - hiding bindings" << oendl; | 74 | odebug << "pcmcia: card is recognized - hiding bindings" << oendl; |
67 | textInfo->hide(); | 75 | textInfo->hide(); |
68 | textBindTo->hide(); | 76 | textBindTo->hide(); |
69 | cbBindTo->hide(); | 77 | cbBindTo->hide(); |
70 | return; | 78 | return; |
71 | } | 79 | } |
72 | else | 80 | else |
@@ -75,15 +83,12 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) | |||
75 | textInfo->show(); | 83 | textInfo->show(); |
76 | textBindTo->show(); | 84 | textBindTo->show(); |
77 | cbBindTo->show(); | 85 | cbBindTo->show(); |
78 | } | 86 | } |
79 | 87 | ||
80 | // parse possible bind entries out of /etc/pcmcia/*.conf | 88 | // parse possible bind entries out of /etc/pcmcia/*.conf |
81 | typedef QMap<QString,QString> StringMap; | ||
82 | StringMap bindEntries; | ||
83 | |||
84 | QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); | 89 | QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); |
85 | 90 | ||
86 | for ( unsigned int i = 0; i < pcmciaconfdir.count(); ++i ) | 91 | for ( unsigned int i = 0; i < pcmciaconfdir.count(); ++i ) |
87 | { | 92 | { |
88 | odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; | 93 | odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; |
89 | QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); | 94 | QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); |
@@ -119,13 +124,13 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) | |||
119 | } | 124 | } |
120 | 125 | ||
121 | ConfigDialog::~ConfigDialog() | 126 | ConfigDialog::~ConfigDialog() |
122 | { | 127 | { |
123 | } | 128 | } |
124 | 129 | ||
125 | QString ConfigDialog::preferredAction( const OPcmciaSocket* card ) | 130 | void ConfigDialog::writeConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& value ) |
126 | { | 131 | { |
127 | OConfig cfg( "PCMCIA" ); | 132 | OConfig cfg( "PCMCIA" ); |
128 | cfg.setGroup( "Global" ); | 133 | cfg.setGroup( "Global" ); |
129 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 134 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
130 | QString action; | 135 | QString action; |
131 | 136 | ||
@@ -134,13 +139,39 @@ QString ConfigDialog::preferredAction( const OPcmciaSocket* card ) | |||
134 | QString cardSection = QString( "Card_%1" ).arg( i ); | 139 | QString cardSection = QString( "Card_%1" ).arg( i ); |
135 | cfg.setGroup( cardSection ); | 140 | cfg.setGroup( cardSection ); |
136 | QString name = cfg.readEntry( "name" ); | 141 | QString name = cfg.readEntry( "name" ); |
137 | odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; | 142 | odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; |
138 | if ( card->name() == name ) | 143 | if ( card->name() == name ) |
139 | { | 144 | { |
140 | action = cfg.readEntry( "action" ); | 145 | cfg.writeEntry( key, value ); |
141 | break; | 146 | break; |
142 | } | 147 | } |
143 | } | 148 | } |
149 | } | ||
144 | 150 | ||
145 | return action; | 151 | QString ConfigDialog::readConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& defaultValue ) |
152 | { | ||
153 | OConfig cfg( "PCMCIA" ); | ||
154 | cfg.setGroup( "Global" ); | ||
155 | int nCards = cfg.readNumEntry( "nCards", 0 ); | ||
156 | QString value; | ||
157 | |||
158 | for ( int i = 0; i < nCards; ++i ) | ||
159 | { | ||
160 | QString cardSection = QString( "Card_%1" ).arg( i ); | ||
161 | cfg.setGroup( cardSection ); | ||
162 | QString name = cfg.readEntry( "name" ); | ||
163 | odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; | ||
164 | if ( card->name() == name ) | ||
165 | { | ||
166 | value = cfg.readEntry( key, defaultValue ); | ||
167 | break; | ||
168 | } | ||
169 | } | ||
170 | return value; | ||
171 | } | ||
172 | |||
173 | |||
174 | QString ConfigDialog::preferredAction( const OPcmciaSocket* card, const QString& type ) | ||
175 | { | ||
176 | return ConfigDialog::readConfigEntry( card, QString( "%1Action" ).arg( type ), "suspend" ); | ||
146 | } | 177 | } |
diff --git a/noncore/applets/pcmcia/configdialog.h b/noncore/applets/pcmcia/configdialog.h index 321180d..169dadb 100644 --- a/noncore/applets/pcmcia/configdialog.h +++ b/noncore/applets/pcmcia/configdialog.h | |||
@@ -31,16 +31,21 @@ | |||
31 | #define CONFIGDIALOG_H | 31 | #define CONFIGDIALOG_H |
32 | 32 | ||
33 | #include "configdialogbase.h" | 33 | #include "configdialogbase.h" |
34 | 34 | ||
35 | namespace Opie { namespace Core { class OPcmciaSocket; }; }; | 35 | namespace Opie { namespace Core { class OPcmciaSocket; }; }; |
36 | 36 | ||
37 | typedef QMap<QString,QString> StringMap; | ||
38 | |||
37 | class ConfigDialog : public ConfigDialogBase | 39 | class ConfigDialog : public ConfigDialogBase |
38 | { | 40 | { |
39 | Q_OBJECT | 41 | Q_OBJECT |
40 | public: | 42 | public: |
41 | ConfigDialog( const Opie::Core::OPcmciaSocket* card, QWidget* parent ); | 43 | ConfigDialog( const Opie::Core::OPcmciaSocket* card, QWidget* parent ); |
42 | ~ConfigDialog(); | 44 | ~ConfigDialog(); |
43 | static QString preferredAction( const Opie::Core::OPcmciaSocket* card ); | 45 | static QString preferredAction( const Opie::Core::OPcmciaSocket* card, const QString& type ); |
46 | static QString readConfigEntry( const Opie::Core::OPcmciaSocket* card, const QString& key, const QString& defaultValue ); | ||
47 | static void writeConfigEntry( const Opie::Core::OPcmciaSocket* card, const QString& key, const QString& value ); | ||
48 | StringMap bindEntries; | ||
44 | }; | 49 | }; |
45 | 50 | ||
46 | #endif | 51 | #endif |
diff --git a/noncore/applets/pcmcia/configdialogbase.ui b/noncore/applets/pcmcia/configdialogbase.ui index 829b71a..97d9a50 100644 --- a/noncore/applets/pcmcia/configdialogbase.ui +++ b/noncore/applets/pcmcia/configdialogbase.ui | |||
@@ -8,13 +8,13 @@ | |||
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>215</width> | 14 | <width>211</width> |
15 | <height>329</height> | 15 | <height>329</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
19 | <name>caption</name> | 19 | <name>caption</name> |
20 | <string>Configure PCMCIA/CF Card</string> | 20 | <string>Configure PCMCIA/CF Card</string> |
@@ -25,13 +25,13 @@ | |||
25 | <property> | 25 | <property> |
26 | <name>layoutSpacing</name> | 26 | <name>layoutSpacing</name> |
27 | </property> | 27 | </property> |
28 | <grid> | 28 | <grid> |
29 | <property stdset="1"> | 29 | <property stdset="1"> |
30 | <name>margin</name> | 30 | <name>margin</name> |
31 | <number>5</number> | 31 | <number>6</number> |
32 | </property> | 32 | </property> |
33 | <property stdset="1"> | 33 | <property stdset="1"> |
34 | <name>spacing</name> | 34 | <name>spacing</name> |
35 | <number>2</number> | 35 | <number>2</number> |
36 | </property> | 36 | </property> |
37 | <widget row="0" column="0" rowspan="1" colspan="3" > | 37 | <widget row="0" column="0" rowspan="1" colspan="3" > |
@@ -145,77 +145,24 @@ | |||
145 | <name>text</name> | 145 | <name>text</name> |
146 | <string>TextLabel3</string> | 146 | <string>TextLabel3</string> |
147 | </property> | 147 | </property> |
148 | </widget> | 148 | </widget> |
149 | </grid> | 149 | </grid> |
150 | </widget> | 150 | </widget> |
151 | <widget row="1" column="0" > | 151 | <widget row="5" column="0" > |
152 | <class>QLabel</class> | ||
153 | <property stdset="1"> | ||
154 | <name>name</name> | ||
155 | <cstring>TextLabel2</cstring> | ||
156 | </property> | ||
157 | <property stdset="1"> | ||
158 | <name>text</name> | ||
159 | <string>On insertion,</string> | ||
160 | </property> | ||
161 | </widget> | ||
162 | <widget row="1" column="1" > | ||
163 | <class>QComboBox</class> | ||
164 | <item> | ||
165 | <property> | ||
166 | <name>text</name> | ||
167 | <string>suspend</string> | ||
168 | </property> | ||
169 | </item> | ||
170 | <item> | ||
171 | <property> | ||
172 | <name>text</name> | ||
173 | <string>activate</string> | ||
174 | </property> | ||
175 | </item> | ||
176 | <item> | ||
177 | <property> | ||
178 | <name>text</name> | ||
179 | <string>eject</string> | ||
180 | </property> | ||
181 | </item> | ||
182 | <item> | ||
183 | <property> | ||
184 | <name>text</name> | ||
185 | <string>prompt for</string> | ||
186 | </property> | ||
187 | </item> | ||
188 | <property stdset="1"> | ||
189 | <name>name</name> | ||
190 | <cstring>cbAction</cstring> | ||
191 | </property> | ||
192 | </widget> | ||
193 | <widget row="1" column="2" > | ||
194 | <class>QLabel</class> | ||
195 | <property stdset="1"> | ||
196 | <name>name</name> | ||
197 | <cstring>TextLabel3</cstring> | ||
198 | </property> | ||
199 | <property stdset="1"> | ||
200 | <name>text</name> | ||
201 | <string>card</string> | ||
202 | </property> | ||
203 | </widget> | ||
204 | <widget row="4" column="0" > | ||
205 | <class>QLabel</class> | 152 | <class>QLabel</class> |
206 | <property stdset="1"> | 153 | <property stdset="1"> |
207 | <name>name</name> | 154 | <name>name</name> |
208 | <cstring>textBindTo</cstring> | 155 | <cstring>textBindTo</cstring> |
209 | </property> | 156 | </property> |
210 | <property stdset="1"> | 157 | <property stdset="1"> |
211 | <name>text</name> | 158 | <name>text</name> |
212 | <string>Bind to:</string> | 159 | <string>Bind to:</string> |
213 | </property> | 160 | </property> |
214 | </widget> | 161 | </widget> |
215 | <widget row="4" column="1" rowspan="1" colspan="2" > | 162 | <widget row="5" column="1" rowspan="1" colspan="2" > |
216 | <class>QComboBox</class> | 163 | <class>QComboBox</class> |
217 | <item> | 164 | <item> |
218 | <property> | 165 | <property> |
219 | <name>text</name> | 166 | <name>text</name> |
220 | <string><None></string> | 167 | <string><None></string> |
221 | </property> | 168 | </property> |
@@ -241,13 +188,13 @@ | |||
241 | </property> | 188 | </property> |
242 | <property stdset="1"> | 189 | <property stdset="1"> |
243 | <name>autoResize</name> | 190 | <name>autoResize</name> |
244 | <bool>false</bool> | 191 | <bool>false</bool> |
245 | </property> | 192 | </property> |
246 | </widget> | 193 | </widget> |
247 | <widget row="3" column="0" rowspan="1" colspan="3" > | 194 | <widget row="4" column="0" rowspan="1" colspan="3" > |
248 | <class>QLabel</class> | 195 | <class>QLabel</class> |
249 | <property stdset="1"> | 196 | <property stdset="1"> |
250 | <name>name</name> | 197 | <name>name</name> |
251 | <cstring>textInfo</cstring> | 198 | <cstring>textInfo</cstring> |
252 | </property> | 199 | </property> |
253 | <property stdset="1"> | 200 | <property stdset="1"> |
@@ -268,13 +215,57 @@ | |||
268 | </property> | 215 | </property> |
269 | <property stdset="1"> | 216 | <property stdset="1"> |
270 | <name>text</name> | 217 | <name>text</name> |
271 | <string><qt>CAUTION: This card is not yet recognized by your system. Without a valid binding, your card may not function correctly. Please choose a driver to bind the card to below:</qt></string> | 218 | <string><qt>CAUTION: This card is not yet recognized by your system. Without a valid binding, your card may not function correctly. Please choose a driver to bind the card to below:</qt></string> |
272 | </property> | 219 | </property> |
273 | </widget> | 220 | </widget> |
274 | <spacer row="2" column="1" > | 221 | <widget row="1" column="0" > |
222 | <class>QLabel</class> | ||
223 | <property stdset="1"> | ||
224 | <name>name</name> | ||
225 | <cstring>TextLabel2</cstring> | ||
226 | </property> | ||
227 | <property stdset="1"> | ||
228 | <name>text</name> | ||
229 | <string>On insertion,</string> | ||
230 | </property> | ||
231 | </widget> | ||
232 | <widget row="1" column="2" > | ||
233 | <class>QLabel</class> | ||
234 | <property stdset="1"> | ||
235 | <name>name</name> | ||
236 | <cstring>TextLabel3</cstring> | ||
237 | </property> | ||
238 | <property stdset="1"> | ||
239 | <name>text</name> | ||
240 | <string>card</string> | ||
241 | </property> | ||
242 | </widget> | ||
243 | <widget row="2" column="0" > | ||
244 | <class>QLabel</class> | ||
245 | <property stdset="1"> | ||
246 | <name>name</name> | ||
247 | <cstring>TextLabel2_2</cstring> | ||
248 | </property> | ||
249 | <property stdset="1"> | ||
250 | <name>text</name> | ||
251 | <string>On resume,</string> | ||
252 | </property> | ||
253 | </widget> | ||
254 | <widget row="2" column="2" > | ||
255 | <class>QLabel</class> | ||
256 | <property stdset="1"> | ||
257 | <name>name</name> | ||
258 | <cstring>TextLabel3_2</cstring> | ||
259 | </property> | ||
260 | <property stdset="1"> | ||
261 | <name>text</name> | ||
262 | <string>card</string> | ||
263 | </property> | ||
264 | </widget> | ||
265 | <spacer row="3" column="1" > | ||
275 | <property> | 266 | <property> |
276 | <name>name</name> | 267 | <name>name</name> |
277 | <cstring>Spacer2</cstring> | 268 | <cstring>Spacer2</cstring> |
278 | </property> | 269 | </property> |
279 | <property stdset="1"> | 270 | <property stdset="1"> |
280 | <name>orientation</name> | 271 | <name>orientation</name> |
@@ -289,9 +280,71 @@ | |||
289 | <size> | 280 | <size> |
290 | <width>20</width> | 281 | <width>20</width> |
291 | <height>20</height> | 282 | <height>20</height> |
292 | </size> | 283 | </size> |
293 | </property> | 284 | </property> |
294 | </spacer> | 285 | </spacer> |
286 | <widget row="1" column="1" > | ||
287 | <class>QComboBox</class> | ||
288 | <item> | ||
289 | <property> | ||
290 | <name>text</name> | ||
291 | <string>suspend</string> | ||
292 | </property> | ||
293 | </item> | ||
294 | <item> | ||
295 | <property> | ||
296 | <name>text</name> | ||
297 | <string>activate</string> | ||
298 | </property> | ||
299 | </item> | ||
300 | <item> | ||
301 | <property> | ||
302 | <name>text</name> | ||
303 | <string>eject</string> | ||
304 | </property> | ||
305 | </item> | ||
306 | <item> | ||
307 | <property> | ||
308 | <name>text</name> | ||
309 | <string>prompt for</string> | ||
310 | </property> | ||
311 | </item> | ||
312 | <property stdset="1"> | ||
313 | <name>name</name> | ||
314 | <cstring>cbInsertAction</cstring> | ||
315 | </property> | ||
316 | </widget> | ||
317 | <widget row="2" column="1" > | ||
318 | <class>QComboBox</class> | ||
319 | <item> | ||
320 | <property> | ||
321 | <name>text</name> | ||
322 | <string>suspend</string> | ||
323 | </property> | ||
324 | </item> | ||
325 | <item> | ||
326 | <property> | ||
327 | <name>text</name> | ||
328 | <string>activate</string> | ||
329 | </property> | ||
330 | </item> | ||
331 | <item> | ||
332 | <property> | ||
333 | <name>text</name> | ||
334 | <string>eject</string> | ||
335 | </property> | ||
336 | </item> | ||
337 | <item> | ||
338 | <property> | ||
339 | <name>text</name> | ||
340 | <string>prompt for</string> | ||
341 | </property> | ||
342 | </item> | ||
343 | <property stdset="1"> | ||
344 | <name>name</name> | ||
345 | <cstring>cbResumeAction</cstring> | ||
346 | </property> | ||
347 | </widget> | ||
295 | </grid> | 348 | </grid> |
296 | </widget> | 349 | </widget> |
297 | </UI> | 350 | </UI> |
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp index 1a2b619..186dfea 100644 --- a/noncore/applets/pcmcia/pcmcia.cpp +++ b/noncore/applets/pcmcia/pcmcia.cpp | |||
@@ -36,17 +36,19 @@ | |||
36 | #include <opie2/oconfig.h> | 36 | #include <opie2/oconfig.h> |
37 | #include <opie2/oprocess.h> | 37 | #include <opie2/oprocess.h> |
38 | #include <opie2/opcmciasystem.h> | 38 | #include <opie2/opcmciasystem.h> |
39 | #include <opie2/oresource.h> | 39 | #include <opie2/oresource.h> |
40 | #include <opie2/otaskbarapplet.h> | 40 | #include <opie2/otaskbarapplet.h> |
41 | #include <qpe/applnk.h> | 41 | #include <qpe/applnk.h> |
42 | #include <qpe/global.h> | ||
42 | #include <qpe/resource.h> | 43 | #include <qpe/resource.h> |
43 | using namespace Opie::Core; | 44 | using namespace Opie::Core; |
44 | using namespace Opie::Ui; | 45 | using namespace Opie::Ui; |
45 | 46 | ||
46 | /* QT */ | 47 | /* QT */ |
48 | #include <qcombobox.h> | ||
47 | #include <qcopchannel_qws.h> | 49 | #include <qcopchannel_qws.h> |
48 | #include <qpainter.h> | 50 | #include <qpainter.h> |
49 | #include <qfile.h> | 51 | #include <qfile.h> |
50 | #include <qtextstream.h> | 52 | #include <qtextstream.h> |
51 | #include <qmessagebox.h> | 53 | #include <qmessagebox.h> |
52 | #include <qsound.h> | 54 | #include <qsound.h> |
@@ -175,26 +177,26 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | |||
175 | OPcmciaSocket* theCard = 0; | 177 | OPcmciaSocket* theCard = 0; |
176 | 178 | ||
177 | while ( it.current() && newCard ) | 179 | while ( it.current() && newCard ) |
178 | { | 180 | { |
179 | if ( it.current()->isEmpty() ) | 181 | if ( it.current()->isEmpty() ) |
180 | { | 182 | { |
181 | odebug << "skipping empty card in socket " << it.current()->number() << oendl; | 183 | odebug << "pcmcia: skipping empty card in socket " << it.current()->number() << oendl; |
182 | ++it; | 184 | ++it; |
183 | continue; | 185 | continue; |
184 | } | 186 | } |
185 | else | 187 | else |
186 | { | 188 | { |
187 | theCard = it.current(); | 189 | theCard = it.current(); |
188 | QString cardName = theCard->productIdentity().join( " " ); | 190 | QString cardName = theCard->productIdentity().join( " " ); |
189 | for ( int i = 0; i < nCards; ++i ) | 191 | for ( int i = 0; i < nCards; ++i ) |
190 | { | 192 | { |
191 | QString cardSection = QString( "Card_%1" ).arg( i ); | 193 | QString cardSection = QString( "Card_%1" ).arg( i ); |
192 | cfg.setGroup( cardSection ); | 194 | cfg.setGroup( cardSection ); |
193 | QString name = cfg.readEntry( "name" ); | 195 | QString name = cfg.readEntry( "name" ); |
194 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; | 196 | odebug << "pcmcia: comparing card '" << cardName << "' with known card '" << name << "'" << oendl; |
195 | if ( cardName == name ) | 197 | if ( cardName == name ) |
196 | { | 198 | { |
197 | newCard = false; | 199 | newCard = false; |
198 | break; | 200 | break; |
199 | } | 201 | } |
200 | } | 202 | } |
@@ -204,44 +206,68 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | |||
204 | if ( newCard ) | 206 | if ( newCard ) |
205 | { | 207 | { |
206 | odebug << "pcmcia: unconfigured card detected" << oendl; | 208 | odebug << "pcmcia: unconfigured card detected" << oendl; |
207 | QString newCardName = theCard->productIdentity().join( " " ).stripWhiteSpace(); | 209 | QString newCardName = theCard->productIdentity().join( " " ).stripWhiteSpace(); |
208 | int result = QMessageBox::information( qApp->desktop(), | 210 | int result = QMessageBox::information( qApp->desktop(), |
209 | tr( "PCMCIA/CF Subsystem" ), | 211 | tr( "PCMCIA/CF Subsystem" ), |
210 | tr( "<qt>You have inserted the card '%1'. This card is not yet configured. Do you want to configure it now?</qt>" ).arg( newCardName ), | 212 | tr( "<qt>You have inserted the card<br/><b>%1</b><br/>This card is not yet configured. Do you want to configure it now?</qt>" ).arg( newCardName ), |
211 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ); | 213 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ); |
212 | odebug << "result = " << result << oendl; | 214 | odebug << "pcmcia: result = " << result << oendl; |
213 | if ( result == 0 ) | 215 | if ( result == 0 ) |
214 | { | 216 | { |
215 | bool configured = configure( theCard ); | 217 | QString insertAction; QString resumeAction; QString driver; QString conf; |
218 | bool configured = configure( theCard, insertAction, resumeAction, driver, conf ); | ||
216 | 219 | ||
217 | if ( configured ) | 220 | if ( configured ) |
218 | { | 221 | { |
219 | odebug << "card has been configured. writing out to dabase" << oendl; | 222 | odebug << "pcmcia: card has been configured. writing out to database" << oendl; |
220 | cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); | 223 | cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); |
221 | cfg.writeEntry( "name", newCardName ); | 224 | cfg.writeEntry( "name", newCardName ); |
222 | cfg.writeEntry( "insert", "suspend" ); | 225 | cfg.writeEntry( "insertAction", insertAction ); |
226 | cfg.writeEntry( "resumeAction", resumeAction ); | ||
223 | cfg.setGroup( "Global" ); | 227 | cfg.setGroup( "Global" ); |
224 | cfg.writeEntry( "nCards", nCards+1 ); | 228 | cfg.writeEntry( "nCards", nCards+1 ); |
225 | cfg.write(); | 229 | cfg.write(); |
230 | |||
231 | QFile confFile( QString( "/etc/pcmcia/%1" ).arg( conf ) ); | ||
232 | if ( confFile.open( IO_ReadWrite | IO_Append ) ) | ||
233 | { | ||
234 | QString entryCard = QString( "card \"%1\"" ).arg( newCardName ); | ||
235 | QString entryVersion( " version " ); | ||
236 | for ( QStringList::Iterator it = theCard->productIdentity().begin(); it != theCard->productIdentity().end(); ++it ) | ||
237 | { | ||
238 | entryVersion += QString( "\"%1\", " ).arg( *it ); | ||
239 | } | ||
240 | QString entryBind = QString( " bind %1" ).arg( driver ); | ||
241 | QString entry = QString( "\n%1\n%2\n%3\n" ).arg( entryCard ).arg( entryVersion ).arg( entryBind ); | ||
242 | odebug << "pcmcia: writing entry...:" << entry << oendl; | ||
243 | |||
244 | confFile.writeBlock( (const char*) entry, entry.length() ); | ||
245 | Global::statusMessage( "restarting pcmcia services..." ); | ||
246 | ::system( "/etc/init.d/pcmcia restart" ); | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | owarn << "pcmcia: couldn't write binding to '" << conf << "'." << oendl; | ||
251 | } | ||
226 | } | 252 | } |
227 | else | 253 | else |
228 | { | 254 | { |
229 | odebug << "card has not been configured this time. leaving as unknown card" << oendl; | 255 | odebug << "pcmcia: card has not been configured this time. leaving as unknown card" << oendl; |
230 | } | 256 | } |
231 | } | 257 | } |
232 | else | 258 | else |
233 | { | 259 | { |
234 | odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl; | 260 | odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl; |
235 | } | 261 | } |
236 | } | 262 | } |
237 | else // it's an already configured card | 263 | else // it's an already configured card |
238 | { | 264 | { |
239 | QString action = ConfigDialog::preferredAction( theCard ); | 265 | QString insertAction = ConfigDialog::preferredAction( theCard, "insert" ); |
240 | odebug << "pcmcia: card has been previously configured" << oendl; | 266 | odebug << "pcmcia: card has been previously configured" << oendl; |
241 | odebug << "pcmcia: need to perform action'" << action << "' now... sorry, not yet implemented..." << oendl; | 267 | odebug << "pcmcia: TODO: need to perform action'" << insertAction << "' now... sorry, not yet implemented..." << oendl; |
242 | } | 268 | } |
243 | repaint( true ); | 269 | repaint( true ); |
244 | } | 270 | } |
245 | 271 | ||
246 | 272 | ||
247 | void PcmciaManager::paintEvent( QPaintEvent * ) | 273 | void PcmciaManager::paintEvent( QPaintEvent * ) |
@@ -268,43 +294,56 @@ int PcmciaManager::position() | |||
268 | void PcmciaManager::execCommand( const QStringList &strList ) | 294 | void PcmciaManager::execCommand( const QStringList &strList ) |
269 | { | 295 | { |
270 | } | 296 | } |
271 | 297 | ||
272 | void PcmciaManager::userCardAction( int action ) | 298 | void PcmciaManager::userCardAction( int action ) |
273 | { | 299 | { |
274 | odebug << "user action on socket " << action / 100 << " requested. action = " << action << oendl; | 300 | odebug << "pcmcia: user action on socket " << action / 100 << " requested. action = " << action << oendl; |
275 | 301 | ||
276 | int socket = action / 100; | 302 | int socket = action / 100; |
277 | int what = action % 100; | 303 | int what = action % 100; |
278 | bool success = false; | 304 | bool success = false; |
279 | 305 | ||
280 | switch ( what ) | 306 | switch ( what ) |
281 | { | 307 | { |
282 | case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); success = true; break; | 308 | case CONFIGURE: |
309 | { | ||
310 | QString insertAction; QString resumeAction; QString driver; QString conf; | ||
311 | bool result = configure( OPcmciaSystem::instance()->socket( socket ), insertAction, resumeAction, driver, conf ); | ||
312 | success = true; | ||
313 | break; | ||
314 | } | ||
283 | case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break; | 315 | case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break; |
284 | case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break; | 316 | case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break; |
285 | case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break; | 317 | case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break; |
286 | case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break; | 318 | case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break; |
287 | case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break; | 319 | case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break; |
288 | default: odebug << "not yet implemented" << oendl; | 320 | default: odebug << "pcmcia: not yet implemented" << oendl; |
289 | } | 321 | } |
290 | 322 | ||
291 | if ( !success ) | 323 | if ( !success ) |
292 | { | 324 | { |
293 | owarn << "couldn't perform user action (" << strerror( errno ) << ")" << oendl; | 325 | owarn << "pcmcia: couldn't perform user action (" << strerror( errno ) << ")" << oendl; |
294 | } | 326 | } |
295 | 327 | ||
296 | } | 328 | } |
297 | 329 | ||
298 | bool PcmciaManager::configure( OPcmciaSocket* card ) | 330 | bool PcmciaManager::configure( OPcmciaSocket* card, QString& insertAction, QString& resumeAction, QString& driver, QString& conf ) |
299 | { | 331 | { |
300 | configuring = true; | 332 | configuring = true; |
301 | ConfigDialog dialog( card, qApp->desktop() ); | 333 | ConfigDialog dialog( card, qApp->desktop() ); |
302 | int configresult = QPEApplication::execDialog( &dialog, false ); | 334 | int configresult = QPEApplication::execDialog( &dialog, false ); |
303 | configuring = false; | 335 | configuring = false; |
304 | odebug << "pcmcia: configresult = " << configresult << oendl; | 336 | odebug << "pcmcia: configresult = " << configresult << oendl; |
337 | if ( configresult ) | ||
338 | { | ||
339 | insertAction = dialog.cbInsertAction->currentText(); | ||
340 | resumeAction = dialog.cbResumeAction->currentText(); | ||
341 | driver = dialog.cbBindTo->currentText(); | ||
342 | conf = dialog.bindEntries[driver]; | ||
343 | } | ||
305 | return configresult; | 344 | return configresult; |
306 | } | 345 | } |
307 | 346 | ||
308 | 347 | ||
309 | EXPORT_OPIE_APPLET_v1( PcmciaManager ) | 348 | EXPORT_OPIE_APPLET_v1( PcmciaManager ) |
310 | 349 | ||
diff --git a/noncore/applets/pcmcia/pcmcia.h b/noncore/applets/pcmcia/pcmcia.h index eb9c513..94203d3 100644 --- a/noncore/applets/pcmcia/pcmcia.h +++ b/noncore/applets/pcmcia/pcmcia.h | |||
@@ -51,13 +51,13 @@ class PcmciaManager : public QWidget | |||
51 | 51 | ||
52 | protected: | 52 | protected: |
53 | void paintEvent( QPaintEvent* ); | 53 | void paintEvent( QPaintEvent* ); |
54 | void mousePressEvent( QMouseEvent * ); | 54 | void mousePressEvent( QMouseEvent * ); |
55 | 55 | ||
56 | private: | 56 | private: |
57 | bool configure( Opie::Core::OPcmciaSocket* ); | 57 | bool configure( Opie::Core::OPcmciaSocket*, QString&, QString&, QString&, QString& ); |
58 | void execCommand( const QStringList &command ); | 58 | void execCommand( const QStringList &command ); |
59 | void popUp(QString message, QString icon = QString::null ); | 59 | void popUp(QString message, QString icon = QString::null ); |
60 | 60 | ||
61 | private: | 61 | private: |
62 | bool configuring; | 62 | bool configuring; |
63 | int commandOrig; | 63 | int commandOrig; |