summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-06-17 13:47:42 (UTC)
committer mickeyl <mickeyl>2005-06-17 13:47:42 (UTC)
commitc36e39b5b1e450e64d4c38cb59e56048a2bec258 (patch) (side-by-side diff)
tree0e796a165a2e4ce8e24b8b79f15bb58f4265a7bb
parent0e11eb29a20ff6bff533a07ff604ed858237f82b (diff)
downloadopie-c36e39b5b1e450e64d4c38cb59e56048a2bec258.zip
opie-c36e39b5b1e450e64d4c38cb59e56048a2bec258.tar.gz
opie-c36e39b5b1e450e64d4c38cb59e56048a2bec258.tar.bz2
- disable DEBUG in opcmciasystem
- fix suspend/resume logic
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/linux/opcmciasystem.cpp12
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp9
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
@@ -28,49 +28,49 @@
*/
#include "opcmciasystem.h"
using namespace Opie::Core;
/* OPIE */
#include <opie2/odebug.h>
/* QT */
#include <qfile.h>
#include <qtextstream.h>
/* STD */
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define PROC_DEVICES "/proc/devices"
-#define OPCMCIA_DEBUG 1
+// #define OPCMCIA_DEBUG 1
/*======================================================================================
* OPcmciaSystem
*======================================================================================*/
OPcmciaSystem* OPcmciaSystem::_instance = 0;
OPcmciaSystem::OPcmciaSystem()
:_major( 0 )
{
qDebug( "OPcmciaSystem::OPcmciaSystem()" );
// get major node number out of /proc/devices
QFile procfile( PROC_DEVICES );
if ( procfile.exists() && procfile.open( IO_ReadOnly ) )
{
QTextStream devstream( &procfile );
devstream.readLine(); // skip header
while ( !devstream.atEnd() && !_major )
{
int nodenumber;
QString driver;
devstream >> nodenumber >> driver;
if ( driver == "pcmcia" )
@@ -284,73 +284,73 @@ const OPcmciaSocket::OPcmciaSocketCardStatus OPcmciaSocket::status() const
}
}
bool OPcmciaSocket::isUnsupported() const
{
return ( strcmp( name(), "unsupported card" ) == 0 );
}
bool OPcmciaSocket::isEmpty() const
{
return ! status() && ( Occupied || OccupiedCardBus );
}
bool OPcmciaSocket::isSuspended() const
{
return status() && Suspended;
}
bool OPcmciaSocket::eject()
{
- return ::ioctl( _fd, DS_EJECT_CARD );
+ return ::ioctl( _fd, DS_EJECT_CARD ) != -1;
}
bool OPcmciaSocket::insert()
{
- return ::ioctl( _fd, DS_INSERT_CARD );
+ return ::ioctl( _fd, DS_INSERT_CARD ) != -1;
}
bool OPcmciaSocket::suspend()
{
- return ::ioctl( _fd, DS_SUSPEND_CARD );
+ return ::ioctl( _fd, DS_SUSPEND_CARD ) != -1;
}
bool OPcmciaSocket::resume()
{
- return ::ioctl( _fd, DS_RESUME_CARD );
+ return ::ioctl( _fd, DS_RESUME_CARD ) != -1;
}
bool OPcmciaSocket::reset()
{
- return ::ioctl( _fd, DS_RESET_CARD );
+ return ::ioctl( _fd, DS_RESET_CARD ) != -1;
}
QStringList OPcmciaSocket::productIdentity() const
{
QStringList list;
cistpl_vers_1_t *vers = &_ioctlarg.tuple_parse.parse.version_1;
if ( getTuple( CISTPL_VERS_1 ) )
{
for ( int i = 0; i < CISTPL_VERS_1_MAX_PROD_STRINGS; ++i )
{
qDebug( " PRODID = '%s'", vers->str+vers->ofs[i] );
list += vers->str+vers->ofs[i];
}
}
else
{
list += "<unknown>";
}
return list;
}
QString OPcmciaSocket::manufacturerIdentity() const
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
@@ -36,48 +36,49 @@
#include <opie2/oconfig.h>
#include <opie2/oprocess.h>
#include <opie2/opcmciasystem.h>
#include <opie2/oresource.h>
#include <opie2/otaskbarapplet.h>
#include <qpe/applnk.h>
#include <qpe/resource.h>
using namespace Opie::Core;
using namespace Opie::Ui;
/* QT */
#include <qcopchannel_qws.h>
#include <qpainter.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qmessagebox.h>
#include <qsound.h>
#include <qtimer.h>
/* STD */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include <fcntl.h>
#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
#include <sys/vfs.h>
#include <mntent.h>
#endif
PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent )
{
QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this );
connect( pcmciaChannel,
SIGNAL( received(const QCString&,const QByteArray&) ), this,
SLOT( cardMessage(const QCString&,const QByteArray&) ) );
setFocusPolicy( NoFocus );
setFixedWidth ( AppLnk::smallIconSize() );
setFixedHeight ( AppLnk::smallIconSize() );
pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon );
configuring = false;
}
PcmciaManager::~PcmciaManager()
{
}
@@ -115,50 +116,50 @@ enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE };
void PcmciaManager::mousePressEvent( QMouseEvent* )
{
QPopupMenu* menu = new QPopupMenu( this );
QStringList cmd;
bool execute = true;
OPcmciaSystem* sys = OPcmciaSystem::instance();
OPcmciaSystem::CardIterator it = sys->iterator();
if ( !sys->count() ) return;
int i = 0;
while ( it.current() )
{
QPopupMenu* submenu = new QPopupMenu( menu );
submenu->insertItem( "&Eject", EJECT+i*100 );
submenu->insertItem( "&Insert", INSERT+i*100 );
submenu->insertItem( "&Suspend", SUSPEND+i*100 );
submenu->insertItem( "&Resume", RESUME+i*100 );
submenu->insertItem( "Rese&t", RESET+i*100 );
submenu->insertItem( "&Configure", CONFIGURE+i*100 );
submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() );
submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() );
- submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() );
- submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && it.current()->isSuspended() );
+ submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && it.current()->isSuspended() );
+ submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() );
submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() && !configuring );
connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) );
menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 );
++it;
}
QPoint p = mapToGlobal( QPoint( 0, 0 ) );
QSize s = menu->sizeHint();
int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 );
qDebug( "pcmcia: menu result = %d", opt );
delete menu;
}
void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
{
odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl;
if ( msg != "stabChanged()" ) return;
/* check if a previously unknown card has been inserted */
OPcmciaSystem::instance()->synchronize();
if ( !OPcmciaSystem::instance()->cardCount() ) return;
@@ -238,60 +239,60 @@ void PcmciaManager::paintEvent( QPaintEvent * )
odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl;
if ( OPcmciaSystem::instance()->cardCount() )
{
p.drawPixmap( 0, 0, pm );
show();
}
else
{
hide();
}
}
int PcmciaManager::position()
{
return 7;
}
void PcmciaManager::execCommand( const QStringList &strList )
{
}
void PcmciaManager::userCardAction( int action )
{
- odebug << "user action requested. action = " << action << oendl;
+ odebug << "user action on socket " << action / 100 << " requested. action = " << action << oendl;
int socket = action / 100;
int what = action % 100;
bool success = false;
switch ( what )
{
case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); success = true; break;
case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break;
case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break;
case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break;
case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break;
case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break;
default: odebug << "not yet implemented" << oendl;
}
if ( !success )
{
- owarn << "couldn't perform user action" << oendl;
+ owarn << "couldn't perform user action (" << strerror( errno ) << ")" << oendl;
}
}
void PcmciaManager::configure( OPcmciaSocket* card )
{
configuring = true;
ConfigDialog dialog( card, qApp->desktop() );
int configresult = QPEApplication::execDialog( &dialog, false );
configuring = false;
odebug << "pcmcia: configresult = " << configresult << oendl;
}
EXPORT_OPIE_APPLET_v1( PcmciaManager )