summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-06-14 13:15:05 (UTC)
committer mickeyl <mickeyl>2005-06-14 13:15:05 (UTC)
commit7d8d317205a74bc2e23291ab4909472db6694091 (patch) (side-by-side diff)
tree7fdf8d039a30f26316fb57edbe53462d1b38b654
parentc1194d42d8456417452b125bd6c2c5048d7bbe02 (diff)
downloadopie-7d8d317205a74bc2e23291ab4909472db6694091.zip
opie-7d8d317205a74bc2e23291ab4909472db6694091.tar.gz
opie-7d8d317205a74bc2e23291ab4909472db6694091.tar.bz2
more work on configuring unsupported cards
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/pcmcia/configdialog.cpp32
-rw-r--r--noncore/applets/pcmcia/configdialog.h4
-rw-r--r--noncore/applets/pcmcia/configdialogbase.ui19
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp12
-rw-r--r--noncore/applets/pcmcia/pcmcia.h3
5 files changed, 53 insertions, 17 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp
index e161d18..9fcf58c 100644
--- a/noncore/applets/pcmcia/configdialog.cpp
+++ b/noncore/applets/pcmcia/configdialog.cpp
@@ -11,108 +11,126 @@
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "configdialog.h"
/* OPIE */
#include <opie2/oconfig.h>
#include <opie2/odebug.h>
+#include <opie2/opcmciasystem.h>
using namespace Opie::Core;
/* QT */
#include <qcombobox.h>
#include <qdir.h>
#include <qfile.h>
+#include <qgroupbox.h>
#include <qlabel.h>
#include <qtextstream.h>
-ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent )
+ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
:ConfigDialogBase( parent, "pcmcia config dialog", true )
{
- //setCaption( tr( "Configure %1" ).arg( cardname ) );
- txtCardName->setText( cardname );
+ gbDetails->setTitle( QString( "Details for '%1'" ).arg( card->identity() ) );
+ txtCardName->setText( card->productIdentity().join( " " ) );
+ txtManfid->setText( card->manufacturerIdentity() );
+ txtFunction->setText( card->function() );
OConfig cfg( "PCMCIA" );
cfg.setGroup( "Global" );
int nCards = cfg.readNumEntry( "nCards", 0 );
QString insert;
for ( int i = 0; i < nCards; ++i )
{
QString cardSection = QString( "Card_%1" ).arg( i );
cfg.setGroup( cardSection );
QString name = cfg.readEntry( "name" );
- odebug << "comparing card '" << cardname << "' with known card '" << name << "'" << oendl;
- if ( cardname == name )
+ odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl;
+ if ( card->name() == name )
{
insert = cfg.readEntry( "insert" );
break;
}
}
- odebug << "preferred action for card '" << cardname << "' seems to be '" << insert << "'" << oendl;
+ odebug << "preferred action for card '" << card->name() << "' seems to be '" << insert << "'" << oendl;
if ( !insert.isEmpty() )
{
for ( int i; i < cbAction->count(); ++i )
if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i );
}
+ if ( !card->isUnsupported() )
+ {
+ odebug << "card is recognized - hiding bindings" << oendl;
+ textBindTo->hide();
+ cbBindTo->hide();
+ return;
+ }
+ else
+ {
+ odebug << "card is unsupported yet - showing possible bindings" << oendl;
+ textBindTo->show();
+ cbBindTo->show();
+ }
+
// parse possible bind entries out of /etc/pcmcia/*.conf
typedef QMap<QString,QString> StringMap;
StringMap bindEntries;
QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" );
for ( int i = 0; i < pcmciaconfdir.count(); ++i )
{
odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl;
QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] );
QFile conffile( conffilename );
if ( conffile.open( IO_ReadOnly ) )
{
QTextStream ts( &conffile );
while ( !ts.atEnd() )
{
QString word;
ts >> word;
if ( word == "bind" )
{
word = ts.readLine();
bindEntries[ word.stripWhiteSpace() ] = conffilename;
continue;
}
ts.readLine();
}
}
else
{
owarn << "couldn't open '" << conffile.name() << "' for reading" << oendl;
continue;
}
}
for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it )
{
- odebug << "found device '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl;
+ odebug << "found binding '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl;
cbBindTo->insertItem( it.key() );
}
}
ConfigDialog::~ConfigDialog()
{
}
diff --git a/noncore/applets/pcmcia/configdialog.h b/noncore/applets/pcmcia/configdialog.h
index f79d7a6..3c7fe85 100644
--- a/noncore/applets/pcmcia/configdialog.h
+++ b/noncore/applets/pcmcia/configdialog.h
@@ -11,34 +11,36 @@
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef CONFIGDIALOG_H
#define CONFIGDIALOG_H
#include "configdialogbase.h"
+namespace Opie { namespace Core { class OPcmciaSocket; }; };
+
class ConfigDialog : public ConfigDialogBase
{
Q_OBJECT
public:
- ConfigDialog( const QString& cardname, QWidget* parent );
+ ConfigDialog( const Opie::Core::OPcmciaSocket* card, QWidget* parent );
~ConfigDialog();
};
#endif
diff --git a/noncore/applets/pcmcia/configdialogbase.ui b/noncore/applets/pcmcia/configdialogbase.ui
index a0760d6..7ec3a75 100644
--- a/noncore/applets/pcmcia/configdialogbase.ui
+++ b/noncore/applets/pcmcia/configdialogbase.ui
@@ -1,140 +1,151 @@
<!DOCTYPE UI><UI>
<class>ConfigDialogBase</class>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>ConfigDialogBase</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>232</width>
- <height>206</height>
+ <width>197</width>
+ <height>154</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Configure PCMCIA/CF Card</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<grid>
<property stdset="1">
<name>margin</name>
<number>5</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>2</number>
</property>
<widget row="2" column="2" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel3</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>card</string>
</property>
</widget>
<widget row="2" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel2</cstring>
</property>
<property stdset="1">
<name>text</name>
- <string>Upon insertion,</string>
+ <string>On insertion,</string>
</property>
</widget>
<widget row="2" column="1" >
<class>QComboBox</class>
<item>
<property>
<name>text</name>
<string>suspend</string>
</property>
</item>
<item>
<property>
<name>text</name>
<string>activate</string>
</property>
</item>
<item>
<property>
<name>text</name>
<string>eject</string>
</property>
</item>
<item>
<property>
<name>text</name>
<string>prompt for</string>
</property>
</item>
<property stdset="1">
<name>name</name>
<cstring>cbAction</cstring>
</property>
</widget>
<widget row="3" column="1" rowspan="1" colspan="2" >
<class>QComboBox</class>
<property stdset="1">
<name>name</name>
<cstring>cbBindTo</cstring>
</property>
<property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
<name>editable</name>
<bool>true</bool>
</property>
+ <property stdset="1">
+ <name>autoResize</name>
+ <bool>false</bool>
+ </property>
</widget>
<widget row="3" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>textBindTo</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Bind to:</string>
</property>
</widget>
<widget row="0" column="0" rowspan="1" colspan="3" >
<class>QGroupBox</class>
<property stdset="1">
<name>name</name>
- <cstring>GroupBox1</cstring>
+ <cstring>gbDetails</cstring>
</property>
<property stdset="1">
<name>title</name>
<string>Details</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<grid>
<property stdset="1">
<name>margin</name>
<number>6</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>4</number>
</property>
<widget row="0" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp
index 6c18e86..fac7065 100644
--- a/noncore/applets/pcmcia/pcmcia.cpp
+++ b/noncore/applets/pcmcia/pcmcia.cpp
@@ -53,111 +53,113 @@ using namespace Opie::Ui;
#include <qtimer.h>
/* STD */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.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()
{
}
void PcmciaManager::popUp( QString message, QString icon )
{
if ( !popupMenu ) {
popupMenu = new QPopupMenu( this );
}
popupMenu->clear();
if ( icon.isEmpty() ) {
popupMenu->insertItem( message, 0 );
} else {
popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ),
message, 0 );
}
QPoint p = mapToGlobal( QPoint( 0, 0 ) );
QSize s = popupMenu->sizeHint();
popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ),
p.y() - s.height() ), 0 );
QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) );
}
void PcmciaManager::popupTimeout()
{
popupMenu->hide();
}
-enum { EJECT, INSERT, SUSPEND, RESUME, CONFIGURE };
+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( CONFIGURE+i*100, !it.current()->isEmpty() );
+ 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;
@@ -250,32 +252,34 @@ int PcmciaManager::position()
{
return 7;
}
void PcmciaManager::execCommand( const QStringList &strList )
{
}
void PcmciaManager::userCardAction( int action )
{
odebug << "user action requested. action = " << action << oendl;
int socket = action / 100;
int what = action % 100;
switch ( what )
{
case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); break;
default: odebug << "not yet implemented";
}
}
void PcmciaManager::configure( OPcmciaSocket* card )
{
- ConfigDialog dialog( card->identity(), qApp->desktop() );
- int configresult = dialog.exec();
+ 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 )
diff --git a/noncore/applets/pcmcia/pcmcia.h b/noncore/applets/pcmcia/pcmcia.h
index ed86579..a453c1b 100644
--- a/noncore/applets/pcmcia/pcmcia.h
+++ b/noncore/applets/pcmcia/pcmcia.h
@@ -38,32 +38,33 @@ namespace Opie { namespace Core { class OPcmciaSocket; } };
class PcmciaManager : public QWidget
{
Q_OBJECT
public:
PcmciaManager( QWidget *parent = 0 );
~PcmciaManager();
static int position();
private slots:
void cardMessage( const QCString& msg, const QByteArray& );
void userCardAction( int action );
void popupTimeout();
protected:
void paintEvent( QPaintEvent* );
void mousePressEvent( QMouseEvent * );
private:
void configure( Opie::Core::OPcmciaSocket* );
void execCommand( const QStringList &command );
void popUp(QString message, QString icon = QString::null );
private:
- int m_commandOrig;
+ bool configuring;
+ int commandOrig;
QPixmap pm;
QPopupMenu *popupMenu;
};
#endif