Diffstat (limited to 'noncore/applets/pcmcia/pcmcia.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp index aea699f..99c1bc9 100644 --- a/noncore/applets/pcmcia/pcmcia.cpp +++ b/noncore/applets/pcmcia/pcmcia.cpp | |||
@@ -48,24 +48,25 @@ using namespace Opie::Ui; | |||
48 | #include <qpainter.h> | 48 | #include <qpainter.h> |
49 | #include <qfile.h> | 49 | #include <qfile.h> |
50 | #include <qtextstream.h> | 50 | #include <qtextstream.h> |
51 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
52 | #include <qsound.h> | 52 | #include <qsound.h> |
53 | #include <qtimer.h> | 53 | #include <qtimer.h> |
54 | 54 | ||
55 | /* STD */ | 55 | /* STD */ |
56 | #include <stdio.h> | 56 | #include <stdio.h> |
57 | #include <unistd.h> | 57 | #include <unistd.h> |
58 | #include <stdlib.h> | 58 | #include <stdlib.h> |
59 | #include <string.h> | 59 | #include <string.h> |
60 | #include <errno.h> | ||
60 | #include <fcntl.h> | 61 | #include <fcntl.h> |
61 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 62 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
62 | #include <sys/vfs.h> | 63 | #include <sys/vfs.h> |
63 | #include <mntent.h> | 64 | #include <mntent.h> |
64 | #endif | 65 | #endif |
65 | 66 | ||
66 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) | 67 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) |
67 | { | 68 | { |
68 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 69 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
69 | connect( pcmciaChannel, | 70 | connect( pcmciaChannel, |
70 | SIGNAL( received(const QCString&,const QByteArray&) ), this, | 71 | SIGNAL( received(const QCString&,const QByteArray&) ), this, |
71 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); | 72 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); |
@@ -127,26 +128,26 @@ void PcmciaManager::mousePressEvent( QMouseEvent* ) | |||
127 | while ( it.current() ) | 128 | while ( it.current() ) |
128 | { | 129 | { |
129 | QPopupMenu* submenu = new QPopupMenu( menu ); | 130 | QPopupMenu* submenu = new QPopupMenu( menu ); |
130 | submenu->insertItem( "&Eject", EJECT+i*100 ); | 131 | submenu->insertItem( "&Eject", EJECT+i*100 ); |
131 | submenu->insertItem( "&Insert", INSERT+i*100 ); | 132 | submenu->insertItem( "&Insert", INSERT+i*100 ); |
132 | submenu->insertItem( "&Suspend", SUSPEND+i*100 ); | 133 | submenu->insertItem( "&Suspend", SUSPEND+i*100 ); |
133 | submenu->insertItem( "&Resume", RESUME+i*100 ); | 134 | submenu->insertItem( "&Resume", RESUME+i*100 ); |
134 | submenu->insertItem( "Rese&t", RESET+i*100 ); | 135 | submenu->insertItem( "Rese&t", RESET+i*100 ); |
135 | submenu->insertItem( "&Configure", CONFIGURE+i*100 ); | 136 | submenu->insertItem( "&Configure", CONFIGURE+i*100 ); |
136 | 137 | ||
137 | submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); | 138 | submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); |
138 | submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); | 139 | submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); |
139 | submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); | 140 | submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); |
140 | submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); | 141 | submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); |
141 | submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() && !configuring ); | 142 | submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() && !configuring ); |
142 | 143 | ||
143 | connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); | 144 | connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); |
144 | menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); | 145 | menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); |
145 | ++it; | 146 | ++it; |
146 | } | 147 | } |
147 | 148 | ||
148 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 149 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
149 | QSize s = menu->sizeHint(); | 150 | QSize s = menu->sizeHint(); |
150 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); | 151 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); |
151 | qDebug( "pcmcia: menu result = %d", opt ); | 152 | qDebug( "pcmcia: menu result = %d", opt ); |
152 | delete menu; | 153 | delete menu; |
@@ -250,44 +251,44 @@ void PcmciaManager::paintEvent( QPaintEvent * ) | |||
250 | 251 | ||
251 | int PcmciaManager::position() | 252 | int PcmciaManager::position() |
252 | { | 253 | { |
253 | return 7; | 254 | return 7; |
254 | } | 255 | } |
255 | 256 | ||
256 | void PcmciaManager::execCommand( const QStringList &strList ) | 257 | void PcmciaManager::execCommand( const QStringList &strList ) |
257 | { | 258 | { |
258 | } | 259 | } |
259 | 260 | ||
260 | void PcmciaManager::userCardAction( int action ) | 261 | void PcmciaManager::userCardAction( int action ) |
261 | { | 262 | { |
262 | odebug << "user action requested. action = " << action << oendl; | 263 | odebug << "user action on socket " << action / 100 << " requested. action = " << action << oendl; |
263 | 264 | ||
264 | int socket = action / 100; | 265 | int socket = action / 100; |
265 | int what = action % 100; | 266 | int what = action % 100; |
266 | bool success = false; | 267 | bool success = false; |
267 | 268 | ||
268 | switch ( what ) | 269 | switch ( what ) |
269 | { | 270 | { |
270 | case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); success = true; break; | 271 | case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); success = true; break; |
271 | case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break; | 272 | case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break; |
272 | case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break; | 273 | case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break; |
273 | case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break; | 274 | case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break; |
274 | case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break; | 275 | case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break; |
275 | case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break; | 276 | case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break; |
276 | default: odebug << "not yet implemented" << oendl; | 277 | default: odebug << "not yet implemented" << oendl; |
277 | } | 278 | } |
278 | 279 | ||
279 | if ( !success ) | 280 | if ( !success ) |
280 | { | 281 | { |
281 | owarn << "couldn't perform user action" << oendl; | 282 | owarn << "couldn't perform user action (" << strerror( errno ) << ")" << oendl; |
282 | } | 283 | } |
283 | 284 | ||
284 | } | 285 | } |
285 | 286 | ||
286 | void PcmciaManager::configure( OPcmciaSocket* card ) | 287 | void PcmciaManager::configure( OPcmciaSocket* card ) |
287 | { | 288 | { |
288 | configuring = true; | 289 | configuring = true; |
289 | ConfigDialog dialog( card, qApp->desktop() ); | 290 | ConfigDialog dialog( card, qApp->desktop() ); |
290 | int configresult = QPEApplication::execDialog( &dialog, false ); | 291 | int configresult = QPEApplication::execDialog( &dialog, false ); |
291 | configuring = false; | 292 | configuring = false; |
292 | odebug << "pcmcia: configresult = " << configresult << oendl; | 293 | odebug << "pcmcia: configresult = " << configresult << oendl; |
293 | } | 294 | } |