-rw-r--r-- | libopie2/opiecore/linux/opcmciasystem.cpp | 12 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.cpp | 9 |
2 files changed, 11 insertions, 10 deletions
diff --git a/libopie2/opiecore/linux/opcmciasystem.cpp b/libopie2/opiecore/linux/opcmciasystem.cpp index 2eece6b..054d261 100644 --- a/libopie2/opiecore/linux/opcmciasystem.cpp +++ b/libopie2/opiecore/linux/opcmciasystem.cpp | |||
@@ -44,17 +44,17 @@ using namespace Opie::Core; | |||
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | #include <sys/ioctl.h> | 45 | #include <sys/ioctl.h> |
46 | #include <sys/types.h> | 46 | #include <sys/types.h> |
47 | #include <sys/stat.h> | 47 | #include <sys/stat.h> |
48 | #include <unistd.h> | 48 | #include <unistd.h> |
49 | 49 | ||
50 | #define PROC_DEVICES "/proc/devices" | 50 | #define PROC_DEVICES "/proc/devices" |
51 | 51 | ||
52 | #define OPCMCIA_DEBUG 1 | 52 | // #define OPCMCIA_DEBUG 1 |
53 | 53 | ||
54 | /*====================================================================================== | 54 | /*====================================================================================== |
55 | * OPcmciaSystem | 55 | * OPcmciaSystem |
56 | *======================================================================================*/ | 56 | *======================================================================================*/ |
57 | 57 | ||
58 | OPcmciaSystem* OPcmciaSystem::_instance = 0; | 58 | OPcmciaSystem* OPcmciaSystem::_instance = 0; |
59 | 59 | ||
60 | OPcmciaSystem::OPcmciaSystem() | 60 | OPcmciaSystem::OPcmciaSystem() |
@@ -300,41 +300,41 @@ bool OPcmciaSocket::isEmpty() const | |||
300 | bool OPcmciaSocket::isSuspended() const | 300 | bool OPcmciaSocket::isSuspended() const |
301 | { | 301 | { |
302 | return status() && Suspended; | 302 | return status() && Suspended; |
303 | } | 303 | } |
304 | 304 | ||
305 | 305 | ||
306 | bool OPcmciaSocket::eject() | 306 | bool OPcmciaSocket::eject() |
307 | { | 307 | { |
308 | return ::ioctl( _fd, DS_EJECT_CARD ); | 308 | return ::ioctl( _fd, DS_EJECT_CARD ) != -1; |
309 | } | 309 | } |
310 | 310 | ||
311 | 311 | ||
312 | bool OPcmciaSocket::insert() | 312 | bool OPcmciaSocket::insert() |
313 | { | 313 | { |
314 | return ::ioctl( _fd, DS_INSERT_CARD ); | 314 | return ::ioctl( _fd, DS_INSERT_CARD ) != -1; |
315 | } | 315 | } |
316 | 316 | ||
317 | 317 | ||
318 | bool OPcmciaSocket::suspend() | 318 | bool OPcmciaSocket::suspend() |
319 | { | 319 | { |
320 | return ::ioctl( _fd, DS_SUSPEND_CARD ); | 320 | return ::ioctl( _fd, DS_SUSPEND_CARD ) != -1; |
321 | } | 321 | } |
322 | 322 | ||
323 | 323 | ||
324 | bool OPcmciaSocket::resume() | 324 | bool OPcmciaSocket::resume() |
325 | { | 325 | { |
326 | return ::ioctl( _fd, DS_RESUME_CARD ); | 326 | return ::ioctl( _fd, DS_RESUME_CARD ) != -1; |
327 | } | 327 | } |
328 | 328 | ||
329 | 329 | ||
330 | bool OPcmciaSocket::reset() | 330 | bool OPcmciaSocket::reset() |
331 | { | 331 | { |
332 | return ::ioctl( _fd, DS_RESET_CARD ); | 332 | return ::ioctl( _fd, DS_RESET_CARD ) != -1; |
333 | } | 333 | } |
334 | 334 | ||
335 | 335 | ||
336 | QStringList OPcmciaSocket::productIdentity() const | 336 | QStringList OPcmciaSocket::productIdentity() const |
337 | { | 337 | { |
338 | QStringList list; | 338 | QStringList list; |
339 | cistpl_vers_1_t *vers = &_ioctlarg.tuple_parse.parse.version_1; | 339 | cistpl_vers_1_t *vers = &_ioctlarg.tuple_parse.parse.version_1; |
340 | if ( getTuple( CISTPL_VERS_1 ) ) | 340 | if ( getTuple( CISTPL_VERS_1 ) ) |
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 | |||
@@ -52,16 +52,17 @@ using namespace Opie::Ui; | |||
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 | { |
@@ -131,18 +132,18 @@ void PcmciaManager::mousePressEvent( QMouseEvent* ) | |||
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 ) ); |
@@ -254,17 +255,17 @@ int PcmciaManager::position() | |||
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; |
@@ -273,17 +274,17 @@ void PcmciaManager::userCardAction( int action ) | |||
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() ); |