summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/pcmcia/configdialog.cpp52
-rw-r--r--noncore/applets/pcmcia/configdialog.h2
-rw-r--r--noncore/applets/pcmcia/configdialogbase.ui217
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp40
-rw-r--r--noncore/applets/pcmcia/pcmcia.h2
5 files changed, 186 insertions, 127 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp
index 9fcf58c..f961069 100644
--- a/noncore/applets/pcmcia/configdialog.cpp
+++ b/noncore/applets/pcmcia/configdialog.cpp
@@ -46,39 +46,25 @@ using namespace Opie::Core;
46ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) 46ConfigDialog::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 '%1'" ).arg( card->identity() ) ); 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 OConfig cfg( "PCMCIA" ); 54 QString action = preferredAction( card );
55 cfg.setGroup( "Global" );
56 int nCards = cfg.readNumEntry( "nCards", 0 );
57 QString insert;
58 55
59 for ( int i = 0; i < nCards; ++i ) 56 odebug << "preferred action for card '" << card->name() << "' seems to be '" << action << "'" << oendl;
60 {
61 QString cardSection = QString( "Card_%1" ).arg( i );
62 cfg.setGroup( cardSection );
63 QString name = cfg.readEntry( "name" );
64 odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl;
65 if ( card->name() == name )
66 {
67 insert = cfg.readEntry( "insert" );
68 break;
69 }
70 }
71 odebug << "preferred action for card '" << card->name() << "' seems to be '" << insert << "'" << oendl;
72 57
73 if ( !insert.isEmpty() ) 58 if ( !action.isEmpty() )
74 { 59 {
75 for ( int i; i < cbAction->count(); ++i ) 60 for ( int i; i < cbAction->count(); ++i )
76 if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i ); 61 if ( cbAction->text( i ) == action ) cbAction->setCurrentItem( i );
77 } 62 }
78 63
79 if ( !card->isUnsupported() ) 64 if ( !card->isUnsupported() )
80 { 65 {
81 odebug << "card is recognized - hiding bindings" << oendl; 66 odebug << "card is recognized - hiding bindings" << oendl;
67 textInfo->hide();
82 textBindTo->hide(); 68 textBindTo->hide();
83 cbBindTo->hide(); 69 cbBindTo->hide();
84 return; 70 return;
@@ -86,6 +72,7 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
86 else 72 else
87 { 73 {
88 odebug << "card is unsupported yet - showing possible bindings" << oendl; 74 odebug << "card is unsupported yet - showing possible bindings" << oendl;
75 textInfo->show();
89 textBindTo->show(); 76 textBindTo->show();
90 cbBindTo->show(); 77 cbBindTo->show();
91 } 78 }
@@ -96,7 +83,7 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
96 83
97 QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); 84 QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" );
98 85
99 for ( int i = 0; i < pcmciaconfdir.count(); ++i ) 86 for ( unsigned int i = 0; i < pcmciaconfdir.count(); ++i )
100 { 87 {
101 odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; 88 odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl;
102 QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); 89 QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] );
@@ -134,3 +121,26 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
134ConfigDialog::~ConfigDialog() 121ConfigDialog::~ConfigDialog()
135{ 122{
136} 123}
124
125QString ConfigDialog::preferredAction( const OPcmciaSocket* card )
126{
127 OConfig cfg( "PCMCIA" );
128 cfg.setGroup( "Global" );
129 int nCards = cfg.readNumEntry( "nCards", 0 );
130 QString action;
131
132 for ( int i = 0; i < nCards; ++i )
133 {
134 QString cardSection = QString( "Card_%1" ).arg( i );
135 cfg.setGroup( cardSection );
136 QString name = cfg.readEntry( "name" );
137 odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl;
138 if ( card->name() == name )
139 {
140 action = cfg.readEntry( "action" );
141 break;
142 }
143 }
144
145 return action;
146}
diff --git a/noncore/applets/pcmcia/configdialog.h b/noncore/applets/pcmcia/configdialog.h
index 3c7fe85..321180d 100644
--- a/noncore/applets/pcmcia/configdialog.h
+++ b/noncore/applets/pcmcia/configdialog.h
@@ -38,9 +38,9 @@ class ConfigDialog : public ConfigDialogBase
38{ 38{
39 Q_OBJECT 39 Q_OBJECT
40 public: 40 public:
41
42 ConfigDialog( const Opie::Core::OPcmciaSocket* card, QWidget* parent ); 41 ConfigDialog( const Opie::Core::OPcmciaSocket* card, QWidget* parent );
43 ~ConfigDialog(); 42 ~ConfigDialog();
43 static QString preferredAction( const Opie::Core::OPcmciaSocket* card );
44}; 44};
45 45
46#endif 46#endif
diff --git a/noncore/applets/pcmcia/configdialogbase.ui b/noncore/applets/pcmcia/configdialogbase.ui
index 7ec3a75..829b71a 100644
--- a/noncore/applets/pcmcia/configdialogbase.ui
+++ b/noncore/applets/pcmcia/configdialogbase.ui
@@ -11,8 +11,8 @@
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>197</width> 14 <width>215</width>
15 <height>154</height> 15 <height>329</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
@@ -34,92 +34,6 @@
34 <name>spacing</name> 34 <name>spacing</name>
35 <number>2</number> 35 <number>2</number>
36 </property> 36 </property>
37 <widget row="2" column="2" >
38 <class>QLabel</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>TextLabel3</cstring>
42 </property>
43 <property stdset="1">
44 <name>text</name>
45 <string>card</string>
46 </property>
47 </widget>
48 <widget row="2" column="0" >
49 <class>QLabel</class>
50 <property stdset="1">
51 <name>name</name>
52 <cstring>TextLabel2</cstring>
53 </property>
54 <property stdset="1">
55 <name>text</name>
56 <string>On insertion,</string>
57 </property>
58 </widget>
59 <widget row="2" column="1" >
60 <class>QComboBox</class>
61 <item>
62 <property>
63 <name>text</name>
64 <string>suspend</string>
65 </property>
66 </item>
67 <item>
68 <property>
69 <name>text</name>
70 <string>activate</string>
71 </property>
72 </item>
73 <item>
74 <property>
75 <name>text</name>
76 <string>eject</string>
77 </property>
78 </item>
79 <item>
80 <property>
81 <name>text</name>
82 <string>prompt for</string>
83 </property>
84 </item>
85 <property stdset="1">
86 <name>name</name>
87 <cstring>cbAction</cstring>
88 </property>
89 </widget>
90 <widget row="3" column="1" rowspan="1" colspan="2" >
91 <class>QComboBox</class>
92 <property stdset="1">
93 <name>name</name>
94 <cstring>cbBindTo</cstring>
95 </property>
96 <property stdset="1">
97 <name>sizePolicy</name>
98 <sizepolicy>
99 <hsizetype>5</hsizetype>
100 <vsizetype>0</vsizetype>
101 </sizepolicy>
102 </property>
103 <property stdset="1">
104 <name>editable</name>
105 <bool>true</bool>
106 </property>
107 <property stdset="1">
108 <name>autoResize</name>
109 <bool>false</bool>
110 </property>
111 </widget>
112 <widget row="3" column="0" >
113 <class>QLabel</class>
114 <property stdset="1">
115 <name>name</name>
116 <cstring>textBindTo</cstring>
117 </property>
118 <property stdset="1">
119 <name>text</name>
120 <string>Bind to:</string>
121 </property>
122 </widget>
123 <widget row="0" column="0" rowspan="1" colspan="3" > 37 <widget row="0" column="0" rowspan="1" colspan="3" >
124 <class>QGroupBox</class> 38 <class>QGroupBox</class>
125 <property stdset="1"> 39 <property stdset="1">
@@ -234,10 +148,133 @@
234 </widget> 148 </widget>
235 </grid> 149 </grid>
236 </widget> 150 </widget>
237 <spacer row="1" column="1" > 151 <widget row="1" 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>
206 <property stdset="1">
207 <name>name</name>
208 <cstring>textBindTo</cstring>
209 </property>
210 <property stdset="1">
211 <name>text</name>
212 <string>Bind to:</string>
213 </property>
214 </widget>
215 <widget row="4" column="1" rowspan="1" colspan="2" >
216 <class>QComboBox</class>
217 <item>
218 <property>
219 <name>text</name>
220 <string>&lt;None&gt;</string>
221 </property>
222 </item>
223 <property stdset="1">
224 <name>name</name>
225 <cstring>cbBindTo</cstring>
226 </property>
227 <property stdset="1">
228 <name>sizePolicy</name>
229 <sizepolicy>
230 <hsizetype>5</hsizetype>
231 <vsizetype>0</vsizetype>
232 </sizepolicy>
233 </property>
234 <property stdset="1">
235 <name>editable</name>
236 <bool>true</bool>
237 </property>
238 <property stdset="1">
239 <name>currentItem</name>
240 <number>0</number>
241 </property>
242 <property stdset="1">
243 <name>autoResize</name>
244 <bool>false</bool>
245 </property>
246 </widget>
247 <widget row="3" column="0" rowspan="1" colspan="3" >
248 <class>QLabel</class>
249 <property stdset="1">
250 <name>name</name>
251 <cstring>textInfo</cstring>
252 </property>
253 <property stdset="1">
254 <name>frameShape</name>
255 <enum>Box</enum>
256 </property>
257 <property stdset="1">
258 <name>frameShadow</name>
259 <enum>Raised</enum>
260 </property>
261 <property stdset="1">
262 <name>lineWidth</name>
263 <number>2</number>
264 </property>
265 <property stdset="1">
266 <name>margin</name>
267 <number>0</number>
268 </property>
269 <property stdset="1">
270 <name>text</name>
271 <string>&lt;qt&gt;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:&lt;/qt&gt;</string>
272 </property>
273 </widget>
274 <spacer row="2" column="1" >
238 <property> 275 <property>
239 <name>name</name> 276 <name>name</name>
240 <cstring>Spacer1</cstring> 277 <cstring>Spacer2</cstring>
241 </property> 278 </property>
242 <property stdset="1"> 279 <property stdset="1">
243 <name>orientation</name> 280 <name>orientation</name>
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
@@ -203,31 +203,42 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
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}
@@ -284,13 +295,14 @@ void PcmciaManager::userCardAction( int action )
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
diff --git a/noncore/applets/pcmcia/pcmcia.h b/noncore/applets/pcmcia/pcmcia.h
index a453c1b..eb9c513 100644
--- a/noncore/applets/pcmcia/pcmcia.h
+++ b/noncore/applets/pcmcia/pcmcia.h
@@ -54,7 +54,7 @@ class PcmciaManager : public QWidget
54 void mousePressEvent( QMouseEvent * ); 54 void mousePressEvent( QMouseEvent * );
55 55
56 private: 56 private:
57 void configure( Opie::Core::OPcmciaSocket* ); 57 bool configure( Opie::Core::OPcmciaSocket* );
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