summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/linux/opcmciasystem.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiecore/linux/opcmciasystem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/linux/opcmciasystem.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/libopie2/opiecore/linux/opcmciasystem.cpp b/libopie2/opiecore/linux/opcmciasystem.cpp
index 21c5a84..9f151ce 100644
--- a/libopie2/opiecore/linux/opcmciasystem.cpp
+++ b/libopie2/opiecore/linux/opcmciasystem.cpp
@@ -109,96 +109,103 @@ void OPcmciaSystem::synchronize()
}
QTextStream cardinfo( &cardinfofile );
while ( !cardinfo.atEnd() )
{
QString strSocket;
int numSocket;
char colon;
QString cardName;
cardinfo >> strSocket >> numSocket >> colon;
cardName = cardinfo.readLine().stripWhiteSpace();
qDebug( "strSocket = '%s', numSocket = '%d', colon = '%c', cardName = '%s'", (const char*) strSocket, numSocket, colon, ( const char*) cardName );
if ( strSocket == "Socket" && colon == ':' )
{
_interfaces.append( new OPcmciaSocket( _major, numSocket, this, (const char*) cardName ) );
}
else
{
continue;
}
}
}
int OPcmciaSystem::count() const
{
return _interfaces.count();
}
int OPcmciaSystem::cardCount() const
{
int nonEmpty = 0;
OPcmciaSystem::CardIterator it = iterator();
while ( it.current() )
{
if ( !it.current()->isEmpty() ) nonEmpty++;
++it;
}
return nonEmpty;
}
OPcmciaSocket* OPcmciaSystem::socket( unsigned int number )
{
return _interfaces.at( number );
}
+void OPcmciaSystem::restart()
+{
+ //FIXME Use OProcess or something that allows more control
+ ::system( "/etc/init.d/pcmcia restart" );
+}
+
+
OPcmciaSystem* OPcmciaSystem::instance()
{
if ( !_instance ) _instance = new OPcmciaSystem();
return _instance;
}
OPcmciaSystem::CardIterator OPcmciaSystem::iterator() const
{
return OPcmciaSystem::CardIterator( _interfaces );
}
/*======================================================================================
* OPcmciaSocket
*======================================================================================*/
OPcmciaSocket::OPcmciaSocket( int major, int socket, QObject* parent, const char* name )
:QObject( parent, name ), _major( major ), _socket( socket )
{
qDebug( "OPcmciaSocket::OPcmciaSocket()" );
init();
}
OPcmciaSocket::~OPcmciaSocket()
{
qDebug( "OPcmciaSocket::~OPcmciaSocket()" );
cleanup();
}
/* internal */ void OPcmciaSocket::init()
{
// open control socket and gather file descriptor
if ( _major )
{
dev_t dev = makedev( _major, _socket );
#ifdef OPCMCIA_DEBUG
QString filename = "/tmp/opcmciasystem-debug";
if ( QFile::exists( filename ) )
#else
QString filename = QString().sprintf( "/tmp/opcmciasystem-%d", ::getpid() );
if ( ::mknod( (const char*) filename, ( S_IFCHR|S_IREAD|S_IWRITE ), dev ) == 0 )
#endif
{
_fd = ::open( (const char*) filename, O_RDONLY);