summaryrefslogtreecommitdiff
path: root/noncore/applets/pcmcia/pcmcia.cpp
Unidiff
Diffstat (limited to 'noncore/applets/pcmcia/pcmcia.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp40
1 files changed, 26 insertions, 14 deletions
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp
index 99c1bc9..1a2b619 100644
--- a/noncore/applets/pcmcia/pcmcia.cpp
+++ b/noncore/applets/pcmcia/pcmcia.cpp
@@ -194,49 +194,60 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
194 odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; 194 odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl;
195 if ( cardName == name ) 195 if ( cardName == name )
196 { 196 {
197 newCard = false; 197 newCard = false;
198 break; 198 break;
199 } 199 }
200 } 200 }
201 if ( !newCard ) ++it; else break; 201 if ( !newCard ) ++it; else break;
202 } 202 }
203 } 203 }
204 if ( newCard ) 204 if ( newCard )
205 { 205 {
206 odebug << "pcmcia: new card detected" << oendl; 206 odebug << "pcmcia: unconfigured card detected" << oendl;
207 cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); 207 QString newCardName = theCard->productIdentity().join( " " ).stripWhiteSpace();
208 cfg.writeEntry( "name", theCard->productIdentity().join( " " ) );
209 cfg.writeEntry( "insert", "suspend" );
210 cfg.setGroup( "Global" );
211 cfg.writeEntry( "nCards", nCards+1 );
212 cfg.write();
213
214 int result = QMessageBox::information( qApp->desktop(), 208 int result = QMessageBox::information( qApp->desktop(),
215 tr( "PCMCIA/CF Subsystem" ), 209 tr( "PCMCIA/CF Subsystem" ),
216 tr( "You have inserted a new card:\n%1\nDo you want to configure?" ).arg( theCard->productIdentity().join( " " ) ), 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 ),
217 tr( "Yes" ), tr( "No" ), 0, 0, 1 ); 211 tr( "Yes" ), tr( "No" ), 0, 0, 1 );
218 odebug << "result = " << result << oendl; 212 odebug << "result = " << result << oendl;
219 if ( result == 0 ) 213 if ( result == 0 )
220 { 214 {
221 configure( theCard ); 215 bool configured = configure( theCard );
216
217 if ( configured )
218 {
219 odebug << "card has been configured. writing out to dabase" << oendl;
220 cfg.setGroup( QString( "Card_%1" ).arg( nCards ) );
221 cfg.writeEntry( "name", newCardName );
222 cfg.writeEntry( "insert", "suspend" );
223 cfg.setGroup( "Global" );
224 cfg.writeEntry( "nCards", nCards+1 );
225 cfg.write();
226 }
227 else
228 {
229 odebug << "card has not been configured this time. leaving as unknown card" << oendl;
230 }
222 } 231 }
223 else 232 else
224 { 233 {
225 odebug << "pcmcia: user doesn't want to configure " << theCard->productIdentity().join( " " ) << " now." << oendl; 234 odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl;
226 } 235 }
227 } 236 }
228 else 237 else // it's an already configured card
229 { 238 {
230 odebug << "pcmcia: card has been previously inserted" << oendl; 239 QString action = ConfigDialog::preferredAction( theCard );
240 odebug << "pcmcia: card has been previously configured" << oendl;
241 odebug << "pcmcia: need to perform action'" << action << "' now... sorry, not yet implemented..." << oendl;
231 } 242 }
232 repaint( true ); 243 repaint( true );
233} 244}
234 245
235 246
236void PcmciaManager::paintEvent( QPaintEvent * ) 247void PcmciaManager::paintEvent( QPaintEvent * )
237{ 248{
238 QPainter p( this ); 249 QPainter p( this );
239 odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl; 250 odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl;
240 251
241 if ( OPcmciaSystem::instance()->cardCount() ) 252 if ( OPcmciaSystem::instance()->cardCount() )
242 { 253 {
@@ -275,24 +286,25 @@ void PcmciaManager::userCardAction( int action )
275 case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break; 286 case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break;
276 case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break; 287 case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break;
277 default: odebug << "not yet implemented" << oendl; 288 default: odebug << "not yet implemented" << oendl;
278 } 289 }
279 290
280 if ( !success ) 291 if ( !success )
281 { 292 {
282 owarn << "couldn't perform user action (" << strerror( errno ) << ")" << oendl; 293 owarn << "couldn't perform user action (" << strerror( errno ) << ")" << oendl;
283 } 294 }
284 295
285} 296}
286 297
287void PcmciaManager::configure( OPcmciaSocket* card ) 298bool PcmciaManager::configure( OPcmciaSocket* card )
288{ 299{
289 configuring = true; 300 configuring = true;
290 ConfigDialog dialog( card, qApp->desktop() ); 301 ConfigDialog dialog( card, qApp->desktop() );
291 int configresult = QPEApplication::execDialog( &dialog, false ); 302 int configresult = QPEApplication::execDialog( &dialog, false );
292 configuring = false; 303 configuring = false;
293 odebug << "pcmcia: configresult = " << configresult << oendl; 304 odebug << "pcmcia: configresult = " << configresult << oendl;
305 return configresult;
294} 306}
295 307
296 308
297EXPORT_OPIE_APPLET_v1( PcmciaManager ) 309EXPORT_OPIE_APPLET_v1( PcmciaManager )
298 310