-rw-r--r-- | noncore/applets/pcmcia/pcmcia.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp index 0787c3c..e435f61 100644 --- a/noncore/applets/pcmcia/pcmcia.cpp +++ b/noncore/applets/pcmcia/pcmcia.cpp | |||
@@ -1,384 +1,384 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | .=l. | 4 | .=l. |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
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 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
35 | #include <opie2/odevice.h> | 35 | #include <opie2/odevice.h> |
36 | #include <opie2/oconfig.h> | 36 | #include <opie2/oconfig.h> |
37 | #include <opie2/oprocess.h> | 37 | #include <opie2/oprocess.h> |
38 | #include <opie2/opcmciasystem.h> | 38 | #include <opie2/opcmciasystem.h> |
39 | #include <opie2/oresource.h> | 39 | #include <opie2/oresource.h> |
40 | #include <opie2/otaskbarapplet.h> | 40 | #include <opie2/otaskbarapplet.h> |
41 | #include <qpe/applnk.h> | 41 | #include <qpe/applnk.h> |
42 | #include <qpe/global.h> | 42 | #include <qpe/global.h> |
43 | #include <qpe/resource.h> | 43 | #include <qpe/resource.h> |
44 | using namespace Opie::Core; | 44 | using namespace Opie::Core; |
45 | using namespace Opie::Ui; | 45 | using namespace Opie::Ui; |
46 | 46 | ||
47 | /* QT */ | 47 | /* QT */ |
48 | #include <qcombobox.h> | 48 | #include <qcombobox.h> |
49 | #include <qcopchannel_qws.h> | 49 | #include <qcopchannel_qws.h> |
50 | #include <qpainter.h> | 50 | #include <qpainter.h> |
51 | #include <qfile.h> | 51 | #include <qfile.h> |
52 | #include <qtextstream.h> | 52 | #include <qtextstream.h> |
53 | #include <qmessagebox.h> | 53 | #include <qmessagebox.h> |
54 | #include <qsound.h> | 54 | #include <qsound.h> |
55 | #include <qtimer.h> | 55 | #include <qtimer.h> |
56 | 56 | ||
57 | /* STD */ | 57 | /* STD */ |
58 | #include <stdio.h> | 58 | #include <stdio.h> |
59 | #include <unistd.h> | 59 | #include <unistd.h> |
60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
61 | #include <string.h> | 61 | #include <string.h> |
62 | #include <errno.h> | 62 | #include <errno.h> |
63 | #include <fcntl.h> | 63 | #include <fcntl.h> |
64 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 64 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
65 | #include <sys/vfs.h> | 65 | #include <sys/vfs.h> |
66 | #include <mntent.h> | 66 | #include <mntent.h> |
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) | 69 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) |
70 | { | 70 | { |
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( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ); | 79 | pm = Opie::Core::OResource::loadPixmap( "pcmcia/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 | ||
88 | PcmciaManager::~PcmciaManager() | 88 | PcmciaManager::~PcmciaManager() |
89 | { | 89 | { |
90 | } | 90 | } |
91 | 91 | ||
92 | void PcmciaManager::handleSystemChannel( const QCString&msg, const QByteArray& ) | 92 | void PcmciaManager::handleSystemChannel( const QCString&msg, const QByteArray& ) |
93 | { | 93 | { |
94 | if ( msg == "returnFromSuspend()" ) | 94 | if ( msg == "returnFromSuspend()" ) |
95 | { | 95 | { |
96 | if ( !OPcmciaSystem::instance()->cardCount() ) return; | 96 | if ( !OPcmciaSystem::instance()->cardCount() ) return; |
97 | OPcmciaSystem* sys = OPcmciaSystem::instance(); | 97 | OPcmciaSystem* sys = OPcmciaSystem::instance(); |
98 | OPcmciaSystem::CardIterator it = sys->iterator(); | 98 | OPcmciaSystem::CardIterator it = sys->iterator(); |
99 | OPcmciaSocket* theCard = 0; | 99 | OPcmciaSocket* theCard = 0; |
100 | 100 | ||
101 | while ( it.current() ) | 101 | while ( it.current() ) |
102 | { | 102 | { |
103 | if ( it.current()->isEmpty() ) | 103 | if ( it.current()->isEmpty() ) |
104 | { | 104 | { |
105 | executeResumeAction( theCard ); | 105 | executeResumeAction( theCard ); |
106 | } | 106 | } |
107 | ++it; | 107 | ++it; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
112 | void PcmciaManager::popUp( QString message, QString icon ) | 112 | void PcmciaManager::popUp( QString message, QString icon ) |
113 | { | 113 | { |
114 | if ( !popupMenu ) { | 114 | if ( !popupMenu ) { |
115 | popupMenu = new QPopupMenu( this ); | 115 | popupMenu = new QPopupMenu( this ); |
116 | } | 116 | } |
117 | 117 | ||
118 | popupMenu->clear(); | 118 | popupMenu->clear(); |
119 | if ( icon.isEmpty() ) { | 119 | if ( icon.isEmpty() ) { |
120 | popupMenu->insertItem( message, 0 ); | 120 | popupMenu->insertItem( message, 0 ); |
121 | } else { | 121 | } else { |
122 | popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ), | 122 | popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ), |
123 | message, 0 ); | 123 | message, 0 ); |
124 | } | 124 | } |
125 | 125 | ||
126 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 126 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
127 | QSize s = popupMenu->sizeHint(); | 127 | QSize s = popupMenu->sizeHint(); |
128 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), | 128 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), |
129 | p.y() - s.height() ), 0 ); | 129 | p.y() - s.height() ), 0 ); |
130 | 130 | ||
131 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); | 131 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); |
132 | } | 132 | } |
133 | 133 | ||
134 | 134 | ||
135 | void PcmciaManager::popupTimeout() | 135 | void PcmciaManager::popupTimeout() |
136 | { | 136 | { |
137 | popupMenu->hide(); | 137 | popupMenu->hide(); |
138 | } | 138 | } |
139 | 139 | ||
140 | enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE }; | 140 | enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE }; |
141 | 141 | ||
142 | void PcmciaManager::mousePressEvent( QMouseEvent* ) | 142 | void PcmciaManager::mousePressEvent( QMouseEvent* ) |
143 | { | 143 | { |
144 | QPopupMenu* menu = new QPopupMenu( this ); | 144 | QPopupMenu* menu = new QPopupMenu( this ); |
145 | QStringList cmd; | 145 | QStringList cmd; |
146 | bool execute = true; | 146 | bool execute = true; |
147 | 147 | ||
148 | OPcmciaSystem* sys = OPcmciaSystem::instance(); | 148 | OPcmciaSystem* sys = OPcmciaSystem::instance(); |
149 | OPcmciaSystem::CardIterator it = sys->iterator(); | 149 | OPcmciaSystem::CardIterator it = sys->iterator(); |
150 | if ( !sys->count() ) return; | 150 | if ( !sys->count() ) return; |
151 | 151 | ||
152 | int i = 0; | 152 | int i = 0; |
153 | while ( it.current() ) | 153 | while ( it.current() ) |
154 | { | 154 | { |
155 | QPopupMenu* submenu = new QPopupMenu( menu ); | 155 | QPopupMenu* submenu = new QPopupMenu( menu ); |
156 | submenu->insertItem( "&Eject", EJECT+i*100 ); | 156 | submenu->insertItem( "&Eject", EJECT+i*100 ); |
157 | submenu->insertItem( "&Insert", INSERT+i*100 ); | 157 | submenu->insertItem( "&Insert", INSERT+i*100 ); |
158 | submenu->insertItem( "&Suspend", SUSPEND+i*100 ); | 158 | submenu->insertItem( "&Suspend", SUSPEND+i*100 ); |
159 | submenu->insertItem( "&Resume", RESUME+i*100 ); | 159 | submenu->insertItem( "&Resume", RESUME+i*100 ); |
160 | submenu->insertItem( "Rese&t", RESET+i*100 ); | 160 | submenu->insertItem( "Rese&t", RESET+i*100 ); |
161 | submenu->insertItem( "&Configure", CONFIGURE+i*100 ); | 161 | submenu->insertItem( "&Configure", CONFIGURE+i*100 ); |
162 | 162 | ||
163 | submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); | 163 | submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); |
164 | submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); | 164 | submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); |
165 | submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); | 165 | submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); |
166 | submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); | 166 | submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); |
167 | submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() && !configuring ); | 167 | submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() && !configuring ); |
168 | 168 | ||
169 | connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); | 169 | connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); |
170 | menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); | 170 | menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); |
171 | ++it; | 171 | ++it; |
172 | } | 172 | } |
173 | 173 | ||
174 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 174 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
175 | QSize s = menu->sizeHint(); | 175 | QSize s = menu->sizeHint(); |
176 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); | 176 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); |
177 | qDebug( "pcmcia: menu result = %d", opt ); | 177 | qDebug( "pcmcia: menu result = %d", opt ); |
178 | delete menu; | 178 | delete menu; |
179 | } | 179 | } |
180 | 180 | ||
181 | 181 | ||
182 | void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | 182 | void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) |
183 | { | 183 | { |
184 | odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl; | 184 | odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl; |
185 | if ( msg != "stabChanged()" ) return; | 185 | if ( msg != "stabChanged()" ) return; |
186 | 186 | ||
187 | /* check if a previously unknown card has been inserted */ | 187 | /* check if a previously unknown card has been inserted */ |
188 | OPcmciaSystem::instance()->synchronize(); | 188 | OPcmciaSystem::instance()->synchronize(); |
189 | 189 | ||
190 | if ( !OPcmciaSystem::instance()->cardCount() ) return; | 190 | if ( !OPcmciaSystem::instance()->cardCount() ) return; |
191 | 191 | ||
192 | OConfig cfg( "PCMCIA" ); | 192 | OConfig cfg( "PCMCIA" ); |
193 | cfg.setGroup( "Global" ); | 193 | cfg.setGroup( "Global" ); |
194 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 194 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
195 | 195 | ||
196 | OPcmciaSystem* sys = OPcmciaSystem::instance(); | 196 | OPcmciaSystem* sys = OPcmciaSystem::instance(); |
197 | OPcmciaSystem::CardIterator it = sys->iterator(); | 197 | OPcmciaSystem::CardIterator it = sys->iterator(); |
198 | 198 | ||
199 | bool newCard = true; | 199 | bool newCard = true; |
200 | OPcmciaSocket* theCard = 0; | 200 | OPcmciaSocket* theCard = 0; |
201 | 201 | ||
202 | while ( it.current() && newCard ) | 202 | while ( it.current() && newCard ) |
203 | { | 203 | { |
204 | if ( it.current()->isEmpty() ) | 204 | if ( it.current()->isEmpty() ) |
205 | { | 205 | { |
206 | odebug << "pcmcia: skipping empty card in socket " << it.current()->number() << oendl; | 206 | odebug << "pcmcia: skipping empty card in socket " << it.current()->number() << oendl; |
207 | ++it; | 207 | ++it; |
208 | continue; | 208 | continue; |
209 | } | 209 | } |
210 | else | 210 | else |
211 | { | 211 | { |
212 | theCard = it.current(); | 212 | theCard = it.current(); |
213 | QString cardName = theCard->productIdentity().join( " " ); | 213 | QString cardName = theCard->productIdentity().join( " " ); |
214 | for ( int i = 0; i < nCards; ++i ) | 214 | for ( int i = 0; i < nCards; ++i ) |
215 | { | 215 | { |
216 | QString cardSection = QString( "Card_%1" ).arg( i ); | 216 | QString cardSection = QString( "Card_%1" ).arg( i ); |
217 | cfg.setGroup( cardSection ); | 217 | cfg.setGroup( cardSection ); |
218 | QString name = cfg.readEntry( "name" ); | 218 | QString name = cfg.readEntry( "name" ); |
219 | odebug << "pcmcia: comparing card '" << cardName << "' with known card '" << name << "'" << oendl; | 219 | odebug << "pcmcia: comparing card '" << cardName << "' with known card '" << name << "'" << oendl; |
220 | if ( cardName == name ) | 220 | if ( cardName == name ) |
221 | { | 221 | { |
222 | newCard = false; | 222 | newCard = false; |
223 | odebug << "pcmcia: we have seen this card before" << oendl; | 223 | odebug << "pcmcia: we have seen this card before" << oendl; |
224 | executeInsertAction( theCard ); | 224 | executeInsertAction( theCard ); |
225 | break; | 225 | break; |
226 | } | 226 | } |
227 | } | 227 | } |
228 | if ( !newCard ) ++it; else break; | 228 | if ( !newCard ) ++it; else break; |
229 | } | 229 | } |
230 | } | 230 | } |
231 | if ( newCard ) | 231 | if ( newCard ) |
232 | { | 232 | { |
233 | odebug << "pcmcia: unconfigured card detected" << oendl; | 233 | odebug << "pcmcia: unconfigured card detected" << oendl; |
234 | QString newCardName = theCard->productIdentity().join( " " ).stripWhiteSpace(); | 234 | QString newCardName = theCard->productIdentity().join( " " ).stripWhiteSpace(); |
235 | int result = QMessageBox::information( qApp->desktop(), | 235 | int result = QMessageBox::information( qApp->desktop(), |
236 | tr( "PCMCIA/CF Subsystem" ), | 236 | tr( "PCMCIA/CF Subsystem" ), |
237 | 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 ), | 237 | 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 ), |
238 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ); | 238 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ); |
239 | odebug << "pcmcia: result = " << result << oendl; | 239 | odebug << "pcmcia: result = " << result << oendl; |
240 | if ( result == 0 ) | 240 | if ( result == 0 ) |
241 | { | 241 | { |
242 | QString insertAction; QString resumeAction; QString driver; QString conf; | 242 | QString insertAction; QString resumeAction; QString driver; QString conf; |
243 | bool configured = configure( theCard, insertAction, resumeAction, driver, conf ); | 243 | bool configured = configure( theCard, insertAction, resumeAction, driver, conf ); |
244 | 244 | ||
245 | if ( configured ) | 245 | if ( configured ) |
246 | { | 246 | { |
247 | odebug << "pcmcia: card has been configured. writing out to database" << oendl; | 247 | odebug << "pcmcia: card has been configured. writing out to database" << oendl; |
248 | cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); | 248 | cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); |
249 | cfg.writeEntry( "name", newCardName ); | 249 | cfg.writeEntry( "name", newCardName ); |
250 | cfg.writeEntry( "insertAction", insertAction ); | 250 | cfg.writeEntry( "insertAction", insertAction ); |
251 | cfg.writeEntry( "resumeAction", resumeAction ); | 251 | cfg.writeEntry( "resumeAction", resumeAction ); |
252 | cfg.setGroup( "Global" ); | 252 | cfg.setGroup( "Global" ); |
253 | cfg.writeEntry( "nCards", nCards+1 ); | 253 | cfg.writeEntry( "nCards", nCards+1 ); |
254 | cfg.write(); | 254 | cfg.write(); |
255 | 255 | ||
256 | QFile confFile( QString( "/etc/pcmcia/%1" ).arg( conf ) ); | 256 | QFile confFile( QString( "/etc/pcmcia/%1" ).arg( conf ) ); |
257 | if ( confFile.open( IO_ReadWrite | IO_Append ) ) | 257 | if ( confFile.open( IO_ReadWrite | IO_Append ) ) |
258 | { | 258 | { |
259 | QString entryCard = QString( "card \"%1\"" ).arg( newCardName ); | 259 | QString entryCard = QString( "card \"%1\"" ).arg( newCardName ); |
260 | QString entryVersion( " version " ); | 260 | QString entryVersion( " version " ); |
261 | for ( QStringList::Iterator it = theCard->productIdentity().begin(); it != theCard->productIdentity().end(); ++it ) | 261 | for ( QStringList::Iterator it = theCard->productIdentity().begin(); it != theCard->productIdentity().end(); ++it ) |
262 | { | 262 | { |
263 | entryVersion += QString( "\"%1\", " ).arg( *it ); | 263 | entryVersion += QString( "\"%1\", " ).arg( *it ); |
264 | } | 264 | } |
265 | QString entryBind = QString( " bind %1" ).arg( driver ); | 265 | QString entryBind = QString( " bind %1" ).arg( driver ); |
266 | QString entry = QString( "\n%1\n%2\n%3\n" ).arg( entryCard ).arg( entryVersion ).arg( entryBind ); | 266 | QString entry = QString( "\n%1\n%2\n%3\n" ).arg( entryCard ).arg( entryVersion ).arg( entryBind ); |
267 | odebug << "pcmcia: writing entry...:" << entry << oendl; | 267 | odebug << "pcmcia: writing entry...:" << entry << oendl; |
268 | 268 | ||
269 | confFile.writeBlock( (const char*) entry, entry.length() ); | 269 | confFile.writeBlock( (const char*) entry, entry.length() ); |
270 | Global::statusMessage( "restarting pcmcia services..." ); | 270 | Global::statusMessage( "restarting pcmcia services..." ); |
271 | ::system( "/etc/init.d/pcmcia restart" ); | 271 | ::system( "/etc/init.d/pcmcia restart" ); |
272 | } | 272 | } |
273 | else | 273 | else |
274 | { | 274 | { |
275 | owarn << "pcmcia: couldn't write binding to '" << conf << "'." << oendl; | 275 | owarn << "pcmcia: couldn't write binding to '" << conf << "'." << oendl; |
276 | } | 276 | } |
277 | } | 277 | } |
278 | else | 278 | else |
279 | { | 279 | { |
280 | odebug << "pcmcia: card has not been configured this time. leaving as unknown card" << oendl; | 280 | odebug << "pcmcia: card has not been configured this time. leaving as unknown card" << oendl; |
281 | } | 281 | } |
282 | } | 282 | } |
283 | else | 283 | else |
284 | { | 284 | { |
285 | odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl; | 285 | odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl; |
286 | } | 286 | } |
287 | } | 287 | } |
288 | else // it's an already configured card | 288 | else // it's an already configured card |
289 | { | 289 | { |
290 | QString insertAction = ConfigDialog::preferredAction( theCard, "insert" ); | 290 | QString insertAction = ConfigDialog::preferredAction( theCard, "insert" ); |
291 | odebug << "pcmcia: card has been previously configured" << oendl; | 291 | odebug << "pcmcia: card has been previously configured" << oendl; |
292 | odebug << "pcmcia: TODO: need to perform action'" << insertAction << "' now... sorry, not yet implemented..." << oendl; | 292 | odebug << "pcmcia: TODO: need to perform action'" << insertAction << "' now... sorry, not yet implemented..." << oendl; |
293 | } | 293 | } |
294 | repaint( true ); | 294 | repaint( true ); |
295 | } | 295 | } |
296 | 296 | ||
297 | 297 | ||
298 | void PcmciaManager::paintEvent( QPaintEvent * ) | 298 | void PcmciaManager::paintEvent( QPaintEvent * ) |
299 | { | 299 | { |
300 | QPainter p( this ); | 300 | QPainter p( this ); |
301 | odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl; | 301 | odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl; |
302 | 302 | ||
303 | if ( OPcmciaSystem::instance()->cardCount() ) | 303 | if ( OPcmciaSystem::instance()->cardCount() ) |
304 | { | 304 | { |
305 | p.drawPixmap( 0, 0, pm ); | 305 | p.drawPixmap( 0, 0, pm ); |
306 | show(); | 306 | show(); |
307 | } | 307 | } |
308 | else | 308 | else |
309 | { | 309 | { |
310 | hide(); | 310 | hide(); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | 313 | ||
314 | int PcmciaManager::position() | 314 | int PcmciaManager::position() |
315 | { | 315 | { |
316 | return 7; | 316 | return 7; |
317 | } | 317 | } |
318 | 318 | ||
319 | void PcmciaManager::execCommand( const QStringList &strList ) | 319 | void PcmciaManager::execCommand( const QStringList &strList ) |
320 | { | 320 | { |
321 | } | 321 | } |
322 | 322 | ||
323 | void PcmciaManager::userCardAction( int action ) | 323 | void PcmciaManager::userCardAction( int action ) |
324 | { | 324 | { |
325 | odebug << "pcmcia: user action on socket " << action / 100 << " requested. action = " << action << oendl; | 325 | odebug << "pcmcia: user action on socket " << action / 100 << " requested. action = " << action << oendl; |
326 | 326 | ||
327 | int socket = action / 100; | 327 | int socket = action / 100; |
328 | int what = action % 100; | 328 | int what = action % 100; |
329 | bool success = false; | 329 | bool success = false; |
330 | 330 | ||
331 | switch ( what ) | 331 | switch ( what ) |
332 | { | 332 | { |
333 | case CONFIGURE: | 333 | case CONFIGURE: |
334 | { | 334 | { |
335 | QString insertAction; QString resumeAction; QString driver; QString conf; | 335 | QString insertAction; QString resumeAction; QString driver; QString conf; |
336 | bool result = configure( OPcmciaSystem::instance()->socket( socket ), insertAction, resumeAction, driver, conf ); | 336 | bool result = configure( OPcmciaSystem::instance()->socket( socket ), insertAction, resumeAction, driver, conf ); |
337 | success = true; | 337 | success = true; |
338 | break; | 338 | break; |
339 | } | 339 | } |
340 | case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break; | 340 | case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break; |
341 | case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break; | 341 | case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break; |
342 | case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break; | 342 | case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break; |
343 | case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break; | 343 | case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break; |
344 | case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break; | 344 | case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break; |
345 | default: odebug << "pcmcia: not yet implemented" << oendl; | 345 | default: odebug << "pcmcia: not yet implemented" << oendl; |
346 | } | 346 | } |
347 | 347 | ||
348 | if ( !success ) | 348 | if ( !success ) |
349 | { | 349 | { |
350 | owarn << "pcmcia: couldn't perform user action (" << strerror( errno ) << ")" << oendl; | 350 | owarn << "pcmcia: couldn't perform user action (" << strerror( errno ) << ")" << oendl; |
351 | } | 351 | } |
352 | 352 | ||
353 | } | 353 | } |
354 | 354 | ||
355 | bool PcmciaManager::configure( OPcmciaSocket* card, QString& insertAction, QString& resumeAction, QString& driver, QString& conf ) | 355 | bool PcmciaManager::configure( OPcmciaSocket* card, QString& insertAction, QString& resumeAction, QString& driver, QString& conf ) |
356 | { | 356 | { |
357 | configuring = true; | 357 | configuring = true; |
358 | ConfigDialog dialog( card, qApp->desktop() ); | 358 | ConfigDialog dialog( card, qApp->desktop() ); |
359 | int configresult = QPEApplication::execDialog( &dialog, false ); | 359 | int configresult = QPEApplication::execDialog( &dialog, false ); |
360 | configuring = false; | 360 | configuring = false; |
361 | odebug << "pcmcia: configresult = " << configresult << oendl; | 361 | odebug << "pcmcia: configresult = " << configresult << oendl; |
362 | if ( configresult ) | 362 | if ( configresult ) |
363 | { | 363 | { |
364 | insertAction = dialog.cbInsertAction->currentText(); | 364 | insertAction = dialog.cbInsertAction->currentText(); |
365 | resumeAction = dialog.cbResumeAction->currentText(); | 365 | resumeAction = dialog.cbResumeAction->currentText(); |
366 | driver = dialog.cbBindTo->currentText(); | 366 | driver = dialog.cbBindTo->currentText(); |
367 | conf = dialog.bindEntries[driver]; | 367 | conf = dialog.bindEntries[driver]; |
368 | } | 368 | } |
369 | return configresult; | 369 | return configresult; |
370 | } | 370 | } |
371 | 371 | ||
372 | void PcmciaManager::executeInsertAction( Opie::Core::OPcmciaSocket* card ) | 372 | void PcmciaManager::executeInsertAction( Opie::Core::OPcmciaSocket* card ) |
373 | { | 373 | { |
374 | odebug << "pcmcia: execute insert action" << oendl; | 374 | odebug << "pcmcia: execute insert action" << oendl; |
375 | } | 375 | } |
376 | 376 | ||
377 | void PcmciaManager::executeResumeAction( Opie::Core::OPcmciaSocket* card ) | 377 | void PcmciaManager::executeResumeAction( Opie::Core::OPcmciaSocket* card ) |
378 | { | 378 | { |
379 | odebug << "pcmcia: execute resume action" << oendl; | 379 | odebug << "pcmcia: execute resume action" << oendl; |
380 | } | 380 | } |
381 | 381 | ||
382 | 382 | ||
383 | EXPORT_OPIE_APPLET_v1( PcmciaManager ) | 383 | EXPORT_OPIE_APPLET_v1( PcmciaManager ) |
384 | 384 | ||