-rw-r--r-- | noncore/applets/pcmcia/configdialog.cpp | 55 | ||||
-rw-r--r-- | noncore/applets/pcmcia/configdialog.h | 7 | ||||
-rw-r--r-- | noncore/applets/pcmcia/configdialogbase.ui | 171 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.cpp | 69 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.h | 2 |
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 | |||
@@ -6,141 +6,172 @@ | |||
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
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 | #include <opie2/opcmciasystem.h> |
36 | using namespace Opie::Core; | 36 | using namespace Opie::Core; |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
40 | #include <qdir.h> | 40 | #include <qdir.h> |
41 | #include <qfile.h> | 41 | #include <qfile.h> |
42 | #include <qgroupbox.h> | 42 | #include <qgroupbox.h> |
43 | #include <qlabel.h> | 43 | #include <qlabel.h> |
44 | #include <qtextstream.h> | 44 | #include <qtextstream.h> |
45 | 45 | ||
46 | ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) | 46 | ConfigDialog::ConfigDialog( const OPcmciaSocket* card, QWidget* parent ) |
47 | :ConfigDialogBase( parent, "pcmcia config dialog", true ) | 47 | :ConfigDialogBase( parent, "pcmcia config dialog", true ) |
48 | { | 48 | { |
49 | gbDetails->setTitle( QString( "Details for card in socket #%1" ).arg( card->number() ) ); | 49 | gbDetails->setTitle( QString( "Details for card in socket #%1" ).arg( card->number() ) ); |
50 | txtCardName->setText( card->productIdentity().join( " " ) ); | 50 | txtCardName->setText( card->productIdentity().join( " " ) ); |
51 | txtManfid->setText( card->manufacturerIdentity() ); | 51 | txtManfid->setText( card->manufacturerIdentity() ); |
52 | txtFunction->setText( card->function() ); | 52 | txtFunction->setText( card->function() ); |
53 | 53 | ||
54 | QString action = preferredAction( card ); | 54 | QString insertAction = preferredAction( card, "insert" ); |
55 | QString resumeAction = preferredAction( card, "resume" ); | ||
55 | 56 | ||
56 | odebug << "preferred action for card '" << card->name() << "' seems to be '" << action << "'" << oendl; | 57 | odebug << "pcmcia: preferred insertion action for card '" << card->name() << "' seems to be '" << insertAction << "'" << oendl; |
58 | odebug << "pcmcia: preferred resume action for card '" << card->name() << "' seems to be '" << resumeAction << "'" << oendl; | ||
57 | 59 | ||
58 | if ( !action.isEmpty() ) | 60 | if ( !insertAction.isEmpty() ) |
59 | { | 61 | { |
60 | for ( int i; i < cbAction->count(); ++i ) | 62 | for ( int i; i < cbInsertAction->count(); ++i ) |
61 | if ( cbAction->text( i ) == action ) cbAction->setCurrentItem( i ); | 63 | if ( cbInsertAction->text( i ) == insertAction ) cbInsertAction->setCurrentItem( i ); |
64 | } | ||
65 | |||
66 | if ( !resumeAction.isEmpty() ) | ||
67 | { | ||
68 | for ( int i; i < cbResumeAction->count(); ++i ) | ||
69 | if ( cbResumeAction->text( i ) == resumeAction ) cbResumeAction->setCurrentItem( i ); | ||
62 | } | 70 | } |
63 | 71 | ||
64 | if ( !card->isUnsupported() ) | 72 | if ( !card->isUnsupported() ) |
65 | { | 73 | { |
66 | odebug << "card is recognized - hiding bindings" << oendl; | 74 | odebug << "pcmcia: card is recognized - hiding bindings" << oendl; |
67 | textInfo->hide(); | 75 | textInfo->hide(); |
68 | textBindTo->hide(); | 76 | textBindTo->hide(); |
69 | cbBindTo->hide(); | 77 | cbBindTo->hide(); |
70 | return; | 78 | return; |
71 | } | 79 | } |
72 | else | 80 | else |
73 | { | 81 | { |
74 | odebug << "card is unsupported yet - showing possible bindings" << oendl; | 82 | odebug << "card is unsupported yet - showing possible bindings" << oendl; |
75 | textInfo->show(); | 83 | textInfo->show(); |
76 | textBindTo->show(); | 84 | textBindTo->show(); |
77 | cbBindTo->show(); | 85 | cbBindTo->show(); |
78 | } | 86 | } |
79 | 87 | ||
80 | // parse possible bind entries out of /etc/pcmcia/*.conf | 88 | // parse possible bind entries out of /etc/pcmcia/*.conf |
81 | typedef QMap<QString,QString> StringMap; | ||
82 | StringMap bindEntries; | ||
83 | |||
84 | QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); | 89 | QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); |
85 | 90 | ||
86 | for ( unsigned int i = 0; i < pcmciaconfdir.count(); ++i ) | 91 | for ( unsigned int i = 0; i < pcmciaconfdir.count(); ++i ) |
87 | { | 92 | { |
88 | odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; | 93 | odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; |
89 | QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); | 94 | QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); |
90 | QFile conffile( conffilename ); | 95 | QFile conffile( conffilename ); |
91 | if ( conffile.open( IO_ReadOnly ) ) | 96 | if ( conffile.open( IO_ReadOnly ) ) |
92 | { | 97 | { |
93 | QTextStream ts( &conffile ); | 98 | QTextStream ts( &conffile ); |
94 | while ( !ts.atEnd() ) | 99 | while ( !ts.atEnd() ) |
95 | { | 100 | { |
96 | QString word; | 101 | QString word; |
97 | ts >> word; | 102 | ts >> word; |
98 | if ( word == "bind" ) | 103 | if ( word == "bind" ) |
99 | { | 104 | { |
100 | word = ts.readLine(); | 105 | word = ts.readLine(); |
101 | bindEntries[ word.stripWhiteSpace() ] = conffilename; | 106 | bindEntries[ word.stripWhiteSpace() ] = conffilename; |
102 | continue; | 107 | continue; |
103 | } | 108 | } |
104 | ts.readLine(); | 109 | ts.readLine(); |
105 | } | 110 | } |
106 | } | 111 | } |
107 | else | 112 | else |
108 | { | 113 | { |
109 | owarn << "couldn't open '" << conffile.name() << "' for reading" << oendl; | 114 | owarn << "couldn't open '" << conffile.name() << "' for reading" << oendl; |
110 | continue; | 115 | continue; |
111 | } | 116 | } |
112 | } | 117 | } |
113 | 118 | ||
114 | for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it ) | 119 | for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it ) |
115 | { | 120 | { |
116 | odebug << "found binding '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl; | 121 | odebug << "found binding '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl; |
117 | cbBindTo->insertItem( it.key() ); | 122 | cbBindTo->insertItem( it.key() ); |
118 | } | 123 | } |
119 | } | 124 | } |
120 | 125 | ||
121 | ConfigDialog::~ConfigDialog() | 126 | ConfigDialog::~ConfigDialog() |
122 | { | 127 | { |
123 | } | 128 | } |
124 | 129 | ||
125 | QString ConfigDialog::preferredAction( const OPcmciaSocket* card ) | 130 | void ConfigDialog::writeConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& value ) |
126 | { | 131 | { |
127 | OConfig cfg( "PCMCIA" ); | 132 | OConfig cfg( "PCMCIA" ); |
128 | cfg.setGroup( "Global" ); | 133 | cfg.setGroup( "Global" ); |
129 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 134 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
130 | QString action; | 135 | QString action; |
131 | 136 | ||
132 | for ( int i = 0; i < nCards; ++i ) | 137 | for ( int i = 0; i < nCards; ++i ) |
133 | { | 138 | { |
134 | QString cardSection = QString( "Card_%1" ).arg( i ); | 139 | QString cardSection = QString( "Card_%1" ).arg( i ); |
135 | cfg.setGroup( cardSection ); | 140 | cfg.setGroup( cardSection ); |
136 | QString name = cfg.readEntry( "name" ); | 141 | QString name = cfg.readEntry( "name" ); |
137 | odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; | 142 | odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; |
138 | if ( card->name() == name ) | 143 | if ( card->name() == name ) |
139 | { | 144 | { |
140 | action = cfg.readEntry( "action" ); | 145 | cfg.writeEntry( key, value ); |
141 | break; | 146 | break; |
142 | } | 147 | } |
143 | } | 148 | } |
149 | } | ||
144 | 150 | ||
145 | return action; | 151 | QString ConfigDialog::readConfigEntry( const OPcmciaSocket* card, const QString& key, const QString& defaultValue ) |
152 | { | ||
153 | OConfig cfg( "PCMCIA" ); | ||
154 | cfg.setGroup( "Global" ); | ||
155 | int nCards = cfg.readNumEntry( "nCards", 0 ); | ||
156 | QString value; | ||
157 | |||
158 | for ( int i = 0; i < nCards; ++i ) | ||
159 | { | ||
160 | QString cardSection = QString( "Card_%1" ).arg( i ); | ||
161 | cfg.setGroup( cardSection ); | ||
162 | QString name = cfg.readEntry( "name" ); | ||
163 | odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; | ||
164 | if ( card->name() == name ) | ||
165 | { | ||
166 | value = cfg.readEntry( key, defaultValue ); | ||
167 | break; | ||
168 | } | ||
169 | } | ||
170 | return value; | ||
171 | } | ||
172 | |||
173 | |||
174 | QString ConfigDialog::preferredAction( const OPcmciaSocket* card, const QString& type ) | ||
175 | { | ||
176 | return ConfigDialog::readConfigEntry( card, QString( "%1Action" ).arg( type ), "suspend" ); | ||
146 | } | 177 | } |
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 | |||
@@ -1,46 +1,51 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | .=l. | 4 | .=l. |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
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 | #ifndef CONFIGDIALOG_H | 30 | #ifndef CONFIGDIALOG_H |
31 | #define CONFIGDIALOG_H | 31 | #define CONFIGDIALOG_H |
32 | 32 | ||
33 | #include "configdialogbase.h" | 33 | #include "configdialogbase.h" |
34 | 34 | ||
35 | namespace Opie { namespace Core { class OPcmciaSocket; }; }; | 35 | namespace Opie { namespace Core { class OPcmciaSocket; }; }; |
36 | 36 | ||
37 | typedef QMap<QString,QString> StringMap; | ||
38 | |||
37 | class ConfigDialog : public ConfigDialogBase | 39 | class ConfigDialog : public ConfigDialogBase |
38 | { | 40 | { |
39 | Q_OBJECT | 41 | Q_OBJECT |
40 | public: | 42 | public: |
41 | ConfigDialog( const Opie::Core::OPcmciaSocket* card, QWidget* parent ); | 43 | ConfigDialog( const Opie::Core::OPcmciaSocket* card, QWidget* parent ); |
42 | ~ConfigDialog(); | 44 | ~ConfigDialog(); |
43 | static QString preferredAction( const Opie::Core::OPcmciaSocket* card ); | 45 | static QString preferredAction( const Opie::Core::OPcmciaSocket* card, const QString& type ); |
46 | static QString readConfigEntry( const Opie::Core::OPcmciaSocket* card, const QString& key, const QString& defaultValue ); | ||
47 | static void writeConfigEntry( const Opie::Core::OPcmciaSocket* card, const QString& key, const QString& value ); | ||
48 | StringMap bindEntries; | ||
44 | }; | 49 | }; |
45 | 50 | ||
46 | #endif | 51 | #endif |
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 | |||
@@ -1,79 +1,79 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>ConfigDialogBase</class> | 2 | <class>ConfigDialogBase</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QDialog</class> | 4 | <class>QDialog</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>ConfigDialogBase</cstring> | 7 | <cstring>ConfigDialogBase</cstring> |
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>215</width> | 14 | <width>211</width> |
15 | <height>329</height> | 15 | <height>329</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
19 | <name>caption</name> | 19 | <name>caption</name> |
20 | <string>Configure PCMCIA/CF Card</string> | 20 | <string>Configure PCMCIA/CF Card</string> |
21 | </property> | 21 | </property> |
22 | <property> | 22 | <property> |
23 | <name>layoutMargin</name> | 23 | <name>layoutMargin</name> |
24 | </property> | 24 | </property> |
25 | <property> | 25 | <property> |
26 | <name>layoutSpacing</name> | 26 | <name>layoutSpacing</name> |
27 | </property> | 27 | </property> |
28 | <grid> | 28 | <grid> |
29 | <property stdset="1"> | 29 | <property stdset="1"> |
30 | <name>margin</name> | 30 | <name>margin</name> |
31 | <number>5</number> | 31 | <number>6</number> |
32 | </property> | 32 | </property> |
33 | <property stdset="1"> | 33 | <property stdset="1"> |
34 | <name>spacing</name> | 34 | <name>spacing</name> |
35 | <number>2</number> | 35 | <number>2</number> |
36 | </property> | 36 | </property> |
37 | <widget row="0" column="0" rowspan="1" colspan="3" > | 37 | <widget row="0" column="0" rowspan="1" colspan="3" > |
38 | <class>QGroupBox</class> | 38 | <class>QGroupBox</class> |
39 | <property stdset="1"> | 39 | <property stdset="1"> |
40 | <name>name</name> | 40 | <name>name</name> |
41 | <cstring>gbDetails</cstring> | 41 | <cstring>gbDetails</cstring> |
42 | </property> | 42 | </property> |
43 | <property stdset="1"> | 43 | <property stdset="1"> |
44 | <name>title</name> | 44 | <name>title</name> |
45 | <string>Details</string> | 45 | <string>Details</string> |
46 | </property> | 46 | </property> |
47 | <property> | 47 | <property> |
48 | <name>layoutMargin</name> | 48 | <name>layoutMargin</name> |
49 | </property> | 49 | </property> |
50 | <property> | 50 | <property> |
51 | <name>layoutSpacing</name> | 51 | <name>layoutSpacing</name> |
52 | </property> | 52 | </property> |
53 | <grid> | 53 | <grid> |
54 | <property stdset="1"> | 54 | <property stdset="1"> |
55 | <name>margin</name> | 55 | <name>margin</name> |
56 | <number>6</number> | 56 | <number>6</number> |
57 | </property> | 57 | </property> |
58 | <property stdset="1"> | 58 | <property stdset="1"> |
59 | <name>spacing</name> | 59 | <name>spacing</name> |
60 | <number>4</number> | 60 | <number>4</number> |
61 | </property> | 61 | </property> |
62 | <widget row="0" column="0" > | 62 | <widget row="0" column="0" > |
63 | <class>QLabel</class> | 63 | <class>QLabel</class> |
64 | <property stdset="1"> | 64 | <property stdset="1"> |
65 | <name>name</name> | 65 | <name>name</name> |
66 | <cstring>labelCardName</cstring> | 66 | <cstring>labelCardName</cstring> |
67 | </property> | 67 | </property> |
68 | <property stdset="1"> | 68 | <property stdset="1"> |
69 | <name>text</name> | 69 | <name>text</name> |
70 | <string>CardName:</string> | 70 | <string>CardName:</string> |
71 | </property> | 71 | </property> |
72 | </widget> | 72 | </widget> |
73 | <widget row="2" column="0" > | 73 | <widget row="2" column="0" > |
74 | <class>QLabel</class> | 74 | <class>QLabel</class> |
75 | <property stdset="1"> | 75 | <property stdset="1"> |
76 | <name>name</name> | 76 | <name>name</name> |
77 | <cstring>labelFunction</cstring> | 77 | <cstring>labelFunction</cstring> |
78 | </property> | 78 | </property> |
79 | <property stdset="1"> | 79 | <property stdset="1"> |
@@ -103,195 +103,248 @@ | |||
103 | <sizepolicy> | 103 | <sizepolicy> |
104 | <hsizetype>7</hsizetype> | 104 | <hsizetype>7</hsizetype> |
105 | <vsizetype>1</vsizetype> | 105 | <vsizetype>1</vsizetype> |
106 | </sizepolicy> | 106 | </sizepolicy> |
107 | </property> | 107 | </property> |
108 | <property stdset="1"> | 108 | <property stdset="1"> |
109 | <name>text</name> | 109 | <name>text</name> |
110 | <string>TextLabel6</string> | 110 | <string>TextLabel6</string> |
111 | </property> | 111 | </property> |
112 | </widget> | 112 | </widget> |
113 | <widget row="2" column="1" > | 113 | <widget row="2" column="1" > |
114 | <class>QLabel</class> | 114 | <class>QLabel</class> |
115 | <property stdset="1"> | 115 | <property stdset="1"> |
116 | <name>name</name> | 116 | <name>name</name> |
117 | <cstring>txtFunction</cstring> | 117 | <cstring>txtFunction</cstring> |
118 | </property> | 118 | </property> |
119 | <property stdset="1"> | 119 | <property stdset="1"> |
120 | <name>sizePolicy</name> | 120 | <name>sizePolicy</name> |
121 | <sizepolicy> | 121 | <sizepolicy> |
122 | <hsizetype>7</hsizetype> | 122 | <hsizetype>7</hsizetype> |
123 | <vsizetype>1</vsizetype> | 123 | <vsizetype>1</vsizetype> |
124 | </sizepolicy> | 124 | </sizepolicy> |
125 | </property> | 125 | </property> |
126 | <property stdset="1"> | 126 | <property stdset="1"> |
127 | <name>text</name> | 127 | <name>text</name> |
128 | <string>TextLabel7</string> | 128 | <string>TextLabel7</string> |
129 | </property> | 129 | </property> |
130 | </widget> | 130 | </widget> |
131 | <widget row="0" column="1" > | 131 | <widget row="0" column="1" > |
132 | <class>QLabel</class> | 132 | <class>QLabel</class> |
133 | <property stdset="1"> | 133 | <property stdset="1"> |
134 | <name>name</name> | 134 | <name>name</name> |
135 | <cstring>txtCardName</cstring> | 135 | <cstring>txtCardName</cstring> |
136 | </property> | 136 | </property> |
137 | <property stdset="1"> | 137 | <property stdset="1"> |
138 | <name>sizePolicy</name> | 138 | <name>sizePolicy</name> |
139 | <sizepolicy> | 139 | <sizepolicy> |
140 | <hsizetype>7</hsizetype> | 140 | <hsizetype>7</hsizetype> |
141 | <vsizetype>1</vsizetype> | 141 | <vsizetype>1</vsizetype> |
142 | </sizepolicy> | 142 | </sizepolicy> |
143 | </property> | 143 | </property> |
144 | <property stdset="1"> | 144 | <property stdset="1"> |
145 | <name>text</name> | 145 | <name>text</name> |
146 | <string>TextLabel3</string> | 146 | <string>TextLabel3</string> |
147 | </property> | 147 | </property> |
148 | </widget> | 148 | </widget> |
149 | </grid> | 149 | </grid> |
150 | </widget> | 150 | </widget> |
151 | <widget row="1" column="0" > | 151 | <widget row="5" column="0" > |
152 | <class>QLabel</class> | ||
153 | <property stdset="1"> | ||
154 | <name>name</name> | ||
155 | <cstring>TextLabel2</cstring> | ||
156 | </property> | ||
157 | <property stdset="1"> | ||
158 | <name>text</name> | ||
159 | <string>On insertion,</string> | ||
160 | </property> | ||
161 | </widget> | ||
162 | <widget row="1" column="1" > | ||
163 | <class>QComboBox</class> | ||
164 | <item> | ||
165 | <property> | ||
166 | <name>text</name> | ||
167 | <string>suspend</string> | ||
168 | </property> | ||
169 | </item> | ||
170 | <item> | ||
171 | <property> | ||
172 | <name>text</name> | ||
173 | <string>activate</string> | ||
174 | </property> | ||
175 | </item> | ||
176 | <item> | ||
177 | <property> | ||
178 | <name>text</name> | ||
179 | <string>eject</string> | ||
180 | </property> | ||
181 | </item> | ||
182 | <item> | ||
183 | <property> | ||
184 | <name>text</name> | ||
185 | <string>prompt for</string> | ||
186 | </property> | ||
187 | </item> | ||
188 | <property stdset="1"> | ||
189 | <name>name</name> | ||
190 | <cstring>cbAction</cstring> | ||
191 | </property> | ||
192 | </widget> | ||
193 | <widget row="1" column="2" > | ||
194 | <class>QLabel</class> | ||
195 | <property stdset="1"> | ||
196 | <name>name</name> | ||
197 | <cstring>TextLabel3</cstring> | ||
198 | </property> | ||
199 | <property stdset="1"> | ||
200 | <name>text</name> | ||
201 | <string>card</string> | ||
202 | </property> | ||
203 | </widget> | ||
204 | <widget row="4" column="0" > | ||
205 | <class>QLabel</class> | 152 | <class>QLabel</class> |
206 | <property stdset="1"> | 153 | <property stdset="1"> |
207 | <name>name</name> | 154 | <name>name</name> |
208 | <cstring>textBindTo</cstring> | 155 | <cstring>textBindTo</cstring> |
209 | </property> | 156 | </property> |
210 | <property stdset="1"> | 157 | <property stdset="1"> |
211 | <name>text</name> | 158 | <name>text</name> |
212 | <string>Bind to:</string> | 159 | <string>Bind to:</string> |
213 | </property> | 160 | </property> |
214 | </widget> | 161 | </widget> |
215 | <widget row="4" column="1" rowspan="1" colspan="2" > | 162 | <widget row="5" column="1" rowspan="1" colspan="2" > |
216 | <class>QComboBox</class> | 163 | <class>QComboBox</class> |
217 | <item> | 164 | <item> |
218 | <property> | 165 | <property> |
219 | <name>text</name> | 166 | <name>text</name> |
220 | <string><None></string> | 167 | <string><None></string> |
221 | </property> | 168 | </property> |
222 | </item> | 169 | </item> |
223 | <property stdset="1"> | 170 | <property stdset="1"> |
224 | <name>name</name> | 171 | <name>name</name> |
225 | <cstring>cbBindTo</cstring> | 172 | <cstring>cbBindTo</cstring> |
226 | </property> | 173 | </property> |
227 | <property stdset="1"> | 174 | <property stdset="1"> |
228 | <name>sizePolicy</name> | 175 | <name>sizePolicy</name> |
229 | <sizepolicy> | 176 | <sizepolicy> |
230 | <hsizetype>5</hsizetype> | 177 | <hsizetype>5</hsizetype> |
231 | <vsizetype>0</vsizetype> | 178 | <vsizetype>0</vsizetype> |
232 | </sizepolicy> | 179 | </sizepolicy> |
233 | </property> | 180 | </property> |
234 | <property stdset="1"> | 181 | <property stdset="1"> |
235 | <name>editable</name> | 182 | <name>editable</name> |
236 | <bool>true</bool> | 183 | <bool>true</bool> |
237 | </property> | 184 | </property> |
238 | <property stdset="1"> | 185 | <property stdset="1"> |
239 | <name>currentItem</name> | 186 | <name>currentItem</name> |
240 | <number>0</number> | 187 | <number>0</number> |
241 | </property> | 188 | </property> |
242 | <property stdset="1"> | 189 | <property stdset="1"> |
243 | <name>autoResize</name> | 190 | <name>autoResize</name> |
244 | <bool>false</bool> | 191 | <bool>false</bool> |
245 | </property> | 192 | </property> |
246 | </widget> | 193 | </widget> |
247 | <widget row="3" column="0" rowspan="1" colspan="3" > | 194 | <widget row="4" column="0" rowspan="1" colspan="3" > |
248 | <class>QLabel</class> | 195 | <class>QLabel</class> |
249 | <property stdset="1"> | 196 | <property stdset="1"> |
250 | <name>name</name> | 197 | <name>name</name> |
251 | <cstring>textInfo</cstring> | 198 | <cstring>textInfo</cstring> |
252 | </property> | 199 | </property> |
253 | <property stdset="1"> | 200 | <property stdset="1"> |
254 | <name>frameShape</name> | 201 | <name>frameShape</name> |
255 | <enum>Box</enum> | 202 | <enum>Box</enum> |
256 | </property> | 203 | </property> |
257 | <property stdset="1"> | 204 | <property stdset="1"> |
258 | <name>frameShadow</name> | 205 | <name>frameShadow</name> |
259 | <enum>Raised</enum> | 206 | <enum>Raised</enum> |
260 | </property> | 207 | </property> |
261 | <property stdset="1"> | 208 | <property stdset="1"> |
262 | <name>lineWidth</name> | 209 | <name>lineWidth</name> |
263 | <number>2</number> | 210 | <number>2</number> |
264 | </property> | 211 | </property> |
265 | <property stdset="1"> | 212 | <property stdset="1"> |
266 | <name>margin</name> | 213 | <name>margin</name> |
267 | <number>0</number> | 214 | <number>0</number> |
268 | </property> | 215 | </property> |
269 | <property stdset="1"> | 216 | <property stdset="1"> |
270 | <name>text</name> | 217 | <name>text</name> |
271 | <string><qt>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:</qt></string> | 218 | <string><qt>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:</qt></string> |
272 | </property> | 219 | </property> |
273 | </widget> | 220 | </widget> |
274 | <spacer row="2" column="1" > | 221 | <widget row="1" column="0" > |
222 | <class>QLabel</class> | ||
223 | <property stdset="1"> | ||
224 | <name>name</name> | ||
225 | <cstring>TextLabel2</cstring> | ||
226 | </property> | ||
227 | <property stdset="1"> | ||
228 | <name>text</name> | ||
229 | <string>On insertion,</string> | ||
230 | </property> | ||
231 | </widget> | ||
232 | <widget row="1" column="2" > | ||
233 | <class>QLabel</class> | ||
234 | <property stdset="1"> | ||
235 | <name>name</name> | ||
236 | <cstring>TextLabel3</cstring> | ||
237 | </property> | ||
238 | <property stdset="1"> | ||
239 | <name>text</name> | ||
240 | <string>card</string> | ||
241 | </property> | ||
242 | </widget> | ||
243 | <widget row="2" column="0" > | ||
244 | <class>QLabel</class> | ||
245 | <property stdset="1"> | ||
246 | <name>name</name> | ||
247 | <cstring>TextLabel2_2</cstring> | ||
248 | </property> | ||
249 | <property stdset="1"> | ||
250 | <name>text</name> | ||
251 | <string>On resume,</string> | ||
252 | </property> | ||
253 | </widget> | ||
254 | <widget row="2" column="2" > | ||
255 | <class>QLabel</class> | ||
256 | <property stdset="1"> | ||
257 | <name>name</name> | ||
258 | <cstring>TextLabel3_2</cstring> | ||
259 | </property> | ||
260 | <property stdset="1"> | ||
261 | <name>text</name> | ||
262 | <string>card</string> | ||
263 | </property> | ||
264 | </widget> | ||
265 | <spacer row="3" column="1" > | ||
275 | <property> | 266 | <property> |
276 | <name>name</name> | 267 | <name>name</name> |
277 | <cstring>Spacer2</cstring> | 268 | <cstring>Spacer2</cstring> |
278 | </property> | 269 | </property> |
279 | <property stdset="1"> | 270 | <property stdset="1"> |
280 | <name>orientation</name> | 271 | <name>orientation</name> |
281 | <enum>Vertical</enum> | 272 | <enum>Vertical</enum> |
282 | </property> | 273 | </property> |
283 | <property stdset="1"> | 274 | <property stdset="1"> |
284 | <name>sizeType</name> | 275 | <name>sizeType</name> |
285 | <enum>Expanding</enum> | 276 | <enum>Expanding</enum> |
286 | </property> | 277 | </property> |
287 | <property> | 278 | <property> |
288 | <name>sizeHint</name> | 279 | <name>sizeHint</name> |
289 | <size> | 280 | <size> |
290 | <width>20</width> | 281 | <width>20</width> |
291 | <height>20</height> | 282 | <height>20</height> |
292 | </size> | 283 | </size> |
293 | </property> | 284 | </property> |
294 | </spacer> | 285 | </spacer> |
286 | <widget row="1" column="1" > | ||
287 | <class>QComboBox</class> | ||
288 | <item> | ||
289 | <property> | ||
290 | <name>text</name> | ||
291 | <string>suspend</string> | ||
292 | </property> | ||
293 | </item> | ||
294 | <item> | ||
295 | <property> | ||
296 | <name>text</name> | ||
297 | <string>activate</string> | ||
298 | </property> | ||
299 | </item> | ||
300 | <item> | ||
301 | <property> | ||
302 | <name>text</name> | ||
303 | <string>eject</string> | ||
304 | </property> | ||
305 | </item> | ||
306 | <item> | ||
307 | <property> | ||
308 | <name>text</name> | ||
309 | <string>prompt for</string> | ||
310 | </property> | ||
311 | </item> | ||
312 | <property stdset="1"> | ||
313 | <name>name</name> | ||
314 | <cstring>cbInsertAction</cstring> | ||
315 | </property> | ||
316 | </widget> | ||
317 | <widget row="2" column="1" > | ||
318 | <class>QComboBox</class> | ||
319 | <item> | ||
320 | <property> | ||
321 | <name>text</name> | ||
322 | <string>suspend</string> | ||
323 | </property> | ||
324 | </item> | ||
325 | <item> | ||
326 | <property> | ||
327 | <name>text</name> | ||
328 | <string>activate</string> | ||
329 | </property> | ||
330 | </item> | ||
331 | <item> | ||
332 | <property> | ||
333 | <name>text</name> | ||
334 | <string>eject</string> | ||
335 | </property> | ||
336 | </item> | ||
337 | <item> | ||
338 | <property> | ||
339 | <name>text</name> | ||
340 | <string>prompt for</string> | ||
341 | </property> | ||
342 | </item> | ||
343 | <property stdset="1"> | ||
344 | <name>name</name> | ||
345 | <cstring>cbResumeAction</cstring> | ||
346 | </property> | ||
347 | </widget> | ||
295 | </grid> | 348 | </grid> |
296 | </widget> | 349 | </widget> |
297 | </UI> | 350 | </UI> |
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 | |||
@@ -1,94 +1,96 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | .=l. | 4 | .=l. |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
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 "pcmcia.h" | 30 | #include "pcmcia.h" |
31 | #include "configdialog.h" | 31 | #include "configdialog.h" |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
35 | #include <opie2/odevice.h> | 35 | #include <opie2/odevice.h> |
36 | #include <opie2/oconfig.h> | 36 | #include <opie2/oconfig.h> |
37 | #include <opie2/oprocess.h> | 37 | #include <opie2/oprocess.h> |
38 | #include <opie2/opcmciasystem.h> | 38 | #include <opie2/opcmciasystem.h> |
39 | #include <opie2/oresource.h> | 39 | #include <opie2/oresource.h> |
40 | #include <opie2/otaskbarapplet.h> | 40 | #include <opie2/otaskbarapplet.h> |
41 | #include <qpe/applnk.h> | 41 | #include <qpe/applnk.h> |
42 | #include <qpe/global.h> | ||
42 | #include <qpe/resource.h> | 43 | #include <qpe/resource.h> |
43 | using namespace Opie::Core; | 44 | using namespace Opie::Core; |
44 | using namespace Opie::Ui; | 45 | using namespace Opie::Ui; |
45 | 46 | ||
46 | /* QT */ | 47 | /* QT */ |
48 | #include <qcombobox.h> | ||
47 | #include <qcopchannel_qws.h> | 49 | #include <qcopchannel_qws.h> |
48 | #include <qpainter.h> | 50 | #include <qpainter.h> |
49 | #include <qfile.h> | 51 | #include <qfile.h> |
50 | #include <qtextstream.h> | 52 | #include <qtextstream.h> |
51 | #include <qmessagebox.h> | 53 | #include <qmessagebox.h> |
52 | #include <qsound.h> | 54 | #include <qsound.h> |
53 | #include <qtimer.h> | 55 | #include <qtimer.h> |
54 | 56 | ||
55 | /* STD */ | 57 | /* STD */ |
56 | #include <stdio.h> | 58 | #include <stdio.h> |
57 | #include <unistd.h> | 59 | #include <unistd.h> |
58 | #include <stdlib.h> | 60 | #include <stdlib.h> |
59 | #include <string.h> | 61 | #include <string.h> |
60 | #include <errno.h> | 62 | #include <errno.h> |
61 | #include <fcntl.h> | 63 | #include <fcntl.h> |
62 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 64 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
63 | #include <sys/vfs.h> | 65 | #include <sys/vfs.h> |
64 | #include <mntent.h> | 66 | #include <mntent.h> |
65 | #endif | 67 | #endif |
66 | 68 | ||
67 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) | 69 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) |
68 | { | 70 | { |
69 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 71 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
70 | connect( pcmciaChannel, | 72 | connect( pcmciaChannel, |
71 | SIGNAL( received(const QCString&,const QByteArray&) ), this, | 73 | SIGNAL( received(const QCString&,const QByteArray&) ), this, |
72 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); | 74 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); |
73 | 75 | ||
74 | setFocusPolicy( NoFocus ); | 76 | setFocusPolicy( NoFocus ); |
75 | setFixedWidth ( AppLnk::smallIconSize() ); | 77 | setFixedWidth ( AppLnk::smallIconSize() ); |
76 | setFixedHeight ( AppLnk::smallIconSize() ); | 78 | setFixedHeight ( AppLnk::smallIconSize() ); |
77 | pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ); | 79 | pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ); |
78 | configuring = false; | 80 | configuring = false; |
79 | } | 81 | } |
80 | 82 | ||
81 | 83 | ||
82 | PcmciaManager::~PcmciaManager() | 84 | PcmciaManager::~PcmciaManager() |
83 | { | 85 | { |
84 | } | 86 | } |
85 | 87 | ||
86 | 88 | ||
87 | void PcmciaManager::popUp( QString message, QString icon ) | 89 | void PcmciaManager::popUp( QString message, QString icon ) |
88 | { | 90 | { |
89 | if ( !popupMenu ) { | 91 | if ( !popupMenu ) { |
90 | popupMenu = new QPopupMenu( this ); | 92 | popupMenu = new QPopupMenu( this ); |
91 | } | 93 | } |
92 | 94 | ||
93 | popupMenu->clear(); | 95 | popupMenu->clear(); |
94 | if ( icon.isEmpty() ) { | 96 | if ( icon.isEmpty() ) { |
@@ -133,178 +135,215 @@ void PcmciaManager::mousePressEvent( QMouseEvent* ) | |||
133 | submenu->insertItem( "&Suspend", SUSPEND+i*100 ); | 135 | submenu->insertItem( "&Suspend", SUSPEND+i*100 ); |
134 | submenu->insertItem( "&Resume", RESUME+i*100 ); | 136 | submenu->insertItem( "&Resume", RESUME+i*100 ); |
135 | submenu->insertItem( "Rese&t", RESET+i*100 ); | 137 | submenu->insertItem( "Rese&t", RESET+i*100 ); |
136 | submenu->insertItem( "&Configure", CONFIGURE+i*100 ); | 138 | submenu->insertItem( "&Configure", CONFIGURE+i*100 ); |
137 | 139 | ||
138 | submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); | 140 | submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); |
139 | submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); | 141 | submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); |
140 | submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); | 142 | submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); |
141 | submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); | 143 | submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); |
142 | submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() && !configuring ); | 144 | submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() && !configuring ); |
143 | 145 | ||
144 | connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); | 146 | connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); |
145 | menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); | 147 | menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); |
146 | ++it; | 148 | ++it; |
147 | } | 149 | } |
148 | 150 | ||
149 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 151 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
150 | QSize s = menu->sizeHint(); | 152 | QSize s = menu->sizeHint(); |
151 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); | 153 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); |
152 | qDebug( "pcmcia: menu result = %d", opt ); | 154 | qDebug( "pcmcia: menu result = %d", opt ); |
153 | delete menu; | 155 | delete menu; |
154 | } | 156 | } |
155 | 157 | ||
156 | 158 | ||
157 | void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | 159 | void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) |
158 | { | 160 | { |
159 | odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl; | 161 | odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl; |
160 | if ( msg != "stabChanged()" ) return; | 162 | if ( msg != "stabChanged()" ) return; |
161 | 163 | ||
162 | /* check if a previously unknown card has been inserted */ | 164 | /* check if a previously unknown card has been inserted */ |
163 | OPcmciaSystem::instance()->synchronize(); | 165 | OPcmciaSystem::instance()->synchronize(); |
164 | 166 | ||
165 | if ( !OPcmciaSystem::instance()->cardCount() ) return; | 167 | if ( !OPcmciaSystem::instance()->cardCount() ) return; |
166 | 168 | ||
167 | OConfig cfg( "PCMCIA" ); | 169 | OConfig cfg( "PCMCIA" ); |
168 | cfg.setGroup( "Global" ); | 170 | cfg.setGroup( "Global" ); |
169 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 171 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
170 | 172 | ||
171 | OPcmciaSystem* sys = OPcmciaSystem::instance(); | 173 | OPcmciaSystem* sys = OPcmciaSystem::instance(); |
172 | OPcmciaSystem::CardIterator it = sys->iterator(); | 174 | OPcmciaSystem::CardIterator it = sys->iterator(); |
173 | 175 | ||
174 | bool newCard = true; | 176 | bool newCard = true; |
175 | OPcmciaSocket* theCard = 0; | 177 | OPcmciaSocket* theCard = 0; |
176 | 178 | ||
177 | while ( it.current() && newCard ) | 179 | while ( it.current() && newCard ) |
178 | { | 180 | { |
179 | if ( it.current()->isEmpty() ) | 181 | if ( it.current()->isEmpty() ) |
180 | { | 182 | { |
181 | odebug << "skipping empty card in socket " << it.current()->number() << oendl; | 183 | odebug << "pcmcia: skipping empty card in socket " << it.current()->number() << oendl; |
182 | ++it; | 184 | ++it; |
183 | continue; | 185 | continue; |
184 | } | 186 | } |
185 | else | 187 | else |
186 | { | 188 | { |
187 | theCard = it.current(); | 189 | theCard = it.current(); |
188 | QString cardName = theCard->productIdentity().join( " " ); | 190 | QString cardName = theCard->productIdentity().join( " " ); |
189 | for ( int i = 0; i < nCards; ++i ) | 191 | for ( int i = 0; i < nCards; ++i ) |
190 | { | 192 | { |
191 | QString cardSection = QString( "Card_%1" ).arg( i ); | 193 | QString cardSection = QString( "Card_%1" ).arg( i ); |
192 | cfg.setGroup( cardSection ); | 194 | cfg.setGroup( cardSection ); |
193 | QString name = cfg.readEntry( "name" ); | 195 | QString name = cfg.readEntry( "name" ); |
194 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; | 196 | odebug << "pcmcia: comparing card '" << cardName << "' with known card '" << name << "'" << oendl; |
195 | if ( cardName == name ) | 197 | if ( cardName == name ) |
196 | { | 198 | { |
197 | newCard = false; | 199 | newCard = false; |
198 | break; | 200 | break; |
199 | } | 201 | } |
200 | } | 202 | } |
201 | if ( !newCard ) ++it; else break; | 203 | if ( !newCard ) ++it; else break; |
202 | } | 204 | } |
203 | } | 205 | } |
204 | if ( newCard ) | 206 | if ( newCard ) |
205 | { | 207 | { |
206 | odebug << "pcmcia: unconfigured card detected" << oendl; | 208 | odebug << "pcmcia: unconfigured card detected" << oendl; |
207 | QString newCardName = theCard->productIdentity().join( " " ).stripWhiteSpace(); | 209 | QString newCardName = theCard->productIdentity().join( " " ).stripWhiteSpace(); |
208 | int result = QMessageBox::information( qApp->desktop(), | 210 | int result = QMessageBox::information( qApp->desktop(), |
209 | tr( "PCMCIA/CF Subsystem" ), | 211 | tr( "PCMCIA/CF Subsystem" ), |
210 | tr( "<qt>You have inserted the card '%1'. This card is not yet configured. Do you want to configure it now?</qt>" ).arg( newCardName ), | 212 | 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 ), |
211 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ); | 213 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ); |
212 | odebug << "result = " << result << oendl; | 214 | odebug << "pcmcia: result = " << result << oendl; |
213 | if ( result == 0 ) | 215 | if ( result == 0 ) |
214 | { | 216 | { |
215 | bool configured = configure( theCard ); | 217 | QString insertAction; QString resumeAction; QString driver; QString conf; |
218 | bool configured = configure( theCard, insertAction, resumeAction, driver, conf ); | ||
216 | 219 | ||
217 | if ( configured ) | 220 | if ( configured ) |
218 | { | 221 | { |
219 | odebug << "card has been configured. writing out to dabase" << oendl; | 222 | odebug << "pcmcia: card has been configured. writing out to database" << oendl; |
220 | cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); | 223 | cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); |
221 | cfg.writeEntry( "name", newCardName ); | 224 | cfg.writeEntry( "name", newCardName ); |
222 | cfg.writeEntry( "insert", "suspend" ); | 225 | cfg.writeEntry( "insertAction", insertAction ); |
226 | cfg.writeEntry( "resumeAction", resumeAction ); | ||
223 | cfg.setGroup( "Global" ); | 227 | cfg.setGroup( "Global" ); |
224 | cfg.writeEntry( "nCards", nCards+1 ); | 228 | cfg.writeEntry( "nCards", nCards+1 ); |
225 | cfg.write(); | 229 | cfg.write(); |
230 | |||
231 | QFile confFile( QString( "/etc/pcmcia/%1" ).arg( conf ) ); | ||
232 | if ( confFile.open( IO_ReadWrite | IO_Append ) ) | ||
233 | { | ||
234 | QString entryCard = QString( "card \"%1\"" ).arg( newCardName ); | ||
235 | QString entryVersion( " version " ); | ||
236 | for ( QStringList::Iterator it = theCard->productIdentity().begin(); it != theCard->productIdentity().end(); ++it ) | ||
237 | { | ||
238 | entryVersion += QString( "\"%1\", " ).arg( *it ); | ||
239 | } | ||
240 | QString entryBind = QString( " bind %1" ).arg( driver ); | ||
241 | QString entry = QString( "\n%1\n%2\n%3\n" ).arg( entryCard ).arg( entryVersion ).arg( entryBind ); | ||
242 | odebug << "pcmcia: writing entry...:" << entry << oendl; | ||
243 | |||
244 | confFile.writeBlock( (const char*) entry, entry.length() ); | ||
245 | Global::statusMessage( "restarting pcmcia services..." ); | ||
246 | ::system( "/etc/init.d/pcmcia restart" ); | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | owarn << "pcmcia: couldn't write binding to '" << conf << "'." << oendl; | ||
251 | } | ||
226 | } | 252 | } |
227 | else | 253 | else |
228 | { | 254 | { |
229 | odebug << "card has not been configured this time. leaving as unknown card" << oendl; | 255 | odebug << "pcmcia: card has not been configured this time. leaving as unknown card" << oendl; |
230 | } | 256 | } |
231 | } | 257 | } |
232 | else | 258 | else |
233 | { | 259 | { |
234 | odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl; | 260 | odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl; |
235 | } | 261 | } |
236 | } | 262 | } |
237 | else // it's an already configured card | 263 | else // it's an already configured card |
238 | { | 264 | { |
239 | QString action = ConfigDialog::preferredAction( theCard ); | 265 | QString insertAction = ConfigDialog::preferredAction( theCard, "insert" ); |
240 | odebug << "pcmcia: card has been previously configured" << oendl; | 266 | odebug << "pcmcia: card has been previously configured" << oendl; |
241 | odebug << "pcmcia: need to perform action'" << action << "' now... sorry, not yet implemented..." << oendl; | 267 | odebug << "pcmcia: TODO: need to perform action'" << insertAction << "' now... sorry, not yet implemented..." << oendl; |
242 | } | 268 | } |
243 | repaint( true ); | 269 | repaint( true ); |
244 | } | 270 | } |
245 | 271 | ||
246 | 272 | ||
247 | void PcmciaManager::paintEvent( QPaintEvent * ) | 273 | void PcmciaManager::paintEvent( QPaintEvent * ) |
248 | { | 274 | { |
249 | QPainter p( this ); | 275 | QPainter p( this ); |
250 | odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl; | 276 | odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl; |
251 | 277 | ||
252 | if ( OPcmciaSystem::instance()->cardCount() ) | 278 | if ( OPcmciaSystem::instance()->cardCount() ) |
253 | { | 279 | { |
254 | p.drawPixmap( 0, 0, pm ); | 280 | p.drawPixmap( 0, 0, pm ); |
255 | show(); | 281 | show(); |
256 | } | 282 | } |
257 | else | 283 | else |
258 | { | 284 | { |
259 | hide(); | 285 | hide(); |
260 | } | 286 | } |
261 | } | 287 | } |
262 | 288 | ||
263 | int PcmciaManager::position() | 289 | int PcmciaManager::position() |
264 | { | 290 | { |
265 | return 7; | 291 | return 7; |
266 | } | 292 | } |
267 | 293 | ||
268 | void PcmciaManager::execCommand( const QStringList &strList ) | 294 | void PcmciaManager::execCommand( const QStringList &strList ) |
269 | { | 295 | { |
270 | } | 296 | } |
271 | 297 | ||
272 | void PcmciaManager::userCardAction( int action ) | 298 | void PcmciaManager::userCardAction( int action ) |
273 | { | 299 | { |
274 | odebug << "user action on socket " << action / 100 << " requested. action = " << action << oendl; | 300 | odebug << "pcmcia: user action on socket " << action / 100 << " requested. action = " << action << oendl; |
275 | 301 | ||
276 | int socket = action / 100; | 302 | int socket = action / 100; |
277 | int what = action % 100; | 303 | int what = action % 100; |
278 | bool success = false; | 304 | bool success = false; |
279 | 305 | ||
280 | switch ( what ) | 306 | switch ( what ) |
281 | { | 307 | { |
282 | case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); success = true; break; | 308 | case CONFIGURE: |
309 | { | ||
310 | QString insertAction; QString resumeAction; QString driver; QString conf; | ||
311 | bool result = configure( OPcmciaSystem::instance()->socket( socket ), insertAction, resumeAction, driver, conf ); | ||
312 | success = true; | ||
313 | break; | ||
314 | } | ||
283 | case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break; | 315 | case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break; |
284 | case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break; | 316 | case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break; |
285 | case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break; | 317 | case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break; |
286 | case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break; | 318 | case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break; |
287 | case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break; | 319 | case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break; |
288 | default: odebug << "not yet implemented" << oendl; | 320 | default: odebug << "pcmcia: not yet implemented" << oendl; |
289 | } | 321 | } |
290 | 322 | ||
291 | if ( !success ) | 323 | if ( !success ) |
292 | { | 324 | { |
293 | owarn << "couldn't perform user action (" << strerror( errno ) << ")" << oendl; | 325 | owarn << "pcmcia: couldn't perform user action (" << strerror( errno ) << ")" << oendl; |
294 | } | 326 | } |
295 | 327 | ||
296 | } | 328 | } |
297 | 329 | ||
298 | bool PcmciaManager::configure( OPcmciaSocket* card ) | 330 | bool PcmciaManager::configure( OPcmciaSocket* card, QString& insertAction, QString& resumeAction, QString& driver, QString& conf ) |
299 | { | 331 | { |
300 | configuring = true; | 332 | configuring = true; |
301 | ConfigDialog dialog( card, qApp->desktop() ); | 333 | ConfigDialog dialog( card, qApp->desktop() ); |
302 | int configresult = QPEApplication::execDialog( &dialog, false ); | 334 | int configresult = QPEApplication::execDialog( &dialog, false ); |
303 | configuring = false; | 335 | configuring = false; |
304 | odebug << "pcmcia: configresult = " << configresult << oendl; | 336 | odebug << "pcmcia: configresult = " << configresult << oendl; |
337 | if ( configresult ) | ||
338 | { | ||
339 | insertAction = dialog.cbInsertAction->currentText(); | ||
340 | resumeAction = dialog.cbResumeAction->currentText(); | ||
341 | driver = dialog.cbBindTo->currentText(); | ||
342 | conf = dialog.bindEntries[driver]; | ||
343 | } | ||
305 | return configresult; | 344 | return configresult; |
306 | } | 345 | } |
307 | 346 | ||
308 | 347 | ||
309 | EXPORT_OPIE_APPLET_v1( PcmciaManager ) | 348 | EXPORT_OPIE_APPLET_v1( PcmciaManager ) |
310 | 349 | ||
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 | |||
@@ -9,62 +9,62 @@ | |||
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
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 | #ifndef PCMCIA_H | 30 | #ifndef PCMCIA_H |
31 | #define PCMCIA_H | 31 | #define PCMCIA_H |
32 | 32 | ||
33 | #include <qwidget.h> | 33 | #include <qwidget.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | 36 | ||
37 | namespace Opie { namespace Core { class OPcmciaSocket; } }; | 37 | namespace Opie { namespace Core { class OPcmciaSocket; } }; |
38 | 38 | ||
39 | class PcmciaManager : public QWidget | 39 | class PcmciaManager : public QWidget |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | public: | 42 | public: |
43 | PcmciaManager( QWidget *parent = 0 ); | 43 | PcmciaManager( QWidget *parent = 0 ); |
44 | ~PcmciaManager(); | 44 | ~PcmciaManager(); |
45 | static int position(); | 45 | static int position(); |
46 | 46 | ||
47 | private slots: | 47 | private slots: |
48 | void cardMessage( const QCString& msg, const QByteArray& ); | 48 | void cardMessage( const QCString& msg, const QByteArray& ); |
49 | void userCardAction( int action ); | 49 | void userCardAction( int action ); |
50 | void popupTimeout(); | 50 | void popupTimeout(); |
51 | 51 | ||
52 | protected: | 52 | protected: |
53 | void paintEvent( QPaintEvent* ); | 53 | void paintEvent( QPaintEvent* ); |
54 | void mousePressEvent( QMouseEvent * ); | 54 | void mousePressEvent( QMouseEvent * ); |
55 | 55 | ||
56 | private: | 56 | private: |
57 | bool configure( Opie::Core::OPcmciaSocket* ); | 57 | bool configure( Opie::Core::OPcmciaSocket*, QString&, QString&, QString&, QString& ); |
58 | void execCommand( const QStringList &command ); | 58 | void execCommand( const QStringList &command ); |
59 | void popUp(QString message, QString icon = QString::null ); | 59 | void popUp(QString message, QString icon = QString::null ); |
60 | 60 | ||
61 | private: | 61 | private: |
62 | bool configuring; | 62 | bool configuring; |
63 | int commandOrig; | 63 | int commandOrig; |
64 | QPixmap pm; | 64 | QPixmap pm; |
65 | QPopupMenu *popupMenu; | 65 | QPopupMenu *popupMenu; |
66 | 66 | ||
67 | }; | 67 | }; |
68 | 68 | ||
69 | #endif | 69 | #endif |
70 | 70 | ||