author | mickeyl <mickeyl> | 2005-06-26 12:02:40 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-06-26 12:02:40 (UTC) |
commit | d5a2b0d5ca4daa11894c52f3599dab56205bef4c (patch) (unidiff) | |
tree | 590d9ba11f3999e4c2b2ebd353ea49af552d9d12 /noncore | |
parent | 790aeb8898d635468c2b9e24fd16a70aab64b1dd (diff) | |
download | opie-d5a2b0d5ca4daa11894c52f3599dab56205bef4c.zip opie-d5a2b0d5ca4daa11894c52f3599dab56205bef4c.tar.gz opie-d5a2b0d5ca4daa11894c52f3599dab56205bef4c.tar.bz2 |
- refactor miscellaneous things to make configuring work all the time
- add 'prompt for' dialog
- applet completion state 100% for Version 1.2.1
-rw-r--r-- | noncore/applets/pcmcia/configdialog.cpp | 111 | ||||
-rw-r--r-- | noncore/applets/pcmcia/configdialog.h | 4 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.cpp | 88 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.h | 2 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.pro | 6 | ||||
-rw-r--r-- | noncore/applets/pcmcia/promptactiondialog.ui | 58 |
6 files changed, 182 insertions, 87 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp index 3b1b40c..010d691 100644 --- a/noncore/applets/pcmcia/configdialog.cpp +++ b/noncore/applets/pcmcia/configdialog.cpp | |||
@@ -30,22 +30,27 @@ | |||
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 | #include <qpe/global.h> | ||
36 | using namespace Opie::Core; | 37 | using namespace Opie::Core; |
37 | 38 | ||
38 | /* QT */ | 39 | /* QT */ |
39 | #include <qcombobox.h> | 40 | #include <qcombobox.h> |
40 | #include <qdir.h> | 41 | #include <qdir.h> |
41 | #include <qfile.h> | 42 | #include <qfile.h> |
42 | #include <qgroupbox.h> | 43 | #include <qgroupbox.h> |
43 | #include <qlabel.h> | 44 | #include <qlabel.h> |
44 | #include <qtextstream.h> | 45 | #include <qtextstream.h> |
45 | 46 | ||
47 | /* STD */ | ||
48 | #include <errno.h> | ||
49 | #include <string.h> | ||
50 | |||
46 | ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) | 51 | ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) |
47 | :ConfigDialogBase( parent, "pcmcia config dialog", true ) | 52 | :ConfigDialogBase( parent, "pcmcia config dialog", true ) |
48 | { | 53 | { |
49 | gbDetails->setTitle( QString( "Details for card in socket #%1" ).arg( card->number() ) ); | 54 | gbDetails->setTitle( QString( "Details for card in socket #%1" ).arg( card->number() ) ); |
50 | txtCardName->setText( card->productIdentity() ); | 55 | txtCardName->setText( card->productIdentity() ); |
51 | txtManfid->setText( card->manufacturerIdentity() ); | 56 | txtManfid->setText( card->manufacturerIdentity() ); |
@@ -56,19 +61,19 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) | |||
56 | 61 | ||
57 | odebug << "pcmcia: preferred insertion action for card '" << card->productIdentity() << "' seems to be '" << insertAction << "'" << oendl; | 62 | odebug << "pcmcia: preferred insertion action for card '" << card->productIdentity() << "' seems to be '" << insertAction << "'" << oendl; |
58 | odebug << "pcmcia: preferred resume action for card '" << card->productIdentity() << "' seems to be '" << resumeAction << "'" << oendl; | 63 | odebug << "pcmcia: preferred resume action for card '" << card->productIdentity() << "' seems to be '" << resumeAction << "'" << oendl; |
59 | 64 | ||
60 | if ( !insertAction.isEmpty() ) | 65 | if ( !insertAction.isEmpty() ) |
61 | { | 66 | { |
62 | for ( int i; i < cbInsertAction->count(); ++i ) | 67 | for ( unsigned int i = 0; i < cbInsertAction->count(); ++i ) |
63 | if ( cbInsertAction->text( i ) == insertAction ) cbInsertAction->setCurrentItem( i ); | 68 | if ( cbInsertAction->text( i ) == insertAction ) cbInsertAction->setCurrentItem( i ); |
64 | } | 69 | } |
65 | 70 | ||
66 | if ( !resumeAction.isEmpty() ) | 71 | if ( !resumeAction.isEmpty() ) |
67 | { | 72 | { |
68 | for ( int i; i < cbResumeAction->count(); ++i ) | 73 | for ( unsigned int i = 0; i < cbResumeAction->count(); ++i ) |
69 | if ( cbResumeAction->text( i ) == resumeAction ) cbResumeAction->setCurrentItem( i ); | 74 | if ( cbResumeAction->text( i ) == resumeAction ) cbResumeAction->setCurrentItem( i ); |
70 | } | 75 | } |
71 | 76 | ||
72 | if ( !card->isUnsupported() ) | 77 | if ( !card->isUnsupported() ) |
73 | { | 78 | { |
74 | odebug << "pcmcia: card is recognized - hiding bindings" << oendl; | 79 | odebug << "pcmcia: card is recognized - hiding bindings" << oendl; |
@@ -126,54 +131,108 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) | |||
126 | ConfigDialog::~ConfigDialog() | 131 | ConfigDialog::~ConfigDialog() |
127 | { | 132 | { |
128 | } | 133 | } |
129 | 134 | ||
130 | void ConfigDialog::writeConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& value ) | 135 | void ConfigDialog::writeConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& value ) |
131 | { | 136 | { |
132 | OConfig cfg( "PCMCIA" ); | 137 | OConfig* cfg = cardConfig( card ); |
133 | cfg.setGroup( "Global" ); | 138 | if ( cfg ) |
134 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 139 | { |
135 | QString cardName = card->productIdentity(); | 140 | cfg->writeEntry( key, value ); |
136 | QString action; | 141 | } |
142 | delete cfg; // deleting a 0 pointer is within spec. | ||
143 | } | ||
137 | 144 | ||
138 | for ( int i = 0; i < nCards; ++i ) | 145 | QString ConfigDialog::readConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& defaultValue ) |
139 | { | 146 | { |
140 | QString cardSection = QString( "Card_%1" ).arg( i ); | 147 | QString value; |
141 | cfg.setGroup( cardSection ); | 148 | OConfig* cfg = cardConfig( card ); |
142 | QString name = cfg.readEntry( "name" ); | 149 | if ( cfg ) |
143 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; | ||
144 | if ( cardName == name ) | ||
145 | { | 150 | { |
146 | cfg.writeEntry( key, value ); | 151 | value = cfg->readEntry( key, defaultValue ); |
147 | break; | ||
148 | } | 152 | } |
153 | delete cfg; // deleting a 0 pointer is within spec. | ||
154 | return value; | ||
149 | } | 155 | } |
156 | |||
157 | |||
158 | QString ConfigDialog::preferredAction( const OPcmciaSocket* card, const QString& type ) | ||
159 | { | ||
160 | return ConfigDialog::readConfigEntry( card, QString( "%1Action" ).arg( type ), "suspend" ); | ||
150 | } | 161 | } |
151 | 162 | ||
152 | QString ConfigDialog::readConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& defaultValue ) | 163 | |
164 | OConfig* ConfigDialog::cardConfig( const OPcmciaSocket* card ) | ||
153 | { | 165 | { |
154 | OConfig cfg( "PCMCIA" ); | 166 | OConfig* cardcfg = 0; |
155 | cfg.setGroup( "Global" ); | 167 | OConfig* cfg = new OConfig( "PCMCIA" ); |
156 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 168 | cfg->setGroup( "Global" ); |
169 | int nCards = cfg->readNumEntry( "nCards", 0 ); | ||
157 | QString cardName = card->productIdentity(); | 170 | QString cardName = card->productIdentity(); |
158 | QString value; | ||
159 | 171 | ||
160 | for ( int i = 0; i < nCards; ++i ) | 172 | for ( int i = 0; i < nCards; ++i ) |
161 | { | 173 | { |
162 | QString cardSection = QString( "Card_%1" ).arg( i ); | 174 | QString cardSection = QString( "Card_%1" ).arg( i ); |
163 | cfg.setGroup( cardSection ); | 175 | cfg->setGroup( cardSection ); |
164 | QString name = cfg.readEntry( "name" ); | 176 | QString name = cfg->readEntry( "name" ); |
165 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; | 177 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; |
166 | if ( cardName == name ) | 178 | if ( cardName == name ) |
167 | { | 179 | { |
168 | value = cfg.readEntry( key, defaultValue ); | 180 | cardcfg = cfg; |
169 | break; | 181 | break; |
170 | } | 182 | } |
171 | } | 183 | } |
172 | return value; | 184 | return cardcfg; |
173 | } | 185 | } |
174 | 186 | ||
175 | 187 | ||
176 | QString ConfigDialog::preferredAction( const OPcmciaSocket* card, const QString& type ) | 188 | void ConfigDialog::writeConfiguration( const OPcmciaSocket* card ) |
177 | { | 189 | { |
178 | return ConfigDialog::readConfigEntry( card, QString( "%1Action" ).arg( type ), "suspend" ); | 190 | odebug << "pcmcia: ConfigDialog::writeConfiguration()" << oendl; |
191 | OConfig* cfg = cardConfig( card ); | ||
192 | if ( !cfg ) | ||
193 | { | ||
194 | cfg = new OConfig( "PCMCIA" ); | ||
195 | cfg->setGroup( "Global" ); | ||
196 | int nCards = cfg->readNumEntry( "nCards", 0 ); | ||
197 | cfg->setGroup( QString( "Card_%1" ).arg( nCards ) ); | ||
198 | cfg->writeEntry( "name", card->productIdentity() ); | ||
199 | cfg->setGroup( "Global" ); | ||
200 | cfg->writeEntry( "nCards", nCards+1 ); | ||
201 | cfg->setGroup( QString( "Card_%1" ).arg( nCards ) ); | ||
202 | } | ||
203 | |||
204 | cfg->writeEntry( "insertAction", cbInsertAction->currentText() ); | ||
205 | cfg->writeEntry( "resumeAction", cbResumeAction->currentText() ); | ||
206 | cfg->write(); | ||
207 | |||
208 | if ( cbBindTo->isVisible() && cbBindTo->currentText() != "<None>" ) | ||
209 | { | ||
210 | QString driver = cbBindTo->currentText(); | ||
211 | QString conf = bindEntries[driver]; | ||
212 | |||
213 | // write binding | ||
214 | |||
215 | QFile confFile( conf ); | ||
216 | if ( confFile.open( IO_ReadWrite | IO_Append ) ) | ||
217 | { | ||
218 | QString entryCard = QString( "card \"%1\"" ).arg( card->productIdentity() ); | ||
219 | QString entryVersion( " version " ); | ||
220 | for ( QStringList::Iterator it = card->productIdentityVector().begin(); it != card->productIdentityVector().end(); ++it ) | ||
221 | { | ||
222 | entryVersion += QString( "\"%1\", " ).arg( *it ); | ||
223 | } | ||
224 | QString entryBind = QString( " bind %1" ).arg( driver ); | ||
225 | QString entry = QString( "\n%1\n%2\n%3\n" ).arg( entryCard ).arg( entryVersion ).arg( entryBind ); | ||
226 | odebug << "pcmcia: writing entry...:" << entry << oendl; | ||
227 | |||
228 | confFile.writeBlock( (const char*) entry, entry.length() ); | ||
229 | Global::statusMessage( "restarting pcmcia services..." ); | ||
230 | OPcmciaSystem::instance()->restart(); | ||
231 | } | ||
232 | else | ||
233 | { | ||
234 | owarn << "pcmcia: couldn't write binding to '" << conf << "' ( " << strerror( errno ) << " )." << oendl; | ||
235 | } | ||
179 | } | 236 | } |
237 | } | ||
238 | |||
diff --git a/noncore/applets/pcmcia/configdialog.h b/noncore/applets/pcmcia/configdialog.h index 169dadb..eb081a1 100644 --- a/noncore/applets/pcmcia/configdialog.h +++ b/noncore/applets/pcmcia/configdialog.h | |||
@@ -29,23 +29,25 @@ | |||
29 | 29 | ||
30 | #ifndef CONFIGDIALOG_H | 30 | #ifndef CONFIGDIALOG_H |
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; class OConfig; }; }; |
36 | 36 | ||
37 | typedef QMap<QString,QString> StringMap; | 37 | typedef QMap<QString,QString> StringMap; |
38 | 38 | ||
39 | class ConfigDialog : public ConfigDialogBase | 39 | class ConfigDialog : public ConfigDialogBase |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | public: | 42 | public: |
43 | ConfigDialog( const Opie::Core::OPcmciaSocket* card, QWidget* parent ); | 43 | ConfigDialog( const Opie::Core::OPcmciaSocket* card, QWidget* parent ); |
44 | ~ConfigDialog(); | 44 | ~ConfigDialog(); |
45 | static QString preferredAction( const Opie::Core::OPcmciaSocket* card, const QString& type ); | 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 ); | 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 ); | 47 | static void writeConfigEntry( const Opie::Core::OPcmciaSocket* card, const QString& key, const QString& value ); |
48 | static Opie::Core::OConfig* cardConfig( const Opie::Core::OPcmciaSocket* card ); | ||
49 | void writeConfiguration( const Opie::Core::OPcmciaSocket* card ); | ||
48 | StringMap bindEntries; | 50 | StringMap bindEntries; |
49 | }; | 51 | }; |
50 | 52 | ||
51 | #endif | 53 | #endif |
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp index c6386cb..187adc6 100644 --- a/noncore/applets/pcmcia/pcmcia.cpp +++ b/noncore/applets/pcmcia/pcmcia.cpp | |||
@@ -26,12 +26,13 @@ | |||
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "pcmcia.h" | 30 | #include "pcmcia.h" |
31 | #include "configdialog.h" | 31 | #include "configdialog.h" |
32 | #include "promptactiondialog.h" | ||
32 | 33 | ||
33 | /* OPIE */ | 34 | /* OPIE */ |
34 | #include <opie2/odebug.h> | 35 | #include <opie2/odebug.h> |
35 | #include <opie2/odevice.h> | 36 | #include <opie2/odevice.h> |
36 | #include <opie2/oconfig.h> | 37 | #include <opie2/oconfig.h> |
37 | #include <opie2/oprocess.h> | 38 | #include <opie2/oprocess.h> |
@@ -135,14 +136,14 @@ void PcmciaManager::popUp( QString message, QString icon ) | |||
135 | 136 | ||
136 | void PcmciaManager::popupTimeout() | 137 | void PcmciaManager::popupTimeout() |
137 | { | 138 | { |
138 | popupMenu->hide(); | 139 | popupMenu->hide(); |
139 | } | 140 | } |
140 | 141 | ||
141 | enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE }; | 142 | enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE, ACTIVATE }; |
142 | static const char* actionText[] = { "eject", "insert", "suspend", "resum", "resett", "configur" }; | 143 | static const char* actionText[] = { "eject", "insert", "suspend", "resum", "resett", "configur", "activat" }; |
143 | 144 | ||
144 | void PcmciaManager::mousePressEvent( QMouseEvent* ) | 145 | void PcmciaManager::mousePressEvent( QMouseEvent* ) |
145 | { | 146 | { |
146 | QPopupMenu* menu = new QPopupMenu( this ); | 147 | QPopupMenu* menu = new QPopupMenu( this ); |
147 | QStringList cmd; | 148 | QStringList cmd; |
148 | bool execute = true; | 149 | bool execute = true; |
@@ -243,52 +244,13 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | |||
243 | tr( "PCMCIA/CF Subsystem" ), | 244 | tr( "PCMCIA/CF Subsystem" ), |
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 ), | 245 | 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 ), |
245 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ); | 246 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ); |
246 | odebug << "pcmcia: result = " << result << oendl; | 247 | odebug << "pcmcia: result = " << result << oendl; |
247 | if ( result == 0 ) | 248 | if ( result == 0 ) |
248 | { | 249 | { |
249 | QString insertAction; QString resumeAction; QString driver; QString conf; | 250 | configure( theCard ); |
250 | bool configured = configure( theCard, insertAction, resumeAction, driver, conf ); | ||
251 | |||
252 | if ( configured ) | ||
253 | { | ||
254 | odebug << "pcmcia: card has been configured. writing out to database" << oendl; | ||
255 | cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); | ||
256 | cfg.writeEntry( "name", newCardName ); | ||
257 | cfg.writeEntry( "insertAction", insertAction ); | ||
258 | cfg.writeEntry( "resumeAction", resumeAction ); | ||
259 | cfg.setGroup( "Global" ); | ||
260 | cfg.writeEntry( "nCards", nCards+1 ); | ||
261 | cfg.write(); | ||
262 | |||
263 | QFile confFile( conf ); | ||
264 | if ( confFile.open( IO_ReadWrite | IO_Append ) ) | ||
265 | { | ||
266 | QString entryCard = QString( "card \"%1\"" ).arg( newCardName ); | ||
267 | QString entryVersion( " version " ); | ||
268 | for ( QStringList::Iterator it = theCard->productIdentityVector().begin(); it != theCard->productIdentityVector().end(); ++it ) | ||
269 | { | ||
270 | entryVersion += QString( "\"%1\", " ).arg( *it ); | ||
271 | } | ||
272 | QString entryBind = QString( " bind %1" ).arg( driver ); | ||
273 | QString entry = QString( "\n%1\n%2\n%3\n" ).arg( entryCard ).arg( entryVersion ).arg( entryBind ); | ||
274 | odebug << "pcmcia: writing entry...:" << entry << oendl; | ||
275 | |||
276 | confFile.writeBlock( (const char*) entry, entry.length() ); | ||
277 | Global::statusMessage( "restarting pcmcia services..." ); | ||
278 | ::system( "/etc/init.d/pcmcia restart" ); | ||
279 | } | ||
280 | else | ||
281 | { | ||
282 | owarn << "pcmcia: couldn't write binding to '" << conf << "' ( " << strerror( errno ) << " )." << oendl; | ||
283 | } | ||
284 | } | ||
285 | else | ||
286 | { | ||
287 | odebug << "pcmcia: card has not been configured this time. leaving as unknown card" << oendl; | ||
288 | } | ||
289 | } | 251 | } |
290 | else | 252 | else |
291 | { | 253 | { |
292 | odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl; | 254 | odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl; |
293 | } | 255 | } |
294 | } | 256 | } |
@@ -323,68 +285,80 @@ void PcmciaManager::userCardAction( int action ) | |||
323 | 285 | ||
324 | switch ( what ) | 286 | switch ( what ) |
325 | { | 287 | { |
326 | case CONFIGURE: | 288 | case CONFIGURE: |
327 | { | 289 | { |
328 | QString insertAction; QString resumeAction; QString driver; QString conf; | 290 | QString insertAction; QString resumeAction; QString driver; QString conf; |
329 | configure( OPcmciaSystem::instance()->socket( socket ), insertAction, resumeAction, driver, conf ); | 291 | configure( OPcmciaSystem::instance()->socket( socket ) ); |
330 | return; | 292 | return; |
331 | } | 293 | } |
332 | case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); | 294 | case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); |
333 | break; | 295 | break; |
334 | case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); | 296 | case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); |
335 | break; | 297 | break; |
336 | case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); | 298 | case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); |
337 | break; | 299 | break; |
338 | case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); | 300 | case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); |
339 | break; | 301 | break; |
340 | case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); | 302 | case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); |
341 | break; | 303 | break; |
304 | case ACTIVATE: success = true; | ||
305 | break; | ||
342 | default: odebug << "pcmcia: not yet implemented" << oendl; | 306 | default: odebug << "pcmcia: not yet implemented" << oendl; |
343 | } | 307 | } |
344 | 308 | ||
345 | if ( success ) | 309 | if ( success ) |
346 | { | 310 | { |
311 | odebug << tr( "Successfully %1ed card in socket #%2" ).arg( actionText[action] ).arg( socket ) << oendl; | ||
347 | popUp( tr( "Successfully %1ed card in socket #%2" ).arg( actionText[action] ).arg( socket ) ); | 312 | popUp( tr( "Successfully %1ed card in socket #%2" ).arg( actionText[action] ).arg( socket ) ); |
348 | } | 313 | } |
349 | else | 314 | else |
350 | { | 315 | { |
316 | odebug << tr( "Error while %1ing card in socket #%2" ).arg( actionText[action] ).arg( socket ) << oendl; | ||
351 | popUp( tr( "Error while %1ing card in socket #%2" ).arg( actionText[action] ).arg( socket ) ); | 317 | popUp( tr( "Error while %1ing card in socket #%2" ).arg( actionText[action] ).arg( socket ) ); |
352 | } | 318 | } |
353 | } | 319 | } |
354 | 320 | ||
355 | bool PcmciaManager::configure( OPcmciaSocket* card, QString& insertAction, QString& resumeAction, QString& driver, QString& conf ) | 321 | void PcmciaManager::configure( OPcmciaSocket* card ) |
356 | { | 322 | { |
357 | configuring = true; | 323 | configuring = true; |
358 | ConfigDialog dialog( card, qApp->desktop() ); | 324 | ConfigDialog dialog( card, qApp->desktop() ); |
359 | int configresult = QPEApplication::execDialog( &dialog, false ); | 325 | int result = QPEApplication::execDialog( &dialog, false ); |
360 | configuring = false; | 326 | configuring = false; |
361 | odebug << "pcmcia: configresult = " << configresult << oendl; | 327 | odebug << "pcmcia: configresult = " << result << oendl; |
362 | if ( configresult ) | 328 | if ( result ) |
363 | { | 329 | { |
364 | insertAction = dialog.cbInsertAction->currentText(); | 330 | dialog.writeConfiguration( card ); |
365 | resumeAction = dialog.cbResumeAction->currentText(); | ||
366 | driver = dialog.cbBindTo->currentText(); | ||
367 | conf = dialog.bindEntries[driver]; | ||
368 | } | 331 | } |
369 | return configresult; | ||
370 | } | 332 | } |
371 | 333 | ||
372 | void PcmciaManager::executeAction( Opie::Core::OPcmciaSocket* card, const QString& type ) | 334 | void PcmciaManager::executeAction( Opie::Core::OPcmciaSocket* card, const QString& type ) |
373 | { | 335 | { |
374 | odebug << "pcmcia: performing " << type << " action ..." << oendl; | 336 | odebug << "pcmcia: performing " << type << " action ..." << oendl; |
375 | QString theAction = ConfigDialog::preferredAction( card, type ); | 337 | QString theAction = ConfigDialog::preferredAction( card, type ); |
376 | int intAction = card->number() * 100; | 338 | int intAction = card->number() * 100; |
377 | if ( theAction == "activate" ) ; | 339 | |
378 | else if ( theAction == "eject" ) intAction += EJECT; | 340 | if ( theAction == "prompt for" ) |
379 | else if ( theAction == "suspend" ) intAction += SUSPEND; | ||
380 | else if ( theAction == "prompt for" ) | ||
381 | { | 341 | { |
382 | odebug << "pcmcia: sorry, not 'prompt for' is not yet implemented!" << oendl; | 342 | PromptActionDialog dialog( qApp->desktop(), "promptfor", true ); |
343 | dialog.setCaption( QString( "Choose action for card #%1" ).arg( card->number() ) ); | ||
344 | int result = QPEApplication::execDialog( &dialog, true ); | ||
345 | odebug << "pcmcia: configresult = " << result << oendl; | ||
346 | if ( result ) | ||
347 | { | ||
348 | theAction = dialog.cbAction->currentText(); | ||
349 | } | ||
350 | else | ||
351 | { | ||
352 | odebug << "pcmcia: prompted to do nothing" << oendl; | ||
383 | return; | 353 | return; |
384 | } | 354 | } |
355 | } | ||
356 | if ( theAction == "activate" ) intAction += ACTIVATE; | ||
357 | else if ( theAction == "eject" ) intAction += EJECT; | ||
358 | else if ( theAction == "suspend" ) intAction += SUSPEND; | ||
385 | else | 359 | else |
386 | { | 360 | { |
387 | owarn << "pcmcia: action '" << theAction << "' not known. Huh?" << oendl; | 361 | owarn << "pcmcia: action '" << theAction << "' not known. Huh?" << oendl; |
388 | return; | 362 | return; |
389 | } | 363 | } |
390 | userCardAction( intAction ); | 364 | userCardAction( intAction ); |
diff --git a/noncore/applets/pcmcia/pcmcia.h b/noncore/applets/pcmcia/pcmcia.h index de7d6bf..0fe936c 100644 --- a/noncore/applets/pcmcia/pcmcia.h +++ b/noncore/applets/pcmcia/pcmcia.h | |||
@@ -52,13 +52,13 @@ class PcmciaManager : public QWidget | |||
52 | 52 | ||
53 | protected: | 53 | protected: |
54 | void paintEvent( QPaintEvent* ); | 54 | void paintEvent( QPaintEvent* ); |
55 | void mousePressEvent( QMouseEvent * ); | 55 | void mousePressEvent( QMouseEvent * ); |
56 | 56 | ||
57 | private: | 57 | private: |
58 | bool configure( Opie::Core::OPcmciaSocket*, QString&, QString&, QString&, QString& ); | 58 | void configure( Opie::Core::OPcmciaSocket* ); |
59 | void execCommand( const QStringList &command ); | 59 | void execCommand( const QStringList &command ); |
60 | void executeAction( Opie::Core::OPcmciaSocket*, const QString& ); | 60 | void executeAction( Opie::Core::OPcmciaSocket*, const QString& ); |
61 | void popUp( QString message, QString icon = QString::null ); | 61 | void popUp( QString message, QString icon = QString::null ); |
62 | 62 | ||
63 | private: | 63 | private: |
64 | bool configuring; | 64 | bool configuring; |
diff --git a/noncore/applets/pcmcia/pcmcia.pro b/noncore/applets/pcmcia/pcmcia.pro index 4a893b5..b9af380 100644 --- a/noncore/applets/pcmcia/pcmcia.pro +++ b/noncore/applets/pcmcia/pcmcia.pro | |||
@@ -1,18 +1,20 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt plugin warn_on | 2 | CONFIG += qt plugin warn_on |
3 | 3 | ||
4 | INTERFACES = configdialogbase.ui | 4 | INTERFACES = configdialogbase.ui \ |
5 | promptactiondialog.ui | ||
5 | HEADERS = pcmcia.h \ | 6 | HEADERS = pcmcia.h \ |
6 | configdialog.h | 7 | configdialog.h |
7 | SOURCES = pcmcia.cpp \ | 8 | SOURCES = pcmcia.cpp \ |
8 | configdialog.cpp | 9 | configdialog.cpp |
9 | TARGET = pcmciaapplet | 10 | TARGET = pcmciaapplet |
10 | 11 | ||
11 | DESTDIR = $(OPIEDIR)/plugins/applets | 12 | DESTDIR = $(OPIEDIR)/plugins/applets |
13 | |||
12 | INCLUDEPATH += $(OPIEDIR)/include | 14 | INCLUDEPATH += $(OPIEDIR)/include |
13 | DEPENDPATH += $(OPIEDIR)/include | 15 | DEPENDPATH += $(OPIEDIR)/include |
14 | 16 | ||
15 | LIBS += -lqpe -lopiecore2 | 17 | LIBS += -lqpe -lopiecore2 |
16 | VERSION = 0.2.0 | 18 | VERSION = 0.9.0 |
17 | 19 | ||
18 | include( $(OPIEDIR)/include.pro ) | 20 | include( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/applets/pcmcia/promptactiondialog.ui b/noncore/applets/pcmcia/promptactiondialog.ui new file mode 100644 index 0000000..c351b48 --- a/dev/null +++ b/noncore/applets/pcmcia/promptactiondialog.ui | |||
@@ -0,0 +1,58 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>PromptActionDialog</class> | ||
3 | <widget> | ||
4 | <class>QDialog</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>PromptActionDialog</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>273</width> | ||
15 | <height>55</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Choose Action for Card</string> | ||
21 | </property> | ||
22 | <grid> | ||
23 | <property stdset="1"> | ||
24 | <name>margin</name> | ||
25 | <number>11</number> | ||
26 | </property> | ||
27 | <property stdset="1"> | ||
28 | <name>spacing</name> | ||
29 | <number>6</number> | ||
30 | </property> | ||
31 | <widget row="0" column="0" > | ||
32 | <class>QComboBox</class> | ||
33 | <item> | ||
34 | <property> | ||
35 | <name>text</name> | ||
36 | <string>activate</string> | ||
37 | </property> | ||
38 | </item> | ||
39 | <item> | ||
40 | <property> | ||
41 | <name>text</name> | ||
42 | <string>suspend</string> | ||
43 | </property> | ||
44 | </item> | ||
45 | <item> | ||
46 | <property> | ||
47 | <name>text</name> | ||
48 | <string>eject</string> | ||
49 | </property> | ||
50 | </item> | ||
51 | <property stdset="1"> | ||
52 | <name>name</name> | ||
53 | <cstring>cbAction</cstring> | ||
54 | </property> | ||
55 | </widget> | ||
56 | </grid> | ||
57 | </widget> | ||
58 | </UI> | ||