summaryrefslogtreecommitdiff
path: root/noncore/applets/pcmcia/configdialog.cpp
Unidiff
Diffstat (limited to 'noncore/applets/pcmcia/configdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/pcmcia/configdialog.cpp32
1 files changed, 25 insertions, 7 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
@@ -23,64 +23,82 @@
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#include "configdialog.h" 30#include "configdialog.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/oconfig.h> 33#include <opie2/oconfig.h>
34#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35#include <opie2/opcmciasystem.h>
35using namespace Opie::Core; 36using namespace Opie::Core;
36 37
37/* QT */ 38/* QT */
38#include <qcombobox.h> 39#include <qcombobox.h>
39#include <qdir.h> 40#include <qdir.h>
40#include <qfile.h> 41#include <qfile.h>
42#include <qgroupbox.h>
41#include <qlabel.h> 43#include <qlabel.h>
42#include <qtextstream.h> 44#include <qtextstream.h>
43 45
44ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) 46ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent )
45 :ConfigDialogBase( parent, "pcmcia config dialog", true ) 47 :ConfigDialogBase( parent, "pcmcia config dialog", true )
46{ 48{
47 //setCaption( tr( "Configure %1" ).arg( cardname ) ); 49 gbDetails->setTitle( QString( "Details for '%1'" ).arg( card->identity() ) );
48 txtCardName->setText( cardname ); 50 txtCardName->setText( card->productIdentity().join( " " ) );
51 txtManfid->setText( card->manufacturerIdentity() );
52 txtFunction->setText( card->function() );
49 53
50 OConfig cfg( "PCMCIA" ); 54 OConfig cfg( "PCMCIA" );
51 cfg.setGroup( "Global" ); 55 cfg.setGroup( "Global" );
52 int nCards = cfg.readNumEntry( "nCards", 0 ); 56 int nCards = cfg.readNumEntry( "nCards", 0 );
53 QString insert; 57 QString insert;
54 58
55 for ( int i = 0; i < nCards; ++i ) 59 for ( int i = 0; i < nCards; ++i )
56 { 60 {
57 QString cardSection = QString( "Card_%1" ).arg( i ); 61 QString cardSection = QString( "Card_%1" ).arg( i );
58 cfg.setGroup( cardSection ); 62 cfg.setGroup( cardSection );
59 QString name = cfg.readEntry( "name" ); 63 QString name = cfg.readEntry( "name" );
60 odebug << "comparing card '" << cardname << "' with known card '" << name << "'" << oendl; 64 odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl;
61 if ( cardname == name ) 65 if ( card->name() == name )
62 { 66 {
63 insert = cfg.readEntry( "insert" ); 67 insert = cfg.readEntry( "insert" );
64 break; 68 break;
65 } 69 }
66 } 70 }
67 odebug << "preferred action for card '" << cardname << "' seems to be '" << insert << "'" << oendl; 71 odebug << "preferred action for card '" << card->name() << "' seems to be '" << insert << "'" << oendl;
68 72
69 if ( !insert.isEmpty() ) 73 if ( !insert.isEmpty() )
70 { 74 {
71 for ( int i; i < cbAction->count(); ++i ) 75 for ( int i; i < cbAction->count(); ++i )
72 if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i ); 76 if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i );
73 } 77 }
74 78
79 if ( !card->isUnsupported() )
80 {
81 odebug << "card is recognized - hiding bindings" << oendl;
82 textBindTo->hide();
83 cbBindTo->hide();
84 return;
85 }
86 else
87 {
88 odebug << "card is unsupported yet - showing possible bindings" << oendl;
89 textBindTo->show();
90 cbBindTo->show();
91 }
92
75 // parse possible bind entries out of /etc/pcmcia/*.conf 93 // parse possible bind entries out of /etc/pcmcia/*.conf
76 typedef QMap<QString,QString> StringMap; 94 typedef QMap<QString,QString> StringMap;
77 StringMap bindEntries; 95 StringMap bindEntries;
78 96
79 QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); 97 QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" );
80 98
81 for ( int i = 0; i < pcmciaconfdir.count(); ++i ) 99 for ( int i = 0; i < pcmciaconfdir.count(); ++i )
82 { 100 {
83 odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; 101 odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl;
84 QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); 102 QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] );
85 QFile conffile( conffilename ); 103 QFile conffile( conffilename );
86 if ( conffile.open( IO_ReadOnly ) ) 104 if ( conffile.open( IO_ReadOnly ) )
@@ -99,20 +117,20 @@ ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent )
99 ts.readLine(); 117 ts.readLine();
100 } 118 }
101 } 119 }
102 else 120 else
103 { 121 {
104 owarn << "couldn't open '" << conffile.name() << "' for reading" << oendl; 122 owarn << "couldn't open '" << conffile.name() << "' for reading" << oendl;
105 continue; 123 continue;
106 } 124 }
107 } 125 }
108 126
109 for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it ) 127 for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it )
110 { 128 {
111 odebug << "found device '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl; 129 odebug << "found binding '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl;
112 cbBindTo->insertItem( it.key() ); 130 cbBindTo->insertItem( it.key() );
113 } 131 }
114} 132}
115 133
116ConfigDialog::~ConfigDialog() 134ConfigDialog::~ConfigDialog()
117{ 135{
118} 136}