summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-06-21 14:11:55 (UTC)
committer mickeyl <mickeyl>2005-06-21 14:11:55 (UTC)
commitae85d18a1f8a63323ad47631724516f3aa355a75 (patch) (unidiff)
tree9238ab79beabca8f035714f3e339513c06685d2a
parent65ea54f43ee7dcbd95ffb474c8dfbb8b076d43e5 (diff)
downloadopie-ae85d18a1f8a63323ad47631724516f3aa355a75.zip
opie-ae85d18a1f8a63323ad47631724516f3aa355a75.tar.gz
opie-ae85d18a1f8a63323ad47631724516f3aa355a75.tar.bz2
- prepare methods to execute the preferred actions on insertion and suspend
- intercept QPE/System channel to listen for 'resumeFromSuspend()'
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp35
-rw-r--r--noncore/applets/pcmcia/pcmcia.h5
2 files changed, 39 insertions, 1 deletions
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp
index 186dfea..0787c3c 100644
--- a/noncore/applets/pcmcia/pcmcia.cpp
+++ b/noncore/applets/pcmcia/pcmcia.cpp
@@ -1,349 +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>
44using namespace Opie::Core; 44using namespace Opie::Core;
45using namespace Opie::Ui; 45using 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
69PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) 69PcmciaManager::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( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon );
80 configuring = false; 80 configuring = false;
81
82 QCopChannel *channel = new QCopChannel( "QPE/System", this );
83 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
84 this, SLOT(handleSystemChannel(const QCString&,const QByteArray&)) );
81} 85}
82 86
83 87
84PcmciaManager::~PcmciaManager() 88PcmciaManager::~PcmciaManager()
85{ 89{
86} 90}
87 91
92void PcmciaManager::handleSystemChannel( const QCString&msg, const QByteArray& )
93{
94 if ( msg == "returnFromSuspend()" )
95 {
96 if ( !OPcmciaSystem::instance()->cardCount() ) return;
97 OPcmciaSystem* sys = OPcmciaSystem::instance();
98 OPcmciaSystem::CardIterator it = sys->iterator();
99 OPcmciaSocket* theCard = 0;
100
101 while ( it.current() )
102 {
103 if ( it.current()->isEmpty() )
104 {
105 executeResumeAction( theCard );
106 }
107 ++it;
108 }
109 }
110}
88 111
89void PcmciaManager::popUp( QString message, QString icon ) 112void PcmciaManager::popUp( QString message, QString icon )
90{ 113{
91 if ( !popupMenu ) { 114 if ( !popupMenu ) {
92 popupMenu = new QPopupMenu( this ); 115 popupMenu = new QPopupMenu( this );
93 } 116 }
94 117
95 popupMenu->clear(); 118 popupMenu->clear();
96 if ( icon.isEmpty() ) { 119 if ( icon.isEmpty() ) {
97 popupMenu->insertItem( message, 0 ); 120 popupMenu->insertItem( message, 0 );
98 } else { 121 } else {
99 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 ) ),
100 message, 0 ); 123 message, 0 );
101 } 124 }
102 125
103 QPoint p = mapToGlobal( QPoint( 0, 0 ) ); 126 QPoint p = mapToGlobal( QPoint( 0, 0 ) );
104 QSize s = popupMenu->sizeHint(); 127 QSize s = popupMenu->sizeHint();
105 popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), 128 popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ),
106 p.y() - s.height() ), 0 ); 129 p.y() - s.height() ), 0 );
107 130
108 QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); 131 QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) );
109} 132}
110 133
111 134
112void PcmciaManager::popupTimeout() 135void PcmciaManager::popupTimeout()
113{ 136{
114 popupMenu->hide(); 137 popupMenu->hide();
115} 138}
116 139
117enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE }; 140enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE };
118 141
119void PcmciaManager::mousePressEvent( QMouseEvent* ) 142void PcmciaManager::mousePressEvent( QMouseEvent* )
120{ 143{
121 QPopupMenu* menu = new QPopupMenu( this ); 144 QPopupMenu* menu = new QPopupMenu( this );
122 QStringList cmd; 145 QStringList cmd;
123 bool execute = true; 146 bool execute = true;
124 147
125 OPcmciaSystem* sys = OPcmciaSystem::instance(); 148 OPcmciaSystem* sys = OPcmciaSystem::instance();
126 OPcmciaSystem::CardIterator it = sys->iterator(); 149 OPcmciaSystem::CardIterator it = sys->iterator();
127 if ( !sys->count() ) return; 150 if ( !sys->count() ) return;
128 151
129 int i = 0; 152 int i = 0;
130 while ( it.current() ) 153 while ( it.current() )
131 { 154 {
132 QPopupMenu* submenu = new QPopupMenu( menu ); 155 QPopupMenu* submenu = new QPopupMenu( menu );
133 submenu->insertItem( "&Eject", EJECT+i*100 ); 156 submenu->insertItem( "&Eject", EJECT+i*100 );
134 submenu->insertItem( "&Insert", INSERT+i*100 ); 157 submenu->insertItem( "&Insert", INSERT+i*100 );
135 submenu->insertItem( "&Suspend", SUSPEND+i*100 ); 158 submenu->insertItem( "&Suspend", SUSPEND+i*100 );
136 submenu->insertItem( "&Resume", RESUME+i*100 ); 159 submenu->insertItem( "&Resume", RESUME+i*100 );
137 submenu->insertItem( "Rese&t", RESET+i*100 ); 160 submenu->insertItem( "Rese&t", RESET+i*100 );
138 submenu->insertItem( "&Configure", CONFIGURE+i*100 ); 161 submenu->insertItem( "&Configure", CONFIGURE+i*100 );
139 162
140 submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); 163 submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() );
141 submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); 164 submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() );
142 submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); 165 submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && it.current()->isSuspended() );
143 submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); 166 submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() );
144 submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() && !configuring ); 167 submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() && !configuring );
145 168
146 connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); 169 connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) );
147 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 );
148 ++it; 171 ++it;
149 } 172 }
150 173
151 QPoint p = mapToGlobal( QPoint( 0, 0 ) ); 174 QPoint p = mapToGlobal( QPoint( 0, 0 ) );
152 QSize s = menu->sizeHint(); 175 QSize s = menu->sizeHint();
153 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 );
154 qDebug( "pcmcia: menu result = %d", opt ); 177 qDebug( "pcmcia: menu result = %d", opt );
155 delete menu; 178 delete menu;
156} 179}
157 180
158 181
159void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) 182void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
160{ 183{
161 odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl; 184 odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl;
162 if ( msg != "stabChanged()" ) return; 185 if ( msg != "stabChanged()" ) return;
163 186
164 /* check if a previously unknown card has been inserted */ 187 /* check if a previously unknown card has been inserted */
165 OPcmciaSystem::instance()->synchronize(); 188 OPcmciaSystem::instance()->synchronize();
166 189
167 if ( !OPcmciaSystem::instance()->cardCount() ) return; 190 if ( !OPcmciaSystem::instance()->cardCount() ) return;
168 191
169 OConfig cfg( "PCMCIA" ); 192 OConfig cfg( "PCMCIA" );
170 cfg.setGroup( "Global" ); 193 cfg.setGroup( "Global" );
171 int nCards = cfg.readNumEntry( "nCards", 0 ); 194 int nCards = cfg.readNumEntry( "nCards", 0 );
172 195
173 OPcmciaSystem* sys = OPcmciaSystem::instance(); 196 OPcmciaSystem* sys = OPcmciaSystem::instance();
174 OPcmciaSystem::CardIterator it = sys->iterator(); 197 OPcmciaSystem::CardIterator it = sys->iterator();
175 198
176 bool newCard = true; 199 bool newCard = true;
177 OPcmciaSocket* theCard = 0; 200 OPcmciaSocket* theCard = 0;
178 201
179 while ( it.current() && newCard ) 202 while ( it.current() && newCard )
180 { 203 {
181 if ( it.current()->isEmpty() ) 204 if ( it.current()->isEmpty() )
182 { 205 {
183 odebug << "pcmcia: skipping empty card in socket " << it.current()->number() << oendl; 206 odebug << "pcmcia: skipping empty card in socket " << it.current()->number() << oendl;
184 ++it; 207 ++it;
185 continue; 208 continue;
186 } 209 }
187 else 210 else
188 { 211 {
189 theCard = it.current(); 212 theCard = it.current();
190 QString cardName = theCard->productIdentity().join( " " ); 213 QString cardName = theCard->productIdentity().join( " " );
191 for ( int i = 0; i < nCards; ++i ) 214 for ( int i = 0; i < nCards; ++i )
192 { 215 {
193 QString cardSection = QString( "Card_%1" ).arg( i ); 216 QString cardSection = QString( "Card_%1" ).arg( i );
194 cfg.setGroup( cardSection ); 217 cfg.setGroup( cardSection );
195 QString name = cfg.readEntry( "name" ); 218 QString name = cfg.readEntry( "name" );
196 odebug << "pcmcia: comparing card '" << cardName << "' with known card '" << name << "'" << oendl; 219 odebug << "pcmcia: comparing card '" << cardName << "' with known card '" << name << "'" << oendl;
197 if ( cardName == name ) 220 if ( cardName == name )
198 { 221 {
199 newCard = false; 222 newCard = false;
223 odebug << "pcmcia: we have seen this card before" << oendl;
224 executeInsertAction( theCard );
200 break; 225 break;
201 } 226 }
202 } 227 }
203 if ( !newCard ) ++it; else break; 228 if ( !newCard ) ++it; else break;
204 } 229 }
205 } 230 }
206 if ( newCard ) 231 if ( newCard )
207 { 232 {
208 odebug << "pcmcia: unconfigured card detected" << oendl; 233 odebug << "pcmcia: unconfigured card detected" << oendl;
209 QString newCardName = theCard->productIdentity().join( " " ).stripWhiteSpace(); 234 QString newCardName = theCard->productIdentity().join( " " ).stripWhiteSpace();
210 int result = QMessageBox::information( qApp->desktop(), 235 int result = QMessageBox::information( qApp->desktop(),
211 tr( "PCMCIA/CF Subsystem" ), 236 tr( "PCMCIA/CF Subsystem" ),
212 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 ),
213 tr( "Yes" ), tr( "No" ), 0, 0, 1 ); 238 tr( "Yes" ), tr( "No" ), 0, 0, 1 );
214 odebug << "pcmcia: result = " << result << oendl; 239 odebug << "pcmcia: result = " << result << oendl;
215 if ( result == 0 ) 240 if ( result == 0 )
216 { 241 {
217 QString insertAction; QString resumeAction; QString driver; QString conf; 242 QString insertAction; QString resumeAction; QString driver; QString conf;
218 bool configured = configure( theCard, insertAction, resumeAction, driver, conf ); 243 bool configured = configure( theCard, insertAction, resumeAction, driver, conf );
219 244
220 if ( configured ) 245 if ( configured )
221 { 246 {
222 odebug << "pcmcia: card has been configured. writing out to database" << oendl; 247 odebug << "pcmcia: card has been configured. writing out to database" << oendl;
223 cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); 248 cfg.setGroup( QString( "Card_%1" ).arg( nCards ) );
224 cfg.writeEntry( "name", newCardName ); 249 cfg.writeEntry( "name", newCardName );
225 cfg.writeEntry( "insertAction", insertAction ); 250 cfg.writeEntry( "insertAction", insertAction );
226 cfg.writeEntry( "resumeAction", resumeAction ); 251 cfg.writeEntry( "resumeAction", resumeAction );
227 cfg.setGroup( "Global" ); 252 cfg.setGroup( "Global" );
228 cfg.writeEntry( "nCards", nCards+1 ); 253 cfg.writeEntry( "nCards", nCards+1 );
229 cfg.write(); 254 cfg.write();
230 255
231 QFile confFile( QString( "/etc/pcmcia/%1" ).arg( conf ) ); 256 QFile confFile( QString( "/etc/pcmcia/%1" ).arg( conf ) );
232 if ( confFile.open( IO_ReadWrite | IO_Append ) ) 257 if ( confFile.open( IO_ReadWrite | IO_Append ) )
233 { 258 {
234 QString entryCard = QString( "card \"%1\"" ).arg( newCardName ); 259 QString entryCard = QString( "card \"%1\"" ).arg( newCardName );
235 QString entryVersion( " version " ); 260 QString entryVersion( " version " );
236 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 )
237 { 262 {
238 entryVersion += QString( "\"%1\", " ).arg( *it ); 263 entryVersion += QString( "\"%1\", " ).arg( *it );
239 } 264 }
240 QString entryBind = QString( " bind %1" ).arg( driver ); 265 QString entryBind = QString( " bind %1" ).arg( driver );
241 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 );
242 odebug << "pcmcia: writing entry...:" << entry << oendl; 267 odebug << "pcmcia: writing entry...:" << entry << oendl;
243 268
244 confFile.writeBlock( (const char*) entry, entry.length() ); 269 confFile.writeBlock( (const char*) entry, entry.length() );
245 Global::statusMessage( "restarting pcmcia services..." ); 270 Global::statusMessage( "restarting pcmcia services..." );
246 ::system( "/etc/init.d/pcmcia restart" ); 271 ::system( "/etc/init.d/pcmcia restart" );
247 } 272 }
248 else 273 else
249 { 274 {
250 owarn << "pcmcia: couldn't write binding to '" << conf << "'." << oendl; 275 owarn << "pcmcia: couldn't write binding to '" << conf << "'." << oendl;
251 } 276 }
252 } 277 }
253 else 278 else
254 { 279 {
255 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;
256 } 281 }
257 } 282 }
258 else 283 else
259 { 284 {
260 odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl; 285 odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl;
261 } 286 }
262 } 287 }
263 else // it's an already configured card 288 else // it's an already configured card
264 { 289 {
265 QString insertAction = ConfigDialog::preferredAction( theCard, "insert" ); 290 QString insertAction = ConfigDialog::preferredAction( theCard, "insert" );
266 odebug << "pcmcia: card has been previously configured" << oendl; 291 odebug << "pcmcia: card has been previously configured" << oendl;
267 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;
268 } 293 }
269 repaint( true ); 294 repaint( true );
270} 295}
271 296
272 297
273void PcmciaManager::paintEvent( QPaintEvent * ) 298void PcmciaManager::paintEvent( QPaintEvent * )
274{ 299{
275 QPainter p( this ); 300 QPainter p( this );
276 odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl; 301 odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl;
277 302
278 if ( OPcmciaSystem::instance()->cardCount() ) 303 if ( OPcmciaSystem::instance()->cardCount() )
279 { 304 {
280 p.drawPixmap( 0, 0, pm ); 305 p.drawPixmap( 0, 0, pm );
281 show(); 306 show();
282 } 307 }
283 else 308 else
284 { 309 {
285 hide(); 310 hide();
286 } 311 }
287} 312}
288 313
289int PcmciaManager::position() 314int PcmciaManager::position()
290{ 315{
291 return 7; 316 return 7;
292} 317}
293 318
294void PcmciaManager::execCommand( const QStringList &strList ) 319void PcmciaManager::execCommand( const QStringList &strList )
295{ 320{
296} 321}
297 322
298void PcmciaManager::userCardAction( int action ) 323void PcmciaManager::userCardAction( int action )
299{ 324{
300 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;
301 326
302 int socket = action / 100; 327 int socket = action / 100;
303 int what = action % 100; 328 int what = action % 100;
304 bool success = false; 329 bool success = false;
305 330
306 switch ( what ) 331 switch ( what )
307 { 332 {
308 case CONFIGURE: 333 case CONFIGURE:
309 { 334 {
310 QString insertAction; QString resumeAction; QString driver; QString conf; 335 QString insertAction; QString resumeAction; QString driver; QString conf;
311 bool result = configure( OPcmciaSystem::instance()->socket( socket ), insertAction, resumeAction, driver, conf ); 336 bool result = configure( OPcmciaSystem::instance()->socket( socket ), insertAction, resumeAction, driver, conf );
312 success = true; 337 success = true;
313 break; 338 break;
314 } 339 }
315 case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break; 340 case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break;
316 case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break; 341 case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break;
317 case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break; 342 case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break;
318 case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break; 343 case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break;
319 case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break; 344 case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break;
320 default: odebug << "pcmcia: not yet implemented" << oendl; 345 default: odebug << "pcmcia: not yet implemented" << oendl;
321 } 346 }
322 347
323 if ( !success ) 348 if ( !success )
324 { 349 {
325 owarn << "pcmcia: couldn't perform user action (" << strerror( errno ) << ")" << oendl; 350 owarn << "pcmcia: couldn't perform user action (" << strerror( errno ) << ")" << oendl;
326 } 351 }
327 352
328} 353}
329 354
330bool PcmciaManager::configure( OPcmciaSocket* card, QString& insertAction, QString& resumeAction, QString& driver, QString& conf ) 355bool PcmciaManager::configure( OPcmciaSocket* card, QString& insertAction, QString& resumeAction, QString& driver, QString& conf )
331{ 356{
332 configuring = true; 357 configuring = true;
333 ConfigDialog dialog( card, qApp->desktop() ); 358 ConfigDialog dialog( card, qApp->desktop() );
334 int configresult = QPEApplication::execDialog( &dialog, false ); 359 int configresult = QPEApplication::execDialog( &dialog, false );
335 configuring = false; 360 configuring = false;
336 odebug << "pcmcia: configresult = " << configresult << oendl; 361 odebug << "pcmcia: configresult = " << configresult << oendl;
337 if ( configresult ) 362 if ( configresult )
338 { 363 {
339 insertAction = dialog.cbInsertAction->currentText(); 364 insertAction = dialog.cbInsertAction->currentText();
340 resumeAction = dialog.cbResumeAction->currentText(); 365 resumeAction = dialog.cbResumeAction->currentText();
341 driver = dialog.cbBindTo->currentText(); 366 driver = dialog.cbBindTo->currentText();
342 conf = dialog.bindEntries[driver]; 367 conf = dialog.bindEntries[driver];
343 } 368 }
344 return configresult; 369 return configresult;
345} 370}
346 371
372void PcmciaManager::executeInsertAction( Opie::Core::OPcmciaSocket* card )
373{
374 odebug << "pcmcia: execute insert action" << oendl;
375}
376
377void PcmciaManager::executeResumeAction( Opie::Core::OPcmciaSocket* card )
378{
379 odebug << "pcmcia: execute resume action" << oendl;
380}
381
347 382
348EXPORT_OPIE_APPLET_v1( PcmciaManager ) 383EXPORT_OPIE_APPLET_v1( PcmciaManager )
349 384
diff --git a/noncore/applets/pcmcia/pcmcia.h b/noncore/applets/pcmcia/pcmcia.h
index 94203d3..6567cd7 100644
--- a/noncore/applets/pcmcia/pcmcia.h
+++ b/noncore/applets/pcmcia/pcmcia.h
@@ -1,70 +1,73 @@
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#ifndef PCMCIA_H 30#ifndef PCMCIA_H
31#define PCMCIA_H 31#define PCMCIA_H
32 32
33#include <qwidget.h> 33#include <qwidget.h>
34#include <qpixmap.h> 34#include <qpixmap.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36 36
37namespace Opie { namespace Core { class OPcmciaSocket; } }; 37namespace Opie { namespace Core { class OPcmciaSocket; } };
38 38
39class PcmciaManager : public QWidget 39class PcmciaManager : public QWidget
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42 public: 42 public:
43 PcmciaManager( QWidget *parent = 0 ); 43 PcmciaManager( QWidget *parent = 0 );
44 ~PcmciaManager(); 44 ~PcmciaManager();
45 static int position(); 45 static int position();
46 46
47 private slots: 47 private slots:
48 void cardMessage( const QCString& msg, const QByteArray& ); 48 void handleSystemChannel( const QCString&, const QByteArray& );
49 void cardMessage( const QCString&, const QByteArray& );
49 void userCardAction( int action ); 50 void userCardAction( int action );
50 void popupTimeout(); 51 void popupTimeout();
51 52
52 protected: 53 protected:
53 void paintEvent( QPaintEvent* ); 54 void paintEvent( QPaintEvent* );
54 void mousePressEvent( QMouseEvent * ); 55 void mousePressEvent( QMouseEvent * );
55 56
56 private: 57 private:
57 bool configure( Opie::Core::OPcmciaSocket*, QString&, QString&, QString&, QString& ); 58 bool configure( Opie::Core::OPcmciaSocket*, QString&, QString&, QString&, QString& );
58 void execCommand( const QStringList &command ); 59 void execCommand( const QStringList &command );
60 void executeInsertAction( Opie::Core::OPcmciaSocket* );
61 void executeResumeAction( Opie::Core::OPcmciaSocket* );
59 void popUp(QString message, QString icon = QString::null ); 62 void popUp(QString message, QString icon = QString::null );
60 63
61 private: 64 private:
62 bool configuring; 65 bool configuring;
63 int commandOrig; 66 int commandOrig;
64 QPixmap pm; 67 QPixmap pm;
65 QPopupMenu *popupMenu; 68 QPopupMenu *popupMenu;
66 69
67}; 70};
68 71
69#endif 72#endif
70 73