Diffstat (limited to 'noncore/applets/pcmcia/configdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/pcmcia/configdialog.cpp | 32 |
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 | |||
@@ -11,108 +11,126 @@ | |||
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
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> | ||
35 | using namespace Opie::Core; | 36 | using 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 | ||
44 | ConfigDialog::ConfigDialog( const QString& cardname, QWidget* parent ) | 46 | ConfigDialog::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 ) ) |
87 | { | 105 | { |
88 | QTextStream ts( &conffile ); | 106 | QTextStream ts( &conffile ); |
89 | while ( !ts.atEnd() ) | 107 | while ( !ts.atEnd() ) |
90 | { | 108 | { |
91 | QString word; | 109 | QString word; |
92 | ts >> word; | 110 | ts >> word; |
93 | if ( word == "bind" ) | 111 | if ( word == "bind" ) |
94 | { | 112 | { |
95 | word = ts.readLine(); | 113 | word = ts.readLine(); |
96 | bindEntries[ word.stripWhiteSpace() ] = conffilename; | 114 | bindEntries[ word.stripWhiteSpace() ] = conffilename; |
97 | continue; | 115 | continue; |
98 | } | 116 | } |
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 | ||
116 | ConfigDialog::~ConfigDialog() | 134 | ConfigDialog::~ConfigDialog() |
117 | { | 135 | { |
118 | } | 136 | } |