summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-06-19 22:02:38 (UTC)
committer mickeyl <mickeyl>2005-06-19 22:02:38 (UTC)
commit34ecdb361924656b758da2073ef6ac0c1bffd210 (patch) (side-by-side diff)
treedbc91b753acae2f9f6a62e922e6707cfef55e171
parent83fec70860e56af97d66e9505b913602505423d7 (diff)
downloadopie-34ecdb361924656b758da2073ef6ac0c1bffd210.zip
opie-34ecdb361924656b758da2073ef6ac0c1bffd210.tar.gz
opie-34ecdb361924656b758da2073ef6ac0c1bffd210.tar.bz2
- s/new card/unconfigured card/
- add note about unrecognized cards in configuration dialog - add ConfigDialog::preferredAction()
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/applets/pcmcia/configdialog.cpp52
-rw-r--r--noncore/applets/pcmcia/configdialog.h2
-rw-r--r--noncore/applets/pcmcia/configdialogbase.ui217
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp38
-rw-r--r--noncore/applets/pcmcia/pcmcia.h2
5 files changed, 185 insertions, 126 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp
index 9fcf58c..f961069 100644
--- a/noncore/applets/pcmcia/configdialog.cpp
+++ b/noncore/applets/pcmcia/configdialog.cpp
@@ -37,75 +37,62 @@ 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 OPcmciaSocket* card, QWidget* parent )
:ConfigDialogBase( parent, "pcmcia config dialog", true )
{
- gbDetails->setTitle( QString( "Details for '%1'" ).arg( card->identity() ) );
+ gbDetails->setTitle( QString( "Details for card in socket #%1" ).arg( card->number() ) );
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;
+ QString action = preferredAction( card );
- 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 '" << card->name() << "' with known card '" << name << "'" << oendl;
- if ( card->name() == name )
- {
- insert = cfg.readEntry( "insert" );
- break;
- }
- }
- odebug << "preferred action for card '" << card->name() << "' seems to be '" << insert << "'" << oendl;
+ odebug << "preferred action for card '" << card->name() << "' seems to be '" << action << "'" << oendl;
- if ( !insert.isEmpty() )
+ if ( !action.isEmpty() )
{
for ( int i; i < cbAction->count(); ++i )
- if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i );
+ if ( cbAction->text( i ) == action ) cbAction->setCurrentItem( i );
}
if ( !card->isUnsupported() )
{
odebug << "card is recognized - hiding bindings" << oendl;
+ textInfo->hide();
textBindTo->hide();
cbBindTo->hide();
return;
}
else
{
odebug << "card is unsupported yet - showing possible bindings" << oendl;
+ textInfo->show();
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 )
+ for ( unsigned 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" )
@@ -125,12 +112,35 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
}
for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it )
{
odebug << "found binding '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl;
cbBindTo->insertItem( it.key() );
}
}
ConfigDialog::~ConfigDialog()
{
}
+
+QString ConfigDialog::preferredAction( const OPcmciaSocket* card )
+{
+ OConfig cfg( "PCMCIA" );
+ cfg.setGroup( "Global" );
+ int nCards = cfg.readNumEntry( "nCards", 0 );
+ QString action;
+
+ 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 '" << card->name() << "' with known card '" << name << "'" << oendl;
+ if ( card->name() == name )
+ {
+ action = cfg.readEntry( "action" );
+ break;
+ }
+ }
+
+ return action;
+}
diff --git a/noncore/applets/pcmcia/configdialog.h b/noncore/applets/pcmcia/configdialog.h
index 3c7fe85..321180d 100644
--- a/noncore/applets/pcmcia/configdialog.h
+++ b/noncore/applets/pcmcia/configdialog.h
@@ -29,18 +29,18 @@
#ifndef CONFIGDIALOG_H
#define CONFIGDIALOG_H
#include "configdialogbase.h"
namespace Opie { namespace Core { class OPcmciaSocket; }; };
class ConfigDialog : public ConfigDialogBase
{
Q_OBJECT
public:
-
ConfigDialog( const Opie::Core::OPcmciaSocket* card, QWidget* parent );
~ConfigDialog();
+ static QString preferredAction( const Opie::Core::OPcmciaSocket* card );
};
#endif
diff --git a/noncore/applets/pcmcia/configdialogbase.ui b/noncore/applets/pcmcia/configdialogbase.ui
index 7ec3a75..829b71a 100644
--- a/noncore/applets/pcmcia/configdialogbase.ui
+++ b/noncore/applets/pcmcia/configdialogbase.ui
@@ -2,133 +2,47 @@
<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>197</width>
- <height>154</height>
+ <width>215</width>
+ <height>329</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>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>gbDetails</cstring>
</property>
<property stdset="1">
<name>title</name>
<string>Details</string>
</property>
<property>
<name>layoutMargin</name>
@@ -225,28 +139,151 @@
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>1</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>text</name>
<string>TextLabel3</string>
</property>
</widget>
</grid>
</widget>
- <spacer row="1" column="1" >
+ <widget row="1" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>On insertion,</string>
+ </property>
+ </widget>
+ <widget row="1" 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="1" 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="4" 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="4" column="1" rowspan="1" colspan="2" >
+ <class>QComboBox</class>
+ <item>
+ <property>
+ <name>text</name>
+ <string>&lt;None&gt;</string>
+ </property>
+ </item>
+ <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>currentItem</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>autoResize</name>
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget row="3" column="0" rowspan="1" colspan="3" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>textInfo</cstring>
+ </property>
+ <property stdset="1">
+ <name>frameShape</name>
+ <enum>Box</enum>
+ </property>
+ <property stdset="1">
+ <name>frameShadow</name>
+ <enum>Raised</enum>
+ </property>
+ <property stdset="1">
+ <name>lineWidth</name>
+ <number>2</number>
+ </property>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>&lt;qt&gt;CAUTION: This card is not yet recognized by your system. Without a valid binding, your card may not function correctly. Please choose a driver to bind the card to below:&lt;/qt&gt;</string>
+ </property>
+ </widget>
+ <spacer row="2" column="1" >
<property>
<name>name</name>
- <cstring>Spacer1</cstring>
+ <cstring>Spacer2</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp
index 99c1bc9..1a2b619 100644
--- a/noncore/applets/pcmcia/pcmcia.cpp
+++ b/noncore/applets/pcmcia/pcmcia.cpp
@@ -194,49 +194,60 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl;
if ( cardName == name )
{
newCard = false;
break;
}
}
if ( !newCard ) ++it; else break;
}
}
if ( newCard )
{
- odebug << "pcmcia: new card detected" << oendl;
- cfg.setGroup( QString( "Card_%1" ).arg( nCards ) );
- cfg.writeEntry( "name", theCard->productIdentity().join( " " ) );
- cfg.writeEntry( "insert", "suspend" );
- cfg.setGroup( "Global" );
- cfg.writeEntry( "nCards", nCards+1 );
- cfg.write();
-
+ odebug << "pcmcia: unconfigured card detected" << oendl;
+ QString newCardName = theCard->productIdentity().join( " " ).stripWhiteSpace();
int result = QMessageBox::information( qApp->desktop(),
tr( "PCMCIA/CF Subsystem" ),
- tr( "You have inserted a new card:\n%1\nDo you want to configure?" ).arg( theCard->productIdentity().join( " " ) ),
+ tr( "<qt>You have inserted the card '%1'. This card is not yet configured. Do you want to configure it now?</qt>" ).arg( newCardName ),
tr( "Yes" ), tr( "No" ), 0, 0, 1 );
odebug << "result = " << result << oendl;
if ( result == 0 )
{
- configure( theCard );
+ bool configured = configure( theCard );
+
+ if ( configured )
+ {
+ odebug << "card has been configured. writing out to dabase" << oendl;
+ cfg.setGroup( QString( "Card_%1" ).arg( nCards ) );
+ cfg.writeEntry( "name", newCardName );
+ cfg.writeEntry( "insert", "suspend" );
+ cfg.setGroup( "Global" );
+ cfg.writeEntry( "nCards", nCards+1 );
+ cfg.write();
}
else
{
- odebug << "pcmcia: user doesn't want to configure " << theCard->productIdentity().join( " " ) << " now." << oendl;
+ odebug << "card has not been configured this time. leaving as unknown card" << oendl;
}
}
else
{
- odebug << "pcmcia: card has been previously inserted" << oendl;
+ odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl;
+ }
+ }
+ else // it's an already configured card
+ {
+ QString action = ConfigDialog::preferredAction( theCard );
+ odebug << "pcmcia: card has been previously configured" << oendl;
+ odebug << "pcmcia: need to perform action'" << action << "' now... sorry, not yet implemented..." << oendl;
}
repaint( true );
}
void PcmciaManager::paintEvent( QPaintEvent * )
{
QPainter p( this );
odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl;
if ( OPcmciaSystem::instance()->cardCount() )
{
@@ -275,24 +286,25 @@ void PcmciaManager::userCardAction( int action )
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 (" << strerror( errno ) << ")" << oendl;
}
}
-void PcmciaManager::configure( OPcmciaSocket* card )
+bool PcmciaManager::configure( OPcmciaSocket* card )
{
configuring = true;
ConfigDialog dialog( card, qApp->desktop() );
int configresult = QPEApplication::execDialog( &dialog, false );
configuring = false;
odebug << "pcmcia: configresult = " << configresult << oendl;
+ return configresult;
}
EXPORT_OPIE_APPLET_v1( PcmciaManager )
diff --git a/noncore/applets/pcmcia/pcmcia.h b/noncore/applets/pcmcia/pcmcia.h
index a453c1b..eb9c513 100644
--- a/noncore/applets/pcmcia/pcmcia.h
+++ b/noncore/applets/pcmcia/pcmcia.h
@@ -45,25 +45,25 @@ class PcmciaManager : public QWidget
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* );
+ bool configure( Opie::Core::OPcmciaSocket* );
void execCommand( const QStringList &command );
void popUp(QString message, QString icon = QString::null );
private:
bool configuring;
int commandOrig;
QPixmap pm;
QPopupMenu *popupMenu;
};
#endif