summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/pcmcia/configdialog.cpp55
-rw-r--r--noncore/applets/pcmcia/configdialog.h7
-rw-r--r--noncore/applets/pcmcia/configdialogbase.ui171
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp69
-rw-r--r--noncore/applets/pcmcia/pcmcia.h2
5 files changed, 216 insertions, 88 deletions
diff --git a/noncore/applets/pcmcia/configdialog.cpp b/noncore/applets/pcmcia/configdialog.cpp
index f961069..f5812ba 100644
--- a/noncore/applets/pcmcia/configdialog.cpp
+++ b/noncore/applets/pcmcia/configdialog.cpp
@@ -53,10 +53,18 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
- QString action = preferredAction( card );
+ QString insertAction = preferredAction( card, "insert" );
+ QString resumeAction = preferredAction( card, "resume" );
- odebug << "preferred action for card '" << card->name() << "' seems to be '" << action << "'" << oendl;
+ odebug << "pcmcia: preferred insertion action for card '" << card->name() << "' seems to be '" << insertAction << "'" << oendl;
+ odebug << "pcmcia: preferred resume action for card '" << card->name() << "' seems to be '" << resumeAction << "'" << oendl;
- if ( !action.isEmpty() )
+ if ( !insertAction.isEmpty() )
{
- for ( int i; i < cbAction->count(); ++i )
- if ( cbAction->text( i ) == action ) cbAction->setCurrentItem( i );
+ for ( int i; i < cbInsertAction->count(); ++i )
+ if ( cbInsertAction->text( i ) == insertAction ) cbInsertAction->setCurrentItem( i );
+ }
+
+ if ( !resumeAction.isEmpty() )
+ {
+ for ( int i; i < cbResumeAction->count(); ++i )
+ if ( cbResumeAction->text( i ) == resumeAction ) cbResumeAction->setCurrentItem( i );
}
@@ -65,3 +73,3 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
{
- odebug << "card is recognized - hiding bindings" << oendl;
+ odebug << "pcmcia: card is recognized - hiding bindings" << oendl;
textInfo->hide();
@@ -80,5 +88,2 @@ ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
// parse possible bind entries out of /etc/pcmcia/*.conf
- typedef QMap<QString,QString> StringMap;
- StringMap bindEntries;
-
QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" );
@@ -124,3 +129,3 @@ ConfigDialog::~ConfigDialog()
-QString ConfigDialog::preferredAction( const OPcmciaSocket* card )
+void ConfigDialog::writeConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& value )
{
@@ -139,3 +144,3 @@ QString ConfigDialog::preferredAction( const OPcmciaSocket* card )
{
- action = cfg.readEntry( "action" );
+ cfg.writeEntry( key, value );
break;
@@ -143,4 +148,30 @@ QString ConfigDialog::preferredAction( const OPcmciaSocket* card )
}
+}
- return action;
+QString ConfigDialog::readConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& defaultValue )
+{
+ OConfig cfg( "PCMCIA" );
+ cfg.setGroup( "Global" );
+ int nCards = cfg.readNumEntry( "nCards", 0 );
+ QString value;
+
+ 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 )
+ {
+ value = cfg.readEntry( key, defaultValue );
+ break;
+ }
+ }
+ return value;
+}
+
+
+QString ConfigDialog::preferredAction( const OPcmciaSocket* card, const QString& type )
+{
+ return ConfigDialog::readConfigEntry( card, QString( "%1Action" ).arg( type ), "suspend" );
}
diff --git a/noncore/applets/pcmcia/configdialog.h b/noncore/applets/pcmcia/configdialog.h
index 321180d..169dadb 100644
--- a/noncore/applets/pcmcia/configdialog.h
+++ b/noncore/applets/pcmcia/configdialog.h
@@ -36,2 +36,4 @@ namespace Opie { namespace Core { class OPcmciaSocket; }; };
+typedef QMap<QString,QString> StringMap;
+
class ConfigDialog : public ConfigDialogBase
@@ -42,3 +44,6 @@ class ConfigDialog : public ConfigDialogBase
~ConfigDialog();
- static QString preferredAction( const Opie::Core::OPcmciaSocket* card );
+ static QString preferredAction( const Opie::Core::OPcmciaSocket* card, const QString& type );
+ static QString readConfigEntry( const Opie::Core::OPcmciaSocket* card, const QString& key, const QString& defaultValue );
+ static void writeConfigEntry( const Opie::Core::OPcmciaSocket* card, const QString& key, const QString& value );
+ StringMap bindEntries;
};
diff --git a/noncore/applets/pcmcia/configdialogbase.ui b/noncore/applets/pcmcia/configdialogbase.ui
index 829b71a..97d9a50 100644
--- a/noncore/applets/pcmcia/configdialogbase.ui
+++ b/noncore/applets/pcmcia/configdialogbase.ui
@@ -13,3 +13,3 @@
<y>0</y>
- <width>215</width>
+ <width>211</width>
<height>329</height>
@@ -30,3 +30,3 @@
<name>margin</name>
- <number>5</number>
+ <number>6</number>
</property>
@@ -150,56 +150,3 @@
</widget>
- <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" >
+ <widget row="5" column="0" >
<class>QLabel</class>
@@ -214,3 +161,3 @@
</widget>
- <widget row="4" column="1" rowspan="1" colspan="2" >
+ <widget row="5" column="1" rowspan="1" colspan="2" >
<class>QComboBox</class>
@@ -246,3 +193,3 @@
</widget>
- <widget row="3" column="0" rowspan="1" colspan="3" >
+ <widget row="4" column="0" rowspan="1" colspan="3" >
<class>QLabel</class>
@@ -273,3 +220,47 @@
</widget>
- <spacer row="2" 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="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_2</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>On resume,</string>
+ </property>
+ </widget>
+ <widget row="2" column="2" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel3_2</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>card</string>
+ </property>
+ </widget>
+ <spacer row="3" column="1" >
<property>
@@ -294,2 +285,64 @@
</spacer>
+ <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>cbInsertAction</cstring>
+ </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>cbResumeAction</cstring>
+ </property>
+ </widget>
</grid>
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp
index 1a2b619..186dfea 100644
--- a/noncore/applets/pcmcia/pcmcia.cpp
+++ b/noncore/applets/pcmcia/pcmcia.cpp
@@ -41,2 +41,3 @@
#include <qpe/applnk.h>
+#include <qpe/global.h>
#include <qpe/resource.h>
@@ -46,2 +47,3 @@ using namespace Opie::Ui;
/* QT */
+#include <qcombobox.h>
#include <qcopchannel_qws.h>
@@ -180,3 +182,3 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
{
- odebug << "skipping empty card in socket " << it.current()->number() << oendl;
+ odebug << "pcmcia: skipping empty card in socket " << it.current()->number() << oendl;
++it;
@@ -193,3 +195,3 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
QString name = cfg.readEntry( "name" );
- odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl;
+ odebug << "pcmcia: comparing card '" << cardName << "' with known card '" << name << "'" << oendl;
if ( cardName == name )
@@ -209,8 +211,9 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
tr( "PCMCIA/CF Subsystem" ),
- 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( "<qt>You have inserted the card<br/><b>%1</b><br/>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;
+ odebug << "pcmcia: result = " << result << oendl;
if ( result == 0 )
{
- bool configured = configure( theCard );
+ QString insertAction; QString resumeAction; QString driver; QString conf;
+ bool configured = configure( theCard, insertAction, resumeAction, driver, conf );
@@ -218,6 +221,7 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
{
- odebug << "card has been configured. writing out to dabase" << oendl;
+ odebug << "pcmcia: card has been configured. writing out to database" << oendl;
cfg.setGroup( QString( "Card_%1" ).arg( nCards ) );
cfg.writeEntry( "name", newCardName );
- cfg.writeEntry( "insert", "suspend" );
+ cfg.writeEntry( "insertAction", insertAction );
+ cfg.writeEntry( "resumeAction", resumeAction );
cfg.setGroup( "Global" );
@@ -225,2 +229,24 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
cfg.write();
+
+ QFile confFile( QString( "/etc/pcmcia/%1" ).arg( conf ) );
+ if ( confFile.open( IO_ReadWrite | IO_Append ) )
+ {
+ QString entryCard = QString( "card \"%1\"" ).arg( newCardName );
+ QString entryVersion( " version " );
+ for ( QStringList::Iterator it = theCard->productIdentity().begin(); it != theCard->productIdentity().end(); ++it )
+ {
+ entryVersion += QString( "\"%1\", " ).arg( *it );
+ }
+ QString entryBind = QString( " bind %1" ).arg( driver );
+ QString entry = QString( "\n%1\n%2\n%3\n" ).arg( entryCard ).arg( entryVersion ).arg( entryBind );
+ odebug << "pcmcia: writing entry...:" << entry << oendl;
+
+ confFile.writeBlock( (const char*) entry, entry.length() );
+ Global::statusMessage( "restarting pcmcia services..." );
+ ::system( "/etc/init.d/pcmcia restart" );
+ }
+ else
+ {
+ owarn << "pcmcia: couldn't write binding to '" << conf << "'." << oendl;
+ }
}
@@ -228,3 +254,3 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
{
- odebug << "card has not been configured this time. leaving as unknown card" << oendl;
+ odebug << "pcmcia: card has not been configured this time. leaving as unknown card" << oendl;
}
@@ -238,5 +264,5 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
{
- QString action = ConfigDialog::preferredAction( theCard );
+ QString insertAction = ConfigDialog::preferredAction( theCard, "insert" );
odebug << "pcmcia: card has been previously configured" << oendl;
- odebug << "pcmcia: need to perform action'" << action << "' now... sorry, not yet implemented..." << oendl;
+ odebug << "pcmcia: TODO: need to perform action'" << insertAction << "' now... sorry, not yet implemented..." << oendl;
}
@@ -273,3 +299,3 @@ void PcmciaManager::userCardAction( int action )
{
- odebug << "user action on socket " << action / 100 << " requested. action = " << action << oendl;
+ odebug << "pcmcia: user action on socket " << action / 100 << " requested. action = " << action << oendl;
@@ -281,3 +307,9 @@ void PcmciaManager::userCardAction( int action )
{
- case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); success = true; break;
+ case CONFIGURE:
+ {
+ QString insertAction; QString resumeAction; QString driver; QString conf;
+ bool result = configure( OPcmciaSystem::instance()->socket( socket ), insertAction, resumeAction, driver, conf );
+ success = true;
+ break;
+ }
case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break;
@@ -287,3 +319,3 @@ void PcmciaManager::userCardAction( int action )
case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break;
- default: odebug << "not yet implemented" << oendl;
+ default: odebug << "pcmcia: not yet implemented" << oendl;
}
@@ -292,3 +324,3 @@ void PcmciaManager::userCardAction( int action )
{
- owarn << "couldn't perform user action (" << strerror( errno ) << ")" << oendl;
+ owarn << "pcmcia: couldn't perform user action (" << strerror( errno ) << ")" << oendl;
}
@@ -297,3 +329,3 @@ void PcmciaManager::userCardAction( int action )
-bool PcmciaManager::configure( OPcmciaSocket* card )
+bool PcmciaManager::configure( OPcmciaSocket* card, QString& insertAction, QString& resumeAction, QString& driver, QString& conf )
{
@@ -304,2 +336,9 @@ bool PcmciaManager::configure( OPcmciaSocket* card )
odebug << "pcmcia: configresult = " << configresult << oendl;
+ if ( configresult )
+ {
+ insertAction = dialog.cbInsertAction->currentText();
+ resumeAction = dialog.cbResumeAction->currentText();
+ driver = dialog.cbBindTo->currentText();
+ conf = dialog.bindEntries[driver];
+ }
return configresult;
diff --git a/noncore/applets/pcmcia/pcmcia.h b/noncore/applets/pcmcia/pcmcia.h
index eb9c513..94203d3 100644
--- a/noncore/applets/pcmcia/pcmcia.h
+++ b/noncore/applets/pcmcia/pcmcia.h
@@ -56,3 +56,3 @@ class PcmciaManager : public QWidget
private:
- bool configure( Opie::Core::OPcmciaSocket* );
+ bool configure( Opie::Core::OPcmciaSocket*, QString&, QString&, QString&, QString& );
void execCommand( const QStringList &command );