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
@@ -182,73 +182,84 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
182 ++it; 182 ++it;
183 continue; 183 continue;
184 } 184 }
185 else 185 else
186 { 186 {
187 theCard = it.current(); 187 theCard = it.current();
188 QString cardName = theCard->productIdentity().join( " " ); 188 QString cardName = theCard->productIdentity().join( " " );
189 for ( int i = 0; i < nCards; ++i ) 189 for ( int i = 0; i < nCards; ++i )
190 { 190 {
191 QString cardSection = QString( "Card_%1" ).arg( i ); 191 QString cardSection = QString( "Card_%1" ).arg( i );
192 cfg.setGroup( cardSection ); 192 cfg.setGroup( cardSection );
193 QString name = cfg.readEntry( "name" ); 193 QString name = cfg.readEntry( "name" );
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 {
243 p.drawPixmap( 0, 0, pm ); 254 p.drawPixmap( 0, 0, pm );
244 show(); 255 show();
245 } 256 }
246 else 257 else
247 { 258 {
248 hide(); 259 hide();
249 } 260 }
250} 261}
251 262
252int PcmciaManager::position() 263int PcmciaManager::position()
253{ 264{
254 return 7; 265 return 7;
@@ -263,36 +274,37 @@ void PcmciaManager::userCardAction( int action )
263 odebug << "user action on socket " << action / 100 << " requested. action = " << action << oendl; 274 odebug << "user action on socket " << action / 100 << " requested. action = " << action << oendl;
264 275
265 int socket = action / 100; 276 int socket = action / 100;
266 int what = action % 100; 277 int what = action % 100;
267 bool success = false; 278 bool success = false;
268 279
269 switch ( what ) 280 switch ( what )
270 { 281 {
271 case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); success = true; break; 282 case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); success = true; break;
272 case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break; 283 case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break;
273 case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break; 284 case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break;
274 case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break; 285 case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break;
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