-rw-r--r-- | noncore/applets/pcmcia/configdialog.cpp | 10 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.cpp | 22 |
2 files changed, 18 insertions, 14 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp index f94edde..3b1b40c 100644 --- a/noncore/applets/pcmcia/configdialog.cpp +++ b/noncore/applets/pcmcia/configdialog.cpp | |||
@@ -42,25 +42,25 @@ using namespace Opie::Core; | |||
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() ); |
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->productIdentity() << "' 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->productIdentity() << "' 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() ) |
@@ -127,17 +127,17 @@ 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 cardName = card->productIdentity(); |
136 | QString action; | 136 | QString action; |
137 | 137 | ||
138 | for ( int i = 0; i < nCards; ++i ) | 138 | for ( int i = 0; i < nCards; ++i ) |
139 | { | 139 | { |
140 | QString cardSection = QString( "Card_%1" ).arg( i ); | 140 | QString cardSection = QString( "Card_%1" ).arg( i ); |
141 | cfg.setGroup( cardSection ); | 141 | cfg.setGroup( cardSection ); |
142 | QString name = cfg.readEntry( "name" ); | 142 | QString name = cfg.readEntry( "name" ); |
143 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; | 143 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; |
@@ -149,17 +149,17 @@ void ConfigDialog::writeConfigEntry( const OPcmciaSocket* card, const QString& k | |||
149 | } | 149 | } |
150 | } | 150 | } |
151 | 151 | ||
152 | 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 ) |
153 | { | 153 | { |
154 | OConfig cfg( "PCMCIA" ); | 154 | OConfig cfg( "PCMCIA" ); |
155 | cfg.setGroup( "Global" ); | 155 | cfg.setGroup( "Global" ); |
156 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 156 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
157 | QString cardName = card->productIdentity().join( " " ).stripWhiteSpace(); | 157 | QString cardName = card->productIdentity(); |
158 | QString value; | 158 | QString value; |
159 | 159 | ||
160 | for ( int i = 0; i < nCards; ++i ) | 160 | for ( int i = 0; i < nCards; ++i ) |
161 | { | 161 | { |
162 | QString cardSection = QString( "Card_%1" ).arg( i ); | 162 | QString cardSection = QString( "Card_%1" ).arg( i ); |
163 | cfg.setGroup( cardSection ); | 163 | cfg.setGroup( cardSection ); |
164 | QString name = cfg.readEntry( "name" ); | 164 | QString name = cfg.readEntry( "name" ); |
165 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; | 165 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; |
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp index af23f58..c6386cb 100644 --- a/noncore/applets/pcmcia/pcmcia.cpp +++ b/noncore/applets/pcmcia/pcmcia.cpp | |||
@@ -71,17 +71,17 @@ PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ), popupMenu( | |||
71 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 71 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
72 | connect( pcmciaChannel, | 72 | connect( pcmciaChannel, |
73 | SIGNAL( received(const QCString&,const QByteArray&) ), this, | 73 | SIGNAL( received(const QCString&,const QByteArray&) ), this, |
74 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); | 74 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); |
75 | 75 | ||
76 | setFocusPolicy( NoFocus ); | 76 | setFocusPolicy( NoFocus ); |
77 | setFixedWidth ( AppLnk::smallIconSize() ); | 77 | setFixedWidth ( AppLnk::smallIconSize() ); |
78 | setFixedHeight ( AppLnk::smallIconSize() ); | 78 | setFixedHeight ( AppLnk::smallIconSize() ); |
79 | pm = Opie::Core::OResource::loadPixmap( "pcmcia/pcmcia", Opie::Core::OResource::SmallIcon ); | 79 | pm = Opie::Core::OResource::loadPixmap( "pcmcia", Opie::Core::OResource::SmallIcon ); |
80 | configuring = false; | 80 | configuring = false; |
81 | 81 | ||
82 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 82 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
83 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 83 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
84 | this, SLOT(handleSystemChannel(const QCString&,const QByteArray&)) ); | 84 | this, SLOT(handleSystemChannel(const QCString&,const QByteArray&)) ); |
85 | } | 85 | } |
86 | 86 | ||
87 | 87 | ||
@@ -158,21 +158,25 @@ void PcmciaManager::mousePressEvent( QMouseEvent* ) | |||
158 | QPopupMenu* submenu = new QPopupMenu( menu ); | 158 | QPopupMenu* submenu = new QPopupMenu( menu ); |
159 | submenu->insertItem( "&Eject", EJECT+i*100 ); | 159 | submenu->insertItem( "&Eject", EJECT+i*100 ); |
160 | submenu->insertItem( "&Insert", INSERT+i*100 ); | 160 | submenu->insertItem( "&Insert", INSERT+i*100 ); |
161 | submenu->insertItem( "&Suspend", SUSPEND+i*100 ); | 161 | submenu->insertItem( "&Suspend", SUSPEND+i*100 ); |
162 | submenu->insertItem( "&Resume", RESUME+i*100 ); | 162 | submenu->insertItem( "&Resume", RESUME+i*100 ); |
163 | submenu->insertItem( "Rese&t", RESET+i*100 ); | 163 | submenu->insertItem( "Rese&t", RESET+i*100 ); |
164 | submenu->insertItem( "&Configure", CONFIGURE+i*100 ); | 164 | submenu->insertItem( "&Configure", CONFIGURE+i*100 ); |
165 | 165 | ||
166 | submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); | 166 | bool isSuspended = it.current()->isSuspended(); |
167 | submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); | 167 | bool isEmpty = it.current()->isEmpty(); |
168 | submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); | 168 | |
169 | submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); | 169 | submenu->setItemEnabled( EJECT+i*100, !isEmpty ); |
170 | submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() && !configuring ); | 170 | submenu->setItemEnabled( INSERT+i*100, isEmpty ); |
171 | submenu->setItemEnabled( SUSPEND+i*100, !isEmpty && !isSuspended ); | ||
172 | submenu->setItemEnabled( RESUME+i*100, !isEmpty && isSuspended ); | ||
173 | submenu->setItemEnabled( RESET+i*100, !isEmpty && !isSuspended ); | ||
174 | submenu->setItemEnabled( CONFIGURE+i*100, !isEmpty && !configuring ); | ||
171 | 175 | ||
172 | connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); | 176 | connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); |
173 | menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); | 177 | menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); |
174 | ++it; | 178 | ++it; |
175 | } | 179 | } |
176 | 180 | ||
177 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 181 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
178 | QSize s = menu->sizeHint(); | 182 | QSize s = menu->sizeHint(); |
@@ -208,17 +212,17 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | |||
208 | { | 212 | { |
209 | odebug << "pcmcia: skipping empty card in socket " << it.current()->number() << oendl; | 213 | odebug << "pcmcia: skipping empty card in socket " << it.current()->number() << oendl; |
210 | ++it; | 214 | ++it; |
211 | continue; | 215 | continue; |
212 | } | 216 | } |
213 | else | 217 | else |
214 | { | 218 | { |
215 | theCard = it.current(); | 219 | theCard = it.current(); |
216 | QString cardName = theCard->productIdentity().join( " " ).stripWhiteSpace(); | 220 | QString cardName = theCard->productIdentity(); |
217 | for ( int i = 0; i < nCards; ++i ) | 221 | for ( int i = 0; i < nCards; ++i ) |
218 | { | 222 | { |
219 | QString cardSection = QString( "Card_%1" ).arg( i ); | 223 | QString cardSection = QString( "Card_%1" ).arg( i ); |
220 | cfg.setGroup( cardSection ); | 224 | cfg.setGroup( cardSection ); |
221 | QString name = cfg.readEntry( "name" ); | 225 | QString name = cfg.readEntry( "name" ); |
222 | odebug << "pcmcia: comparing card '" << cardName << "' with known card '" << name << "'" << oendl; | 226 | odebug << "pcmcia: comparing card '" << cardName << "' with known card '" << name << "'" << oendl; |
223 | if ( cardName == name ) | 227 | if ( cardName == name ) |
224 | { | 228 | { |
@@ -229,17 +233,17 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | |||
229 | } | 233 | } |
230 | } | 234 | } |
231 | if ( !newCard ) ++it; else break; | 235 | if ( !newCard ) ++it; else break; |
232 | } | 236 | } |
233 | } | 237 | } |
234 | if ( newCard ) | 238 | if ( newCard ) |
235 | { | 239 | { |
236 | odebug << "pcmcia: unconfigured card detected" << oendl; | 240 | odebug << "pcmcia: unconfigured card detected" << oendl; |
237 | QString newCardName = theCard->productIdentity().join( " " ).stripWhiteSpace(); | 241 | QString newCardName = theCard->productIdentity(); |
238 | int result = QMessageBox::information( qApp->desktop(), | 242 | int result = QMessageBox::information( qApp->desktop(), |
239 | tr( "PCMCIA/CF Subsystem" ), | 243 | tr( "PCMCIA/CF Subsystem" ), |
240 | 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 ), | 244 | 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 ), |
241 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ); | 245 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ); |
242 | odebug << "pcmcia: result = " << result << oendl; | 246 | odebug << "pcmcia: result = " << result << oendl; |
243 | if ( result == 0 ) | 247 | if ( result == 0 ) |
244 | { | 248 | { |
245 | QString insertAction; QString resumeAction; QString driver; QString conf; | 249 | QString insertAction; QString resumeAction; QString driver; QString conf; |
@@ -256,17 +260,17 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | |||
256 | cfg.writeEntry( "nCards", nCards+1 ); | 260 | cfg.writeEntry( "nCards", nCards+1 ); |
257 | cfg.write(); | 261 | cfg.write(); |
258 | 262 | ||
259 | QFile confFile( conf ); | 263 | QFile confFile( conf ); |
260 | if ( confFile.open( IO_ReadWrite | IO_Append ) ) | 264 | if ( confFile.open( IO_ReadWrite | IO_Append ) ) |
261 | { | 265 | { |
262 | QString entryCard = QString( "card \"%1\"" ).arg( newCardName ); | 266 | QString entryCard = QString( "card \"%1\"" ).arg( newCardName ); |
263 | QString entryVersion( " version " ); | 267 | QString entryVersion( " version " ); |
264 | for ( QStringList::Iterator it = theCard->productIdentity().begin(); it != theCard->productIdentity().end(); ++it ) | 268 | for ( QStringList::Iterator it = theCard->productIdentityVector().begin(); it != theCard->productIdentityVector().end(); ++it ) |
265 | { | 269 | { |
266 | entryVersion += QString( "\"%1\", " ).arg( *it ); | 270 | entryVersion += QString( "\"%1\", " ).arg( *it ); |
267 | } | 271 | } |
268 | QString entryBind = QString( " bind %1" ).arg( driver ); | 272 | QString entryBind = QString( " bind %1" ).arg( driver ); |
269 | QString entry = QString( "\n%1\n%2\n%3\n" ).arg( entryCard ).arg( entryVersion ).arg( entryBind ); | 273 | QString entry = QString( "\n%1\n%2\n%3\n" ).arg( entryCard ).arg( entryVersion ).arg( entryBind ); |
270 | odebug << "pcmcia: writing entry...:" << entry << oendl; | 274 | odebug << "pcmcia: writing entry...:" << entry << oendl; |
271 | 275 | ||
272 | confFile.writeBlock( (const char*) entry, entry.length() ); | 276 | confFile.writeBlock( (const char*) entry, entry.length() ); |