-rw-r--r-- | noncore/applets/pcmcia/configdialog.cpp | 52 | ||||
-rw-r--r-- | noncore/applets/pcmcia/configdialog.h | 2 | ||||
-rw-r--r-- | noncore/applets/pcmcia/configdialogbase.ui | 217 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.cpp | 40 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.h | 2 |
5 files changed, 186 insertions, 127 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 | |||
@@ -1,136 +1,146 @@ | |||
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 "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 '%1'" ).arg( card->identity() ) ); | 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 | OConfig cfg( "PCMCIA" ); | 54 | QString action = preferredAction( card ); |
55 | cfg.setGroup( "Global" ); | ||
56 | int nCards = cfg.readNumEntry( "nCards", 0 ); | ||
57 | QString insert; | ||
58 | 55 | ||
59 | for ( int i = 0; i < nCards; ++i ) | 56 | odebug << "preferred action for card '" << card->name() << "' seems to be '" << action << "'" << oendl; |
60 | { | ||
61 | QString cardSection = QString( "Card_%1" ).arg( i ); | ||
62 | cfg.setGroup( cardSection ); | ||
63 | QString name = cfg.readEntry( "name" ); | ||
64 | odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; | ||
65 | if ( card->name() == name ) | ||
66 | { | ||
67 | insert = cfg.readEntry( "insert" ); | ||
68 | break; | ||
69 | } | ||
70 | } | ||
71 | odebug << "preferred action for card '" << card->name() << "' seems to be '" << insert << "'" << oendl; | ||
72 | 57 | ||
73 | if ( !insert.isEmpty() ) | 58 | if ( !action.isEmpty() ) |
74 | { | 59 | { |
75 | for ( int i; i < cbAction->count(); ++i ) | 60 | for ( int i; i < cbAction->count(); ++i ) |
76 | if ( cbAction->text( i ) == insert ) cbAction->setCurrentItem( i ); | 61 | if ( cbAction->text( i ) == action ) cbAction->setCurrentItem( i ); |
77 | } | 62 | } |
78 | 63 | ||
79 | if ( !card->isUnsupported() ) | 64 | if ( !card->isUnsupported() ) |
80 | { | 65 | { |
81 | odebug << "card is recognized - hiding bindings" << oendl; | 66 | odebug << "card is recognized - hiding bindings" << oendl; |
67 | textInfo->hide(); | ||
82 | textBindTo->hide(); | 68 | textBindTo->hide(); |
83 | cbBindTo->hide(); | 69 | cbBindTo->hide(); |
84 | return; | 70 | return; |
85 | } | 71 | } |
86 | else | 72 | else |
87 | { | 73 | { |
88 | odebug << "card is unsupported yet - showing possible bindings" << oendl; | 74 | odebug << "card is unsupported yet - showing possible bindings" << oendl; |
75 | textInfo->show(); | ||
89 | textBindTo->show(); | 76 | textBindTo->show(); |
90 | cbBindTo->show(); | 77 | cbBindTo->show(); |
91 | } | 78 | } |
92 | 79 | ||
93 | // parse possible bind entries out of /etc/pcmcia/*.conf | 80 | // parse possible bind entries out of /etc/pcmcia/*.conf |
94 | typedef QMap<QString,QString> StringMap; | 81 | typedef QMap<QString,QString> StringMap; |
95 | StringMap bindEntries; | 82 | StringMap bindEntries; |
96 | 83 | ||
97 | QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); | 84 | QDir pcmciaconfdir( "/etc/pcmcia", "*.conf" ); |
98 | 85 | ||
99 | for ( int i = 0; i < pcmciaconfdir.count(); ++i ) | 86 | for ( unsigned int i = 0; i < pcmciaconfdir.count(); ++i ) |
100 | { | 87 | { |
101 | odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; | 88 | odebug << "processing conf file '" << pcmciaconfdir[i] << "'" << oendl; |
102 | QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); | 89 | QString conffilename = QString( "%1/%2" ).arg( pcmciaconfdir.absPath() ).arg( pcmciaconfdir[i] ); |
103 | QFile conffile( conffilename ); | 90 | QFile conffile( conffilename ); |
104 | if ( conffile.open( IO_ReadOnly ) ) | 91 | if ( conffile.open( IO_ReadOnly ) ) |
105 | { | 92 | { |
106 | QTextStream ts( &conffile ); | 93 | QTextStream ts( &conffile ); |
107 | while ( !ts.atEnd() ) | 94 | while ( !ts.atEnd() ) |
108 | { | 95 | { |
109 | QString word; | 96 | QString word; |
110 | ts >> word; | 97 | ts >> word; |
111 | if ( word == "bind" ) | 98 | if ( word == "bind" ) |
112 | { | 99 | { |
113 | word = ts.readLine(); | 100 | word = ts.readLine(); |
114 | bindEntries[ word.stripWhiteSpace() ] = conffilename; | 101 | bindEntries[ word.stripWhiteSpace() ] = conffilename; |
115 | continue; | 102 | continue; |
116 | } | 103 | } |
117 | ts.readLine(); | 104 | ts.readLine(); |
118 | } | 105 | } |
119 | } | 106 | } |
120 | else | 107 | else |
121 | { | 108 | { |
122 | owarn << "couldn't open '" << conffile.name() << "' for reading" << oendl; | 109 | owarn << "couldn't open '" << conffile.name() << "' for reading" << oendl; |
123 | continue; | 110 | continue; |
124 | } | 111 | } |
125 | } | 112 | } |
126 | 113 | ||
127 | for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it ) | 114 | for ( StringMap::Iterator it = bindEntries.begin(); it != bindEntries.end(); ++it ) |
128 | { | 115 | { |
129 | odebug << "found binding '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl; | 116 | odebug << "found binding '" << it.key() << "' defined in '" << it.data().latin1() << "'" << oendl; |
130 | cbBindTo->insertItem( it.key() ); | 117 | cbBindTo->insertItem( it.key() ); |
131 | } | 118 | } |
132 | } | 119 | } |
133 | 120 | ||
134 | ConfigDialog::~ConfigDialog() | 121 | ConfigDialog::~ConfigDialog() |
135 | { | 122 | { |
136 | } | 123 | } |
124 | |||
125 | QString ConfigDialog::preferredAction( const OPcmciaSocket* card ) | ||
126 | { | ||
127 | OConfig cfg( "PCMCIA" ); | ||
128 | cfg.setGroup( "Global" ); | ||
129 | int nCards = cfg.readNumEntry( "nCards", 0 ); | ||
130 | QString action; | ||
131 | |||
132 | for ( int i = 0; i < nCards; ++i ) | ||
133 | { | ||
134 | QString cardSection = QString( "Card_%1" ).arg( i ); | ||
135 | cfg.setGroup( cardSection ); | ||
136 | QString name = cfg.readEntry( "name" ); | ||
137 | odebug << "comparing card '" << card->name() << "' with known card '" << name << "'" << oendl; | ||
138 | if ( card->name() == name ) | ||
139 | { | ||
140 | action = cfg.readEntry( "action" ); | ||
141 | break; | ||
142 | } | ||
143 | } | ||
144 | |||
145 | return action; | ||
146 | } | ||
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 | |||
@@ -1,46 +1,46 @@ | |||
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 | class ConfigDialog : public ConfigDialogBase | 37 | class ConfigDialog : public ConfigDialogBase |
38 | { | 38 | { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | public: | 40 | public: |
41 | |||
42 | ConfigDialog( const Opie::Core::OPcmciaSocket* card, QWidget* parent ); | 41 | ConfigDialog( const Opie::Core::OPcmciaSocket* card, QWidget* parent ); |
43 | ~ConfigDialog(); | 42 | ~ConfigDialog(); |
43 | static QString preferredAction( const Opie::Core::OPcmciaSocket* card ); | ||
44 | }; | 44 | }; |
45 | 45 | ||
46 | #endif | 46 | #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 | |||
@@ -1,260 +1,297 @@ | |||
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>197</width> | 14 | <width>215</width> |
15 | <height>154</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>5</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="2" column="2" > | ||
38 | <class>QLabel</class> | ||
39 | <property stdset="1"> | ||
40 | <name>name</name> | ||
41 | <cstring>TextLabel3</cstring> | ||
42 | </property> | ||
43 | <property stdset="1"> | ||
44 | <name>text</name> | ||
45 | <string>card</string> | ||
46 | </property> | ||
47 | </widget> | ||
48 | <widget row="2" column="0" > | ||
49 | <class>QLabel</class> | ||
50 | <property stdset="1"> | ||
51 | <name>name</name> | ||
52 | <cstring>TextLabel2</cstring> | ||
53 | </property> | ||
54 | <property stdset="1"> | ||
55 | <name>text</name> | ||
56 | <string>On insertion,</string> | ||
57 | </property> | ||
58 | </widget> | ||
59 | <widget row="2" column="1" > | ||
60 | <class>QComboBox</class> | ||
61 | <item> | ||
62 | <property> | ||
63 | <name>text</name> | ||
64 | <string>suspend</string> | ||
65 | </property> | ||
66 | </item> | ||
67 | <item> | ||
68 | <property> | ||
69 | <name>text</name> | ||
70 | <string>activate</string> | ||
71 | </property> | ||
72 | </item> | ||
73 | <item> | ||
74 | <property> | ||
75 | <name>text</name> | ||
76 | <string>eject</string> | ||
77 | </property> | ||
78 | </item> | ||
79 | <item> | ||
80 | <property> | ||
81 | <name>text</name> | ||
82 | <string>prompt for</string> | ||
83 | </property> | ||
84 | </item> | ||
85 | <property stdset="1"> | ||
86 | <name>name</name> | ||
87 | <cstring>cbAction</cstring> | ||
88 | </property> | ||
89 | </widget> | ||
90 | <widget row="3" column="1" rowspan="1" colspan="2" > | ||
91 | <class>QComboBox</class> | ||
92 | <property stdset="1"> | ||
93 | <name>name</name> | ||
94 | <cstring>cbBindTo</cstring> | ||
95 | </property> | ||
96 | <property stdset="1"> | ||
97 | <name>sizePolicy</name> | ||
98 | <sizepolicy> | ||
99 | <hsizetype>5</hsizetype> | ||
100 | <vsizetype>0</vsizetype> | ||
101 | </sizepolicy> | ||
102 | </property> | ||
103 | <property stdset="1"> | ||
104 | <name>editable</name> | ||
105 | <bool>true</bool> | ||
106 | </property> | ||
107 | <property stdset="1"> | ||
108 | <name>autoResize</name> | ||
109 | <bool>false</bool> | ||
110 | </property> | ||
111 | </widget> | ||
112 | <widget row="3" column="0" > | ||
113 | <class>QLabel</class> | ||
114 | <property stdset="1"> | ||
115 | <name>name</name> | ||
116 | <cstring>textBindTo</cstring> | ||
117 | </property> | ||
118 | <property stdset="1"> | ||
119 | <name>text</name> | ||
120 | <string>Bind to:</string> | ||
121 | </property> | ||
122 | </widget> | ||
123 | <widget row="0" column="0" rowspan="1" colspan="3" > | 37 | <widget row="0" column="0" rowspan="1" colspan="3" > |
124 | <class>QGroupBox</class> | 38 | <class>QGroupBox</class> |
125 | <property stdset="1"> | 39 | <property stdset="1"> |
126 | <name>name</name> | 40 | <name>name</name> |
127 | <cstring>gbDetails</cstring> | 41 | <cstring>gbDetails</cstring> |
128 | </property> | 42 | </property> |
129 | <property stdset="1"> | 43 | <property stdset="1"> |
130 | <name>title</name> | 44 | <name>title</name> |
131 | <string>Details</string> | 45 | <string>Details</string> |
132 | </property> | 46 | </property> |
133 | <property> | 47 | <property> |
134 | <name>layoutMargin</name> | 48 | <name>layoutMargin</name> |
135 | </property> | 49 | </property> |
136 | <property> | 50 | <property> |
137 | <name>layoutSpacing</name> | 51 | <name>layoutSpacing</name> |
138 | </property> | 52 | </property> |
139 | <grid> | 53 | <grid> |
140 | <property stdset="1"> | 54 | <property stdset="1"> |
141 | <name>margin</name> | 55 | <name>margin</name> |
142 | <number>6</number> | 56 | <number>6</number> |
143 | </property> | 57 | </property> |
144 | <property stdset="1"> | 58 | <property stdset="1"> |
145 | <name>spacing</name> | 59 | <name>spacing</name> |
146 | <number>4</number> | 60 | <number>4</number> |
147 | </property> | 61 | </property> |
148 | <widget row="0" column="0" > | 62 | <widget row="0" column="0" > |
149 | <class>QLabel</class> | 63 | <class>QLabel</class> |
150 | <property stdset="1"> | 64 | <property stdset="1"> |
151 | <name>name</name> | 65 | <name>name</name> |
152 | <cstring>labelCardName</cstring> | 66 | <cstring>labelCardName</cstring> |
153 | </property> | 67 | </property> |
154 | <property stdset="1"> | 68 | <property stdset="1"> |
155 | <name>text</name> | 69 | <name>text</name> |
156 | <string>CardName:</string> | 70 | <string>CardName:</string> |
157 | </property> | 71 | </property> |
158 | </widget> | 72 | </widget> |
159 | <widget row="2" column="0" > | 73 | <widget row="2" column="0" > |
160 | <class>QLabel</class> | 74 | <class>QLabel</class> |
161 | <property stdset="1"> | 75 | <property stdset="1"> |
162 | <name>name</name> | 76 | <name>name</name> |
163 | <cstring>labelFunction</cstring> | 77 | <cstring>labelFunction</cstring> |
164 | </property> | 78 | </property> |
165 | <property stdset="1"> | 79 | <property stdset="1"> |
166 | <name>text</name> | 80 | <name>text</name> |
167 | <string>Function:</string> | 81 | <string>Function:</string> |
168 | </property> | 82 | </property> |
169 | </widget> | 83 | </widget> |
170 | <widget row="1" column="0" > | 84 | <widget row="1" column="0" > |
171 | <class>QLabel</class> | 85 | <class>QLabel</class> |
172 | <property stdset="1"> | 86 | <property stdset="1"> |
173 | <name>name</name> | 87 | <name>name</name> |
174 | <cstring>labelManufacturer</cstring> | 88 | <cstring>labelManufacturer</cstring> |
175 | </property> | 89 | </property> |
176 | <property stdset="1"> | 90 | <property stdset="1"> |
177 | <name>text</name> | 91 | <name>text</name> |
178 | <string>Manufacturer:</string> | 92 | <string>Manufacturer:</string> |
179 | </property> | 93 | </property> |
180 | </widget> | 94 | </widget> |
181 | <widget row="1" column="1" > | 95 | <widget row="1" column="1" > |
182 | <class>QLabel</class> | 96 | <class>QLabel</class> |
183 | <property stdset="1"> | 97 | <property stdset="1"> |
184 | <name>name</name> | 98 | <name>name</name> |
185 | <cstring>txtManfid</cstring> | 99 | <cstring>txtManfid</cstring> |
186 | </property> | 100 | </property> |
187 | <property stdset="1"> | 101 | <property stdset="1"> |
188 | <name>sizePolicy</name> | 102 | <name>sizePolicy</name> |
189 | <sizepolicy> | 103 | <sizepolicy> |
190 | <hsizetype>7</hsizetype> | 104 | <hsizetype>7</hsizetype> |
191 | <vsizetype>1</vsizetype> | 105 | <vsizetype>1</vsizetype> |
192 | </sizepolicy> | 106 | </sizepolicy> |
193 | </property> | 107 | </property> |
194 | <property stdset="1"> | 108 | <property stdset="1"> |
195 | <name>text</name> | 109 | <name>text</name> |
196 | <string>TextLabel6</string> | 110 | <string>TextLabel6</string> |
197 | </property> | 111 | </property> |
198 | </widget> | 112 | </widget> |
199 | <widget row="2" column="1" > | 113 | <widget row="2" column="1" > |
200 | <class>QLabel</class> | 114 | <class>QLabel</class> |
201 | <property stdset="1"> | 115 | <property stdset="1"> |
202 | <name>name</name> | 116 | <name>name</name> |
203 | <cstring>txtFunction</cstring> | 117 | <cstring>txtFunction</cstring> |
204 | </property> | 118 | </property> |
205 | <property stdset="1"> | 119 | <property stdset="1"> |
206 | <name>sizePolicy</name> | 120 | <name>sizePolicy</name> |
207 | <sizepolicy> | 121 | <sizepolicy> |
208 | <hsizetype>7</hsizetype> | 122 | <hsizetype>7</hsizetype> |
209 | <vsizetype>1</vsizetype> | 123 | <vsizetype>1</vsizetype> |
210 | </sizepolicy> | 124 | </sizepolicy> |
211 | </property> | 125 | </property> |
212 | <property stdset="1"> | 126 | <property stdset="1"> |
213 | <name>text</name> | 127 | <name>text</name> |
214 | <string>TextLabel7</string> | 128 | <string>TextLabel7</string> |
215 | </property> | 129 | </property> |
216 | </widget> | 130 | </widget> |
217 | <widget row="0" column="1" > | 131 | <widget row="0" column="1" > |
218 | <class>QLabel</class> | 132 | <class>QLabel</class> |
219 | <property stdset="1"> | 133 | <property stdset="1"> |
220 | <name>name</name> | 134 | <name>name</name> |
221 | <cstring>txtCardName</cstring> | 135 | <cstring>txtCardName</cstring> |
222 | </property> | 136 | </property> |
223 | <property stdset="1"> | 137 | <property stdset="1"> |
224 | <name>sizePolicy</name> | 138 | <name>sizePolicy</name> |
225 | <sizepolicy> | 139 | <sizepolicy> |
226 | <hsizetype>7</hsizetype> | 140 | <hsizetype>7</hsizetype> |
227 | <vsizetype>1</vsizetype> | 141 | <vsizetype>1</vsizetype> |
228 | </sizepolicy> | 142 | </sizepolicy> |
229 | </property> | 143 | </property> |
230 | <property stdset="1"> | 144 | <property stdset="1"> |
231 | <name>text</name> | 145 | <name>text</name> |
232 | <string>TextLabel3</string> | 146 | <string>TextLabel3</string> |
233 | </property> | 147 | </property> |
234 | </widget> | 148 | </widget> |
235 | </grid> | 149 | </grid> |
236 | </widget> | 150 | </widget> |
237 | <spacer row="1" column="1" > | 151 | <widget row="1" 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> | ||
206 | <property stdset="1"> | ||
207 | <name>name</name> | ||
208 | <cstring>textBindTo</cstring> | ||
209 | </property> | ||
210 | <property stdset="1"> | ||
211 | <name>text</name> | ||
212 | <string>Bind to:</string> | ||
213 | </property> | ||
214 | </widget> | ||
215 | <widget row="4" column="1" rowspan="1" colspan="2" > | ||
216 | <class>QComboBox</class> | ||
217 | <item> | ||
218 | <property> | ||
219 | <name>text</name> | ||
220 | <string><None></string> | ||
221 | </property> | ||
222 | </item> | ||
223 | <property stdset="1"> | ||
224 | <name>name</name> | ||
225 | <cstring>cbBindTo</cstring> | ||
226 | </property> | ||
227 | <property stdset="1"> | ||
228 | <name>sizePolicy</name> | ||
229 | <sizepolicy> | ||
230 | <hsizetype>5</hsizetype> | ||
231 | <vsizetype>0</vsizetype> | ||
232 | </sizepolicy> | ||
233 | </property> | ||
234 | <property stdset="1"> | ||
235 | <name>editable</name> | ||
236 | <bool>true</bool> | ||
237 | </property> | ||
238 | <property stdset="1"> | ||
239 | <name>currentItem</name> | ||
240 | <number>0</number> | ||
241 | </property> | ||
242 | <property stdset="1"> | ||
243 | <name>autoResize</name> | ||
244 | <bool>false</bool> | ||
245 | </property> | ||
246 | </widget> | ||
247 | <widget row="3" column="0" rowspan="1" colspan="3" > | ||
248 | <class>QLabel</class> | ||
249 | <property stdset="1"> | ||
250 | <name>name</name> | ||
251 | <cstring>textInfo</cstring> | ||
252 | </property> | ||
253 | <property stdset="1"> | ||
254 | <name>frameShape</name> | ||
255 | <enum>Box</enum> | ||
256 | </property> | ||
257 | <property stdset="1"> | ||
258 | <name>frameShadow</name> | ||
259 | <enum>Raised</enum> | ||
260 | </property> | ||
261 | <property stdset="1"> | ||
262 | <name>lineWidth</name> | ||
263 | <number>2</number> | ||
264 | </property> | ||
265 | <property stdset="1"> | ||
266 | <name>margin</name> | ||
267 | <number>0</number> | ||
268 | </property> | ||
269 | <property stdset="1"> | ||
270 | <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> | ||
272 | </property> | ||
273 | </widget> | ||
274 | <spacer row="2" column="1" > | ||
238 | <property> | 275 | <property> |
239 | <name>name</name> | 276 | <name>name</name> |
240 | <cstring>Spacer1</cstring> | 277 | <cstring>Spacer2</cstring> |
241 | </property> | 278 | </property> |
242 | <property stdset="1"> | 279 | <property stdset="1"> |
243 | <name>orientation</name> | 280 | <name>orientation</name> |
244 | <enum>Vertical</enum> | 281 | <enum>Vertical</enum> |
245 | </property> | 282 | </property> |
246 | <property stdset="1"> | 283 | <property stdset="1"> |
247 | <name>sizeType</name> | 284 | <name>sizeType</name> |
248 | <enum>Expanding</enum> | 285 | <enum>Expanding</enum> |
249 | </property> | 286 | </property> |
250 | <property> | 287 | <property> |
251 | <name>sizeHint</name> | 288 | <name>sizeHint</name> |
252 | <size> | 289 | <size> |
253 | <width>20</width> | 290 | <width>20</width> |
254 | <height>20</height> | 291 | <height>20</height> |
255 | </size> | 292 | </size> |
256 | </property> | 293 | </property> |
257 | </spacer> | 294 | </spacer> |
258 | </grid> | 295 | </grid> |
259 | </widget> | 296 | </widget> |
260 | </UI> | 297 | </UI> |
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 | |||
@@ -14,285 +14,297 @@ | |||
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/resource.h> | 42 | #include <qpe/resource.h> |
43 | using namespace Opie::Core; | 43 | using namespace Opie::Core; |
44 | using namespace Opie::Ui; | 44 | using namespace Opie::Ui; |
45 | 45 | ||
46 | /* QT */ | 46 | /* QT */ |
47 | #include <qcopchannel_qws.h> | 47 | #include <qcopchannel_qws.h> |
48 | #include <qpainter.h> | 48 | #include <qpainter.h> |
49 | #include <qfile.h> | 49 | #include <qfile.h> |
50 | #include <qtextstream.h> | 50 | #include <qtextstream.h> |
51 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
52 | #include <qsound.h> | 52 | #include <qsound.h> |
53 | #include <qtimer.h> | 53 | #include <qtimer.h> |
54 | 54 | ||
55 | /* STD */ | 55 | /* STD */ |
56 | #include <stdio.h> | 56 | #include <stdio.h> |
57 | #include <unistd.h> | 57 | #include <unistd.h> |
58 | #include <stdlib.h> | 58 | #include <stdlib.h> |
59 | #include <string.h> | 59 | #include <string.h> |
60 | #include <errno.h> | 60 | #include <errno.h> |
61 | #include <fcntl.h> | 61 | #include <fcntl.h> |
62 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 62 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
63 | #include <sys/vfs.h> | 63 | #include <sys/vfs.h> |
64 | #include <mntent.h> | 64 | #include <mntent.h> |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) | 67 | PcmciaManager::PcmciaManager( QWidget * parent ) : QWidget( parent ) |
68 | { | 68 | { |
69 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 69 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
70 | connect( pcmciaChannel, | 70 | connect( pcmciaChannel, |
71 | SIGNAL( received(const QCString&,const QByteArray&) ), this, | 71 | SIGNAL( received(const QCString&,const QByteArray&) ), this, |
72 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); | 72 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); |
73 | 73 | ||
74 | setFocusPolicy( NoFocus ); | 74 | setFocusPolicy( NoFocus ); |
75 | setFixedWidth ( AppLnk::smallIconSize() ); | 75 | setFixedWidth ( AppLnk::smallIconSize() ); |
76 | setFixedHeight ( AppLnk::smallIconSize() ); | 76 | setFixedHeight ( AppLnk::smallIconSize() ); |
77 | pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ); | 77 | pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ); |
78 | configuring = false; | 78 | configuring = false; |
79 | } | 79 | } |
80 | 80 | ||
81 | 81 | ||
82 | PcmciaManager::~PcmciaManager() | 82 | PcmciaManager::~PcmciaManager() |
83 | { | 83 | { |
84 | } | 84 | } |
85 | 85 | ||
86 | 86 | ||
87 | void PcmciaManager::popUp( QString message, QString icon ) | 87 | void PcmciaManager::popUp( QString message, QString icon ) |
88 | { | 88 | { |
89 | if ( !popupMenu ) { | 89 | if ( !popupMenu ) { |
90 | popupMenu = new QPopupMenu( this ); | 90 | popupMenu = new QPopupMenu( this ); |
91 | } | 91 | } |
92 | 92 | ||
93 | popupMenu->clear(); | 93 | popupMenu->clear(); |
94 | if ( icon.isEmpty() ) { | 94 | if ( icon.isEmpty() ) { |
95 | popupMenu->insertItem( message, 0 ); | 95 | popupMenu->insertItem( message, 0 ); |
96 | } else { | 96 | } else { |
97 | popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ), | 97 | popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ), |
98 | message, 0 ); | 98 | message, 0 ); |
99 | } | 99 | } |
100 | 100 | ||
101 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 101 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
102 | QSize s = popupMenu->sizeHint(); | 102 | QSize s = popupMenu->sizeHint(); |
103 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), | 103 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), |
104 | p.y() - s.height() ), 0 ); | 104 | p.y() - s.height() ), 0 ); |
105 | 105 | ||
106 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); | 106 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); |
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | void PcmciaManager::popupTimeout() | 110 | void PcmciaManager::popupTimeout() |
111 | { | 111 | { |
112 | popupMenu->hide(); | 112 | popupMenu->hide(); |
113 | } | 113 | } |
114 | 114 | ||
115 | enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE }; | 115 | enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE }; |
116 | 116 | ||
117 | void PcmciaManager::mousePressEvent( QMouseEvent* ) | 117 | void PcmciaManager::mousePressEvent( QMouseEvent* ) |
118 | { | 118 | { |
119 | QPopupMenu* menu = new QPopupMenu( this ); | 119 | QPopupMenu* menu = new QPopupMenu( this ); |
120 | QStringList cmd; | 120 | QStringList cmd; |
121 | bool execute = true; | 121 | bool execute = true; |
122 | 122 | ||
123 | OPcmciaSystem* sys = OPcmciaSystem::instance(); | 123 | OPcmciaSystem* sys = OPcmciaSystem::instance(); |
124 | OPcmciaSystem::CardIterator it = sys->iterator(); | 124 | OPcmciaSystem::CardIterator it = sys->iterator(); |
125 | if ( !sys->count() ) return; | 125 | if ( !sys->count() ) return; |
126 | 126 | ||
127 | int i = 0; | 127 | int i = 0; |
128 | while ( it.current() ) | 128 | while ( it.current() ) |
129 | { | 129 | { |
130 | QPopupMenu* submenu = new QPopupMenu( menu ); | 130 | QPopupMenu* submenu = new QPopupMenu( menu ); |
131 | submenu->insertItem( "&Eject", EJECT+i*100 ); | 131 | submenu->insertItem( "&Eject", EJECT+i*100 ); |
132 | submenu->insertItem( "&Insert", INSERT+i*100 ); | 132 | submenu->insertItem( "&Insert", INSERT+i*100 ); |
133 | submenu->insertItem( "&Suspend", SUSPEND+i*100 ); | 133 | submenu->insertItem( "&Suspend", SUSPEND+i*100 ); |
134 | submenu->insertItem( "&Resume", RESUME+i*100 ); | 134 | submenu->insertItem( "&Resume", RESUME+i*100 ); |
135 | submenu->insertItem( "Rese&t", RESET+i*100 ); | 135 | submenu->insertItem( "Rese&t", RESET+i*100 ); |
136 | submenu->insertItem( "&Configure", CONFIGURE+i*100 ); | 136 | submenu->insertItem( "&Configure", CONFIGURE+i*100 ); |
137 | 137 | ||
138 | submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); | 138 | submenu->setItemEnabled( EJECT+i*100, !it.current()->isEmpty() ); |
139 | submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); | 139 | submenu->setItemEnabled( INSERT+i*100, it.current()->isEmpty() ); |
140 | submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); | 140 | submenu->setItemEnabled( SUSPEND+i*100, !it.current()->isEmpty() && it.current()->isSuspended() ); |
141 | submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); | 141 | submenu->setItemEnabled( RESUME+i*100, !it.current()->isEmpty() && !it.current()->isSuspended() ); |
142 | submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() && !configuring ); | 142 | submenu->setItemEnabled( CONFIGURE+i*100, !it.current()->isEmpty() && !configuring ); |
143 | 143 | ||
144 | connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); | 144 | connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); |
145 | menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); | 145 | menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); |
146 | ++it; | 146 | ++it; |
147 | } | 147 | } |
148 | 148 | ||
149 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 149 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
150 | QSize s = menu->sizeHint(); | 150 | QSize s = menu->sizeHint(); |
151 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); | 151 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); |
152 | qDebug( "pcmcia: menu result = %d", opt ); | 152 | qDebug( "pcmcia: menu result = %d", opt ); |
153 | delete menu; | 153 | delete menu; |
154 | } | 154 | } |
155 | 155 | ||
156 | 156 | ||
157 | void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) | 157 | void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) |
158 | { | 158 | { |
159 | odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl; | 159 | odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl; |
160 | if ( msg != "stabChanged()" ) return; | 160 | if ( msg != "stabChanged()" ) return; |
161 | 161 | ||
162 | /* check if a previously unknown card has been inserted */ | 162 | /* check if a previously unknown card has been inserted */ |
163 | OPcmciaSystem::instance()->synchronize(); | 163 | OPcmciaSystem::instance()->synchronize(); |
164 | 164 | ||
165 | if ( !OPcmciaSystem::instance()->cardCount() ) return; | 165 | if ( !OPcmciaSystem::instance()->cardCount() ) return; |
166 | 166 | ||
167 | OConfig cfg( "PCMCIA" ); | 167 | OConfig cfg( "PCMCIA" ); |
168 | cfg.setGroup( "Global" ); | 168 | cfg.setGroup( "Global" ); |
169 | int nCards = cfg.readNumEntry( "nCards", 0 ); | 169 | int nCards = cfg.readNumEntry( "nCards", 0 ); |
170 | 170 | ||
171 | OPcmciaSystem* sys = OPcmciaSystem::instance(); | 171 | OPcmciaSystem* sys = OPcmciaSystem::instance(); |
172 | OPcmciaSystem::CardIterator it = sys->iterator(); | 172 | OPcmciaSystem::CardIterator it = sys->iterator(); |
173 | 173 | ||
174 | bool newCard = true; | 174 | bool newCard = true; |
175 | OPcmciaSocket* theCard = 0; | 175 | OPcmciaSocket* theCard = 0; |
176 | 176 | ||
177 | while ( it.current() && newCard ) | 177 | while ( it.current() && newCard ) |
178 | { | 178 | { |
179 | if ( it.current()->isEmpty() ) | 179 | if ( it.current()->isEmpty() ) |
180 | { | 180 | { |
181 | odebug << "skipping empty card in socket " << it.current()->number() << oendl; | 181 | odebug << "skipping empty card in socket " << it.current()->number() << oendl; |
182 | ++it; | 182 | ++it; |
183 | continue; | 183 | continue; |
184 | } | 184 | } |
185 | else | 185 | else |
186 | { | 186 | { |
187 | theCard = it.current(); | 187 | theCard = it.current(); |
188 | QString cardName = theCard->productIdentity().join( " " ); | 188 | QString cardName = theCard->productIdentity().join( " " ); |
189 | for ( int i = 0; i < nCards; ++i ) | 189 | for ( int i = 0; i < nCards; ++i ) |
190 | { | 190 | { |
191 | QString cardSection = QString( "Card_%1" ).arg( i ); | 191 | QString cardSection = QString( "Card_%1" ).arg( i ); |
192 | cfg.setGroup( cardSection ); | 192 | cfg.setGroup( cardSection ); |
193 | QString name = cfg.readEntry( "name" ); | 193 | QString name = cfg.readEntry( "name" ); |
194 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; | 194 | odebug << "comparing card '" << cardName << "' with known card '" << name << "'" << oendl; |
195 | if ( cardName == name ) | 195 | if ( cardName == name ) |
196 | { | 196 | { |
197 | newCard = false; | 197 | newCard = false; |
198 | break; | 198 | break; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | if ( !newCard ) ++it; else break; | 201 | if ( !newCard ) ++it; else break; |
202 | } | 202 | } |
203 | } | 203 | } |
204 | if ( newCard ) | 204 | if ( newCard ) |
205 | { | 205 | { |
206 | odebug << "pcmcia: new card detected" << oendl; | 206 | odebug << "pcmcia: unconfigured card detected" << oendl; |
207 | cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); | 207 | QString newCardName = theCard->productIdentity().join( " " ).stripWhiteSpace(); |
208 | cfg.writeEntry( "name", theCard->productIdentity().join( " " ) ); | ||
209 | cfg.writeEntry( "insert", "suspend" ); | ||
210 | cfg.setGroup( "Global" ); | ||
211 | cfg.writeEntry( "nCards", nCards+1 ); | ||
212 | cfg.write(); | ||
213 | |||
214 | int result = QMessageBox::information( qApp->desktop(), | 208 | int result = QMessageBox::information( qApp->desktop(), |
215 | tr( "PCMCIA/CF Subsystem" ), | 209 | tr( "PCMCIA/CF Subsystem" ), |
216 | tr( "You have inserted a new card:\n%1\nDo you want to configure?" ).arg( theCard->productIdentity().join( " " ) ), | 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 ), |
217 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ); | 211 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ); |
218 | odebug << "result = " << result << oendl; | 212 | odebug << "result = " << result << oendl; |
219 | if ( result == 0 ) | 213 | if ( result == 0 ) |
220 | { | 214 | { |
221 | configure( theCard ); | 215 | bool configured = configure( theCard ); |
216 | |||
217 | if ( configured ) | ||
218 | { | ||
219 | odebug << "card has been configured. writing out to dabase" << oendl; | ||
220 | cfg.setGroup( QString( "Card_%1" ).arg( nCards ) ); | ||
221 | cfg.writeEntry( "name", newCardName ); | ||
222 | cfg.writeEntry( "insert", "suspend" ); | ||
223 | cfg.setGroup( "Global" ); | ||
224 | cfg.writeEntry( "nCards", nCards+1 ); | ||
225 | cfg.write(); | ||
226 | } | ||
227 | else | ||
228 | { | ||
229 | odebug << "card has not been configured this time. leaving as unknown card" << oendl; | ||
230 | } | ||
222 | } | 231 | } |
223 | else | 232 | else |
224 | { | 233 | { |
225 | odebug << "pcmcia: user doesn't want to configure " << theCard->productIdentity().join( " " ) << " now." << oendl; | 234 | odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl; |
226 | } | 235 | } |
227 | } | 236 | } |
228 | else | 237 | else // it's an already configured card |
229 | { | 238 | { |
230 | odebug << "pcmcia: card has been previously inserted" << oendl; | 239 | QString action = ConfigDialog::preferredAction( theCard ); |
240 | odebug << "pcmcia: card has been previously configured" << oendl; | ||
241 | odebug << "pcmcia: need to perform action'" << action << "' now... sorry, not yet implemented..." << oendl; | ||
231 | } | 242 | } |
232 | repaint( true ); | 243 | repaint( true ); |
233 | } | 244 | } |
234 | 245 | ||
235 | 246 | ||
236 | void PcmciaManager::paintEvent( QPaintEvent * ) | 247 | void PcmciaManager::paintEvent( QPaintEvent * ) |
237 | { | 248 | { |
238 | QPainter p( this ); | 249 | QPainter p( this ); |
239 | odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl; | 250 | odebug << "sockets = " << OPcmciaSystem::instance()->count() << ", cards = " << OPcmciaSystem::instance()->cardCount() << oendl; |
240 | 251 | ||
241 | if ( OPcmciaSystem::instance()->cardCount() ) | 252 | if ( OPcmciaSystem::instance()->cardCount() ) |
242 | { | 253 | { |
243 | p.drawPixmap( 0, 0, pm ); | 254 | p.drawPixmap( 0, 0, pm ); |
244 | show(); | 255 | show(); |
245 | } | 256 | } |
246 | else | 257 | else |
247 | { | 258 | { |
248 | hide(); | 259 | hide(); |
249 | } | 260 | } |
250 | } | 261 | } |
251 | 262 | ||
252 | int PcmciaManager::position() | 263 | int PcmciaManager::position() |
253 | { | 264 | { |
254 | return 7; | 265 | return 7; |
255 | } | 266 | } |
256 | 267 | ||
257 | void PcmciaManager::execCommand( const QStringList &strList ) | 268 | void PcmciaManager::execCommand( const QStringList &strList ) |
258 | { | 269 | { |
259 | } | 270 | } |
260 | 271 | ||
261 | void PcmciaManager::userCardAction( int action ) | 272 | void PcmciaManager::userCardAction( int action ) |
262 | { | 273 | { |
263 | odebug << "user action on socket " << action / 100 << " requested. action = " << action << oendl; | 274 | odebug << "user action on socket " << action / 100 << " requested. action = " << action << oendl; |
264 | 275 | ||
265 | int socket = action / 100; | 276 | int socket = action / 100; |
266 | int what = action % 100; | 277 | int what = action % 100; |
267 | bool success = false; | 278 | bool success = false; |
268 | 279 | ||
269 | switch ( what ) | 280 | switch ( what ) |
270 | { | 281 | { |
271 | case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); success = true; break; | 282 | case CONFIGURE: configure( OPcmciaSystem::instance()->socket( socket ) ); success = true; break; |
272 | case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break; | 283 | case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break; |
273 | case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break; | 284 | case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break; |
274 | case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break; | 285 | case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break; |
275 | case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break; | 286 | case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break; |
276 | case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break; | 287 | case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break; |
277 | default: odebug << "not yet implemented" << oendl; | 288 | default: odebug << "not yet implemented" << oendl; |
278 | } | 289 | } |
279 | 290 | ||
280 | if ( !success ) | 291 | if ( !success ) |
281 | { | 292 | { |
282 | owarn << "couldn't perform user action (" << strerror( errno ) << ")" << oendl; | 293 | owarn << "couldn't perform user action (" << strerror( errno ) << ")" << oendl; |
283 | } | 294 | } |
284 | 295 | ||
285 | } | 296 | } |
286 | 297 | ||
287 | void PcmciaManager::configure( OPcmciaSocket* card ) | 298 | bool PcmciaManager::configure( OPcmciaSocket* card ) |
288 | { | 299 | { |
289 | configuring = true; | 300 | configuring = true; |
290 | ConfigDialog dialog( card, qApp->desktop() ); | 301 | ConfigDialog dialog( card, qApp->desktop() ); |
291 | int configresult = QPEApplication::execDialog( &dialog, false ); | 302 | int configresult = QPEApplication::execDialog( &dialog, false ); |
292 | configuring = false; | 303 | configuring = false; |
293 | odebug << "pcmcia: configresult = " << configresult << oendl; | 304 | odebug << "pcmcia: configresult = " << configresult << oendl; |
305 | return configresult; | ||
294 | } | 306 | } |
295 | 307 | ||
296 | 308 | ||
297 | EXPORT_OPIE_APPLET_v1( PcmciaManager ) | 309 | EXPORT_OPIE_APPLET_v1( PcmciaManager ) |
298 | 310 | ||
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 | |||
@@ -1,70 +1,70 @@ | |||
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 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 | void configure( Opie::Core::OPcmciaSocket* ); | 57 | bool configure( Opie::Core::OPcmciaSocket* ); |
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 | ||